bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Vulkan Validation Error in a default, empty app w/ window.

Open brandon-reinhart opened this issue 2 years ago • 17 comments

Bevy version

0.8-dev (main)

Relevant system information

AdapterInfo {
  name: "NVIDIA GeForce RTX 3090", 
  vendor: 4318, 
  device: 8708, 
  device_type: DiscreteGpu, 
  backend: Vulkan 
}

What you did

Any project started with DefaultPlugins and a window on a vulkan backend.

What went wrong

Vulkan device creation is being provided with a non-compliant VkPhysicalDeviceVulkan12Features / device create info struct.

The expectation is that default vulkan init would be free of validation errors.

2022-07-21T14:59:03.219031Z ERROR wgpu_hal::vulkan::instance: VALIDATION [VUID-VkDeviceCreateInfo-pNext-02830 (0x211e533b)]
        Validation Error: [ VUID-VkDeviceCreateInfo-pNext-02830 ] Object 0: handle = 0x2307368ded0, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0x211e533b | If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or VkPhysicalDeviceVulkanMemoryModelFeatures structure The Vulkan spec states: If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or VkPhysicalDeviceVulkanMemoryModelFeatures structure (https://vulkan.lunarg.com/doc/view/1.3.211.0/windows/1.3-extensions/vkspec.html#VUID-VkDeviceCreateInfo-pNext-02830)
2022-07-21T14:59:03.219780Z ERROR wgpu_hal::vulkan::instance:   objects: (type: INSTANCE, hndl: 0x2307368ded0, name: ?)

brandon-reinhart avatar Jul 21 '22 15:07 brandon-reinhart

This is probably a bug in wgpu, the rendering crate used by Bevy. Try running wgpu's examples and/or tests. If you still get this error, close this issue and create a new one in wgpu's repository.

x-52 avatar Jul 22 '22 14:07 x-52

i'm getting the same issue on a rtx 2070. arch linux. wgpu examples seem to run fine.

oddfacade avatar Jul 29 '22 00:07 oddfacade

I have the same issue on RTX 2080 (Win10) when I upgraded to 0.8.0. WGPU examples run fine.

orromis avatar Jul 30 '22 22:07 orromis

wgpu issue link: https://github.com/gfx-rs/wgpu/issues/2925

pkupper avatar Jul 31 '22 11:07 pkupper

getting the same thing on arch, RX 6800M

jacekpoz avatar Jul 31 '22 17:07 jacekpoz

TL;DR: I'm still going to blame wgpu.

This error is affecting multiple GPUs from both Nvidia and AMD, so we can rule out driver/GPU problems. It's also happening on both Windows and Linux, so it's likely not the OS, either. The culprit is likely either bevy_render or wgpu. However, bevy_render doesn't interact with Vulkan directly – that's wgpu_hal's job.

The error that you got is saying that the list of features was invalid. The only optional feature that Bevy enables by default is TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES, which, according to the wgpu docs, is required for read/write storage access. wgpu, in turn, converts the features it receives into a list of features to be passed to Vulkan.

Here's where the magic happens.

wgpu essentially included redundant information: The VkPhysicalDeviceVulkan12Features structure has several boolean fields, which can be toggled to enable/disable many of Vulkan's features. However, in older versions of Vulkan, instead of using a single structure for most features, you would instead pass a linked list of many structures. (You still have to use a linked list if you're using features that aren't in VkPhysicalDeviceVulkan12Features, by the way.) wgpu, for some reason, decides to declare features through both techniques at the same time (probably for backwards compatibility). Vulkan's spec doesn't allow this, since it creates two different sources of truth, which can make things confusing for the driver. The output from LogPlugin suggests that the error comes from wgpu's built-in validation layer, which detected the problem and threw an error.

The solution would be for wgpu to use only VkPhysicalDeviceVulkan12Features when running on Vulkan 1.2 or newer, and use a good ol' linked list for older versions.

x-52 avatar Aug 02 '22 13:08 x-52

Marking this as blocked upstream based on current conversation, let me know if that is not correct.

Weibye avatar Aug 07 '22 13:08 Weibye

The linked wgpu bug is now closed and the fix is in their 0.14.0 release. fix: https://github.com/gfx-rs/wgpu/commit/c519901d575bd6d61711e5cf9c3c1b047e7d3cf7 issue: https://github.com/gfx-rs/wgpu/issues/2925

rabbit400 avatar Oct 14 '22 02:10 rabbit400

Is there a recommended workaround to suppress this warning when working on a new project? Ignoring it doesn't seem like a viable option when it spams the console.

lstanden avatar Oct 09 '23 07:10 lstanden

@lstanden It looks like the fix for this one was merged to wgpu almost a year ago here: https://github.com/gfx-rs/wgpu/commit/c519901d575bd6d61711e5cf9c3c1b047e7d3cf7 Are you sure you are still getting the same validation error or is it a different one? It looks like this issue should have been closed.

paul-hansen avatar Oct 09 '23 22:10 paul-hansen

As far as I can see, wgpu 0.16 is the one being used by bevy, and that fix in is 0.17.1

lstanden avatar Oct 09 '23 23:10 lstanden

If you search their changelog it was included in 0.14 https://github.com/gfx-rs/wgpu/blob/2664da88b0c7e5090a4f6d40dea834ae79005560/CHANGELOG.md#vulkan-14 The comment right above your first one also said it would be in the 0.14 release. Note that the comments on this issue before yours are from 2022 and there have been multiple releases of bevy and wgpu since then.

I'm just suggesting that you should compare your validation error more closely to the one in this issue and let us know if it's actually the same or not (if not please create a new issue). Does your's have this part in it?

if the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures,

paul-hansen avatar Oct 09 '23 23:10 paul-hansen

Maybe this is a separate issue then, although it looks like it started all the same

Validation Error: [ VUID-VkRenderPassBeginInfo-framebuffer-04627 ] Object 0: handle = 0x628d6100000000f7, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x45125641 | vkCmdBeginRenderPass(): Image view #0 created from an image with usage set as 0x11 but using VkImageViewUsageCreateInfo the inherite d usage is the subset 0x10 and the image info #0 used to create the framebuffer had usage set as 0x11 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 VkRenderPassAtt achmentBeginInfo structure included in the pNext chain must be a VkImageView with an inherited usage equal to the usage member of the corresponding element of VkFramebufferAttachmentsCreateInfo::pAttachmentImageInfos used to create framebuffer (https://vulkan.lunarg.com/doc/view/1.2.182.0/windows/1.2-extensions/vkspec.html#VUID-VkRenderPassBeginInfo-framebuffer-04627)

lstanden avatar Oct 10 '23 05:10 lstanden

Ok, after suggesting it might be different, I just found this comment in another related issue: https://github.com/bevyengine/bevy/issues/3640#issuecomment-1113793791

The solution is exactly what's suggested in that comment: uninstall the Vulkan SDK from your computer. Ugh.

lstanden avatar Oct 10 '23 05:10 lstanden

They actually say it was fixed in newer versions of the Vulkan SDK. So maybe try installing an up to date version of the Vulkan SDK?

paul-hansen avatar Oct 10 '23 07:10 paul-hansen

Already installed the latest version when I ran into this and realized it was Vulkan related. Appreciate the suggestion though!

lstanden avatar Oct 10 '23 09:10 lstanden

@lstanden that issue is https://github.com/gfx-rs/wgpu/issues/3855 and was due to an issue in OBS (who fixed the issue in their vulkan layer, and afaik the fix will be in OBS 30 when that releases).

There's a workaround applied in wgpu 0.17, but we only just merged that into main (it'll be part of bevy 0.12 when that releases soon).

It's also possible to disable the OBS layer(s) for your bevy games in the vulkan configurator which is included in the sdk (but that might break capturing gameplay with OBS of that program, and iirc you need to manually add every bevy/wgpu app where it's bothering you)

Elabajaba avatar Oct 11 '23 05:10 Elabajaba

I was having this from OBS, there's also a DISABLE_VULKAN_OBS_CAPTURE environment variable you can set to 1 that will prevent the messages.

josh04 avatar Oct 14 '23 22:10 josh04