Jump to content

  • Log In with Google      Sign In   
  • Create Account


Create and fill texture array


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Tournicoti   Prime Members   -  Reputation: 682

Like
0Likes
Like

Posted 12 March 2013 - 11:11 PM

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

 



Sponsor:

#2 MJP   Moderators   -  Reputation: 10235

Like
1Likes
Like

Posted 13 March 2013 - 12:06 AM

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.



#3 Tournicoti   Prime Members   -  Reputation: 682

Like
0Likes
Like

Posted 13 March 2013 - 06:20 AM

Thank you MJP smile.png, it solved my problem


Edited by Tournicoti, 14 March 2013 - 12:44 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS