Sign in to follow this  
myers80

DirectX11 Help with Multiple Render Targets

Recommended Posts

I have had no luck all day trying to get multiple render targets to work. I have used them before in DirectX9 so the concept is not new, just the syntax. I keep getting an access violation error when calling OMSetRenderTargets. I would be very grateful if someone could point out the flaw in my logic. Here is the basic break down of what I'm doing,

ID3D11RenderTargetView* pRenderTargetView[2];

// Create the render target view with the back buffer pointer.
hr = pDevice->CreateRenderTargetView( pBackBuffer, NULL, &pRenderTargetView[0] );

hr = pDevice->CreateRenderTargetView( pRTargetTexture, &renderTargetViewDesc, &pRenderTargetView[1] );

==========

pDeviceContext->OMSetRenderTargets( 2, pRenderTargetView, NULL );

pDeviceContext->ClearRenderTargetView( pRenderTargetView[0], clearColor );
pDeviceContext->ClearRenderTargetView( pRenderTargetView[1], clearColor );

// Draw Geometry

pSwapChain->Present(1, 0);

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1307670798' post='4821563']
After calling [font="Lucida Console"]CreateRenderTargetView[/font], are you validating the return value and checking that your array of pointers has actually been filled in?
[/quote]

Yeah, the HRESULT returns OK

Share this post


Link to post
Share on other sites
my guessing is that you forget to get actual backbuffer address.
in initialize phaze like this
[code]pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ),(LPVOID*)&pBackBuffer); [/code]

Share this post


Link to post
Share on other sites
[quote name='katsh' timestamp='1307677816' post='4821583']
my guessing is that you forget to get actual backbuffer address.
in initialize phaze like this
[code]pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ),(LPVOID*)&pBackBuffer); [/code]
[/quote]

I do that for the back buffer, is there something similar I need to do for the render target?

I'm no longer getting the error message, and the back buffer is drawing fine. However, when I go to draw a small 2D quad of the render target's texture on the screen it is black. I'm even setting the clear color to red, but it still shows as a black quad. I've tested the textured quad drawing on a texture read from a file, so I know that is working correctly.

Share this post


Link to post
Share on other sites
[quote name='myers80' timestamp='1307678277' post='4821585']
I do that for the back buffer, is there something similar I need to do for the render target?
[/quote]
cant sure without actual code.

assuming the texture is fine, and still screen is black,then possible reasons are ....

1.polygon culling mode. set D3D10_RASTERIZER_DESC::CullMode to CULL_NONE.

2.the quad has no UV. or you dont pass the texture to the shader.(i mean you dont map the texture on the quad)

3.RenderTaget is not work. one or the other. or both. does clear color work on the normal rendertarget(i mean backbuffer one).

Share this post


Link to post
Share on other sites
[quote name='katsh' timestamp='1307679664' post='4821589']
[quote name='myers80' timestamp='1307678277' post='4821585']
I do that for the back buffer, is there something similar I need to do for the render target?
[/quote]
cant sure without actual code.

assuming the texture is fine, and still screen is black,then possible reasons are ....

1.polygon culling mode. set D3D10_RASTERIZER_DESC::CullMode to CULL_NONE.

2.the quad has no UV. or you dont pass the texture to the shader.(i mean you dont map the texture on the quad)

3.RenderTaget is not work. one or the other. or both. does clear color work on the normal rendertarget(i mean backbuffer one).
[/quote]

Got it! I wasn't releasing the render target from the geometry pass before drawing it on the quad. Thank you for your help though, you got me thinking :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this