Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


DX11 - Converting an UAV to SRV or Reading an UAV


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 Migi0027 (肉コーダ)   Crossbones+   -  Reputation: 3008

Like
0Likes
Like

Posted 23 September 2013 - 09:45 AM

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


Hi!

Game-Dev Journal: www.gamedev.net/blog/1882-the-cuboid-zone/

Wordpress Journal: cuboidzone.wordpress.com/


Sponsor:

#2 MJP   Moderators   -  Reputation: 13059

Like
0Likes
Like

Posted 23 September 2013 - 12:55 PM

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. 



#3 Migi0027 (肉コーダ)   Crossbones+   -  Reputation: 3008

Like
0Likes
Like

Posted 23 September 2013 - 01:04 PM

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, 23 September 2013 - 01:06 PM.

Hi!

Game-Dev Journal: www.gamedev.net/blog/1882-the-cuboid-zone/

Wordpress Journal: cuboidzone.wordpress.com/


#4 Styves   Members   -  Reputation: 1103

Like
1Likes
Like

Posted 23 September 2013 - 01:15 PM

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).



#5 mrhyperpenguin   Members   -  Reputation: 340

Like
0Likes
Like

Posted 23 September 2013 - 01:18 PM


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. 



#6 Migi0027 (肉コーダ)   Crossbones+   -  Reputation: 3008

Like
1Likes
Like

Posted 23 September 2013 - 01:27 PM

Heh unsure.png

 

Sorry guys (+Styves), this topic is still quite new to me, still trying to get my head around it...


Hi!

Game-Dev Journal: www.gamedev.net/blog/1882-the-cuboid-zone/

Wordpress Journal: cuboidzone.wordpress.com/


#7 Styves   Members   -  Reputation: 1103

Like
0Likes
Like

Posted 23 September 2013 - 02:21 PM

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. ;)



#8 unbird   Crossbones+   -  Reputation: 6508

Like
0Likes
Like

Posted 24 September 2013 - 12:27 PM

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).




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS