Fix crash in pixel shaders caused undefined behavior in LTCG handler

This commit is contained in:
Luke Usher 2019-10-08 16:24:47 +01:00
parent 9537158007
commit c79b11109f
1 changed files with 15 additions and 10 deletions

View File

@ -6806,16 +6806,12 @@ VOID __declspec(noinline) D3DDevice_SetPixelShaderCommon(DWORD Handle)
// This uses a custom calling convention where parameter is passed in EAX
// Test-case: Metal Wolf Chaos
// Test-case: Lord of the Rings: The Third Age
VOID WINAPI XTL::EMUPATCH(D3DDevice_SetPixelShader_0)
VOID WINAPI D3DDevice_SetPixelShader_0_IMPL
(
DWORD Handle
)
{
DWORD Handle;
__asm mov Handle, eax;
//LOG_FUNC_ONE_ARG(Handle);
EmuLog(LOG_LEVEL::DEBUG, "D3DDevice_SetPixelShader_0(Handle : %d);", Handle);
LOG_FUNC_ONE_ARG(Handle);
// Call the Xbox function to make sure D3D structures get set
XB_trampoline(VOID, WINAPI, D3DDevice_SetPixelShader_0, ());
@ -6827,6 +6823,15 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetPixelShader_0)
D3DDevice_SetPixelShaderCommon(Handle);
}
VOID WINAPI XTL::EMUPATCH(D3DDevice_SetPixelShader_0)()
{
__asm {
push eax
call D3DDevice_SetPixelShader_0_IMPL
ret
}
}
// ******************************************************************
// * patch: D3DDevice_SetPixelShader
// ******************************************************************