Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Loading a texture array a layer at a time


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 Funkymunky   Members   -  Reputation: 762

Like
0Likes
Like

Posted 29 March 2014 - 04:30 PM

I have a piece of code that loads several textures into the layers of a texture array (which was created with a usage flag of D3D11_USAGE_STAGING).  Right now, I call:

 

D3D11DeviceContext->Map(Texture2DResource, 0, D3D11_MAP_WRITE, 0, &mappedResource)

 

Then I do a memcpy to the mappedResource.pData, with an offset based on the layer of the texture I want to load.  Then I Unmap.  (Every layer has the same dimensions and depth of course).

 

The problem is, I only see the last texture I loaded.  I had thought that since I wasn't using D3D11_MAP_WRITE_DISCARD, it would leave the untouched contents of the texture resource alone.

 

Is there a way to do what I want?  Or do I have to rework my architecture.  I understand that it would be faster and more efficient to have all my data at one time, Map once, and copy it all... but I'm still wondering if it's possible to load the layers individually.



Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 8966

Like
1Likes
Like

Posted 29 March 2014 - 04:42 PM

Yes, it's possible.  You use the subresource parameter to Map to specify which array slice you're mapping, and you must also take account of any mipmap levels in the textures.  See http://msdn.microsoft.com/en-us/library/windows/desktop/ff476901%28v=vs.85%29.aspx for more info and discussion.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 Funkymunky   Members   -  Reputation: 762

Like
1Likes
Like

Posted 29 March 2014 - 04:50 PM

Ah!  So I was mistaken in my first analysis, it was only showing me the first texture i'd loaded!  Thanks mhagain, your response led me to the function D3D11CalcSubresource, which in turn led me to realize that the problem wasn't in the portion of my code where I mapped, memcpy'd, and unmapped (after I updated it per your response of specifying the subresource).  It was in the portion after, where I created the shader resource view and copied my texture set up as D3D11_USAGE_STAGING to one set up as D3D11_USAGE_DEFAULT.  I was only copying the first subresource.

 

Thanks again!


Edited by Funkymunky, 29 March 2014 - 05:19 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