Jump to content
  • Advertisement
Sign in to follow this  
Migi0027

DX11 DX11 - Converting an UAV to SRV or Reading an UAV

This topic is 2128 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well, some few days a go I asked a question about re-writable textures, a UAV, which basically acts as a render target, though it took me a while to figure that out. tongue.png

 

Case #1:

But one problem is that if you use multiple render targets, there aren't so many slots for any UAVs, so I was suggested to sample a UAV to a Srv on a full screen quad, which is actually the way to go!

 

But, yeah it had to come, what about 3D Textures?

 

Do I render each single depth slice on and on, wouldn't that be terrible slow? (Sampling each single pixel on a full screen...)

 

My 3D Texture has the dimension 128x128x128, so using that approach above, I would need to sample 2097152 times, just for one 3D Texture!

 

What approaches could be taken to this?

 

Case #2

When reading my UAV, I get several warnings/errors in the runtime:

D3D11: ERROR: ID3D11DeviceContext::DrawIndexed: The Unordered Access View (UAV) in slot 1 of the Pixel Shader unit has the Format (R8G8B8A8_UNORM). This format does not support being read from a shader as as UAV. This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). It was unfortunately not possible to have all hardware implementations support reading this format as a UAV, despite that the format can written to as a UAV. If the shader only needs to perform reads but not writes to this resource, consider using a Shader Resource View instead of a UAV.  [ EXECUTION ERROR #2097382: DEVICE_UNORDEREDACCESSVIEW_FORMAT_LD_UNSUPPORTED ]

I get the error, and the reason for it to appear, but just not which format which I should use instead.

 

How can, if possible, I fix this error, what format is needed?

 

Thanks, as usual!

-MIGI0027

Share this post


Link to post
Share on other sites
Advertisement

I don't understand the problem you're describing for case #1. Could you elaborate on what you're trying to accomplish?

For #2, the only texture format that can be read from a UAV is R32_FLOAT/R32_UINT/R32_SINT. 

Share this post


Link to post
Share on other sites

In case #1, imagine that I had a RW2DTexture, which needed to be converted to a Texture2D.

 

I'd read over all the data in the pixel shader from the RW (On a full screen quad), the position is the texcoord, then output it to a shader resource view via a render target.

 

But what I have is a 3d texture, not a 2d, and I actually have 6 of them (Cube Map)

 

EDIT: Sorry if I made a mess in case #1, I hope this version is better.

Edited by Migi0027

Share this post


Link to post
Share on other sites

Heh I think you misunderstood from the other topic. :)

 

You don't need to convert UAV data to a SRV. When you create your UAV resource, you can create a matching SRV resource that points to the same data. You just bind this as a shader resource and in the shader use "Texture2D" as the type. Same goes for Texture3D, etc.

 

There's no conversions involved, no extra passes. You just create a new SRV. ;)

 

Hint: so long as the creation flags permit, you can have RTVs, UAVs and SRVs all pointing to the same source. You just need to watch the formats and description setup as it's somewhat specific.

 

As for the format, what MJP says is basically it. You need to pack the data that you would store to RGBA8_UNORM and pack it to R32_UINT (bitshifts).

Share this post


Link to post
Share on other sites


What approaches could be taken to this?

 

I would say use DirectCompute to update your 3D texture, it might be better suited for that type of computation. 

Share this post


Link to post
Share on other sites

No problem. It can be a little difficult to get it all working (creating UAV and SRV with proper types, setting up the CS, etc) so I don't expect anyone to get it all working without a single question if they've never used it before. :)

 

A good idea though would be to run over to the DX documentation and read up on the UAVs and SRVs a bit more, I'm pretty sure they go over this stuff and also have the notes for proper types, etc. It's a great reference for this stuff. ;)

Share this post


Link to post
Share on other sites
There's a handy HLSL include coming with the SDK (Include folder, D3DX_DXGIFormatConvert.inl) to help with format conversions. Hmmm, nice, reading the comments there is also enlightening (it mentions the UAV limitations).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!