Jump to content

  • Log In with Google      Sign In   
  • Create Account


DX11 - Multiple Render Targets


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
23 replies to this topic

#1 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 25 June 2013 - 05:33 AM

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!


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

Sponsor:

#2 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 25 June 2013 - 01:38 PM

You're awfully quiet.

 

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


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#3 MJP   Moderators   -  Reputation: 11017

Like
1Likes
Like

Posted 25 June 2013 - 06:09 PM

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.



#4 Juliean   GDNet+   -  Reputation: 2453

Like
0Likes
Like

Posted 27 June 2013 - 02:08 AM

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.



#5 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 27 June 2013 - 04:37 AM

Pix Output:

 

2ikv1ww.png


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#6 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 27 June 2013 - 05:16 AM

No warnings at all...


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#7 Alessio1989   Members   -  Reputation: 1959

Like
1Likes
Like

Posted 27 June 2013 - 07:49 AM

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


001100010010011110100001101101110011


#8 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 28 June 2013 - 04:03 PM

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


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#9 phantom   Moderators   -  Reputation: 7155

Like
0Likes
Like

Posted 28 June 2013 - 05:14 PM

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

#10 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 28 June 2013 - 05:38 PM

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


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#11 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 29 June 2013 - 04:21 AM

Just so you know, the render targets are valid, as when I clear them with, e.g. a red or a green color, it appears in the output, even in pix.

 

But it still appears as if the second and third render targets aren't being written to...


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#12 Juliean   GDNet+   -  Reputation: 2453

Like
0Likes
Like

Posted 29 June 2013 - 04:56 AM

Look at the render targets while having selected the draw call that should render to them. what shows up there? Right-click any pixel, and press "debug pixel". Also, try to output explicitely float4(1.0f, 1.0f, 1.0f, 1.0f) to the second and third render target - there might be some issue with your calculations here.



#13 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 29 June 2013 - 05:37 AM

When debuggin the first RT, the pixel is written to correctly:

 

Pixel History
Pixel (427, 298) of Render Target 0x069F85B8, Frame 616
 

Initial framebuffer value     Alpha: 0.000 Red: 0.000 Green: 0.000 Blue: 0.000   Event 315: ID3D11DeviceContext::ClearRenderTargetView(0x0BAA5F98, 0x0017F1EC)     Alpha: 1.000 Red: 0.000 Green: 1.000 Blue: 0.000   Event 329: ID3D11DeviceContext::DrawIndexed(36, 0, 0) Primitive 1 of 12

Vertex Shader:0x0BAA5EE8
Debug Vertex 0
Debug Vertex 1
Debug Vertex 2

Geometry Shader:(none)

Pixel Shader:0x0BAA5F40
Debug Pixel (427, 298)
Pixel shader output:   Alpha: 1.000 Red: 0.988 Green: 0.988 Blue: 0.988
Final framebuffer color:   Alpha: 0.000 Red: 0.000 Green: 0.000 Blue: 0.000   Event 329: ID3D11DeviceContext::DrawIndexed(36, 0, 0) Primitive 11 of 12

Vertex Shader:0x0BAA5EE8
Debug Vertex 0
Debug Vertex 1
Debug Vertex 2

Geometry Shader:(none)

Pixel Shader:0x0BAA5F40
Debug Pixel (427, 298)
Pixel shader output:   Alpha: 1.000 Red: 0.988 Green: 0.988 Blue: 0.988
Final framebuffer color:   Alpha: 0.000 Red: 0.000 Green: 0.000 Blue: 0.000   Final framebuffer value     Alpha: 1.000 Red: 1.000 Green: 0.000 Blue: 0.000  

 

But then in the 2nd render target, nothing is there!

 

Same pixel location as in the 1st RT:

 

Pixel History
Pixel (427, 298) of Render Target 0x069F8658, Frame 616
 

Initial framebuffer value     Alpha: 0.000 Red: 0.000 Green: 0.000 Blue: 0.000   Event 317: ID3D11DeviceContext::ClearRenderTargetView(0x0BAA6048, 0x0017F1EC)     Alpha: 1.000 Red: 1.000 Green: 0.000 Blue: 0.000   Final framebuffer value     Alpha: 1.000 Red: 1.000 Green: 0.000 Blue: 0.000  
Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#14 Juliean   GDNet+   -  Reputation: 2453

Like
0Likes
Like

Posted 29 June 2013 - 05:42 AM

Thats odd. On that same draw-call, look at the device, and inspect its states till you have found the render-target section (don't know which category its under, you should easily find it). Are all render targets still bound at this point in time?



#15 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 29 June 2013 - 07:31 AM

Render Targets

 

Slot Buffer

0 0x069F85B8

1 0x069F8658

2 0x069F86F8

(3-7) NULL


Edited by Migi0027, 29 June 2013 - 07:31 AM.

Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#16 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 29 June 2013 - 07:33 AM

And all of those pointers are valid, they point to the right render targets!


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#17 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 29 June 2013 - 03:15 PM

316oml2.png


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#18 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 30 June 2013 - 09:14 AM

I dont know if this is too much to ask for, but maybe one of you guys can write a small mini tutorial with all the steps to create a directx 11 app with multiple render targets, like a small step based tutorial, e.g.:

 

  • Do this...
  • ...
  • Then that

To see if I've done everything right... wacko.png


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#19 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 30 June 2013 - 04:12 PM

I do believe that all my render targets are valid, as if I change the order of the render targets, it's still the first render target that works.

 

Btw, how can you check the maximum render targets your graphics card supports?


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!

#20 Migi0027   Crossbones+   -  Reputation: 1659

Like
0Likes
Like

Posted 01 July 2013 - 03:59 AM

The output signature of the pixel shader:

// Output signature:
//
// Name                 Index   Mask Register SysValue Format   Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_Target                0   xyzw        0   TARGET  float   xyzw
// SV_Target                1   xyzw        1   TARGET  float   xyzw
// SV_Target                2   xyzw        2   TARGET  float   xyzw

After hours in PIX, all the render targets seems to be connected correctly, but when rendering the mesh (PIX has the quite amazing feature where you can see the resources change over time!), still only the first render target gets written to!


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS