[DirectX10] My texture views get set to NULL

Started by
4 comments, last by mind in a box 13 years, 11 months ago
I am writing a bloom post processing shader at the moment, and I got a problem. DirectX sets my textures views to NULL, because it thinks that they are bound as output already. But that is not true (Or it is?)! Here is my code:

void PP_EngineEffect::OnRender(Mesh* PlaneMesh)
{
	//RenderQuad(PlaneMesh,SimpleShader);

	if(!PongTex || !PingTex)
	{
		return; //Those textures didn't get created
	}
	
	//------------------------
	//Begin rendering the bloom. I use 2 textures (Ping and pong) to switch between them
	//for doing such things like downscaleing and blurring.
	//------------------------


	//Downscale the rendertarget and apply brightpass
	SetRenderTexture(PingTex->RenderTargetView); //Set the new backbuffer
	BrightPass->SetBackBufferVar(NULL); //Set the texture, where the world is rendered to, to the shader (NULL uses the default backbuffer)
	RenderQuadSized(PlaneMesh,BrightPass,0.25,0.25,  0.25,0.25); //Draw quad at size 0.25,0.25 and set the scissoring rect to 0.25,0.25 as well


	//horizontaly blur the rendertarget
	SetRenderTexture(PongTex->RenderTargetView);
	HBlur->SetBackBufferVar(PingTex->ShaderResView);
	RenderQuadSized(PlaneMesh,HBlur,1,1,  0.25,0.25);
	HBlur->SetBackBufferVar(NULL);


	//Verticaly blur the rendertarget 
	SetRenderTexture(PingTex->RenderTargetView);
	VBlur->SetBackBufferVar(PongTex->ShaderResView);
	RenderQuadSized(PlaneMesh,VBlur,1,1,  0.25,0.25);
	VBlur->SetBackBufferVar(NULL);


	//Upscale the blur
	SetRenderTexture(PongTex->RenderTargetView);
	SimpleShader->SetBackBufferVar(PingTex->ShaderResView);
	RenderQuadSized(PlaneMesh,SimpleShader,4,4,  1,1);
	SimpleShader->SetBackBufferVar(NULL);




	//Apply the blooming to the rendertarget
	SetRenderTexture(PingTex->RenderTargetView);
	Combiner->SetBackBufferVar(NULL); //Original scene
	if(Combiner->CustomTextureVariable)
	{
		Combiner->CustomTextureVariable->SetResource(PongTex->ShaderResView); //Blurred and brightpassed scene
	} 

	RenderQuadSized(PlaneMesh,Combiner,1,1,  1,1);

	if(Combiner->CustomTextureVariable)
	{
		Combiner->CustomTextureVariable->SetResource(NULL); //Need to NULL (default backbuffer) this (Do I?)
	} 
	Combiner->SetBackBufferVar(NULL);





	//And at least, copy the scene back to the backbuffer
	SetRenderTexture(StartRenderTarget);
	SimpleShader->SetBackBufferVar(PingTex->ShaderResView); //Original scene
	RenderQuadSized(PlaneMesh,SimpleShader,1,1,  1,1);
	SimpleShader->SetBackBufferVar(NULL);

}

The CustomTextureVariable of the Combiner-shader is a special variable for coders to do something with it, without hurting the users freedom of using other textures. SetRenderTexture() sets the current backbuffer And here is what directX says:

D3D10: WARNING: ID3D10Device::OMSetRenderTargets: Resource being set to OM RenderTarget slot 0 is still bound on input! [ STATE_SETTING WARNING #9: DEVICE_OMSETRENDERTARGETS_HAZARD ]
D3D10: WARNING: ID3D10Device::OMSetRenderTargets: Forcing PS shader resource slot 0 to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD ]
These warnings cause that the whole downscale/blurring/etc stuff doesn't run. (It works, I tested it in a simple test) So, how to fix it=
Advertisement
I doubt that the device is mistaken about which resources are set as render target views and shader resource views. You can find out yourself pretty easily by using PIX: find the draw call, look at the device state, and see which resources are bound.
Somehow, PIX crashes everytime I want to use it with my engine. But only if I do the "Press F12 to log everything" option. Every other works. It gives an assert that my backbuffer is not at the same size as my window. I'll try a release build now...

EDIT: And the releas build doesn't starts, because of a side-by-side config problem. ???
Quote:Original post by mind in a box
It gives an assert that my backbuffer is not at the same size as my window.


Well, is it?

Without PIX, it is...

EDIT: Do I have to validate the new setting of the Rendertarget first? If yes: How?

[Edited by - mind in a box on April 30, 2010 2:37:14 PM]
What is, when it IS bound? How can I unbind them? You see, I set a new ShaderResource and a new Rendertarget before I switch them. Do I need to do something to validate the new settings (Like with a draw call)?

This topic is closed to new replies.

Advertisement