• Advertisement
Sign in to follow this  

[gpgpu, dx 10] pingpong rendertarget can't work right

This topic is 3967 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, sorry I posted too much these days. tough time. Hope useful for upcomers:) for gpgpu, i have to read the output of next pass. this goes to MRT using pingpong textures: pass i: ps reads texA in, renders to texB; pass i+1: ps reads texB in, renders to texA; ... My code is all wondered by myself, so seniors please give suggestions, thanks: (omitted unimportant descs, since they prove to be ok)
ID3D10Texture2D*		pTexAB[2] = {NULL};
ID3D10RenderTargetView*		pRTViewAB[2] = {NULL};
ID3D10ShaderResourceView*	pResViewAB[2] = {NULL};

//1. texture
	descTex.Usage = D3D10_USAGE_DEFAULT;
	descTex.CPUAccessFlags = 0;
	for(int i = 0; i < 2; ++i)
		V(g_pd3dDevice->CreateTexture2D(&descTex, NULL, &pTexAB));

	//2. render target view
	descRTView.Format = descTex.Format;
	for(int i = 0; i < 2; ++i)
		V(g_pd3dDevice->CreateRenderTargetView(pTexAB, &descRTView, &pRTViewAB));
	//3. shader resource view
	descResView.Format = descTex.Format;
	for(int i = 0; i < 2; ++i)
		V(g_pd3dDevice->CreateShaderResourceView(pTexAB, &descResView, &pResViewAB));
in the rendering: (I already have N other data rendertargets)
	ID3D10RenderTargetView* pViewMRT[N + 1] = {NULL};
	for(int i = 0; i < N; ++i)
		pViewMRT = pViewTexData;
	int pass = 0;
	int pingpongRT = 0;
	for(; pass < _maxPasses; ++pass)
		pViewMRT[N] = pRTViewFoot[pingpongRT];  //renders to one tex
		g_pd3dDevice->OMSetRenderTargets(N + 1, pViewMRT, pViewTexDepth);   
		V((g_pEffect->GetVariableByName("texAB")->AsShaderResource())->SetResource(pResViewAB[1 - pingpongRT]));	//reads another tex in

That's all the codes. When I test using g_pd3dDevice->CopyResource(pStagingTest, pTexAB[pingpongRT]); I found it doesn't work: whenever, only tex0 has written result, tex1 is all 0. And I noticed that when stepping to "OMSetRenderTargets" line, the output window spits: D3D10: WARNING: ID3D10Device::OMSetRenderTargets: Resource being set to OM RenderTarget slot 1 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 ] [/quote] I have to "unbind" the Resource input first, but how? What's the problem? I guess I missed some necessary Set..(). Thanks! //ps from the bottom para of sdk's "Choosing a Resource (Direct3D 10)", they suggest CopyResource rather than 2 views' pinpong. So I give up pingpong. //psps even CopyResource doesn't work. sleep for now. dream of ps not. [Edited by - yk_cadcg on May 14, 2007 10:07:27 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement