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

Zero init textures #1688

Merged
merged 24 commits into from
Oct 28, 2021
Merged

Zero init textures #1688

merged 24 commits into from
Oct 28, 2021

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Jul 18, 2021

Connections
Fixes #1102
Some preparatory work happened in: #2081, #2046, #1905, #1839

Description
Implements zero texture init using some of the same building blocks & patterns already used for buffer zero init.

Moved "inter-submit" init code to a new mod which also has utlitities to tackle the rare texure inits ("fixups") that may happen due to a discarded texture being used within an encoder/cmd-buf. The machinery for this is a bit clunky right now and may be improved down the line.
Special-special handling is given for depth/stencil discards, there are comment blocks that should explain the situation and approach (if those aren't clear enough this needs fixing as well).

Testing
Started out with new / rearranged player tests. For testing the more complicated sideffects of render target discards, a new regular unit test is added.
Overall, I believe testing is about the bare minimum that we can run with for now, but devising good ones is challenging on its own as so often.

sadly, they are typically passing even if texture zero init isn't doing its job
However, they form nice isolated examples for testing out texture initialization
It could be possible to dirty texture memory prior to ensure zero init did the job
* queue submit
* write_texture
enforce COPY_DST usage now on all textures
init_tracker has now a `discard` function to get single data points back to uninitialized

use new standardized partition_point function
missing:
* init on the fly if discarded is found within command buffer
* handle discarding only stencil or only depth
…through utility function

allows to resolve discard/init_action interactions
CommandBufferTextureMemoryActions is now fully encapsulated
@Wumpf Wumpf changed the title [draft] Zero init textures Zero init textures Oct 24, 2021
@Wumpf Wumpf marked this pull request as ready for review October 24, 2021 17:31
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done the first review pass. This is grand piece of work!
When the group was deciding to zero-init resources, I didn't expect this to be associated with so much complexity. And I hoped this would work together with the state tracker, while you've shown that it's better off to be a completely independent system.

wgpu-core/src/command/memory_init.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/memory_init.rs Show resolved Hide resolved
wgpu/tests/zero_init_texture_after_discard.rs Outdated Show resolved Hide resolved
wgpu/tests/zero_init_texture_after_discard.rs Outdated Show resolved Hide resolved
wgpu/tests/zero_init_texture_after_discard.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/memory_init.rs Show resolved Hide resolved
wgpu-core/src/command/memory_init.rs Show resolved Hide resolved
wgpu-core/src/command/memory_init.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/memory_init.rs Show resolved Hide resolved
wgpu-core/src/command/memory_init.rs Outdated Show resolved Hide resolved
@Wumpf
Copy link
Member Author

Wumpf commented Oct 25, 2021

I didn't expect this to be associated with so much complexity

neither did I. Very unlikely I would have promised to look after this thing if I knew 😄
how does the old saying go, we don't do these things because they are easy, we do them because we thought they were easy

@kvark
Copy link
Member

kvark commented Oct 28, 2021

We have a bit of clippy complains, otherwise let's ship it!

@kvark kvark merged commit 9887169 into gfx-rs:master Oct 28, 2021
@Wumpf Wumpf deleted the zero-init-textures branch October 28, 2021 19:28
@Wumpf
Copy link
Member Author

Wumpf commented Oct 28, 2021

🥳 finally, what a relief!

waywardmonkeys added a commit to waywardmonkeys/wgpu that referenced this pull request Feb 5, 2024
When no work is submitted for a frame, presenting the surface results
in a timeout due to no work having been submitted.

Fixes gfx-rs#3189.

This flag was added in gfx-rs#1892 with a note that it was going to be
temporary until gfx-rs#1688 landed.
waywardmonkeys added a commit to waywardmonkeys/wgpu that referenced this pull request Feb 5, 2024
When no work is submitted for a frame, presenting the surface results
in a timeout due to no work having been submitted.

Fixes gfx-rs#3189.

This flag was added in gfx-rs#1892 with a note that it was going to be
temporary until gfx-rs#1688 landed.
waywardmonkeys added a commit to waywardmonkeys/wgpu that referenced this pull request Feb 5, 2024
When no work is submitted for a frame, presenting the surface results
in a timeout due to no work having been submitted.

Fixes gfx-rs#3189.

This flag was added in gfx-rs#1892 with a note that it was going to be
temporary until gfx-rs#1688 landed.
nical pushed a commit that referenced this pull request Feb 9, 2024
When no work is submitted for a frame, presenting the surface results
in a timeout due to no work having been submitted.

Fixes #3189.

This flag was added in #1892 with a note that it was going to be
temporary until #1688 landed.
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.

Initialize texture sub-resources to zero
2 participants