Advertisement Jump to content
Sign in to follow this  
Albeoris

How to create a Texture3D from the memory?

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

Hi,

 

I have a DDS CubeMap texture in the memory: 64x64, depht: 1, mipmaps: 7, format: BC3_UNorm_SRgb.

ibAsyHH.png

 

It's stored as 6 * 7 data blocks.

iVHwy2M.png

 

I trying to create a texture:

using (SafeUnmanagedArray array = new SafeUnmanagedArray(gtex.MipMapData.Sum(d => d.Length)))
{
    DataBox[] rects = new DataBox[gtex.MipMapData.Length];
    using (UnmanagedMemoryStream io = array.OpenStream(FileAccess.Write))
    {
        byte[] buff = new byte[32 * 1024];
        for (int index = 0; index < gtex.MipMapData.Length; index++)
        {
            GtexMipMapLocation mimMap = gtex.MipMapData[index];
            Int32 rowPitch, depthPitch;
            GetPitch(descriptor, index % descriptor.MipLevels, out rowPitch, out depthPitch);

            rects[index] = CreateDataBox(array, io, rowPitch, depthPitch);
            input.SetPosition(mimMap.Offset);
            input.CopyToStream(io, mimMap.Length, buff);
        }
    }

    Texture3D texture = new Texture3D(_device, descriptor, rects);
    return new DxTexture(texture, descriptor);
}

But get an invalid MiscFlags exception (0x6). I think the problem in the wrong formation of DataCubes.

Or invalid depthPitch.

dCAL1Wi.png

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!