#Texture does not display correctly in D3D11
19 messages · Page 1 of 1 (latest)
I expect it to be all white
If I create a 32x32 image, I get all white
Another interesting thing is that the buggy case appears fine in RenderDoc
(this is the first 33x33 case)
I may be violating something in the spec, but I'm not comfortable with D3D11 enough to know and find what :/
Do you mind posting your code to fill the texture data after calling Map? Are you respecting the RowPitch that’s returned when calling Map?
Generally what this means is undefined behavior for future reference, you probably are not respecting a memory padding of some sort when copying data as MJP states
this image is 1024x1204
Exactly on point
I was just directly memcpy-ing the entire buffer into the mapped texture
memcpy(mapped_subresource.pData, density_field, SimulationResolution.x * SimulationResolution.y * sizeof(Real));
Now changed to
for (uint32_t y = 0; y < SimulationResolution.y; ++y)
{
uint8_t* dst = reinterpret_cast<uint8_t*>(mapped_subresource.pData) + y * mapped_subresource.RowPitch;
uint8_t* src = reinterpret_cast<uint8_t*>(density_field) + y * SimulationResolution.x * sizeof(Real);
memcpy(dst, src, SimulationResolution.x * sizeof(Real));
}
and now it works perfectly
Thanks a ton
Nice! Glad it’s working now.