I am trying to read&modify the data from my vertex buffer in the compute shader. the position in the vertex buffer has the format of R16G16B16A16. (there are some other elements in the vertex buffer as well: normal, color, texcoord...)
here is the compute shader code to read&write the position value.
uint nOffsetPosXY = vDispatchThreadId.x*nStride;
uint nOffsetPosZW = nOffsetPosXY + 4;
uint nXY = gVertexBufferSrcSRV.Load(nOffsetPosXY);
uint nZW = gVertexBufferSrcSRV.Load(nOffsetPosZW);
vInPos.x = f16tof32(nXY);
vInPos.y = f16tof32(nXY>>16);
vInPos.z = f16tof32(nZW);
vInPos.w = f16tof32(nZW>>16);
// some modification for the position
vInPos.z = 10; // value doesn't behave correctly
// write into another UAV buffer
uint nXYNew = f32tof16(vInPos.x)|(f32tof16(vInPos.y)<<16);
uint nZWNew = f32tof16(vInPos.z)|(f32tof16(vInPos.w)<<16);
I am sure the offset is correct since if i set x,y,z individually to 0, i can see the value in the corresponding axis is set to 0 visually. but if i set the value other than 0, the value doesn't behave correctly. (although the sign is correct.)
My feeling is that the f16tof32 f32tof16 doesn't work correctly. (or maybe i did something stupid.
Any help or suggestion would be really appreciated.
By the way, i couldn't find any tool to debug compute shader on PC, PIX & VS2012 graphics debugger don't work. Is there any good tool for debugging the compute shader?
Edited by MJP, 19 July 2013 - 11:08 PM.