Render rendertargets.

Started by
12 comments, last by korvax 11 years ago

Hi,

im currently exprementing and trying to learn about buffers/gbuffers and using diffrent rendering targets.

So my question is how do i texture that quad with render target 1 as a texture. All the help i verry much appreacheated.


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


PSOutput main(PS_INPUT input) 
{
	PSOutput output;
	output.Color = diffuse*txDiffuse.Sample(samLinear, input.texcoord);;
	output.Normal = input.normal;
	return output;
}

Advertisement

You can simply assign the rendertarget as an input texture, like you would do with any other texture. I suppose you have some issue with that...?

To be honest, im not even sure where to start. I use ShaderResourceViews as for more "normal" texture.. Im quiet green to DX.

Oh, didn't read you was DX11, thats not quite my buisness, sorry! But can't you create a ShaderResourceView from your rendertarget? Unless D3D11 changed handling of rendertarget dramatically they should qualify here as well. If thats not the case, I'd have to pass :/

In D3D11 you create the texture you want to use as a render target and CreateRenderTargetView. If you then want to use it as a normal texture as well you create a normal CreateShaderResourceView with the same texture. Just make sure you don't use the views at the same time in one present loop.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

Thx NightCreature83 that make seens actually. Will see if i can get it to work next week.

What do you men dont use the views at the same time in one present loop?

"Present loop" sounds like you couldn't use the same resource as input and output in the same frame. This is of course wrong. What he meant is: You can't bind the same resource as input and output at the same time. (E.g. you can't sample from a texture you're also using as a render target).

The pipeline will automatically nullify such attempts, so make sure you detach a resource before you attach it elsewhere. The debug layer will also report this very clearly (if enabled at device creation).

Ok, i think i manged to create a rendertarget and and a shaderview based on the same texture.

But im no getting the error msg that you guys described "Resource being set to PS shader resource slot 0 is still bound on output! Forcing to NULL".. So my question now is obviously what im doing wrong now? :)

im using OMSetRenderTargets to set all my render targets to the device and in my shader it looks like this.

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


PSOutput main(PS_INPUT input)
{
PSOutput output;
output.Color = diffuse*txDiffuse.Sample(samLinear, input.texcoord);;
output.Normal = input.normal;
return output;
}

If you bind either the color or normal buffer to samLinear it will not work. The problem you are now getting is probably that you forgot to reset the render target to the backbuffer when you want to read from these textures.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

If you bind either the color or normal buffer to samLinear it will not work. The problem you are now getting is probably that you forgot to reset the render target to the backbuffer when you want to read from these textures.

Sorry not quiet following you (quiet green indeed). rest the render target to the backbuffer when you want to read form these textures, can you elaborate more pls?

Complete Warning:

ID3D11DeviceContext::PSSetShaderResources: Resource being set to PS shader resource slot 0 is still bound on output! Forcing to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD]

This topic is closed to new replies.

Advertisement