Bigger than expected Span returned from Map<>
Kharzette opened this issue · 6 comments
I'm using the ID3D11DeviceContext Map call to write to a dynamic 1D texture, and I noticed the span returned is rather large.
The texture itself is 1000 wide with format R8_UInt. The returned pitch is 1024, but there's a multiply by mipSize which in my case is 1000, so I end up with a uint span of 256000.
So I'm not sure if the math is off in CalculateSubResourceIndex or if this is some kind of special case for 1D textures?
I've also been having trouble with UpdateSubresource but I haven't narrowed down what the problem is other than nothing seems to get copied into the texture. I'll keep investigating that.
Thanks!
Hi,
Do you have any repro case? The texture is 1D texture and you call Map right?
Yes I was using Map<uint>, but really I probably should have been using Map<byte>. R8_UInt format is byte sized I think.
With Map<byte> my span size is still 1000x1024 but the call actually works and I can see the data copied in my shader.
If you want to see where I'm using it, this is a bit of code that acts like an old character mode screen on a C64: https://github.com/Kharzette/GrogLibs/blob/e0a68a9c92fb7830ac511ff52dcce0c85b0f7baf/MaterialLib/Screen.cs
SetScreenContents has some of the other things I tried commented out. It hooks up with the TextMode.hlsl shader in groglibs shaderlib.
Groglibs is a mess right now as I'm still converting over from sharpDX so it might be hard to build that stuff.
I've FIXED the Map method with commit: 08bfced, now you can create texture with R32_Uint and map it as byte.
Tell me if you have any issues.
The span returned is now 1024, which is exactly what I'd expect. Thanks!
Nice, I'll push new stable nuget version soon