I’m playing around with DirectX 12 ray tracing, and I’m trying to read and write data to a 32-bit RGBA floating point RWTexture2DArray within a DirectX 12 HLSL shader. I’m getting weird corruption/noise when I read back values I’ve written to the texture.
I’ve bound the texture as a UAV, and in my shader I’ve tagged it with the "globallycoherent" like so:
globallycoherent RWTexture2DArray<float4> myTextureArray;
I’m able to demonstrate the issue I’m seeing with a trivial bit of shader code:
myTextureArray[xIndex, yIndex, 0] = float4((float)xIndex / (float)xRes, (float)yIndex / (float)yRes, 0.0f, 1.0f); myOutputTexture[xIndex, yIndex] = myTextureArray[xIndex, yIndex, 0];
For the sake of a simple demonstration, I’m just writing increasing values of red along the x axis, and increasing values of green along the y axis, and storing them into the first slice of my 32-bit floating point RGBA RWTexture2DArray. Then, I’m immediately reading the values back from the same position.
Unfortunately, even with this trivial bit of code, when I read the values back they’re often garbled. I’ve got a screenshot of the results, notice the weird, speckled noise in the output:
I’m relatively new to DirectX12/HLSL, and I have a feeling I’m likely missing something simple. I’ve consulted the Microsoft documentation, which states you can both read and write to a RWTexture2DArray, and I’m using the "globallycoherent" prefix as instructed.
I’m using NVidia Falcor as a wrapper for some DXR experiments, so it’s possible either I’ve missed some specific configuration (or, there’s a bug in their implementation). If you can think of anything I might have missed, or might not be understanding, I’d be very appreciative of your help! I’m trying to use an array of textures as a buffer to hold various data elements (positions, indexes, etc etc), so if there’s an easier/better way, let me know!
0 Asked on August 27, 2021 by b1skit
1 Asked on August 27, 2021 by emil-kabirov
1 Asked on August 27, 2021 by makogan
1 Asked on March 3, 2021 by lucio-coire-galibone
2 Asked on February 10, 2021
2 Asked on January 29, 2021 by adrian
0 Asked on January 5, 2021 by bisma
0 Asked on January 2, 2021 by weichsem
2 Asked on August 12, 2020 by jheindel
0 Asked on July 23, 2020 by przemek-b
Get help from others!