DirectX11 Help with Multiple Render Targets

Started by
5 comments, last by myers80 12 years, 10 months ago
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);
Advertisement
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?

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?


Yeah, the HRESULT returns OK
my guessing is that you forget to get actual backbuffer address.
in initialize phaze like this
pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ),(LPVOID*)&pBackBuffer);

my guessing is that you forget to get actual backbuffer address.
in initialize phaze like this
pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ),(LPVOID*)&pBackBuffer);


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.

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

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 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?

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 :)

This topic is closed to new replies.

Advertisement