I have Texture3Da Texture3D. I want to read a part of it from CPU side.
(I'm using the SharpDX toolkit (v2.5.1).)
My data is always 0. it's not working, but I don't get any errors in the output shows no errors.
This is the source texture:
testTex = Texture3D.New<float>(GraphicsDevice, wx, wy, wz, PixelFormat.R32.Float, texDat, TextureFlags.ShaderResource, sdx11.ResourceUsage.Default);
And I'm trying to read part of it here:
tempFloat = new float[1];
TextureDescription stagedTexDesc = new TextureDescription()
{
Height = 1,
Width = 1,
Depth = 1,
MipLevels = 1,
ArraySize = 1,
Format = testTex.Format,
Usage = sdx11.ResourceUsage.Staging,
CpuAccessFlags = sdx11.CpuAccessFlags.Read | sdx11.CpuAccessFlags.Write,
};
texNew = Texture3D.New(GraphicsDevice, stagedTexDesc);
deviceContext.CopySubresourceRegion(testTex, 0, new sdx11.ResourceRegion(iHPos.X, iHPos.Y, iHPos.Z, iHPos.X + 1, iHPos.Y + 1, iHPos.Z + 1), texNew, 0);
texNew.GetData(tempFloat);
tempFloat[0]tempFloat[0] value is always 0.0. GetDataThe GetData method performs MapMap and UnmapUnmap of the resource automatically.
If
If I try to call GetData methodGetData on the original texture then, it seems that it getsto get the data correctly.
Also
Also, is there somea better way to read the data?