Skip to content

Commit 26a9590

Browse files
committed
Fix D3D11 compressed texture corruption caused by incorrect rowPitch parameter
1 parent f44fbdc commit 26a9590

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

axmol/rhi/d3d11/Texture11.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,10 @@ void TextureImpl::updateCompressedSubData(int xoffset,
228228
box.bottom = static_cast<UINT>(yoffset + height);
229229
box.back = 1;
230230

231-
auto context = static_cast<DriverImpl*>(axdrv)->getContext();
232-
UINT subresource = D3D11CalcSubresource(level, layerIndex, _desc.mipLevels);
233-
context->UpdateSubresource(_nativeTexture, subresource, &box, data, 0, 0);
231+
auto context = static_cast<DriverImpl*>(axdrv)->getContext();
232+
UINT subresource = D3D11CalcSubresource(level, layerIndex, _desc.mipLevels);
233+
const auto rowPitch = RHIUtils::computeRowPitch(_desc.pixelFormat, width);
234+
context->UpdateSubresource(_nativeTexture, subresource, &box, data, rowPitch, 0);
234235

235236
if (shouldGenMipmaps(level))
236237
generateMipmaps(context);

0 commit comments

Comments
 (0)