DX11 - Multiple Render Targets

Started by
22 comments, last by Migi0027 10 years, 9 months ago

Hi guys, again...

I'm having a problem with multiple render targets, where only the first render target gets filled out (has a value).

Setting the render targets:


DeferredRender.ApplyShader(dev, devcon);

DeferredRender.mDepth.ClearRenderTarget(devcon, zbuffer, 0, 0, 0, 1);
DeferredRender.mNormals.ClearRenderTarget(devcon, zbuffer, 0, 0, 0, 1);
DeferredRender.mLighting.ClearRenderTarget(devcon, zbuffer, 0, 0, 0, 1);

ID3D11RenderTargetView *deferredViews[3];

deferredViews[0] = DeferredRender.mDepth.m_renderTargetView;
deferredViews[1] = DeferredRender.mNormals.m_renderTargetView;
deferredViews[2] = DeferredRender.mLighting.m_renderTargetView;

devcon->OMSetRenderTargets(3, deferredViews, zbuffer);

RenderScene(STATE_DEFERRED);

gBuffer_Depth = DeferredRender.mDepth.GetShaderResourceView();
gBuffer_Normals = DeferredRender.mNormals.GetShaderResourceView();
gBuffer_Lighting = DeferredRender.mLighting.GetShaderResourceView();

Pixel Shader: (This is just a testing shader, it isn't complete)


struct POut
{
	float4 Depth    : SV_Target0;
	float4 Normals  : SV_Target1;
	float4 Lighting : SV_Target2;
};

POut PShader(VOut input)
{
	POut output;

	// Initialize
	output.Depth = float4(0,0,0,1);
	output.Normals = float4(0,1,0,1);
	output.Lighting = float4(0,1,0,1);

	// Depth
	float depth = (input.depthPosition.z / input.depthPosition.w);
	output.Depth = float4(depth, depth, depth, 1);
	if (_alphamap == 1)
	{
		output.Depth.a *= t_alphamap.Sample(ss, input.texcoord).a;
	}
	if (_diffusealpha == 1)
	{
		output.Depth.a *= t_dffalpha.Sample(ss, input.texcoord).a;
	}

	// Normals
	float3 viewSpaceNormalizedNormals = 0.5 * normalize (input.normal) + 0.5; //0.5 * normalize (input.normal) + 0.5
	output.Normals = float4(viewSpaceNormalizedNormals, 1);

	return output;
}

But as I said, only the first render target gets set, the others doesn't, and I don't get why. Am I even setting the render targets correctly?

THANKS!

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

Advertisement

You're awfully quiet.

Am i missing a crucial piece of information here? blink.png

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

Use PIX or VS 2012 Graphics Debugger to inspect device state at the time of the draw call, it will tell you what render targets are currently bound.

Also make sure to create your device with the debug flag, this will tell you if there is any problem.


				UINT createDeviceFlags = 0;
#ifdef _DEBUG
    createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

				if(FAILED(D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, createDeviceFlags, nullptr, 0, D3D11_SDK_VERSION, &description, &m_pSwapChain, &m_pDevice, &m_featureLevel, &m_pContext)))
					throw d3dException();

You could have some mismatch between your render targets, but my quess is just as good as yours, so check for debug output and PIX is the way to go.

Pix Output:

2ikv1ww.png

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

No warnings at all...

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

"maybe" could be a driver issue, try to run your code in reference mode (or warp mode since reference mode is VERY slow).

"Recursion is the first step towards madness." - "Skegg?ld, Skálm?ld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

Do you need to create the shader in a special way to accept multiple render targets? huh.png

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

That pix capture just shows you are setting 3 RTVs; do the RTVs all point at the textures you expect them to?

When looking at where they are pointing at, all three paths appear black (empty black preview), but I know that one works, the depth mapping (RTV #1).

This is confusing... dry.png

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

This topic is closed to new replies.

Advertisement