From 2088632d15cdc6da0096a609bd2f388d6f6838b6 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 13 Dec 2022 06:17:01 -0600 Subject: [PATCH 01/35] d3d: fix typo from D3D_PDEVICE to D3D_g_pDevice variable --- src/OOVPADatabase/D3D8/3911.inl | 48 ++++++++++++++--------------- src/OOVPADatabase/D3D8/4034.inl | 6 ++-- src/OOVPADatabase/D3D8/4039.inl | 12 ++++---- src/OOVPADatabase/D3D8/4531.inl | 4 +-- src/OOVPADatabase/D3D8/4627.inl | 2 +- src/OOVPADatabase/D3D8/4831.inl | 2 +- src/OOVPADatabase/D3D8/5028.inl | 4 +-- src/OOVPADatabase/D3D8/5344.inl | 8 ++--- src/OOVPADatabase/D3D8LTCG/3911.inl | 4 +-- src/OOVPADatabase/D3D8LTCG/5344.inl | 4 +-- src/lib/manual_d3d8__ltcg.h | 4 +-- 11 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 45594147..5e9cde82 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -27,7 +27,7 @@ // * D3DDevice__m_VerticalBlankEvent__ManualFindGeneric // ****************************************************************** // Generic OOVPA as of 3911 and newer. -// NOTE: This signature will find any generic match with D3D__PDEVICE +// NOTE: This signature will find any generic match with D3D_g_pDevice // Currently, this is the best method without rely on // D3DDevice_BlockUntilVerticalBlank detection. // So, even though it's scanning for D3DDevice_BlockUntilVerticalBlank, @@ -38,31 +38,31 @@ OOVPA_SIG_HEADER_XREF_DETECT(D3DDevice__m_VerticalBlankEvent__ManualFindGeneric, DetectFirst) OOVPA_SIG_MATCH( - // D3DDevice__m_VerticalBlankEvent__ManualFindGeneric+0x00 : mov eax, [D3D__PDEVICE] + // mov eax, [D3D_g_pDevice] XREF_ENTRY(0x01, XREF_D3D_g_pDevice), - // D3DDevice__m_VerticalBlankEvent__ManualFindGeneric+0x17 : add eax, OFFSET_D3DDevice__m_VerticalBlankEvent + // add eax, OFFSET_D3DDevice__m_VerticalBlankEvent XREF_ENTRY(0x18, XREF_OFFSET_D3DDevice__m_VerticalBlankEvent), // <-- Deriving this XRef is the purpose of this OOVPA - // D3DDevice__m_VerticalBlankEvent__ManualFindGeneric+0x00 : mov eax,[D3D__PDEVICE] + // mov eax,[D3D_g_pDevice] OV_MATCH(0x00, 0xA1), - // D3DDevice__m_VerticalBlankEvent__ManualFindGeneric+0x05 : push 0; push 0; push 1 + // push 0; push 0; push 1 OV_MATCH(0x05, 0x6A, 0x00, 0x6A, 0x00, 0x6A, 0x01), - // D3DDevice__m_VerticalBlankEvent__ManualFindGeneric+0x0B : mov dword ptr [eax+OFFSET_D3DDEVICE_M_???], + // mov dword ptr [eax+OFFSET_D3DDEVICE_M_???], OV_MATCH(0x0B, 0xC7, 0x80), - // D3DDevice__m_VerticalBlankEvent__ManualFindGeneric+0x15 : push 6 + // push 6 OV_MATCH(0x15, 0x6A, 0x06), - // D3DDevice__m_VerticalBlankEvent__ManualFindGeneric+0x17 : add eax, OFFSET_D3DDevice__m_VerticalBlankEvent + // add eax, OFFSET_D3DDevice__m_VerticalBlankEvent OV_MATCH(0x17, 0x05), - // D3DDevice__m_VerticalBlankEvent__ManualFindGeneric+0x1D : push eax + // push eax OV_MATCH(0x1C, 0x50), - // D3DDevice__m_VerticalBlankEvent__ManualFindGeneric+0x1D : call e__ + // call e__ OV_MATCH(0x1D, 0xFF), // @@ -1505,13 +1505,13 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_BlockUntilVerticalBlank, XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_BlockUntilVerticalBlank+0x00 : mov eax, [D3D__PDEVICE] + // D3DDevice_BlockUntilVerticalBlank+0x00 : mov eax, [D3D_g_pDevice] XREF_ENTRY(0x01, XREF_D3D_g_pDevice), // D3DDevice_BlockUntilVerticalBlank+0x17 : add eax, OFFSET_D3DDevice__m_VerticalBlankEvent XREF_ENTRY(0x18, XREF_OFFSET_D3DDevice__m_VerticalBlankEvent), - // D3DDevice_BlockUntilVerticalBlank+0x00 : mov eax,[D3D__PDEVICE] + // D3DDevice_BlockUntilVerticalBlank+0x00 : mov eax,[D3D_g_pDevice] OV_MATCH(0x00, 0xA1), // D3DDevice_BlockUntilVerticalBlank+0x05 : push 0; push 0; push 1 @@ -1544,7 +1544,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetVerticalBlankCallback, XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetVerticalBlankCallback+0x04 : mov ecx,[D3D__PDEVICE] + // D3DDevice_SetVerticalBlankCallback+0x04 : mov ecx,[D3D_g_pDevice] XREF_ENTRY(0x06, XREF_D3D_g_pDevice), // D3DDevice_SetVerticalBlankCallback+0x0A : mov [ecx+OFFSET_D3DDevice__m_VBlankCallback],eax @@ -2641,10 +2641,10 @@ OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FillMode, 3911) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_FillMode+0x00 : push esi + // push esi { 0x00, 0x56 }, - // D3DDevice_SetRenderState_FillMode+0x23 : mov dword ptr [eax], 0x8038C + // mov dword ptr [eax],0x8038C { 0x23, 0xC7 }, { 0x24, 0x00 }, { 0x25, 0x8C }, @@ -2652,12 +2652,12 @@ OOVPA_SIG_MATCH( { 0x27, 0x08 }, { 0x28, 0x00 }, - // D3DDevice_SetRenderState_FillMode+0x2F : add eax, 0x0C + // add eax,0x0C { 0x2F, 0x83 }, { 0x30, 0xC0 }, { 0x31, 0x0C }, - // D3DDevice_SetRenderState_FillMode+0x3B : retn 0x04 + // retn 0x04 { 0x3B, 0xC2 }, { 0x3C, 0x04 }, // @@ -3819,7 +3819,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_PersistDisplay, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_PersistDisplay+0x02 : mov ebx,[D3D__PDEVICE] + // D3DDevice_PersistDisplay+0x02 : mov ebx,[D3D_g_pDevice] XREF_ENTRY(0x04, XREF_D3D_g_pDevice), // D3DDevice_PersistDisplay+0x00 : push ecx @@ -3940,7 +3940,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_OcclusionCullEnable, XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_OcclusionCullEnable+0x05 : mov esi,[D3D__PDEVICE] + // D3DDevice_SetRenderState_OcclusionCullEnable+0x05 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x07, XREF_D3D_g_pDevice), // D3DDevice_SetRenderState_OcclusionCullEnable+0x0C : D3D__RenderState[D3DRS_OCCLUSIONCULLENABLE] @@ -3974,7 +3974,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilCullEnable, XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D__PDEVICE] + // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x07, XREF_D3D_g_pDevice), // D3DDevice_SetRenderState_StencilCullEnable+0x0C : D3D__RenderState[D3DRS_STENCILCULLENABLE] @@ -4006,7 +4006,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_DrawVerticesUP, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_DrawVerticesUP+0x09 : mov edi,[D3D__PDEVICE] + // D3DDevice_DrawVerticesUP+0x09 : mov edi,[D3D_g_pDevice] XREF_ENTRY(0x0B, XREF_D3D_g_pDevice), // D3DDevice_DrawVerticesUP+0x00 : push ebp @@ -4015,7 +4015,7 @@ OOVPA_SIG_MATCH( // D3DDevice_DrawVerticesUP+0x03 : sub esp,0x10 OV_MATCH(0x03, 0x83, 0xEC, 0x10), - // D3DDevice_DrawVerticesUP+0x09 : mov edi,[D3D__PDEVICE] + // D3DDevice_DrawVerticesUP+0x09 : mov edi,[D3D_g_pDevice] OV_MATCH(0x09, 0x8B, 0x3D), // D3DDevice_DrawVerticesUP+0x0F : mov ecx,edi @@ -4036,7 +4036,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_DrawIndexedVerticesUP, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_DrawIndexedVerticesUP+0x09 : mov edi,[D3D__PDEVICE] + // D3DDevice_DrawIndexedVerticesUP+0x09 : mov edi,[D3D_g_pDevice] XREF_ENTRY(0x0B, XREF_D3D_g_pDevice), // D3DDevice_DrawIndexedVerticesUP+0x00 : push ebp @@ -4045,7 +4045,7 @@ OOVPA_SIG_MATCH( // D3DDevice_DrawIndexedVerticesUP+0x03 : sub esp,0x14 OV_MATCH(0x03, 0x83, 0xEC, 0x14), - // D3DDevice_DrawIndexedVerticesUP+0x09 : mov edi,[D3D__PDEVICE] + // D3DDevice_DrawIndexedVerticesUP+0x09 : mov edi,[D3D_g_pDevice] OV_MATCH(0x09, 0x8B, 0x3D), // D3DDevice_DrawIndexedVerticesUP+0x0F : mov ecx,edi diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index ca8dc0be..973115e0 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -853,7 +853,7 @@ OOVPA_SIG_HEADER_XREF(D3DVertexBuffer_Lock, XRefOne) OOVPA_SIG_MATCH( - // D3DVertexBuffer_Lock+0x0B : mov esi,[D3D__PDEVICE] + // D3DVertexBuffer_Lock+0x0B : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x0D, XREF_D3D_g_pDevice), // D3DVertexBuffer_Lock+0x18 : call D3DDevice_MakeSpace @@ -1523,7 +1523,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_OcclusionCullEnable, XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D__PDEVICE] + // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x07, XREF_D3D_g_pDevice), // D3DDevice_SetRenderState_OcclusionCullEnable+0x0B : D3D__RenderState[D3DRS_OCCLUSIONCULLENABLE] @@ -1558,7 +1558,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilCullEnable, XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D__PDEVICE] + // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x07, XREF_D3D_g_pDevice), // D3DDevice_SetRenderState_StencilCullEnable+0x0B : D3D__RenderState[D3DRS_STENCILCULLENABLE] diff --git a/src/OOVPADatabase/D3D8/4039.inl b/src/OOVPADatabase/D3D8/4039.inl index 63cba619..06a22dff 100644 --- a/src/OOVPADatabase/D3D8/4039.inl +++ b/src/OOVPADatabase/D3D8/4039.inl @@ -153,7 +153,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetSwapCallback, XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetSwapCallback+0x04 : mov ecx,[D3D__PDEVICE] + // D3DDevice_SetSwapCallback+0x04 : mov ecx,[D3D_g_pDevice] XREF_ENTRY(0x06, XREF_D3D_g_pDevice), // D3DDevice_SetSwapCallback+0x0A : mov [ecx+OFFSET_D3DDevice__m_SwapCallback],eax @@ -379,7 +379,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_PersistDisplay, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_PersistDisplay+0x04 : mov edi,[D3D__PDEVICE] + // D3DDevice_PersistDisplay+0x04 : mov edi,[D3D_g_pDevice] XREF_ENTRY(0x06, XREF_D3D_g_pDevice), // D3DDevice_PersistDisplay+0x00 : sub esp,0x__ @@ -411,7 +411,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_DrawVerticesUP, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_DrawVerticesUP+0x07 : mov edi,[D3D__PDEVICE] + // D3DDevice_DrawVerticesUP+0x07 : mov edi,[D3D_g_pDevice] XREF_ENTRY(0x09, XREF_D3D_g_pDevice), // D3DDevice_DrawVerticesUP+0x00 : push ebp @@ -420,7 +420,7 @@ OOVPA_SIG_MATCH( // D3DDevice_DrawVerticesUP+0x03 : sub esp,0x14 OV_MATCH(0x03, 0x83, 0xEC, 0x14), - // D3DDevice_DrawVerticesUP+0x07 : mov edi,[D3D__PDEVICE] + // D3DDevice_DrawVerticesUP+0x07 : mov edi,[D3D_g_pDevice] OV_MATCH(0x07, 0x8B, 0x3D), // D3DDevice_DrawVerticesUP+0x0D : mov ecx,edi @@ -720,10 +720,10 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_BeginPush2, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_BeginPush__8+0x01 : mov esi,[D3D__PDEVICE] + // D3DDevice_BeginPush__8+0x01 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x03, XREF_D3D_g_pDevice), - // D3DDevice_BeginPush__8+0x00 : push esi; mov esi,[D3D__PDEVICE] + // D3DDevice_BeginPush__8+0x00 : push esi; mov esi,[D3D_g_pDevice] OV_MATCH(0x00, 0x56, 0x8B, 0x35), // D3DDevice_BeginPush__8+0x0B : call CDevice_SetStateVB diff --git a/src/OOVPADatabase/D3D8/4531.inl b/src/OOVPADatabase/D3D8/4531.inl index b6e44375..8e3501c2 100644 --- a/src/OOVPADatabase/D3D8/4531.inl +++ b/src/OOVPADatabase/D3D8/4531.inl @@ -139,10 +139,10 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_BeginPush, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_BeginPush__4+0x01 : mov esi,[D3D__PDEVICE] + // D3DDevice_BeginPush__4+0x01 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x03, XREF_D3D_g_pDevice), - // D3DDevice_BeginPush__4+0x00 : push esi; mov esi,[D3D__PDEVICE] + // D3DDevice_BeginPush__4+0x00 : push esi; mov esi,[D3D_g_pDevice] OV_MATCH(0x00, 0x56, 0x8B, 0x35), // D3DDevice_BeginPush__4+0x0B : call CDevice_SetStateVB diff --git a/src/OOVPADatabase/D3D8/4627.inl b/src/OOVPADatabase/D3D8/4627.inl index 38440c36..efdcc04f 100644 --- a/src/OOVPADatabase/D3D8/4627.inl +++ b/src/OOVPADatabase/D3D8/4627.inl @@ -1417,7 +1417,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_PersistDisplay, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_PersistDisplay+0x02 : mov ebx,[D3D__PDEVICE] + // D3DDevice_PersistDisplay+0x02 : mov ebx,[D3D_g_pDevice] XREF_ENTRY(0x04, XREF_D3D_g_pDevice), // D3DDevice_PersistDisplay+0x00 : push ecx diff --git a/src/OOVPADatabase/D3D8/4831.inl b/src/OOVPADatabase/D3D8/4831.inl index 004e82aa..d2fff6e3 100644 --- a/src/OOVPADatabase/D3D8/4831.inl +++ b/src/OOVPADatabase/D3D8/4831.inl @@ -125,7 +125,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_PersistDisplay, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_PersistDisplay+0x04 : mov ebx,[D3D__PDEVICE] + // D3DDevice_PersistDisplay+0x04 : mov ebx,[D3D_g_pDevice] XREF_ENTRY(0x06, XREF_D3D_g_pDevice), // D3DDevice_PersistDisplay+0x00 : sub esp,0x__ diff --git a/src/OOVPADatabase/D3D8/5028.inl b/src/OOVPADatabase/D3D8/5028.inl index 0c4ed7a0..565cd8db 100644 --- a/src/OOVPADatabase/D3D8/5028.inl +++ b/src/OOVPADatabase/D3D8/5028.inl @@ -545,7 +545,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_DrawIndexedVerticesUP, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_DrawIndexedVerticesUP+0x07 : mov esi,[D3D__PDEVICE] + // D3DDevice_DrawIndexedVerticesUP+0x07 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x09, XREF_D3D_g_pDevice), // D3DDevice_DrawIndexedVerticesUP+0x00 : push ebp @@ -554,7 +554,7 @@ OOVPA_SIG_MATCH( // D3DDevice_DrawIndexedVerticesUP+0x03 : sub esp,0x14 OV_MATCH(0x03, 0x83, 0xEC, 0x14), - // D3DDevice_DrawIndexedVerticesUP+0x07 : mov esi,[D3D__PDEVICE] + // D3DDevice_DrawIndexedVerticesUP+0x07 : mov esi,[D3D_g_pDevice] OV_MATCH(0x07, 0x8B, 0x35), // D3DDevice_DrawIndexedVerticesUP+0x0D : mov ecx,esi diff --git a/src/OOVPADatabase/D3D8/5344.inl b/src/OOVPADatabase/D3D8/5344.inl index 0053de45..0cc8eeb0 100644 --- a/src/OOVPADatabase/D3D8/5344.inl +++ b/src/OOVPADatabase/D3D8/5344.inl @@ -330,7 +330,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_DrawVerticesUP, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_DrawVerticesUP+0x09 : mov edi,[D3D__PDEVICE] + // D3DDevice_DrawVerticesUP+0x09 : mov edi,[D3D_g_pDevice] XREF_ENTRY(0x0B, XREF_D3D_g_pDevice), // D3DDevice_DrawVerticesUP+0x00 : push ebp @@ -339,7 +339,7 @@ OOVPA_SIG_MATCH( // D3DDevice_DrawVerticesUP+0x03 : sub esp,0x14 OV_MATCH(0x03, 0x83, 0xEC, 0x14), - // D3DDevice_DrawVerticesUP+0x09 : mov edi,[D3D__PDEVICE] + // D3DDevice_DrawVerticesUP+0x09 : mov edi,[D3D_g_pDevice] OV_MATCH(0x09, 0x8B, 0x3D), // D3DDevice_DrawVerticesUP+0x0F : mov ecx,edi @@ -361,7 +361,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_DrawIndexedVerticesUP, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_DrawIndexedVerticesUP+0x08 : mov edi,[D3D__PDEVICE] + // D3DDevice_DrawIndexedVerticesUP+0x08 : mov edi,[D3D_g_pDevice] XREF_ENTRY(0x0A, XREF_D3D_g_pDevice), // D3DDevice_DrawIndexedVerticesUP+0x00 : push ebp @@ -370,7 +370,7 @@ OOVPA_SIG_MATCH( // D3DDevice_DrawIndexedVerticesUP+0x03 : sub esp,0x14 OV_MATCH(0x03, 0x83, 0xEC, 0x14), - // D3DDevice_DrawIndexedVerticesUP+0x08 : mov esi,[D3D__PDEVICE] + // D3DDevice_DrawIndexedVerticesUP+0x08 : mov esi,[D3D_g_pDevice] OV_MATCH(0x08, 0x8B, 0x35), // D3DDevice_DrawIndexedVerticesUP+0x0F : mov ecx,esi diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index 9524bf70..85c5ce3e 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -1163,13 +1163,13 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_BlockUntilVerticalBlank, XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_BlockUntilVerticalBlank+0x00 : mov eax, [D3D__PDEVICE] + // D3DDevice_BlockUntilVerticalBlank+0x00 : mov eax, [D3D_g_pDevice] XREF_ENTRY(0x01, XREF_D3D_g_pDevice), // D3DDevice_BlockUntilVerticalBlank+0x17 : add eax, OFFSET_D3DDevice__m_VerticalBlankEvent XREF_ENTRY(0x18, XREF_OFFSET_D3DDevice__m_VerticalBlankEvent), - // D3DDevice_BlockUntilVerticalBlank+0x00 : mov eax,[D3D__PDEVICE] + // D3DDevice_BlockUntilVerticalBlank+0x00 : mov eax,[D3D_g_pDevice] OV_MATCH(0x00, 0xA1), // D3DDevice_BlockUntilVerticalBlank+0x05 : push 0; push 0; push 1 diff --git a/src/OOVPADatabase/D3D8LTCG/5344.inl b/src/OOVPADatabase/D3D8LTCG/5344.inl index 6bb86dbe..82a03202 100644 --- a/src/OOVPADatabase/D3D8LTCG/5344.inl +++ b/src/OOVPADatabase/D3D8LTCG/5344.inl @@ -109,7 +109,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_DrawVerticesUP, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_DrawVerticesUP+0x08 : mov esi,[D3D__PDEVICE] + // D3DDevice_DrawVerticesUP+0x08 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x0A, XREF_D3D_g_pDevice), // D3DDevice_DrawVerticesUP+0x00 : push ebp @@ -118,7 +118,7 @@ OOVPA_SIG_MATCH( // D3DDevice_DrawVerticesUP+0x03 : sub esp,0x14 OV_MATCH(0x03, 0x83, 0xEC, 0x14), - // D3DDevice_DrawVerticesUP+0x08 : mov esi,[D3D__PDEVICE] + // D3DDevice_DrawVerticesUP+0x08 : mov esi,[D3D_g_pDevice] OV_MATCH(0x08, 0x8B, 0x35), // D3DDevice_DrawVerticesUP+0x0E : push edi diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index faa93954..d6449990 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -478,7 +478,7 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, // * D3DDevice_SetSwapCallback // * D3DDevice_SetVerticalBlankCallback - // First, check if D3D__PDEVICE is found. + // First, check if D3D_g_pDevice is found. if (pContext->xref_database[XREF_D3D_g_pDevice] != XREF_ADDR_DERIVE && // Then, check at least one of symbol's member variable is not found. pContext->xref_database[XREF_OFFSET_D3DDevice__m_SwapCallback] == XREF_ADDR_UNDETERMINED) { @@ -508,7 +508,7 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, internal_SetXRefDatabase(pContext, iLibraryType, XREF_OFFSET_D3DDevice__m_SwapCallback, xSymbolAddr - 8); internal_SetXRefDatabase(pContext, iLibraryType, XREF_OFFSET_D3DDevice__m_VBlankCallback, xSymbolAddr - 4); } - // If D3D__PDEVICE is not found, the scan is not complete + // If D3D_g_pDevice is not found, the scan is not complete // and will continue scan to next given section. else { return false; From 019b9e6d9437092c76888878cf5342b0a52ce06a Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Mon, 19 Dec 2022 07:15:38 -0600 Subject: [PATCH 02/35] d3d: fix D3DRS_ prefix constant as "variables" --- include/xref/d3d8.def | 40 +++++------ src/OOVPADatabase/D3D8/3911.inl | 24 +++---- src/OOVPADatabase/D3D8/4034.inl | 12 ++-- src/OOVPADatabase/D3D8LTCG/3911.inl | 24 +++---- src/OOVPADatabase/D3D8LTCG/4039.inl | 18 ++--- src/OOVPADatabase/D3D8LTCG/4432.inl | 8 +-- src/OOVPADatabase/D3D8LTCG/4531.inl | 2 +- src/OOVPADatabase/D3D8LTCG/4627.inl | 10 +-- src/OOVPADatabase/D3D8LTCG/5788.inl | 4 +- src/OOVPADatabase/D3D8LTCG/5849.inl | 2 +- src/lib/libXbSymbolDatabase.c | 12 ++-- src/lib/manual_d3d8__ltcg.h | 100 ++++++++++++++-------------- src/test/libverify/D3D8.cpp | 2 +- 13 files changed, 129 insertions(+), 129 deletions(-) diff --git a/include/xref/d3d8.def b/include/xref/d3d8.def index 17ddedf3..a072b283 100644 --- a/include/xref/d3d8.def +++ b/include/xref/d3d8.def @@ -27,26 +27,26 @@ XREF_SYMBOL(D3D_g_DeferredRenderState) XREF_SYMBOL(D3D_g_DeferredTextureState) XREF_SYMBOL(D3D_g_pDevice) XREF_SYMBOL(D3D_g_Stream) -XREF_SYMBOL(D3DRS_BACKFILLMODE) -XREF_SYMBOL(D3DRS_CULLMODE) -XREF_SYMBOL(D3DRS_DXT1NOISEENABLE) -XREF_SYMBOL(D3DRS_FILLMODE) -XREF_SYMBOL(D3DRS_LINEWIDTH) -XREF_SYMBOL(D3DRS_LOGICOP) -XREF_SYMBOL(D3DRS_MULTISAMPLEANTIALIAS) -XREF_SYMBOL(D3DRS_MULTISAMPLEMASK) -XREF_SYMBOL(D3DRS_MULTISAMPLEMODE) -XREF_SYMBOL(D3DRS_MULTISAMPLERENDERTARGETMODE) -XREF_SYMBOL(D3DRS_OCCLUSIONCULLENABLE) -XREF_SYMBOL(D3DRS_ROPZCMPALWAYSREAD) -XREF_SYMBOL(D3DRS_ROPZREAD) -XREF_SYMBOL(D3DRS_DONOTCULLUNCOMPRESSED) -XREF_SYMBOL(D3DRS_SAMPLEALPHA) -XREF_SYMBOL(D3DRS_STENCILCULLENABLE) -XREF_SYMBOL(D3DRS_STENCILENABLE) -XREF_SYMBOL(D3DRS_TWOSIDEDLIGHTING) -XREF_SYMBOL(D3DRS_YUVENABLE) -XREF_SYMBOL(D3DRS_ZBIAS) +XREF_SYMBOL(D3DRS_BackFillMode) +XREF_SYMBOL(D3DRS_CullMode) +XREF_SYMBOL(D3DRS_Dxt1NoiseEnable) +XREF_SYMBOL(D3DRS_FillMode) +XREF_SYMBOL(D3DRS_LineWidth) +XREF_SYMBOL(D3DRS_LogicOp) +XREF_SYMBOL(D3DRS_MultiSampleAntiAlias) +XREF_SYMBOL(D3DRS_MultiSampleMask) +XREF_SYMBOL(D3DRS_MultiSampleMode) +XREF_SYMBOL(D3DRS_MultiSampleRenderTargetMode) +XREF_SYMBOL(D3DRS_OcclusionCullEnable) +XREF_SYMBOL(D3DRS_RopZCmpAlwaysRead) +XREF_SYMBOL(D3DRS_RopZRead) +XREF_SYMBOL(D3DRS_DoNotCullUncompressed) +XREF_SYMBOL(D3DRS_SampleAlpha) +XREF_SYMBOL(D3DRS_StencilCullEnable) +XREF_SYMBOL(D3DRS_StencilEnable) +XREF_SYMBOL(D3DRS_TwoSidedLighting) +XREF_SYMBOL(D3DRS_YuvEnable) +XREF_SYMBOL(D3DRS_ZBias) XREF_SYMBOL(D3DTSS_TEXCOORDINDEX) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 5e9cde82..d84fdc90 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -1199,7 +1199,7 @@ OOVPA_SIG_MATCH( XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - XREF_ENTRY(0x25, XREF_D3DRS_CULLMODE), // Derived + XREF_ENTRY(0x25, XREF_D3DRS_CullMode), // Derived // D3DDevice_SetRenderState_CullMode+0x00 : push esi { 0x00, 0x56 }, @@ -3943,8 +3943,8 @@ OOVPA_SIG_MATCH( // D3DDevice_SetRenderState_OcclusionCullEnable+0x05 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_OcclusionCullEnable+0x0C : D3D__RenderState[D3DRS_OCCLUSIONCULLENABLE] - XREF_ENTRY(0x0D, XREF_D3DRS_OCCLUSIONCULLENABLE), // Derived + // D3DDevice_SetRenderState_OcclusionCullEnable+0x0C : [D3DRS_OcclusionCullEnable] + XREF_ENTRY(0x0D, XREF_D3DRS_OcclusionCullEnable), // Derived // D3DDevice_SetRenderState_OcclusionCullEnable+0x11 : call XMETAL_StartPush //XREF_ENTRY(0x12, XREF_XMETAL_StartPush), @@ -3977,8 +3977,8 @@ OOVPA_SIG_MATCH( // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_StencilCullEnable+0x0C : D3D__RenderState[D3DRS_STENCILCULLENABLE] - XREF_ENTRY(0x0D, XREF_D3DRS_STENCILCULLENABLE), // Derived + // D3DDevice_SetRenderState_StencilCullEnable+0x0C : [D3DRS_StencilCullEnable] + XREF_ENTRY(0x0D, XREF_D3DRS_StencilCullEnable), // Derived // D3DDevice_SetRenderState_StencilCullEnable+0x11 : call XMETAL_StartPush //XREF_ENTRY(0x12, XREF_XMETAL_StartPush), @@ -4218,7 +4218,7 @@ OOVPA_SIG_MATCH( { 0x07, 0x09 }, { 0x08, 0x05 }, - // D3DDevice_SetRenderState_Deferred+0x0D : mov dword ptr ds:D3D__RenderState[ecx*4], edx + // D3DDevice_SetRenderState_Deferred+0x0D : mov dword ptr ds:D3D_g_RenderState[ecx*4], edx { 0x0D, 0x89 }, { 0x0E, 0x14 }, { 0x0F, 0x8D }, @@ -4698,8 +4698,8 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_RopZCmpAlwaysRead, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_RopZCmpAlwaysRead+0x05 : D3D__RenderState[D3DRS_ROPZCMPALWAYSREAD] - XREF_ENTRY(0x05, XREF_D3DRS_ROPZCMPALWAYSREAD), // Derived + // D3DDevice_SetRenderState_RopZCmpAlwaysRead+0x05 : [D3DRS_RopZCmpAlwaysRead] + XREF_ENTRY(0x05, XREF_D3DRS_RopZCmpAlwaysRead), // Derived // D3DDevice_SetRenderState_RopZCmpAlwaysRead+0x00 : mov eax, [esp+0x04] { 0x00, 0x8B }, @@ -4726,8 +4726,8 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_RopZRead, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_RopZRead+0x05 : D3D__RenderState[D3DRS_ROPZREAD] - XREF_ENTRY(0x05, XREF_D3DRS_ROPZREAD), // Derived + // D3DDevice_SetRenderState_RopZRead+0x05 : [D3DRS_RopZRead] + XREF_ENTRY(0x05, XREF_D3DRS_RopZRead), // Derived // D3DDevice_SetRenderState_RopZRead+0x00 : mov eax, [esp+0x04] { 0x00, 0x8B }, @@ -4754,8 +4754,8 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_DoNotCullUncompressed, XRefOne) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_DoNotCullUncompressed+0x05 : D3D__RenderState[D3DRS_DONOTCULLUNCOMPRESSED] - XREF_ENTRY(0x05, XREF_D3DRS_DONOTCULLUNCOMPRESSED), // Derived + // D3DDevice_SetRenderState_DoNotCullUncompressed+0x05 : [D3DRS_DoNotCullUncompressed] + XREF_ENTRY(0x05, XREF_D3DRS_DoNotCullUncompressed), // Derived // D3DDevice_SetRenderState_DoNotCullUncompressed+0x00 : mov eax, [esp+0x04] { 0x00, 0x8B }, diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index 973115e0..2ca97692 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -226,7 +226,7 @@ OOVPA_SIG_MATCH( XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - XREF_ENTRY(0x2B, XREF_D3DRS_CULLMODE), // Derived + XREF_ENTRY(0x2B, XREF_D3DRS_CullMode), // Derived // D3DDevice_SetRenderState_CullMode+0x00 : push esi { 0x00, 0x56 }, @@ -1458,7 +1458,7 @@ OOVPA_XREF(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, XRefTwo) { #endif - XREF_ENTRY(0x0B, XREF_D3DRS_MULTISAMPLERENDERTARGETMODE), // Derived + XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleRenderTargetMode), // Derived #ifdef WIP_LessVertexPatching XREF_ENTRY(0x11, XREF_OFFSET_D3DDevice__m_RenderTarget), // Derived @@ -1526,8 +1526,8 @@ OOVPA_SIG_MATCH( // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_OcclusionCullEnable+0x0B : D3D__RenderState[D3DRS_OCCLUSIONCULLENABLE] - XREF_ENTRY(0x0C, XREF_D3DRS_OCCLUSIONCULLENABLE), // Derived + // D3DDevice_SetRenderState_OcclusionCullEnable+0x0B : [D3DRS_OcclusionCullEnable] + XREF_ENTRY(0x0C, XREF_D3DRS_OcclusionCullEnable), // Derived // D3DDevice_SetRenderState_OcclusionCullEnable+0x17 : call D3DDevice_MakeSpace //XREF_ENTRY(0x18, XREF_D3DDevice_MakeSpace), @@ -1561,8 +1561,8 @@ OOVPA_SIG_MATCH( // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D_g_pDevice] XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_StencilCullEnable+0x0B : D3D__RenderState[D3DRS_STENCILCULLENABLE] - XREF_ENTRY(0x0C, XREF_D3DRS_STENCILCULLENABLE), // Derived + // D3DDevice_SetRenderState_StencilCullEnable+0x0B : [D3DRS_StencilCullEnable] + XREF_ENTRY(0x0C, XREF_D3DRS_StencilCullEnable), // Derived // D3DDevice_SetRenderState_StencilCullEnable+0x17 : call D3DDevice_MakeSpace //XREF_ENTRY(0x18, XREF_D3DDevice_MakeSpace), diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index 85c5ce3e..a740d0df 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -55,7 +55,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_CullMode, OOVPA_SIG_MATCH( XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - XREF_ENTRY(0x2D, XREF_D3DRS_CULLMODE), // Derived + XREF_ENTRY(0x2D, XREF_D3DRS_CullMode), // Derived { 0x00, 0x56 }, @@ -171,7 +171,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_YuvEnable, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_YUVENABLE), + XREF_ENTRY(0x0C, XREF_D3DRS_YuvEnable), { 0x01, 0x44 }, { 0x04, 0x56 }, @@ -192,7 +192,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_OcclusionCullEnable, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_OCCLUSIONCULLENABLE), + XREF_ENTRY(0x0C, XREF_D3DRS_OcclusionCullEnable), { 0x00, 0x8B }, { 0x06, 0x35 }, @@ -283,7 +283,7 @@ OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_ZBias, 1048) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBIAS ), + // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBias ), { 0x00, 0x51 }, { 0x01, 0x53 }, @@ -308,7 +308,7 @@ OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_LineWidth, OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x5B, XREF_D3DRS_LINEWIDTH ), + // XREF_ENTRY( 0x5B, XREF_D3DRS_LineWidth ), { 0x02, 0x5C }, @@ -329,7 +329,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilCullEnable, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_STENCILCULLENABLE), + XREF_ENTRY(0x0C, XREF_D3DRS_StencilCullEnable), { 0x01, 0x44 }, { 0x04, 0x56 }, @@ -349,8 +349,8 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_BackFillMode, XRefTwo) OOVPA_SIG_MATCH( - XREF_ENTRY(0x06, XREF_D3DRS_FILLMODE), - XREF_ENTRY(0x0B, XREF_D3DRS_BACKFILLMODE), + XREF_ENTRY(0x06, XREF_D3DRS_FillMode), + XREF_ENTRY(0x0B, XREF_D3DRS_BackFillMode), { 0x01, 0x44 }, { 0x0F, 0x89 }, @@ -431,7 +431,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_MULTISAMPLEANTIALIAS), + XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleAntiAlias), { 0x00, 0x8B }, @@ -453,7 +453,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_MULTISAMPLEMASK), + XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleMask), { 0x00, 0x8B }, { 0x01, 0x44 }, @@ -475,7 +475,7 @@ OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_LogicOp, 1024) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x2D, XREF_D3DRS_LOGICOP ), + // XREF_ENTRY( 0x2D, XREF_D3DRS_LogicOp ), { 0x01, 0x8B }, @@ -536,7 +536,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_TwoSidedLighting, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x15, XREF_D3DRS_TWOSIDEDLIGHTING), + XREF_ENTRY(0x15, XREF_D3DRS_TwoSidedLighting), { 0x00, 0xA1 }, diff --git a/src/OOVPADatabase/D3D8LTCG/4039.inl b/src/OOVPADatabase/D3D8LTCG/4039.inl index 431b3402..ef15081a 100644 --- a/src/OOVPADatabase/D3D8LTCG/4039.inl +++ b/src/OOVPADatabase/D3D8LTCG/4039.inl @@ -148,7 +148,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_CullMode, OOVPA_SIG_MATCH( XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - XREF_ENTRY(0x31, XREF_D3DRS_CULLMODE), // Derived + XREF_ENTRY(0x31, XREF_D3DRS_CullMode), // Derived { 0x00, 0x56 }, @@ -451,8 +451,8 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_TwoSidedLighting, XRefTwo) OOVPA_SIG_MATCH( - XREF_ENTRY(0x18, XREF_D3DRS_FILLMODE), - XREF_ENTRY(0x1D, XREF_D3DRS_TWOSIDEDLIGHTING), + XREF_ENTRY(0x18, XREF_D3DRS_FillMode), + XREF_ENTRY(0x1D, XREF_D3DRS_TwoSidedLighting), { 0x00, 0x8B }, { 0x06, 0x8B }, @@ -471,7 +471,7 @@ OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_LogicOp, 1036) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x34, XREF_D3DRS_LOGICOP ), + // XREF_ENTRY( 0x34, XREF_D3DRS_LogicOp ), { 0x01, 0x8B }, @@ -493,7 +493,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_MULTISAMPLEANTIALIAS), + XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleAntiAlias), { 0x00, 0x8B }, @@ -515,7 +515,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_MULTISAMPLEMASK), + XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleMask), { 0x00, 0x8B }, { 0x01, 0x44 }, @@ -537,7 +537,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMode, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0B, XREF_D3DRS_MULTISAMPLEMODE), + XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleMode), { 0x00, 0x8B }, { 0x15, 0x3B }, @@ -558,7 +558,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0B, XREF_D3DRS_MULTISAMPLERENDERTARGETMODE), + XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleRenderTargetMode), { 0x01, 0x4C }, { 0x15, 0x3B }, @@ -643,7 +643,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderTarget, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x4F, XREF_D3DRS_MULTISAMPLEMODE), + XREF_ENTRY(0x4F, XREF_D3DRS_MultiSampleMode), { 0x00, 0x83 }, { 0x01, 0xEC }, diff --git a/src/OOVPADatabase/D3D8LTCG/4432.inl b/src/OOVPADatabase/D3D8LTCG/4432.inl index de0b0f6c..50cb7025 100644 --- a/src/OOVPADatabase/D3D8LTCG/4432.inl +++ b/src/OOVPADatabase/D3D8LTCG/4432.inl @@ -122,7 +122,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_CullMode, OOVPA_SIG_MATCH( XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - XREF_ENTRY(0x34, XREF_D3DRS_CULLMODE), // Derived + XREF_ENTRY(0x34, XREF_D3DRS_CullMode), // Derived { 0x00, 0x56 }, @@ -356,7 +356,7 @@ OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_LogicOp, 1048) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x34, XREF_D3DRS_LOGICOP ), + // XREF_ENTRY( 0x34, XREF_D3DRS_LogicOp ), { 0x01, 0x8B }, @@ -378,7 +378,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_MULTISAMPLEANTIALIAS), + XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleAntiAlias), { 0x00, 0x8B }, @@ -400,7 +400,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_MULTISAMPLEMASK), + XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleMask), { 0x00, 0x8B }, { 0x01, 0x44 }, diff --git a/src/OOVPADatabase/D3D8LTCG/4531.inl b/src/OOVPADatabase/D3D8LTCG/4531.inl index 75c5a932..2d32370b 100644 --- a/src/OOVPADatabase/D3D8LTCG/4531.inl +++ b/src/OOVPADatabase/D3D8LTCG/4531.inl @@ -101,7 +101,7 @@ OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_ZBias, 1036) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBIAS ), + // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBias ), { 0x00, 0x51 }, { 0x01, 0x56 }, diff --git a/src/OOVPADatabase/D3D8LTCG/4627.inl b/src/OOVPADatabase/D3D8LTCG/4627.inl index a28a1930..b376abae 100644 --- a/src/OOVPADatabase/D3D8LTCG/4627.inl +++ b/src/OOVPADatabase/D3D8LTCG/4627.inl @@ -77,7 +77,7 @@ OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_ZBias, 1060) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBIAS ), + // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBias ), { 0x00, 0x51 }, { 0x01, 0x53 }, @@ -101,7 +101,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0D, XREF_D3DRS_MULTISAMPLEANTIALIAS), + XREF_ENTRY(0x0D, XREF_D3DRS_MultiSampleAntiAlias), { 0x00, 0x8B }, { 0x01, 0x44 }, @@ -121,7 +121,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_MULTISAMPLEMASK), + XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleMask), { 0x01, 0x44 }, { 0x02, 0x24 }, @@ -140,7 +140,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0B, XREF_D3DRS_MULTISAMPLEMASK), + XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleMask), { 0x01, 0x44 }, { 0x0F, 0xC1 }, @@ -159,7 +159,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_SampleAlpha, XRefOne) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_SAMPLEALPHA), + XREF_ENTRY(0x0C, XREF_D3DRS_SampleAlpha), { 0x00, 0x8B }, { 0x04, 0x57 }, diff --git a/src/OOVPADatabase/D3D8LTCG/5788.inl b/src/OOVPADatabase/D3D8LTCG/5788.inl index ff185d42..9d03e391 100644 --- a/src/OOVPADatabase/D3D8LTCG/5788.inl +++ b/src/OOVPADatabase/D3D8LTCG/5788.inl @@ -178,7 +178,7 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_CullMode, OOVPA_SIG_MATCH( XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - XREF_ENTRY(0x35, XREF_D3DRS_CULLMODE), // Derived + XREF_ENTRY(0x35, XREF_D3DRS_CullMode), // Derived { 0x00, 0x56 }, @@ -282,7 +282,7 @@ OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_LogicOp, 1060) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x34, XREF_D3DRS_LOGICOP ), + // XREF_ENTRY( 0x34, XREF_D3DRS_LogicOp ), { 0x01, 0x8B }, diff --git a/src/OOVPADatabase/D3D8LTCG/5849.inl b/src/OOVPADatabase/D3D8LTCG/5849.inl index db33b730..015b4fc2 100644 --- a/src/OOVPADatabase/D3D8LTCG/5849.inl +++ b/src/OOVPADatabase/D3D8LTCG/5849.inl @@ -280,7 +280,7 @@ OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_ZBias, 1024) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBIAS ), + // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBias ), { 0x00, 0x51 }, diff --git a/src/lib/libXbSymbolDatabase.c b/src/lib/libXbSymbolDatabase.c index 9987f887..9205d795 100644 --- a/src/lib/libXbSymbolDatabase.c +++ b/src/lib/libXbSymbolDatabase.c @@ -825,12 +825,12 @@ bool XbSymbolDatabase_CreateXbSymbolContext(XbSymbolContextHandle* ppHandle, // Request a few fundamental XRefs to be derived instead of checked // D3D pContext->xref_database[XREF_D3D_g_pDevice] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_CULLMODE] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_MULTISAMPLERENDERTARGETMODE] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_ROPZCMPALWAYSREAD] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_ROPZREAD] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_DONOTCULLUNCOMPRESSED] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_STENCILCULLENABLE] = XREF_ADDR_DERIVE; //In use + pContext->xref_database[XREF_D3DRS_CullMode] = XREF_ADDR_DERIVE; //In use + pContext->xref_database[XREF_D3DRS_MultiSampleRenderTargetMode] = XREF_ADDR_DERIVE; //In use + pContext->xref_database[XREF_D3DRS_RopZCmpAlwaysRead] = XREF_ADDR_DERIVE; //In use + pContext->xref_database[XREF_D3DRS_RopZRead] = XREF_ADDR_DERIVE; //In use + pContext->xref_database[XREF_D3DRS_DoNotCullUncompressed] = XREF_ADDR_DERIVE; //In use + pContext->xref_database[XREF_D3DRS_StencilCullEnable] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DTSS_TEXCOORDINDEX] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3D_g_Stream] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_OFFSET_D3DDevice__m_PixelShader] = XREF_ADDR_DERIVE; // diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index d6449990..f8f31d20 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -25,7 +25,7 @@ static void manual_scan_section_dx8_register_xrefs(iXbSymbolContext* pContext, const iXbSymbolLibrarySession* pLibrarySession, memptr_t pFunc, - xbaddr DerivedAddr_D3DRS_CULLMODE, + xbaddr DerivedAddr_D3DRS_CullMode, uint32_t patchOffset, uint32_t Increment, uint32_t Decrement) @@ -49,56 +49,56 @@ static void manual_scan_section_dx8_register_xrefs(iXbSymbolContext* pContext, pContext->register_func(pLibrary->name, pLibrary->flag, XREF_D3D_g_pDevice, "D3D_g_pDevice", DerivedAddr_D3DDevice, 0); // Temporary verification - is XREF_D3D_RenderState_CullMode derived correctly? - if (pContext->xref_database[XREF_D3DRS_CULLMODE] != DerivedAddr_D3DRS_CULLMODE) { + if (pContext->xref_database[XREF_D3DRS_CullMode] != DerivedAddr_D3DRS_CullMode) { - if (pContext->xref_database[XREF_D3DRS_CULLMODE] != XREF_ADDR_DERIVE) { + if (pContext->xref_database[XREF_D3DRS_CullMode] != XREF_ADDR_DERIVE) { output_message(&pContext->output, XB_OUTPUT_MESSAGE_WARN, "Second derived XREF_D3D_RenderState_CullMode differs from first!"); } - internal_SetXRefDatabase(pContext, pLibrarySession->iLibraryType, XREF_D3DRS_CULLMODE, DerivedAddr_D3DRS_CULLMODE); + internal_SetXRefDatabase(pContext, pLibrarySession->iLibraryType, XREF_D3DRS_CullMode, DerivedAddr_D3DRS_CullMode); } - // Register the offset of D3DRS_CULLMODE, this can be used to programatically locate other render-states in the calling program - pContext->register_func(pLibrary->name, pLibrary->flag, XREF_D3DRS_CULLMODE, "D3DRS_CULLMODE", DerivedAddr_D3DRS_CULLMODE, 0); + // Register the offset of D3DRS_CullMode, this can be used to programatically locate other render-states in the calling program + pContext->register_func(pLibrary->name, pLibrary->flag, XREF_D3DRS_CullMode, "D3DRS_CullMode", DerivedAddr_D3DRS_CullMode, 0); - // Derive address of EmuD3DDeferredRenderState from D3DRS_CULLMODE - xbaddr EmuD3DDeferredRenderState = DerivedAddr_D3DRS_CULLMODE - Decrement + Increment; + // Derive address of EmuD3DDeferredRenderState from D3DRS_CullMode + xbaddr EmuD3DDeferredRenderState = DerivedAddr_D3DRS_CullMode - Decrement + Increment; patchOffset -= Increment; // Derive address of a few other deferred render state slots (to help xref-based function location) - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_PSTEXTUREMODES, DerivedAddr_D3DRS_CULLMODE - 11*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_VERTEXBLEND, DerivedAddr_D3DRS_CULLMODE - 10*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_FOGCOLOR, DerivedAddr_D3DRS_CULLMODE - 9*4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_FILLMODE, DerivedAddr_D3DRS_CULLMODE - 8 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_BACKFILLMODE, DerivedAddr_D3DRS_CULLMODE - 7 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_TWOSIDEDLIGHTING, DerivedAddr_D3DRS_CULLMODE - 6 * 4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_NORMALIZENORMALS, DerivedAddr_D3DRS_CULLMODE - 5*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_ZENABLE, DerivedAddr_D3DRS_CULLMODE - 4*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_STENCILENABLE, DerivedAddr_D3DRS_CULLMODE - 3*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_STENCILFAIL, DerivedAddr_D3DRS_CULLMODE - 2*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_FRONTFACE, DerivedAddr_D3DRS_CULLMODE - 1*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_CULLMODE, DerivedAddr_D3DRS_CULLMODE - 0*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_TEXTUREFACTOR, DerivedAddr_D3DRS_CULLMODE + 1*4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_ZBIAS, DerivedAddr_D3DRS_CULLMODE + 2 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_LOGICOP, DerivedAddr_D3DRS_CULLMODE + 3 * 4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_EDGEANTIALIAS, DerivedAddr_D3DRS_CULLMODE + 4*4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MULTISAMPLEANTIALIAS, DerivedAddr_D3DRS_CULLMODE + 5 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MULTISAMPLEMASK, DerivedAddr_D3DRS_CULLMODE + 6 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MULTISAMPLEMODE, DerivedAddr_D3DRS_CULLMODE + 7 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MULTISAMPLERENDERTARGETMODE, DerivedAddr_D3DRS_CULLMODE + 8 * 4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_SHADOWFUNC, DerivedAddr_D3DRS_CULLMODE + 9*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_LINEWIDTH, DerivedAddr_D3DRS_CULLMODE + 10*4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_PSTextureModes, DerivedAddr_D3DRS_CullMode - 11*4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_VertexBlend, DerivedAddr_D3DRS_CullMode - 10*4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_FogColor, DerivedAddr_D3DRS_CullMode - 9*4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_FillMode, DerivedAddr_D3DRS_CullMode - 8 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_BackFillMode, DerivedAddr_D3DRS_CullMode - 7 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_TwoSidedLighting, DerivedAddr_D3DRS_CullMode - 6 * 4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_NormalizeNormals, DerivedAddr_D3DRS_CullMode - 5*4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_ZEnable, DerivedAddr_D3DRS_CullMode - 4*4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_StencilEnable, DerivedAddr_D3DRS_CullMode - 3*4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_StencilFail, DerivedAddr_D3DRS_CullMode - 2*4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_FrontFace, DerivedAddr_D3DRS_CullMode - 1*4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_CullMode, DerivedAddr_D3DRS_CullMode - 0*4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_TextureFactor, DerivedAddr_D3DRS_CullMode + 1*4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_ZBias, DerivedAddr_D3DRS_CullMode + 2 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_LogicOp, DerivedAddr_D3DRS_CullMode + 3 * 4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_EdgeAntiAlias, DerivedAddr_D3DRS_CullMode + 4*4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MultiSampleAntiAlias, DerivedAddr_D3DRS_CullMode + 5 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MultiSampleMask, DerivedAddr_D3DRS_CullMode + 6 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MultiSampleMode, DerivedAddr_D3DRS_CullMode + 7 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MultiSampleRenderTargetMode, DerivedAddr_D3DRS_CullMode + 8 * 4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_ShadowFunc, DerivedAddr_D3DRS_CullMode + 9*4); + // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_LineWidth, DerivedAddr_D3DRS_CullMode + 10*4); if (pLibrary->build_version >= 4627 && pLibrary->build_version <= 5933) { // Add XDK 4627 - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_SAMPLEALPHA, DerivedAddr_D3DRS_CULLMODE + 11 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_SampleAlpha, DerivedAddr_D3DRS_CullMode + 11 * 4); } - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_DXT1NOISEENABLE, EmuD3DDeferredRenderState + patchOffset - 3 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_YUVENABLE, EmuD3DDeferredRenderState + patchOffset - 2 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_OCCLUSIONCULLENABLE, EmuD3DDeferredRenderState + patchOffset - 1 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_STENCILCULLENABLE, EmuD3DDeferredRenderState + patchOffset + 0 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_ROPZCMPALWAYSREAD, EmuD3DDeferredRenderState + patchOffset + 1 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_ROPZREAD, EmuD3DDeferredRenderState + patchOffset + 2 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_DONOTCULLUNCOMPRESSED, EmuD3DDeferredRenderState + patchOffset + 3 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_Dxt1NoiseEnable, EmuD3DDeferredRenderState + patchOffset - 3 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_YuvEnable, EmuD3DDeferredRenderState + patchOffset - 2 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_OcclusionCullEnable, EmuD3DDeferredRenderState + patchOffset - 1 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_StencilCullEnable, EmuD3DDeferredRenderState + patchOffset + 0 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_RopZCmpAlwaysRead, EmuD3DDeferredRenderState + patchOffset + 1 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_RopZRead, EmuD3DDeferredRenderState + patchOffset + 2 * 4); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_DoNotCullUncompressed, EmuD3DDeferredRenderState + patchOffset + 3 * 4); pContext->register_func(pLibrary->name, pLibrary->flag, XREF_D3D_g_DeferredRenderState, "D3D_g_DeferredRenderState", EmuD3DDeferredRenderState, 0); } @@ -174,7 +174,7 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, memptr_t pFunc = 0; xbaddr xSymbolAddr = 0; // offset for stencil cull enable render state in the deferred render state buffer - uint32_t DerivedAddr_D3DRS_CULLMODE = 0; + uint32_t DerivedAddr_D3DRS_CullMode = 0; int Decrement = 0; // TODO : Rename into something understandable int Increment = 0; // TODO : Rename into something understandable int patchOffset = 0; // TODO : Rename into something understandable @@ -209,13 +209,13 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, // NOTE: Is a requirement to align properly. pFunc += virt_start_relative; - // Read address of D3DRS_CULLMODE from D3DDevice_SetRenderState_CullMode + // Read address of D3DRS_CullMode from D3DDevice_SetRenderState_CullMode // TODO : Simplify this when XREF_D3D_RenderState_CullMode derivation is deemed stable if (pLibrary->build_version < 3911) { // Not supported, currently ignored. } else if (pLibrary->build_version < 4034) { - DerivedAddr_D3DRS_CULLMODE = *(uint32_t*)(pFunc + 0x25); + DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + 0x25); Decrement = 0x1FC; // TODO: Clean up (?) Increment = 82 * 4; patchOffset = 140 * 4; // Verified 3925 and 3948 @@ -225,19 +225,19 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, //patchOffset = 142*4; // TODO: Verify } else if (pLibrary->build_version <= 4361) { - DerivedAddr_D3DRS_CULLMODE = *(uint32_t*)(pFunc + 0x2B); + DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + 0x2B); Decrement = 0x200; Increment = 82 * 4; patchOffset = 142 * 4; } else if (pLibrary->build_version < 4627) { - DerivedAddr_D3DRS_CULLMODE = *(uint32_t*)(pFunc + 0x2B); + DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + 0x2B); Decrement = 0x204; Increment = 83 * 4; patchOffset = 143 * 4; } else { // 4627-5933 - DerivedAddr_D3DRS_CULLMODE = *(uint32_t*)(pFunc + 0x2B); + DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + 0x2B); Decrement = 0x24C; Increment = 92 * 4; patchOffset = 162 * 4; @@ -279,13 +279,13 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, // NOTE: Is a requirement to align properly. pFunc += virt_start_relative; - // Read address of D3DRS_CULLMODE from D3DDevice_SetRenderState_CullMode + // Read address of D3DRS_CullMode from D3DDevice_SetRenderState_CullMode // TODO : Simplify this when XREF_D3D_RenderState_CullMode derivation is deemed stable if (pLibrary->build_version < 3911) { // Not supported, currently ignored. } else if (pLibrary->build_version < 4034) { - DerivedAddr_D3DRS_CULLMODE = *(uint32_t*)(pFunc + pXRefOffset); + DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + pXRefOffset); Decrement = 0x1FC; // TODO: Clean up (?) Increment = 82 * 4; patchOffset = 140 * 4; // Verified 3925 and 3948 @@ -295,27 +295,27 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, //patchOffset = 142*4; // TODO: Verify } else if (pLibrary->build_version <= 4361) { - DerivedAddr_D3DRS_CULLMODE = *(uint32_t*)(pFunc + pXRefOffset); + DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + pXRefOffset); Decrement = 0x200; Increment = 82 * 4; patchOffset = 142 * 4; } else if (pLibrary->build_version < 4627) { - DerivedAddr_D3DRS_CULLMODE = *(uint32_t*)(pFunc + pXRefOffset); + DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + pXRefOffset); Decrement = 0x204; Increment = 83 * 4; patchOffset = 143 * 4; } else { // 4627-5933 // NOTE: Burnout 3 is (pFunc + 0x34), Black is (pFunc + 0x35) - DerivedAddr_D3DRS_CULLMODE = *(uint32_t*)(pFunc + pXRefOffset); + DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + pXRefOffset); Decrement = 0x24C; Increment = 92 * 4; patchOffset = 162 * 4; } } } - manual_scan_section_dx8_register_xrefs(pContext, pLibrarySession, pFunc, DerivedAddr_D3DRS_CULLMODE, patchOffset, Increment, Decrement); + manual_scan_section_dx8_register_xrefs(pContext, pLibrarySession, pFunc, DerivedAddr_D3DRS_CullMode, patchOffset, Increment, Decrement); // then locate D3DDeferredTextureState if (pLibrary->flag == XbSymbolLib_D3D8) { diff --git a/src/test/libverify/D3D8.cpp b/src/test/libverify/D3D8.cpp index 6eb98107..8fc098a5 100644 --- a/src/test/libverify/D3D8.cpp +++ b/src/test/libverify/D3D8.cpp @@ -8,7 +8,7 @@ static const library_list database_full = { REGISTER_SYMBOL_INLINE(D3D_g_DeferredTextureState, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_g_pDevice, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_g_Stream, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), - REGISTER_SYMBOL_INLINE(D3DRS_CULLMODE, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_CullMode, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), // derived xrefs (offsets) REGISTER_SYMBOL_INLINE_VAR_OFFSET(D3DDevice__m_SwapCallback, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), From e3b8ce6c431e3c04597fbfe9315eb3892a3cab6e Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 20 Dec 2022 06:17:36 -0600 Subject: [PATCH 03/35] d3d: move callback events scan process into function --- src/lib/manual_d3d8__ltcg.h | 98 +++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 38 deletions(-) diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index f8f31d20..e72ebb35 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -165,6 +165,59 @@ static void manual_scan_section_dx8_register_stream(iXbSymbolContext* pContext, pContext->register_func(pLibrary->name, pLibrary->flag, XREF_D3D_g_Stream, "D3D_g_Stream", Derived_g_Stream, 0); } +// Has dependency on D3D_g_pDevice xref. +static bool manual_scan_section_dx8_register_callbacks(iXbSymbolContext* pContext, + const iXbSymbolLibrarySession* pLibrarySession, + SymbolDatabaseList* pLibraryDB, + const XbSDBSection* pSection) +{ + // Generic usage + memptr_t pFunc = 0; + xbaddr xSymbolAddr = 0; + const eLibraryType iLibraryType = pLibrarySession->iLibraryType; + // Manual check require for able to self-register these symbols: + // * D3DDevice_SetSwapCallback + // * D3DDevice_SetVerticalBlankCallback + + // First, check if D3D_g_pDevice is found. + if (pContext->xref_database[XREF_D3D_g_pDevice] != XREF_ADDR_DERIVE && + // Then, check at least one of symbol's member variable is not found. + pContext->xref_database[XREF_OFFSET_D3DDevice__m_SwapCallback] == XREF_ADDR_UNDETERMINED) { + + // Scan if event handle variable is not yet derived. + if (pContext->xref_database[XREF_OFFSET_D3DDevice__m_VerticalBlankEvent] == XREF_ADDR_DERIVE) { + xSymbolAddr = (xbaddr)(uintptr_t)internal_LocateSymbolFunction(pContext, + pLibrarySession, + pLibraryDB, + "D3DDevice__m_VerticalBlankEvent__ManualFindGeneric", + pSection, + true, + NULL, + NULL); + } + + // We are not registering D3DDevice__m_VerticalBlankEvent__ManualFindGeneric itself, as it is NOT a symbol. + + + // If not found, skip manual register. + if (pContext->xref_database[XREF_OFFSET_D3DDevice__m_VerticalBlankEvent] == XREF_ADDR_DERIVE) { + return false; + } + + // Finally, manual register the symbol variables. + xSymbolAddr = pContext->xref_database[XREF_OFFSET_D3DDevice__m_VerticalBlankEvent]; + internal_SetXRefDatabase(pContext, iLibraryType, XREF_OFFSET_D3DDevice__m_SwapCallback, xSymbolAddr - 8); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_OFFSET_D3DDevice__m_VBlankCallback, xSymbolAddr - 4); + } + // If D3D_g_pDevice is not found, the scan is not complete + // and will continue scan to next given section. + else { + return false; + } + + return true; +} + static bool manual_scan_section_dx8(iXbSymbolContext* pContext, const iXbSymbolLibrarySession* pLibrarySession, SymbolDatabaseList* pLibraryDB, @@ -187,6 +240,10 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, OOVPARevision* pOOVPARevision = NULL; + // We need to mask boolean from each function's scan process if any return false. + // Needed for no dependency, scanning multiple sections, and library's databases. + bool bComplete = true; + if (pLibrary->flag == XbSymbolLib_D3D8) { // locate D3DDevice_SetRenderState_CullMode first @@ -474,44 +531,9 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, manual_scan_section_dx8_register_stream(pContext, pLibrarySession, pFunc, iCodeOffsetFor_g_Stream); } - // Manual check require for able to self-register these symbols: - // * D3DDevice_SetSwapCallback - // * D3DDevice_SetVerticalBlankCallback - - // First, check if D3D_g_pDevice is found. - if (pContext->xref_database[XREF_D3D_g_pDevice] != XREF_ADDR_DERIVE && - // Then, check at least one of symbol's member variable is not found. - pContext->xref_database[XREF_OFFSET_D3DDevice__m_SwapCallback] == XREF_ADDR_UNDETERMINED) { - - // Scan if event handle variable is not yet derived. - if (pContext->xref_database[XREF_OFFSET_D3DDevice__m_VerticalBlankEvent] == XREF_ADDR_DERIVE) { - xSymbolAddr = (xbaddr)(uintptr_t)internal_LocateSymbolFunction(pContext, - pLibrarySession, - pLibraryDB, - "D3DDevice__m_VerticalBlankEvent__ManualFindGeneric", - pSection, - true, - NULL, - NULL); - } - - // We are not registering D3DDevice__m_VerticalBlankEvent__ManualFindGeneric itself, as it is NOT a symbol. - - - // If not found, skip manual register. - if (pContext->xref_database[XREF_OFFSET_D3DDevice__m_VerticalBlankEvent] == XREF_ADDR_DERIVE) { - return false; - } - - // Finally, manual register the symbol variables. - xSymbolAddr = pContext->xref_database[XREF_OFFSET_D3DDevice__m_VerticalBlankEvent]; - internal_SetXRefDatabase(pContext, iLibraryType, XREF_OFFSET_D3DDevice__m_SwapCallback, xSymbolAddr - 8); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_OFFSET_D3DDevice__m_VBlankCallback, xSymbolAddr - 4); - } - // If D3D_g_pDevice is not found, the scan is not complete - // and will continue scan to next given section. - else { - return false; + bComplete = manual_scan_section_dx8_register_callbacks(pContext, pLibrarySession, pLibraryDB, pSection); + if (!bComplete) { + return bComplete; } return true; From 6739087c66d2078727ea1786167a0cea3a5c23eb Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 20 Dec 2022 05:42:50 -0600 Subject: [PATCH 04/35] d3d: prepare for replace old scan process to DxbxRenderStateInfo table method --- src/lib/libXbSymbolDatabase.c | 1 + src/lib/manual_d3d8__ltcg.h | 219 ++++++++++++++++++++++++++++++++++ 2 files changed, 220 insertions(+) diff --git a/src/lib/libXbSymbolDatabase.c b/src/lib/libXbSymbolDatabase.c index 9205d795..b92684da 100644 --- a/src/lib/libXbSymbolDatabase.c +++ b/src/lib/libXbSymbolDatabase.c @@ -36,6 +36,7 @@ #include #include #include +#include // for static_assert #ifdef _MSC_VER #include diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index e72ebb35..2dc33b67 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -22,6 +22,225 @@ // ****************************************************************** #pragma once +// Notes : +// * Most renderstates were introduced in the (lowest known) XDK version : 3424 +// * Some titles use XDK version 3911 +// * The lowest XDK version that has been verified is : 3944 +// * All renderstates marked 3424 are also verified to be present in 3944 +// * Twenty-three additional renderstates were introduced after 3944 and up to 4627; +// * D3DRS_DEPTHCLIPCONTROL, D3DRS_STIPPLEENABLE, D3DRS_SIMPLE_UNUSED8..D3DRS_SIMPLE_UNUSED1, +// * D3DRS_SWAPFILTER, D3DRS_PRESENTATIONINTERVAL, D3DRS_DEFERRED_UNUSED8..D3DRS_DEFERRED_UNUSED1, +// * D3DRS_MULTISAMPLEMODE, D3DRS_MULTISAMPLERENDERTARGETMODE, and D3DRS_SAMPLEALPHA +// * One renderstate, D3DRS_MULTISAMPLETYPE, was removed (after 3944, before 4039, perhaps even 4034) +// * Around when D3DRS_MULTISAMPLETYPE was removed, D3DRS_MULTISAMPLEMODE was introduced (after 3944, before or at 4039, perhaps even 4034) +// * We MUST list exact versions for all above mentioned renderstates, since their inserts impacts mapping! +// * Renderstates verified to be introduced at 4039 or earlier, may have been introduced at 4034 or earlier +// * Renderstates were finalized in 4627 (so no change after that version) +// * XDK versions that have been verified : 3944, 4039, 4134, 4242, 4361, 4432, 4531, 4627, 4721, 4831, 4928, 5028, 5120, 5233, 5344, 5455, 5558, 5659, 5788, 5849, 5933 +// * Renderstates with uncertain validity are marked "Verified absent in #XDK#" and/or "present in #XDK#". Some have "Might be introduced "... "in between" or "around #XDK#" +// * Renderstates after D3DRS_MULTISAMPLEMASK have no host DX9 D3DRS mapping, thus no impact +typedef struct _RenderStateRevision { + uint16_t version; + uint16_t removed; + unsigned xref; + const char* name; +} RenderStateRevision; + +#define XREF_NAME(x) XREF_##x, #x + +static const RenderStateRevision DxbxRenderStateInfo[] = { + // Ord | Version (add/remove) | Name + /* 0 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaInputs0) */ }, + /* 1 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaInputs1) */ }, + /* 2 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaInputs2) */ }, + /* 3 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaInputs3) */ }, + /* 4 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaInputs4) */ }, + /* 5 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaInputs5) */ }, + /* 6 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaInputs6) */ }, + /* 7 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaInputs7) */ }, + /* 8 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSFinalCombinerInputsABCD) */ }, + /* 9 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSFinalCombinerInputsEFG) */ }, + /* 10 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant0_0) */ }, + /* 11 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant0_1) */ }, + /* 12 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant0_2) */ }, + /* 13 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant0_3) */ }, + /* 14 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant0_4) */ }, + /* 15 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant0_5) */ }, + /* 16 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant0_6) */ }, + /* 17 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant0_7) */ }, + /* 18 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant1_0) */ }, + /* 19 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant1_1) */ }, + /* 20 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant1_2) */ }, + /* 21 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant1_3) */ }, + /* 22 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant1_4) */ }, + /* 23 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant1_5) */ }, + /* 24 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant1_6) */ }, + /* 25 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSConstant1_7) */ }, + /* 26 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaOutputs0) */ }, + /* 27 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaOutputs1) */ }, + /* 28 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaOutputs2) */ }, + /* 29 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaOutputs3) */ }, + /* 30 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaOutputs4) */ }, + /* 31 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaOutputs5) */ }, + /* 32 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaOutputs6) */ }, + /* 33 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSAlphaOutputs7) */ }, + /* 34 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBInputs0) */ }, + /* 35 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBInputs1) */ }, + /* 36 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBInputs2) */ }, + /* 37 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBInputs3) */ }, + /* 38 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBInputs4) */ }, + /* 39 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBInputs5) */ }, + /* 40 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBInputs6) */ }, + /* 41 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBInputs7) */ }, + /* 42 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSCompareMode) */ }, + /* 43 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSFinalCombinerConstant0) */ }, + /* 44 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSFinalCombinerConstant1) */ }, + /* 45 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBOutputs0) */ }, + /* 46 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBOutputs1) */ }, + /* 47 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBOutputs2) */ }, + /* 48 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBOutputs3) */ }, + /* 49 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBOutputs4) */ }, + /* 50 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBOutputs5) */ }, + /* 51 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBOutputs6) */ }, + /* 52 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSRGBOutputs7) */ }, + /* 53 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSCombinerCount) */ }, + /* 54 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSTextureModes_Reserved) */ }, // Dxbx note : This takes the slot of X_D3DPIXELSHADERDEF.PSTextureModes, set by D3DDevice_SetRenderState_LogicOp? + /* 55 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSDotMapping) */ }, // + /* 56 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSInputTexture) */ }, // + /* End of "pixel-shader" render states, continuing with "simple" render states: */ // + /* 57 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ZFunc) */ }, // + /* 58 */ { 3424, 0000 /*, XREF_NAME(D3DRS_AlphaFunc) */ }, // + /* 59 */ { 3424, 0000 /*, XREF_NAME(D3DRS_AlphaBlendEnable) */ }, // + /* 60 */ { 3424, 0000 /*, XREF_NAME(D3DRS_AlphaTestEnable) */ }, // + /* 61 */ { 3424, 0000 /*, XREF_NAME(D3DRS_AlphaRef) */ }, // + /* 62 */ { 3424, 0000 /*, XREF_NAME(D3DRS_SrcBlend) */ }, // + /* 63 */ { 3424, 0000 /*, XREF_NAME(D3DRS_DestBlend) */ }, // + /* 64 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ZWriteEnable) */ }, // + /* 65 */ { 3424, 0000 /*, XREF_NAME(D3DRS_DitherEnable) */ }, // + /* 66 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ShadeMode) */ }, // + /* 67 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ColorWriteEnable) */ }, // *_ALPHA, etc. per-channel write enable + /* 68 */ { 3424, 0000 /*, XREF_NAME(D3DRS_StencilZFail) */ }, // + /* 69 */ { 3424, 0000 /*, XREF_NAME(D3DRS_StencilPass) */ }, // + /* 70 */ { 3424, 0000 /*, XREF_NAME(D3DRS_StencilFunc) */ }, // + /* 71 */ { 3424, 0000 /*, XREF_NAME(D3DRS_StencilRef) */ }, // + /* 72 */ { 3424, 0000 /*, XREF_NAME(D3DRS_StencilMask) */ }, // + /* 73 */ { 3424, 0000 /*, XREF_NAME(D3DRS_StencilWriteMask) */ }, // + /* 74 */ { 3424, 0000 /*, XREF_NAME(D3DRS_BlendOp) */ }, // + /* 75 */ { 3424, 0000 /*, XREF_NAME(D3DRS_BlendColor) */ }, // + /* D3D9 D3DRS_BLENDFACTOR : D3DColor used for a constant blend factor during */ // + /* alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR */ // + /* 76 */ { 3424, 0000 /*, XREF_NAME(D3DRS_SwathWidth) */ }, // + /* 77 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PolygonOffsetZSlopeScale) */ }, // + /* 78 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PolygonOffsetZOffset) */ }, // + /* 79 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PointOffsetEnable) */ }, // + /* 80 */ { 3424, 0000 /*, XREF_NAME(D3DRS_WireFrameOffsetEnable) */ }, // + /* 81 */ { 3424, 0000 /*, XREF_NAME(D3DRS_SolidOffsetEnable) */ }, // + /* 82 */ { 4432, 0000 /*, XREF_NAME(D3DRS_DepthClipControl) */ }, // Verified absent in 4361, present in 4432 TODO: Might be introduced around 4400? + /* 83 */ { 4627, 0000 /*, XREF_NAME(D3DRS_StippleEnable) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 84 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Simple_Unused8) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 85 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Simple_Unused7) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 86 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Simple_Unused6) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 87 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Simple_Unused5) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 88 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Simple_Unused4) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 89 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Simple_Unused3) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 90 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Simple_Unused2) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 91 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Simple_Unused1) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* End of "simple" render states, continuing with "deferred" render states: */ // + /* Verified as XDK 3911 Deferred RenderStates(3424 yet to do) */ // + /* 92 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FogEnable) */ }, // TRUE to enable fog blending + /* 93 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FogTableMode) */ }, // D3DFOGMODE + /* 94 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FogStart) */ }, // float fog start (for both vertex and pixel fog) + /* 95 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FogEnd) */ }, // float fog end + /* 96 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FogDensity) */ }, // float fog density // + NV2A_FOG_EQUATION_LINEAR + NV2A_FOG_EQUATION_QUADRATIC + /* 97 */ { 3424, 0000 /*, XREF_NAME(D3DRS_RangeFogEnable) */ }, // TRUE to enable range-based fog + /* 98 */ { 3424, 0000 /*, XREF_NAME(D3DRS_Wrap0) */ }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 1st texture coord. + /* 99 */ { 3424, 0000 /*, XREF_NAME(D3DRS_Wrap1) */ }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 2nd texture coord. + /* 100 */ { 3424, 0000 /*, XREF_NAME(D3DRS_Wrap2) */ }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 3rd texture coord. + /* 101 */ { 3424, 0000 /*, XREF_NAME(D3DRS_Wrap3) */ }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 4th texture coord. + /* 102 */ { 3424, 0000 /*, XREF_NAME(D3DRS_Lighting) */ }, // TRUE to enable lighting // TODO: Needs push-buffer data conversion + /* 103 */ { 3424, 0000 /*, XREF_NAME(D3DRS_SpecularEnable) */ }, // TRUE to enable specular + /* 104 */ { 3424, 0000 /*, XREF_NAME(D3DRS_LocalViewer) */ }, // TRUE to enable camera-relative specular highlights + /* 105 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ColorVertex) */ }, // TRUE to enable per-vertex color + /* 106 */ { 3424, 0000 /*, XREF_NAME(D3DRS_BackSpecularMaterialSource) */ }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp. + /* 107 */ { 3424, 0000 /*, XREF_NAME(D3DRS_BackDiffuseMaterialSource) */ }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp. + /* 108 */ { 3424, 0000 /*, XREF_NAME(D3DRS_BackAmbientMaterialSource) */ }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp. + /* 109 */ { 3424, 0000 /*, XREF_NAME(D3DRS_BackEmissiveMaterialSource) */ }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp. + /* 110 */ { 3424, 0000 /*, XREF_NAME(D3DRS_SpecularMaterialSource) */ }, // D3DMATERIALCOLORSOURCE + /* 111 */ { 3424, 0000 /*, XREF_NAME(D3DRS_DiffuseMaterialSource) */ }, // D3DMATERIALCOLORSOURCE + /* 112 */ { 3424, 0000 /*, XREF_NAME(D3DRS_AmbientMaterialSource) */ }, // D3DMATERIALCOLORSOURCE + /* 113 */ { 3424, 0000 /*, XREF_NAME(D3DRS_EmissiveMaterialSource) */ }, // D3DMATERIALCOLORSOURCE + /* 114 */ { 3424, 0000 /*, XREF_NAME(D3DRS_BackAmbient) */ }, // D3DCOLOR (Xbox extension) // ..NV2A_MATERIAL_FACTOR_Back_B nsp. Was NV2A_LIGHT_MODEL_Back_AMBIENT_R + /* 115 */ { 3424, 0000 /*, XREF_NAME(D3DRS_Ambient) */ }, // D3DCOLOR // ..NV2A_LIGHT_MODEL_FRONT_Ambient_B + NV2A_MATERIAL_FACTOR_FRONT_R..NV2A_MATERIAL_FACTOR_FRONT_A Was NV2A_LIGHT_MODEL_FRONT_AMBIENT_R + /* 116 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PointSize) */ }, // float point size + /* 117 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PointSize_Min) */ }, // float point size min threshold + /* 118 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PointSpriteEnable) */ }, // TRUE to enable point sprites + /* 119 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PointScaleEnable) */ }, // TRUE to enable point size scaling + /* 120 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PointScale_A) */ }, // float point attenuation A value + /* 121 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PointScale_B) */ }, // float point attenuation B value + /* 122 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PointScale_C) */ }, // float point attenuation C value + /* 123 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PointSize_Max) */ }, // float point size max threshold + /* 124 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PatchEdgeStyle) */ }, // D3DPATCHEDGESTYLE + /* 125 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PatchSegments) */ }, // DWORD number of segments per edge when drawing patches, nsp (D3DRS_PATCHSEGMENTS exists in Direct3D 8, but not in 9) + /* TODO -oDxbx : Is X_D3DRS_SWAPFILTER really a xtD3DMULTISAMPLE_TYPE? */ // + /* 126 */ { 4034, 0000 /*, XREF_NAME(D3DRS_SwapFilter) */ }, // nsp. Verified absent in 3944, present in 4034. 4034 state based on test-case : The Simpsons Road Rage + /* 127 */ { 4627, 0000 /*, XREF_NAME(D3DRS_PresentationInterval) */ }, // nsp. Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 128 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Deferred_Unused8) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 129 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Deferred_Unused7) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 130 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Deferred_Unused6) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 131 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Deferred_Unused5) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 132 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Deferred_Unused4) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 133 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Deferred_Unused3) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 134 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Deferred_Unused2) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 135 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Deferred_Unused1) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* End of "deferred" render states, continuing with "complex" render states: */ // + /* 136 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSTextureModes) */ }, // This is where pPSDef->PSTextureModes is stored (outside the pPSDEF - see DxbxUpdateActivePixelShader) + /* 137 */ { 3424, 0000 /*, XREF_NAME(D3DRS_VertexBlend) */ }, // + /* 138 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FogColor) */ }, // SwapRgb + /* 139 */ { 3424, 0000, XREF_NAME(D3DRS_FillMode) }, // + /* 140 */ { 3424, 0000, XREF_NAME(D3DRS_BackFillMode) }, // nsp. + /* 141 */ { 3424, 0000, XREF_NAME(D3DRS_TwoSidedLighting) }, // nsp. // FIXME map from NV2A_LIGHT_MODEL + /* 142 */ { 3424, 0000 /*, XREF_NAME(D3DRS_NormalizeNormals) */ }, // + /* 143 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ZEnable) */ }, // D3DZBUFFERTYPE? + /* 144 */ { 3424, 0000, XREF_NAME(D3DRS_StencilEnable) }, // + /* 145 */ { 3424, 0000 /*, XREF_NAME(D3DRS_StencilFail) */ }, // + /* 146 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FrontFace) */ }, // nsp. + /* 147 */ { 3424, 0000, XREF_NAME(D3DRS_CullMode) }, // + /* 148 */ { 3424, 0000 /*, XREF_NAME(D3DRS_TextureFactor) */ }, // + /* 149 */ { 3424, 0000, XREF_NAME(D3DRS_ZBias) }, // Was D3DRS_ZBIAS + /* 150 */ { 3424, 0000, XREF_NAME(D3DRS_LogicOp) }, // nsp. + /* 151 */ { 3424, 0000 /*, XREF_NAME(D3DRS_EdgeAntiAlias) */ }, // Was D3DRS_EDGEANTIALIAS. Dxbx note : No Xbox ext. (according to Direct3D8) ! + /* 152 */ { 3424, 0000, XREF_NAME(D3DRS_MultiSampleAntiAlias) }, // + /* 153 */ { 3424, 0000, XREF_NAME(D3DRS_MultiSampleMask) }, // + /* 154 */ { 3424, 4034 /*, XREF_NAME(D3DRS_MultiSampleType) */ }, // Verified present in 3944, removed in 4034. 4034 state based on test-case : The Simpsons Road Rage + /* 155 */ { 4034, 0000 /*, XREF_NAME(D3DRS_MultiSampleMode) */ }, // D3DMULTISAMPLEMODE for the backbuffer. Verified absent in 3944, present in 4034. 4034 state based on test-case : The Simpsons Road Rage + /* 156 */ { 4034, 0000, XREF_NAME(D3DRS_MultiSampleRenderTargetMode) }, // Verified absent in 3944, present in 4034. Presence in 4034 is based on test-case : The Simpsons Road Rage + /* 157 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ShadowFunc) */ }, // + /* 158 */ { 3424, 0000, XREF_NAME(D3DRS_LineWidth) }, // + /* 159 */ { 4627, 0000, XREF_NAME(D3DRS_SampleAlpha) }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? + /* 160 */ { 3424, 0000, XREF_NAME(D3DRS_Dxt1NoiseEnable) }, // + /* 161 */ { 3911, 0000, XREF_NAME(D3DRS_YuvEnable) }, // Verified present in 3944 + /* 162 */ { 3911, 0000, XREF_NAME(D3DRS_OcclusionCullEnable) }, // Verified present in 3944 + /* 163 */ { 3911, 0000, XREF_NAME(D3DRS_StencilCullEnable) }, // Verified present in 3944 + /* 164 */ { 3911, 0000, XREF_NAME(D3DRS_RopZCmpAlwaysRead) }, // Verified present in 3944 + /* 165 */ { 3911, 0000, XREF_NAME(D3DRS_RopZRead) }, // Verified present in 3944 + /* 166 */ { 3911, 0000, XREF_NAME(D3DRS_DoNotCullUncompressed) }, // Verified present in 3944 +}; +static_assert(XBSDB_ARRAY_SIZE(DxbxRenderStateInfo) == 167, "DxbxRenderStateInfo is not at correct array size!"); + +static const size_t DxbxRenderStateInfoSize = XBSDB_ARRAY_SIZE(DxbxRenderStateInfo); + +static bool IsRenderStateAvailableInCurrentXboxD3D8Lib(RenderStateRevision aRenderStateInfo, + uint16_t library_version) +{ + bool bIsRenderStateAvailable = (aRenderStateInfo.version <= library_version); + if (aRenderStateInfo.removed > 0) { // Applies to xbox::X_D3DRS_MULTISAMPLETYPE + // Note : X_D3DRS_MULTISAMPLETYPE seems the only render state that got + // removed (from 4039 onwards), so we check that limitation here as well + bIsRenderStateAvailable &= (library_version < aRenderStateInfo.removed); + } + return bIsRenderStateAvailable; +} + static void manual_scan_section_dx8_register_xrefs(iXbSymbolContext* pContext, const iXbSymbolLibrarySession* pLibrarySession, memptr_t pFunc, From 12d4732ffd54518743ee817889e98d7ae47670c0 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 20 Dec 2022 07:34:17 -0600 Subject: [PATCH 05/35] d3d: dump render state's list to symbol registration callback. --- src/lib/manual_d3d8__ltcg.h | 27 ++++++++++++++++++++++++--- src/test/libverify/D3D8.cpp | 20 ++++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index 2dc33b67..0e48d01e 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -277,7 +277,7 @@ static void manual_scan_section_dx8_register_xrefs(iXbSymbolContext* pContext, internal_SetXRefDatabase(pContext, pLibrarySession->iLibraryType, XREF_D3DRS_CullMode, DerivedAddr_D3DRS_CullMode); } // Register the offset of D3DRS_CullMode, this can be used to programatically locate other render-states in the calling program - pContext->register_func(pLibrary->name, pLibrary->flag, XREF_D3DRS_CullMode, "D3DRS_CullMode", DerivedAddr_D3DRS_CullMode, 0); + internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_CullMode, DerivedAddr_D3DRS_CullMode); // Derive address of EmuD3DDeferredRenderState from D3DRS_CullMode xbaddr EmuD3DDeferredRenderState = DerivedAddr_D3DRS_CullMode - Decrement + Increment; @@ -319,7 +319,26 @@ static void manual_scan_section_dx8_register_xrefs(iXbSymbolContext* pContext, internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_RopZRead, EmuD3DDeferredRenderState + patchOffset + 2 * 4); internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_DoNotCullUncompressed, EmuD3DDeferredRenderState + patchOffset + 3 * 4); - pContext->register_func(pLibrary->name, pLibrary->flag, XREF_D3D_g_DeferredRenderState, "D3D_g_DeferredRenderState", EmuD3DDeferredRenderState, 0); +} + +static bool manual_scan_section_dx8_register_D3DRS_list(iXbSymbolContext* pContext, + const iXbSymbolLibrarySession* pLibrarySession, + SymbolDatabaseList* pLibraryDB, + const XbSDBSection* pSection) +{ + // Instead of individual register call, let's go through the list to automatically register valid xrefs. + const uint16_t lib_version = pLibrarySession->pLibrary->build_version; + for (size_t i = 0; i < DxbxRenderStateInfoSize; i++) { + const RenderStateRevision render_state_i = DxbxRenderStateInfo[i]; + if (IsRenderStateAvailableInCurrentXboxD3D8Lib(render_state_i, lib_version) && render_state_i.xref != 0) { + internal_RegisterValidXRefAddr(pContext, Lib_D3D8, XbSymbolLib_D3D8, render_state_i.xref, render_state_i.version, render_state_i.name); + } + } + + // Manual register RenderState sections. + internal_RegisterValidXRefAddr(pContext, Lib_D3D8, XbSymbolLib_D3D8, XREF_D3D_g_DeferredRenderState, 0, "D3D_g_DeferredRenderState"); + + return true; } static void manual_scan_section_dx8_register_D3DTSS(iXbSymbolContext* pContext, @@ -755,7 +774,9 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, return bComplete; } - return true; + bComplete = manual_scan_section_dx8_register_D3DRS_list(pContext, pLibrarySession, pLibraryDB, pSection); + + return bComplete; } static inline void manual_register_d3d8__ltcg(iXbSymbolContext* pContext) diff --git a/src/test/libverify/D3D8.cpp b/src/test/libverify/D3D8.cpp index 8fc098a5..78fc4ed5 100644 --- a/src/test/libverify/D3D8.cpp +++ b/src/test/libverify/D3D8.cpp @@ -8,7 +8,23 @@ static const library_list database_full = { REGISTER_SYMBOL_INLINE(D3D_g_DeferredTextureState, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_g_pDevice, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_g_Stream, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_BackFillMode, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_CullMode, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_DoNotCullUncompressed, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_Dxt1NoiseEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_FillMode, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_LogicOp, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleAntiAlias, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleMask, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleRenderTargetMode, VER_RANGE(4034, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_OcclusionCullEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_RopZCmpAlwaysRead, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_RopZRead, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_SampleAlpha, VER_RANGE(4627, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_StencilCullEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_TwoSidedLighting, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_YuvEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_ZBias, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), // derived xrefs (offsets) REGISTER_SYMBOL_INLINE_VAR_OFFSET(D3DDevice__m_SwapCallback, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), @@ -421,7 +437,7 @@ void getLibraryD3D8(library_db& lib_db) // TODO: database is incomplete + 1 internal reference need to be exclude. // Excluding: // - 1 internal manual scan reference - // - 20 variables + // - 4 variables // - 5 internal offsets - lib_db.xref_exclude = 26; + lib_db.xref_exclude = 10; } From bce6f59bf519693e9f55cbacb57fd0a03ffde126 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Wed, 21 Dec 2022 05:29:42 -0600 Subject: [PATCH 06/35] d3d: add D3D_g_RenderState support base on D3DDevice_SetRenderState(Not)Inline signatures --- include/xref/d3d8.def | 1 + include/xref/d3d8ltcg.def | 3 ++ src/OOVPADatabase/D3D8/3911.inl | 3 +- src/OOVPADatabase/D3D8LTCG/3911.inl | 38 +++++++++++++ src/OOVPADatabase/D3D8LTCG/4039.inl | 38 +++++++++++++ src/OOVPADatabase/D3D8LTCG/4627.inl | 12 ++++- src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 1 + src/OOVPADatabase/D3D8_OOVPA.inl | 4 +- src/lib/libXbSymbolDatabase.c | 1 + src/lib/manual_d3d8__ltcg.h | 79 ++++++++++++++++++++++++++++ src/test/libverify/D3D8.cpp | 7 +-- 11 files changed, 179 insertions(+), 8 deletions(-) diff --git a/include/xref/d3d8.def b/include/xref/d3d8.def index a072b283..1406a6a7 100644 --- a/include/xref/d3d8.def +++ b/include/xref/d3d8.def @@ -23,6 +23,7 @@ XREF_SYMBOL(D3DDevice__m_VerticalBlankEvent__ManualFindGeneric) // variable addresses +XREF_SYMBOL(D3D_g_RenderState) XREF_SYMBOL(D3D_g_DeferredRenderState) XREF_SYMBOL(D3D_g_DeferredTextureState) XREF_SYMBOL(D3D_g_pDevice) diff --git a/include/xref/d3d8ltcg.def b/include/xref/d3d8ltcg.def index eeab15b9..1d0403b2 100644 --- a/include/xref/d3d8ltcg.def +++ b/include/xref/d3d8ltcg.def @@ -19,6 +19,9 @@ // * // ****************************************************************** +// custom search (not for external project usage) +XREF_SYMBOL(D3DDevice_SetRenderStateInline__ManualFindGeneric) + // TODO: Verify each xref's function match with d3d8.def's function xrefs. // functions diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index d84fdc90..c22d9f97 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -5671,11 +5671,12 @@ OOVPA_SIG_MATCH( // Generic OOVPA as of 3911 and newer. OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderStateNotInline, 3911, - XRefOne) + XRefTwo) OOVPA_SIG_MATCH( // D3DDevice::SetRenderStateNotInline+0x18 : call D3DDevice_SetRenderState_Simple XREF_ENTRY(0x19, XREF_D3DDevice_SetRenderState_Simple), + XREF_ENTRY(0x20, XREF_D3D_g_RenderState), // D3DDevice::SetRenderStateNotInline+0x00 : push esi OV_MATCH(0x00, 0x56), diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index a740d0df..74379125 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -1222,3 +1222,41 @@ OOVPA_SIG_MATCH( OV_MATCH(0x24, 0x81, 0xFE, 0x00, 0x00, 0x05, 0x00), // ); + +// ****************************************************************** +// * D3DDevice_SetRenderStateInline__ManualFindGeneric +// ****************************************************************** +// NOTE: This signature will find any generic match with D3D_g_RenderState +// Currently, this is the best method if +// D3DDevice_SetRenderStateNotInline detection is absent. +// This OOVPA itself is not a symbol. +OOVPA_SIG_HEADER_XREF_DETECT(D3DDevice_SetRenderStateInline__ManualFindGeneric, + 3911, + XRefTwo, + DetectFirst) +OOVPA_SIG_MATCH( + // call D3DDevice_SetRenderState_Simple + XREF_ENTRY(0x15, XREF_D3DDevice_SetRenderState_Simple), + XREF_ENTRY(0x1C, XREF_D3D_g_RenderState), + + // cmp esi,0x?? // Up until < 4039 is 0x52 + OV_MATCH(0x00, 0x83, 0xFE), + + // mov edi,ptr [ebx + ????] + OV_MATCH(0x03, 0x8B, 0xBB), + + // jge +0x?? + OV_MATCH(0x09, 0x7D), + + // mov ecx,ptr [esi * 4 + ????] + OV_MATCH(0x0B, 0x8B, 0x0C, 0xB5), + + // mov edx,edi + OV_MATCH(0x12, 0x8B, 0xD7), + // call D3DDevice_SetRenderState_Simple + OV_MATCH(0x14, 0xE8), + + // mov ptr [esi * 4 + D3D_g_RenderState],edi + OV_MATCH(0x19, 0x89, 0x3C, 0xB5), + // +); diff --git a/src/OOVPADatabase/D3D8LTCG/4039.inl b/src/OOVPADatabase/D3D8LTCG/4039.inl index ef15081a..bea89dd7 100644 --- a/src/OOVPADatabase/D3D8LTCG/4039.inl +++ b/src/OOVPADatabase/D3D8LTCG/4039.inl @@ -1291,3 +1291,41 @@ OOVPA_SIG_MATCH( { 0x64, 0x01 }, // ); + +// ****************************************************************** +// * D3DDevice_SetRenderStateInline__ManualFindGeneric +// ****************************************************************** +// Generic OOVPA as of 4039? and newer. +// NOTE: This signature will find any generic match with D3D_g_RenderState +// Currently, this is the best method if +// D3DDevice_SetRenderStateNotInline detection is absent. +// This OOVPA itself is not a symbol. +// NOTE: Unknown if any titles build before 4039 with sig been detected. +// Due to lack of titles compiled as LTCG in 4039 and earlier builds. +// All titles from 4039 and later always detect 4039 sig. +OOVPA_SIG_HEADER_XREF_DETECT(D3DDevice_SetRenderStateInline__ManualFindGeneric, + 4039, + XRefTwo, + DetectFirst) +OOVPA_SIG_MATCH( + // call D3DDevice_SetRenderState_Simple + XREF_ENTRY(0x0F, XREF_D3DDevice_SetRenderState_Simple), + XREF_ENTRY(0x16, XREF_D3D_g_RenderState), + + // cmp esi,0x?? // Up until < 4242 is 0x52; 4432 & 4531 = 0x53; 4627+ = 0x5C + OV_MATCH(0x00, 0x83, 0xFE), + // jge +0x?? + OV_MATCH(0x03, 0x7D), + + // mov ecx,ptr [esi * 4 + ????] + OV_MATCH(0x05, 0x8B, 0x0C, 0xB5), + + // mov edx,edi + OV_MATCH(0x0C, 0x8B, 0xD7), + // call D3DDevice_SetRenderState_Simple + OV_MATCH(0x0E, 0xE8), + + // mov ptr [esi * 4 + D3D_g_RenderState],edi + OV_MATCH(0x13, 0x89, 0x3C, 0xB5), + // +); diff --git a/src/OOVPADatabase/D3D8LTCG/4627.inl b/src/OOVPADatabase/D3D8LTCG/4627.inl index b376abae..d6920d3a 100644 --- a/src/OOVPADatabase/D3D8LTCG/4627.inl +++ b/src/OOVPADatabase/D3D8LTCG/4627.inl @@ -1132,9 +1132,17 @@ OOVPA_SIG_MATCH( // * D3DDevice_SetRenderStateNotInline // ****************************************************************** //C381FE880000007D1D8B0D ...C3 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderStateNotInline_0, - 2048) +// Titles found are... +// * (4928.1) Shin Megami Tensei: Nine (DDS9) +// * (5120.1) Crimson Sea +// * (5344.1) The Italian Job +// * (5455.1) Freaky Flyers +// * (5659.4) Beyond Good And Evil +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderStateNotInline_0, + 2048, + XRefOne) OOVPA_SIG_MATCH( + XREF_ENTRY(0x16, XREF_D3D_g_RenderState), { 0x00, 0x83 }, { 0x01, 0xFE }, diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index 8a99fd07..fd57abd8 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -145,6 +145,7 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS_BIND_XREF(D3DDevice_SetPixelShaderConstant_4, D3DDevice_SetPixelShaderConstant, 2024), REGISTER_OOVPAS(D3DDevice_SetPixelShaderProgram, 1024), REGISTER_OOVPAS_BIND_XREF(D3DDevice_SetPixelShader_0__LTCG_eax_handle, D3DDevice_SetPixelShader, 2024, 2036, 2048, 2060, 2072), + REGISTER_OOVPAS_M(D3DDevice_SetRenderStateInline__ManualFindGeneric, 3911, 4039), // Final generic OOVPA: 4039?; Removed: 0 // NOTE: see notes from 4039 sig. REGISTER_OOVPAS_BIND_XREF(D3DDevice_SetRenderStateNotInline_0, D3DDevice_SetRenderStateNotInline, 2048), REGISTER_OOVPAS(D3DDevice_SetRenderState_BackFillMode, 1024, 1036), REGISTER_OOVPAS_C(D3DDevice_SetRenderState_CullMode, 1045, 1049, 1052, 1053), diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index ebd876b2..ecd83cd4 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -313,8 +313,8 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetPixelShader, 3911, 4034, 4627), REGISTER_OOVPAS(D3DDevice_SetPixelShaderConstant, 3911, 4831), REGISTER_OOVPAS(D3DDevice_SetPixelShaderProgram, 3911), - REGISTER_OOVPAS(D3DDevice_SetRenderState_Simple, 3911), // Final generic OOVPA: 3911; Removed: 0 - REGISTER_OOVPAS(D3DDevice_SetRenderStateNotInline, 3911), // Final generic OOVPA: 3911; Removed: 0 // NOTE: Must be after D3DDevice_SetRenderState_Simple. + REGISTER_OOVPAS_M(D3DDevice_SetRenderState_Simple, 3911), // Final generic OOVPA: 3911; Removed: 0 + REGISTER_OOVPAS_M(D3DDevice_SetRenderStateNotInline, 3911), // Final generic OOVPA: 3911; Removed: 0 // NOTE: Must be after D3DDevice_SetRenderState_Simple. // NOTE: Some or most of render state signatures below must be after D3DDevice_SetRenderStateNotInline. REGISTER_OOVPAS(D3DDevice_SetRenderState, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState2, 3911), // Final generic OOVPA: 3911; Removed: 0 // NOTE: There is a verified duplicate function. diff --git a/src/lib/libXbSymbolDatabase.c b/src/lib/libXbSymbolDatabase.c index b92684da..68690ed0 100644 --- a/src/lib/libXbSymbolDatabase.c +++ b/src/lib/libXbSymbolDatabase.c @@ -826,6 +826,7 @@ bool XbSymbolDatabase_CreateXbSymbolContext(XbSymbolContextHandle* ppHandle, // Request a few fundamental XRefs to be derived instead of checked // D3D pContext->xref_database[XREF_D3D_g_pDevice] = XREF_ADDR_DERIVE; //In use + pContext->xref_database[XREF_D3D_g_RenderState] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_CullMode] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_MultiSampleRenderTargetMode] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_RopZCmpAlwaysRead] = XREF_ADDR_DERIVE; //In use diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index 0e48d01e..113ff4d4 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -336,11 +336,82 @@ static bool manual_scan_section_dx8_register_D3DRS_list(iXbSymbolContext* pConte } // Manual register RenderState sections. + internal_RegisterValidXRefAddr(pContext, Lib_D3D8, XbSymbolLib_D3D8, XREF_D3D_g_RenderState, 0, "D3D_g_RenderState"); internal_RegisterValidXRefAddr(pContext, Lib_D3D8, XbSymbolLib_D3D8, XREF_D3D_g_DeferredRenderState, 0, "D3D_g_DeferredRenderState"); return true; } +// No dependency requirement +static bool manual_scan_section_dx8_register_D3DRS(iXbSymbolContext* pContext, + const iXbSymbolLibrarySession* pLibrarySession, + SymbolDatabaseList* pLibraryDB, + const XbSDBSection* pSection) +{ + OOVPATable* pSymbol = NULL; + OOVPARevision* pRevision = NULL; + // First, we need to find D3DDevice_SetRenderState_Simple symbol. + xbaddr D3DDevice_SetRenderState_Simple = pContext->xref_database[XREF_D3DDevice_SetRenderState_Simple]; + if (internal_IsXRefAddrUnset(D3DDevice_SetRenderState_Simple)) { + xbaddr xFuncAddr = (xbaddr)(uintptr_t)internal_LocateSymbolFunction(pContext, + pLibrarySession, + pLibraryDB, + "D3DDevice_SetRenderState_Simple", + pSection, + true, + &pSymbol, + &pRevision); + // If not found, skip the rest of the scan. + if (xFuncAddr == 0) { + return false; + } + + internal_RegisterSymbol(pContext, pLibrarySession, pSymbol, pRevision->Version, xFuncAddr); + } + + // Then look up for D3DDevice_SetRenderStateNotInline + xbaddr D3DDevice_SetRenderStateNotInline = pContext->xref_database[XREF_D3DDevice_SetRenderStateNotInline]; + xbaddr D3DDevice_SetRenderStateInline = pContext->xref_database[XREF_D3DDevice_SetRenderStateInline__ManualFindGeneric]; + if (internal_IsXRefAddrUnset(D3DDevice_SetRenderStateNotInline) && internal_IsXRefAddrUnset(D3DDevice_SetRenderStateInline)) { + xbaddr xFuncAddr = (xbaddr)(uintptr_t)internal_LocateSymbolFunction(pContext, + pLibrarySession, + pLibraryDB, + "D3DDevice_SetRenderStateNotInline", + pSection, + true, + &pSymbol, + &pRevision); + if (xFuncAddr == 0) { + // If not found, then check if library is not LTCG. + if (pLibrarySession->pLibrary->flag == XbSymbolLib_D3D8) { + return false; + } + // Otherwise, let's look up for D3DDevice_SetRenderStateInline which is NOT a function. + xFuncAddr = (xbaddr)(uintptr_t)internal_LocateSymbolFunction(pContext, + pLibrarySession, + pLibraryDB, + "D3DDevice_SetRenderStateInline__ManualFindGeneric", + pSection, + true, + &pSymbol, + &pRevision); + + // If not found, skip the rest of the scan. + if (xFuncAddr == 0) { + return false; + } + // If it is found, don't register it. + } + else { + // Register only D3DDevice_SetRenderStateNotInline symbol function. + // D3DDevice_SetRenderStateInline__ManualFindGeneric is not a function but a generic method to find D3D_g_RenderState. + internal_RegisterSymbol(pContext, pLibrarySession, pSymbol, pRevision->Version, xFuncAddr); + } + // D3D_g_RenderState variable is already set internal, will be register later. + } + return true; +} + static void manual_scan_section_dx8_register_D3DTSS(iXbSymbolContext* pContext, const iXbSymbolLibrarySession* pLibrarySession, memptr_t pFunc, @@ -482,6 +553,14 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, // Needed for no dependency, scanning multiple sections, and library's databases. bool bComplete = true; + // Get D3D_g_RenderState variable + bComplete &= manual_scan_section_dx8_register_D3DRS(pContext, pLibrarySession, pLibraryDB, pSection); + + // Check if any results as incomplete scan. + if (!bComplete) { + return bComplete; + } + if (pLibrary->flag == XbSymbolLib_D3D8) { // locate D3DDevice_SetRenderState_CullMode first diff --git a/src/test/libverify/D3D8.cpp b/src/test/libverify/D3D8.cpp index 78fc4ed5..fb42f353 100644 --- a/src/test/libverify/D3D8.cpp +++ b/src/test/libverify/D3D8.cpp @@ -4,6 +4,7 @@ static const library_list database_full = { // derived xrefs (variables) + REGISTER_SYMBOL_INLINE(D3D_g_RenderState, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_g_DeferredRenderState, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_g_DeferredTextureState, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_g_pDevice, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), @@ -434,10 +435,10 @@ void getLibraryD3D8(library_db& lib_db) lib_db.subcategories = { &d3d8_db }; lib_db.xref_offset = XREF_OFFSET; lib_db.xref_total = LOCAL_COUNT; - // TODO: database is incomplete + 1 internal reference need to be exclude. + // TODO: database is incomplete + 2 internal reference need to be exclude. // Excluding: - // - 1 internal manual scan reference + // - 2 internal manual scan reference // - 4 variables // - 5 internal offsets - lib_db.xref_exclude = 10; + lib_db.xref_exclude = 11; } From f3307d2367d77a3f941cb76812484e5fdf9ccc6e Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 20 Dec 2022 06:39:41 -0600 Subject: [PATCH 07/35] d3d: replace function to manual_scan_section_dx8_VerifyRenderStateOffsets --- src/lib/manual_d3d8__ltcg.h | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index 113ff4d4..dc78b80a 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -241,6 +241,74 @@ static bool IsRenderStateAvailableInCurrentXboxD3D8Lib(RenderStateRevision aRend return bIsRenderStateAvailable; } +static int GetRenderStateOffsetByXRef(uint16_t xref, + uint16_t library_version) +{ + int offset = 0; + for (size_t i = 0; i < DxbxRenderStateInfoSize; i++) { + if (DxbxRenderStateInfo[i].xref == xref) { + return offset; + } + if (IsRenderStateAvailableInCurrentXboxD3D8Lib(DxbxRenderStateInfo[i], library_version)) { + offset++; + } + } + return -1; +} + +static void manual_scan_section_dx8_VerifyRenderStateOffsets(iXbSymbolContext* pContext, + const iXbSymbolLibrarySession* pLibrarySession) +{ + const XbSDBLibrary* pLibrary = pLibrarySession->pLibrary; + + // Perform basic check up on: + // * Deferred offset + // * Complex offset + // Verify D3D_g_RenderState is set. + xbaddr g_RenderState = pContext->xref_database[XREF_D3D_g_RenderState]; + if (internal_IsXRefAddrUnset(g_RenderState)) { + output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, "D3D_g_RenderState is not set!"); + return; + } + + // Verify D3D_g_DeferredRenderState is set. + xbaddr g_DeferredRenderState = pContext->xref_database[XREF_D3D_g_DeferredRenderState]; + if (internal_IsXRefAddrUnset(g_DeferredRenderState)) { + output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, "D3D_g_DeferredRenderState is not set!"); + return; + } + + // Now we want to inspect each entries to be sure they are properly offset from DxbxRenderStateInfo list inspection. + // If an offset is inaccurate, we want to know ASAP! + unsigned RenderState_iLib = 0; + char buffer_str[512]; + for (size_t i = 0; i < DxbxRenderStateInfoSize; i++) { + if (IsRenderStateAvailableInCurrentXboxD3D8Lib(DxbxRenderStateInfo[i], pLibrary->build_version)) { + if (DxbxRenderStateInfo[i].xref) { + xbaddr RenderState_iAddr = pContext->xref_database[DxbxRenderStateInfo[i].xref]; + if (internal_IsXRefAddrUnset(RenderState_iAddr)) { + if (RenderState_iAddr != XREF_ADDR_DERIVE) { + sprintf(buffer_str, "XbSymbolDatabase's %s symbol is not set!", DxbxRenderStateInfo[i].name); + output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, buffer_str); + } + else { + sprintf(buffer_str, "XbSymbolDatabase's %s symbol is currently set to derive.", DxbxRenderStateInfo[i].name); + output_message(&pContext->output, XB_OUTPUT_MESSAGE_DEBUG, buffer_str); + } + } + else if (RenderState_iLib * sizeof(xbaddr) != RenderState_iAddr - g_RenderState) { + sprintf(buffer_str, "DxbxRenderStateInfo list's entry base on %s is inaccurate!", DxbxRenderStateInfo[i].name); + output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, buffer_str); + } + } + RenderState_iLib++; + } + } + + output_message(&pContext->output, XB_OUTPUT_MESSAGE_DEBUG, "Verify RenderState offsets is complete."); +} + + static void manual_scan_section_dx8_register_xrefs(iXbSymbolContext* pContext, const iXbSymbolLibrarySession* pLibrarySession, memptr_t pFunc, @@ -855,6 +923,10 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, bComplete = manual_scan_section_dx8_register_D3DRS_list(pContext, pLibrarySession, pLibraryDB, pSection); + if (bComplete) { + manual_scan_section_dx8_VerifyRenderStateOffsets(pContext, pLibrarySession); + } + return bComplete; } From 5ee5991be88864af0813b5e70f89252ae256b0bd Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 20 Dec 2022 06:10:46 -0600 Subject: [PATCH 08/35] d3d: found two D3DRS variables aren't used with any signature, disabled for now. --- include/xref/d3d8.def | 4 ++-- src/lib/manual_d3d8__ltcg.h | 4 ++-- src/test/libverify/D3D8.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/xref/d3d8.def b/include/xref/d3d8.def index 1406a6a7..367dd0b1 100644 --- a/include/xref/d3d8.def +++ b/include/xref/d3d8.def @@ -32,7 +32,7 @@ XREF_SYMBOL(D3DRS_BackFillMode) XREF_SYMBOL(D3DRS_CullMode) XREF_SYMBOL(D3DRS_Dxt1NoiseEnable) XREF_SYMBOL(D3DRS_FillMode) -XREF_SYMBOL(D3DRS_LineWidth) +//XREF_SYMBOL(D3DRS_LineWidth) // Not been used XREF_SYMBOL(D3DRS_LogicOp) XREF_SYMBOL(D3DRS_MultiSampleAntiAlias) XREF_SYMBOL(D3DRS_MultiSampleMask) @@ -44,7 +44,7 @@ XREF_SYMBOL(D3DRS_RopZRead) XREF_SYMBOL(D3DRS_DoNotCullUncompressed) XREF_SYMBOL(D3DRS_SampleAlpha) XREF_SYMBOL(D3DRS_StencilCullEnable) -XREF_SYMBOL(D3DRS_StencilEnable) +//XREF_SYMBOL(D3DRS_StencilEnable) // Not been used XREF_SYMBOL(D3DRS_TwoSidedLighting) XREF_SYMBOL(D3DRS_YuvEnable) XREF_SYMBOL(D3DRS_ZBias) diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index dc78b80a..ac37aa48 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -201,7 +201,7 @@ static const RenderStateRevision DxbxRenderStateInfo[] = { /* 141 */ { 3424, 0000, XREF_NAME(D3DRS_TwoSidedLighting) }, // nsp. // FIXME map from NV2A_LIGHT_MODEL /* 142 */ { 3424, 0000 /*, XREF_NAME(D3DRS_NormalizeNormals) */ }, // /* 143 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ZEnable) */ }, // D3DZBUFFERTYPE? - /* 144 */ { 3424, 0000, XREF_NAME(D3DRS_StencilEnable) }, // + /* 144 */ { 3424, 0000 /*, XREF_NAME(D3DRS_StencilEnable) */ }, // /* 145 */ { 3424, 0000 /*, XREF_NAME(D3DRS_StencilFail) */ }, // /* 146 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FrontFace) */ }, // nsp. /* 147 */ { 3424, 0000, XREF_NAME(D3DRS_CullMode) }, // @@ -215,7 +215,7 @@ static const RenderStateRevision DxbxRenderStateInfo[] = { /* 155 */ { 4034, 0000 /*, XREF_NAME(D3DRS_MultiSampleMode) */ }, // D3DMULTISAMPLEMODE for the backbuffer. Verified absent in 3944, present in 4034. 4034 state based on test-case : The Simpsons Road Rage /* 156 */ { 4034, 0000, XREF_NAME(D3DRS_MultiSampleRenderTargetMode) }, // Verified absent in 3944, present in 4034. Presence in 4034 is based on test-case : The Simpsons Road Rage /* 157 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ShadowFunc) */ }, // - /* 158 */ { 3424, 0000, XREF_NAME(D3DRS_LineWidth) }, // + /* 158 */ { 3424, 0000 /*, XREF_NAME(D3DRS_LineWidth) */ }, // /* 159 */ { 4627, 0000, XREF_NAME(D3DRS_SampleAlpha) }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? /* 160 */ { 3424, 0000, XREF_NAME(D3DRS_Dxt1NoiseEnable) }, // /* 161 */ { 3911, 0000, XREF_NAME(D3DRS_YuvEnable) }, // Verified present in 3944 diff --git a/src/test/libverify/D3D8.cpp b/src/test/libverify/D3D8.cpp index fb42f353..cdd0f661 100644 --- a/src/test/libverify/D3D8.cpp +++ b/src/test/libverify/D3D8.cpp @@ -438,7 +438,7 @@ void getLibraryD3D8(library_db& lib_db) // TODO: database is incomplete + 2 internal reference need to be exclude. // Excluding: // - 2 internal manual scan reference - // - 4 variables + // - 2 variables // - 5 internal offsets - lib_db.xref_exclude = 11; + lib_db.xref_exclude = 9; } From e0659cc9ac5314f212f14c2ec52a960bbee1228f Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 20 Dec 2022 07:42:05 -0600 Subject: [PATCH 09/35] d3d: use cmp opcode's value to obtain offset where deferred render state start at. --- src/lib/manual_d3d8__ltcg.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index ac37aa48..2c88d5f5 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -348,7 +348,9 @@ static void manual_scan_section_dx8_register_xrefs(iXbSymbolContext* pContext, internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_CullMode, DerivedAddr_D3DRS_CullMode); // Derive address of EmuD3DDeferredRenderState from D3DRS_CullMode - xbaddr EmuD3DDeferredRenderState = DerivedAddr_D3DRS_CullMode - Decrement + Increment; + // NOTE: No longer requirement anymore! Woohoo! + // xbaddr EmuD3DDeferredRenderState = DerivedAddr_D3DRS_CullMode - Decrement + Increment; + xbaddr EmuD3DDeferredRenderState = pContext->xref_database[XREF_D3D_g_DeferredRenderState]; patchOffset -= Increment; // Derive address of a few other deferred render state slots (to help xref-based function location) @@ -437,6 +439,8 @@ static bool manual_scan_section_dx8_register_D3DRS(iXbSymbolContext* pContext, internal_RegisterSymbol(pContext, pLibrarySession, pSymbol, pRevision->Version, xFuncAddr); } + memptr_t pD3D_g_DeferredRenderStateOffset = 0; + // Then look up for D3DDevice_SetRenderStateNotInline xbaddr D3DDevice_SetRenderStateNotInline = pContext->xref_database[XREF_D3DDevice_SetRenderStateNotInline]; xbaddr D3DDevice_SetRenderStateInline = pContext->xref_database[XREF_D3DDevice_SetRenderStateInline__ManualFindGeneric]; @@ -464,6 +468,9 @@ static bool manual_scan_section_dx8_register_D3DRS(iXbSymbolContext* pContext, &pSymbol, &pRevision); + // pointer to cmp opcode's value from D3DDevice_SetRenderStateInline__ManualFindGeneric sig. + pD3D_g_DeferredRenderStateOffset = internal_section_VirtToHostAddress(pContext, xFuncAddr + 0x02); + // If not found, skip the rest of the scan. if (xFuncAddr == 0) { return false; @@ -471,11 +478,24 @@ static bool manual_scan_section_dx8_register_D3DRS(iXbSymbolContext* pContext, // If it is found, don't register it. } else { + // pointer to cmp opcode's value from D3DDevice_SetRenderStateNotInline sig. + pD3D_g_DeferredRenderStateOffset = internal_section_VirtToHostAddress(pContext, xFuncAddr + 0x07); + // Register only D3DDevice_SetRenderStateNotInline symbol function. // D3DDevice_SetRenderStateInline__ManualFindGeneric is not a function but a generic method to find D3D_g_RenderState. internal_RegisterSymbol(pContext, pLibrarySession, pSymbol, pRevision->Version, xFuncAddr); } // D3D_g_RenderState variable is already set internal, will be register later. + + // And set D3D_g_DeferredRenderState variable base on signature cmp opcode's value as offset. + // This is 100% accurate method than manual offset usage. + if (pD3D_g_DeferredRenderStateOffset) { + uint8_t D3D_g_DeferredRenderStateOffset = *(uint8_t*)pD3D_g_DeferredRenderStateOffset; + internal_SetXRefDatabase(pContext, + pLibrarySession->iLibraryType, + XREF_D3D_g_DeferredRenderState, + pContext->xref_database[XREF_D3D_g_RenderState] + D3D_g_DeferredRenderStateOffset * 4); + } } return true; } @@ -621,7 +641,7 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, // Needed for no dependency, scanning multiple sections, and library's databases. bool bComplete = true; - // Get D3D_g_RenderState variable + // Get D3D_g_RenderState and D3D_g_DeferredRenderState variables bComplete &= manual_scan_section_dx8_register_D3DRS(pContext, pLibrarySession, pLibraryDB, pSection); // Check if any results as incomplete scan. From a9c9988e6aac14fac98885d9351a4c9d366f5e80 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Wed, 21 Dec 2022 05:45:18 -0600 Subject: [PATCH 10/35] d3d: add D3D_g_ComplexRenderState support base on D3DDevice_SetRenderState_FillMode --- include/xref/d3d8.def | 3 ++ src/OOVPADatabase/D3D8/3911.inl | 39 +++++++++------- src/OOVPADatabase/D3D8/4034.inl | 40 ++++++++++++----- src/OOVPADatabase/D3D8LTCG/3911.inl | 40 +++++++++++------ src/OOVPADatabase/D3D8LTCG/4039.inl | 40 +++++++++++------ src/OOVPADatabase/D3D8LTCG/4432.inl | 38 +++++++++++----- src/OOVPADatabase/D3D8LTCG/5788.inl | 38 +++++++++++----- src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 2 +- src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- src/lib/libXbSymbolDatabase.c | 3 ++ src/lib/manual_d3d8__ltcg.h | 67 ++++++++++++++++++++++++++-- src/test/libverify/D3D8.cpp | 2 + 12 files changed, 233 insertions(+), 81 deletions(-) diff --git a/include/xref/d3d8.def b/include/xref/d3d8.def index 367dd0b1..2c37a1d4 100644 --- a/include/xref/d3d8.def +++ b/include/xref/d3d8.def @@ -25,6 +25,8 @@ XREF_SYMBOL(D3DDevice__m_VerticalBlankEvent__ManualFindGeneric) // variable addresses XREF_SYMBOL(D3D_g_RenderState) XREF_SYMBOL(D3D_g_DeferredRenderState) +XREF_SYMBOL(D3D_g_ComplexRenderState) + XREF_SYMBOL(D3D_g_DeferredTextureState) XREF_SYMBOL(D3D_g_pDevice) XREF_SYMBOL(D3D_g_Stream) @@ -41,6 +43,7 @@ XREF_SYMBOL(D3DRS_MultiSampleRenderTargetMode) XREF_SYMBOL(D3DRS_OcclusionCullEnable) XREF_SYMBOL(D3DRS_RopZCmpAlwaysRead) XREF_SYMBOL(D3DRS_RopZRead) +XREF_SYMBOL(D3DRS_PSTextureModes) XREF_SYMBOL(D3DRS_DoNotCullUncompressed) XREF_SYMBOL(D3DRS_SampleAlpha) XREF_SYMBOL(D3DRS_StencilCullEnable) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index c22d9f97..b4ef83b7 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -2637,29 +2637,38 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FillMode // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FillMode, - 3911) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FillMode, + 3911, + XRefThree) OOVPA_SIG_MATCH( + // mov ecx,ptr [D3DRS_TwoSidedLighting] + XREF_ENTRY(0x0F, XREF_D3DRS_TwoSidedLighting), + // mov edx,ptr [D3DRS_BackFillMode] + XREF_ENTRY(0x15, XREF_D3DRS_BackFillMode), + // mov ptr [D3DRS_FillMode],ecx + XREF_ENTRY(0x36, XREF_D3DRS_FillMode), + // push esi - { 0x00, 0x56 }, + OV_MATCH(0x00, 0x56), - // mov dword ptr [eax],0x8038C - { 0x23, 0xC7 }, - { 0x24, 0x00 }, - { 0x25, 0x8C }, - { 0x26, 0x03 }, - { 0x27, 0x08 }, - { 0x28, 0x00 }, + // mov ecx,ptr [D3DRS_TwoSidedLighting] + OV_MATCH(0x0D, 0x8B), + + // mov edx,ptr [D3DRS_BackFillMode] + OV_MATCH(0x13, 0x8B), + + // mov ptr [eax],0x008038C + OV_MATCH(0x23, 0xC7, 0x00, 0x8C, 0x03, 0x08, 0x00), // add eax,0x0C - { 0x2F, 0x83 }, - { 0x30, 0xC0 }, - { 0x31, 0x0C }, + OV_MATCH(0x2F, 0x83, 0xC0, 0x0C), + + // mov ptr [D3DRS_FillMode],ecx + OV_MATCH(0x34, 0x89), // retn 0x04 - { 0x3B, 0xC2 }, - { 0x3C, 0x04 }, + OV_MATCH(0x3B, 0xC2, 0x04), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index 2ca97692..6a6fa5e2 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -490,18 +490,38 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FillMode // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FillMode, - 4034) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FillMode, + 4034, + XRefThree) OOVPA_SIG_MATCH( - { 0x00, 0x56 }, - { 0x07, 0x8B }, - { 0x13, 0x8B }, - { 0x19, 0x8B }, - { 0x22, 0x4C }, - { 0x2B, 0x8C }, - { 0x34, 0x08 }, - { 0x40, 0x5E }, + // mov ecx,ptr [D3DRS_TwoSidedLighting] + XREF_ENTRY(0x15, XREF_D3DRS_TwoSidedLighting), + // mov edx,ptr [D3DRS_BackFillMode] + XREF_ENTRY(0x1B, XREF_D3DRS_BackFillMode), + // mov ptr [D3DRS_FillMode],ecx + XREF_ENTRY(0x3C, XREF_D3DRS_FillMode), + + // push esi + OV_MATCH(0x00, 0x56), + + // mov ecx,ptr [D3DRS_TwoSidedLighting] + OV_MATCH(0x13, 0x8B), + + // mov edx,ptr [D3DRS_BackFillMode] + OV_MATCH(0x19, 0x8B), + + // mov ptr [eax],0x008038C + OV_MATCH(0x29, 0xC7, 0x00, 0x8C, 0x03, 0x08, 0x00), + + // add eax,0x0C + OV_MATCH(0x35, 0x83, 0xC0, 0x0C), + + // mov ptr [D3DRS_FillMode],ecx + OV_MATCH(0x3A, 0x89), + + // retn 0x04 + OV_MATCH(0x41, 0xC2, 0x04), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index 74379125..d8831f9c 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -385,21 +385,35 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FillMode // ****************************************************************** -//C98B4C24087502 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FillMode, - 1024) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FillMode, + 1024, + XRefThree) OOVPA_SIG_MATCH( - { 0x00, 0x56 }, - { 0x08, 0x06 }, - - { 0x22, 0xC9 }, - { 0x23, 0x8B }, - { 0x24, 0x4C }, - { 0x25, 0x24 }, - { 0x26, 0x08 }, - { 0x27, 0x75 }, - { 0x28, 0x02 }, + XREF_ENTRY(0x17, XREF_D3DRS_TwoSidedLighting), + XREF_ENTRY(0x1D, XREF_D3DRS_BackFillMode), + XREF_ENTRY(0x3E, XREF_D3DRS_FillMode), + + // push esi + OV_MATCH(0x00, 0x56), + + // mov ecx,ptr [D3DRS_TwoSidedLighting] + OV_MATCH(0x15, 0x8B), + + // mov edx,ptr [D3DRS_BackFillMode] + OV_MATCH(0x1B, 0x8B), + + // mov ptr [eax],0x008038C + OV_MATCH(0x2B, 0xC7, 0x00, 0x8C, 0x03, 0x08, 0x00), + + // add eax,0x0C + OV_MATCH(0x37, 0x83, 0xC0, 0x0C), + + // mov ptr [D3DRS_FillMode],ecx + OV_MATCH(0x3C, 0x89), + + // retn 0x04 + OV_MATCH(0x43, 0xC2, 0x04), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4039.inl b/src/OOVPADatabase/D3D8LTCG/4039.inl index bea89dd7..1f0ebcf2 100644 --- a/src/OOVPADatabase/D3D8LTCG/4039.inl +++ b/src/OOVPADatabase/D3D8LTCG/4039.inl @@ -230,21 +230,35 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FillMode // ****************************************************************** -//C98B4C24087502 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FillMode, - 1036) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FillMode, + 1036, + XRefThree) OOVPA_SIG_MATCH( - { 0x00, 0x56 }, - { 0x08, 0x06 }, - - { 0x26, 0xC9 }, - { 0x27, 0x8B }, - { 0x28, 0x4C }, - { 0x29, 0x24 }, - { 0x2A, 0x08 }, - { 0x2B, 0x75 }, - { 0x2C, 0x02 }, + XREF_ENTRY(0x1B, XREF_D3DRS_TwoSidedLighting), + XREF_ENTRY(0x21, XREF_D3DRS_BackFillMode), + XREF_ENTRY(0x42, XREF_D3DRS_FillMode), + + // push esi + OV_MATCH(0x00, 0x56), + + // mov ecx,ptr [D3DRS_TwoSidedLighting] + OV_MATCH(0x19, 0x8B), + + // mov edx,ptr [D3DRS_BackFillMode] + OV_MATCH(0x1F, 0x8B), + + // mov ptr [eax],0x008038C + OV_MATCH(0x2F, 0xC7, 0x00, 0x8C, 0x03, 0x08, 0x00), + + // add eax,0x0C + OV_MATCH(0x3B, 0x83, 0xC0, 0x0C), + + // mov ptr [D3DRS_FillMode],ecx + OV_MATCH(0x40, 0x89), + + // retn 0x04 + OV_MATCH(0x47, 0xC2, 0x04), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4432.inl b/src/OOVPADatabase/D3D8LTCG/4432.inl index 50cb7025..df869130 100644 --- a/src/OOVPADatabase/D3D8LTCG/4432.inl +++ b/src/OOVPADatabase/D3D8LTCG/4432.inl @@ -206,21 +206,35 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FillMode // ****************************************************************** -//C98B4C24087502 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FillMode, - 1048) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FillMode, + 1048, + XRefThree) OOVPA_SIG_MATCH( - { 0x00, 0x56 }, - { 0x08, 0x06 }, + XREF_ENTRY(0x1E, XREF_D3DRS_TwoSidedLighting), + XREF_ENTRY(0x24, XREF_D3DRS_BackFillMode), + XREF_ENTRY(0x45, XREF_D3DRS_FillMode), - { 0x29, 0xC9 }, - { 0x2A, 0x8B }, - { 0x2B, 0x4C }, - { 0x2C, 0x24 }, - { 0x2D, 0x08 }, - { 0x2E, 0x75 }, - { 0x2F, 0x02 }, + // push esi + OV_MATCH(0x00, 0x56), + + // mov ecx,ptr [D3DRS_TwoSidedLighting] + OV_MATCH(0x1C, 0x8B), + + // mov edx,ptr [D3DRS_BackFillMode] + OV_MATCH(0x22, 0x8B), + + // mov ptr [eax],0x008038C + OV_MATCH(0x32, 0xC7, 0x00, 0x8C, 0x03, 0x08, 0x00), + + // add eax,0x0C + OV_MATCH(0x3E, 0x83, 0xC0, 0x0C), + + // mov ptr [D3DRS_FillMode],ecx + OV_MATCH(0x43, 0x89), + + // retn 0x04 + OV_MATCH(0x4A, 0xC2, 0x04), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/5788.inl b/src/OOVPADatabase/D3D8LTCG/5788.inl index 9d03e391..0f2566b6 100644 --- a/src/OOVPADatabase/D3D8LTCG/5788.inl +++ b/src/OOVPADatabase/D3D8LTCG/5788.inl @@ -217,21 +217,35 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FillMode // ****************************************************************** -//C98B4C24087502 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FillMode, - 1060) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FillMode, + 1060, + XRefThree) OOVPA_SIG_MATCH( - { 0x00, 0x56 }, - { 0x08, 0x06 }, + XREF_ENTRY(0x1F, XREF_D3DRS_TwoSidedLighting), + XREF_ENTRY(0x25, XREF_D3DRS_BackFillMode), + XREF_ENTRY(0x46, XREF_D3DRS_FillMode), - { 0x2A, 0xC9 }, - { 0x2B, 0x8B }, - { 0x2C, 0x4C }, - { 0x2D, 0x24 }, - { 0x2E, 0x08 }, - { 0x2F, 0x75 }, - { 0x30, 0x02 }, + // push esi + OV_MATCH(0x00, 0x56), + + // mov ecx,ptr [D3DRS_TwoSidedLighting] + OV_MATCH(0x1D, 0x8B), + + // mov edx,ptr [D3DRS_BackFillMode] + OV_MATCH(0x23, 0x8B), + + // mov ptr [eax],0x008038C + OV_MATCH(0x33, 0xC7, 0x00, 0x8C, 0x03, 0x08, 0x00), + + // add eax,0x0C + OV_MATCH(0x3F, 0x83, 0xC0, 0x0C), + + // mov ptr [D3DRS_FillMode],ecx + OV_MATCH(0x44, 0x89), + + // retn 0x04 + OV_MATCH(0x4B, 0xC2, 0x04), // ); diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index fd57abd8..c441fa52 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -150,7 +150,7 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_BackFillMode, 1024, 1036), REGISTER_OOVPAS_C(D3DDevice_SetRenderState_CullMode, 1045, 1049, 1052, 1053), REGISTER_OOVPAS(D3DDevice_SetRenderState_EdgeAntiAlias, 1024, 1036, 1048, 1060), - REGISTER_OOVPAS(D3DDevice_SetRenderState_FillMode, 1024, 1036, 1048, 1060), + REGISTER_OOVPAS_M(D3DDevice_SetRenderState_FillMode, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_FogColor, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_FrontFace, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_LineWidth, 1024), diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index ecd83cd4..47f12e62 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -324,7 +324,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_DoNotCullUncompressed, 3911), REGISTER_OOVPAS(D3DDevice_SetRenderState_Dxt1NoiseEnable, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_EdgeAntiAlias, 3911, 4034), - REGISTER_OOVPAS(D3DDevice_SetRenderState_FillMode, 3911, 4034), + REGISTER_OOVPAS_M(D3DDevice_SetRenderState_FillMode, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_FogColor, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_FrontFace, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_LineWidth, 3911, 4034), diff --git a/src/lib/libXbSymbolDatabase.c b/src/lib/libXbSymbolDatabase.c index 68690ed0..a84dca83 100644 --- a/src/lib/libXbSymbolDatabase.c +++ b/src/lib/libXbSymbolDatabase.c @@ -827,12 +827,15 @@ bool XbSymbolDatabase_CreateXbSymbolContext(XbSymbolContextHandle* ppHandle, // D3D pContext->xref_database[XREF_D3D_g_pDevice] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3D_g_RenderState] = XREF_ADDR_DERIVE; //In use + pContext->xref_database[XREF_D3DRS_BackFillMode] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_CullMode] = XREF_ADDR_DERIVE; //In use + pContext->xref_database[XREF_D3DRS_FillMode] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_MultiSampleRenderTargetMode] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_RopZCmpAlwaysRead] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_RopZRead] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_DoNotCullUncompressed] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_StencilCullEnable] = XREF_ADDR_DERIVE; //In use + pContext->xref_database[XREF_D3DRS_TwoSidedLighting] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DTSS_TEXCOORDINDEX] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3D_g_Stream] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_OFFSET_D3DDevice__m_PixelShader] = XREF_ADDR_DERIVE; // diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index 2c88d5f5..bb6ea05b 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -193,7 +193,7 @@ static const RenderStateRevision DxbxRenderStateInfo[] = { /* 134 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Deferred_Unused2) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? /* 135 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Deferred_Unused1) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? /* End of "deferred" render states, continuing with "complex" render states: */ // - /* 136 */ { 3424, 0000 /*, XREF_NAME(D3DRS_PSTextureModes) */ }, // This is where pPSDef->PSTextureModes is stored (outside the pPSDEF - see DxbxUpdateActivePixelShader) + /* 136 */ { 3424, 0000, XREF_NAME(D3DRS_PSTextureModes) }, // This is where pPSDef->PSTextureModes is stored (outside the pPSDEF - see DxbxUpdateActivePixelShader) /* 137 */ { 3424, 0000 /*, XREF_NAME(D3DRS_VertexBlend) */ }, // /* 138 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FogColor) */ }, // SwapRgb /* 139 */ { 3424, 0000, XREF_NAME(D3DRS_FillMode) }, // @@ -278,6 +278,22 @@ static void manual_scan_section_dx8_VerifyRenderStateOffsets(iXbSymbolContext* p return; } + // Verify D3D_g_ComplexRenderState is set. + xbaddr g_ComplexRenderState = pContext->xref_database[XREF_D3D_g_ComplexRenderState]; + if (internal_IsXRefAddrUnset(g_ComplexRenderState)) { + output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, "D3D_g_ComplexRenderState is not set!"); + return; + } + // Verify complex offset is correct + int RenderStateOffset = GetRenderStateOffsetByXRef(XREF_D3DRS_PSTextureModes, pLibrary->build_version); + if (RenderStateOffset == -1) { + output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, "Could not find D3DRS_PSTextureModes offset from DxbxRenderStateInfo list!"); + return; + } + if (RenderStateOffset * sizeof(xbaddr) != g_ComplexRenderState - g_RenderState) { + output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, "DxbxRenderStateInfo list's entry base on g_ComplexRenderState is inaccurate!"); + } + // Now we want to inspect each entries to be sure they are properly offset from DxbxRenderStateInfo list inspection. // If an offset is inaccurate, we want to know ASAP! unsigned RenderState_iLib = 0; @@ -357,9 +373,9 @@ static void manual_scan_section_dx8_register_xrefs(iXbSymbolContext* pContext, // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_PSTextureModes, DerivedAddr_D3DRS_CullMode - 11*4); // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_VertexBlend, DerivedAddr_D3DRS_CullMode - 10*4); // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_FogColor, DerivedAddr_D3DRS_CullMode - 9*4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_FillMode, DerivedAddr_D3DRS_CullMode - 8 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_BackFillMode, DerivedAddr_D3DRS_CullMode - 7 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_TwoSidedLighting, DerivedAddr_D3DRS_CullMode - 6 * 4); + //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_FillMode, DerivedAddr_D3DRS_CullMode - 8 * 4); // is done in manual_scan_section_dx8_register_D3DCRS. + //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_BackFillMode, DerivedAddr_D3DRS_CullMode - 7 * 4); // is done in manual_scan_section_dx8_register_D3DCRS. + //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_TwoSidedLighting, DerivedAddr_D3DRS_CullMode - 6 * 4); // is done in manual_scan_section_dx8_register_D3DCRS. // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_NormalizeNormals, DerivedAddr_D3DRS_CullMode - 5*4); // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_ZEnable, DerivedAddr_D3DRS_CullMode - 4*4); // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_StencilEnable, DerivedAddr_D3DRS_CullMode - 3*4); @@ -407,6 +423,7 @@ static bool manual_scan_section_dx8_register_D3DRS_list(iXbSymbolContext* pConte // Manual register RenderState sections. internal_RegisterValidXRefAddr(pContext, Lib_D3D8, XbSymbolLib_D3D8, XREF_D3D_g_RenderState, 0, "D3D_g_RenderState"); + internal_RegisterValidXRefAddr(pContext, Lib_D3D8, XbSymbolLib_D3D8, XREF_D3D_g_ComplexRenderState, 0, "D3D_g_ComplexRenderState"); internal_RegisterValidXRefAddr(pContext, Lib_D3D8, XbSymbolLib_D3D8, XREF_D3D_g_DeferredRenderState, 0, "D3D_g_DeferredRenderState"); return true; @@ -500,6 +517,45 @@ static bool manual_scan_section_dx8_register_D3DRS(iXbSymbolContext* pContext, return true; } +// No dependency requirement +static bool manual_scan_section_dx8_register_D3DCRS(iXbSymbolContext* pContext, + const iXbSymbolLibrarySession* pLibrarySession, + SymbolDatabaseList* pLibraryDB, + const XbSDBSection* pSection) +{ + OOVPATable* pSymbol = NULL; + OOVPARevision* pRevision = NULL; + // First, we need to find D3DDevice_SetRenderState_Simple symbol. + xbaddr D3DRS_FillMode = pContext->xref_database[XREF_D3DRS_FillMode]; + if (internal_IsXRefAddrUnset(D3DRS_FillMode)) { + xbaddr xFuncAddr = (xbaddr)(uintptr_t)internal_LocateSymbolFunction(pContext, + pLibrarySession, + pLibraryDB, + "D3DDevice_SetRenderState_FillMode", + pSection, + false, + &pSymbol, + &pRevision); + // If not found, skip the rest of the scan. + if (xFuncAddr == 0) { + return false; + } + + internal_RegisterSymbol(pContext, pLibrarySession, pSymbol, pRevision->Version, xFuncAddr); + } + + // Derived D3DRS_FillMode, D3DRS_BackFillMode, and D3DRS_TwoSidedLighting variables are already set. + + // Set D3D_g_ComplexRenderState variable + // Had been reverse engineered and verified across compiled XDK builds from retail titles. + pContext->xref_database[XREF_D3D_g_ComplexRenderState] = pContext->xref_database[XREF_D3DRS_FillMode] - 3 /*index*/ * sizeof(xbaddr); + + // Set D3DRS_PSTextureModes variable which reside in same address as D3D_g_ComplexRenderState is at. + pContext->xref_database[XREF_D3DRS_PSTextureModes] = pContext->xref_database[XREF_D3D_g_ComplexRenderState]; + + return true; +} + static void manual_scan_section_dx8_register_D3DTSS(iXbSymbolContext* pContext, const iXbSymbolLibrarySession* pLibrarySession, memptr_t pFunc, @@ -644,6 +700,9 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, // Get D3D_g_RenderState and D3D_g_DeferredRenderState variables bComplete &= manual_scan_section_dx8_register_D3DRS(pContext, pLibrarySession, pLibraryDB, pSection); + // Get D3D_g_ComplexRenderState, D3DRS_FillMode, and D3DRS_PSTextureModes variables + bComplete &= manual_scan_section_dx8_register_D3DCRS(pContext, pLibrarySession, pLibraryDB, pSection); + // Check if any results as incomplete scan. if (!bComplete) { return bComplete; diff --git a/src/test/libverify/D3D8.cpp b/src/test/libverify/D3D8.cpp index cdd0f661..089a98d1 100644 --- a/src/test/libverify/D3D8.cpp +++ b/src/test/libverify/D3D8.cpp @@ -5,6 +5,7 @@ static const library_list database_full = { // derived xrefs (variables) REGISTER_SYMBOL_INLINE(D3D_g_RenderState, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3D_g_ComplexRenderState, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_g_DeferredRenderState, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_g_DeferredTextureState, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_g_pDevice, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), @@ -19,6 +20,7 @@ static const library_list database_full = { REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleMask, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleRenderTargetMode, VER_RANGE(4034, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_OcclusionCullEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_PSTextureModes, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_RopZCmpAlwaysRead, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_RopZRead, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_SampleAlpha, VER_RANGE(4627, VER_MAX, VER_NONE, VER_NONE)), From 083ae9d17d40627801bb8b4d6ac00b80e5b25a2b Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 20 Dec 2022 07:53:15 -0600 Subject: [PATCH 11/35] d3d: relocate derived setters to secure location and add D3DRS_FogEnable symbol --- include/xref/d3d8.def | 1 + src/lib/libXbSymbolDatabase.c | 3 --- src/lib/manual_d3d8__ltcg.h | 51 ++++++++++++++++++++++++++--------- src/test/libverify/D3D8.cpp | 1 + 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/include/xref/d3d8.def b/include/xref/d3d8.def index 2c37a1d4..f01888c5 100644 --- a/include/xref/d3d8.def +++ b/include/xref/d3d8.def @@ -34,6 +34,7 @@ XREF_SYMBOL(D3DRS_BackFillMode) XREF_SYMBOL(D3DRS_CullMode) XREF_SYMBOL(D3DRS_Dxt1NoiseEnable) XREF_SYMBOL(D3DRS_FillMode) +XREF_SYMBOL(D3DRS_FogEnable) //XREF_SYMBOL(D3DRS_LineWidth) // Not been used XREF_SYMBOL(D3DRS_LogicOp) XREF_SYMBOL(D3DRS_MultiSampleAntiAlias) diff --git a/src/lib/libXbSymbolDatabase.c b/src/lib/libXbSymbolDatabase.c index a84dca83..38de7e5a 100644 --- a/src/lib/libXbSymbolDatabase.c +++ b/src/lib/libXbSymbolDatabase.c @@ -826,10 +826,7 @@ bool XbSymbolDatabase_CreateXbSymbolContext(XbSymbolContextHandle* ppHandle, // Request a few fundamental XRefs to be derived instead of checked // D3D pContext->xref_database[XREF_D3D_g_pDevice] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3D_g_RenderState] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_BackFillMode] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_CullMode] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_FillMode] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_MultiSampleRenderTargetMode] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_RopZCmpAlwaysRead] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_RopZRead] = XREF_ADDR_DERIVE; //In use diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index bb6ea05b..6ef19154 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -147,7 +147,7 @@ static const RenderStateRevision DxbxRenderStateInfo[] = { /* 91 */ { 4627, 0000 /*, XREF_NAME(D3DRS_Simple_Unused1) */ }, // Verified absent in 4531, present in 4627 TODO: might be introduced in between? /* End of "simple" render states, continuing with "deferred" render states: */ // /* Verified as XDK 3911 Deferred RenderStates(3424 yet to do) */ // - /* 92 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FogEnable) */ }, // TRUE to enable fog blending + /* 92 */ { 3424, 0000, XREF_NAME(D3DRS_FogEnable) }, // TRUE to enable fog blending /* 93 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FogTableMode) */ }, // D3DFOGMODE /* 94 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FogStart) */ }, // float fog start (for both vertex and pixel fog) /* 95 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FogEnd) */ }, // float fog end @@ -277,6 +277,15 @@ static void manual_scan_section_dx8_VerifyRenderStateOffsets(iXbSymbolContext* p output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, "D3D_g_DeferredRenderState is not set!"); return; } + // Verify deferred offset is correct + int RenderStateOffset = GetRenderStateOffsetByXRef(XREF_D3DRS_FogEnable, pLibrary->build_version); + if (RenderStateOffset == -1) { + output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, "Could not find D3DRS_FogEnable offset from DxbxRenderStateInfo list!"); + return; + } + if (RenderStateOffset * sizeof(xbaddr) != g_DeferredRenderState - g_RenderState) { + output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, "DxbxRenderStateInfo list's entry base on g_DeferredRenderState is inaccurate!"); + } // Verify D3D_g_ComplexRenderState is set. xbaddr g_ComplexRenderState = pContext->xref_database[XREF_D3D_g_ComplexRenderState]; @@ -285,7 +294,7 @@ static void manual_scan_section_dx8_VerifyRenderStateOffsets(iXbSymbolContext* p return; } // Verify complex offset is correct - int RenderStateOffset = GetRenderStateOffsetByXRef(XREF_D3DRS_PSTextureModes, pLibrary->build_version); + RenderStateOffset = GetRenderStateOffsetByXRef(XREF_D3DRS_PSTextureModes, pLibrary->build_version); if (RenderStateOffset == -1) { output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, "Could not find D3DRS_PSTextureModes offset from DxbxRenderStateInfo list!"); return; @@ -458,10 +467,11 @@ static bool manual_scan_section_dx8_register_D3DRS(iXbSymbolContext* pContext, memptr_t pD3D_g_DeferredRenderStateOffset = 0; - // Then look up for D3DDevice_SetRenderStateNotInline - xbaddr D3DDevice_SetRenderStateNotInline = pContext->xref_database[XREF_D3DDevice_SetRenderStateNotInline]; - xbaddr D3DDevice_SetRenderStateInline = pContext->xref_database[XREF_D3DDevice_SetRenderStateInline__ManualFindGeneric]; - if (internal_IsXRefAddrUnset(D3DDevice_SetRenderStateNotInline) && internal_IsXRefAddrUnset(D3DDevice_SetRenderStateInline)) { + // Then look up for D3D_g_RenderState + xbaddr D3D_g_RenderState = pContext->xref_database[XREF_D3D_g_RenderState]; + if (internal_IsXRefAddrUnset(D3D_g_RenderState)) { + // Below xref is used to obtain from D3DDevice_SetRenderState(Not)Inline signatures. + pContext->xref_database[XREF_D3D_g_RenderState] = XREF_ADDR_DERIVE; xbaddr xFuncAddr = (xbaddr)(uintptr_t)internal_LocateSymbolFunction(pContext, pLibrarySession, pLibraryDB, @@ -473,9 +483,10 @@ static bool manual_scan_section_dx8_register_D3DRS(iXbSymbolContext* pContext, if (xFuncAddr == 0) { // If not found, then check if library is not LTCG. if (pLibrarySession->pLibrary->flag == XbSymbolLib_D3D8) { + pContext->xref_database[XREF_D3D_g_RenderState] = XREF_ADDR_UNDETERMINED; return false; } - // Otherwise, let's look up for D3DDevice_SetRenderStateInline which is NOT a function. + // Otherwise, let's look up for D3DDevice_SetRenderStateInline__ManualFindGeneric which is NOT a symbol. xFuncAddr = (xbaddr)(uintptr_t)internal_LocateSymbolFunction(pContext, pLibrarySession, pLibraryDB, @@ -485,13 +496,14 @@ static bool manual_scan_section_dx8_register_D3DRS(iXbSymbolContext* pContext, &pSymbol, &pRevision); - // pointer to cmp opcode's value from D3DDevice_SetRenderStateInline__ManualFindGeneric sig. - pD3D_g_DeferredRenderStateOffset = internal_section_VirtToHostAddress(pContext, xFuncAddr + 0x02); - // If not found, skip the rest of the scan. if (xFuncAddr == 0) { + pContext->xref_database[XREF_D3D_g_RenderState] = XREF_ADDR_UNDETERMINED; return false; } + // pointer to cmp opcode's value from D3DDevice_SetRenderStateInline__ManualFindGeneric sig. + pD3D_g_DeferredRenderStateOffset = internal_section_VirtToHostAddress(pContext, xFuncAddr + 0x02); + // If it is found, don't register it. } else { @@ -499,12 +511,13 @@ static bool manual_scan_section_dx8_register_D3DRS(iXbSymbolContext* pContext, pD3D_g_DeferredRenderStateOffset = internal_section_VirtToHostAddress(pContext, xFuncAddr + 0x07); // Register only D3DDevice_SetRenderStateNotInline symbol function. - // D3DDevice_SetRenderStateInline__ManualFindGeneric is not a function but a generic method to find D3D_g_RenderState. + // NOTE: D3DDevice_SetRenderStateInline__ManualFindGeneric is NOT a symbol but a generic method to find D3D_g_RenderState. internal_RegisterSymbol(pContext, pLibrarySession, pSymbol, pRevision->Version, xFuncAddr); } // D3D_g_RenderState variable is already set internal, will be register later. - // And set D3D_g_DeferredRenderState variable base on signature cmp opcode's value as offset. + + // And set D3D_g_DeferredRenderState, including D3DRS_FogEnable, variables base on signature cmp opcode's value as offset. // This is 100% accurate method than manual offset usage. if (pD3D_g_DeferredRenderStateOffset) { uint8_t D3D_g_DeferredRenderStateOffset = *(uint8_t*)pD3D_g_DeferredRenderStateOffset; @@ -512,6 +525,11 @@ static bool manual_scan_section_dx8_register_D3DRS(iXbSymbolContext* pContext, pLibrarySession->iLibraryType, XREF_D3D_g_DeferredRenderState, pContext->xref_database[XREF_D3D_g_RenderState] + D3D_g_DeferredRenderStateOffset * 4); + + internal_SetXRefDatabase(pContext, + pLibrarySession->iLibraryType, + XREF_D3DRS_FogEnable, + pContext->xref_database[XREF_D3D_g_DeferredRenderState]); } } return true; @@ -525,9 +543,13 @@ static bool manual_scan_section_dx8_register_D3DCRS(iXbSymbolContext* pContext, { OOVPATable* pSymbol = NULL; OOVPARevision* pRevision = NULL; - // First, we need to find D3DDevice_SetRenderState_Simple symbol. + // First, we need to find D3DRS_FillMode symbol. xbaddr D3DRS_FillMode = pContext->xref_database[XREF_D3DRS_FillMode]; if (internal_IsXRefAddrUnset(D3DRS_FillMode)) { + // These xrefs are used to obtain from D3DDevice_SetRenderState_FillMode signature. + pContext->xref_database[XREF_D3DRS_FillMode] = XREF_ADDR_DERIVE; + pContext->xref_database[XREF_D3DRS_BackFillMode] = XREF_ADDR_DERIVE; + pContext->xref_database[XREF_D3DRS_TwoSidedLighting] = XREF_ADDR_DERIVE; xbaddr xFuncAddr = (xbaddr)(uintptr_t)internal_LocateSymbolFunction(pContext, pLibrarySession, pLibraryDB, @@ -538,6 +560,9 @@ static bool manual_scan_section_dx8_register_D3DCRS(iXbSymbolContext* pContext, &pRevision); // If not found, skip the rest of the scan. if (xFuncAddr == 0) { + pContext->xref_database[XREF_D3DRS_FillMode] = XREF_ADDR_UNDETERMINED; + pContext->xref_database[XREF_D3DRS_BackFillMode] = XREF_ADDR_UNDETERMINED; + pContext->xref_database[XREF_D3DRS_TwoSidedLighting] = XREF_ADDR_UNDETERMINED; return false; } diff --git a/src/test/libverify/D3D8.cpp b/src/test/libverify/D3D8.cpp index 089a98d1..dc5f472a 100644 --- a/src/test/libverify/D3D8.cpp +++ b/src/test/libverify/D3D8.cpp @@ -15,6 +15,7 @@ static const library_list database_full = { REGISTER_SYMBOL_INLINE(D3DRS_DoNotCullUncompressed, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_Dxt1NoiseEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_FillMode, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_FogEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_LogicOp, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleAntiAlias, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleMask, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), From 159c0941b271f7fff87cec883f4023da5936d961 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Mon, 19 Dec 2022 08:08:06 -0600 Subject: [PATCH 12/35] d3d: update D3DDevice_SetRenderState_BackFillMode signatures --- src/OOVPADatabase/D3D8/3911.inl | 38 ++++++++++---------- src/OOVPADatabase/D3D8/4034.inl | 35 +++++++++---------- src/OOVPADatabase/D3D8LTCG/3911.inl | 54 +++++++++++++++++++++++++---- src/OOVPADatabase/D3D8LTCG/4432.inl | 20 ----------- 4 files changed, 82 insertions(+), 65 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index b4ef83b7..542697cb 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -3585,32 +3585,30 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_BackFillMode // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_BackFillMode, - 3911) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_BackFillMode, + 3911, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_BackFillMode+0x00 : mov eax, [esp+arg_0] - { 0x00, 0x8B }, + // mov esi,ptr [D3DRS_FillMode] + XREF_ENTRY(0x07, XREF_D3DRS_FillMode), + // mov [D3DRS_BackFillMode],eax + XREF_ENTRY(0x14, XREF_D3DRS_BackFillMode), + + // mov eax, [esp+arg_0] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), - // D3DDevice_SetRenderState_BackFillMode+0x2B : jnz +0x2 - { 0x2B, 0x75 }, - { 0x2C, 0x02 }, + // mov esi,ptr [D3DRS_FillMode] + OV_MATCH(0x05, 0x8B), - // D3DDevice_SetRenderState_BackFillMode+0x32 : mov dword ptr [eax], abs - { 0x32, 0xC7 }, - { 0x33, 0x00 }, + // mov [D3DRS_BackFillMode],eax + OV_MATCH(0x13, 0xA3), - // D3DDevice_SetRenderState_BackFillMode+0x3B : add eax, 0x0C; mov [edi], eax; pop edi - { 0x3B, 0x83 }, - { 0x3C, 0xC0 }, - { 0x3D, 0x0C }, - { 0x3E, 0x89 }, - { 0x3F, 0x07 }, - { 0x40, 0x5F }, + // add eax, 0x0C + OV_MATCH(0x3B, 0x83, 0xC0, 0x0C), - // D3DDevice_SetRenderState_BackFillMode+0x48 : retn 0x04 - { 0x48, 0xC2 }, - { 0x49, 0x04 }, + // retn 0x04 + OV_MATCH(0x48, 0xC2, 0x04), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index 6a6fa5e2..38e96310 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -528,30 +528,27 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_BackFillMode // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_BackFillMode, - 4034) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_BackFillMode, + 4034, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_BackFillMode+0x1C : jb +0x05 - { 0x1C, 0x72 }, - { 0x1D, 0x05 }, + // mov [D3DRS_BackFillMode],eax + XREF_ENTRY(0x0C, XREF_D3DRS_BackFillMode), + // mov ecx,ptr [D3DRS_FillMode] + XREF_ENTRY(0x18, XREF_D3DRS_FillMode), - // D3DDevice_SetRenderState_BackFillMode+0x35 : mov dword ptr [eax], abs - { 0x35, 0xC7 }, - { 0x36, 0x00 }, + // mov [D3DRS_BackFillMode],eax + OV_MATCH(0x0B, 0xA3), - // D3DDevice_SetRenderState_BackFillMode+0x41 : add eax, 0x0C; mov [esi], eax; mov [abs], edi - { 0x41, 0x83 }, - { 0x42, 0xC0 }, - { 0x43, 0x0C }, - { 0x44, 0x89 }, - { 0x45, 0x06 }, - { 0x46, 0x89 }, - { 0x47, 0x3D }, + // mov esi,ptr [D3DRS_FillMode] + OV_MATCH(0x16, 0x8B), - // D3DDevice_SetRenderState_BackFillMode+0x4E : retn 0x04 - { 0x4E, 0xC2 }, - { 0x4F, 0x04 }, + // add eax, 0x0C + OV_MATCH(0x41, 0x83, 0xC0, 0x0C), + + // retn 0x04 + OV_MATCH(0x4E, 0xC2, 0x04), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index d8831f9c..c8356703 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -344,22 +344,64 @@ OOVPA_SIG_MATCH( //****************************************************************** //* D3DDevice_SetRenderState_BackFillMode //****************************************************************** +// Found in 4039 title "NBA 2K2" OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_BackFillMode, 1024, - XRefTwo) + XRefThree) OOVPA_SIG_MATCH( + // mov ecx,ptr [D3DRS_FillMode] XREF_ENTRY(0x06, XREF_D3DRS_FillMode), + // mov [D3DRS_BackFillMode],eax XREF_ENTRY(0x0B, XREF_D3DRS_BackFillMode), + // jmp D3DDevice_SetRenderState_FillMode + XREF_ENTRY(0x14, XREF_D3DDevice_SetRenderState_FillMode), - { 0x01, 0x44 }, - { 0x0F, 0x89 }, - { 0x10, 0x4C }, - { 0x11, 0x24 }, - { 0x12, 0x04 }, + // mov eax,ptr [esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + + // mov ecx,ptr [D3DRS_FillMode] + OV_MATCH(0x04, 0x8B, 0x0D), + + // mov [D3DRS_BackFillMode],eax + OV_MATCH(0x0A, 0xA3), + // mov ptr [esp + param_1],ecx + OV_MATCH(0x0F, 0x89, 0x4C, 0x24, 0x04), + // jmp D3DDevice_SetRenderState_FillMode + OV_MATCH(0x13, 0xE9) // ); +//****************************************************************** +//* D3DDevice_SetRenderState_BackFillMode +//****************************************************************** +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_BackFillMode, + 1036, + XRefTwo) +OOVPA_SIG_MATCH( + + // mov [D3DRS_BackFillMode],eax + XREF_ENTRY(0x0C, XREF_D3DRS_BackFillMode), + // mov edi,ptr [D3DRS_FillMode] + XREF_ENTRY(0x18, XREF_D3DRS_FillMode), + + // mov eax,ptr [esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + + // mov [D3DRS_BackFillMode],eax + OV_MATCH(0x0B, 0xA3), + + // mov eax,ptr [esi] + OV_MATCH(0x10, 0x8B, 0x06), + // cmp eax,ptr [esi + 0x4] + OV_MATCH(0x12, 0x3B, 0x46, 0x04), + // push edi + OV_MATCH(0x15, 0x57), + // mov edi,ptr [D3DRS_FillMode] + OV_MATCH(0x16, 0x8B, 0x3D), + // Generic support over multiple revisions end at offset 0x1C +); + // ****************************************************************** // * D3DDevice_SetRenderState_EdgeAntiAlias // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG/4432.inl b/src/OOVPADatabase/D3D8LTCG/4432.inl index df869130..a0b2fccd 100644 --- a/src/OOVPADatabase/D3D8LTCG/4432.inl +++ b/src/OOVPADatabase/D3D8LTCG/4432.inl @@ -467,26 +467,6 @@ OOVPA_SIG_MATCH( // ); -//****************************************************************** -//* D3DDevice_SetRenderState_BackFillMode -//****************************************************************** -//8B063B4604578B -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_BackFillMode, - 1036) -OOVPA_SIG_MATCH( - - { 0x01, 0x44 }, - - { 0x10, 0x8B }, - { 0x11, 0x06 }, - { 0x12, 0x3B }, - { 0x13, 0x46 }, - { 0x14, 0x04 }, - { 0x15, 0x57 }, - { 0x16, 0x8B }, - // -); - // ****************************************************************** // * D3DDevice_CreateTexture // ****************************************************************** From 89e5706a803cf8e5cec2f1219152cf6dddc886ce Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Wed, 21 Dec 2022 05:41:57 -0600 Subject: [PATCH 13/35] d3d: update D3D_CommonSetDebugRegisters signature and derive D3DRS_DoNotCullUncompressed --- include/xref/d3d8.def | 2 +- src/OOVPADatabase/D3D8/3911.inl | 46 ++++++++++++++++++++++---------- src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- src/lib/libXbSymbolDatabase.c | 12 ++++++--- src/lib/manual_d3d8__ltcg.h | 45 ++++++++++++++++++++++++++++--- src/test/libverify/D3D8.cpp | 2 +- 6 files changed, 86 insertions(+), 23 deletions(-) diff --git a/include/xref/d3d8.def b/include/xref/d3d8.def index f01888c5..ac7537f7 100644 --- a/include/xref/d3d8.def +++ b/include/xref/d3d8.def @@ -87,6 +87,7 @@ XREF_SYMBOL(D3D_BlockOnResource) XREF_SYMBOL(D3D_BlockOnTime) XREF_SYMBOL(D3D_CheckDeviceFormat) XREF_SYMBOL(D3D_ClearStateBlockFlags) +XREF_SYMBOL(D3D_CommonSetDebugRegisters) XREF_SYMBOL(D3D_CommonSetRenderTarget) XREF_SYMBOL(D3D_CreateStandAloneSurface) XREF_SYMBOL(D3D_DestroyResource) @@ -99,7 +100,6 @@ XREF_SYMBOL(D3D_KickOffAndWaitForIdle) XREF_SYMBOL(D3D_LazySetPointParams) XREF_SYMBOL(D3D_MakeRequestedSpace) XREF_SYMBOL(D3D_RecordStateBlock) -XREF_SYMBOL(D3D_SetCommonDebugRegisters) XREF_SYMBOL(D3D_SetFence) XREF_SYMBOL(D3D_SetPushBufferSize) XREF_SYMBOL(D3D_SetTileNoWait) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 542697cb..36bf5f7c 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -4991,23 +4991,41 @@ OOVPA_SIG_MATCH( ); // ****************************************************************** -// * D3D::SetCommonDebugRegisters +// * D3D::CommonSetDebugRegisters // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3D_SetCommonDebugRegisters, - 3911) +// Generic OOVPA as of 3911 and newer. +OOVPA_SIG_HEADER_XREF(D3D_CommonSetDebugRegisters, + 3911, + XRefThree) OOVPA_SIG_MATCH( - { 0x07, 0x8B }, - { 0x08, 0x96 }, - { 0x09, 0x44 }, - { 0x0A, 0x2B }, - { 0x31, 0x81 }, - { 0x32, 0xE2 }, - { 0x33, 0xFF }, - { 0x34, 0xFF }, - { 0x35, 0xEF }, - { 0x36, 0xE7 }, - // + // mov ecx, ptr [D3DRS_DoNotCullUncompressed] + XREF_ENTRY(0x18, XREF_D3DRS_DoNotCullUncompressed), // derived + // mov ecx, ptr [D3DRS_RopZCmpAlwaysRead] + XREF_ENTRY(0x3F, XREF_D3DRS_RopZCmpAlwaysRead), // derived + // mov eax, ptr [D3DRS_RopZRead] + XREF_ENTRY(0x55, XREF_D3DRS_RopZRead), // derived + + // push esi + OV_MATCH(0x00, 0x56), + + // and edx, -9 + OV_MATCH(0x0D, 0x83, 0xE2, 0xF7), + + // mov ecx, ptr [D3DRS_DoNotCullUncompressed] + OV_MATCH(0x16, 0x8B), + + // Unique offset + // and edx,0xE7EFFFFF + OV_MATCH(0x31, 0x81, 0xE2, 0xFF, 0xFF, 0xEF, 0xE7), + + // mov ecx, ptr [D3DRS_RopZCmpAlwaysRead] + OV_MATCH(0x3D, 0x8B), + + // mov eax, ptr [D3DRS_RopZRead] + OV_MATCH(0x54, 0xA1), + + // offset from 0x67 and later are different across builds. ); // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index 47f12e62..5645598e 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -411,6 +411,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS_D3D(CMiniport_GetDisplayCapabilities, 3911), REGISTER_OOVPAS(D3D_CheckDeviceFormat, 3911), REGISTER_OOVPAS(D3D_ClearStateBlockFlags, 3911), + REGISTER_OOVPAS_M(D3D_CommonSetDebugRegisters, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3D_CommonSetRenderTarget, 4627, 5028), // Used between 4627 to 5233 (from 5344's comment) REGISTER_OOVPAS(D3D_CreateStandAloneSurface, 4034), REGISTER_OOVPAS(D3D_DestroyResource, 3911), @@ -422,7 +423,6 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3D_KickOffAndWaitForIdle, 3911, 4034, 4627, 5028), REGISTER_OOVPAS(D3D_LazySetPointParams, 3911, 4034), REGISTER_OOVPAS(D3D_RecordStateBlock, 3911), - REGISTER_OOVPAS(D3D_SetCommonDebugRegisters, 3911), REGISTER_OOVPAS(D3D_SetFence, 3911, 4034, 4134, 5028, 5558), REGISTER_OOVPAS(D3D_SetPushBufferSize, 3911), REGISTER_OOVPAS(D3D_SetTileNoWait, 4627, 5455), diff --git a/src/lib/libXbSymbolDatabase.c b/src/lib/libXbSymbolDatabase.c index 38de7e5a..0449a2a2 100644 --- a/src/lib/libXbSymbolDatabase.c +++ b/src/lib/libXbSymbolDatabase.c @@ -975,9 +975,15 @@ void XbSymbolContext_ScanManual(XbSymbolContextHandle pHandle) if ((pLibrary->flag & (XbSymbolLib_D3D8 | XbSymbolLib_D3D8LTCG)) > 0) { // TODO: Do we need to check twice? - // Initialize a matching specific section is currently pair with library in order to scan specific section only. - // By doing this method will reduce false detection dramatically. If it had happened before. - manual_scan_library_custom(pContext, manual_scan_section_dx8, &libSession); + // Perform check twice, since sections can be in different order. + for (unsigned int loop = 0; loop < 2; loop++) { + // Initialize a matching specific section is currently pair with library in order to scan specific section only. + // By doing this method will reduce false detection dramatically. If it had happened before. + if (!manual_scan_library_custom(pContext, manual_scan_section_dx8, &libSession)) { + continue; + } + break; + } } else if ((pLibrary->flag & XbSymbolLib_DSOUND) > 0) { // Perform check twice, since sections can be in different order. diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index 6ef19154..39ee583c 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -410,9 +410,9 @@ static void manual_scan_section_dx8_register_xrefs(iXbSymbolContext* pContext, internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_YuvEnable, EmuD3DDeferredRenderState + patchOffset - 2 * 4); internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_OcclusionCullEnable, EmuD3DDeferredRenderState + patchOffset - 1 * 4); internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_StencilCullEnable, EmuD3DDeferredRenderState + patchOffset + 0 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_RopZCmpAlwaysRead, EmuD3DDeferredRenderState + patchOffset + 1 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_RopZRead, EmuD3DDeferredRenderState + patchOffset + 2 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_DoNotCullUncompressed, EmuD3DDeferredRenderState + patchOffset + 3 * 4); + //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_RopZCmpAlwaysRead, EmuD3DDeferredRenderState + patchOffset + 1 * 4); + //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_RopZRead, EmuD3DDeferredRenderState + patchOffset + 2 * 4); + //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_DoNotCullUncompressed, EmuD3DDeferredRenderState + patchOffset + 3 * 4); } @@ -581,6 +581,42 @@ static bool manual_scan_section_dx8_register_D3DCRS(iXbSymbolContext* pContext, return true; } +// No dependency requirement +static bool manual_scan_section_dx8_register_D3DRS_end_of_list(iXbSymbolContext* pContext, + const iXbSymbolLibrarySession* pLibrarySession, + SymbolDatabaseList* pLibraryDB, + const XbSDBSection* pSection) +{ + OOVPATable* pSymbol = NULL; + OOVPARevision* pRevision = NULL; + // First, we need to find D3DRS_DoNotCullUncompressed symbol. + xbaddr D3DRS_DoNotCullUncompressed = pContext->xref_database[XREF_D3DRS_DoNotCullUncompressed]; + if (internal_IsXRefAddrUnset(D3DRS_DoNotCullUncompressed)) { + // These xrefs are used to obtain from D3D_CommonSetDebugRegisters signature. + pContext->xref_database[XREF_D3DRS_RopZCmpAlwaysRead] = XREF_ADDR_DERIVE; + pContext->xref_database[XREF_D3DRS_RopZRead] = XREF_ADDR_DERIVE; + pContext->xref_database[XREF_D3DRS_DoNotCullUncompressed] = XREF_ADDR_DERIVE; + xbaddr xFuncAddr = (xbaddr)(uintptr_t)internal_LocateSymbolFunction(pContext, + pLibrarySession, + pLibraryDB, + "D3D_CommonSetDebugRegisters", + pSection, + false, + &pSymbol, + &pRevision); + // If not found, skip the rest of the scan. + if (xFuncAddr == 0) { + pContext->xref_database[XREF_D3DRS_RopZCmpAlwaysRead] = XREF_ADDR_UNDETERMINED; + pContext->xref_database[XREF_D3DRS_RopZRead] = XREF_ADDR_UNDETERMINED; + pContext->xref_database[XREF_D3DRS_DoNotCullUncompressed] = XREF_ADDR_UNDETERMINED; + return false; + } + + internal_RegisterSymbol(pContext, pLibrarySession, pSymbol, pRevision->Version, xFuncAddr); + } + return true; +} + static void manual_scan_section_dx8_register_D3DTSS(iXbSymbolContext* pContext, const iXbSymbolLibrarySession* pLibrarySession, memptr_t pFunc, @@ -722,6 +758,9 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, // Needed for no dependency, scanning multiple sections, and library's databases. bool bComplete = true; + // Get end of D3D_g_RenderState list by D3DRS_DoNotCullUncompressed variable + bComplete &= manual_scan_section_dx8_register_D3DRS_end_of_list(pContext, pLibrarySession, pLibraryDB, pSection); + // Get D3D_g_RenderState and D3D_g_DeferredRenderState variables bComplete &= manual_scan_section_dx8_register_D3DRS(pContext, pLibrarySession, pLibraryDB, pSection); diff --git a/src/test/libverify/D3D8.cpp b/src/test/libverify/D3D8.cpp index dc5f472a..3e9368cb 100644 --- a/src/test/libverify/D3D8.cpp +++ b/src/test/libverify/D3D8.cpp @@ -359,6 +359,7 @@ static const library_list database_full = { REGISTER_SYMBOL_INLINE_D3D(CMiniport_GetDisplayCapabilities, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_CheckDeviceFormat, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_ClearStateBlockFlags, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3D_CommonSetDebugRegisters, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_CommonSetRenderTarget, VER_RANGE(4627, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_CreateStandAloneSurface, VER_RANGE(4034, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOLS(D3D_DestroyResource, @@ -372,7 +373,6 @@ static const library_list database_full = { REGISTER_SYMBOL_INLINE(D3D_KickOffAndWaitForIdle, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_LazySetPointParams, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_RecordStateBlock, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), - REGISTER_SYMBOL_INLINE(D3D_SetCommonDebugRegisters, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_SetFence, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_SetPushBufferSize, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3D_SetTileNoWait, VER_RANGE(4627, VER_MAX, VER_NONE, VER_NONE)), From f97c38226e31aba701c4f5a6f59c7b926c0006b5 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Mon, 19 Dec 2022 09:03:46 -0600 Subject: [PATCH 14/35] d3d: update ...DoNotCullUncompressed, ...RopZCmpAlwaysRead, and ...SetRenderState_RopZRead sigs --- src/OOVPADatabase/D3D8/3911.inl | 81 ++++++++++++++------------------ src/OOVPADatabase/D3D8_OOVPA.inl | 6 +-- 2 files changed, 39 insertions(+), 48 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 36bf5f7c..1c1dd058 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -4699,84 +4699,75 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_RopZCmpAlwaysRead // ****************************************************************** -// LTCG: 1024 +// Generic OOVPA as of 3911 and newer. OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_RopZCmpAlwaysRead, 3911, - XRefOne) + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_RopZCmpAlwaysRead+0x05 : [D3DRS_RopZCmpAlwaysRead] - XREF_ENTRY(0x05, XREF_D3DRS_RopZCmpAlwaysRead), // Derived + // [D3DRS_RopZCmpAlwaysRead],eax + XREF_ENTRY(0x05, XREF_D3DRS_RopZCmpAlwaysRead), + // call D3D_CommonSetDebugRegisters + XREF_ENTRY(0x0A, XREF_D3D_CommonSetDebugRegisters), - // D3DDevice_SetRenderState_RopZCmpAlwaysRead+0x00 : mov eax, [esp+0x04] - { 0x00, 0x8B }, - { 0x01, 0x44 }, - { 0x02, 0x24 }, - { 0x03, 0x04 }, + // mov eax, [esp+0x04] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), - // D3DDevice_SetRenderState_RopZCmpAlwaysRead+0x09 : call [abs] - { 0x09, 0xE8 }, + // call D3D_CommonSetDebugRegisters + OV_MATCH(0x09, 0xE8), - // D3DDevice_SetRenderState_RopZCmpAlwaysRead+0x0E : retn 0x04 - { 0x0E, 0xC2 }, - { 0x0F, 0x04 }, - { 0x10, 0x00 }, + // retn 0x04 + OV_MATCH(0x0E, 0xC2, 0x04, 0x00), // ); // ****************************************************************** // * D3DDevice_SetRenderState_RopZRead // ****************************************************************** -// LTCG: 1024 +// Generic OOVPA as of 3911 and newer. OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_RopZRead, 3911, - XRefOne) + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_RopZRead+0x05 : [D3DRS_RopZRead] - XREF_ENTRY(0x05, XREF_D3DRS_RopZRead), // Derived + // mov [D3DRS_RopZRead],eax + XREF_ENTRY(0x05, XREF_D3DRS_RopZRead), + // call D3D_CommonSetDebugRegisters + XREF_ENTRY(0x0A, XREF_D3D_CommonSetDebugRegisters), - // D3DDevice_SetRenderState_RopZRead+0x00 : mov eax, [esp+0x04] - { 0x00, 0x8B }, - { 0x01, 0x44 }, - { 0x02, 0x24 }, - { 0x03, 0x04 }, + // mov eax, [esp+0x04] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), - // D3DDevice_SetRenderState_RopZRead+0x09 : call [abs] - { 0x09, 0xE8 }, + // call D3D_CommonSetDebugRegisters + OV_MATCH(0x09, 0xE8), - // D3DDevice_SetRenderState_RopZRead+0x0E : retn 0x04 - { 0x0E, 0xC2 }, - { 0x0F, 0x04 }, - { 0x10, 0x00 }, + // retn 0x04 + OV_MATCH(0x0E, 0xC2, 0x04, 0x00), // ); // ****************************************************************** // * D3DDevice_SetRenderState_DoNotCullUncompressed // ****************************************************************** -// LTCG: 1024 +// Generic OOVPA as of 3911 and newer. OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_DoNotCullUncompressed, 3911, - XRefOne) + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_DoNotCullUncompressed+0x05 : [D3DRS_DoNotCullUncompressed] - XREF_ENTRY(0x05, XREF_D3DRS_DoNotCullUncompressed), // Derived + // mov [D3DRS_DoNotCullUncompressed],eax + XREF_ENTRY(0x05, XREF_D3DRS_DoNotCullUncompressed), + // call D3D_CommonSetDebugRegisters + XREF_ENTRY(0x0A, XREF_D3D_CommonSetDebugRegisters), - // D3DDevice_SetRenderState_DoNotCullUncompressed+0x00 : mov eax, [esp+0x04] - { 0x00, 0x8B }, - { 0x01, 0x44 }, - { 0x02, 0x24 }, - { 0x03, 0x04 }, + // mov eax, [esp+0x04] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), - // D3DDevice_SetRenderState_DoNotCullUncompressed+0x09 : call [abs] - { 0x09, 0xE8 }, + // call D3D_CommonSetDebugRegisters + OV_MATCH(0x09, 0xE8), - // D3DDevice_SetRenderState_DoNotCullUncompressed+0x0E : retn 0x04 - { 0x0E, 0xC2 }, - { 0x0F, 0x04 }, - { 0x10, 0x00 }, + // retn 0x04 + OV_MATCH(0x0E, 0xC2, 0x04, 0x00), // ); diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index 5645598e..0088185e 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -321,7 +321,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_BackFillMode, 3911, 4034), REGISTER_OOVPAS_C(D3DDevice_SetRenderState_CullMode, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_Deferred, 3911), - REGISTER_OOVPAS(D3DDevice_SetRenderState_DoNotCullUncompressed, 3911), + REGISTER_OOVPAS(D3DDevice_SetRenderState_DoNotCullUncompressed, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_Dxt1NoiseEnable, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_EdgeAntiAlias, 3911, 4034), REGISTER_OOVPAS_M(D3DDevice_SetRenderState_FillMode, 3911, 4034), @@ -336,8 +336,8 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_OcclusionCullEnable, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_PSTextureModes, 3911, 4034), - REGISTER_OOVPAS(D3DDevice_SetRenderState_RopZCmpAlwaysRead, 3911), - REGISTER_OOVPAS(D3DDevice_SetRenderState_RopZRead, 3911), + REGISTER_OOVPAS(D3DDevice_SetRenderState_RopZCmpAlwaysRead, 3911), // Final generic OOVPA: 3911; Removed: 0 + REGISTER_OOVPAS(D3DDevice_SetRenderState_RopZRead, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 4627), REGISTER_OOVPAS(D3DDevice_SetRenderState_ShadowFunc, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilCullEnable, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 From ca92eac314f2db7c05613b58712983246035f3f5 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Wed, 21 Dec 2022 05:45:57 -0600 Subject: [PATCH 15/35] d3d: add D3DRS_Stencils_and_Occlusion__ManualFindGeneric signature --- include/xref/d3d8.def | 4 ++- src/OOVPADatabase/D3D8/3911.inl | 42 +++++++++++++++++++++++++++ src/OOVPADatabase/D3D8_OOVPA.inl | 1 + src/lib/libXbSymbolDatabase.c | 1 - src/lib/manual_d3d8__ltcg.h | 49 +++++++++++++++++++++++++++++--- src/test/libverify/D3D8.cpp | 8 ++++-- 6 files changed, 96 insertions(+), 9 deletions(-) diff --git a/include/xref/d3d8.def b/include/xref/d3d8.def index ac7537f7..e3ceee04 100644 --- a/include/xref/d3d8.def +++ b/include/xref/d3d8.def @@ -21,6 +21,7 @@ // custom search (not for external project usage) XREF_SYMBOL(D3DDevice__m_VerticalBlankEvent__ManualFindGeneric) +XREF_SYMBOL(D3DRS_Stencils_and_Occlusion__ManualFindGeneric) // variable addresses XREF_SYMBOL(D3D_g_RenderState) @@ -48,7 +49,8 @@ XREF_SYMBOL(D3DRS_PSTextureModes) XREF_SYMBOL(D3DRS_DoNotCullUncompressed) XREF_SYMBOL(D3DRS_SampleAlpha) XREF_SYMBOL(D3DRS_StencilCullEnable) -//XREF_SYMBOL(D3DRS_StencilEnable) // Not been used +XREF_SYMBOL(D3DRS_StencilEnable) // Not been used +XREF_SYMBOL(D3DRS_StencilFail) XREF_SYMBOL(D3DRS_TwoSidedLighting) XREF_SYMBOL(D3DRS_YuvEnable) XREF_SYMBOL(D3DRS_ZBias) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 1c1dd058..7f6f5dde 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -68,6 +68,48 @@ OOVPA_SIG_MATCH( // ); +// ****************************************************************** +// * D3DRS_Stencils_and_Occlusion__ManualFindGeneric +// ****************************************************************** +// Generic OOVPA as of 3911 and newer. +OOVPA_SIG_HEADER_XREF_DETECT(D3DRS_Stencils_and_Occlusion__ManualFindGeneric, + 3911, + XRefFour, + DetectFirst) +OOVPA_SIG_MATCH( + + // mov e??, [D3DRS_StencilCullEnable] + XREF_ENTRY(0x02, XREF_D3DRS_StencilCullEnable), + + // mov e??, [D3DRS_OcclusionCullEnable] + XREF_ENTRY(0x13, XREF_D3DRS_OcclusionCullEnable), + + // mov e??, [D3DRS_StencilEnable] + XREF_ENTRY(0x1D, XREF_D3DRS_StencilEnable), + + // cmp [D3DRS_StencilFail],0x1E00 + XREF_ENTRY(0x27, XREF_D3DRS_StencilFail), + + // mov e??, [D3DRS_StencilCullEnable] + OV_MATCH(0x00, 0x8B), + + // mov ecx,0x2 + OV_MATCH(0x0C, 0xB9, 0x02, 0x00 /*, 0x00, 0x00*/), + + // mov e??, [D3DRS_OcclusionCullEnable] + OV_MATCH(0x11, 0x8B), + + // mov e??, [D3DRS_StencilEnable] + OV_MATCH(0x1B, 0x8B), + + // cmp [D3DRS_StencilFail],0x1E00 + OV_MATCH(0x25, 0x81), + + // or ecx,0x1 + OV_MATCH(0x31, 0x83, 0xC9, 0x01), + // +); + // ****************************************************************** // * Direct3D_CreateDevice // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index 0088185e..5a984f5c 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -186,6 +186,7 @@ // ****************************************************************** OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS_M(D3DDevice__m_VerticalBlankEvent__ManualFindGeneric, 3911), // This OOVPA signature is not a symbol. Read its note for more details. + REGISTER_OOVPAS_M(D3DRS_Stencils_and_Occlusion__ManualFindGeneric, 3911), // This OOVPA signature is not a symbol. Read its note for more details. REGISTER_OOVPAS(D3D_UpdateProjectionViewportTransform, 3900, 3901), // Final generic OOVPA: 4034; Removed: 0 // NOTE: 3901 is 4034 signature, except LTCG title been detected in 3925. diff --git a/src/lib/libXbSymbolDatabase.c b/src/lib/libXbSymbolDatabase.c index 0449a2a2..c04d9411 100644 --- a/src/lib/libXbSymbolDatabase.c +++ b/src/lib/libXbSymbolDatabase.c @@ -831,7 +831,6 @@ bool XbSymbolDatabase_CreateXbSymbolContext(XbSymbolContextHandle* ppHandle, pContext->xref_database[XREF_D3DRS_RopZCmpAlwaysRead] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_RopZRead] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_DoNotCullUncompressed] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_StencilCullEnable] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DRS_TwoSidedLighting] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DTSS_TEXCOORDINDEX] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3D_g_Stream] = XREF_ADDR_DERIVE; //In use diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index 39ee583c..f9e3bf80 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -201,8 +201,8 @@ static const RenderStateRevision DxbxRenderStateInfo[] = { /* 141 */ { 3424, 0000, XREF_NAME(D3DRS_TwoSidedLighting) }, // nsp. // FIXME map from NV2A_LIGHT_MODEL /* 142 */ { 3424, 0000 /*, XREF_NAME(D3DRS_NormalizeNormals) */ }, // /* 143 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ZEnable) */ }, // D3DZBUFFERTYPE? - /* 144 */ { 3424, 0000 /*, XREF_NAME(D3DRS_StencilEnable) */ }, // - /* 145 */ { 3424, 0000 /*, XREF_NAME(D3DRS_StencilFail) */ }, // + /* 144 */ { 3424, 0000, XREF_NAME(D3DRS_StencilEnable) }, // + /* 145 */ { 3424, 0000, XREF_NAME(D3DRS_StencilFail) }, // /* 146 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FrontFace) */ }, // nsp. /* 147 */ { 3424, 0000, XREF_NAME(D3DRS_CullMode) }, // /* 148 */ { 3424, 0000 /*, XREF_NAME(D3DRS_TextureFactor) */ }, // @@ -408,8 +408,8 @@ static void manual_scan_section_dx8_register_xrefs(iXbSymbolContext* pContext, internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_Dxt1NoiseEnable, EmuD3DDeferredRenderState + patchOffset - 3 * 4); internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_YuvEnable, EmuD3DDeferredRenderState + patchOffset - 2 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_OcclusionCullEnable, EmuD3DDeferredRenderState + patchOffset - 1 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_StencilCullEnable, EmuD3DDeferredRenderState + patchOffset + 0 * 4); + //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_OcclusionCullEnable, EmuD3DDeferredRenderState + patchOffset - 1 * 4); + //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_StencilCullEnable, EmuD3DDeferredRenderState + patchOffset + 0 * 4); //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_RopZCmpAlwaysRead, EmuD3DDeferredRenderState + patchOffset + 1 * 4); //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_RopZRead, EmuD3DDeferredRenderState + patchOffset + 2 * 4); //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_DoNotCullUncompressed, EmuD3DDeferredRenderState + patchOffset + 3 * 4); @@ -617,6 +617,44 @@ static bool manual_scan_section_dx8_register_D3DRS_end_of_list(iXbSymbolContext* return true; } +// No dependency requirement +static bool manual_scan_section_dx8_register_D3DRS_Stencils_and_Occlusion(iXbSymbolContext* pContext, + const iXbSymbolLibrarySession* pLibrarySession, + SymbolDatabaseList* pLibraryDB, + const XbSDBSection* pSection) +{ + OOVPATable* pSymbol = NULL; + OOVPARevision* pRevision = NULL; + // First, we need to find D3DRS_StencilEnable symbol. + xbaddr D3DRS_StencilEnable = pContext->xref_database[XREF_D3DRS_StencilEnable]; + if (internal_IsXRefAddrUnset(D3DRS_StencilEnable)) { + // These xrefs are used to obtain from D3DRS_Stencils_and_Occlusion__ManualFindGeneric signature. + pContext->xref_database[XREF_D3DRS_StencilEnable] = XREF_ADDR_DERIVE; + pContext->xref_database[XREF_D3DRS_StencilFail] = XREF_ADDR_DERIVE; + pContext->xref_database[XREF_D3DRS_OcclusionCullEnable] = XREF_ADDR_DERIVE; + pContext->xref_database[XREF_D3DRS_StencilCullEnable] = XREF_ADDR_DERIVE; + xbaddr xFuncAddr = (xbaddr)(uintptr_t)internal_LocateSymbolFunction(pContext, + pLibrarySession, + pLibraryDB, + "D3DRS_Stencils_and_Occlusion__ManualFindGeneric", + pSection, + false, + &pSymbol, + &pRevision); + // If not found, skip the rest of the scan. + if (xFuncAddr == 0) { + pContext->xref_database[XREF_D3DRS_StencilEnable] = XREF_ADDR_UNDETERMINED; + pContext->xref_database[XREF_D3DRS_StencilFail] = XREF_ADDR_UNDETERMINED; + pContext->xref_database[XREF_D3DRS_OcclusionCullEnable] = XREF_ADDR_UNDETERMINED; + pContext->xref_database[XREF_D3DRS_StencilCullEnable] = XREF_ADDR_UNDETERMINED; + return false; + } + + // If found, then above xrefs will be set internally. + } + return true; +} + static void manual_scan_section_dx8_register_D3DTSS(iXbSymbolContext* pContext, const iXbSymbolLibrarySession* pLibrarySession, memptr_t pFunc, @@ -767,6 +805,9 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, // Get D3D_g_ComplexRenderState, D3DRS_FillMode, and D3DRS_PSTextureModes variables bComplete &= manual_scan_section_dx8_register_D3DCRS(pContext, pLibrarySession, pLibraryDB, pSection); + // Get D3DRS_OcclusionCullEnable, D3DRS_StencilCullEnable, D3DRS_StencilEnable, and D3DRS_StencilFail variables + bComplete &= manual_scan_section_dx8_register_D3DRS_Stencils_and_Occlusion(pContext, pLibrarySession, pLibraryDB, pSection); + // Check if any results as incomplete scan. if (!bComplete) { return bComplete; diff --git a/src/test/libverify/D3D8.cpp b/src/test/libverify/D3D8.cpp index 3e9368cb..4f8a809c 100644 --- a/src/test/libverify/D3D8.cpp +++ b/src/test/libverify/D3D8.cpp @@ -26,6 +26,8 @@ static const library_list database_full = { REGISTER_SYMBOL_INLINE(D3DRS_RopZRead, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_SampleAlpha, VER_RANGE(4627, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_StencilCullEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_StencilEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_StencilFail, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_TwoSidedLighting, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_YuvEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_ZBias, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), @@ -438,10 +440,10 @@ void getLibraryD3D8(library_db& lib_db) lib_db.subcategories = { &d3d8_db }; lib_db.xref_offset = XREF_OFFSET; lib_db.xref_total = LOCAL_COUNT; - // TODO: database is incomplete + 2 internal reference need to be exclude. + // TODO: database is incomplete + 3 internal reference need to be exclude. // Excluding: - // - 2 internal manual scan reference + // - 3 internal manual scan reference // - 2 variables // - 5 internal offsets - lib_db.xref_exclude = 9; + lib_db.xref_exclude = 10; } From 8000f8acc80efac399661ca3440137cc62262eff Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Mon, 19 Dec 2022 09:24:11 -0600 Subject: [PATCH 16/35] d3d: update OcclusionCullEnable and StencilCullEnable sigs --- src/OOVPADatabase/D3D8/3911.inl | 96 +++++++++++++++++++++------- src/OOVPADatabase/D3D8/4034.inl | 70 -------------------- src/OOVPADatabase/D3D8LTCG/3911.inl | 41 ------------ src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 2 - src/OOVPADatabase/D3D8_OOVPA.inl | 4 +- 5 files changed, 74 insertions(+), 139 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 7f6f5dde..0c1de1e8 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -3989,27 +3989,51 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_OcclusionCullEnable, XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_OcclusionCullEnable+0x05 : mov esi,[D3D_g_pDevice] + // mov esi,[D3D_g_pDevice] XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_OcclusionCullEnable+0x0C : [D3DRS_OcclusionCullEnable] - XREF_ENTRY(0x0D, XREF_D3DRS_OcclusionCullEnable), // Derived + // mov [D3DRS_OcclusionCullEnable],eax + XREF_ENTRY(0x0D, XREF_D3DRS_OcclusionCullEnable), - // D3DDevice_SetRenderState_OcclusionCullEnable+0x11 : call XMETAL_StartPush + // call XMETAL_StartPush //XREF_ENTRY(0x12, XREF_XMETAL_StartPush), - // D3DDevice_SetRenderState_OcclusionCullEnable+0x00 : mov eax, [esp+arg_0] + // mov eax,[esp+arg_0] OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + // push esi + OV_MATCH(0x04, 0x56), + + // mov [D3DRS_OcclusionCullEnable],eax + OV_MATCH(0x0C, 0xA3) + // +); + +// ****************************************************************** +// * D3DDevice_SetRenderState_OcclusionCullEnable +// ****************************************************************** +// Generic OOVPA as of 3911 (LTCG) / 4034 (non-LTCG) and newer. +// NOTE: asm codes are the same as D3DDevice_SetRenderState_StencilCullEnable +// except for the offset references. +// NOTE2: This signature is used in LTCG titles first in 3911 then later +// afterward become standard in non-LTCG titles since build 4034. +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_OcclusionCullEnable, + 1024, + XRefTwo) +OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_OcclusionCullEnable+0x3B : cmp [abs], 0x1E00 - OV_MATCH(0x3B, 0x81), - OV_MATCH(0x41, 0x00, 0x1E), + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_OcclusionCullEnable+0x4A : mov dword ptr [eax], 0x41D84 - OV_MATCH(0x4A, 0xC7, 0x00, 0x84, 0x1D, 0x04), + // mov [D3DRS_OcclusionCullEnable],eax + XREF_ENTRY(0x0C, XREF_D3DRS_OcclusionCullEnable), - // D3DDevice_SetRenderState_OcclusionCullEnable+0x59 : retn 0x04 - OV_MATCH(0x59, 0xC2, 0x04), + // mov eax,[esp+arg_0] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + // push esi + OV_MATCH(0x04, 0x56), + + // mov [D3DRS_OcclusionCullEnable],eax + OV_MATCH(0x0B, 0xA3) // ); @@ -4023,27 +4047,51 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilCullEnable, XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D_g_pDevice] + // mov esi,[D3D_g_pDevice] XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_StencilCullEnable+0x0C : [D3DRS_StencilCullEnable] - XREF_ENTRY(0x0D, XREF_D3DRS_StencilCullEnable), // Derived + // mov [D3DRS_StencilCullEnable],eax + XREF_ENTRY(0x0D, XREF_D3DRS_StencilCullEnable), - // D3DDevice_SetRenderState_StencilCullEnable+0x11 : call XMETAL_StartPush + // call XMETAL_StartPush //XREF_ENTRY(0x12, XREF_XMETAL_StartPush), - // D3DDevice_SetRenderState_StencilCullEnable+0x00 : mov eax, [esp+arg_0] + // mov eax, [esp+arg_0] OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + // push esi + OV_MATCH(0x04, 0x56), + + // mov [D3DRS_StencilCullEnable],eax + OV_MATCH(0x0C, 0xA3) + // +); + +// ****************************************************************** +// * D3DDevice_SetRenderState_StencilCullEnable +// ****************************************************************** +// Generic OOVPA as of 3911 (LTCG) / 4034 (non-LTCG) and newer. +// NOTE: asm codes are the same as D3DDevice_SetRenderState_OcclusionCullEnable +// except for the offset references. +// NOTE2: This signature is used in LTCG titles first in 3911 then later +// afterward become standard in non-LTCG titles since build 4034. +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilCullEnable, + 1024, + XRefTwo) +OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_StencilCullEnable+0x3B : cmp [abs], 0x1E00 - OV_MATCH(0x3B, 0x81), - OV_MATCH(0x41, 0x00, 0x1E), + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_StencilCullEnable+0x4A : mov dword ptr [eax], 0x41D84 - OV_MATCH(0x4A, 0xC7, 0x00, 0x84, 0x1D, 0x04), + // mov [D3DRS_StencilCullEnable],eax + XREF_ENTRY(0x0C, XREF_D3DRS_StencilCullEnable), + + // mov eax, [esp+arg_0] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + // push esi + OV_MATCH(0x04, 0x56), - // D3DDevice_SetRenderState_StencilCullEnable+0x59 : retn 0x04 - OV_MATCH(0x59, 0xC2, 0x04), + // mov [D3DRS_StencilCullEnable],eax + OV_MATCH(0x0B, 0xA3) // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index 38e96310..83d3708c 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -1529,76 +1529,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_OcclusionCullEnable -// ****************************************************************** -// Generic OOVPA as of 4034 and newer. -// NOTE: asm codes are the same as D3DDevice_SetRenderState_StencilCullEnable -// except for the offset references. -OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_OcclusionCullEnable, - 4034, - XRefTwo) -OOVPA_SIG_MATCH( - - // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D_g_pDevice] - XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - - // D3DDevice_SetRenderState_OcclusionCullEnable+0x0B : [D3DRS_OcclusionCullEnable] - XREF_ENTRY(0x0C, XREF_D3DRS_OcclusionCullEnable), // Derived - - // D3DDevice_SetRenderState_OcclusionCullEnable+0x17 : call D3DDevice_MakeSpace - //XREF_ENTRY(0x18, XREF_D3DDevice_MakeSpace), - - // D3DDevice_SetRenderState_StencilCullEnable+0x00 : mov eax, [esp+arg_0] - OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), - - // D3DDevice_SetRenderState_OcclusionCullEnable+0x41 : cmp [abs], 0x1E00 - OV_MATCH(0x41, 0x81), - OV_MATCH(0x47, 0x00, 0x1E), - - // D3DDevice_SetRenderState_OcclusionCullEnable+0x50 : mov dword ptr [eax], 0x41D84 - OV_MATCH(0x50, 0xC7, 0x00, 0x84, 0x1D, 0x04), - - // D3DDevice_SetRenderState_OcclusionCullEnable+0x5F : retn 0x04 - OV_MATCH(0x5F, 0xC2, 0x04), - // -); - -// ****************************************************************** -// * D3DDevice_SetRenderState_StencilCullEnable -// ****************************************************************** -// Generic OOVPA as of 4034 and newer. -// NOTE: asm codes are the same as D3DDevice_SetRenderState_OcclusionCullEnable -// except for the offset references. -OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilCullEnable, - 4034, - XRefTwo) -OOVPA_SIG_MATCH( - - // D3DDevice_SetRenderState_StencilCullEnable+0x05 : mov esi,[D3D_g_pDevice] - XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - - // D3DDevice_SetRenderState_StencilCullEnable+0x0B : [D3DRS_StencilCullEnable] - XREF_ENTRY(0x0C, XREF_D3DRS_StencilCullEnable), // Derived - - // D3DDevice_SetRenderState_StencilCullEnable+0x17 : call D3DDevice_MakeSpace - //XREF_ENTRY(0x18, XREF_D3DDevice_MakeSpace), - - // D3DDevice_SetRenderState_StencilCullEnable+0x00 : mov eax, [esp+arg_0] - OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), - - // D3DDevice_SetRenderState_StencilCullEnable+0x41 : cmp [abs], 0x1E00 - OV_MATCH(0x41, 0x81), - OV_MATCH(0x47, 0x00, 0x1E), - - // D3DDevice_SetRenderState_StencilCullEnable+0x50 : mov dword ptr [eax], 0x41D84 - OV_MATCH(0x50, 0xC7, 0x00, 0x84, 0x1D, 0x04), - - // D3DDevice_SetRenderState_StencilCullEnable+0x5F : retn 0x04 - OV_MATCH(0x5F, 0xC2, 0x04), - // -); - // ****************************************************************** // * D3DResource_GetType // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index c8356703..0bed5a0e 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -183,27 +183,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_OcclusionCullEnable -// ****************************************************************** -//568BD0E8 -OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_OcclusionCullEnable, - 1024, - XRefOne) -OOVPA_SIG_MATCH( - - XREF_ENTRY(0x0C, XREF_D3DRS_OcclusionCullEnable), - - { 0x00, 0x8B }, - { 0x06, 0x35 }, - - //{ 0x26, 0x56 }, - //{ 0x27, 0x8B }, - //{ 0x28, 0xD0 }, - //{ 0x29, 0xE8 }, - // -); - // ****************************************************************** // * D3DDevice_SetTextureState_TexCoordIndex // ****************************************************************** @@ -321,26 +300,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_StencilCullEnable -// ****************************************************************** -OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilCullEnable, - 1024, - XRefOne) -OOVPA_SIG_MATCH( - - XREF_ENTRY(0x0C, XREF_D3DRS_StencilCullEnable), - - { 0x01, 0x44 }, - { 0x04, 0x56 }, - { 0x05, 0x8B }, - { 0x06, 0x35 }, - { 0x0B, 0xA3 }, - { 0x11, 0x06 }, - { 0x15, 0x72 }, - // -); - //****************************************************************** //* D3DDevice_SetRenderState_BackFillMode //****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index c441fa52..efc11534 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -160,10 +160,8 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMode, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 1024, 1036, 1048, 1060), - REGISTER_OOVPAS(D3DDevice_SetRenderState_OcclusionCullEnable, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 1024, 1036), REGISTER_OOVPAS(D3DDevice_SetRenderState_ShadowFunc, 1024, 1036, 1048, 1060), - REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilCullEnable, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilEnable, 1024, 1036, 1048, 1060, 1072, 1084), REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilFail, 1024, 1036, 1048, 1060, 1072, 1084), REGISTER_OOVPAS(D3DDevice_SetRenderState_TextureFactor, 1036), diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index 5a984f5c..a92bc2c1 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -335,13 +335,13 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMode, 3925, 4034, 4134, 4627, 5233), REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 4034), // Was 5233 (from 5344's comment) REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 3911, 4034), - REGISTER_OOVPAS(D3DDevice_SetRenderState_OcclusionCullEnable, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 + REGISTER_OOVPAS(D3DDevice_SetRenderState_OcclusionCullEnable, 3911, 1024), // Final generic OOVPA: 3911 (LTCG) / 4034 (non-LTCG); Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_PSTextureModes, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_RopZCmpAlwaysRead, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_RopZRead, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 4627), REGISTER_OOVPAS(D3DDevice_SetRenderState_ShadowFunc, 3911, 4034), - REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilCullEnable, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 + REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilCullEnable, 3911, 1024), // Final generic OOVPA: 3911 (LTCG) / 4034 (non-LTCG); Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilEnable, 3911, 4034, 5849), REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilFail, 3911, 4034, 5849), REGISTER_OOVPAS(D3DDevice_SetRenderState_TextureFactor, 3911, 4034), From 1e07cedec3dcc9f846541fdadb2b9cf88b3c769b Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Thu, 22 Dec 2022 19:34:35 -0600 Subject: [PATCH 17/35] d3d: finally take down hardcode offset guesswork to rely on DxbxRenderStateInfo table instead --- src/OOVPADatabase/D3D8/3911.inl | 4 +- src/lib/libXbSymbolDatabase.c | 7 - src/lib/manual_d3d8__ltcg.h | 257 ++++---------------------------- src/test/libverify/D3D8.cpp | 5 +- 4 files changed, 36 insertions(+), 237 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 0c1de1e8..71aa7391 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -5077,9 +5077,11 @@ OOVPA_SIG_MATCH( // Generic OOVPA as of 3911 and newer. OOVPA_SIG_HEADER_XREF(D3D_CommonSetDebugRegisters, 3911, - XRefThree) + XRefFour) OOVPA_SIG_MATCH( + // mov esi, ptr [D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // derived // mov ecx, ptr [D3DRS_DoNotCullUncompressed] XREF_ENTRY(0x18, XREF_D3DRS_DoNotCullUncompressed), // derived // mov ecx, ptr [D3DRS_RopZCmpAlwaysRead] diff --git a/src/lib/libXbSymbolDatabase.c b/src/lib/libXbSymbolDatabase.c index c04d9411..9687565b 100644 --- a/src/lib/libXbSymbolDatabase.c +++ b/src/lib/libXbSymbolDatabase.c @@ -825,13 +825,6 @@ bool XbSymbolDatabase_CreateXbSymbolContext(XbSymbolContextHandle* ppHandle, // clang-format off // Request a few fundamental XRefs to be derived instead of checked // D3D - pContext->xref_database[XREF_D3D_g_pDevice] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_CullMode] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_MultiSampleRenderTargetMode] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_RopZCmpAlwaysRead] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_RopZRead] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_DoNotCullUncompressed] = XREF_ADDR_DERIVE; //In use - pContext->xref_database[XREF_D3DRS_TwoSidedLighting] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3DTSS_TEXCOORDINDEX] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_D3D_g_Stream] = XREF_ADDR_DERIVE; //In use pContext->xref_database[XREF_OFFSET_D3DDevice__m_PixelShader] = XREF_ADDR_DERIVE; // diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index f9e3bf80..89c0f8cb 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -212,7 +212,7 @@ static const RenderStateRevision DxbxRenderStateInfo[] = { /* 152 */ { 3424, 0000, XREF_NAME(D3DRS_MultiSampleAntiAlias) }, // /* 153 */ { 3424, 0000, XREF_NAME(D3DRS_MultiSampleMask) }, // /* 154 */ { 3424, 4034 /*, XREF_NAME(D3DRS_MultiSampleType) */ }, // Verified present in 3944, removed in 4034. 4034 state based on test-case : The Simpsons Road Rage - /* 155 */ { 4034, 0000 /*, XREF_NAME(D3DRS_MultiSampleMode) */ }, // D3DMULTISAMPLEMODE for the backbuffer. Verified absent in 3944, present in 4034. 4034 state based on test-case : The Simpsons Road Rage + /* 155 */ { 4034, 0000, XREF_NAME(D3DRS_MultiSampleMode) }, // D3DMULTISAMPLEMODE for the backbuffer. Verified absent in 3944, present in 4034. 4034 state based on test-case : The Simpsons Road Rage /* 156 */ { 4034, 0000, XREF_NAME(D3DRS_MultiSampleRenderTargetMode) }, // Verified absent in 3944, present in 4034. Presence in 4034 is based on test-case : The Simpsons Road Rage /* 157 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ShadowFunc) */ }, // /* 158 */ { 3424, 0000 /*, XREF_NAME(D3DRS_LineWidth) */ }, // @@ -333,100 +333,35 @@ static void manual_scan_section_dx8_VerifyRenderStateOffsets(iXbSymbolContext* p output_message(&pContext->output, XB_OUTPUT_MESSAGE_DEBUG, "Verify RenderState offsets is complete."); } - -static void manual_scan_section_dx8_register_xrefs(iXbSymbolContext* pContext, - const iXbSymbolLibrarySession* pLibrarySession, - memptr_t pFunc, - xbaddr DerivedAddr_D3DRS_CullMode, - uint32_t patchOffset, - uint32_t Increment, - uint32_t Decrement) -{ - if (pFunc == NULL) { - return; - } - const XbSDBLibrary* pLibrary = pLibrarySession->pLibrary; - const eLibraryType iLibraryType = pLibrarySession->iLibraryType; - - // Temporary verification - is XREF_D3D_g_pDevice derived correctly? - xbaddr DerivedAddr_D3DDevice = *(xbaddr*)(pFunc + 0x03); - if (pContext->xref_database[XREF_D3D_g_pDevice] != DerivedAddr_D3DDevice) { - - if (pContext->xref_database[XREF_D3D_g_pDevice] != XREF_ADDR_DERIVE) { - output_message(&pContext->output, XB_OUTPUT_MESSAGE_INFO, "Second derived XREF_D3D_g_pDevice differs from first!"); - } - - internal_SetXRefDatabase(pContext, pLibrarySession->iLibraryType, XREF_D3D_g_pDevice, DerivedAddr_D3DDevice); - } - pContext->register_func(pLibrary->name, pLibrary->flag, XREF_D3D_g_pDevice, "D3D_g_pDevice", DerivedAddr_D3DDevice, 0); - - // Temporary verification - is XREF_D3D_RenderState_CullMode derived correctly? - if (pContext->xref_database[XREF_D3DRS_CullMode] != DerivedAddr_D3DRS_CullMode) { - - if (pContext->xref_database[XREF_D3DRS_CullMode] != XREF_ADDR_DERIVE) { - output_message(&pContext->output, XB_OUTPUT_MESSAGE_WARN, "Second derived XREF_D3D_RenderState_CullMode differs from first!"); - } - - internal_SetXRefDatabase(pContext, pLibrarySession->iLibraryType, XREF_D3DRS_CullMode, DerivedAddr_D3DRS_CullMode); - } - // Register the offset of D3DRS_CullMode, this can be used to programatically locate other render-states in the calling program - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_CullMode, DerivedAddr_D3DRS_CullMode); - - // Derive address of EmuD3DDeferredRenderState from D3DRS_CullMode - // NOTE: No longer requirement anymore! Woohoo! - // xbaddr EmuD3DDeferredRenderState = DerivedAddr_D3DRS_CullMode - Decrement + Increment; - xbaddr EmuD3DDeferredRenderState = pContext->xref_database[XREF_D3D_g_DeferredRenderState]; - patchOffset -= Increment; - - // Derive address of a few other deferred render state slots (to help xref-based function location) - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_PSTextureModes, DerivedAddr_D3DRS_CullMode - 11*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_VertexBlend, DerivedAddr_D3DRS_CullMode - 10*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_FogColor, DerivedAddr_D3DRS_CullMode - 9*4); - //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_FillMode, DerivedAddr_D3DRS_CullMode - 8 * 4); // is done in manual_scan_section_dx8_register_D3DCRS. - //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_BackFillMode, DerivedAddr_D3DRS_CullMode - 7 * 4); // is done in manual_scan_section_dx8_register_D3DCRS. - //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_TwoSidedLighting, DerivedAddr_D3DRS_CullMode - 6 * 4); // is done in manual_scan_section_dx8_register_D3DCRS. - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_NormalizeNormals, DerivedAddr_D3DRS_CullMode - 5*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_ZEnable, DerivedAddr_D3DRS_CullMode - 4*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_StencilEnable, DerivedAddr_D3DRS_CullMode - 3*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_StencilFail, DerivedAddr_D3DRS_CullMode - 2*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_FrontFace, DerivedAddr_D3DRS_CullMode - 1*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_CullMode, DerivedAddr_D3DRS_CullMode - 0*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_TextureFactor, DerivedAddr_D3DRS_CullMode + 1*4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_ZBias, DerivedAddr_D3DRS_CullMode + 2 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_LogicOp, DerivedAddr_D3DRS_CullMode + 3 * 4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_EdgeAntiAlias, DerivedAddr_D3DRS_CullMode + 4*4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MultiSampleAntiAlias, DerivedAddr_D3DRS_CullMode + 5 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MultiSampleMask, DerivedAddr_D3DRS_CullMode + 6 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MultiSampleMode, DerivedAddr_D3DRS_CullMode + 7 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_MultiSampleRenderTargetMode, DerivedAddr_D3DRS_CullMode + 8 * 4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_ShadowFunc, DerivedAddr_D3DRS_CullMode + 9*4); - // SetXRefDataBase(pContext, iLibraryType, XREF_D3DRS_LineWidth, DerivedAddr_D3DRS_CullMode + 10*4); - - if (pLibrary->build_version >= 4627 && pLibrary->build_version <= 5933) { // Add XDK 4627 - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_SampleAlpha, DerivedAddr_D3DRS_CullMode + 11 * 4); - } - - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_Dxt1NoiseEnable, EmuD3DDeferredRenderState + patchOffset - 3 * 4); - internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_YuvEnable, EmuD3DDeferredRenderState + patchOffset - 2 * 4); - //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_OcclusionCullEnable, EmuD3DDeferredRenderState + patchOffset - 1 * 4); - //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_StencilCullEnable, EmuD3DDeferredRenderState + patchOffset + 0 * 4); - //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_RopZCmpAlwaysRead, EmuD3DDeferredRenderState + patchOffset + 1 * 4); - //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_RopZRead, EmuD3DDeferredRenderState + patchOffset + 2 * 4); - //internal_SetXRefDatabase(pContext, iLibraryType, XREF_D3DRS_DoNotCullUncompressed, EmuD3DDeferredRenderState + patchOffset + 3 * 4); - -} - -static bool manual_scan_section_dx8_register_D3DRS_list(iXbSymbolContext* pContext, +static bool manual_scan_section_dx8_register_D3DRS_vars(iXbSymbolContext* pContext, const iXbSymbolLibrarySession* pLibrarySession, SymbolDatabaseList* pLibraryDB, const XbSDBSection* pSection) { // Instead of individual register call, let's go through the list to automatically register valid xrefs. const uint16_t lib_version = pLibrarySession->pLibrary->build_version; + unsigned RenderState_iLib = 0; + char buffer_str[512]; for (size_t i = 0; i < DxbxRenderStateInfoSize; i++) { const RenderStateRevision render_state_i = DxbxRenderStateInfo[i]; - if (IsRenderStateAvailableInCurrentXboxD3D8Lib(render_state_i, lib_version) && render_state_i.xref != 0) { - internal_RegisterValidXRefAddr(pContext, Lib_D3D8, XbSymbolLib_D3D8, render_state_i.xref, render_state_i.version, render_state_i.name); + if (IsRenderStateAvailableInCurrentXboxD3D8Lib(render_state_i, lib_version)) { + if (DxbxRenderStateInfo[i].xref) { + xbaddr RenderState_iAddr = pContext->xref_database[DxbxRenderStateInfo[i].xref]; + // Check if D3DRS_ prefix variables are set. + if (internal_IsXRefAddrUnset(RenderState_iAddr)) { + if (RenderState_iAddr != XREF_ADDR_DERIVE) { + // If it is not derive address, then let's calculate base on DxbxRenderStateInfo table for accuracy. + internal_SetXRefDatabase(pContext, + pLibrarySession->iLibraryType, + DxbxRenderStateInfo[i].xref, + pContext->xref_database[XREF_D3D_g_RenderState] + RenderState_iLib * sizeof(xbaddr)); + snprintf(buffer_str, sizeof(buffer_str), "%s symbol address is manually set to D3D_g_RenderState + %zd * %u.", DxbxRenderStateInfo[i].name, sizeof(xbaddr), RenderState_iLib); + output_message(&pContext->output, XB_OUTPUT_MESSAGE_DEBUG, buffer_str); + } + } + internal_RegisterValidXRefAddr(pContext, Lib_D3D8, XbSymbolLib_D3D8, render_state_i.xref, render_state_i.version, render_state_i.name); + } + RenderState_iLib++; } } @@ -593,6 +528,7 @@ static bool manual_scan_section_dx8_register_D3DRS_end_of_list(iXbSymbolContext* xbaddr D3DRS_DoNotCullUncompressed = pContext->xref_database[XREF_D3DRS_DoNotCullUncompressed]; if (internal_IsXRefAddrUnset(D3DRS_DoNotCullUncompressed)) { // These xrefs are used to obtain from D3D_CommonSetDebugRegisters signature. + pContext->xref_database[XREF_D3D_g_pDevice] = XREF_ADDR_DERIVE; pContext->xref_database[XREF_D3DRS_RopZCmpAlwaysRead] = XREF_ADDR_DERIVE; pContext->xref_database[XREF_D3DRS_RopZRead] = XREF_ADDR_DERIVE; pContext->xref_database[XREF_D3DRS_DoNotCullUncompressed] = XREF_ADDR_DERIVE; @@ -606,6 +542,7 @@ static bool manual_scan_section_dx8_register_D3DRS_end_of_list(iXbSymbolContext* &pRevision); // If not found, skip the rest of the scan. if (xFuncAddr == 0) { + pContext->xref_database[XREF_D3D_g_pDevice] = XREF_ADDR_UNDETERMINED; pContext->xref_database[XREF_D3DRS_RopZCmpAlwaysRead] = XREF_ADDR_UNDETERMINED; pContext->xref_database[XREF_D3DRS_RopZRead] = XREF_ADDR_UNDETERMINED; pContext->xref_database[XREF_D3DRS_DoNotCullUncompressed] = XREF_ADDR_UNDETERMINED; @@ -778,11 +715,6 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, // Generic usage memptr_t pFunc = 0; xbaddr xSymbolAddr = 0; - // offset for stencil cull enable render state in the deferred render state buffer - uint32_t DerivedAddr_D3DRS_CullMode = 0; - int Decrement = 0; // TODO : Rename into something understandable - int Increment = 0; // TODO : Rename into something understandable - int patchOffset = 0; // TODO : Rename into something understandable int OOVPA_version; int iCodeOffsetFor_g_Stream; int pXRefOffset = 0; // TODO : Rename into something understandable @@ -813,135 +745,14 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, return bComplete; } - if (pLibrary->flag == XbSymbolLib_D3D8) { - - // locate D3DDevice_SetRenderState_CullMode first - if (pLibrary->build_version < 3911) { - // Not supported, currently ignored. - } - else { - pFunc = internal_LocateSymbolFunction(pContext, - pLibrarySession, - pLibraryDB, - "D3DDevice_SetRenderState_CullMode", - pSection, - true, - NULL, - NULL); - } - - // then locate D3DDeferredRenderState - if (pFunc != 0) { - // NOTE: Is a requirement to align properly. - pFunc += virt_start_relative; + bComplete = manual_scan_section_dx8_register_D3DRS_vars(pContext, pLibrarySession, pLibraryDB, pSection); - // Read address of D3DRS_CullMode from D3DDevice_SetRenderState_CullMode - // TODO : Simplify this when XREF_D3D_RenderState_CullMode derivation is deemed stable - if (pLibrary->build_version < 3911) { - // Not supported, currently ignored. - } - else if (pLibrary->build_version < 4034) { - DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + 0x25); - Decrement = 0x1FC; // TODO: Clean up (?) - Increment = 82 * 4; - patchOffset = 140 * 4; // Verified 3925 and 3948 - - //Decrement = 0x19F; // TODO: Clean up (?) - //Increment = 72 * 4; - //patchOffset = 142*4; // TODO: Verify - } - else if (pLibrary->build_version <= 4361) { - DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + 0x2B); - Decrement = 0x200; - Increment = 82 * 4; - patchOffset = 142 * 4; - } - else if (pLibrary->build_version < 4627) { - DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + 0x2B); - Decrement = 0x204; - Increment = 83 * 4; - patchOffset = 143 * 4; - } - else { // 4627-5933 - DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + 0x2B); - Decrement = 0x24C; - Increment = 92 * 4; - patchOffset = 162 * 4; - } - } + if (bComplete) { + manual_scan_section_dx8_VerifyRenderStateOffsets(pContext, pLibrarySession); } - else { // D3D8LTCG - // locate D3DDevice_SetRenderState_CullMode first - pFunc = internal_LocateSymbolFunction(pContext, - pLibrarySession, - pLibraryDB, - "D3DDevice_SetRenderState_CullMode", - pSection, - true, - NULL, - &pOOVPARevision); - - if (pFunc != 0) { - - // D3DDevice_SetRenderState_CullMode assign pXRefOffset for D3DDeferredRenderState - switch (pOOVPARevision->Version) { - case 1045: - default: - pXRefOffset = 0x2D; // verified for 3925 - break; - case 1049: - pXRefOffset = 0x31; // verified for 4039 - break; - case 1052: - pXRefOffset = 0x34; - break; - case 1053: - pXRefOffset = 0x35; - break; - } - - // then locate D3DDeferredRenderState - - // NOTE: Is a requirement to align properly. - pFunc += virt_start_relative; - - // Read address of D3DRS_CullMode from D3DDevice_SetRenderState_CullMode - // TODO : Simplify this when XREF_D3D_RenderState_CullMode derivation is deemed stable - if (pLibrary->build_version < 3911) { - // Not supported, currently ignored. - } - else if (pLibrary->build_version < 4034) { - DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + pXRefOffset); - Decrement = 0x1FC; // TODO: Clean up (?) - Increment = 82 * 4; - patchOffset = 140 * 4; // Verified 3925 and 3948 - - //Decrement = 0x19F; // TODO: Clean up (?) - //Increment = 72 * 4; - //patchOffset = 142*4; // TODO: Verify - } - else if (pLibrary->build_version <= 4361) { - DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + pXRefOffset); - Decrement = 0x200; - Increment = 82 * 4; - patchOffset = 142 * 4; - } - else if (pLibrary->build_version < 4627) { - DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + pXRefOffset); - Decrement = 0x204; - Increment = 83 * 4; - patchOffset = 143 * 4; - } - else { // 4627-5933 - // NOTE: Burnout 3 is (pFunc + 0x34), Black is (pFunc + 0x35) - DerivedAddr_D3DRS_CullMode = *(uint32_t*)(pFunc + pXRefOffset); - Decrement = 0x24C; - Increment = 92 * 4; - patchOffset = 162 * 4; - } - } + if (!bComplete) { + return bComplete; } - manual_scan_section_dx8_register_xrefs(pContext, pLibrarySession, pFunc, DerivedAddr_D3DRS_CullMode, patchOffset, Increment, Decrement); // then locate D3DDeferredTextureState if (pLibrary->flag == XbSymbolLib_D3D8) { @@ -1101,15 +912,6 @@ static bool manual_scan_section_dx8(iXbSymbolContext* pContext, } bComplete = manual_scan_section_dx8_register_callbacks(pContext, pLibrarySession, pLibraryDB, pSection); - if (!bComplete) { - return bComplete; - } - - bComplete = manual_scan_section_dx8_register_D3DRS_list(pContext, pLibrarySession, pLibraryDB, pSection); - - if (bComplete) { - manual_scan_section_dx8_VerifyRenderStateOffsets(pContext, pLibrarySession); - } return bComplete; } @@ -1118,6 +920,7 @@ static inline void manual_register_d3d8__ltcg(iXbSymbolContext* pContext) { xbaddr xD3D_pDeviceAddr = pContext->xref_database[XREF_D3D_g_pDevice]; if (internal_IsXRefAddrValid(xD3D_pDeviceAddr)) { + internal_RegisterValidXRefAddr_M(pContext, Lib_D3D8, XbSymbolLib_D3D8, XREF_D3D_g_pDevice, 0, "D3D_g_pDevice"); // Register offsets of D3DDevice's members internal_RegisterValidXRefAddr_M(pContext, Lib_D3D8, XbSymbolLib_D3D8, XREF_OFFSET_D3DDevice__m_SwapCallback, 0, "D3DDevice__m_SwapCallback_OFFSET"); internal_RegisterValidXRefAddr_M(pContext, Lib_D3D8, XbSymbolLib_D3D8, XREF_OFFSET_D3DDevice__m_VBlankCallback, 0, "D3DDevice__m_VBlankCallback_OFFSET"); diff --git a/src/test/libverify/D3D8.cpp b/src/test/libverify/D3D8.cpp index 4f8a809c..73f6ec15 100644 --- a/src/test/libverify/D3D8.cpp +++ b/src/test/libverify/D3D8.cpp @@ -19,6 +19,7 @@ static const library_list database_full = { REGISTER_SYMBOL_INLINE(D3DRS_LogicOp, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleAntiAlias, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleMask, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleMode, VER_RANGE(4034, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleRenderTargetMode, VER_RANGE(4034, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_OcclusionCullEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_PSTextureModes, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), @@ -443,7 +444,7 @@ void getLibraryD3D8(library_db& lib_db) // TODO: database is incomplete + 3 internal reference need to be exclude. // Excluding: // - 3 internal manual scan reference - // - 2 variables + // - 1 variables // - 5 internal offsets - lib_db.xref_exclude = 10; + lib_db.xref_exclude = 9; } From 14ef2c2721372c49e38bdb923685b4d61bad220a Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sat, 24 Dec 2022 08:04:22 -0600 Subject: [PATCH 18/35] lib: use snprintf instead of sprintf --- src/lib/manual_d3d8__ltcg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index 89c0f8cb..eefcd313 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -313,16 +313,16 @@ static void manual_scan_section_dx8_VerifyRenderStateOffsets(iXbSymbolContext* p xbaddr RenderState_iAddr = pContext->xref_database[DxbxRenderStateInfo[i].xref]; if (internal_IsXRefAddrUnset(RenderState_iAddr)) { if (RenderState_iAddr != XREF_ADDR_DERIVE) { - sprintf(buffer_str, "XbSymbolDatabase's %s symbol is not set!", DxbxRenderStateInfo[i].name); + snprintf(buffer_str, XBSDB_ARRAY_SIZE(buffer_str), "XbSymbolDatabase's %s symbol is not set!", DxbxRenderStateInfo[i].name); output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, buffer_str); } else { - sprintf(buffer_str, "XbSymbolDatabase's %s symbol is currently set to derive.", DxbxRenderStateInfo[i].name); + snprintf(buffer_str, XBSDB_ARRAY_SIZE(buffer_str), "XbSymbolDatabase's %s symbol is currently set to derive.", DxbxRenderStateInfo[i].name); output_message(&pContext->output, XB_OUTPUT_MESSAGE_DEBUG, buffer_str); } } else if (RenderState_iLib * sizeof(xbaddr) != RenderState_iAddr - g_RenderState) { - sprintf(buffer_str, "DxbxRenderStateInfo list's entry base on %s is inaccurate!", DxbxRenderStateInfo[i].name); + snprintf(buffer_str, XBSDB_ARRAY_SIZE(buffer_str), "DxbxRenderStateInfo list's entry base on %s is inaccurate!", DxbxRenderStateInfo[i].name); output_message(&pContext->output, XB_OUTPUT_MESSAGE_ERROR, buffer_str); } } @@ -355,7 +355,7 @@ static bool manual_scan_section_dx8_register_D3DRS_vars(iXbSymbolContext* pConte pLibrarySession->iLibraryType, DxbxRenderStateInfo[i].xref, pContext->xref_database[XREF_D3D_g_RenderState] + RenderState_iLib * sizeof(xbaddr)); - snprintf(buffer_str, sizeof(buffer_str), "%s symbol address is manually set to D3D_g_RenderState + %zd * %u.", DxbxRenderStateInfo[i].name, sizeof(xbaddr), RenderState_iLib); + snprintf(buffer_str, XBSDB_ARRAY_SIZE(buffer_str), "%s symbol address is manually set to D3D_g_RenderState + %zd * %u.", DxbxRenderStateInfo[i].name, sizeof(xbaddr), RenderState_iLib); output_message(&pContext->output, XB_OUTPUT_MESSAGE_DEBUG, buffer_str); } } From a3725942a7d9d9b64535c783c469dbd519cd8805 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sat, 14 Jan 2023 13:01:22 -0600 Subject: [PATCH 19/35] d3d: update D3DDevice_SetRenderState_MultiSampleAntiAlias and D3DDevice_SetRenderState_MultiSampleMask sigs Removed: - D3DDevice_SetRenderState_MultiSampleAntiAlias (4039, 1036, 1048) - D3DDevice_SetRenderState_MultiSampleMask (4039, 1036, 1048, 1072) Updated: - 3911 and 4627, 1024 and 1060 signatures now use xrefs from new manual detection system --- src/OOVPADatabase/D3D8/3911.inl | 61 +++++++++++++-------------- src/OOVPADatabase/D3D8/4034.inl | 34 --------------- src/OOVPADatabase/D3D8/4627.inl | 63 +++++++++++++++------------- src/OOVPADatabase/D3D8LTCG/3911.inl | 44 ++++++++++--------- src/OOVPADatabase/D3D8LTCG/4039.inl | 45 -------------------- src/OOVPADatabase/D3D8LTCG/4432.inl | 45 -------------------- src/OOVPADatabase/D3D8LTCG/4627.inl | 58 ++++++++++++------------- src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 4 +- src/OOVPADatabase/D3D8_OOVPA.inl | 4 +- 9 files changed, 118 insertions(+), 240 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 71aa7391..12a7a9f8 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -3576,18 +3576,25 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleAntiAlias // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, - 3911) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, + 3911, + XRefTwo) OOVPA_SIG_MATCH( - { 0x00, 0x8B }, - { 0x0B, 0x8B }, - { 0x1D, 0x8B }, - { 0x26, 0x8B }, - { 0x2C, 0x8B }, - { 0x38, 0x0B }, - { 0x40, 0x89 }, - { 0x49, 0xC2 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), + + // mov [D3DRS_MultiSampleAntiAlias],eax + XREF_ENTRY(0x0E, XREF_D3DRS_MultiSampleAntiAlias), + + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x05, 0x8B, 0x35), + + // mov [D3DRS_MultiSampleAntiAlias],eax + OV_MATCH(0x0D, 0xA3), // 4627 0x0E vs 0x0D // ); @@ -3830,33 +3837,25 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleMask // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_MultiSampleMask, - 3911) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, + 3911, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_MultiSampleMask+0x00 : mov eax, [esp+arg_0] - { 0x00, 0x8B }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_MultiSampleMask+0x0B : mov ecx, esi - { 0x0B, 0x8B }, - { 0x0C, 0xCE }, + // mov [D3DRS_MultiSampleMask],eax + XREF_ENTRY(0x0E, XREF_D3DRS_MultiSampleMask), - // D3DDevice_SetRenderState_MultiSampleMask+0x32 : and ecx, 0x0F; shl edx, 0x10 - { 0x32, 0x83 }, - { 0x33, 0xE1 }, - { 0x34, 0x0F }, - { 0x35, 0xC1 }, + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), - // D3DDevice_SetRenderState_MultiSampleMask+0x3A : mov dword ptr [eax], 0x41D7C - { 0x3A, 0xC7 }, - { 0x3B, 0x00 }, - { 0x3C, 0x7C }, - { 0x3D, 0x1D }, - { 0x3E, 0x04 }, + // esi,[D3D_g_pDevice] + OV_MATCH(0x05, 0x8B, 0x35), - // D3DDevice_SetRenderState_MultiSampleMask+0x49 : retn 0x04 - { 0x49, 0xC2 }, - { 0x4A, 0x04 }, + // mov [D3DRS_MultiSampleMask],eax + OV_MATCH(0x0D, 0xA3), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index 83d3708c..b0366657 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -603,40 +603,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleAntiAlias -// ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, - 4034) -OOVPA_SIG_MATCH( - - { 0x0B, 0x8B }, - { 0x17, 0x8B }, - { 0x23, 0x8B }, - { 0x2C, 0x8B }, - { 0x38, 0xC1 }, - { 0x40, 0x7C }, - { 0x4B, 0x08 }, - // -); - -// ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleMask -// ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_MultiSampleMask, - 4034) -OOVPA_SIG_MATCH( - - { 0x0B, 0x8B }, - { 0x17, 0x8B }, - { 0x23, 0x8B }, - { 0x2C, 0x8B }, - { 0x38, 0x83 }, - { 0x40, 0x7C }, - { 0x4B, 0x08 }, - // -); - // ****************************************************************** // * D3DDevice_SetRenderState_NormalizeNormals // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8/4627.inl b/src/OOVPADatabase/D3D8/4627.inl index efdcc04f..b74e5b0c 100644 --- a/src/OOVPADatabase/D3D8/4627.inl +++ b/src/OOVPADatabase/D3D8/4627.inl @@ -975,29 +975,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleAntiAlias // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, - 4627) +// Generic OOVPA as of 4627 and newer. +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, + 4627, + XRefTwo) OOVPA_SIG_MATCH( - { 0x04, 0x56 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), + + // mov [D3DRS_MultiSampleAntiAlias],eax + XREF_ENTRY(0x0F, XREF_D3DRS_MultiSampleAntiAlias), - { 0x13, 0xE8 }, + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x05, 0x8B, 0x35), - { 0x48, 0xC7 }, - { 0x50, 0x04 }, - { 0x51, 0x8B }, - { 0x52, 0x4E }, - { 0x53, 0x04 }, - { 0x54, 0x83 }, - { 0x55, 0xC0 }, - { 0x56, 0x08 }, - { 0x57, 0x3B }, - { 0x58, 0xC1 }, - { 0x59, 0x89 }, - { 0x5A, 0x06 }, - { 0x5B, 0x72 }, - { 0x5C, 0x05 }, - { 0x5D, 0xE8 }, + // mov [D3DRS_MultiSampleAntiAlias],eax + OV_MATCH(0x0E, 0xA3), // 3911 0x0D vs 0x0E // ); @@ -1308,18 +1305,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleMask // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_MultiSampleMask, - 4627) +// Generic OOVPA as of 4627 and newer. +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, + 4627, + XRefTwo) OOVPA_SIG_MATCH( - { 0x0A, 0xA3 }, - { 0x12, 0x56 }, - { 0x1C, 0x8B }, - { 0x2A, 0x85 }, - { 0x30, 0x01 }, - { 0x3D, 0xC7 }, - { 0x44, 0x78 }, - { 0x4E, 0x04 }, + // mov [D3DRS_MultiSampleMask],eax + XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleMask), + + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x15, XREF_D3D_g_pDevice), + + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + + // mov [D3DRS_MultiSampleMask],eax + OV_MATCH(0x0A, 0xA3), + + // esi,[D3D_g_pDevice] + OV_MATCH(0x13, 0x8B, 0x35), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index 0bed5a0e..17def8b4 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -440,45 +440,49 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleAntiAlias // ****************************************************************** -//C1E11083E20F OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, 1024, - XRefOne) + XRefTwo) OOVPA_SIG_MATCH( + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), + + // mov [D3DRS_MultiSampleAntiAlias],eax XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleAntiAlias), - { 0x00, 0x8B }, + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), - { 0x36, 0xC1 }, - { 0x37, 0xE1 }, - { 0x38, 0x10 }, - { 0x39, 0x83 }, - { 0x3A, 0xE2 }, - { 0x3B, 0x0F }, - // + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x05, 0x8B, 0x35), + + // mov [D3DRS_MultiSampleAntiAlias],eax + OV_MATCH(0x0B, 0xA3), // 3911 (non-LTCG) 0x0D vs 0x0B ); // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleMask // ****************************************************************** -//83E10FC1E210 OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, 1024, - XRefOne) + XRefTwo) OOVPA_SIG_MATCH( + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), + + // mov [D3DRS_MultiSampleMask],eax XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleMask), - { 0x00, 0x8B }, - { 0x01, 0x44 }, + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x05, 0x8B, 0x35), - { 0x36, 0x83 }, - { 0x37, 0xE1 }, - { 0x38, 0x0F }, - { 0x39, 0xC1 }, - { 0x3A, 0xE2 }, - { 0x3B, 0x10 }, + // mov [D3DRS_MultiSampleMask],eax + OV_MATCH(0x0B, 0xA3), // 3911 (non-LTCG) 0x0D vs 0x0B // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4039.inl b/src/OOVPADatabase/D3D8LTCG/4039.inl index 1f0ebcf2..0181de68 100644 --- a/src/OOVPADatabase/D3D8LTCG/4039.inl +++ b/src/OOVPADatabase/D3D8LTCG/4039.inl @@ -498,51 +498,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleAntiAlias -// ****************************************************************** -//C1E11083E20F -OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, - 1036, - XRefOne) -OOVPA_SIG_MATCH( - - XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleAntiAlias), - - { 0x00, 0x8B }, - - { 0x3D, 0xC1 }, - { 0x3E, 0xE1 }, - { 0x3F, 0x10 }, - { 0x40, 0x83 }, - { 0x41, 0xE2 }, - { 0x42, 0x0F }, - // -); - -// ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleMask -// ****************************************************************** -//83E10FC1E210 -OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, - 1036, - XRefOne) -OOVPA_SIG_MATCH( - - XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleMask), - - { 0x00, 0x8B }, - { 0x01, 0x44 }, - - { 0x3D, 0x83 }, - { 0x3E, 0xE1 }, - { 0x3F, 0x0F }, - { 0x40, 0xC1 }, - { 0x41, 0xE2 }, - { 0x42, 0x10 }, - // -); - // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleMode // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG/4432.inl b/src/OOVPADatabase/D3D8LTCG/4432.inl index a0b2fccd..5821264f 100644 --- a/src/OOVPADatabase/D3D8LTCG/4432.inl +++ b/src/OOVPADatabase/D3D8LTCG/4432.inl @@ -383,51 +383,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleAntiAlias -// ****************************************************************** -//C1E11083E20F -OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, - 1048, - XRefOne) -OOVPA_SIG_MATCH( - - XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleAntiAlias), - - { 0x00, 0x8B }, - - { 0x3B, 0xC1 }, - { 0x3C, 0xE1 }, - { 0x3D, 0x10 }, - { 0x3E, 0x83 }, - { 0x3F, 0xE2 }, - { 0x40, 0x0F }, - // -); - -// ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleMask -// ****************************************************************** -//83E10FC1E210 -OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, - 1048, - XRefOne) -OOVPA_SIG_MATCH( - - XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleMask), - - { 0x00, 0x8B }, - { 0x01, 0x44 }, - - { 0x3B, 0x83 }, - { 0x3C, 0xE1 }, - { 0x3D, 0x0F }, - { 0x3E, 0xC1 }, - { 0x3F, 0xE2 }, - { 0x40, 0x10 }, - // -); - // ****************************************************************** // * D3DDevice_SetRenderState_StencilFail // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG/4627.inl b/src/OOVPADatabase/D3D8LTCG/4627.inl index d6920d3a..c236dfc6 100644 --- a/src/OOVPADatabase/D3D8LTCG/4627.inl +++ b/src/OOVPADatabase/D3D8LTCG/4627.inl @@ -96,58 +96,52 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleAntiAlias // ****************************************************************** +// Generic OOVPA as of 4627 and newer. OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleAntiAlias, 1060, - XRefOne) + XRefTwo) OOVPA_SIG_MATCH( + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), + + // mov [D3DRS_MultiSampleAntiAlias],eax XREF_ENTRY(0x0D, XREF_D3DRS_MultiSampleAntiAlias), - { 0x00, 0x8B }, - { 0x01, 0x44 }, - { 0x02, 0x24 }, - { 0x03, 0x04 }, - { 0x04, 0x56 }, - { 0x05, 0x8B }, - { 0x06, 0x35 }, + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x05, 0x8B, 0x35), + + // mov [D3DRS_MultiSampleAntiAlias],eax + OV_MATCH(0x0C, 0xA3), // 4627 (non-LTCG) 0x0E vs 0x0C // ); // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleMask // ****************************************************************** +// Generic OOVPA as of 4627 and newer. OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, 1060, - XRefOne) + XRefTwo) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleMask), + // mov edi,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - { 0x01, 0x44 }, - { 0x02, 0x24 }, - { 0x03, 0x04 }, - { 0x04, 0x57 }, - { 0x05, 0x8B }, - { 0x06, 0x3D }, - // -); + // mov [D3DRS_MultiSampleMask],eax + XREF_ENTRY(0x0C, XREF_D3DRS_MultiSampleMask), -// ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleMask -// ****************************************************************** -OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMask, - 1072, - XRefOne) -OOVPA_SIG_MATCH( + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), - XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleMask), + // mov edi,[D3D_g_pDevice] + OV_MATCH(0x05, 0x8B, 0x3D), - { 0x01, 0x44 }, - { 0x0F, 0xC1 }, - { 0x10, 0xE0 }, - { 0x11, 0x10 }, - { 0x12, 0x56 }, - { 0x13, 0x8B }, + // mov [D3DRS_MultiSampleMask],eax + OV_MATCH(0x0B, 0xA3), // 4627 (non-LTCG) 0x0A vs 0x0B // ); diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index efc11534..b398c8be 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -155,8 +155,8 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_FrontFace, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_LineWidth, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_LogicOp, 1024, 1036, 1048, 1060), - REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleAntiAlias, 1024, 1036, 1048, 1060), - REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMask, 1024, 1036, 1048, 1060, 1072), + REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleAntiAlias, 1024, 1060), // Final generic OOVPA: 4627; Removed: 0 + REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMask, 1024, 1060), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMode, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 1024, 1036, 1048, 1060), diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index a92bc2c1..85317fcc 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -330,8 +330,8 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_FrontFace, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_LineWidth, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_LogicOp, 3911, 4034), - REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleAntiAlias, 3911, 4034, 4627), - REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMask, 3911, 4034, 4627), + REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleAntiAlias, 3911, 4627), // Final generic OOVPA: 4627; Removed: 0 + REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMask, 3911, 4627), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMode, 3925, 4034, 4134, 4627, 5233), REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 4034), // Was 5233 (from 5344's comment) REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 3911, 4034), From 0e1c659b5ff9d0c215b651a31b0dba12f1387383 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sat, 14 Jan 2023 13:55:42 -0600 Subject: [PATCH 20/35] d3d: clean up D3DDevice_SetRenderState_Dxt1NoiseEnable's comments --- src/OOVPADatabase/D3D8/3911.inl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 12a7a9f8..a06550ab 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -2747,27 +2747,28 @@ OOVPA_SIG_MATCH( // * D3DDevice_SetRenderState_Dxt1NoiseEnable // ****************************************************************** // Generic OOVPA as of 3911 and newer. -// 1024 (4627), 1036 (3911) <-- jarupxx, this doesn't make sense. +// NOTE: D3DRS_Dxt1NoiseEnable is referenced at end of the function, +// therefore will require additional OOVPA signatures. This +// signature is currently the best generic version. OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_Dxt1NoiseEnable, 3911) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_Dxt1NoiseEnable+0x00 : push ebx + // push ebx OV_MATCH(0x00, 0x53), - - // D3DDevice_SetRenderState_Dxt1NoiseEnable+0x01 : mov ebx,[esp+0x__] + // mov ebx,[esp + 0x??] OV_MATCH(0x01, 0x8B), - // D3DDevice_SetRenderState_Dxt1NoiseEnable+0x05 : push esi + // push esi OV_MATCH(0x05, 0x56), - // D3DDevice_SetRenderState_Dxt1NoiseEnable+0x1D : and dl, 0x3C + // and dl, 0x3C OV_MATCH(0x1D, 0x80, 0xE2, 0x3C), - // D3DDevice_SetRenderState_Dxt1NoiseEnable+0x22 : cmp dl, 0x20 + // cmp dl, 0x20 OV_MATCH(0x22, 0x80, 0xFA, 0x20), - // D3DDevice_SetRenderState_Dxt1NoiseEnable+0x2E : and ecx,0x01 + // and ecx,0x01 OV_MATCH(0x2E, 0x83, 0xE1, 0x01), // From 75227851ffb74644c06cfa44d9e4a75a7487a795 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sat, 14 Jan 2023 13:58:00 -0600 Subject: [PATCH 21/35] d3d: update D3DDevice_SetRenderState_FillMode's comment --- src/OOVPADatabase/D3D8/4034.inl | 15 ++++++++------- src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index b0366657..ced91f21 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -490,34 +490,35 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FillMode // ****************************************************************** +// Generic OOVPA as of 4034 and newer. OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FillMode, 4034, XRefThree) OOVPA_SIG_MATCH( - // mov ecx,ptr [D3DRS_TwoSidedLighting] + // mov ecx,[D3DRS_TwoSidedLighting] XREF_ENTRY(0x15, XREF_D3DRS_TwoSidedLighting), - // mov edx,ptr [D3DRS_BackFillMode] + // mov edx,[D3DRS_BackFillMode] XREF_ENTRY(0x1B, XREF_D3DRS_BackFillMode), - // mov ptr [D3DRS_FillMode],ecx + // mov [D3DRS_FillMode],ecx XREF_ENTRY(0x3C, XREF_D3DRS_FillMode), // push esi OV_MATCH(0x00, 0x56), - // mov ecx,ptr [D3DRS_TwoSidedLighting] + // mov ecx,[D3DRS_TwoSidedLighting] OV_MATCH(0x13, 0x8B), - // mov edx,ptr [D3DRS_BackFillMode] + // mov edx,[D3DRS_BackFillMode] OV_MATCH(0x19, 0x8B), - // mov ptr [eax],0x008038C + // mov [eax],0x008038C OV_MATCH(0x29, 0xC7, 0x00, 0x8C, 0x03, 0x08, 0x00), // add eax,0x0C OV_MATCH(0x35, 0x83, 0xC0, 0x0C), - // mov ptr [D3DRS_FillMode],ecx + // mov [D3DRS_FillMode],ecx OV_MATCH(0x3A, 0x89), // retn 0x04 diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index 85317fcc..d9a21167 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -325,7 +325,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_DoNotCullUncompressed, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_Dxt1NoiseEnable, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_EdgeAntiAlias, 3911, 4034), - REGISTER_OOVPAS_M(D3DDevice_SetRenderState_FillMode, 3911, 4034), + REGISTER_OOVPAS_M(D3DDevice_SetRenderState_FillMode, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_FogColor, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_FrontFace, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_LineWidth, 3911, 4034), From 06f4359b30ae25560768d29fb2283b1dec6b9afc Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sat, 14 Jan 2023 14:24:09 -0600 Subject: [PATCH 22/35] d3d: update D3DDevice_SetRenderState_PSTextureModes signatures --- src/OOVPADatabase/D3D8/3911.inl | 35 ++++++++++++++++---------------- src/OOVPADatabase/D3D8/4034.inl | 33 +++++++++++++++++++----------- src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index a06550ab..32ae7116 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -2475,29 +2475,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_PSTextureModes // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_PSTextureModes, - 3911) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_PSTextureModes, + 3911, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_PSTextureModes+0x00 : mov eax, [addr] - { 0x00, 0xA1 }, + // mov eax,[D3D_g_pDevice] + XREF_ENTRY(0x01, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_PSTextureModes+0x0C : or edx, 0x400 - { 0x0C, 0x81 }, - { 0x0D, 0xCA }, - { 0x0E, 0x00 }, - { 0x0F, 0x04 }, + // mov [D3DRS_PSTextureModes],e?? + XREF_ENTRY(0x1D, XREF_D3DRS_PSTextureModes), - // D3DDevice_SetRenderState_PSTextureModes+0x12 : mov [eax+0x420], ecx - { 0x12, 0x89 }, - { 0x13, 0x88 }, - { 0x14, 0x20 }, - { 0x15, 0x04 }, - { 0x16, 0x00 }, + // mov eax,[D3D_g_pDevice] + OV_MATCH(0x00, 0xA1), - // D3DDevice_SetRenderState_PSTextureModes+0x21 : retn 4 - { 0x21, 0xC2 }, - { 0x22, 0x04 }, + // or edx,0x400 + OV_MATCH(0x0C, 0x81, 0xCA, 0x00, 0x04), + + // mov [D3DRS_PSTextureModes],e?? + OV_MATCH(0x1B, 0x89), + + // retn 4 + OV_MATCH(0x21, 0xC2, 0x04), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index ced91f21..c72ffcbd 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -1367,20 +1367,29 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_PSTextureModes // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_PSTextureModes, - 4034) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_PSTextureModes, + 4034, + XRefTwo) OOVPA_SIG_MATCH( - { 0x0A, 0x89 }, - { 0x0B, 0x81 }, - { 0x0E, 0x00 }, - { 0x0F, 0x00 }, - { 0x10, 0x81 }, - { 0x11, 0x0D }, - { 0x16, 0x00 }, - { 0x17, 0x40 }, - { 0x1A, 0xA3 }, - { 0x1F, 0xC2 }, + // mov eax,[D3D_g_pDevice] + XREF_ENTRY(0x06, XREF_D3D_g_pDevice), + + // mov [D3DRS_PSTextureModes],e?? + XREF_ENTRY(0x1B, XREF_D3DRS_PSTextureModes), + + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + + // or [0x????????],0x4000 + OV_MATCH(0x10, 0x81, 0x0D), + OV_MATCH(0x16, 0x00, 0x40), + + // mov [D3DRS_PSTextureModes],e?? + OV_MATCH(0x1A, 0xA3), + + // retn 4 + OV_MATCH(0x1F, 0xC2, 0x04), // ); diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index d9a21167..1a9d560b 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -336,7 +336,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 4034), // Was 5233 (from 5344's comment) REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_OcclusionCullEnable, 3911, 1024), // Final generic OOVPA: 3911 (LTCG) / 4034 (non-LTCG); Removed: 0 - REGISTER_OOVPAS(D3DDevice_SetRenderState_PSTextureModes, 3911, 4034), + REGISTER_OOVPAS(D3DDevice_SetRenderState_PSTextureModes, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_RopZCmpAlwaysRead, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_RopZRead, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 4627), From b49831cd807d7e70c7502ce6830de501a6cb2eb6 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sat, 14 Jan 2023 14:54:28 -0600 Subject: [PATCH 23/35] d3d: update D3DDevice_SetRenderState_SampleAlpha signatures Removed: - D3DDevice_SetRenderState_SampleAlpha (1036) --- src/OOVPADatabase/D3D8/4627.inl | 27 ++++++++++++++------- src/OOVPADatabase/D3D8LTCG/4627.inl | 35 ++++++++++------------------ src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 2 +- src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- 4 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/OOVPADatabase/D3D8/4627.inl b/src/OOVPADatabase/D3D8/4627.inl index b74e5b0c..5b78f47f 100644 --- a/src/OOVPADatabase/D3D8/4627.inl +++ b/src/OOVPADatabase/D3D8/4627.inl @@ -1750,17 +1750,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_SampleAlpha // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_SampleAlpha, - 4627) +// Generic OOVPA as of 4627 and newer. +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_SampleAlpha, + 4627, + XRefTwo) OOVPA_SIG_MATCH( - { 0x0B, 0xC1 }, - { 0x15, 0x0B }, - { 0x1C, 0x8B }, - { 0x28, 0x85 }, - { 0x30, 0x07 }, - { 0x3B, 0xC7 }, - { 0x44, 0x83 }, + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x11, XREF_D3D_g_pDevice), + + // mov [D3DRS_SampleAlpha],eax + XREF_ENTRY(0x18, XREF_D3DRS_SampleAlpha), + + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + + // mov e??,[D3D_g_pDevice] + OV_MATCH(0x0F, 0x8B), + + // mov [D3DRS_SampleAlpha],eax + OV_MATCH(0x17, 0xA3), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4627.inl b/src/OOVPADatabase/D3D8LTCG/4627.inl index c236dfc6..8968e175 100644 --- a/src/OOVPADatabase/D3D8LTCG/4627.inl +++ b/src/OOVPADatabase/D3D8LTCG/4627.inl @@ -148,37 +148,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_SampleAlpha // ****************************************************************** +// Generic OOVPA as of 4627 and newer. OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_SampleAlpha, 1024, - XRefOne) + XRefTwo) OOVPA_SIG_MATCH( - XREF_ENTRY(0x0C, XREF_D3DRS_SampleAlpha), + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - { 0x00, 0x8B }, - { 0x04, 0x57 }, - { 0x05, 0x8B }, - { 0x06, 0x3D }, - // -); + // mov [D3DRS_SampleAlpha],eax + XREF_ENTRY(0x0C, XREF_D3DRS_SampleAlpha), -// ****************************************************************** -// * D3DDevice_SetRenderState_SampleAlpha -// ****************************************************************** -//C1E610578B3D -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_SampleAlpha, - 1036) -OOVPA_SIG_MATCH( + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), - { 0x00, 0x8B }, - { 0x01, 0x44 }, + // mov e??,[D3D_g_pDevice] + OV_MATCH(0x05, 0x8B), - { 0x0B, 0xC1 }, - { 0x0C, 0xE6 }, - { 0x0D, 0x10 }, - { 0x0E, 0x57 }, - { 0x0F, 0x8B }, - { 0x10, 0x3D }, + // mov [D3DRS_SampleAlpha],eax + OV_MATCH(0x0B, 0xA3), // ); diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index b398c8be..5d2ce66d 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -160,7 +160,7 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMode, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 1024, 1036, 1048, 1060), - REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 1024, 1036), + REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 1024), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_ShadowFunc, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilEnable, 1024, 1036, 1048, 1060, 1072, 1084), REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilFail, 1024, 1036, 1048, 1060, 1072, 1084), diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index 1a9d560b..04b16243 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -339,7 +339,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_PSTextureModes, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_RopZCmpAlwaysRead, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_RopZRead, 3911), // Final generic OOVPA: 3911; Removed: 0 - REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 4627), + REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 4627), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_ShadowFunc, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilCullEnable, 3911, 1024), // Final generic OOVPA: 3911 (LTCG) / 4034 (non-LTCG); Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilEnable, 3911, 4034, 5849), From 57f2eb7bf14223e4569f7e69ad8421c7ad8c86f6 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sat, 14 Jan 2023 21:46:52 -0600 Subject: [PATCH 24/35] d3d: update D3DDevice_SetRenderState_YuvEnable signatures Removed: - 4034 Updated: - 1024 (include support for 4034 non-LTCG and later) --- src/OOVPADatabase/D3D8/3911.inl | 58 ++++++++++++++++++++-------- src/OOVPADatabase/D3D8/4034.inl | 17 -------- src/OOVPADatabase/D3D8LTCG/3911.inl | 20 ---------- src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 1 - src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- 5 files changed, 42 insertions(+), 56 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 32ae7116..a268a631 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -3952,29 +3952,53 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_YuvEnable // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_YuvEnable, - 3911) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_YuvEnable, + 3911, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_YuvEnable+0x00 : mov eax, [esp+0x04] - { 0x00, 0x8B }, - { 0x01, 0x44 }, - { 0x02, 0x24 }, - { 0x03, 0x04 }, + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_YuvEnable+0x04 : push edi - { 0x04, 0x56 }, + // mov [D3DRS_YuvEnable],eax + XREF_ENTRY(0x0D, XREF_D3DRS_YuvEnable), - // D3DDevice_SetRenderState_YuvEnable+0x0B : push edi - { 0x0B, 0x56 }, + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), - // D3DDevice_SetRenderState_YuvEnable+0x1F : mov [esi], eax - { 0x1F, 0x89 }, - { 0x20, 0x06 }, + // mov e??,[D3D_g_pDevice] + OV_MATCH(0x05, 0x8B), - // D3DDevice_SetRenderState_YuvEnable+0x22 : retn 0x04 - { 0x22, 0xC2 }, - { 0x23, 0x04 }, + // mov [D3DRS_YuvEnable],eax + OV_MATCH(0x0C, 0xA3), + // +); + +// ****************************************************************** +// * D3DDevice_SetRenderState_YuvEnable +// ****************************************************************** +// Generic OOVPA as of 3911 (LTCG) / 4034 (non-LTCG) and newer. +// NOTE: This signature is used in LTCG titles first in 3911 then later +// afterward become standard in non-LTCG titles since build 4034. +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_YuvEnable, + 1024, + XRefTwo) +OOVPA_SIG_MATCH( + + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x07, XREF_D3D_g_pDevice), + + // mov [D3DRS_YuvEnable],eax + XREF_ENTRY(0x0C, XREF_D3DRS_YuvEnable), + + // mov eax,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + + // mov e??,[D3D_g_pDevice] + OV_MATCH(0x05, 0x8B), + + // mov [D3DRS_YuvEnable],eax + OV_MATCH(0x0B, 0xA3), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index c72ffcbd..a195677f 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -673,23 +673,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_YuvEnable -// ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_YuvEnable, - 4034) -OOVPA_SIG_MATCH( - - { 0x04, 0x56 }, - { 0x0B, 0xA3 }, - { 0x10, 0x8B }, - { 0x16, 0x05 }, - { 0x1C, 0x8B }, - { 0x25, 0x89 }, - { 0x28, 0xC2 }, - // -); - // ****************************************************************** // * D3DDevice_SetRenderState_TwoSidedLighting // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index 17def8b4..2e23291a 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -163,26 +163,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_YuvEnable -// ****************************************************************** -OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_YuvEnable, - 1024, - XRefOne) -OOVPA_SIG_MATCH( - - XREF_ENTRY(0x0C, XREF_D3DRS_YuvEnable), - - { 0x01, 0x44 }, - { 0x04, 0x56 }, - { 0x05, 0x8B }, - { 0x06, 0x35 }, - { 0x0B, 0xA3 }, - { 0x11, 0x06 }, - { 0x15, 0x72 }, - // -); - // ****************************************************************** // * D3DDevice_SetTextureState_TexCoordIndex // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index 5d2ce66d..ac20cf6d 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -167,7 +167,6 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_TextureFactor, 1036), REGISTER_OOVPAS(D3DDevice_SetRenderState_TwoSidedLighting, 1024, 1036, 1048, 1060, 1072, 1084), REGISTER_OOVPAS(D3DDevice_SetRenderState_VertexBlend, 1024, 1036, 1048), - REGISTER_OOVPAS(D3DDevice_SetRenderState_YuvEnable, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_ZBias, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_ZEnable, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderTarget, 1024, 1036, 1048, 1072, 1084), diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index 04b16243..d4c8df6a 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -347,7 +347,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_TextureFactor, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_TwoSidedLighting, 3911, 4034, 5344), // Beware of the typo... (from 4627's comment) REGISTER_OOVPAS(D3DDevice_SetRenderState_VertexBlend, 3911, 4034), - REGISTER_OOVPAS(D3DDevice_SetRenderState_YuvEnable, 3911, 4034), + REGISTER_OOVPAS(D3DDevice_SetRenderState_YuvEnable, 3911, 1024), // Final generic OOVPA: 3911 (LTCG) / 4034 (non-LTCG); Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_ZBias, 3911), REGISTER_OOVPAS(D3DDevice_SetRenderState_ZEnable, 3911, 4034, 4134, 4432), REGISTER_OOVPAS(D3DDevice_SetRenderTarget, 3911, 3947, 4034, 4039, 4627, 5344, 5455), // Final generic OOVPA: 5344/5455; Removed: 0 From c8ee2eac4ed8e706f6593cccccd31ca49799de5b Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sat, 14 Jan 2023 23:54:04 -0600 Subject: [PATCH 25/35] d3d: update D3DDevice_SetRenderState_ZBias signatures Removed: - 1036, 1048 Updated: - 3911, 1024, 1060 --- src/OOVPADatabase/D3D8/3911.inl | 34 +++++++++++++--------------- src/OOVPADatabase/D3D8LTCG/3911.inl | 29 ++++++++++++------------ src/OOVPADatabase/D3D8LTCG/4531.inl | 24 -------------------- src/OOVPADatabase/D3D8LTCG/4627.inl | 28 +++++++++++++---------- src/OOVPADatabase/D3D8LTCG/5849.inl | 23 ------------------- src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 2 +- src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- 7 files changed, 49 insertions(+), 93 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index a268a631..ee00b163 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -2776,30 +2776,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_ZBias // ****************************************************************** +// Generic OOVPA as of 3911 and newer. +// NOTE: D3DRS_ZBias is referenced at end of the function, +// therefore will require additional OOVPA signatures. This +// signature is currently the best generic version. +// NOTE2: Above note include LTCG's titles detection. OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_ZBias, 3911) OOVPA_SIG_MATCH( + // push ecx + // push esi + OV_MATCH(0x00, 0x51, 0x56), - // D3DDevice_SetRenderState_ZBias+0x00 : push ecx - { 0x00, 0x51 }, - - // D3DDevice_SetRenderState_ZBias+0x0B : setnz al - { 0x0B, 0x0F }, - { 0x0C, 0x95 }, - { 0x0D, 0xC0 }, + // setnz al + OV_MATCH(0x0B, 0x0F, 0x95, 0xC0), - // D3DDevice_SetRenderState_ZBias+0x14 : fild [esp+0x10] - { 0x14, 0xDB }, - { 0x15, 0x44 }, - { 0x16, 0x24 }, + // fild [esp + param_1] + OV_MATCH(0x14, 0xDB, 0x44, 0x24, 0x10), - // D3DDevice_SetRenderState_ZBias+0x45 : push 0x4E - { 0x45, 0x6A }, - { 0x46, 0x4E }, - - // D3DDevice_SetRenderState_ZBias+0x45 : retn 0x04 - { 0x71, 0xC2 }, - { 0x72, 0x04 }, + // jge +0x06 + OV_MATCH(0x1A, 0x7D, 0x06), + // fadd [0x????????] + OV_MATCH(0x1C, 0xD8, 0x05), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index 2e23291a..0cb95f60 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -237,25 +237,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_ZBias // ****************************************************************** -//24..8BF07D06D805 OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_ZBias, - 1048) + 1024) OOVPA_SIG_MATCH( + // push ecx + // push ebx // non-LTCG does not have this instruction + // push esi + OV_MATCH(0x00, 0x51, 0x53, 0x56), - // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBias ), + // setnz al + OV_MATCH(0x0C, 0x0F, 0x95, 0xC0), - { 0x00, 0x51 }, - { 0x01, 0x53 }, + // fild [esp + param_1] + OV_MATCH(0x15, 0xDB, 0x44, 0x24, 0x14), - { 0x17, 0x24 }, - //{ 0x18, 0x10 }, - { 0x19, 0x8B }, - { 0x1A, 0xF0 }, - { 0x1B, 0x7D }, - { 0x1C, 0x06 }, - { 0x1D, 0xD8 }, - { 0x1E, 0x05 }, - // + // jge +0x06 + OV_MATCH(0x1B, 0x7D, 0x06), + // fadd [0x????????] + OV_MATCH(0x1D, 0xD8, 0x05), + // NOTE: fchs instruction is moved to different offset + // Source: (4928) The Fellowship of the Ring ); // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG/4531.inl b/src/OOVPADatabase/D3D8LTCG/4531.inl index 2d32370b..871e583c 100644 --- a/src/OOVPADatabase/D3D8LTCG/4531.inl +++ b/src/OOVPADatabase/D3D8LTCG/4531.inl @@ -93,30 +93,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_ZBias -// ****************************************************************** -//24..8BF07D06D805 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_ZBias, - 1036) -OOVPA_SIG_MATCH( - - // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBias ), - - { 0x00, 0x51 }, - { 0x01, 0x56 }, - - { 0x16, 0x24 }, - //{ 0x17, 0x10 }, - { 0x18, 0x8B }, - { 0x19, 0xF0 }, - { 0x1A, 0x7D }, - { 0x1B, 0x06 }, - { 0x1C, 0xD8 }, - { 0x1D, 0x05 }, - // -); - // ****************************************************************** // * D3DDevice_Swap // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG/4627.inl b/src/OOVPADatabase/D3D8LTCG/4627.inl index 8968e175..68797c42 100644 --- a/src/OOVPADatabase/D3D8LTCG/4627.inl +++ b/src/OOVPADatabase/D3D8LTCG/4627.inl @@ -72,24 +72,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_ZBias // ****************************************************************** -//24..8BF07D06D805 +// List of titles found: +// - (4627) Aggressive Inline +// - (5028) BMX XXX OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_ZBias, 1060) OOVPA_SIG_MATCH( + // push ecx + // push ebx // non-LTCG titles does not have this instruction + // push ebp // most LTCG titles does not have this instruction + // push esi + OV_MATCH(0x00, 0x51, 0x53, 0x55, 0x56), - // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBias ), + // setnz al + OV_MATCH(0x0D, 0x0F, 0x95, 0xC0), - { 0x00, 0x51 }, - { 0x01, 0x53 }, + // fild [esp + param_1] + OV_MATCH(0x16, 0xDB, 0x44, 0x24, 0x18), - { 0x18, 0x24 }, - //{ 0x19, 0x18 }, - { 0x1A, 0x8B }, - { 0x1B, 0xF0 }, - { 0x1C, 0x7D }, - { 0x1D, 0x06 }, - { 0x1E, 0xD8 }, - { 0x1F, 0x05 }, + // jge +0x06 + OV_MATCH(0x1C, 0x7D, 0x06), + // fadd [0x????????] + OV_MATCH(0x1E, 0xD8, 0x05), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/5849.inl b/src/OOVPADatabase/D3D8LTCG/5849.inl index 015b4fc2..09107a13 100644 --- a/src/OOVPADatabase/D3D8LTCG/5849.inl +++ b/src/OOVPADatabase/D3D8LTCG/5849.inl @@ -272,29 +272,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_ZBias -// ****************************************************************** -//241485FF0F95C085 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_ZBias, - 1024) -OOVPA_SIG_MATCH( - - // XREF_ENTRY( 0x6A, XREF_D3DRS_ZBias ), - - { 0x00, 0x51 }, - - { 0x08, 0x24 }, - { 0x09, 0x14 }, - { 0x0A, 0x85 }, - { 0x0B, 0xFF }, - { 0x0C, 0x0F }, - { 0x0D, 0x95 }, - { 0x0E, 0xC0 }, - { 0x0F, 0x85 }, - // -); - // ****************************************************************** // * D3DDevice_SetRenderState_StencilFail // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index ac20cf6d..20ebc070 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -167,7 +167,7 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_TextureFactor, 1036), REGISTER_OOVPAS(D3DDevice_SetRenderState_TwoSidedLighting, 1024, 1036, 1048, 1060, 1072, 1084), REGISTER_OOVPAS(D3DDevice_SetRenderState_VertexBlend, 1024, 1036, 1048), - REGISTER_OOVPAS(D3DDevice_SetRenderState_ZBias, 1024, 1036, 1048, 1060), + REGISTER_OOVPAS(D3DDevice_SetRenderState_ZBias, 1024, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_ZEnable, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderTarget, 1024, 1036, 1048, 1072, 1084), REGISTER_OOVPAS_BIND_XREF(D3DDevice_SetRenderTarget_0, D3DDevice_SetRenderTarget, 2048), diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index d4c8df6a..d8c5a6c6 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -348,7 +348,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_TwoSidedLighting, 3911, 4034, 5344), // Beware of the typo... (from 4627's comment) REGISTER_OOVPAS(D3DDevice_SetRenderState_VertexBlend, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_YuvEnable, 3911, 1024), // Final generic OOVPA: 3911 (LTCG) / 4034 (non-LTCG); Removed: 0 - REGISTER_OOVPAS(D3DDevice_SetRenderState_ZBias, 3911), + REGISTER_OOVPAS(D3DDevice_SetRenderState_ZBias, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_ZEnable, 3911, 4034, 4134, 4432), REGISTER_OOVPAS(D3DDevice_SetRenderTarget, 3911, 3947, 4034, 4039, 4627, 5344, 5455), // Final generic OOVPA: 5344/5455; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderTargetFast, 5233), From 817f766d9f68a8cc1c5a18264f1a5cab02ba61b6 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sun, 15 Jan 2023 05:16:23 -0600 Subject: [PATCH 26/35] d3d: update D3DDevice_SetRenderState_MultiSampleMode and add D3DDevice_SetRenderState_MultiSampleType sigs Removed: - D3DDevice_SetRenderState_MultiSampleMode (4134, 4627, 5233, 1024) Renamed: - D3DDevice_SetRenderState_MultiSampleMode (3925) to D3DDevice_SetRenderState_MultiSampleType Updated: - D3DDevice_SetRenderState_MultiSampleMode (4034) - D3DDevice_SetRenderState_MultiSampleType (3925) --- include/xref/d3d8.def | 2 + src/OOVPADatabase/D3D8/3925.inl | 34 ++++++++--------- src/OOVPADatabase/D3D8/4034.inl | 56 ++++++++++++---------------- src/OOVPADatabase/D3D8/4134.inl | 29 -------------- src/OOVPADatabase/D3D8/4627.inl | 18 --------- src/OOVPADatabase/D3D8/5233.inl | 34 ----------------- src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 1 - src/OOVPADatabase/D3D8_OOVPA.inl | 3 +- src/lib/manual_d3d8__ltcg.h | 2 +- src/test/libverify/D3D8.cpp | 4 +- 10 files changed, 46 insertions(+), 137 deletions(-) diff --git a/include/xref/d3d8.def b/include/xref/d3d8.def index e3ceee04..db6f42b1 100644 --- a/include/xref/d3d8.def +++ b/include/xref/d3d8.def @@ -42,6 +42,7 @@ XREF_SYMBOL(D3DRS_MultiSampleAntiAlias) XREF_SYMBOL(D3DRS_MultiSampleMask) XREF_SYMBOL(D3DRS_MultiSampleMode) XREF_SYMBOL(D3DRS_MultiSampleRenderTargetMode) +XREF_SYMBOL(D3DRS_MultiSampleType) XREF_SYMBOL(D3DRS_OcclusionCullEnable) XREF_SYMBOL(D3DRS_RopZCmpAlwaysRead) XREF_SYMBOL(D3DRS_RopZRead) @@ -238,6 +239,7 @@ XREF_SYMBOL(D3DDevice_SetRenderState_MultiSampleAntiAlias) XREF_SYMBOL(D3DDevice_SetRenderState_MultiSampleMask) XREF_SYMBOL(D3DDevice_SetRenderState_MultiSampleMode) XREF_SYMBOL(D3DDevice_SetRenderState_MultiSampleRenderTargetMode) +XREF_SYMBOL(D3DDevice_SetRenderState_MultiSampleType) XREF_SYMBOL(D3DDevice_SetRenderState_NormalizeNormals) XREF_SYMBOL(D3DDevice_SetRenderState_OcclusionCullEnable) XREF_SYMBOL(D3DDevice_SetRenderState_PSTextureModes) diff --git a/src/OOVPADatabase/D3D8/3925.inl b/src/OOVPADatabase/D3D8/3925.inl index 0c0f1e38..821804d2 100644 --- a/src/OOVPADatabase/D3D8/3925.inl +++ b/src/OOVPADatabase/D3D8/3925.inl @@ -24,30 +24,26 @@ // ****************************************************************** // ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleMode +// * D3DDevice_SetRenderState_MultiSampleType // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_MultiSampleMode, - 3925) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleType, + 3925, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_MultiSampleMode+0x05 : mov ecx, [esp+4] - { 0x05, 0x8B }, - { 0x06, 0x4C }, - { 0x07, 0x24 }, - { 0x08, 0x04 }, + // mov [D3DRS_MultiSampleType],ecx + XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleType), - // D3DDevice_SetRenderState_MultiSampleMode+0x0F : mov edx, [eax+0x410] - { 0x0F, 0x8B }, - { 0x10, 0x90 }, - { 0x11, 0x10 }, - { 0x12, 0x04 }, + // call D3DDevice_SetRenderTarget + XREF_ENTRY(0x1E, XREF_D3DDevice_SetRenderTarget), - // D3DDevice_SetRenderState_MultiSampleMode+0x15 : mov eax, [eax+0x40C] - { 0x15, 0x8B }, - { 0x16, 0x80 }, + // mov ecx,[esp + param_1] + OV_MATCH(0x05, 0x8B, 0x4C, 0x24, 0x04), - // D3DDevice_SetRenderState_MultiSampleMode+0x22 : retn 0x04 - { 0x22, 0xC2 }, - { 0x23, 0x04 }, + // call D3DDevice_SetRenderTarget + OV_MATCH(0x1D, 0xE8), + + // retn 0x04 + OV_MATCH(0x22, 0xC2, 0x04), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index a195677f..5a7c3a8c 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -1379,43 +1379,33 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleMode // ****************************************************************** -#ifndef WIP_LessVertexPatching -OOVPA_NO_XREF(D3DDevice_SetRenderState_MultiSampleMode, 4034, 12) - { -#else -OOVPA_XREF(D3DDevice_SetRenderState_MultiSampleMode, - 4034, - 1 + 8, - XRefOne) -{ +// Generic OOVPA as of 4034 and newer. +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleMode, + 4034, + XRefOne) +OOVPA_SIG_MATCH( - XREF_ENTRY(0x11, XREF_OFFSET_D3DDevice__m_RenderTarget), // Derived -#endif - // D3DDevice_SetRenderState_MultiSampleMode+0x0F : mov ecx, [eax+0x21F0] - { 0x0F, 0x8B }, - { 0x10, 0x88 }, -#ifndef WIP_LessVertexPatching - { 0x11, 0xF0 }, // disabled. part of an offset - { 0x12, 0x21 }, -#endif + // Do not xref with D3D_g_pDevice due to offset difference across builds. - // D3DDevice_SetRenderState_MultiSampleMode+0x15 : cmp ecx, [eax+0x21FC] - { 0x15, 0x3B }, - { 0x16, 0x88 }, -#ifndef WIP_LessVertexPatching - { 0x17, 0xFC }, // disabled. part of an offset - { 0x18, 0x21 }, -#endif + // mov [D3DRS_MultiSampleMode],e?? + XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleMode), - // D3DDevice_SetRenderState_MultiSampleMode+0x1B : jnz +0x0D - { 0x1B, 0x75 }, - { 0x1C, 0x0D }, + // TODO: enable below for WIP_LessVertexPatching + //XREF_ENTRY(0x11, XREF_OFFSET_D3DDevice__m_RenderTarget), // Derived - // D3DDevice_SetRenderState_MultiSampleMode+0x2A : retn 0x04 - { 0x2A, 0xC2 }, - { 0x2B, 0x04 }, - } -OOVPA_END; + // mov e??,[esp + param_1] + OV_MATCH(0x00, 0x8B), + OV_MATCH(0x02, 0x24, 0x04), + // Do not input any OV patterns in-between here and before offset 0x0F. + + // mov e??,[e??+OFFSET_D3DDevice__m_RenderTarget] + OV_MATCH(0x0F, 0x8B), + // cmp e??, [e??+0x????????] + OV_MATCH(0x15, 0x3B), + // jnz +0x?? + OV_MATCH(0x1B, 0x75), + // +); // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleRenderTargetMode diff --git a/src/OOVPADatabase/D3D8/4134.inl b/src/OOVPADatabase/D3D8/4134.inl index b7d52469..2da69280 100644 --- a/src/OOVPADatabase/D3D8/4134.inl +++ b/src/OOVPADatabase/D3D8/4134.inl @@ -218,35 +218,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleMode -// ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_MultiSampleMode, - 4134) -OOVPA_SIG_MATCH( - - // D3DDevice_SetRenderState_MultiSampleMode+0x0F : mov ecx, [eax+0x2070] - { 0x0F, 0x8B }, - { 0x10, 0x88 }, - { 0x11, 0x70 }, - { 0x12, 0x20 }, - - // D3DDevice_SetRenderState_MultiSampleMode+0x15 : cmp ecx, [eax+0x207C] - { 0x15, 0x3B }, - { 0x16, 0x88 }, - { 0x17, 0x7C }, - { 0x18, 0x20 }, - - // D3DDevice_SetRenderState_MultiSampleMode+0x1B : jnz +0x0D - { 0x1B, 0x75 }, - { 0x1C, 0x0D }, - - // D3DDevice_SetRenderState_MultiSampleMode+0x2A : retn 0x04 - { 0x2A, 0xC2 }, - { 0x2B, 0x04 }, - // -); - // ****************************************************************** // * D3D::SetFence // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8/4627.inl b/src/OOVPADatabase/D3D8/4627.inl index 5b78f47f..063ff21e 100644 --- a/src/OOVPADatabase/D3D8/4627.inl +++ b/src/OOVPADatabase/D3D8/4627.inl @@ -1443,24 +1443,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleMode -// ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_MultiSampleMode, - 4627) -OOVPA_SIG_MATCH( - - { 0x09, 0x89 }, - { 0x0F, 0x8B }, - { 0x13, 0x00 }, - { 0x1A, 0x00 }, - { 0x1B, 0x75 }, - { 0x21, 0x00 }, - { 0x28, 0x00 }, - { 0x31, 0xC2 }, - // -); - // ****************************************************************** // * D3DDevice_ApplyStateBlock // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8/5233.inl b/src/OOVPADatabase/D3D8/5233.inl index 2df1665f..ec4413ff 100644 --- a/src/OOVPADatabase/D3D8/5233.inl +++ b/src/OOVPADatabase/D3D8/5233.inl @@ -46,40 +46,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleMode -// ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_MultiSampleMode, - 5233) -OOVPA_SIG_MATCH( - - // D3DDevice_SetRenderState_MultiSampleMode+0x04 : mov ecx, ds:dword_XXXX - { 0x04, 0x8B }, - { 0x05, 0x0D }, - - // D3DDevice_SetRenderState_MultiSampleMode+0x0F : mov edx, [ecx+XXXXh] - { 0x0F, 0x8B }, - { 0x10, 0x91 }, - - // D3DDevice_SetRenderState_MultiSampleMode+0x15 : cmp edx, [ecx+XXXXh] - { 0x15, 0x3B }, - { 0x16, 0x91 }, - - // D3DDevice_SetRenderState_MultiSampleMode+0x1B : jnz short - { 0x1B, 0x75 }, - { 0x1C, 0x07 }, - - // D3DDevice_SetRenderState_MultiSampleMode+0x1D : xor edx, edx - { 0x1D, 0x33 }, - { 0x1E, 0xD2 }, - - // D3DDevice_SetRenderState_MultiSampleMode+0x24 : retn 4 - { 0x24, 0xC2 }, - { 0x25, 0x04 }, - { 0x26, 0x00 }, - // -); - // ****************************************************************** // * D3DDevice_SetRenderTargetFast // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index 20ebc070..57c099b3 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -157,7 +157,6 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_LogicOp, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleAntiAlias, 1024, 1060), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMask, 1024, 1060), // Final generic OOVPA: 4627; Removed: 0 - REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMode, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 1024), // Final generic OOVPA: 4627; Removed: 0 diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index d8c5a6c6..30db7ae2 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -332,8 +332,9 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_LogicOp, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleAntiAlias, 3911, 4627), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMask, 3911, 4627), // Final generic OOVPA: 4627; Removed: 0 - REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMode, 3925, 4034, 4134, 4627, 5233), + REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMode, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 4034), // Was 5233 (from 5344's comment) + REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleType, 3925), // Final generic OOVPA: ???; Removed: 4034 REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_OcclusionCullEnable, 3911, 1024), // Final generic OOVPA: 3911 (LTCG) / 4034 (non-LTCG); Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_PSTextureModes, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index eefcd313..3c4abd35 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -211,7 +211,7 @@ static const RenderStateRevision DxbxRenderStateInfo[] = { /* 151 */ { 3424, 0000 /*, XREF_NAME(D3DRS_EdgeAntiAlias) */ }, // Was D3DRS_EDGEANTIALIAS. Dxbx note : No Xbox ext. (according to Direct3D8) ! /* 152 */ { 3424, 0000, XREF_NAME(D3DRS_MultiSampleAntiAlias) }, // /* 153 */ { 3424, 0000, XREF_NAME(D3DRS_MultiSampleMask) }, // - /* 154 */ { 3424, 4034 /*, XREF_NAME(D3DRS_MultiSampleType) */ }, // Verified present in 3944, removed in 4034. 4034 state based on test-case : The Simpsons Road Rage + /* 154 */ { 3424, 4034, XREF_NAME(D3DRS_MultiSampleType) }, // Verified present in 3944, removed in 4034. 4034 state based on test-case : The Simpsons Road Rage /* 155 */ { 4034, 0000, XREF_NAME(D3DRS_MultiSampleMode) }, // D3DMULTISAMPLEMODE for the backbuffer. Verified absent in 3944, present in 4034. 4034 state based on test-case : The Simpsons Road Rage /* 156 */ { 4034, 0000, XREF_NAME(D3DRS_MultiSampleRenderTargetMode) }, // Verified absent in 3944, present in 4034. Presence in 4034 is based on test-case : The Simpsons Road Rage /* 157 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ShadowFunc) */ }, // diff --git a/src/test/libverify/D3D8.cpp b/src/test/libverify/D3D8.cpp index 73f6ec15..689b1d74 100644 --- a/src/test/libverify/D3D8.cpp +++ b/src/test/libverify/D3D8.cpp @@ -21,6 +21,7 @@ static const library_list database_full = { REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleMask, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleMode, VER_RANGE(4034, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleRenderTargetMode, VER_RANGE(4034, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleType, VER_RANGE(0, 4034, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_OcclusionCullEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_PSTextureModes, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_RopZCmpAlwaysRead, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), @@ -230,8 +231,9 @@ static const library_list database_full = { REGISTER_SYMBOL_INLINE(D3DDevice_SetRenderState_LogicOp, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DDevice_SetRenderState_MultiSampleAntiAlias, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DDevice_SetRenderState_MultiSampleMask, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), - REGISTER_SYMBOL_INLINE(D3DDevice_SetRenderState_MultiSampleMode, VER_RANGE(3925, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DDevice_SetRenderState_MultiSampleMode, VER_RANGE(4034, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, VER_RANGE(4034, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DDevice_SetRenderState_MultiSampleType, VER_RANGE(3911, 4034, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DDevice_SetRenderState_NormalizeNormals, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DDevice_SetRenderState_OcclusionCullEnable, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DDevice_SetRenderState_PSTextureModes, VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)), From cc53667759f3e8848cfdd9b36129baaf4e30b83f Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Fri, 20 Jan 2023 12:46:06 -0600 Subject: [PATCH 27/35] d3d: update D3DDevice_SetRenderState_MultiSampleMode and add D3DDevice_SetRenderState_MultiSampleType sigs Removed: - D3DDevice_SetRenderState_MultiSampleMode (4134, 4627, 5233, 1024) Renamed: - D3DDevice_SetRenderState_MultiSampleMode (3925) to D3DDevice_SetRenderState_MultiSampleType Updated: - D3DDevice_SetRenderState_MultiSampleMode (4034) - D3DDevice_SetRenderState_MultiSampleType (3925) Added: - D3DDevice_SetRenderState_MultiSampleType (3911) --- src/OOVPADatabase/D3D8/3911.inl | 25 +++++++++++++++++++++++++ src/OOVPADatabase/D3D8/3925.inl | 3 ++- src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index ee00b163..e7ed385f 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -5874,3 +5874,28 @@ OOVPA_SIG_MATCH( // ); + +// ****************************************************************** +// * D3DDevice_SetRenderState_MultiSampleType +// ****************************************************************** +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleType, + 3911, + XRefTwo) +OOVPA_SIG_MATCH( + + // mov [D3DRS_MultiSampleType],e?? + XREF_ENTRY(0x0E, XREF_D3DRS_MultiSampleType), + + // call D3DDevice_SetViewport + XREF_ENTRY(0x1F, XREF_D3DDevice_SetViewport), + + // mov ecx,[esp + param_1] + OV_MATCH(0x00, 0x8B, 0x44, 0x24, 0x04), + + // call D3DDevice_SetViewport + OV_MATCH(0x1E, 0xE8), + + // retn 0x04 + OV_MATCH(0x2B, 0xC2, 0x04), + // +); diff --git a/src/OOVPADatabase/D3D8/3925.inl b/src/OOVPADatabase/D3D8/3925.inl index 821804d2..0b469e91 100644 --- a/src/OOVPADatabase/D3D8/3925.inl +++ b/src/OOVPADatabase/D3D8/3925.inl @@ -26,12 +26,13 @@ // ****************************************************************** // * D3DDevice_SetRenderState_MultiSampleType // ****************************************************************** +// Generic OOVPA as of 3925 and newer. OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleType, 3925, XRefTwo) OOVPA_SIG_MATCH( - // mov [D3DRS_MultiSampleType],ecx + // mov [D3DRS_MultiSampleType],e?? XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleType), // call D3DDevice_SetRenderTarget diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index 30db7ae2..33f152a2 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -334,7 +334,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMask, 3911, 4627), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMode, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 4034), // Was 5233 (from 5344's comment) - REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleType, 3925), // Final generic OOVPA: ???; Removed: 4034 + REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleType, 3911, 3925), // Final generic OOVPA: 3925 Removed: 4034 REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_OcclusionCullEnable, 3911, 1024), // Final generic OOVPA: 3911 (LTCG) / 4034 (non-LTCG); Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_PSTextureModes, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 From 801ed6acdcf3a1351d4c426b5834923c1abf9750 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sun, 15 Jan 2023 15:15:36 -0600 Subject: [PATCH 28/35] d3d: update D3DDevice_SetRenderState_TwoSidedLighting signatures Updated: - 3911, 4034, 5344 - 1024, 1036, 1060 Removed: - 1072 Added: - 1061 --- src/OOVPADatabase/D3D8/3911.inl | 37 +++++++++----------- src/OOVPADatabase/D3D8/4034.inl | 29 +++++++++++----- src/OOVPADatabase/D3D8/5344.inl | 37 +++++++++----------- src/OOVPADatabase/D3D8LTCG/3911.inl | 20 ++++++----- src/OOVPADatabase/D3D8LTCG/4039.inl | 17 +++++---- src/OOVPADatabase/D3D8LTCG/4432.inl | 21 ----------- src/OOVPADatabase/D3D8LTCG/5344.inl | 52 ++++++++++++++++------------ src/OOVPADatabase/D3D8LTCG/5849.inl | 3 ++ src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 2 +- src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- 10 files changed, 110 insertions(+), 110 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index e7ed385f..fc78cf97 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -3662,33 +3662,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_TwoSidedLighting // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_TwoSidedLighting, - 3911) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_TwoSidedLighting, + 3911, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_TwoSidedLighting+0x00 : mov eax, [addr] - { 0x00, 0xA1 }, + // mov eax,[D3D_g_pDevice] + XREF_ENTRY(0x01, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_TwoSidedLighting+0x06 : or dword ptr [eax+8], 0x20 - { 0x06, 0x83 }, - { 0x07, 0x48 }, - { 0x08, 0x08 }, - { 0x09, 0x20 }, + // mov [D3DRS_TwoSidedLighting],eax + XREF_ENTRY(0x1D, XREF_D3DRS_TwoSidedLighting), - // D3DDevice_SetRenderState_TwoSidedLighting+0x3B : mov dword ptr [eax], 0x8038C - { 0x3B, 0xC7 }, - { 0x3C, 0x00 }, - { 0x3D, 0x8C }, - { 0x3E, 0x03 }, + // mov eax,[D3D_g_pDevice] + OV_MATCH(0x00, 0xA1), + + // mov e??,[esp + param_1] + OV_MATCH(0x0A, 0x8B), - // D3DDevice_SetRenderState_TwoSidedLighting+0x44 : add eax, 0x0C - { 0x44, 0x83 }, - { 0x45, 0xC0 }, - { 0x46, 0x0C }, + // mov e??,[D3DRS_FillMode] + OV_MATCH(0x0E, 0x8B), - // D3DDevice_SetRenderState_TwoSidedLighting+0x51 : retn 0x04 - { 0x51, 0xC2 }, - { 0x52, 0x04 }, + // mov [D3DRS_TwoSidedLighting],eax + OV_MATCH(0x1C, 0xA3), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index 5a7c3a8c..ae32a6ac 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -676,17 +676,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_TwoSidedLighting // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_TwoSidedLighting, - 4034) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_TwoSidedLighting, + 4034, + XRefTwo) OOVPA_SIG_MATCH( - { 0x0B, 0x8B }, - { 0x18, 0x15 }, - { 0x25, 0x46 }, - { 0x35, 0x8B }, - { 0x43, 0x75 }, - { 0x4C, 0x00 }, - { 0x59, 0x3D }, + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x0D, XREF_D3D_g_pDevice), + + // mov [D3DRS_TwoSidedLighting],eax + XREF_ENTRY(0x1E, XREF_D3DRS_TwoSidedLighting), + + // mov e??,[0x????????] + OV_MATCH(0x00, 0x8B), + + // mov e??,[esp + param_1] + OV_MATCH(0x06, 0x8B), + + // mov e??,[D3D_g_pDevice] + OV_MATCH(0x0B, 0x8B), + + // mov [D3DRS_TwoSidedLighting],eax + OV_MATCH(0x1D, 0xA3), // ); diff --git a/src/OOVPADatabase/D3D8/5344.inl b/src/OOVPADatabase/D3D8/5344.inl index 0cc8eeb0..28ed00b3 100644 --- a/src/OOVPADatabase/D3D8/5344.inl +++ b/src/OOVPADatabase/D3D8/5344.inl @@ -62,31 +62,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_TwoSidedLighting // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_TwoSidedLighting, - 5344) +// Generic OOVPA as of 5344 and newer. +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_TwoSidedLighting, + 5344, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_TwoSidedLighting+0x07 : mov eax, [esi] - { 0x07, 0x8B }, - { 0x08, 0x06 }, + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_TwoSidedLighting+0x09 : cmp eax, [esi+4] - { 0x09, 0x3B }, - { 0x0A, 0x46 }, - { 0x0B, 0x04 }, - - // *** - // D3DDevice_SetRenderState_TwoSidedLighting+0x18 : mov dword ptr [eax], 417C4h - { 0x18, 0xC7 }, - { 0x19, 0x00 }, - { 0x1A, 0xC4 }, - { 0x1B, 0x17 }, - { 0x1C, 0x04 }, - { 0x1D, 0x00 }, + // mov [D3DRS_TwoSidedLighting],eax + XREF_ENTRY(0x42, XREF_D3DRS_TwoSidedLighting), + + // mov e??,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B), + + // mov e??,[esp + param_1] + OV_MATCH(0x14, 0x8B), - // D3DDevice_SetRenderState_TwoSidedLighting+0x7D : retn 0x04 - { 0x7D, 0xC2 }, - { 0x7E, 0x04 }, + // mov [D3DRS_TwoSidedLighting],e?? + OV_MATCH(0x40, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index 0cb95f60..b5d774f4 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -530,21 +530,25 @@ OOVPA_SIG_MATCH( //****************************************************************** //* D3DDevice_SetRenderState_TwoSidedLighting //****************************************************************** -//834808208B OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_TwoSidedLighting, 1024, - XRefOne) + XRefTwo) OOVPA_SIG_MATCH( + // mov eax,[D3D_g_pDevice] + XREF_ENTRY(0x01, XREF_D3D_g_pDevice), + + // mov [D3DRS_TwoSidedLighting],eax XREF_ENTRY(0x15, XREF_D3DRS_TwoSidedLighting), - { 0x00, 0xA1 }, + // mov eax,[D3D_g_pDevice] + OV_MATCH(0x00, 0xA1), + + // mov e??,[esp + param_1] + OV_MATCH(0x09, 0x8B), - { 0x05, 0x83 }, - { 0x06, 0x48 }, - { 0x07, 0x08 }, - { 0x08, 0x20 }, - { 0x09, 0x8B }, + // mov [D3DRS_TwoSidedLighting],eax + OV_MATCH(0x14, 0xA3), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4039.inl b/src/OOVPADatabase/D3D8LTCG/4039.inl index 0181de68..8f7ec816 100644 --- a/src/OOVPADatabase/D3D8LTCG/4039.inl +++ b/src/OOVPADatabase/D3D8LTCG/4039.inl @@ -465,15 +465,20 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_TwoSidedLighting, XRefTwo) OOVPA_SIG_MATCH( + // mov e??,[D3DRS_FillMode] XREF_ENTRY(0x18, XREF_D3DRS_FillMode), + + // mov [D3DRS_TwoSidedLighting],e?? XREF_ENTRY(0x1D, XREF_D3DRS_TwoSidedLighting), - { 0x00, 0x8B }, - { 0x06, 0x8B }, - { 0x07, 0x44 }, - { 0x08, 0x24 }, - { 0x09, 0x04 }, - { 0x25, 0xE9 }, + // mov e??,[0x????????] + OV_MATCH(0x00, 0x8B), + + // mov e??,[esp + param_1] + OV_MATCH(0x06, 0x8B), + + // mov e??,[D3DRS_FillMode] + OV_MATCH(0x16, 0x8B), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4432.inl b/src/OOVPADatabase/D3D8LTCG/4432.inl index 5821264f..70410cac 100644 --- a/src/OOVPADatabase/D3D8LTCG/4432.inl +++ b/src/OOVPADatabase/D3D8LTCG/4432.inl @@ -341,27 +341,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_TwoSidedLighting -// ****************************************************************** -//81CA001000008915 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_TwoSidedLighting, - 1048) -OOVPA_SIG_MATCH( - - { 0x01, 0x15 }, - - { 0x11, 0x81 }, - { 0x12, 0xCA }, - { 0x13, 0x00 }, - { 0x14, 0x10 }, - { 0x15, 0x00 }, - { 0x16, 0x00 }, - { 0x17, 0x89 }, - { 0x18, 0x15 }, - // -); - // ****************************************************************** // * D3DDevice_SetRenderState_LogicOp // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG/5344.inl b/src/OOVPADatabase/D3D8LTCG/5344.inl index 82a03202..1f219c35 100644 --- a/src/OOVPADatabase/D3D8LTCG/5344.inl +++ b/src/OOVPADatabase/D3D8LTCG/5344.inl @@ -175,40 +175,48 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_TwoSidedLighting // ****************************************************************** -//C700C417040089 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_TwoSidedLighting, - 1060) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_TwoSidedLighting, + 1060, + XRefOne) OOVPA_SIG_MATCH( - { 0x01, 0x8B }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), - { 0x20, 0xC7 }, - { 0x21, 0x00 }, - { 0x22, 0xC4 }, - { 0x23, 0x17 }, - { 0x24, 0x04 }, - { 0x25, 0x00 }, - { 0x26, 0x89 }, + // jz +0x0A + OV_MATCH(0x31, 0x74, 0x0A), + // or [0x????????],0x900000 + OV_MATCH(0x33, 0x81), + OV_MATCH(0x38, 0x00, 0x00, 0x90, 0x00, 0x00), // unique // ); // ****************************************************************** // * D3DDevice_SetRenderState_TwoSidedLighting // ****************************************************************** -//C700C417040089 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_TwoSidedLighting, - 1072) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_TwoSidedLighting, + 1061, + XRefOne) OOVPA_SIG_MATCH( - { 0x01, 0x8B }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), - { 0x21, 0xC7 }, - { 0x22, 0x00 }, - { 0x23, 0xC4 }, - { 0x24, 0x17 }, - { 0x25, 0x04 }, - { 0x26, 0x00 }, - { 0x27, 0x89 }, + // jz +0x0A + OV_MATCH(0x32, 0x74, 0x0A), + // or [0x????????],0x900000 + OV_MATCH(0x34, 0x81), + OV_MATCH(0x39, 0x00, 0x00, 0x90, 0x00, 0x00), // unique // ); diff --git a/src/OOVPADatabase/D3D8LTCG/5849.inl b/src/OOVPADatabase/D3D8LTCG/5849.inl index 09107a13..67f70767 100644 --- a/src/OOVPADatabase/D3D8LTCG/5849.inl +++ b/src/OOVPADatabase/D3D8LTCG/5849.inl @@ -256,6 +256,9 @@ OOVPA_SIG_MATCH( // * D3DDevice_SetRenderState_TwoSidedLighting // ****************************************************************** //C700C417040089 +// TODO: Find title match with this signature. If there are absolutely +// none, then delete it from database. Otherwise, try reuse pattern +// from LTCG 5344's signatures. OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_TwoSidedLighting, 1084) OOVPA_SIG_MATCH( diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index 57c099b3..2d6ac580 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -164,7 +164,7 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilEnable, 1024, 1036, 1048, 1060, 1072, 1084), REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilFail, 1024, 1036, 1048, 1060, 1072, 1084), REGISTER_OOVPAS(D3DDevice_SetRenderState_TextureFactor, 1036), - REGISTER_OOVPAS(D3DDevice_SetRenderState_TwoSidedLighting, 1024, 1036, 1048, 1060, 1072, 1084), + REGISTER_OOVPAS(D3DDevice_SetRenderState_TwoSidedLighting, 1024, 1036, 1060, 1061, 1084), REGISTER_OOVPAS(D3DDevice_SetRenderState_VertexBlend, 1024, 1036, 1048), REGISTER_OOVPAS(D3DDevice_SetRenderState_ZBias, 1024, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_ZEnable, 1024, 1036, 1048, 1060), diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index 33f152a2..306ca979 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -346,7 +346,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilEnable, 3911, 4034, 5849), REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilFail, 3911, 4034, 5849), REGISTER_OOVPAS(D3DDevice_SetRenderState_TextureFactor, 3911, 4034), - REGISTER_OOVPAS(D3DDevice_SetRenderState_TwoSidedLighting, 3911, 4034, 5344), // Beware of the typo... (from 4627's comment) + REGISTER_OOVPAS(D3DDevice_SetRenderState_TwoSidedLighting, 3911, 4034, 5344), // Final generic OOVPA: 5344; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_VertexBlend, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_YuvEnable, 3911, 1024), // Final generic OOVPA: 3911 (LTCG) / 4034 (non-LTCG); Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_ZBias, 3911), // Final generic OOVPA: 3911; Removed: 0 From feb674700b6fb96494bc684e64ab79ba9c517577 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 17 Jan 2023 13:43:02 -0600 Subject: [PATCH 29/35] d3d: update D3DDevice_SetRenderState_CullMode signatures to use unique asm --- src/OOVPADatabase/D3D8/3911.inl | 38 +++++++++-------------------- src/OOVPADatabase/D3D8/4034.inl | 37 +++++++++------------------- src/OOVPADatabase/D3D8LTCG/3911.inl | 21 ++++++++-------- src/OOVPADatabase/D3D8LTCG/4039.inl | 21 ++++++++-------- src/OOVPADatabase/D3D8LTCG/4432.inl | 21 ++++++++-------- src/OOVPADatabase/D3D8LTCG/5788.inl | 21 ++++++++-------- src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- 7 files changed, 68 insertions(+), 93 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index fc78cf97..8a0705e8 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -1239,35 +1239,19 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_CullMode, XRefTwo) OOVPA_SIG_MATCH( - XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - - XREF_ENTRY(0x25, XREF_D3DRS_CullMode), // Derived + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_CullMode],e?? + XREF_ENTRY(0x25, XREF_D3DRS_CullMode), - // D3DDevice_SetRenderState_CullMode+0x00 : push esi - { 0x00, 0x56 }, + // push esi + OV_MATCH(0x00, 0x56), - // D3DDevice_SetRenderState_CullMode+0x42 : mov dword ptr [eax+8], 0x4039C - { 0x42, 0xC7 }, - { 0x43, 0x40 }, - { 0x44, 0x08 }, - { 0x45, 0x9C }, - { 0x46, 0x03 }, - { 0x47, 0x04 }, - - // D3DDevice_SetRenderState_CullMode+0x49 : add eax, 0x10 - { 0x49, 0x83 }, - { 0x4A, 0xC0 }, - { 0x4B, 0x10 }, - - // D3DDevice_SetRenderState_CullMode+0x4D : add edx, 0x404 - { 0x4D, 0x81 }, - { 0x4E, 0xC2 }, - { 0x4F, 0x04 }, - { 0x50, 0x04 }, - - // D3DDevice_SetRenderState_CullMode+0x5F : retn 4 - { 0x5F, 0xC2 }, - { 0x60, 0x04 }, + // unique + // mov [eax],0x40308 + OV_MATCH(0x13, 0xC7, 0x00, 0x08, 0x03, 0x04, 0x00), + // jnz +0x?? + OV_MATCH(0x19, 0x75), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index ae32a6ac..9e763a7d 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -219,38 +219,25 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_CullMode // ****************************************************************** +// Generic OOVPA as of 4034 and newer. OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_CullMode, 4034, XRefTwo) OOVPA_SIG_MATCH( - XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - - XREF_ENTRY(0x2B, XREF_D3DRS_CullMode), // Derived - - // D3DDevice_SetRenderState_CullMode+0x00 : push esi - { 0x00, 0x56 }, - - // D3DDevice_SetRenderState_CullMode+0x19 : mov dword ptr [eax], 0x40308 - { 0x19, 0xC7 }, - { 0x1B, 0x08 }, - { 0x1C, 0x03 }, - { 0x1D, 0x04 }, - - // D3DDevice_SetRenderState_CullMode+0x24 : add eax, 8 - { 0x24, 0x83 }, - { 0x25, 0xC0 }, - { 0x26, 0x08 }, + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_CullMode],e?? + XREF_ENTRY(0x2B, XREF_D3DRS_CullMode), - // D3DDevice_SetRenderState_CullMode+0x30 : retn 4 - { 0x30, 0xC2 }, - { 0x31, 0x04 }, + // push esi + OV_MATCH(0x00, 0x56), - // D3DDevice_SetRenderState_CullMode+0x53 : add edx, 0x404 - { 0x53, 0x81 }, - { 0x54, 0xC2 }, - { 0x55, 0x04 }, - { 0x56, 0x04 }, + // unique + // mov [eax],0x40308 + OV_MATCH(0x19, 0xC7, 0x00, 0x08, 0x03, 0x04, 0x00), + // jnz +0x?? + OV_MATCH(0x1F, 0x75), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index b5d774f4..c28dceef 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -54,18 +54,19 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_CullMode, XRefTwo) OOVPA_SIG_MATCH( - XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - XREF_ENTRY(0x2D, XREF_D3DRS_CullMode), // Derived + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_CullMode],e?? + XREF_ENTRY(0x2D, XREF_D3DRS_CullMode), - { 0x00, 0x56 }, + // push esi + OV_MATCH(0x00, 0x56), - { 0x1B, 0xC7 }, - { 0x1C, 0x00 }, - { 0x1D, 0x08 }, - { 0x1E, 0x03 }, - { 0x1F, 0x04 }, - { 0x20, 0x00 }, - { 0x21, 0x75 }, + // unique + // mov [eax],0x40308 + OV_MATCH(0x1B, 0xC7, 0x00, 0x08, 0x03, 0x04, 0x00), + // jnz +0x?? + OV_MATCH(0x21, 0x75), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4039.inl b/src/OOVPADatabase/D3D8LTCG/4039.inl index 8f7ec816..3f60788f 100644 --- a/src/OOVPADatabase/D3D8LTCG/4039.inl +++ b/src/OOVPADatabase/D3D8LTCG/4039.inl @@ -147,18 +147,19 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_CullMode, XRefTwo) OOVPA_SIG_MATCH( - XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - XREF_ENTRY(0x31, XREF_D3DRS_CullMode), // Derived + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_CullMode],e?? + XREF_ENTRY(0x31, XREF_D3DRS_CullMode), - { 0x00, 0x56 }, + // push esi + OV_MATCH(0x00, 0x56), - { 0x1F, 0xC7 }, - { 0x20, 0x00 }, - { 0x21, 0x08 }, - { 0x22, 0x03 }, - { 0x23, 0x04 }, - { 0x24, 0x00 }, - { 0x25, 0x75 }, + // unique + // mov [eax],0x40308 + OV_MATCH(0x1F, 0xC7, 0x00, 0x08, 0x03, 0x04, 0x00), + // jnz +0x?? + OV_MATCH(0x25, 0x75), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4432.inl b/src/OOVPADatabase/D3D8LTCG/4432.inl index 70410cac..edc898e7 100644 --- a/src/OOVPADatabase/D3D8LTCG/4432.inl +++ b/src/OOVPADatabase/D3D8LTCG/4432.inl @@ -121,18 +121,19 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_CullMode, XRefTwo) OOVPA_SIG_MATCH( - XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - XREF_ENTRY(0x34, XREF_D3DRS_CullMode), // Derived + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_CullMode],e?? + XREF_ENTRY(0x34, XREF_D3DRS_CullMode), - { 0x00, 0x56 }, + // push esi + OV_MATCH(0x00, 0x56), - { 0x22, 0xC7 }, - { 0x23, 0x00 }, - { 0x24, 0x08 }, - { 0x25, 0x03 }, - { 0x26, 0x04 }, - { 0x27, 0x00 }, - { 0x28, 0x75 }, + // unique + // mov [eax],0x40308 + OV_MATCH(0x22, 0xC7, 0x00, 0x08, 0x03, 0x04, 0x00), + // jnz +0x?? + OV_MATCH(0x28, 0x75), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/5788.inl b/src/OOVPADatabase/D3D8LTCG/5788.inl index 0f2566b6..7896c828 100644 --- a/src/OOVPADatabase/D3D8LTCG/5788.inl +++ b/src/OOVPADatabase/D3D8LTCG/5788.inl @@ -177,18 +177,19 @@ OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_CullMode, XRefTwo) OOVPA_SIG_MATCH( - XREF_ENTRY(0x03, XREF_D3D_g_pDevice), // Derived - XREF_ENTRY(0x35, XREF_D3DRS_CullMode), // Derived + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_CullMode],e?? + XREF_ENTRY(0x35, XREF_D3DRS_CullMode), - { 0x00, 0x56 }, + // push esi + OV_MATCH(0x00, 0x56), - { 0x23, 0xC7 }, - { 0x24, 0x00 }, - { 0x25, 0x08 }, - { 0x26, 0x03 }, - { 0x27, 0x04 }, - { 0x28, 0x00 }, - { 0x29, 0x75 }, + // unique + // mov [eax],0x40308 + OV_MATCH(0x23, 0xC7, 0x00, 0x08, 0x03, 0x04, 0x00), + // jnz +0x?? + OV_MATCH(0x29, 0x75), // ); diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index 306ca979..f1be9c73 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -320,7 +320,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState2, 3911), // Final generic OOVPA: 3911; Removed: 0 // NOTE: There is a verified duplicate function. REGISTER_OOVPAS(D3DDevice_SetRenderState_BackFillMode, 3911, 4034), - REGISTER_OOVPAS_C(D3DDevice_SetRenderState_CullMode, 3911, 4034), + REGISTER_OOVPAS_C(D3DDevice_SetRenderState_CullMode, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_Deferred, 3911), REGISTER_OOVPAS(D3DDevice_SetRenderState_DoNotCullUncompressed, 3911), // Final generic OOVPA: 3911; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_Dxt1NoiseEnable, 3911), // Final generic OOVPA: 3911; Removed: 0 From e7632607b16916ce148ad48b3e74a351970aa2db Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 17 Jan 2023 15:00:17 -0600 Subject: [PATCH 30/35] d3d: update D3DDevice_SetRenderState_LogicOp signatures --- src/OOVPADatabase/D3D8/3911.inl | 31 +++++++++++++---------------- src/OOVPADatabase/D3D8/4034.inl | 26 +++++++++++++++--------- src/OOVPADatabase/D3D8LTCG/3911.inl | 25 +++++++++++++---------- src/OOVPADatabase/D3D8LTCG/4039.inl | 25 +++++++++++++---------- src/OOVPADatabase/D3D8LTCG/4432.inl | 25 +++++++++++++---------- src/OOVPADatabase/D3D8LTCG/5788.inl | 25 +++++++++++++---------- src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- 7 files changed, 88 insertions(+), 71 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 8a0705e8..c7b86bef 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -3756,27 +3756,24 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_LogicOp // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_LogicOp, - 3911) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_LogicOp, + 3911, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_LogicOp+0x00 : push esi - { 0x00, 0x56 }, - - // D3DDevice_SetRenderState_LogicOp+0x11 : test ecx, ecx - { 0x11, 0x85 }, - { 0x12, 0xC9 }, + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_LogicOp],e?? + XREF_ENTRY(0x25, XREF_D3DRS_LogicOp), - // D3DDevice_SetRenderState_LogicOp+0x2D : mov dword ptr [eax], 0x817BC - { 0x2D, 0xC7 }, - { 0x2E, 0x00 }, - { 0x2F, 0xBC }, - { 0x30, 0x17 }, - { 0x31, 0x08 }, + // push esi + OV_MATCH(0x00, 0x56), - // D3DDevice_SetRenderState_LogicOp+0x49 : retn 0x04 - { 0x49, 0xC2 }, - { 0x4A, 0x04 }, + // jnz +0x?? + OV_MATCH(0x13, 0x75), + // unique + // mov [eax],0x417bc + OV_MATCH(0x15, 0xC7, 0x00, 0xBC, 0x17, 0x04, 0x00), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index 9e763a7d..702d144b 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -577,17 +577,25 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_LogicOp // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_LogicOp, - 4034) +// Generic OOVPA as of 4034 and newer. +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_LogicOp, + 4034, + XRefTwo) OOVPA_SIG_MATCH( - { 0x09, 0x3B }, - { 0x14, 0x4C }, - { 0x1F, 0x04 }, - { 0x2A, 0x0D }, - { 0x35, 0xBC }, - { 0x40, 0x89 }, - { 0x4E, 0x5E }, + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_LogicOp],e?? + XREF_ENTRY(0x2B, XREF_D3DRS_LogicOp), + + // push esi + OV_MATCH(0x00, 0x56), + + // jnz +0x?? + OV_MATCH(0x19, 0x75), + // unique + // mov [eax],0x417bc + OV_MATCH(0x1B, 0xC7, 0x00, 0xBC, 0x17, 0x04, 0x00), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index c28dceef..6b25c83e 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -471,21 +471,24 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_LogicOp // ****************************************************************** -//18C700BC1704 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_LogicOp, - 1024) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_LogicOp, + 1024, + XRefTwo) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x2D, XREF_D3DRS_LogicOp ), + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_LogicOp],e?? + XREF_ENTRY(0x2D, XREF_D3DRS_LogicOp), - { 0x01, 0x8B }, + // push esi + OV_MATCH(0x00, 0x56), - { 0x1C, 0x18 }, - { 0x1D, 0xC7 }, - { 0x1E, 0x00 }, - { 0x1F, 0xBC }, - { 0x20, 0x17 }, - { 0x21, 0x04 }, + // jnz +0x?? + OV_MATCH(0x1B, 0x75), + // unique + // mov [eax],0x417bc + OV_MATCH(0x1D, 0xC7, 0x00, 0xBC, 0x17, 0x04, 0x00), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4039.inl b/src/OOVPADatabase/D3D8LTCG/4039.inl index 3f60788f..c60cf253 100644 --- a/src/OOVPADatabase/D3D8LTCG/4039.inl +++ b/src/OOVPADatabase/D3D8LTCG/4039.inl @@ -486,21 +486,24 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_LogicOp // ****************************************************************** -//18C700BC1704 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_LogicOp, - 1036) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_LogicOp, + 1036, + XRefTwo) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x34, XREF_D3DRS_LogicOp ), + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_LogicOp],e?? + XREF_ENTRY(0x31, XREF_D3DRS_LogicOp), - { 0x01, 0x8B }, + // push esi + OV_MATCH(0x00, 0x56), - { 0x20, 0x18 }, - { 0x21, 0xC7 }, - { 0x22, 0x00 }, - { 0x23, 0xBC }, - { 0x24, 0x17 }, - { 0x25, 0x04 }, + // jnz +0x?? + OV_MATCH(0x1F, 0x75), + // unique + // mov [eax],0x417bc + OV_MATCH(0x21, 0xC7, 0x00, 0xBC, 0x17, 0x04, 0x00), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4432.inl b/src/OOVPADatabase/D3D8LTCG/4432.inl index edc898e7..1ab1331b 100644 --- a/src/OOVPADatabase/D3D8LTCG/4432.inl +++ b/src/OOVPADatabase/D3D8LTCG/4432.inl @@ -345,21 +345,24 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_LogicOp // ****************************************************************** -//18C700BC1704 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_LogicOp, - 1048) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_LogicOp, + 1048, + XRefTwo) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x34, XREF_D3DRS_LogicOp ), + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_LogicOp],e?? + XREF_ENTRY(0x34, XREF_D3DRS_LogicOp), - { 0x01, 0x8B }, + // push esi + OV_MATCH(0x00, 0x56), - { 0x23, 0x18 }, - { 0x24, 0xC7 }, - { 0x25, 0x00 }, - { 0x26, 0xBC }, - { 0x27, 0x17 }, - { 0x28, 0x04 }, + // jnz +0x?? + OV_MATCH(0x22, 0x75), + // unique + // mov [eax],0x417bc + OV_MATCH(0x24, 0xC7, 0x00, 0xBC, 0x17, 0x04, 0x00), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/5788.inl b/src/OOVPADatabase/D3D8LTCG/5788.inl index 7896c828..390b3229 100644 --- a/src/OOVPADatabase/D3D8LTCG/5788.inl +++ b/src/OOVPADatabase/D3D8LTCG/5788.inl @@ -292,21 +292,24 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_LogicOp // ****************************************************************** -//18C700BC1704 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_LogicOp, - 1060) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_LogicOp, + 1060, + XRefTwo) OOVPA_SIG_MATCH( - // XREF_ENTRY( 0x34, XREF_D3DRS_LogicOp ), + // mov e??,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // mov [D3DRS_LogicOp],e?? + XREF_ENTRY(0x35, XREF_D3DRS_LogicOp), - { 0x01, 0x8B }, + // push esi + OV_MATCH(0x00, 0x56), - { 0x24, 0x18 }, - { 0x25, 0xC7 }, - { 0x26, 0x00 }, - { 0x27, 0xBC }, - { 0x28, 0x17 }, - { 0x29, 0x04 }, + // jnz +0x?? + OV_MATCH(0x23, 0x75), + // unique + // mov [eax],0x417bc + OV_MATCH(0x25, 0xC7, 0x00, 0xBC, 0x17, 0x04, 0x00), // ); diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index f1be9c73..d1e69932 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -329,7 +329,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_FogColor, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_FrontFace, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_LineWidth, 3911, 4034), - REGISTER_OOVPAS(D3DDevice_SetRenderState_LogicOp, 3911, 4034), + REGISTER_OOVPAS(D3DDevice_SetRenderState_LogicOp, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleAntiAlias, 3911, 4627), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMask, 3911, 4627), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMode, 4034), // Final generic OOVPA: 4034; Removed: 0 From 01ad3acbc6ccfedc7f77e1879125a29ddcc73576 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Fri, 20 Jan 2023 03:13:32 -0600 Subject: [PATCH 31/35] d3d: update D3DDevice_SetRenderState_StencilEnable signatures Removed: - 1072, 1084 Updated: - 3911, 4034, 5849, 1024, 1036, 1048, 1060 --- src/OOVPADatabase/D3D8/3911.inl | 35 +++++++++++------------ src/OOVPADatabase/D3D8/4034.inl | 30 +++++++++++++------- src/OOVPADatabase/D3D8/5849.inl | 31 ++++++++++++-------- src/OOVPADatabase/D3D8LTCG/3911.inl | 34 ++++++++++++---------- src/OOVPADatabase/D3D8LTCG/4039.inl | 32 ++++++++++++--------- src/OOVPADatabase/D3D8LTCG/4432.inl | 32 ++++++++++++--------- src/OOVPADatabase/D3D8LTCG/5788.inl | 34 ++++++++++++---------- src/OOVPADatabase/D3D8LTCG/5849.inl | 42 ---------------------------- src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 2 +- 9 files changed, 136 insertions(+), 136 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index c7b86bef..2ae0663c 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -2700,29 +2700,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilEnable // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilEnable, - 3911) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilEnable, + 3911, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_StencilEnable+0x00 : push esi - { 0x00, 0x56 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_StencilEnable+0x45 : mov dword ptr [eax], 0x41D84 - { 0x45, 0xC7 }, - { 0x46, 0x00 }, - { 0x47, 0x84 }, - { 0x48, 0x1D }, - { 0x49, 0x04 }, - { 0x4A, 0x00 }, + // mov [D3DRS_StencilEnable],e?? + XREF_ENTRY(0x78, XREF_D3DRS_StencilEnable), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), - // D3DDevice_SetRenderState_StencilEnable+0x71 : add eax, 0x08 - { 0x71, 0x83 }, - { 0x72, 0xC0 }, - { 0x73, 0x08 }, + // mov [e??],0x4032C + OV_MATCH(0x68, 0xC7), + OV_MATCH(0x6A, 0x2C, 0x03, 0x04, 0x00), - // D3DDevice_SetRenderState_StencilEnable+0x7D : retn 0x04 - { 0x7D, 0xC2 }, - { 0x7E, 0x04 }, + // mov [D3DRS_StencilEnable],e?? + OV_MATCH(0x76, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index 702d144b..f4bb0cac 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -636,18 +636,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilEnable // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilEnable, - 4034) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilEnable, + 4034, + XRefTwo) OOVPA_SIG_MATCH( - { 0x00, 0x56 }, - { 0x13, 0x8B }, - { 0x20, 0x02 }, - { 0x34, 0x85 }, - { 0x42, 0x75 }, - { 0x53, 0x89 }, - { 0x64, 0x00 }, - { 0x75, 0x83 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // mov [D3DRS_StencilEnable],e?? + XREF_ENTRY(0x7C, XREF_D3DRS_StencilEnable), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov [e?? + 0x8],0x4032C + OV_MATCH(0x6B, 0xC7), + OV_MATCH(0x6D, 0x08, 0x2C, 0x03, 0x04, 0x00), + + // mov [D3DRS_StencilEnable],e?? + OV_MATCH(0x7A, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8/5849.inl b/src/OOVPADatabase/D3D8/5849.inl index c59836f9..e893fac0 100644 --- a/src/OOVPADatabase/D3D8/5849.inl +++ b/src/OOVPADatabase/D3D8/5849.inl @@ -26,19 +26,28 @@ // ****************************************************************** // * D3DDevice_SetRenderState_StencilEnable // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilEnable, - 5849) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilEnable, + 5849, + XRefTwo) OOVPA_SIG_MATCH( - { 0x12, 0x8B }, - { 0x24, 0x33 }, - { 0x37, 0x74 }, - { 0x4A, 0x1E }, - { 0x5D, 0x74 }, - { 0x70, 0xB9 }, - { 0x83, 0x40 }, - { 0x96, 0x04 }, - // + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // [D3DRS_StencilEnable],e?? + XREF_ENTRY(0x0E, XREF_D3DRS_StencilEnable), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov e??,[esp + param_1] + OV_MATCH(0x08, 0x8B), + OV_MATCH(0x0A, 0x24, 0x0C), + + // [D3DRS_StencilEnable],e?? + OV_MATCH(0x0C, 0x89), + // Do NOT use any offsets after 0x1D ); // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index 6b25c83e..4d50e240 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -599,22 +599,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilEnable // ****************************************************************** -//018b54240885d2c700 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilEnable, - 1024) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilEnable, + 1024, + XRefTwo) OOVPA_SIG_MATCH( - { 0x02, 0x35 }, - - { 0x48, 0x01 }, - { 0x49, 0x8B }, - { 0x4A, 0x54 }, - { 0x4B, 0x24 }, - { 0x4C, 0x08 }, - { 0x4D, 0x85 }, - { 0x4E, 0xD2 }, - { 0x4F, 0xC7 }, - { 0x50, 0x00 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // mov [D3DRS_StencilEnable],e?? + XREF_ENTRY(0x7E, XREF_D3DRS_StencilEnable), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov [e?? + 0x8],0x4032C + OV_MATCH(0x6D, 0xC7), + OV_MATCH(0x6F, 0x08, 0x2C, 0x03, 0x04, 0x00), + + // mov [D3DRS_StencilEnable],e?? + OV_MATCH(0x7C, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4039.inl b/src/OOVPADatabase/D3D8LTCG/4039.inl index c60cf253..ab5aff5c 100644 --- a/src/OOVPADatabase/D3D8LTCG/4039.inl +++ b/src/OOVPADatabase/D3D8LTCG/4039.inl @@ -209,22 +209,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilEnable // ****************************************************************** -//018b54240885d2c700 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilEnable, - 1036) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilEnable, + 1036, + XRefTwo) OOVPA_SIG_MATCH( - { 0x02, 0x35 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), - { 0x4C, 0x01 }, - { 0x4D, 0x8B }, - { 0x4E, 0x54 }, - { 0x4F, 0x24 }, - { 0x50, 0x08 }, - { 0x51, 0x85 }, - { 0x52, 0xD2 }, - { 0x53, 0xC7 }, - { 0x54, 0x00 }, + // mov [D3DRS_StencilEnable],e?? + XREF_ENTRY(0x82, XREF_D3DRS_StencilEnable), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov [e?? + 0x8],0x4032C + OV_MATCH(0x71, 0xC7), + OV_MATCH(0x73, 0x08, 0x2C, 0x03, 0x04, 0x00), + + // mov [D3DRS_StencilEnable],e?? + OV_MATCH(0x80, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4432.inl b/src/OOVPADatabase/D3D8LTCG/4432.inl index 1ab1331b..5e707885 100644 --- a/src/OOVPADatabase/D3D8LTCG/4432.inl +++ b/src/OOVPADatabase/D3D8LTCG/4432.inl @@ -185,22 +185,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilEnable // ****************************************************************** -//018b54240885d2c700 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilEnable, - 1048) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilEnable, + 1048, + XRefTwo) OOVPA_SIG_MATCH( - { 0x02, 0x35 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // mov [D3DRS_StencilEnable],e?? + XREF_ENTRY(0x85, XREF_D3DRS_StencilEnable), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov [e?? + 0x8],0x4032C + OV_MATCH(0x74, 0xC7), + OV_MATCH(0x76, 0x08, 0x2C, 0x03, 0x04, 0x00), - { 0x4F, 0x01 }, - { 0x50, 0x8B }, - { 0x51, 0x54 }, - { 0x52, 0x24 }, - { 0x53, 0x08 }, - { 0x54, 0x85 }, - { 0x55, 0xD2 }, - { 0x56, 0xC7 }, - { 0x57, 0x00 }, + // mov [D3DRS_StencilEnable],e?? + OV_MATCH(0x83, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/5788.inl b/src/OOVPADatabase/D3D8LTCG/5788.inl index 390b3229..333319e5 100644 --- a/src/OOVPADatabase/D3D8LTCG/5788.inl +++ b/src/OOVPADatabase/D3D8LTCG/5788.inl @@ -356,22 +356,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilEnable // ****************************************************************** -//018b54240885d2c700 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilEnable, - 1060) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilEnable, + 1060, + XRefTwo) OOVPA_SIG_MATCH( - { 0x02, 0x35 }, - - { 0x50, 0x01 }, - { 0x51, 0x8B }, - { 0x52, 0x54 }, - { 0x53, 0x24 }, - { 0x54, 0x08 }, - { 0x55, 0x85 }, - { 0x56, 0xD2 }, - { 0x57, 0xC7 }, - { 0x58, 0x00 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // mov [D3DRS_StencilEnable],e?? + XREF_ENTRY(0x86, XREF_D3DRS_StencilEnable), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov [e?? + 0x8],0x4032C + OV_MATCH(0x75, 0xC7), + OV_MATCH(0x77, 0x08, 0x2C, 0x03, 0x04, 0x00), + + // mov [D3DRS_StencilEnable],e?? + OV_MATCH(0x84, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/5849.inl b/src/OOVPADatabase/D3D8LTCG/5849.inl index 67f70767..1a2e20d9 100644 --- a/src/OOVPADatabase/D3D8LTCG/5849.inl +++ b/src/OOVPADatabase/D3D8LTCG/5849.inl @@ -89,48 +89,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_StencilEnable -// ****************************************************************** -//85FFC700841D0400 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilEnable, - 1072) -OOVPA_SIG_MATCH( - - { 0x00, 0x56 }, - { 0x02, 0x35 }, - - { 0x5C, 0x85 }, - { 0x5D, 0xFF }, - { 0x5E, 0xC7 }, - { 0x5F, 0x00 }, - { 0x60, 0x84 }, - { 0x61, 0x1D }, - { 0x62, 0x04 }, - // -); - -// ****************************************************************** -// * D3DDevice_SetRenderState_StencilEnable -// ****************************************************************** -//85FFC700841D0400 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilEnable, - 1084) -OOVPA_SIG_MATCH( - - { 0x00, 0x56 }, - { 0x02, 0x35 }, - - { 0x5B, 0x85 }, - { 0x5C, 0xFF }, - { 0x5D, 0xC7 }, - { 0x5E, 0x00 }, - { 0x5F, 0x84 }, - { 0x60, 0x1D }, - { 0x61, 0x04 }, - // -); - // ****************************************************************** // * D3DTexture_GetLevelDesc // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index 2d6ac580..9dbd16f4 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -161,7 +161,7 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 1024), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_ShadowFunc, 1024, 1036, 1048, 1060), - REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilEnable, 1024, 1036, 1048, 1060, 1072, 1084), + REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilEnable, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilFail, 1024, 1036, 1048, 1060, 1072, 1084), REGISTER_OOVPAS(D3DDevice_SetRenderState_TextureFactor, 1036), REGISTER_OOVPAS(D3DDevice_SetRenderState_TwoSidedLighting, 1024, 1036, 1060, 1061, 1084), From 9a3206482fac81978f1b755e2865780c56040ac9 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Fri, 20 Jan 2023 03:14:56 -0600 Subject: [PATCH 32/35] d3d: update D3DDevice_SetRenderState_StencilFail signatures Removed: - 1072, 1084 Updated: - 3911, 4034, 5849, 1024, 1036, 1048, 1060 --- src/OOVPADatabase/D3D8/3911.inl | 36 +++++++++++++------------- src/OOVPADatabase/D3D8/4034.inl | 29 ++++++++++++++------- src/OOVPADatabase/D3D8/5849.inl | 31 +++++++++++++++-------- src/OOVPADatabase/D3D8LTCG/3911.inl | 29 +++++++++++++-------- src/OOVPADatabase/D3D8LTCG/4039.inl | 29 +++++++++++++-------- src/OOVPADatabase/D3D8LTCG/4432.inl | 29 +++++++++++++-------- src/OOVPADatabase/D3D8LTCG/5788.inl | 29 +++++++++++++-------- src/OOVPADatabase/D3D8LTCG/5849.inl | 38 ---------------------------- src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 2 +- 9 files changed, 134 insertions(+), 118 deletions(-) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 2ae0663c..180a073a 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -2487,30 +2487,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilFail // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilFail, - 3911) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilFail, + 3911, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_StencilFail+0x00 : push esi - { 0x00, 0x56 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_StencilFail+0x19 : mov ecx, 2 - { 0x19, 0xB9 }, - { 0x1A, 0x02 }, - { 0x1B, 0x00 }, + // mov [D3DRS_StencilFail],e?? + XREF_ENTRY(0x61, XREF_D3DRS_StencilFail), - // D3DDevice_SetRenderState_StencilFail+0x3E : or ecx, 1 - { 0x3E, 0x83 }, - { 0x3F, 0xC9 }, - { 0x40, 0x01 }, + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), - // D3DDevice_SetRenderState_StencilFail+0x48 : mov dword ptr [eax], 0x00041D84 - { 0x48, 0xC7 }, - { 0x49, 0x00 }, - { 0x4A, 0x84 }, - { 0x4B, 0x1D }, - { 0x4C, 0x04 }, - { 0x4D, 0x00 }, + // mov [e??],0x40370 + OV_MATCH(0x51, 0xC7), + OV_MATCH(0x53, 0x70, 0x03, 0x04, 0x00), + + // mov [D3DRS_StencilFail],e?? + OV_MATCH(0x5F, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index f4bb0cac..79ad953b 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -664,17 +664,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilFail // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilFail, - 4034) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilFail, + 4034, + XRefTwo) OOVPA_SIG_MATCH( - { 0x0C, 0x72 }, - { 0x1A, 0xC9 }, - { 0x2A, 0x85 }, - { 0x36, 0x74 }, - { 0x44, 0x83 }, - { 0x52, 0x24 }, - { 0x60, 0x10 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // mov [D3DRS_StencilFail],e?? + XREF_ENTRY(0x65, XREF_D3DRS_StencilFail), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov [e?? + 0x8],0x40370 + OV_MATCH(0x54, 0xC7), + OV_MATCH(0x56, 0x08, 0x70, 0x03, 0x04, 0x00), + + // mov [D3DRS_StencilFail],e?? + OV_MATCH(0x63, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8/5849.inl b/src/OOVPADatabase/D3D8/5849.inl index e893fac0..33b35030 100644 --- a/src/OOVPADatabase/D3D8/5849.inl +++ b/src/OOVPADatabase/D3D8/5849.inl @@ -71,17 +71,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilFail // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilFail, - 5849) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilFail, + 5849, + XRefTwo) OOVPA_SIG_MATCH( - { 0x0C, 0x89 }, - { 0x1E, 0x8B }, - { 0x28, 0x74 }, - { 0x36, 0xD2 }, - { 0x44, 0x3D }, - { 0x52, 0xC7 }, - { 0x60, 0x04 }, - { 0x6E, 0x00 }, - // + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + // [D3DRS_StencilFail],e?? + XREF_ENTRY(0x0E, XREF_D3DRS_StencilFail), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov e??,[esp + param_1] + OV_MATCH(0x08, 0x8B), + OV_MATCH(0x0A, 0x24, 0x0C), + + // [D3DRS_StencilFail],e?? + OV_MATCH(0x0C, 0x89), + // Do NOT use any offsets after 0x1D ); diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index 4d50e240..18423b33 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -515,19 +515,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilFail // ****************************************************************** -//7003040089 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilFail, - 1024) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilFail, + 1024, + XRefTwo) OOVPA_SIG_MATCH( - { 0x01, 0x8B }, - { 0x1B, 0x33 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // mov [D3DRS_StencilFail],e?? + XREF_ENTRY(0x67, XREF_D3DRS_StencilFail), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov [e?? + 0x8],0x40370 + OV_MATCH(0x56, 0xC7), + OV_MATCH(0x58, 0x08, 0x70, 0x03, 0x04, 0x00), - { 0x59, 0x70 }, - { 0x5A, 0x03 }, - { 0x5B, 0x04 }, - { 0x5C, 0x00 }, - { 0x5D, 0x89 }, + // mov [D3DRS_StencilFail],e?? + OV_MATCH(0x65, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4039.inl b/src/OOVPADatabase/D3D8LTCG/4039.inl index ab5aff5c..860bd030 100644 --- a/src/OOVPADatabase/D3D8LTCG/4039.inl +++ b/src/OOVPADatabase/D3D8LTCG/4039.inl @@ -559,19 +559,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilFail // ****************************************************************** -//7003040089 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilFail, - 1036) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilFail, + 1036, + XRefTwo) OOVPA_SIG_MATCH( - { 0x01, 0x8B }, - { 0x1F, 0x33 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // mov [D3DRS_StencilFail],e?? + XREF_ENTRY(0x6B, XREF_D3DRS_StencilFail), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov [e?? + 0x8],0x40370 + OV_MATCH(0x5A, 0xC7), + OV_MATCH(0x5C, 0x08, 0x70, 0x03, 0x04, 0x00), - { 0x5D, 0x70 }, - { 0x5E, 0x03 }, - { 0x5F, 0x04 }, - { 0x60, 0x00 }, - { 0x61, 0x89 }, + // mov [D3DRS_StencilFail],e?? + OV_MATCH(0x69, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4432.inl b/src/OOVPADatabase/D3D8LTCG/4432.inl index 5e707885..cda2e88c 100644 --- a/src/OOVPADatabase/D3D8LTCG/4432.inl +++ b/src/OOVPADatabase/D3D8LTCG/4432.inl @@ -375,19 +375,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilFail // ****************************************************************** -//7003040089 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilFail, - 1048) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilFail, + 1048, + XRefTwo) OOVPA_SIG_MATCH( - { 0x01, 0x8B }, - { 0x22, 0x33 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // mov [D3DRS_StencilFail],e?? + XREF_ENTRY(0x6E, XREF_D3DRS_StencilFail), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov [e?? + 0x8],0x40370 + OV_MATCH(0x5D, 0xC7), + OV_MATCH(0x5F, 0x08, 0x70, 0x03, 0x04, 0x00), - { 0x60, 0x70 }, - { 0x61, 0x03 }, - { 0x62, 0x04 }, - { 0x63, 0x00 }, - { 0x64, 0x89 }, + // mov [D3DRS_StencilFail],e?? + OV_MATCH(0x6C, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/5788.inl b/src/OOVPADatabase/D3D8LTCG/5788.inl index 333319e5..faf5cf99 100644 --- a/src/OOVPADatabase/D3D8LTCG/5788.inl +++ b/src/OOVPADatabase/D3D8LTCG/5788.inl @@ -384,19 +384,28 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_StencilFail // ****************************************************************** -//7003040089 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilFail, - 1060) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_StencilFail, + 1060, + XRefTwo) OOVPA_SIG_MATCH( - { 0x01, 0x8B }, - { 0x23, 0x33 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // mov [D3DRS_StencilFail],e?? + XREF_ENTRY(0x6F, XREF_D3DRS_StencilFail), + + // push esi + OV_MATCH(0x00, 0x56), + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x01, 0x8B, 0x35), + + // mov [e?? + 0x8],0x40370 + OV_MATCH(0x5E, 0xC7), + OV_MATCH(0x60, 0x08, 0x70, 0x03, 0x04, 0x00), - { 0x61, 0x70 }, - { 0x62, 0x03 }, - { 0x63, 0x04 }, - { 0x64, 0x00 }, - { 0x65, 0x89 }, + // mov [D3DRS_StencilFail],e?? + OV_MATCH(0x6D, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/5849.inl b/src/OOVPADatabase/D3D8LTCG/5849.inl index 1a2e20d9..1b9d24b4 100644 --- a/src/OOVPADatabase/D3D8LTCG/5849.inl +++ b/src/OOVPADatabase/D3D8LTCG/5849.inl @@ -233,44 +233,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_StencilFail -// ****************************************************************** -//7003040089 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilFail, - 1072) -OOVPA_SIG_MATCH( - - { 0x01, 0x8B }, - { 0x2E, 0x33 }, - - { 0x68, 0x70 }, - { 0x69, 0x03 }, - { 0x6A, 0x04 }, - { 0x6B, 0x00 }, - { 0x6C, 0x89 }, - // -); - -// ****************************************************************** -// * D3DDevice_SetRenderState_StencilFail -// ****************************************************************** -//7003040089 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_StencilFail, - 1084) -OOVPA_SIG_MATCH( - - { 0x01, 0x8B }, - { 0x2D, 0x33 }, - - { 0x67, 0x70 }, - { 0x68, 0x03 }, - { 0x69, 0x04 }, - { 0x6A, 0x00 }, - { 0x6B, 0x89 }, - // -); - // ****************************************************************** // * D3DDevice_SetTextureState_TexCoordIndex // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index 9dbd16f4..dd955a6c 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -162,7 +162,7 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 1024), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_ShadowFunc, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilEnable, 1024, 1036, 1048, 1060), - REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilFail, 1024, 1036, 1048, 1060, 1072, 1084), + REGISTER_OOVPAS(D3DDevice_SetRenderState_StencilFail, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_TextureFactor, 1036), REGISTER_OOVPAS(D3DDevice_SetRenderState_TwoSidedLighting, 1024, 1036, 1060, 1061, 1084), REGISTER_OOVPAS(D3DDevice_SetRenderState_VertexBlend, 1024, 1036, 1048), From 3fd410f1e7f52320d2a67b78b583dbda4a4ee79b Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Fri, 20 Jan 2023 12:48:45 -0600 Subject: [PATCH 33/35] d3d: update D3DDevice_SetRenderState_MultiSampleRenderTargetMode sig Removed: - 1024 Updated: - 4034 --- src/OOVPADatabase/D3D8/4034.inl | 58 ++++++++++------------------ src/OOVPADatabase/D3D8LTCG/4039.inl | 22 ----------- src/OOVPADatabase/D3D8LTCG_OOVPA.inl | 1 - src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- 4 files changed, 22 insertions(+), 61 deletions(-) diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index 79ad953b..7da0ff69 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -1438,46 +1438,30 @@ OOVPA_SIG_MATCH( // * D3DDevice_SetRenderState_MultiSampleRenderTargetMode // ****************************************************************** // Generic OOVPA as of 4034 and newer. -#ifndef WIP_LessVertexPatching -OOVPA_XREF(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, - 4034, - 1 + 10, - XRefOne) - { -#else -OOVPA_XREF(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, - 4034, - 2 + 10, - XRefTwo) -{ -#endif - XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleRenderTargetMode), // Derived +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, + 4034, + XRefOne) +OOVPA_SIG_MATCH( -#ifdef WIP_LessVertexPatching - XREF_ENTRY(0x11, XREF_OFFSET_D3DDevice__m_RenderTarget), // Derived -#endif + XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleRenderTargetMode), - { 0x00, 0x8B }, - //{ 0x01, 0x4C }, - { 0x02, 0x24 }, - { 0x03, 0x04 }, + // TODO: enable below for WIP_LessVertexPatching + // mov e??,[e?? + XREF_OFFSET_D3DDevice__m_RenderTarget] + //XREF_ENTRY(0x11, XREF_OFFSET_D3DDevice__m_RenderTarget), // Derived - { 0x0F, 0x8B }, - //{ 0x10, 0x88 }, - //{ 0x11, 0x70 }, - //{ 0x12, 0x20 }, - { 0x13, 0x00 }, - { 0x14, 0x00 }, - { 0x15, 0x3B }, - //{ 0x16, 0x88 }, - //{ 0x17, 0x7C }, - //{ 0x18, 0x20 }, - { 0x19, 0x00 }, - { 0x1A, 0x00 }, - { 0x1B, 0x74 }, // MultiSampleRenderTargetMode 0x74 vs MultiSampleMode 0x75 - //{ 0x1C, 0x0D }, - } -OOVPA_END; + // mov e??,[esp + param_1] + OV_MATCH(0x00, 0x8B), + OV_MATCH(0x02, 0x24, 0x04), + + // mov e??,[e?? + XREF_OFFSET_D3DDevice__m_RenderTarget] + OV_MATCH(0x0F, 0x8B), + + // cmp e??,[e?? + XREF_OFFSET_D3DDevice__m_????] + OV_MATCH(0x15, 0x3B), + + // jz +0x?? + OV_MATCH(0x1B, 0x74), // MultiSampleRenderTargetMode 0x74 vs MultiSampleMode 0x75 +); // ****************************************************************** // * D3DDevice_SetRenderState_LineWidth diff --git a/src/OOVPADatabase/D3D8LTCG/4039.inl b/src/OOVPADatabase/D3D8LTCG/4039.inl index 860bd030..716ba842 100644 --- a/src/OOVPADatabase/D3D8LTCG/4039.inl +++ b/src/OOVPADatabase/D3D8LTCG/4039.inl @@ -534,28 +534,6 @@ OOVPA_SIG_MATCH( // ); -// ****************************************************************** -// * D3DDevice_SetRenderState_MultiSampleRenderTargetMode -// ****************************************************************** -OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, - 1024, - XRefOne) -OOVPA_SIG_MATCH( - - XREF_ENTRY(0x0B, XREF_D3DRS_MultiSampleRenderTargetMode), - - { 0x01, 0x4C }, - { 0x15, 0x3B }, - //{ 0x16, 0x90 }, - //{ 0x17, 0x14 }, - //{ 0x18, 0x1A }, - { 0x19, 0x00 }, - { 0x1A, 0x00 }, - { 0x1B, 0x74 }, - //{ 0x1C, 0x0D }, - // -); - // ****************************************************************** // * D3DDevice_SetRenderState_StencilFail // ****************************************************************** diff --git a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl index dd955a6c..8195822e 100644 --- a/src/OOVPADatabase/D3D8LTCG_OOVPA.inl +++ b/src/OOVPADatabase/D3D8LTCG_OOVPA.inl @@ -157,7 +157,6 @@ OOVPATable D3D8LTCG_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_LogicOp, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleAntiAlias, 1024, 1060), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMask, 1024, 1060), // Final generic OOVPA: 4627; Removed: 0 - REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 1024), REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 1024, 1036, 1048, 1060), REGISTER_OOVPAS(D3DDevice_SetRenderState_SampleAlpha, 1024), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_ShadowFunc, 1024, 1036, 1048, 1060), diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index d1e69932..6f8b7902 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -333,7 +333,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleAntiAlias, 3911, 4627), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMask, 3911, 4627), // Final generic OOVPA: 4627; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleMode, 4034), // Final generic OOVPA: 4034; Removed: 0 - REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 4034), // Was 5233 (from 5344's comment) + REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleRenderTargetMode, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleType, 3911, 3925), // Final generic OOVPA: 3925 Removed: 4034 REGISTER_OOVPAS(D3DDevice_SetRenderState_NormalizeNormals, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_OcclusionCullEnable, 3911, 1024), // Final generic OOVPA: 3911 (LTCG) / 4034 (non-LTCG); Removed: 0 From cd4f0d3c8670c462cb563b1379edc4a6c5256883 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Fri, 20 Jan 2023 12:54:20 -0600 Subject: [PATCH 34/35] fixup D3DRS_StencilEnable --- include/xref/d3d8.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xref/d3d8.def b/include/xref/d3d8.def index db6f42b1..c2d08039 100644 --- a/include/xref/d3d8.def +++ b/include/xref/d3d8.def @@ -50,7 +50,7 @@ XREF_SYMBOL(D3DRS_PSTextureModes) XREF_SYMBOL(D3DRS_DoNotCullUncompressed) XREF_SYMBOL(D3DRS_SampleAlpha) XREF_SYMBOL(D3DRS_StencilCullEnable) -XREF_SYMBOL(D3DRS_StencilEnable) // Not been used +XREF_SYMBOL(D3DRS_StencilEnable) XREF_SYMBOL(D3DRS_StencilFail) XREF_SYMBOL(D3DRS_TwoSidedLighting) XREF_SYMBOL(D3DRS_YuvEnable) From 951ff7da7d874208818d21389390073b31797339 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Fri, 20 Jan 2023 13:32:57 -0600 Subject: [PATCH 35/35] d3d: update D3DDevice_SetRenderState_FrontFace signatures --- include/xref/d3d8.def | 1 + src/OOVPADatabase/D3D8/3911.inl | 30 ++++++++++++++--------------- src/OOVPADatabase/D3D8/4034.inl | 27 +++++++++++++++++--------- src/OOVPADatabase/D3D8LTCG/3911.inl | 28 ++++++++++++++++----------- src/OOVPADatabase/D3D8LTCG/4039.inl | 28 ++++++++++++++++----------- src/OOVPADatabase/D3D8LTCG/4432.inl | 28 ++++++++++++++++----------- src/OOVPADatabase/D3D8LTCG/5788.inl | 28 ++++++++++++++++----------- src/OOVPADatabase/D3D8_OOVPA.inl | 2 +- src/lib/manual_d3d8__ltcg.h | 2 +- src/test/libverify/D3D8.cpp | 1 + 10 files changed, 105 insertions(+), 70 deletions(-) diff --git a/include/xref/d3d8.def b/include/xref/d3d8.def index c2d08039..dfd5d2f1 100644 --- a/include/xref/d3d8.def +++ b/include/xref/d3d8.def @@ -36,6 +36,7 @@ XREF_SYMBOL(D3DRS_CullMode) XREF_SYMBOL(D3DRS_Dxt1NoiseEnable) XREF_SYMBOL(D3DRS_FillMode) XREF_SYMBOL(D3DRS_FogEnable) +XREF_SYMBOL(D3DRS_FrontFace) //XREF_SYMBOL(D3DRS_LineWidth) // Not been used XREF_SYMBOL(D3DRS_LogicOp) XREF_SYMBOL(D3DRS_MultiSampleAntiAlias) diff --git a/src/OOVPADatabase/D3D8/3911.inl b/src/OOVPADatabase/D3D8/3911.inl index 180a073a..1de0ec6e 100644 --- a/src/OOVPADatabase/D3D8/3911.inl +++ b/src/OOVPADatabase/D3D8/3911.inl @@ -3697,26 +3697,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FrontFace // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FrontFace, - 3911) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FrontFace, + 3911, + XRefTwo) OOVPA_SIG_MATCH( - // D3DDevice_SetRenderState_FrontFace+0x00 : push esi - { 0x00, 0x56 }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), - // D3DDevice_SetRenderState_FrontFace+0x07 : push esi - { 0x07, 0x56 }, + // mov [D3DRS_FrontFace],e?? + XREF_ENTRY(0x26, XREF_D3DRS_FrontFace), - // D3DDevice_SetRenderState_FrontFace+0xD : mov ecx, [esp+0x08] - { 0x0D, 0x8B }, - { 0x0E, 0x4C }, - { 0x0F, 0x24 }, - { 0x10, 0x08 }, + // push esi + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x00, 0x56, 0x8B, 0x35), - // D3DDevice_SetRenderState_FrontFace+0x1A : add eax, 8 - { 0x1A, 0x83 }, - { 0x1B, 0xC0 }, - { 0x1C, 0x08 }, + // add eax,0x08 + OV_MATCH(0x1A, 0x83, 0xC0, 0x08), + + // mov [D3DRS_FrontFace],e?? + OV_MATCH(0x24, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8/4034.inl b/src/OOVPADatabase/D3D8/4034.inl index 7da0ff69..b5e5f000 100644 --- a/src/OOVPADatabase/D3D8/4034.inl +++ b/src/OOVPADatabase/D3D8/4034.inl @@ -560,17 +560,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FrontFace // ****************************************************************** -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FrontFace, - 4034) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FrontFace, + 4034, + XRefTwo) OOVPA_SIG_MATCH( - { 0x00, 0x56 }, - { 0x07, 0x8B }, - { 0x0E, 0xE8 }, - { 0x16, 0x08 }, - { 0x1E, 0x48 }, - { 0x2A, 0x89 }, - { 0x30, 0x5E }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), + + // mov [D3DRS_FrontFace],e?? + XREF_ENTRY(0x2C, XREF_D3DRS_FrontFace), + + // push esi + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x00, 0x56, 0x8B, 0x35), + + // add eax,0x08 + OV_MATCH(0x20, 0x83, 0xC0, 0x08), + + // mov [D3DRS_FrontFace],e?? + OV_MATCH(0x2A, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/3911.inl b/src/OOVPADatabase/D3D8LTCG/3911.inl index 18423b33..56f33fc9 100644 --- a/src/OOVPADatabase/D3D8LTCG/3911.inl +++ b/src/OOVPADatabase/D3D8LTCG/3911.inl @@ -568,20 +568,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FrontFace // ****************************************************************** -//00A00304008948 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FrontFace, - 1024) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FrontFace, + 1024, + XRefTwo) OOVPA_SIG_MATCH( - { 0x01, 0x8B }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), - { 0x1A, 0x00 }, - { 0x1B, 0xA0 }, - { 0x1C, 0x03 }, - { 0x1D, 0x04 }, - { 0x1E, 0x00 }, - { 0x1F, 0x89 }, - { 0x20, 0x48 }, + // mov [D3DRS_FrontFace],e?? + XREF_ENTRY(0x2E, XREF_D3DRS_FrontFace), + + // push esi + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x00, 0x56, 0x8B, 0x35), + + // add eax,0x08 + OV_MATCH(0x22, 0x83, 0xC0, 0x08), + + // mov [D3DRS_FrontFace],e?? + OV_MATCH(0x2C, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4039.inl b/src/OOVPADatabase/D3D8LTCG/4039.inl index 716ba842..95ecac7b 100644 --- a/src/OOVPADatabase/D3D8LTCG/4039.inl +++ b/src/OOVPADatabase/D3D8LTCG/4039.inl @@ -565,20 +565,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FrontFace // ****************************************************************** -//00A00304008948 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FrontFace, - 1036) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FrontFace, + 1036, + XRefTwo) OOVPA_SIG_MATCH( - { 0x01, 0x8B }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), - { 0x1E, 0x00 }, - { 0x1F, 0xA0 }, - { 0x20, 0x03 }, - { 0x21, 0x04 }, - { 0x22, 0x00 }, - { 0x23, 0x89 }, - { 0x24, 0x48 }, + // mov [D3DRS_FrontFace],e?? + XREF_ENTRY(0x2D, XREF_D3DRS_FrontFace), + + // push esi + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x00, 0x56, 0x8B, 0x35), + + // add eax,0x08 + OV_MATCH(0x26, 0x83, 0xC0, 0x08), + + // mov [D3DRS_FrontFace],e?? + OV_MATCH(0x2B, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/4432.inl b/src/OOVPADatabase/D3D8LTCG/4432.inl index cda2e88c..8e1a23ff 100644 --- a/src/OOVPADatabase/D3D8LTCG/4432.inl +++ b/src/OOVPADatabase/D3D8LTCG/4432.inl @@ -403,20 +403,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FrontFace // ****************************************************************** -//00A00304008948 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FrontFace, - 1048) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FrontFace, + 1048, + XRefTwo) OOVPA_SIG_MATCH( - { 0x01, 0x8B }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), - { 0x21, 0x00 }, - { 0x22, 0xA0 }, - { 0x23, 0x03 }, - { 0x24, 0x04 }, - { 0x25, 0x00 }, - { 0x26, 0x89 }, - { 0x27, 0x48 }, + // mov [D3DRS_FrontFace],e?? + XREF_ENTRY(0x35, XREF_D3DRS_FrontFace), + + // push esi + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x00, 0x56, 0x8B, 0x35), + + // add eax,0x08 + OV_MATCH(0x29, 0x83, 0xC0, 0x08), + + // mov [D3DRS_FrontFace],e?? + OV_MATCH(0x33, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8LTCG/5788.inl b/src/OOVPADatabase/D3D8LTCG/5788.inl index faf5cf99..634e0ca9 100644 --- a/src/OOVPADatabase/D3D8LTCG/5788.inl +++ b/src/OOVPADatabase/D3D8LTCG/5788.inl @@ -272,20 +272,26 @@ OOVPA_SIG_MATCH( // ****************************************************************** // * D3DDevice_SetRenderState_FrontFace // ****************************************************************** -//00a0A0304008948 -OOVPA_SIG_HEADER_NO_XREF(D3DDevice_SetRenderState_FrontFace, - 1060) +OOVPA_SIG_HEADER_XREF(D3DDevice_SetRenderState_FrontFace, + 1060, + XRefTwo) OOVPA_SIG_MATCH( - { 0x01, 0x8B }, + // mov esi,[D3D_g_pDevice] + XREF_ENTRY(0x03, XREF_D3D_g_pDevice), - { 0x22, 0x00 }, - { 0x23, 0xA0 }, - { 0x24, 0x03 }, - { 0x25, 0x04 }, - { 0x26, 0x00 }, - { 0x27, 0x89 }, - { 0x28, 0x48 }, + // mov [D3DRS_FrontFace],e?? + XREF_ENTRY(0x37, XREF_D3DRS_FrontFace), + + // push esi + // mov esi,[D3D_g_pDevice] + OV_MATCH(0x00, 0x56, 0x8B, 0x35), + + // add eax,0x08 + OV_MATCH(0x2A, 0x83, 0xC0, 0x08), + + // mov [D3DRS_FrontFace],e?? + OV_MATCH(0x35, 0x89), // ); diff --git a/src/OOVPADatabase/D3D8_OOVPA.inl b/src/OOVPADatabase/D3D8_OOVPA.inl index 6f8b7902..39e76fc7 100644 --- a/src/OOVPADatabase/D3D8_OOVPA.inl +++ b/src/OOVPADatabase/D3D8_OOVPA.inl @@ -327,7 +327,7 @@ OOVPATable D3D8_OOVPA[] = { REGISTER_OOVPAS(D3DDevice_SetRenderState_EdgeAntiAlias, 3911, 4034), REGISTER_OOVPAS_M(D3DDevice_SetRenderState_FillMode, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_FogColor, 3911, 4034), - REGISTER_OOVPAS(D3DDevice_SetRenderState_FrontFace, 3911, 4034), + REGISTER_OOVPAS(D3DDevice_SetRenderState_FrontFace, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_LineWidth, 3911, 4034), REGISTER_OOVPAS(D3DDevice_SetRenderState_LogicOp, 3911, 4034), // Final generic OOVPA: 4034; Removed: 0 REGISTER_OOVPAS(D3DDevice_SetRenderState_MultiSampleAntiAlias, 3911, 4627), // Final generic OOVPA: 4627; Removed: 0 diff --git a/src/lib/manual_d3d8__ltcg.h b/src/lib/manual_d3d8__ltcg.h index 3c4abd35..d7146925 100644 --- a/src/lib/manual_d3d8__ltcg.h +++ b/src/lib/manual_d3d8__ltcg.h @@ -203,7 +203,7 @@ static const RenderStateRevision DxbxRenderStateInfo[] = { /* 143 */ { 3424, 0000 /*, XREF_NAME(D3DRS_ZEnable) */ }, // D3DZBUFFERTYPE? /* 144 */ { 3424, 0000, XREF_NAME(D3DRS_StencilEnable) }, // /* 145 */ { 3424, 0000, XREF_NAME(D3DRS_StencilFail) }, // - /* 146 */ { 3424, 0000 /*, XREF_NAME(D3DRS_FrontFace) */ }, // nsp. + /* 146 */ { 3424, 0000, XREF_NAME(D3DRS_FrontFace) }, // nsp. /* 147 */ { 3424, 0000, XREF_NAME(D3DRS_CullMode) }, // /* 148 */ { 3424, 0000 /*, XREF_NAME(D3DRS_TextureFactor) */ }, // /* 149 */ { 3424, 0000, XREF_NAME(D3DRS_ZBias) }, // Was D3DRS_ZBIAS diff --git a/src/test/libverify/D3D8.cpp b/src/test/libverify/D3D8.cpp index 689b1d74..127f86b3 100644 --- a/src/test/libverify/D3D8.cpp +++ b/src/test/libverify/D3D8.cpp @@ -16,6 +16,7 @@ static const library_list database_full = { REGISTER_SYMBOL_INLINE(D3DRS_Dxt1NoiseEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_FillMode, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_FogEnable, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), + REGISTER_SYMBOL_INLINE(D3DRS_FrontFace, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_LogicOp, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleAntiAlias, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)), REGISTER_SYMBOL_INLINE(D3DRS_MultiSampleMask, VER_RANGE(0, VER_MAX, VER_NONE, VER_NONE)),