From a8dfc34678169b17471d18b845e3a35a215c0ed4 Mon Sep 17 00:00:00 2001 From: Luke Usher Date: Sat, 4 May 2019 19:54:55 +0100 Subject: [PATCH 1/2] Fix Begin/EndPush length calculation --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index 02d25c748..f542f9e17 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -2658,7 +2658,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_EndPush)(DWORD *pPush) EmuLog(LOG_LEVEL::WARNING, "D3DDevice_EndPush called without preceding D3DDevice_BeginPush?!"); else { - EmuExecutePushBufferRaw(g_pPrimaryPB, g_dwPrimaryPBCount * sizeof(DWORD)); + // Note: We don't use the count from BeginPush because that specifies the *maximum* count + // rather than the count actually in the pushbuffer. + EmuExecutePushBufferRaw(g_pPrimaryPB, (uintptr_t)pPush - (uintptr_t)g_pPrimaryPB); delete[] g_pPrimaryPB; g_pPrimaryPB = nullptr; From 57238afbe5c34204b482a9c248178c4d5cd9adfe Mon Sep 17 00:00:00 2001 From: Luke Usher Date: Sat, 4 May 2019 20:31:27 +0100 Subject: [PATCH 2/2] Remove now-unused variable --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index f542f9e17..7385f7d33 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -109,10 +109,8 @@ static bool g_bHasStencil = false; // Does device have static DWORD g_dwPrimPerFrame = 0; // Number of primitives within one frame // primary push buffer -static uint32_t g_dwPrimaryPBCount = 0; static uint32_t *g_pPrimaryPB = nullptr; - struct { XTL::X_D3DSurface Surface; RECT SrcRect; @@ -2615,7 +2613,6 @@ PDWORD WINAPI XTL::EMUPATCH(D3DDevice_BeginPush)(DWORD Count) DWORD *pRet = new DWORD[Count]; - g_dwPrimaryPBCount = Count; g_pPrimaryPB = (uint32_t*)pRet; return pRet; @@ -2641,7 +2638,6 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_BeginPush2)(DWORD Count, DWORD** ppPush) DWORD *pRet = new DWORD[Count]; - g_dwPrimaryPBCount = Count; g_pPrimaryPB = (uint32_t*)pRet; *ppPush=pRet;