• Advertisement
Sign in to follow this  

Create and fill texture array

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

Hello

 

I'm trying to load several textures into a texture array :

		D3D10_TEXTURE2D_DESC desc;
		ZeroMemory(&desc,sizeof(desc));
		desc.Width=width;
		desc.Height=height;
		desc.ArraySize=nbFrames;
		desc.MipLevels=1;
		desc.Format=DXGI_FORMAT_R8G8B8A8_UNORM;
		desc.SampleDesc.Count=1;
		desc.Usage=D3D10_USAGE_DYNAMIC;
		desc.BindFlags=D3D10_BIND_SHADER_RESOURCE;
		desc.CPUAccessFlags=D3D10_CPU_ACCESS_WRITE;

		if FAILED(device->CreateTexture2D(&desc,NULL,&texture)) return false;

But I get an exception : ID3D10Device::CreateTexture2D: A D3D10_USAGE_DYNAMIC Resource must have ArraySize equal to 1.

How can I create a texture array with a CPU-write access (as a shader resource and with dynamic usage) please ? Or equivalent ?

 

Thanks

Nico

 

Share this post


Link to post
Share on other sites
Advertisement

You only want to use DYNAMIC usage if the resource will actually be dynamic. In other words, that usage is designed for cases where the CPU will need to update the contents of the resource many times during the lifetime of that resource. If you just want a static read-only texture, then you should use IMMUTABLE usage and initialize the contents of the texture using the pInitialData parameter. For the case of a texture array, you'll want to pass a pointer to an array of N D3D10_SUBRESOURCE_DATA, where N is the number of array slices in your texture. Then for each D3D10_SUBRESOURCE_DATA, you need to set pSysMem to a pointer to the texture data for a single array slice.

Share this post


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

  • Advertisement