Do not try to resolve the palettized texture if there is no palette bound

Fixes a crash in DRIV3R
This commit is contained in:
Silent 2020-11-25 20:39:03 +01:00
parent 4d8c4fbb68
commit 7af503b90c
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
1 changed files with 20 additions and 7 deletions

View File

@ -5956,14 +5956,27 @@ void CreateHostResource(xbox::X_D3DResource *pResource, DWORD D3DUsage, int iTex
if (bConvertToARGB) {
EmuLog(LOG_LEVEL::DEBUG, "Unsupported texture format, expanding to D3DFMT_A8R8G8B8");
// In case where there is a palettized texture without a palette attached,
// fill it with zeroes for now. This might not be correct, but it prevents a crash.
// Test case: DRIV3R
bool skipDueToNoPalette = false;
if (X_Format == xbox::X_D3DFMT_P8 && g_pXbox_Palette_Data[iTextureStage] == nullptr) {
LOG_TEST_CASE("Palettized texture bound without a palette");
memset(pDst, 0, dwDstRowPitch * dwMipHeight);
skipDueToNoPalette = true;
}
// Convert a row at a time, using a libyuv-like callback approach :
if (!ConvertD3DTextureToARGBBuffer(
X_Format,
pSrc, dwMipWidth, dwMipHeight, dwMipRowPitch, dwSrcSlicePitch,
pDst, dwDstRowPitch, dwDstSlicePitch,
dwDepth,
iTextureStage)) {
CxbxKrnlCleanup("Unhandled conversion!");
if (!skipDueToNoPalette) {
if (!ConvertD3DTextureToARGBBuffer(
X_Format,
pSrc, dwMipWidth, dwMipHeight, dwMipRowPitch, dwSrcSlicePitch,
pDst, dwDstRowPitch, dwDstSlicePitch,
dwDepth,
iTextureStage)) {
CxbxKrnlCleanup("Unhandled conversion!");
}
}
}
else if (bSwizzled) {