first of all, sorry about my short English.
i found a unexpected situation when using “for” loop increment term with decreasing.
this situation could reproduce with code like below.
#version 430
#extension GL_ARB_compute_shader : enable
#extension GL_ARB_shader_storage_buffer_object : enable
layout( std430, binding=4) buffer offsetRaw{int oData[];};
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main(void)
{
for(int loop = 8; loop>0; loop-=2)
{
oData[loop+gl_LocalInvocationIndex ]=loop ;
oData[loop+gl_LocalInvocationIndex-1]=loop-1;
}
barrier();
}
glDispatchCompute(1,1,1);
glMemoryBarrier( GL_SHADER_STORAGE_BARRIER_BIT );
the index value “gl_LocalInvocationIndex” is zero because the shader is dispatched by single invocation and single group.
so we can predict a result easily.
but result is not matched.
oData[1] = 1 oData[1]=0
oData[2] = 2 oData[2]=0
oData[3] = 3 oData[3]=3
oData[4] = 4 oData[4]=4
oData[5] = 5 oData[5]=5
oData[6] = 6 oData[6]=6
oData[7] = 7 oData[7]=7
oData[8] = 8 oData[8]=8
is this a bug? or my mistake?
if it is a bug, what should i doing for resolve it?