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

Validation error with Depth buffers #384

Closed
cloudhead opened this issue Nov 26, 2019 · 10 comments
Closed

Validation error with Depth buffers #384

cloudhead opened this issue Nov 26, 2019 · 10 comments
Assignees
Labels
type: bug Something isn't working

Comments

@cloudhead
Copy link
Contributor

I'm getting the following validation error when using depth writing/testing in certain cases:

[2019-11-26T22:42:24Z ERROR gfx_backend_vulkan]
VALIDATION [VUID-VkImageSubresource-aspectMask-parameter (0)] : vkCmdPipelineBarrier(): Depth-only image formats must have the VK_IMAGE_ASPECT_DEPTH_BIT set. The Vulkan spec states: aspectMask must be a valid combination of VkImageAspectFlagBits values (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkImageSubresource-aspectMask-parameter)
object info: (type: IMAGE, hndl: 116)

I don't know if I'm doing anything wrong, since things work as expected.. the relevant part of my pipeline config looks like this:

            .create_render_pipeline(&wgpu::RenderPipelineDescriptor {
             ...
                rasterization_state: Some(wgpu::RasterizationStateDescriptor {
                    front_face: wgpu::FrontFace::Ccw,
                    cull_mode: wgpu::CullMode::None,
                    depth_bias: 0,
                    depth_bias_slope_scale: 0.0,
                    depth_bias_clamp: 0.0,
                }),
...
                depth_stencil_state: Some(wgpu::DepthStencilStateDescriptor {
                    format: wgpu::TextureFormat::Depth32Float,
                    depth_write_enabled: true,
                    depth_compare: wgpu::CompareFunction::LessEqual,
                    stencil_front: wgpu::StencilStateFaceDescriptor::IGNORE,
                    stencil_back: wgpu::StencilStateFaceDescriptor::IGNORE,
                    stencil_read_mask: 0,
                    stencil_write_mask: 0,
                }),
                index_format: wgpu::IndexFormat::Uint16,
                vertex_buffers: &[vertex_attrs],
                sample_count: 1,
                sample_mask: !0,
                alpha_to_coverage_enabled: false,
            });
@cloudhead
Copy link
Contributor Author

The depth textures only have

usage: wgpu::TextureUsage::COPY_DST | wgpu::TextureUsage::OUTPUT_ATTACHMENT

@kvark
Copy link
Member

kvark commented Nov 27, 2019

Thank you for the report! Is this on wgpu-0.4 or master?
It would be useful to know exactly, which line of code triggers this.

@cloudhead
Copy link
Contributor Author

This is wgpu 0.4. I’ll try and narrow it down to the line of code! I could also try master if the API hasn’t changed.

@cloudhead
Copy link
Contributor Author

So the offending line is:

        encoder.copy_buffer_to_texture(
            wgpu::BufferCopyView {
                buffer,
                offset: 0,
                row_pitch: 4 * w,
                image_height: h,
            },
            wgpu::TextureCopyView {
                texture,
                mip_level: 0,
                array_layer: 0,
                origin: wgpu::Origin3d { x, y, z: 0.0 },
            },
            extent,
        );

On a depth buffer.

I am creating the buffer and copying to it in the same frame, so this might be the issue, though I do this for color textures without problem.

@kvark
Copy link
Member

kvark commented Nov 28, 2019

I can see that the code would use the full aspects of the texture, so in your case it should be correct:

let aspects = texture_guard[destination.texture].full_range.aspects;

Is there any way I could reproduce this? Perhaps, you could share a branch of code?

@cloudhead
Copy link
Contributor Author

Ok, I reproduced it pretty easily in rgx, here's the branch: https://github.com/cloudhead/rgx/tree/bug/depth-buffer-validation-error

You have to run cargo run --example screenshot

@kvark kvark added the type: bug Something isn't working label Nov 28, 2019
@kvark kvark self-assigned this Nov 28, 2019
@cloudhead
Copy link
Contributor Author

You can grep for XXX for the offending line(s)

@kvark
Copy link
Member

kvark commented Nov 28, 2019

Turns out, this was already fixed in #378, just never backported to 0.4 version. Doing this now in #389

@cloudhead
Copy link
Contributor Author

🙏

bors bot added a commit that referenced this issue Nov 29, 2019
389: [0.4] Transition and binding fixes r=grovesNL a=kvark

Back-ports #387 as well as a tiny bit of #378 to v0.4 branch and bumps the patch version.
Fixes  #384

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
@kvark
Copy link
Member

kvark commented Nov 29, 2019

Fixed by #378 and #389

@kvark kvark closed this as completed Nov 29, 2019
kvark added a commit to kvark/wgpu that referenced this issue Jun 3, 2021
384: Add include_spirv macro r=cwfitzgerald,rukai a=kvark

Depends on gfx-rs#729
Makes out shader loading in the examples a bit tidier.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants