Add patch for LTCG optimized functions

- D3DDevice_SetVertexShaderConstant_8
- D3DDevice_SetPixelShader_0
- D3DDevice_SetTextureState_BorderColor_4
This commit is contained in:
jarupxx 2018-04-12 20:31:01 +09:00
parent b7b6f16c7b
commit 6c977ec426
4 changed files with 88 additions and 21 deletions

View File

@ -3226,6 +3226,31 @@ HRESULT WINAPI XTL::EMUPATCH(D3DDevice_CreateVertexShader)
return hRet;
}
// LTCG specific D3DDevice_SetVertexShaderConstant function...
// This uses a custom calling convention where parameter is passed in EDX
// Test-case: Murakumo
VOID __stdcall XTL::EMUPATCH(D3DDevice_SetVertexShaderConstant_8)
(
)
{
FUNC_EXPORTS;
static uint32 returnAddr;
#ifdef _DEBUG_TRACE
__asm add esp, 4
#endif
__asm {
pop returnAddr
push edx
call EmuPatch_D3DDevice_SetVertexShaderConstant
mov eax, 0
push returnAddr
ret
}
}
// ******************************************************************
// * patch: D3DDevice_SetVertexShaderConstant
// ******************************************************************
@ -3367,7 +3392,7 @@ VOID __fastcall XTL::EMUPATCH(D3DDevice_SetVertexShaderConstantNotInlineFast)
BOOL g_bBadIndexData = FALSE;
// LTCG specific D3DDevice_SetTexture function...
// This uses a custom calling convention where parameter is passed in EAX
// TODO: XB_trampoline is not working yet.
// Test-case: Metal Wolf Chaos
VOID __stdcall XTL::EMUPATCH(D3DDevice_SetTexture_4)
(
@ -4927,18 +4952,41 @@ VOID XTL::EMUPATCH(D3DDevice_SetTextureState_BorderColor_0)
FUNC_EXPORTS;
DWORD Stage;
__asm {
mov Stage, eax;
}
DWORD Value;
__asm {
mov Value, ebx;
mov Stage, eax
mov Value, ebx
}
return EMUPATCH(D3DDevice_SetTextureState_BorderColor)(Stage, Value);
}
// LTCG specific D3DDevice_SetTextureState_BorderColor function...
// This uses a custom calling convention where parameter is passed in EAX
// Test-case: Murakumo
VOID __stdcall XTL::EMUPATCH(D3DDevice_SetTextureState_BorderColor_4)
(
)
{
FUNC_EXPORTS;
static uint32 returnAddr;
#ifdef _DEBUG_TRACE
__asm add esp, 4
#endif
__asm {
pop returnAddr
push eax
call EmuPatch_D3DDevice_SetTextureState_BorderColor
mov eax, 0
push returnAddr
ret
}
}
// ******************************************************************
// * patch: D3DDevice_SetTextureState_BorderColor
// ******************************************************************
@ -4969,13 +5017,11 @@ VOID XTL::EMUPATCH(D3DDevice_SetTextureState_ColorKeyColor_0)
FUNC_EXPORTS;
DWORD Stage;
__asm {
mov Stage, esi;
}
DWORD Value;
__asm {
mov Value, ebx;
mov Stage, esi
mov Value, ebx
}
return EMUPATCH(D3DDevice_SetTextureState_ColorKeyColor)(Stage, Value);
@ -5727,13 +5773,11 @@ VOID __stdcall XTL::EMUPATCH(D3DDevice_SetTransform_0)
FUNC_EXPORTS;
D3DTRANSFORMSTATETYPE param1;
__asm {
mov param1, eax;
}
CONST D3DMATRIX *param2;
__asm {
mov param2, edx;
mov param1, eax
mov param2, edx
}
return EMUPATCH(D3DDevice_SetTransform)(param1, param2);
@ -6027,6 +6071,23 @@ void CxbxUpdateNativeD3DResources()
*/
}
// LTCG specific D3DDevice_SetPixelShader function...
// TODO: XB_trampoline is not working yet.
// Test-case: Metal Wolf Chaos
VOID __stdcall XTL::EMUPATCH(D3DDevice_SetPixelShader_0)
(
)
{
//FUNC_EXPORTS;
uint32_t param;
__asm {
mov param, eax
}
return EMUPATCH(D3DDevice_SetPixelShader)(param);
}
// ******************************************************************
// * patch: D3DDevice_SetPixelShader
// ******************************************************************

View File

@ -402,6 +402,8 @@ VOID WINAPI EMUPATCH(D3DDevice_SetVertexShaderConstant)
DWORD ConstantCount
);
VOID __stdcall EMUPATCH(D3DDevice_SetVertexShaderConstant_8)();
// ******************************************************************
// * patch: D3DDevice_SetVertexShaderConstant1
// ******************************************************************
@ -474,6 +476,8 @@ VOID WINAPI EMUPATCH(D3DDevice_SetPixelShader)
DWORD Handle
);
VOID __stdcall EMUPATCH(D3DDevice_SetPixelShader_0)();
// ******************************************************************
// * patch: D3DDevice_CreateTexture2
// ******************************************************************
@ -967,6 +971,7 @@ VOID WINAPI EMUPATCH(D3DDevice_SetTextureState_BorderColor)
);
VOID EMUPATCH(D3DDevice_SetTextureState_BorderColor_0)();
VOID __stdcall EMUPATCH(D3DDevice_SetTextureState_BorderColor_4)();
// ******************************************************************
// * patch: D3DDevice_SetTextureState_ColorKeyColor

View File

@ -204,8 +204,9 @@ OOVPA_END;
// * D3DDevice_SetTextureState_BorderColor
// ******************************************************************
//C1..0681..241B040089 ...C3
OOVPA_NO_XREF(D3DDevice_SetTextureState_BorderColor_0, 2024, 11)
OOVPA_NO_XREF(D3DDevice_SetTextureState_BorderColor_0, 2024, 12)
{ 0x00, 0x56 },
{ 0x01, 0x8B },
{ 0x1C, 0xC1 },
@ -842,7 +843,7 @@ OOVPA_END;
// * D3DDevice_SetVertexShaderConstant
// ******************************************************************
//83C160C1E202A810 ...C3
OOVPA_NO_XREF(D3DDevice_SetVertexShaderConstant_0, 2024, 10)
OOVPA_NO_XREF(D3DDevice_SetVertexShaderConstant_8, 2024, 10)
{ 0x00, 0x55 },
{ 0x01, 0x8B },

View File

@ -138,7 +138,7 @@ OOVPATable D3D8LTCG_OOVPAV2[] = {
REGISTER_OOVPAS(D3DDevice_SetPixelShaderConstant, PATCH, 1024),
REGISTER_OOVPAS(D3DDevice_SetPixelShaderConstant_4, UNPATCHED, 2024),
REGISTER_OOVPAS(D3DDevice_SetPixelShaderProgram, PATCH, 1024),
REGISTER_OOVPAS(D3DDevice_SetPixelShader_0, UNPATCHED, 2024, 2036),
REGISTER_OOVPAS(D3DDevice_SetPixelShader_0, PATCH, 2024, 2036),
REGISTER_OOVPAS(D3DDevice_SetRenderStateNotInline, PATCH, 1024),
REGISTER_OOVPAS(D3DDevice_SetRenderStateNotInline_0, UNPATCHED, 2048),
REGISTER_OOVPAS(D3DDevice_SetRenderState_BackFillMode, PATCH, 1024, 1036),
@ -182,7 +182,7 @@ OOVPATable D3D8LTCG_OOVPAV2[] = {
REGISTER_OOVPAS(D3DDevice_SetTextureStageStateNotInline_0, UNPATCHED, 2024),
REGISTER_OOVPAS(D3DDevice_SetTextureState_BorderColor, PATCH, 1024, 1048),
REGISTER_OOVPAS(D3DDevice_SetTextureState_BorderColor_0, PATCH, 2024, 2036, 2048),
REGISTER_OOVPAS(D3DDevice_SetTextureState_BorderColor_4, UNPATCHED, 2048, 2060),
REGISTER_OOVPAS(D3DDevice_SetTextureState_BorderColor_4, PATCH, 2048, 2060),
REGISTER_OOVPAS(D3DDevice_SetTextureState_BumpEnv, PATCH, 1024),
REGISTER_OOVPAS(D3DDevice_SetTextureState_BumpEnv_8, PATCH, 2024),
REGISTER_OOVPAS(D3DDevice_SetTextureState_ColorKeyColor, PATCH, 1024, 1036),
@ -204,7 +204,7 @@ OOVPATable D3D8LTCG_OOVPAV2[] = {
REGISTER_OOVPAS(D3DDevice_SetVertexShader, PATCH, 1024, 1036),
REGISTER_OOVPAS(D3DDevice_SetVertexShaderConstant, PATCH, 1024),
REGISTER_OOVPAS(D3DDevice_SetVertexShaderConstantNotInline, PATCH, 1024),
REGISTER_OOVPAS(D3DDevice_SetVertexShaderConstant_0, UNPATCHED, 2024),
REGISTER_OOVPAS(D3DDevice_SetVertexShaderConstant_8, PATCH, 2024),
REGISTER_OOVPAS(D3DDevice_SetVertexShader_0, UNPATCHED, 2024, 2036),
REGISTER_OOVPAS(D3DDevice_SetViewport, PATCH, 1024, 1036, 1048),
REGISTER_OOVPAS(D3DDevice_Swap, PATCH, 1024, 1036),