Skip to main content
Fixed code formatting. Grammar.
Source Link
Anko
  • 13.5k
  • 10
  • 56
  • 82

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?

I have Texture3D. I want to read a part of it from CPU side.  I'm using SharpDX toolkit (v2.5.1).

My data is always 0. it's not working, but I don't get any errors in the output.

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] value is always 0.0. GetData method performs Map and Unmap of the resource automatically.
If I try to call GetData method on original texture then it seems that it gets the data correctly. Also, is there some better way to read the data?

I have a 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, but 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);

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] value is always 0.0. The GetData method performs Map and Unmap of the resource automatically

If I try to call GetData on the original texture, it seems to get the data correctly.

Also, is there a better way to read the data?

I have a Texture3D and. I would likewant to read just onea part of it on thefrom CPU side.
  I'm using SharpDX toolkit (v2.5.1), and I expected this code to work but the.

My data is always 0.
Also it's not working, but I don't get any errors in the output.

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 like thishere:

        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);

But tempFloat[0] value is always 0.0. GetData method performs Map and Unmap of the resource automatically.
If I try to call GetData method on original texture then it seems that it gets the data correctly. Also, is there some better way to read the data?

Thank you

I have a Texture3D and I would like to read just one part of it on the CPU.
  I'm using SharpDX toolkit (v2.5.1), and I expected this code to work but the data is always 0.
Also, I don't get any errors in the output.

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 like this:

        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);

But tempFloat[0] value is always 0.0. GetData method performs Map and Unmap of the resource automatically.
If I try to call GetData method on original texture then it seems that it gets the data correctly. Also, is there some better way to read the data?

Thank you

I have Texture3D. I want to read a part of it from CPU side. I'm using SharpDX toolkit (v2.5.1).

My data is always 0. it's not working, but I don't get any errors in the output.

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] value is always 0.0. GetData method performs Map and Unmap of the resource automatically.
If I try to call GetData method on original texture then it seems that it gets the data correctly. Also, is there some better way to read the data?

added 14 characters in body
Source Link
Renesis
  • 121
  • 6

I have a Texture3D and I would like to read just one part of it on the CPU.
I'm using SharpDX toolkit (v2.5.1), and I expected this code to work but the data is always 0.
Also, I don't get any errors in the output.

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 like this:

        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);

But tempFloat[0] value is always 0.0. GetData method performs Map and Unmap of the resource automatically.
If I try to call GetData method on original texture then it seems that it gets the data correctly. Also, is there some better way to read the data?

Thank you

I have a Texture3D and I would like to read just one part of it on the CPU.
I'm using SharpDX toolkit, and I expected this to work but the data is always 0.
Also, I don't get any errors in the output.

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 like this:

        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);

But tempFloat[0] value is always 0.0. GetData method performs Map and Unmap of the resource automatically.
If I try to call GetData method on original texture then it seems that it gets the data correctly. Also, is there some better way to read the data?

Thank you

I have a Texture3D and I would like to read just one part of it on the CPU.
I'm using SharpDX toolkit (v2.5.1), and I expected this code to work but the data is always 0.
Also, I don't get any errors in the output.

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 like this:

        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);

But tempFloat[0] value is always 0.0. GetData method performs Map and Unmap of the resource automatically.
If I try to call GetData method on original texture then it seems that it gets the data correctly. Also, is there some better way to read the data?

Thank you

Source Link
Renesis
  • 121
  • 6
Loading