Jump to content
  • Advertisement
Sign in to follow this  
SeeMe

DX11 [SlimDX] Texture array with DirectX11

This topic is 2693 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 try to migrate my code to directX11, but I'm stuck at the creation of texture array.

here is the code I used with slimDX - DX 10 (Working fine) :



//Foreach Texture
for (int arraySlice = 0; arraySlice < srcTex.Length; arraySlice++)
{
//Foreach mipmap level
for (int mipSlice = 0; mipSlice < Imagesdesc.MipLevels; mipSlice++)
{
var mapped = srcTex[arraySlice].Map(mipSlice, MapMode.Read, MapFlags.None);
mapped.Data.Position = 0;

device.UpdateSubresource(new DataBox(mapped.Pitch, 0, mapped.Data),
texArray,
S33M3Engines.D3D.Tools.Resource.CalcSubresource(mipSlice, arraySlice, Imagesdesc.MipLevels)
);
srcTex[arraySlice].Unmap(mipSlice);
}
}



Here is the translated DX11 code :



for (int arraySlice = 0; arraySlice < srcTex.Length; arraySlice++)
{
//Foreach mipmap level
for (int mipSlice = 0; mipSlice < Imagesdesc.MipLevels; mipSlice++)
{
int mipHeight = ArrayTextureHelper.GetMipSize(mipSlice, srcTex[arraySlice].Description.Height);
int lockedSize = mipHeight * RowPtch; // <===== What's the Row pitch of the targetted texture2d mipmap subresource ?

DataBox box = device.ImmediateContext.MapSubresource(srcTex[arraySlice], mipSlice, lockedSize , MapMode.Read, MapFlags.None);

box.Data.Position = 0;
device.ImmediateContext.UpdateSubresource(box,
texArray,
S33M3Engines.D3D.Tools.Resource.CalcSubresource(mipSlice, arraySlice, Imagesdesc.MipLevels)
);
device.ImmediateContext.UnmapSubresource(srcTex[arraySlice], mipSlice);
}
}



The problem is :
- I don't know the rowpitch before the MapSubresource (The row pitch will after that be inside the databox). This rowpitch is needed to compute the sizeinbyte of my subresource
- MapSubresource need the sizeinbyte to create the databox.

So here I'm stuck ! How can I find it ? Can I compute what will be the rowpitch of the mipmap based on the mipmap level and the texture height + width ?

Tx you for your help !

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!