gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
12.17k stars 894 forks source link

Vulkan validation error involving MSAA and rendering to attachments #4040

Open aweinstock314 opened 1 year ago

aweinstock314 commented 1 year ago

Description When capturing the first 4 frames of the reproducer in renderdoc , the texture that's a color attachment to quad_rpass appears from renderdoc's viewpoint to be cleared to transparent instead of loaded from the previous contents. Additionally, a vulkan validation error is present:

Validation error: [ UNASSIGNED-CoreValidation-DrwaState-InvalidImageLayout ] Object 0: handle = Command Buffer 328, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageId = 0x4dae5635 | vkQueueSubmit(): pSubmits[0].pCommandBuffers[0] command buffer VkCommandBuffer Command Buffer 328 expects VkImage 2D Color Attachment 269 (subresource: aspectMask 0x1 array layer 0 mip level 0) to be in layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL -- instead, current layout is VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL.

Repro steps Reproducer: https://github.com/aweinstock314/wgpu-validation-error-repro

Expected vs observed behavior The example draws a red quad in the top left, a green quad in the bottom left, a blue quad in the top right, and then a yellow quad in the bottom right, one quad per frame, to a texture whose contents are loaded from the previous frame, and then renders that texture to the surface. The expected behavior is that after the 4th frame, all 4 colored quads are present in the intermediate texture in renderdoc in a manner consistent with the runtime behavior. The actual behavior is that only one colored quad at a time is visible in the intermediate texture in renderdoc.

Platform

teoxoy commented 1 year ago

I can't reproduce this. I'm on windows and tried with both an Nvidia dGPU and an Intel iGPU.

image

aweinstock314 commented 1 year ago

That looks like the summary of the captures. For me, the issue shows up within the captures: 2023-08-21-135119_1366x667_scrot 2023-08-21-135130_1366x666_scrot 2023-08-21-135140_1366x689_scrot 2023-08-21-135201_1366x660_scrot 2023-08-21-135220_1364x664_scrot

teoxoy commented 1 year ago

I dug in the captures but can't see the issue. Would you be able to reproduce this on windows, another machine and/or GPU?