From 4057e18f65c9173a41bdfd2c4eca7abf32e83d80 Mon Sep 17 00:00:00 2001 From: Jack Chen Date: Mon, 13 Nov 2023 21:41:40 +0800 Subject: [PATCH] fix mis-calculated dword_count in D3DDevice_SetTexture() when pTexture<> nullptr. this fixs HeatShimmer sample. --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index ce93dc28e..cf5149d44 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -5779,10 +5779,12 @@ xbox::void_xt WINAPI xbox::EMUPATCH(D3DDevice_SetTexture) else { int dword_count = HLE_PushStart + 2; - DWORD* pPush_local = HLE_PushPrepare(X_D3DDevice_SetTexture, dword_count); + DWORD* pPush_local;// = HLE_PushPrepare(X_D3DDevice_SetTexture, dword_count); - pPush_local[2] = (DWORD)Stage; if (pTexture) { + dword_count += sizeof(X_D3DSurface) / 4; + pPush_local = HLE_PushPrepare(X_D3DDevice_SetTexture, dword_count); + pPush_local[2] = (DWORD)Stage; // we should better erase the pTexture if the key already existed in the map. // but this would introduce a data confliction if the pgraph is accessing the same key which we're trying to erase. // either a lock should be implemented here with g_TextureCache, or we simply keep the old key without updating it. @@ -5802,8 +5804,11 @@ xbox::void_xt WINAPI xbox::EMUPATCH(D3DDevice_SetTexture) } //g_TextureCache.insert(std::pair(key, pTexture)); } - else + else { + pPush_local = HLE_PushPrepare(X_D3DDevice_SetTexture, dword_count); + pPush_local[2] = (DWORD)Stage; pPush_local[3] = 0; // no pTexture + } //*(UINT64*)& pPush_local[4] = pTexture->Data; //pPush_local[5] = (DWORD)pTexture->Format;