RWTexture2D - read and write

Started by
0 comments, last by Tsus 12 years, 2 months ago
I create my RWTexture2D with this flags:

textureDesc.BindFlags = D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_SHADER_RESOURCE;

In Compute Shader
RWTexture2D<float4> data;


Afterward I want to bind this texture for Read only (srv, some errors) or Write (uav) or Read/Write (uav)...

If I bind this texture as SRV or UAV and read from it, i got this error:

- typed UAV loads are only allowed for single-component 32-bit element types
- if my code contains for-loop with break: Loop termination conditions in varying flow control cannot depend on data read from a UAV


First one is limitation of DX SDK as i found... co i can do only RWTexture2D<int> if I want to use it as read only (srv).
Second error is mystery :) Even if I change float4 to int


Thanks
Advertisement
Hi,


- typed UAV loads are only allowed for single-component 32-bit element types

Theoretically, you can either use a SRV to fetch from the texture (Texture2D<float4>) or you bind it as UAV and do 4 reads (RWTexture2D<float>). Caching should make the other three reads very fast, so I wouldn’t expect too much penalty.


- if my code contains for-loop with break: Loop termination conditions in varying flow control cannot depend on data read from a UAV

As for flow control depending on UAV reads, you can use a special modifier in front of the loop, see here.
[allow_uav_condition] for(...) { }

Cheers!

This topic is closed to new replies.

Advertisement