0
votes

I was wondering what would be the quickest / most performant way to clear a 2D texture using DirectX 11?

Context: I am using an RWTexture object as a head pointer to implement linked lists on the GPU (essentially, to implement Order-Independent Transparency as known from the AMD Tech Demo) and I need to reset this buffer to a fixed value every Frame.

The following ideas come to my mind:

  • Declare it as a Render Target and use ClearRenderTargetView to set it. Seems unnatural to me since I don't actually render to it directly, also I am not sure if it actually works with an uint datatype
  • Actually Map it as a render target and render a fullscreen quad, using the pixel shader to set the value
  • Use a compute shader to set the fixed value

Is there some obvious way I am missing or an API for this that I am not aware of?

1
ClearUnorderedAccessViewUint and ClearUnorderedAccessViewFloat is better and simpler if you need to clear, the best solution would be to not have to clear. - galop1n
Oh well that was exactly what I was looking for. Should have found that by myself, thats a little embarassing. Anyway, thanks very much! - Jack White

1 Answers

1
votes

As pointed out by user galop1n, ClearUnorderedAccessViewUint and ClearUnorderedAccessViewFloat are the way to go here.