Jump to content
  • Advertisement
Sign in to follow this  
yk_cadcg

[d3d10] CreateTexture2D() can't be RenderTarget&&Stage?

This topic is 4060 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, I want to render-to-texture, and for some reason I must readback the multiple rendertarget to cpu. Thus I wrote below, but failed.
		D3D10_TEXTURE2D_DESC desc;
		ZeroMemory( &desc, sizeof(desc) );
		desc.Width = texW;
		desc.Height = texRH;
		desc.MipLevels = 1;
		desc.ArraySize = 6;
		desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
		desc.SampleDesc.Count = 1;
		desc.SampleDesc.Quality = 0;
		desc.MiscFlags = 0;
		desc.BindFlags = D3D10_BIND_RENDER_TARGET;
		desc.Usage = D3D10_USAGE_STAGING; //D3D10_USAGE_DEFAULT;
		desc.CPUAccessFlags =D3D10_CPU_ACCESS_READ;//0;

		ID3D10Texture2D* pRenderTarget = NULL;
		V(g_pd3dDevice->CreateTexture2D( &desc, NULL, &pRenderTarget ));
I checked sdk:
Quote:
"The CPU can only read from resources created with the D3D10_USAGE_STAGING flag. Since resources created with this flag cannot be set as outputs of the pipeline, if the CPU wants to read the data in a resource generated by the GPU, the data must be copied to a resource created with the staging flag. "
I guess there's no way to stage a rendertarget resource directly? I must create MRT as _Default, and after rendered, I have to Copy it to another Stage texture, and then I can Map it to CPU, is it? Is there any lightweight way to achieve my goal? Thank you!

Share this post


Link to post
Share on other sites
Advertisement
A staging resource could not bind on any pipeline stage. Therefore a copy from a bind able resource could not be avoided.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!