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

Driver crash/system freeze when copying buffer device address to struct #35

Open
martin-ejdestig opened this issue Nov 28, 2024 · 2 comments
Assignees
Labels
Vulkan This is an issue with Vulkan driver

Comments

@martin-ejdestig
Copy link

martin-ejdestig commented Nov 28, 2024

GPU: AMD Radeon RX 6700 XT
Driver Version: 24.10.1
OS: Windows 10 (Build 19045)
Vulkan SDK: 1.3.296.0

Experiencing a program crash/system freeze when trying to run a shader where a buffer device address is copied from a uniform buffer to a member in a local struct variable.

Originally discovered in a much larger shader. But looks like similar problem is also reproducible if modifying shader in simple VK_KHR_buffer_device_address sample found in Sascha Willems' Vulkan example repository.

To get program to crash, modify https://github.com/SaschaWillems/Vulkan/blob/master/shaders/glsl/bufferdeviceaddress/cube.vert by applying the following diff (and recompile the shader, there is a separate python script for this in shaders/glsl):

diff --git a/shaders/glsl/bufferdeviceaddress/cube.vert b/shaders/glsl/bufferdeviceaddress/cube.vert
index 0bf5c602..9d4e7123 100644
--- a/shaders/glsl/bufferdeviceaddress/cube.vert
+++ b/shaders/glsl/bufferdeviceaddress/cube.vert
@@ -30,13 +30,32 @@ layout (location = 0) out vec3 outNormal;
 layout (location = 1) out vec3 outColor;
 layout (location = 2) out vec2 outUV;
 
+#define AMD_CRASH 1
+#if AMD_CRASH
+struct Foo
+{
+       MatrixReference sceneData;
+       MatrixReference modelData;
+};
+#endif
+
 void main() 
 {
+#if AMD_CRASH
+       Foo foo;
+       foo.sceneData = pushConstants.sceneDataReference;
+       foo.modelData = pushConstants.modelDataReference;
+#else
        MatrixReference sceneData = pushConstants.sceneDataReference;
        MatrixReference modelData = pushConstants.modelDataReference;
+#endif
 
        outNormal = inNormal;
        outColor = inColor;
        outUV = inUV;
+#if AMD_CRASH
+       gl_Position = foo.sceneData.matrix * foo.modelData.matrix * vec4(inPos.xyz, 1.0);
+#else
        gl_Position = sceneData.matrix * modelData.matrix * vec4(inPos.xyz, 1.0);
+#endif
}

If AMD_CRASH is defined to 0, there is no crash.

Willems' example uses vkQueueWaitIdle(), and if I remember correctly, assert gets triggered in VulkanExampleBase::submitFrame(). Program where problem was originally discovered does not use vkQueueWaitIdle(). There program just crashes and sometimes it even causes system to freeze and a hard reset is required. Also, in own more complicated shader, buffer device address is copied from a uniform buffer and stored in a local struct variable that gets passed thorough functions to eventually be de-referenced. If shader is modified to just use address directly from uniform buffer, there is no crash.

Can not reproduce this problem on Nvidia nor Intel GPU:s available to test with. Neither in own more complicated shader nor with diff from above applied to simple VK_KHR_buffer_device_address example.

@martin-ejdestig martin-ejdestig changed the title Driver crash/system freeze when copying buffer reference to struct Driver crash/system freeze when copying buffer device address to struct Nov 28, 2024
@martin-ejdestig
Copy link
Author

martin-ejdestig commented Nov 29, 2024

Willems' example uses vkQueueWaitIdle(), and if I remember correctly, assert gets triggered in VulkanExampleBase::submitFrame().

Assert gets triggered at https://github.com/SaschaWillems/Vulkan/blob/04cc268ec352267f4347d60300b3323897457c46/base/vulkanexamplebase.cpp#L781 . vkQueueWaitIdle() returns VK_TIMEOUT.

@martin-ejdestig
Copy link
Author

Ping?

@jinjianrong jinjianrong added the Vulkan This is an issue with Vulkan driver label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Vulkan This is an issue with Vulkan driver
Projects
None yet
Development

No branches or pull requests

3 participants