Writing to render target with compute shader?

Started by
0 comments, last by MJP 11 years, 2 months ago

What's the best way to go about displaying an image calculated in a compute shader to the screen? Is it possible to write directly to a render target from the compute shader? Or would you have to write the results to a 2D UAV texture, then somehow swap that into the back buffer? I suppose writing to a RWTexture2D<float4> is the way to go, but how exactly would you set up the swap chain for this?

The only way I can get it working right now is to write into a 2D UAV texture, then render a rectangle to activate the pixel shader, which then reads from the texture and writes those values to the render target. Obviously, I would like to avoid this method because it requires unnecessary switching between the compute shader and pixel shader, which impacts performance.

Advertisement

When you create your swap chain, specify DXGI_USAGE_UNORDERED_ACCESS as your BufferUsage. If you do that, you'll be able to create an unordered access view from the back buffer texture that you get from that swap chain.

This topic is closed to new replies.

Advertisement