From b3768ba5ec0985612ddd51c724ed57599c7d9cea Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 11 Mar 2021 20:37:22 +1300 Subject: [PATCH] Avoid crash by not attempting to convert compressed textures (which currently isn't supported) --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index 423e2f142..b8540e72d 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -1542,6 +1542,14 @@ bool ConvertD3DTextureToARGBBuffer( AdditionalArgument = DstRowPitch; if (EmuXBFormatIsCompressed(X_Format)) { + if (SrcWidth < 4 || SrcHeight < 4) { + // HACK: The compressed DXT conversion code currently writes more pixels than it should, which can cause a crash. + // This code will get hit when converting compressed texture mipmaps on hardware that somehow doesn't support DXT natively + // (or lied when Cxbx asked it if it does!) + EmuLog(LOG_LEVEL::WARNING, "Converting DXT textures smaller than a block is not currently implemented. Ignoring conversion!"); + return true; + } + // All compressed formats (DXT1, DXT3 and DXT5) encode blocks of 4 pixels on 4 lines SrcHeight = (SrcHeight + 3) / 4; DstRowPitch *= 4;