🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Directx12: copy Descriptors from BackHeap to FrontHeap => taking SRV or UAW Descriptor doesnt matter

Started by
1 comment, last by MJP 2 years, 10 months ago

Hello,

in my engine i have a unique function that creates all kinds of buffers or textures and returns a userdefined resource object.

When allocating the needed memory i create by default ALLWAYS a SRV and a UAV and store the adresses in a global descriptor table defined as not shader accesible so lets call it the BackHeap.

In the application code i copy the needed descriptors from the backheap to the shader accesible frontheap in the needed order. Mostly this copy process is optimized and done only once for the lifetime of the resource.

When e.g.

  • reading a texture or a buffer in the shader register(t2) i reference the SRV entry in the frontheap table
  • writing a texture or a buffer (u5) i reference the UAV entry in the frontheap table.

Now lets only discuss => compute shaders

For some reason i did a test and it makes NO DIFFERENCE ( all cases work fine )

- copy the SRV entry from backheap to SRV entry in the frontheap ( this is the rule we should follow, right ? )

- copy the SRV entry from backheap to the UAV entry in the frontheap
to me this should be wrong, but i can write to the texture in the shader code

- copy the UAV entry from backheap to the SRV entry in the frontheap
this also works fine

Why do i need to create a UAV in Directx12 when i can use a SRV also to write to the resource ?

Is here a difference between compute shaders and raster shaders ?

Advertisement

Are you running with the debug layer enabled? I will almost certainly give you an error for this. Accessing the a resource through the wrong descriptor type is undefined behavior. You're probably just getting lucky and the particular GPU you're running on happens to use the same descriptor for SRV and UAV, but that is not at all guaranteed to work on all vendors, GPUs, and drivers.

This topic is closed to new replies.

Advertisement