godot: 3D preview plugins: Vulkan validation errors and wrong images

Godot version

4.0.dev (fe6c65a1a8)

System information

Windows 10, Vulkan Clustered, RTX2060

Issue description

See thread where this issue was discovered: https://github.com/godotengine/godot/pull/54427#issuecomment-958060797

When enabling vulkan validation layers (--vk-layers), the 3D preview plugins no longer display correctly.

(Edit: 3D preview plugins occasionally show the wrong image on sufficiently weak hardware regardless whether validation is enabled)

USER ERROR: VALIDATION - Message Id Number: 337425955 | Message Id Name: UNASSIGNED-Threading-MultipleThreads
        Validation Error: [ UNASSIGNED-Threading-MultipleThreads ] Object 0: handle = 0x913a870000000018, type = VK_OBJECT_TYPE_COMMAND_POOL; | MessageID = 0x141cb623 | THREADING ERROR : vkCmdBindIndexBuffer(): object of type VkCommandPool is simultaneously used in thread 0x71c and thread 0x3b4
        Objects - 1
                Object[0] - VK_OBJECT_TYPE_COMMAND_POOL, Handle -7981918955491033064
   at: VulkanContext::_debug_messenger_callback (drivers\vulkan\vulkan_context.cpp:157) - VALIDATION - Message Id Number: 337425955 | Message Id Name: UNASSIGNED-Threading-MultipleThreads
        Validation Error: [ UNASSIGNED-Threading-MultipleThreads ] Object 0: handle = 0x913a870000000018, type = VK_OBJECT_TYPE_COMMAND_POOL; | MessageID = 0x141cb623 | THREADING ERROR : vkCmdBindIndexBuffer(): object of type VkCommandPool is simultaneously used in thread 0x71c and thread 0x3b4
        Objects - 1
                Object[0] - VK_OBJECT_TYPE_COMMAND_POOL, Handle -7981918955491033064

Applying this patch resolves the validation error, but of course the previews don’t work still:

diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
index fbcb9e7db7..40bb70b396 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
@@ -1033,6 +1033,10 @@ Ref<Image> RendererStorageRD::texture_2d_get(RID p_texture) const {
 	Texture *tex = texture_owner.get_or_null(p_texture);
 	ERR_FAIL_COND_V(!tex, Ref<Image>());
 
+	if (tex->is_render_target) {
+		return Ref<Image>();
+	}
+
 #ifdef TOOLS_ENABLED
 	if (tex->image_cache_2d.is_valid() && !tex->is_render_target) {
 		return tex->image_cache_2d;

Steps to reproduce

  1. Open a project with --vk-layers
  2. View a material or mesh and see incorrect/missing preview

Minimal reproduction project

https://github.com/godotengine/godot/pull/54427#issuecomment-958236480

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 18 (18 by maintainers)

Most upvoted comments

Haha, it happens. By the way, I’m curious if the PR I submitted recently makes previews are more reliable for you. No hurry though.