Render rendertargets.

Started by
12 comments, last by korvax 11 years ago
When you want to use the rendertargets as a texture to read from you need to unbind the rendertargetviews for them and reset this to the actual backbuffer the one you want to show on screen.

Before you set your render targets you want to call this function http://msdn.microsoft.com/en-us/library/windows/desktop/ff476460%28v=vs.85%29.aspx and once you are done rendering to these targets you call OMSetRenderTargets again and pass it the information the function call in the link gives you.

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

Advertisement

When you want to use the rendertargets as a texture to read from you need to unbind the rendertargetviews for them and reset this to the actual backbuffer the one you want to show on screen.

Before you set your render targets you want to call this function http://msdn.microsoft.com/en-us/library/windows/desktop/ff476460%28v=vs.85%29.aspx and once you are done rendering to these targets you call OMSetRenderTargets again and pass it the information the function call in the link gives you.

I manged to get it work and but even better i full understand it want im doing as well Thx so much for you help NightCreature83.

I havent got the GetRenderTargets -> SetRenderTargets to work, think i need to do some reading about ** to * i guess. But thx again for you help!

Thats an easy fix just put a & in front of the variable you are passing to getRenderTargets, as like this (pseudo code for your problem)

void function(int** var);

//This is then called as this
int* anotherVar;
function(&anotherVar);

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

HI again, sorry for this NightCreateure83 (or anyone else :) just one more thing.

I got it to work as i wrote before, but im getting some warnings that i would like to get ride off. I gueesing im not resting the them correctly or that im doing it in the wrong order.

* 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]
* D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets: Resource being set to OM RenderTarget slot 1 is still bound on input! [ STATE_SETTING WARNING #9: DEVICE_OMSETRENDERTARGETS_HAZARD]
* D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets[AndUnorderedAccessViews]: Forcing PS shader resource slot 0 to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD]
My order.
1) Setting all rendertargets, there are two off them the main output and one with normals that Im rendering to a Quad.

void PipelineManagerDX11::SetRenderTargetView(TArray<ID3D11RenderTargetView*> renderTargets,ID3D11DepthStencilView* pDepthStencilView)
{
	m_RenderTargets = renderTargets;	
	m_pDepthStencilView = pDepthStencilView;
	UINT nViews = m_RenderTargets.count();
	ID3D11RenderTargetView*	rtvs[2];	
	for (UINT i= 0; i<nViews;++i){	
		rtvs = m_RenderTargets;
	}
	m_pContext->OMSetRenderTargets(nViews,rtvs,m_pDepthStencilView);	
}
 

2) Render the scene

3) Resting the Rendertarget, setting Rendertarget 2 to null so i can use the the texture and Setting render target 1 to the device.


ID3D11RenderTargetView* rTargets[2] = {m_RenderTargets[0], NULL };
m_pContext->OMSetRenderTargets(2, rTargets, NULL);

4) rendering the quad with Shaderview bound to the texture that Rendertarget 2 is using.


m_pContext->PSSetShaderResources(0, 1, &m_pShaderResourceView);		
m_pContext->VSSetShader(m_pVertexShader, NULL, 0 );
m_pContext->PSSetShader(m_pPixelShader, NULL, 0);
m_pContext->DrawIndexed(m_QuadIB->m_numIndices,0,0);


5) Setting all the rendertargets as i did in step one.


SetRenderTargetView(m_RenderTargets,m_pDepthStencilView);

6) Ending the pipeline with the usual stuff, clearing all the renderingtargets, swaping the backbufffer, present etc.

Stupied me, this I already knew :), thx anyway!

Thats an easy fix just put a & in front of the variable you are passing to getRenderTargets, as like this (pseudo code for your problem)


void function(int** var);

//This is then called as this
int* anotherVar;
function(&anotherVar);

This topic is closed to new replies.

Advertisement