Reading from a staging 2D texture array in DirectX10
- by Don Reba
I have a DX10 program, where I create an array of 3 16x16 textures, then map, read, and unmap each subresource in turn. I use a single mip level, set resource usage to staging and CPU access to read. Now, here is the problem:
Subresource 0 contains 1024 bytes, pitch 64, as expected.
Subresource 1 contains 512 bytes, pitch 64.
Subresource 2 contains 256 bytes, pitch 64.
I expect all three to be the same size. Debugging output is enabled, but not reporting any warnings or errors. Am I missing something, or might this be some sort of driver issue?
Here is the code. The language is Nemerle, but C# and C++ would look almost the same. I have looked through the generated code, and am fairly confident the problem is not language-related.
def cpuTexture = Texture2D
( device
, Texture2DDescription() <-
{
Width = 16;
Height = 16;
MipLevels = 1;
ArraySize = 3;
Format = Format.R32_Float;
Usage = ResourceUsage.Staging;
CpuAccessFlags = CpuAccessFlags.Read;
SampleDescription = SampleDescription(count = 1, quality = 0);
}
);
foreach (subresource in [0 .. 2])
{
def data = cpuTexture.Map(subresource, MapMode.Read, MapFlags.None);
Console.WriteLine($"subresource $subresource");
Console.WriteLine($"length = $(data.Data.Length)");
Console.WriteLine($"pitch = $(data.Pitch)");
cpuTexture.Unmap(subresource);
}