AMD Driver version - 22.3.1
AMD GPU - AMD Vega 8 (I have no other AMD GPUs to test right now)
OS - Windows 10
(look screenshot below)
Bug - Shadertoy link (launch shadertoy shader in Vulkan, it does work correctly in OpenGL and DX11)
My test Vulkan app to test this shader (Warning exe you may not trust this). - bug_amd_array.zip
C code to test in GCC and see that this is not my code bug - C code link.
Shader code:
const int numsSize = 19;
const int [] nums = int[](0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1);
const int imap_size = numsSize+numsSize%2;
int imap[imap_size];
void bug(){
for(int i=0;i<imap_size;i++){imap[i]=0;}
int imidx=0;
{
int ctr=0;
for (int i=0;i<numsSize;i++){
if(nums[i]==1){
if(ctr!=0){
ctr=0;
imap[imidx]=i;
imidx++;
}else if(ctr==0&&i==0){imap[imidx]=i;imidx++;}
}else {if(ctr==0&&i!=0){imap[imidx]=i;imidx++;}ctr++;}
}
if(ctr!=0){ctr=0;}
}
}
Result of calling bug() will be - imap array.
Expected result:
2 4 6 9 10 12 15 0 0 0 0 0 0 0 0 0 0 0 0 0
AMD Vulkan result: (bug/wrong)
2 3 6 7 8 10 11 15 16 17 18 0 0 0 0 0 0 0 0 0
Screenshot: