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

Depth target gets cleared before compute pass when previously used as attachement without storing values #4146

Closed
AnotherNathan opened this issue Sep 16, 2023 · 1 comment · Fixed by #4147
Labels
area: api Issues related to API surface area: documentation Documentation for crate items, public or private

Comments

@AnotherNathan
Copy link

Description
Occurs with the following sequence

  • render pass that clears targets and stores depth values
  • render pass that does not clear targets and does not store depth values
  • (wgpu clears depth target internally)
  • depth target gets used as texture_depth_2d in compute pass (and has now all 0 values) -> I would have expected to still have the depth values from the first render pass available here

Repro steps
see the attached example

Expected vs observed behavior
I would expect that the depth target does not get cleared when running the compute pass.

Extra materials
The attached zip contains a minimal example of the issue.

Platform
Windows 10
wgpu 0.17 and master on Vulkan backend
RX 570 driver version 21.50.21.11

wgpu-depth-clear-bug.zip

@Wumpf
Copy link
Member

Wumpf commented Sep 16, 2023

Thank you so much for the nice repro sample!

The issue here is a (I think re-occuring) miss-understanding with the store bool flag: If it's false then the content of the buffer may be discarded. This means that after any store false operation, the texture is in an undetermined state, thus forcing wgpu-core to clear it out the next time a read operation on it occurs.

Imho this is super unclear from the API as-is. I think wgpu should expose the wgpu-core Store-Op as is instead of putting a boolean there:

pub enum StoreOp {
    /// Discards the content of the render target.
    ///
    /// If you don't care about the contents of the target, this can be faster.
    Discard = 0,
    /// Store the result of the renderpass.
    Store = 1,
}

See also https://www.w3.org/TR/webgpu/#load-and-store-ops

@Wumpf Wumpf added area: api Issues related to API surface area: documentation Documentation for crate items, public or private labels Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API surface area: documentation Documentation for crate items, public or private
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants