- Home /
ComputeShader, bad output After "if" condition
Ho every One and thanks to read me, i'm doing a marching cube implementati on via computer shader, Building vertices and triangle for my chunk of voxel, i know implementation exists, but thats for learning purpose, After being able to store vertex in a computeBuffer, i got problem looking for the triangulation table. The triangulation Is stored in c# as int[,] 256 * 16, that i access Linearly in my kernel with a structuredBuffer of int. The problem in racing appear while i look up the table on the GPU, using an uint as index for the 255 use case multiplied by 16 couse the table i use Is represented likes this (copy pasted), if i read the uint index, It exist within the right range 0~255, any how, if i check the table with the uint index i manager to sometimes read the int stored in the table, if i check for the table value, with an if(table[uint]!=-1) the value i read from the table seems likes if it suffer of bad casting, likes if It get truncated or worst interpreted as unsigned, giving me result likes 1900480380 (actually Just example), others times It become 655535, im pretty sure to be using int, 32bit One, but not really sure, if i comment out the of statement, the output start to being readable again... It seems that if i read from the structuredBuffer insider di condition, the data get corrupted or bad casted. Im using rwstructbuffer for vertex, appendBuffer for triangles and structuredBuffer as input for the triangulation table. On the c# i retrieve the data as nativearray. I can provide some example code, im on Linux vulkan probably mono backend. Do you have some hint, on what May Be happening?