void StoreFragmentsPS( SceneVS_Output input )
{
uint x = input.pos.x; // [0,g_nFrameWidth]
uint y = input.pos.y; // [0,g_nFrameHeight]
// Create fragment data.
uint4 nColor = saturate( input.color ) * 255;
FragmentLink element;
element.fragmentData.nColor = (nColor.x) | (nColor.y << 8) | (nColor.z << 16) | (nColor.a << 24);
element.fragmentData.fDepth = input.pos.z;
// Increment and get current pixel count.
uint nPixelCount= FLBuffer.IncrementCounter();
// Read and update Start Offset Buffer.
uint nIndex = y * g_nFrameWidth + x;
uint nStartOffsetAddress = 4 * nIndex;
uint nOldStartOffset;
StartOffsetBuffer.InterlockedExchange(
nStartOffsetAddress, nPixelCount, nOldStartOffset );
if ( nOldStartOffset != 0xFFFFFFFF ) {
//get an error: array, matrix, vector or indexable object.......
uint index = StartOffsetBuffer[ idx ];
}
// Store fragment link.
element.nNext = nOldStartOffset;
FLBuffer[ nPixelCount ] = element;
}
With the function InterlockedExchange, nPixelCount value will be saved at nStartOffsetAddress position and we can get the old value. Hence, we can use nOldStartOffset value as an index to get the previous/next element, but why did I get that error? and how to solve it?
Anybody help me, please? Thank in advance.