Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New DX12 backend (unfinished) #1602

Merged
merged 33 commits into from
Jul 13, 2021
Merged

New DX12 backend (unfinished) #1602

merged 33 commits into from
Jul 13, 2021

Conversation

kvark
Copy link
Member

@kvark kvark commented Jul 5, 2021

Connections
Continuation of #1471

Description
Mostly fresh implementation on DX12 backend for wgpu-hal
Core changes:

  • texture usage is filtered before passing to create_texture_view, so that wgpu-hal can assume every bit is important.
  • all the copies involving textures are limited to one array layer at a time
  • remove render pass boundary usages

Testing
Examples (not running yet)

@niklaskorz
Copy link
Contributor

Out of interest, what benefits does the winapi crate have over Microsoft's official windows-rs crate which also includes bindings for DX12?

@Gordon-F
Copy link
Contributor

Gordon-F commented Jul 5, 2021

Out of interest, what benefits does the winapi crate have over Microsoft's official windows-rs crate which also includes bindings for DX12

Related discussion in winit - rust-windowing/winit#1938

@kvark kvark force-pushed the dx12 branch 4 times, most recently from 222c97d to 07847fb Compare July 9, 2021 19:43
@kvark kvark marked this pull request as ready for review July 13, 2021 05:12
@kvark
Copy link
Member Author

kvark commented Jul 13, 2021

I think it's at the point where we can merge and follow-up. I'm not able to test it thoroughly because of Naga's HLSL backend, which needs work. I'll be collaborating with @Gordon-F on this one, and in the meantime DX12 is removed from the PRIMARY set of backends.

Another thing missing is rebinding all the bindings. Currently, the only lazy state is vertex buffers, because of gpuweb/gpuweb#1921. However, DX12 prescribes all the bindings to be reset on any layout change. This is unfortunate, since wgpu-core's handling of Vulkan pipeline compatibility is wasted, and we have to have more lazy state in DX12 now... See also - gpuweb/gpuweb#1926 . More specifically, this makes the whole binding model to be one giant lazy state.

@kvark kvark changed the title [early WIP] New DX12 backend New DX12 backend (unfinished) Jul 13, 2021
@kvark
Copy link
Member Author

kvark commented Jul 13, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 13, 2021

@bors bors bot merged commit 0f784bb into gfx-rs:master Jul 13, 2021
@kvark kvark deleted the dx12 branch July 13, 2021 22:37
bors bot added a commit that referenced this pull request Jul 15, 2021
1661: dx12/hal: invalidate root elements on signature change r=kvark a=kvark

**Connections**
A follow-up to #1602, which I hesitated to implement, but now it doesn't sound like there is any choice we have.

**Description**
D3D12's root signature is internally mapped to device's physical descriptors. But this mapping isn't guaranteed to have any properties. That is, any changes to the root signature mean that all of the bound resources need to be invalidated...

It's a bit unfortunate. gfx-backend-dx12 did a lazy flushing approach at draw call. In wgpu-hal I tried to be more aggressive, and we are rebinding everything as it goes. We can choose to go lazy if we want - this PR introduces the necessary logic and infrastructure to do so.

**Testing**
Untested.


Co-authored-by: Dzmitry Malyshau <[email protected]>
bors bot added a commit that referenced this pull request Jul 15, 2021
1663: hal/dx12: flip the root signature upside down r=kvark a=kvark

**Connections**
Another follow-up to #1602

**Description**
Apparently, Microsoft recommends putting most frequently changed stuff at the bottom of root signature.

**Testing**
Unable to test yet.


Co-authored-by: Dzmitry Malyshau <[email protected]>
bors bot added a commit that referenced this pull request Jul 15, 2021
1664: hal/dx12: reset scissor and viewport r=kvark a=kvark

**Connections**
Follow-up to #1602 that actually makes it render!

**Description**
"hello-triange" and "msaa-line" examples work now.
Everything else is blocked on Naga's HLSL output, starting from gfx-rs/naga#1086

**Testing**
Ran the examples :)


Co-authored-by: Dzmitry Malyshau <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants