Jump to content
  • Advertisement
Sign in to follow this  
poigwym

DX11 How To Get/create Shader Resource For Dx11 Backbuffer

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

I CreateRenderTargetView use these code:
 
ID3D11Texture2D* backBuffer;
mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer));
mDevice->CreateRenderTargetView(backBuffer, 0, &mRenderTargetView);
 
I want to create a ShaderResource for it, and will be used to bind texture,  who know how to do?

Share this post


Link to post
Share on other sites
Advertisement

First, when you create the swapchain you need to set the DXGI_USAGE_SHADER_INPUT flag.

Second: when do you want to read from it? If it's after you've called Present(), then you need to make sure you use the DXGI_SWAP_EFFECT_SEQUENTIAL or DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL effects, and that the buffer you get is (BufferCount - 1). It it's before you call Present(), then none of that matters and you can just make the view of buffer 0.

Share this post


Link to post
Share on other sites

 matters and you can just make the view of buffer 0.

I need to read it .  The first(initial) render target.  The current back buffer.

PSSetShaderResources(slot, 1, 0); ????

Edited by poigwym

Share this post


Link to post
Share on other sites

I need to read it.


Do you?

What are you actually trying to accomplish with this?

It's usually a far better idea to render into an off-screen buffer and use _that_ as your shader input, using the back buffer for only the very final image.

If you're trying to grab a screen cap or something, consider using CopyResource to make staging textures instead of trying to read or manipulate the back buffer directly.

The windowing system is generally setup to treat the Swap Chain buffers very specially. You don't want to read out of them if you can at all avoid doing so.

Share this post


Link to post
Share on other sites

 

I need to read it.


Do you?

What are you actually trying to accomplish with this?

It's usually a far better idea to render into an off-screen buffer and use _that_ as your shader input, using the back buffer for only the very final image.

If you're trying to grab a screen cap or something, consider using CopyResource to make staging textures instead of trying to read or manipulate the back buffer directly.

The windowing system is generally setup to treat the Swap Chain buffers very specially. You don't want to read out of them if you can at all avoid doing so.

 

Thank you , I take it. 

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!