Jump to content
  • Advertisement
Sign in to follow this  
IrYoKu1

Create shader resource view from backbuffer texture

This topic is 2809 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

Hey guys,

I would like to use the backbuffer as a shader resource (I don't want to create additional intermediate rendertargets).

Is there any way of using CreateShaderResourceView to obtain a shader resource view from the backbuffer? I just debugged a little and it seems that the swapchain Texture2D is created using only D3D10_BIND_RENDER_TARGET. For being able to create a shader resource view it should be created using D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE. Is there any way to control this, or maybe other workaround for using the backbuffer as shader resource input in a shader?

Cheers!
Jorge

Share this post


Link to post
Share on other sites
Advertisement
Yes, when the call to CreateDeviceAndSwapChain(), or the call to just CreateSwapChain() is made you have the opportunity to indicate usage flags for the back buffer using DXGI_SWAP_CHAIN_DESC::BufferUsage. The flags would be: DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT

Share this post


Link to post
Share on other sites
Thanks! It did the trick.

We are facing other problem now: we want to create both a RGB and a SRGB shader resource views. AFAIK, for this, the format of the underlaying Texture2D format must be typeless (DXGI_FORMAT_R8G8B8A8_TYPELESS). However it seems DX doesn't allow to create a device with a DXGI_FORMAT_R8G8B8A8_TYPELESS format as backbuffer (we are using DXGI_MODE_DESC in the DXUTSetCallbackDeviceChanging callback to set the backbuffer format). Do you know of any workaround for this problem?

Thanks!

Share this post


Link to post
Share on other sites
A swapchain's back buffer can't be typeless because there's no way for you to tell the hardware what the format is when you call present.

Share this post


Link to post
Share on other sites
So, I suppose there is no way of having both a RGB and sRGB shader resource views of the backbuffer then, is there?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!