danilw

AMD Vulkan driver SPIR-V shader Much more critical bug

Discussion created by danilw on Mar 31, 2020
Latest reply on Apr 15, 2020 by danilw

This is my third bugreport about Vulkan SPIR-V shaders bugs in AMD:

Previous bugs 1, 2

 

Hardware AMD Vega 8(Ryzen 3200)

This is not hardware bug, why - because this shader work without problems in same AMD hardware in OpenGL.

 

OS Windows10, AMD drivers latest, everything latest, tested on two PC

Examples(exe) linked in end of this post. (code do not have validation errors at all)

 

Problem is :

1. using something more complicated then single linear function in AMD SPIR-V shader, with single exit(single return for whole logic) result UB or unpredictable result. Having any code after first single return function will result UB.

2. using any loops in AMD SPIR-V shaders trigger UB almost always.

 

Example code that 100% ruin GLSL any shader just call main2() function in your shader

void main2()
{
int i=0;
if(i==0)return;
else return;
// BUG ??? I have no idea how and why it work, it work only with loop(while or for)
for (int i=0; i < 1; i++) {
}
return;
}

 

 

How this bug ruin real shader:

in this shader I use 128bytes push constant and reat them bit by bit in shader, and print all bits as Number and as red lines. this is single shader, nothing else

on AMD:

 

same shader on Nvidia

 

Source code of this shader https://www.shadertoy.com/view/3sXyW2 

(change var bits to push constant array)

 

Download examples and exe:

test_AMD_shader_ub.zip

zip contain three tests, with single shader.

Shader source in test_<X>\shaders\src\main.frag

 

test_1 - shader that display 128 bytes(UINT) push_contants (same as on screenshot), bug happened

test_2 - shader from shadertoy that dispaly 128 bytes that build in to shader, no bug

test_3 - code with Example code from this post, call only main2() that ruin shader

 

 

Other download Vulkan code from SaschaWillems triangle.cpp

Download valid_AMD_ub_test.zip

valid_AMD_ub_test.zip has two folder, NO_BUG and BUG

launcheing triangle.exe from BUG folder make app crash on AMD GPU

Outcomes