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

Bogus image usage check in vkCmdBeginRenderPass with KHR_imageless_framebuffer #2502

Closed
kvark opened this issue Jan 26, 2021 · 9 comments
Closed
Assignees

Comments

@kvark
Copy link

kvark commented Jan 26, 2021

Describe the Issue

See gfx-rs/wgpu#1175 for details.
Validation triggers an error with image-less framebuffers. We believe it's a VVL bug.

Valid Usage ID

[VUID-VkRenderPassBeginInfo-framebuffer-03210] Validation Error: [ VUID-VkRenderPassBeginInfo-framebuffer-03210 ] Object 0: handle = 0x8970000000897, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0xcc018073 | VkRenderPassBeginInfo: Image view #0 created from an image with usage set as 0x11, but image info #0 used to create the framebuffer had usage set as 0x10 The Vulkan spec states: If framebuffer was created with a VkFramebufferCreateInfo::flags value that included VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, each element of the pAttachments member of a VkRenderPassAttachmentBeginInfo structure included in the pNext chain must be a VkImageView of an image created with a value of VkImageCreateInfo::usage equal to the usage member of the corresponding element of VkFramebufferAttachmentsCreateInfo::pAttachments used to create framebuffer (https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-VkRenderPassBeginInfo-framebuffer-03210)

Environment:

  • OS: Linux
  • GPU: Nvidia GTX 1050
  • SDK or header version if building from repo: 1.2.162.0 release 11
  • Options enabled (synchronization, best practices, etc.): standard validation

Additional context
See the renderdoc capture. It shows the validation error, yet one can inspect the parameters of vkCreateFramebuffer as well as vkCreateSwapchain and see that the usage is consistently VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, and the VVL error is wrong.

@sfricke-samsung
Copy link
Contributor

This VU was recently (1.2.165) changed to VUID-VkRenderPassBeginInfo-framebuffer-04627 to address another issue
KhronosGroup/Vulkan-Docs#1391

Code change:
#2480

If you were by change using VkImageViewUsageCreateInfo from VK_KHR_maintenance2 this will probably fix your issue

@kvark
Copy link
Author

kvark commented Mar 4, 2021

We are getting multiple reports about the validation layers just plain crashing after showing this error.
It appears to me that VVL tries to access garbage memory, which is a severe issue given that VVL are supposed to be mostly enabled during development and testing of applications. Can we prioritize this, please?

@sfricke-samsung sfricke-samsung self-assigned this Mar 4, 2021
@sfricke-samsung
Copy link
Contributor

Sure, unless @ncesario-lunarg wants, I can take this on

@ncesario-lunarg
Copy link
Contributor

If you're offering, it's all yours @sfricke-samsung!

@sfricke-samsung
Copy link
Contributor

@kvark

  1. Is the issue still there with the current Validation (post Add inherited usage edge case #2480)
  2. I am having a hard time reproducing it, I grabbed the trace.zip file in the wgpu repo issue, and I see the play tool, but with my complete lack of rust, you have a one line command for how to compile play.rs (on ubuntu) or is there a binary somewhere I can quick use

@kvark
Copy link
Author

kvark commented Mar 5, 2021

One way to reproduce this would be by running the affected wgpu-rs example:

# install rust & cargo, VVL
git clone https://github.com/gfx-rs/wgpu-rs && cd wgpu-rs
cargo run --example mipmap

The current VVL version on my system (Solus) is 1.2.162.0, where it still reproduces.

As for #2480, it only improves the error message and fixes VkImageViewUsageCreateInfo, which we aren't using anyway right now (considering in gfx-rs/gfx#3659), so I don't think it's going to fix this.

@sfricke-samsung
Copy link
Contributor

sounds good... using this as an excuse to learn about setting up cargo for other rust projects as it was on my bucket list in life anyways 😄

@sfricke-samsung
Copy link
Contributor

So I ran with a GTX 1070 and Swiftshader, I checked out the sdk-1.2.162.1 commit and ran that, and got a few VUID-VkRenderPassBeginInfo-framebuffer-03211/VUID-VkRenderPassBeginInfo-framebuffer-03212 errors, so then grabbed sdk-1.2.170.0 and had no validation errors at all

By chance could you grab the latest SDK and retry on your machine and if you are still getting the same error can you do a

VK_INSTANCE_LAYERS=$VK_INSTANCE_LAYERS:VK_LAYER_LUNARG_api_dump cargo run --example mipmap > dump.txt

and post that here. I only see a single vkCreateImage call with

VkImageUsageFlags = 22 (VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)

with 9 vkCreateFramebuffer calls, 8 of which have a VkFramebufferAttachmentsCreateInfo::pAttachmentImageInfos with the same 3 image usage flags, these are the mipmaps ones as I can tell from the width/height, but the last framebuffer has just VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT from what seems to be the 800x600 swapchain surface

So if you are getting this issue, it would be because of the usage flags for the image from vkGetSwapchainImagesKHR's VkSwapchainCreateInfoKHR::imageUsage which for my run both swapchains only had VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT

@kvark
Copy link
Author

kvark commented Jun 9, 2021

Looks to be fixed in vvl-1.2.170.0. Thank you!

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

No branches or pull requests

3 participants