Sign in to follow this  
yk_cadcg

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

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
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

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