The “result” will have to be a RWStructuredBuffer and in “: register(u0)”, for example, not t2.
You might want to use density.Load (with whole-number texel indices) instead of density.SampleLevel (with uvw texture coordinates), because you said you want to “copy all texels”, you didn't mention any filtering.
I don't understand what you mean by “without doing a lookup”.
Also beware that your (RW)StructuredBuffer is a single-dimensional array, so you'll have to layout your 3D texture texels into it somehow. What are you trying to achieve?
I want to be able to read back on the CPU all lookup float4's from the whole texture, not just one point of it (retrieving one float4 is what I meant with doing a lookup)
In this example by using SampleLevel you just retrieve only one coordinate of it.
I want to be able to do this for all texels for all texcoords of the texture, and save it in the (RW) StructuredBuffer.
@fs1 Create a resource to read back to the CPU. Then copy(copybufferregion()) the resource that has your data into that CPU-read resource and read it from the CPU.
The same way you load your data from the CPU to the GPU, but backwards.
Regardless if the resource is UAV or SRV, and regardless the dimensions. You copy it into a CPU-read resource and then copy it to an array.
@fs1 It exactly copies a region of a resource into another resource. It is up to you to define the data type of the array on the CPU side. You read the data as bare BYTEs. Every 4 consecutive 4bytes(UINT32) will be your Float4(4xUINT32).