Sign in to follow this  

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

This topic is 3869 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

This topic is 3869 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this