• Advertisement
Sign in to follow this  

How to create a Texture3D from the memory?

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



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



It's stored as 6 * 7 data blocks.



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.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.


Share this post

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

  • Advertisement