Skip to main content
gamedev.net
🔒 Locked

The Pixel Shader expects a Render Target View

Started by korvax Jun 17, 2013 at 7:28 PM 2 replies 17.8k views
Original Post
korvax
korvax

Hi, im rendering to to rendering targets and render on of those targets to a texture. Which seems to work fine, its displaying what it should, a quad in the corner showing the normals as of the scene as a color.

Im getting this warning and trying to understand what it means

D3D11 WARNING: ID3D11DeviceContext::DrawIndexed: The Pixel Shader expects a Render Target View bound to slot 1, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here. [ EXECUTION WARNING #3146081: DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET]

This is what i think is happening, would be awesome if some one could confirm or despute this.

1) Set both rendertargets with OMSetRenderTargets and the DepthStencilView

2) Render the scene -> which the PixelShader in turn fills with Color output SV_Target0 and SV_Target1 with Normals.

3) Sets the Rendertarget

4) Render the quad with is linked to SV_Target1 but because I use the same PixelShader as "the main scene" nothing is

bound to SV_Target1. Because only on RenderTarget is active

What i think this means i no Render target is bound SV_Target1 when i draw the quad.

PixelShader


Texture2D txDiffuse : register( t0 );
SamplerState samLinear : register( s0 );

cbuffer cbPerObject : register(b0)
{

	float4 diffuse;
	float4 lightDirection;
	float4 lightColor;
	float4 lightAmbient;
	bool isTextured;	
}

//--------------------------------------------------------------------------------------

struct PS_INPUT
{
    float4 position	 : SV_POSITION;
    float2 texcoord	 : TEXCOORD0;	
	float3 normal	: NORMAL;
};

struct PSOutput
{
	float4 Color : SV_Target0;
    float3 Normal : SV_Target1;
};

//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
PSOutput main(PS_INPUT input) 
{
     PSOutput output;
    float4 finalColor=0;
    if (isTextured==true){
	   finalColor =  diffuse*txDiffuse.Sample(samLinear, input.texcoord); 
     }
    else{
      finalColor = diffuse;
     }
	output.Color = diffuse*txDiffuse.Sample(samLinear, input.texcoord);;
	output.Normal = input.normal;
	return output;
}

Thx for the help.

MJP
MJP

That warning means your pixel shader is trying to write out to SV_Target1, but you have a NULL render target view bound to the device context for slot 1. It won't actually cause a problem since the write to SV_Target1 will just be ignored, but you will be wasting a little bit of performance.

korvax
korvax

Hi, thx for the help.

So to get rid of this warning I should have a special shader that only have a SV_Target0 to render the quad. And not use the main one.

Jason Z
Jason Z

Hi, thx for the help.

So to get rid of this warning I should have a special shader that only have a SV_Target0 to render the quad. And not use the main one.

That's right - you should have a pixel shader that only tries to write to the buffers that you expect to be attached.

Jason Zink :: DirectX MVP   Direct3D 11 engine on CodePlex: Hieroglyph 3 Direct3D Books: 

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.