From d2375abaa86f4726b0235adf1b974a9be0bedd96 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Fri, 11 Oct 2019 17:21:06 +0200 Subject: [PATCH 01/19] Updated CONTRIBUTORS --- CONTRIBUTORS | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 50d577767..8bfe34d4e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,17 +1,41 @@ -Developers: -Luke Usher [SoullessSentinel] -PatrickvL -StrikerX3 -blueshogun96 -donwayo -hrydgard -jagotu -jarupxx -phire -x1nixmzeng +Contributors: +PatrickvL (Patrick van Logchem) +LukeUsher (Luke Usher) [SoullessSentinel] RadWolfie -Luca D'Amico (Luca1991/Luca91) +jarupxx +x1nixmzeng +Echelon9 ergo720 +blueshogun96 +NZJenkins +anita999 +dstien +revel8n +Luca1991 (Luca D'Amico) [Luca91] +Fisherman166 +Margen67 +GXTX +Voxel9 +StrikerX3 +CakeLancelot +jagotu +gandalfthewhite19890404 +donwayo +literalmente-game +gellis713 +darrena092 +JayFoxRox +BenNottelling +Ernegien +phire +jackchentwkh +hrydgard +ggKismet +aav7fl +TotalCaesar659 +DiscoStarslayer +(After https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/graphs/contributors) + Supporters: Cedric Wilson From 9c81eda65e07c260f2b988db0c8b8fa1dd2c29ed Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Fri, 11 Oct 2019 17:22:25 +0200 Subject: [PATCH 02/19] Make resource file language-neutral, so that Visual Studio won't complain when regional settings aren't compatible. (See https://stackoverflow.com/a/58011025/12170) Also applied the advisory steps from our GPL license to our About dialog, and trimmed this advise from COPYING itself. --- COPYING | 61 -------------------------------------------- resource/Cxbx.rc | 39 ++++------------------------ src/gui/DlgAbout.cpp | 5 +++- 3 files changed, 9 insertions(+), 96 deletions(-) diff --git a/COPYING b/COPYING index b8306825e..960fe7469 100644 --- a/COPYING +++ b/COPYING @@ -278,64 +278,3 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. - diff --git a/resource/Cxbx.rc b/resource/Cxbx.rc index 3bcebfd55..5f6af33b0 100644 --- a/resource/Cxbx.rc +++ b/resource/Cxbx.rc @@ -13,11 +13,11 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// English (United States) resources +// Language neutral resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#pragma code_page(65001) ///////////////////////////////////////////////////////////////////////////// // @@ -661,36 +661,6 @@ BEGIN MENUITEM " ", ID_LOG,MFT_STRING,MFS_ENABLED END -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (United Kingdom) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 303 - TOPMARGIN, 7 - BOTTOMMARGIN, 170 - END -END -#endif // APSTUDIO_INVOKED - - ///////////////////////////////////////////////////////////////////////////// // // Dialog @@ -725,7 +695,8 @@ IDR_CONTRIBUTORS TXT "..\\CONTRIBUTORS" IDR_COPYING TXT "..\\COPYING" -#endif // English (United Kingdom) resources +#endif // Language neutral resources + ///////////////////////////////////////////////////////////////////////////// diff --git a/src/gui/DlgAbout.cpp b/src/gui/DlgAbout.cpp index a0e3def65..8ea02205c 100644 --- a/src/gui/DlgAbout.cpp +++ b/src/gui/DlgAbout.cpp @@ -81,7 +81,10 @@ INT_PTR CALLBACK DlgAboutProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SendMessage(GetDlgItem(hWndDlg, IDC_TAB1), TCM_ADJUSTRECT, FALSE, (LPARAM)&tabRect); // Tab Pane 1 HWND tab = CreateWindowEx - (NULL, "STATIC", "\nCxbx-Reloaded\nVersion " _CXBX_VERSION "\nŠ The Cxbx-Reloaded Team", + (NULL, "STATIC", "\nCxbx-Reloaded\nVersion " _CXBX_VERSION "\nŠ The Cxbx-Reloaded Team" + "\nThis software comes with ABSOLUTELY NO WARRANTY." + "\nThis is free software, and you are welcome to redistribute it" + "\nunder certain conditions; See our website for details.", WS_CHILD | WS_VISIBLE, tabRect.left + 10, tabRect.top + 10, tabRect.right - tabRect.left, From f4177031f82ad70db8f1815ce4f8c6f84db270eb Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Fri, 11 Oct 2019 17:24:42 +0200 Subject: [PATCH 03/19] Added a rudimentary setup script, to get up and running more easily. --- setup.cmd | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 setup.cmd diff --git a/setup.cmd b/setup.cmd new file mode 100644 index 000000000..ddcfa78b8 --- /dev/null +++ b/setup.cmd @@ -0,0 +1,26 @@ +@echo off + +REM CXbx-Reloaded setup script +REM +REM Depends on git, cmake and Visual Studio being installed. + +echo Pulling lastest version from git... +REM git clone --recurse-submodules https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/ +git pull --recurse-submodules + +REM echo Synchronizing submodules... +REM git submodule update --init --recursive + +echo Initializing most recent Visual Studio build environment... +@call "%VS140COMNTOOLS%vsvars32.bat" + +echo Generating solution... +mkdir build +cd build +REM cmake .. -G "Visual Studio 16 2019" -A Win32 +cmake .. -A Win32 + +echo Building solution... +cmake --build . + +echo Done! Enjoy using Cxbx-Reloaded! \ No newline at end of file From b3671fe0e48df482bb3d54ecf1cda9f546bc5092 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Fri, 15 Nov 2019 17:59:16 +0100 Subject: [PATCH 04/19] Read Fog color through GetXboxRenderState (not via host GetRenderState), just like all other states. Also updated a few random comments and stuff mentioning the now-obsolete EmuMappedD3DRenderState. Removed unused code and replaced manual conversion of DWORD to 4 ARGB floats by using D3DXCOLOR. --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 25 ++++++++--------------- src/core/hle/D3D8/XbD3D8Types.h | 8 ++++---- src/core/hle/D3D8/XbPixelShader.cpp | 21 +++++-------------- 3 files changed, 17 insertions(+), 37 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index 44fefdacc..74522f27b 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -4368,7 +4368,7 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData2s) float fa, fb; // Test case: Halo - // Note : XQEMU recently verified that the int16_t arguments + // Note : XQEMU verified that the int16_t arguments // must be mapped to floats in the range [-32768.0, 32767.0] // (See https://github.com/xqemu/xqemu/pull/176) fa = (float)a; @@ -4377,16 +4377,6 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData2s) EMUPATCH(D3DDevice_SetVertexData4f)(Register, fa, fb, 0.0f, 1.0f); } -DWORD FloatsToDWORD(FLOAT d, FLOAT a, FLOAT b, FLOAT c) -{ - DWORD ca = (FtoDW(d) << 24); - DWORD cr = (FtoDW(a) << 16) & 0x00FF0000; - DWORD cg = (FtoDW(b) << 8) & 0x0000FF00; - DWORD cb = (FtoDW(c) << 0) & 0x000000FF; - - return ca | cr | cg | cb; -} - extern uint32_t HLE_read_NV2A_pgraph_register(const int reg); // Declared in PushBuffer.cpp extern void HLE_write_NV2A_vertex_attribute_slot(unsigned slot, uint32_t parameter); // Declared in PushBuffer.cpp extern uint32_t HLE_read_NV2A_vertex_attribute_slot(unsigned VertexSlot); // Declared in PushBuffer.cpp @@ -4410,6 +4400,8 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData4f_16) mov Register, edi } + LOG_FORWARD("D3DDevice_SetVertexData4f"); + EMUPATCH(D3DDevice_SetVertexData4f)(Register, a, b, c, d); } @@ -4727,7 +4719,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData4s) float fa, fb, fc, fd; // Test case: Halo - // See comment note in D3DDevice_SetVertexData2s + // Note : XQEMU verified that the int16_t arguments + // must be mapped to floats in the range [-32768.0, 32767.0] + // (See https://github.com/xqemu/xqemu/pull/176) fa = (float)a; fb = (float)b; fc = (float)c; @@ -4747,12 +4741,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexDataColor) { LOG_FORWARD("D3DDevice_SetVertexData4f"); - FLOAT a = ((Color & 0xFF000000) >> 24) / 255.0f; - FLOAT r = ((Color & 0x00FF0000) >> 16) / 255.0f; - FLOAT g = ((Color & 0x0000FF00) >> 8) / 255.0f; - FLOAT b = ((Color & 0x000000FF) >> 0) / 255.0f; + D3DXCOLOR XColor = Color; - EMUPATCH(D3DDevice_SetVertexData4f)(Register, r, g, b, a); + EMUPATCH(D3DDevice_SetVertexData4f)(Register, XColor.r, XColor.g, XColor.b, XColor.a); } // ****************************************************************** diff --git a/src/core/hle/D3D8/XbD3D8Types.h b/src/core/hle/D3D8/XbD3D8Types.h index 345cbe7d0..6131804ab 100644 --- a/src/core/hle/D3D8/XbD3D8Types.h +++ b/src/core/hle/D3D8/XbD3D8Types.h @@ -650,11 +650,11 @@ typedef enum _X_D3DRENDERSTATETYPE { // Dxbx note : These declarations are from XDK version 5933, the most recent and complete version. // Older versions are slightly different (some members are missing), so we use a mapping table to // cater for the differences (see DxbxBuildRenderStateMappingTable). This enables to ignore these - // version-differences in the rest of our code (unless it matters somehow); We write via indirection : - // *EmuMappedD3DRenderState[X_D3DRENDERSTATETYPE] = Value; + // version-differences in the rest of our code (unless it matters somehow); We write like this : + // XboxRenderStates.SetXboxRenderState(X_D3DRENDERSTATETYPE, Value); // - // And we read via the same mapping (do note, that missing elements all point to the same dummy) : - // Result = *EmuMappedD3DRenderState[X_D3DRENDERSTATETYPE]; + // And we read like this (do note, that missing elements all point to the same dummy) : + // Result = XboxRenderStates.GetXboxRenderState(X_D3DRENDERSTATETYPE); // Dxbx note : The PS* render states map 1-on-1 to the X_D3DPIXELSHADERDEF record, // SetPixelShader actually pushes the definition into these render state slots. diff --git a/src/core/hle/D3D8/XbPixelShader.cpp b/src/core/hle/D3D8/XbPixelShader.cpp index 9d1e7ea7a..547973acb 100644 --- a/src/core/hle/D3D8/XbPixelShader.cpp +++ b/src/core/hle/D3D8/XbPixelShader.cpp @@ -1210,7 +1210,7 @@ float PSH_IMD_ARGUMENT::GetConstValue() if (HasModifier(ARGMOD_NEGATE)) Result = -Result; // y = x-0.5 -> 0..1 > -0.5..0.5 - if (HasModifier (ARGMOD_BIAS)) Result = Result-0.5f; + if (HasModifier(ARGMOD_BIAS)) Result = Result-0.5f; // y = x*2 -> 0..1 > 0..2 if (HasModifier(ARGMOD_SCALE_X2)) Result = Result*2.0f; @@ -1650,7 +1650,7 @@ bool PSH_IMD_ARGUMENT::Decode(const DWORD Value, DWORD aMask, TArgumentType Argu Modifiers = (1 << ARGMOD_BIAS); break; // case PS_INPUTMAPPING_HALFBIAS_NEGATE: -// Modifiers = ARGMOD_IDENTITY; ??? +// Modifiers = (1 << ARGMOD_IDENTITY); ??? // break; case PS_INPUTMAPPING_SIGNED_IDENTITY: Modifiers = (1 << ARGMOD_IDENTITY); @@ -5982,11 +5982,9 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH HRESULT Result = D3D_OK; - // TODO: Is this even right? The first RenderState is PSAlpha, + // The first RenderState is PSAlpha, // The pixel shader is stored in pDevice->m_pPixelShader // For now, we still patch SetPixelShader and read from there... - //DWORD *XTL_D3D__RenderState = EmuMappedD3DRenderState[0]; - //pPSDef = (XTL::X_D3DPIXELSHADERDEF*)(XTL_D3D__RenderState); // Use the pixel shader stored in D3D__RenderState rather than the set handle // This allows changes made via SetRenderState to actually take effect! @@ -5994,6 +5992,7 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH // All other fields are the same. // We cast D3D__RenderState to a pPSDef for these fields, but // manually read from D3D__RenderState[X_D3DRS_PSTEXTUREMODES) for that one field. + // See D3DDevice_SetPixelShaderCommon which implements this pPSDef = g_pXbox_PixelShader != nullptr ? (XTL::X_D3DPIXELSHADERDEF*)(XboxRenderStates.GetPixelShaderRenderStatePointer()) : nullptr; @@ -6066,25 +6065,16 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH if (RecompiledPixelShader->ConstInUse[i]) { // Read the color from the corresponding render state slot : - // TODO: These should read from EmuMappedD3DRenderState, but it doesn't exist yet - // The required code needs o be ported from Wip_LessVertexPatching or Dxbx switch (i) { case PSH_XBOX_CONSTANT_FOG: - //dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_FOGCOLOR] | 0xFF000000; // Note : FOG.RGB is correct like this, but FOG.a should be coming // from the vertex shader (oFog) - however, D3D8 does not forward this... - g_pD3DDevice->GetRenderState(D3DRS_FOGCOLOR, &dwColor); - fColor.a = ((dwColor >> 24) & 0xFF) / 255.0f; - fColor.r = ((dwColor >> 16) & 0xFF) / 255.0f; - fColor.g = ((dwColor >> 8) & 0xFF) / 255.0f; - fColor.b = (dwColor & 0xFF) / 255.0f; + fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_FOGCOLOR); break; case PSH_XBOX_CONSTANT_FC0: - //dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT0]; fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_PSFINALCOMBINERCONSTANT0); break; case PSH_XBOX_CONSTANT_FC1: - //dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT1]; fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_PSFINALCOMBINERCONSTANT1); break; case PSH_XBOX_CONSTANT_MUL0: @@ -6119,7 +6109,6 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH break; } default: - //dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSCONSTANT0_0 + i]; fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_PSCONSTANT0_0 + i); break; } From 2012d86522acb2be1970c5d9a5b307bf8776541b Mon Sep 17 00:00:00 2001 From: patrickvl Date: Sat, 16 Nov 2019 14:43:02 +0100 Subject: [PATCH 05/19] Introduce two CxbxImpl_*'s for as-yet unimplemented functions. --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 15 +++++------- src/core/hle/D3D8/XbVertexShader.cpp | 30 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index 44fefdacc..33a68dc33 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -188,6 +188,10 @@ static DWORD WINAPI EmuUpdateTickCount(LPVOID); static inline void EmuVerifyResourceIsRegistered(XTL::X_D3DResource *pResource, DWORD D3DUsage, int iTextureStage, DWORD dwSize); static void UpdateCurrentMSpFAndFPS(); // Used for benchmarking/fps count +// Declared in XbVertexShader.cpp +extern void CxbxImpl_SetVertexShaderInput(DWORD Handle, UINT StreamCount, XTL::X_STREAMINPUT* pStreamInputs); +extern void CxbxImpl_SelectVertexShaderDirect(XTL::X_VERTEXATTRIBUTEFORMAT* pVAF, DWORD Address); + extern void UpdateFPSCounter(); typedef uint64_t resource_key_t; @@ -7808,7 +7812,7 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SelectVertexShaderDirect) LOG_FUNC_ARG(Address) LOG_FUNC_END; - LOG_UNIMPLEMENTED(); + CxbxImpl_SelectVertexShaderDirect(pVAF, Address); } // ****************************************************************** @@ -7933,16 +7937,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexShaderInput) LOG_FUNC_ARG(pStreamInputs) LOG_FUNC_END; - // If Handle is NULL, all VertexShader input state is cleared. - // Otherwise, Handle is the address of an Xbox VertexShader struct, or-ed with 1 (X_D3DFVF_RESERVED0) - - - LOG_UNIMPLEMENTED(); - - return; + CxbxImpl_SetVertexShaderInput(Handle, StreamCount, pStreamInputs); } - // ****************************************************************** // * patch: D3DDevice_RunVertexStateShader // ****************************************************************** diff --git a/src/core/hle/D3D8/XbVertexShader.cpp b/src/core/hle/D3D8/XbVertexShader.cpp index 493ba336c..7b3ec8e4f 100644 --- a/src/core/hle/D3D8/XbVertexShader.cpp +++ b/src/core/hle/D3D8/XbVertexShader.cpp @@ -2797,3 +2797,33 @@ void SetCxbxVertexShader(DWORD XboxVertexShaderHandle, CxbxVertexShader* shader) g_CxbxVertexShaders[XboxVertexShaderHandle] = shader; } + +void CxbxImpl_SetVertexShaderInput +( + DWORD Handle, + UINT StreamCount, + XTL::X_STREAMINPUT* pStreamInputs +) +{ + LOG_INIT + + // If Handle is NULL, all VertexShader input state is cleared. + // Otherwise, Handle is the address of an Xbox VertexShader struct, or-ed with 1 (X_D3DFVF_RESERVED0) + // (Thus, a FVF handle is an invalid argument.) + // + + LOG_UNIMPLEMENTED(); +} + +void CxbxImpl_SelectVertexShaderDirect +( + XTL::X_VERTEXATTRIBUTEFORMAT* pVAF, + DWORD Address +) +{ + LOG_INIT; + + // When pVAF is non-null, this vertex attribute format takes precedence over the the one + LOG_UNIMPLEMENTED(); +} + From 8dfb3e20c296e0f80b52f2b5b77d4803503f9127 Mon Sep 17 00:00:00 2001 From: patrickvl Date: Sat, 16 Nov 2019 17:10:08 +0100 Subject: [PATCH 06/19] Introduced CxbxImpl_SetStreamSource, and simplified it's storage. Also some renaming and comments (all this copied over from Vsh_unpatching) --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 70 +++++++++++------------ src/core/hle/D3D8/XbVertexBuffer.cpp | 24 ++++++-- 2 files changed, 54 insertions(+), 40 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index 33a68dc33..0fff3e470 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -141,6 +141,13 @@ static bool g_bHack_DisableHostGPUQueries = false; // TO static IDirect3DQuery *g_pHostQueryWaitForIdle = nullptr; static IDirect3DQuery *g_pHostQueryCallbackEvent = nullptr; +// Vertex shader symbols, declared in XbVertexShader.cpp : +extern void CxbxImpl_SelectVertexShaderDirect(XTL::X_VERTEXATTRIBUTEFORMAT* pVAF, DWORD Address); +extern void CxbxImpl_SetVertexShaderInput(DWORD Handle, UINT StreamCount, XTL::X_STREAMINPUT* pStreamInputs); + +// Vertex buffer symbols, declared in XbVertexBuffer.cpp +extern void CxbxImpl_SetStreamSource(UINT StreamNumber, XTL::X_D3DVertexBuffer* pStreamData, UINT Stride); + static std::condition_variable g_VBConditionVariable; // Used in BlockUntilVerticalBlank static std::mutex g_VBConditionMutex; // Used in BlockUntilVerticalBlank static DWORD g_VBLastSwap = 0; @@ -173,9 +180,6 @@ static XTL::DWORD *g_Xbox_D3DDevice; // TODO: This should be a static DWORD g_dwVertexShaderUsage = 0; // Unused. If needed, move to XbVertexShader.cpp */ -// Active D3D Vertex Streams (and strides) - XTL::X_D3DVertexBuffer *g_D3DStreams[16]; - XTL::UINT g_D3DStreamStrides[16]; static XTL::DWORD g_VertexShaderSlots[X_VSH_MAX_INSTRUCTION_COUNT]; XTL::DWORD g_Xbox_VertexShader_Handle = 0; @@ -188,10 +192,6 @@ static DWORD WINAPI EmuUpdateTickCount(LPVOID); static inline void EmuVerifyResourceIsRegistered(XTL::X_D3DResource *pResource, DWORD D3DUsage, int iTextureStage, DWORD dwSize); static void UpdateCurrentMSpFAndFPS(); // Used for benchmarking/fps count -// Declared in XbVertexShader.cpp -extern void CxbxImpl_SetVertexShaderInput(DWORD Handle, UINT StreamCount, XTL::X_STREAMINPUT* pStreamInputs); -extern void CxbxImpl_SelectVertexShaderDirect(XTL::X_VERTEXATTRIBUTEFORMAT* pVAF, DWORD Address); - extern void UpdateFPSCounter(); typedef uint64_t resource_key_t; @@ -3424,7 +3424,7 @@ XTL::X_D3DSurface* WINAPI XTL::EMUPATCH(D3DDevice_GetBackBuffer2) /** unsafe, somehow HRESULT hRet = D3D_OK; - X_D3DSurface *pBackBuffer = EmuNewD3DSurface(); + X_D3DSurface *pXboxBackBuffer = EmuNewD3DSurface(); if(BackBuffer == -1) { static IDirect3DSurface *pCachedPrimarySurface = nullptr; @@ -3436,21 +3436,21 @@ XTL::X_D3DSurface* WINAPI XTL::EMUPATCH(D3DDevice_GetBackBuffer2) DEBUG_D3DRESULT(hRet, "g_pD3DDevice->CreateOffscreenPlainSurface"); } - SetHostSurface(pBackBuffer, pCachedPrimarySurface); + SetHostSurface(pXboxBackBuffer, pCachedPrimarySurface); hRet = g_pD3DDevice->GetFrontBuffer(pCachedPrimarySurface); DEBUG_D3DRESULT(hRet, "g_pD3DDevice->GetFrontBuffer"); if (FAILED(hRet)) { EmuLog(LOG_LEVEL::WARNING, "Could not retrieve primary surface, using backbuffer"); - SetHostSurface(pBackBuffer, nullptr); + SetHostSurface(pXboxBackBuffer, nullptr); pCachedPrimarySurface->Release(); pCachedPrimarySurface = nullptr; BackBuffer = 0; } // Debug: Save this image temporarily - //D3DXSaveSurfaceToFile("C:\\Aaron\\Textures\\FrontBuffer.bmp", D3DXIFF_BMP, GetHostSurface(pBackBuffer), nullptr, nullptr); + //D3DXSaveSurfaceToFile("C:\\Aaron\\Textures\\FrontBuffer.bmp", D3DXIFF_BMP, GetHostSurface(pXboxBackBuffer), nullptr, nullptr); } if(BackBuffer != -1) { @@ -3461,7 +3461,7 @@ XTL::X_D3DSurface* WINAPI XTL::EMUPATCH(D3DDevice_GetBackBuffer2) } //*/ - static X_D3DSurface *pBackBuffer = EmuNewD3DSurface(); + static X_D3DSurface *pXboxBackBuffer = EmuNewD3DSurface(); IDirect3DSurface *pCurrentHostBackBuffer = nullptr; STATUS_SUCCESS; @@ -3478,12 +3478,12 @@ XTL::X_D3DSurface* WINAPI XTL::EMUPATCH(D3DDevice_GetBackBuffer2) if (FAILED(hRet)) CxbxKrnlCleanup("Unable to retrieve back buffer"); - SetHostSurface(pBackBuffer, pCurrentHostBackBuffer); + SetHostSurface(pXboxBackBuffer, pCurrentHostBackBuffer); // Increment reference count - pBackBuffer->Common++; // EMUPATCH(D3DResource_AddRef)(pBackBuffer); + pXboxBackBuffer->Common++; // EMUPATCH(D3DResource_AddRef)(pXboxBackBuffer); - return pBackBuffer; + return pXboxBackBuffer; #else // COPY_BACKBUFFER_TO_XBOX_SURFACE // Rather than create a new surface, we should forward to the Xbox version of GetBackBuffer, // This gives us the correct Xbox surface to update. @@ -6409,15 +6409,12 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetStreamSource_4) // LOG_FUNC_END; EmuLog(LOG_LEVEL::DEBUG, "D3DDevice_SetStreamSource_4(StreamNumber : %08X pStreamData : %08X Stride : %08X);", StreamNumber, pStreamData, Stride); - // Forward to Xbox implementation + CxbxImpl_SetStreamSource(StreamNumber, pStreamData, Stride); + + // TODO : Forward to Xbox implementation // This should stop us having to patch GetStreamSource! //XB_trampoline(VOID, WINAPI, D3DDevice_SetStreamSource_4, (UINT, X_D3DVertexBuffer*, UINT)); //XB_D3DDevice_SetStreamSource_4(StreamNumber, pStreamData, Stride); - - if (StreamNumber < 16) { - g_D3DStreams[StreamNumber] = pStreamData; - g_D3DStreamStrides[StreamNumber] = Stride; - } } // This uses a custom calling convention where parameter is passed in EAX @@ -6442,15 +6439,12 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetStreamSource_8) // LOG_FUNC_END; EmuLog(LOG_LEVEL::DEBUG, "D3DDevice_SetStreamSource_8(StreamNumber : %08X pStreamData : %08X Stride : %08X);", StreamNumber, pStreamData, Stride); + CxbxImpl_SetStreamSource(StreamNumber, pStreamData, Stride); + // TODO : Forward to Xbox implementation // This should stop us having to patch GetStreamSource! //XB_trampoline(VOID, WINAPI, D3DDevice_SetStreamSource_8, (X_D3DVertexBuffer*, UINT)); //XB_D3DDevice_SetStreamSource_8(pStreamData, Stride); - - if (StreamNumber < 16) { - g_D3DStreams[StreamNumber] = pStreamData; - g_D3DStreamStrides[StreamNumber] = Stride; - } } // ****************************************************************** @@ -6469,19 +6463,12 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetStreamSource) LOG_FUNC_ARG(Stride) LOG_FUNC_END; + CxbxImpl_SetStreamSource(StreamNumber, pStreamData, Stride); + // Forward to Xbox implementation // This should stop us having to patch GetStreamSource! XB_trampoline(VOID, WINAPI, D3DDevice_SetStreamSource, (UINT, X_D3DVertexBuffer*, UINT)); XB_D3DDevice_SetStreamSource(StreamNumber, pStreamData, Stride); - - if(pStreamData != xbnullptr && Stride == 0){ - LOG_TEST_CASE("Stream stride set to 0"); - } - - if (StreamNumber < 16) { - g_D3DStreams[StreamNumber] = pStreamData; - g_D3DStreamStrides[StreamNumber] = Stride; - } } // ****************************************************************** @@ -7937,6 +7924,16 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexShaderInput) LOG_FUNC_ARG(pStreamInputs) LOG_FUNC_END; + // When this API is in effect, VertexBuffers as set by Xbox SetStreamSource are disregarded, + // instead, the pStreamInputs[].VertexBuffer streams are used. + + // If Handle is NULL, all VertexShader input state is cleared (after which the VertexBuffers as set by SetStreamSource are used once again). + + // Otherwise, Handle is the address of an Xbox VertexShader struct, or-ed with 1 (X_D3DFVF_RESERVED0) + // The given pStreamInputs are stored in a global array, and the NV2A is programmed to read + // each vertex attribute (as defined in the given VertexShader.VertexAttribute.Slots[]) to read + // the attribute data from the pStreamInputs[slot].VertexBuffer + pStreamInputs[slot].Offset + VertexShader.VertexAttribute.Slots[slot].Offset + CxbxImpl_SetVertexShaderInput(Handle, StreamCount, pStreamInputs); } @@ -7954,6 +7951,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_RunVertexStateShader) LOG_FUNC_ARG(pData) LOG_FUNC_END; + // If pData is assigned, pData[0..3] is pushed towards nv2a transform data registers + // then sends the nv2a a command to launch the vertex shader function located at Address + LOG_UNIMPLEMENTED(); } diff --git a/src/core/hle/D3D8/XbVertexBuffer.cpp b/src/core/hle/D3D8/XbVertexBuffer.cpp index 36ea192d6..27719ee22 100644 --- a/src/core/hle/D3D8/XbVertexBuffer.cpp +++ b/src/core/hle/D3D8/XbVertexBuffer.cpp @@ -55,8 +55,10 @@ FLOAT *g_InlineVertexBuffer_pData = nullptr; UINT g_InlineVertexBuffer_DataSize = 0; extern DWORD g_dwPrimPerFrame = 0; -extern XTL::X_D3DVertexBuffer*g_D3DStreams[X_VSH_MAX_STREAMS]; -extern UINT g_D3DStreamStrides[X_VSH_MAX_STREAMS]; + +// Copy of active Xbox D3D Vertex Streams (and strides), set by [D3DDevice|CxbxImpl]_SetStreamSource* +XTL::X_STREAMINPUT g_SetStreamSources[X_VSH_MAX_STREAMS] = { 0 }; // Note : .Offset member is never set (so always 0) + extern XTL::X_D3DSurface* g_pXbox_RenderTarget; extern XTL::X_D3DSurface* g_pXbox_BackBufferSurface; void *GetDataFromXboxResource(XTL::X_D3DResource *pXboxResource); @@ -118,7 +120,7 @@ int CountActiveD3DStreams() { int lastStreamIndex = 0; for (int i = 0; i < X_VSH_MAX_STREAMS; i++) { - if (g_D3DStreams[i] != xbnullptr) { + if (g_SetStreamSources[i].VertexBuffer != xbnullptr) { lastStreamIndex = i + 1; } } @@ -292,7 +294,7 @@ void CxbxVertexBufferConverter::ConvertStream uiHostVertexStride = (bNeedVertexPatching) ? pVertexShaderStreamInfo->HostVertexStride : uiXboxVertexStride; dwHostVertexDataSize = uiVertexCount * uiHostVertexStride; } else { - XTL::X_D3DVertexBuffer *pXboxVertexBuffer = g_D3DStreams[uiStream]; + XTL::X_D3DVertexBuffer *pXboxVertexBuffer = g_SetStreamSources[uiStream].VertexBuffer; pXboxVertexData = (uint8_t*)GetDataFromXboxResource(pXboxVertexBuffer); if (pXboxVertexData == xbnullptr) { HRESULT hRet = g_pD3DDevice->SetStreamSource( @@ -308,7 +310,7 @@ void CxbxVertexBufferConverter::ConvertStream return; } - uiXboxVertexStride = g_D3DStreamStrides[uiStream]; + uiXboxVertexStride = g_SetStreamSources[uiStream].Stride; // Set a new (exact) vertex count uiVertexCount = pDrawContext->VerticesInBuffer; // Dxbx note : Don't overwrite pDrawContext.dwVertexCount with uiVertexCount, because an indexed draw @@ -987,3 +989,15 @@ VOID EmuFlushIVB() } g_InlineVertexBuffer_TableOffset = 0; // Might not be needed (also cleared in D3DDevice_Begin) } + +void CxbxImpl_SetStreamSource(UINT StreamNumber, XTL::X_D3DVertexBuffer* pStreamData, UINT Stride) +{ + if (pStreamData != xbnullptr && Stride == 0) { + LOG_TEST_CASE("CxbxImpl_SetStreamSource : Stream assigned, and stride set to 0 (might be okay)"); + } + + assert(StreamNumber < X_VSH_MAX_STREAMS); + + g_SetStreamSources[StreamNumber].VertexBuffer = pStreamData; + g_SetStreamSources[StreamNumber].Stride = Stride; +} From 070316c677710c6fd272de50feaeab3574a5464a Mon Sep 17 00:00:00 2001 From: patrickvl Date: Sat, 16 Nov 2019 15:50:02 +0100 Subject: [PATCH 07/19] Updated CONTRIBUTORS once more and renamed setup.cmd to setup.bat per RadWolfie's suggestion --- CONTRIBUTORS | 113 +++++++++++++++++++++++++++++------------ setup.cmd => setup.bat | 0 2 files changed, 80 insertions(+), 33 deletions(-) rename setup.cmd => setup.bat (100%) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 8bfe34d4e..43e98770b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,43 +1,65 @@ -Contributors: -PatrickvL (Patrick van Logchem) -LukeUsher (Luke Usher) [SoullessSentinel] -RadWolfie -jarupxx -x1nixmzeng -Echelon9 +Contributors +------------ + +Cxbx-Reloaded has a rich history, with lots of contributors in it's various stages of life. +Cxbx-Reloaded was initiated by Luke Usher, as a fork of the then-dormant Cxbx, and inspired by Dxbx. +Cxbx was initiated by Caustik. Dxbx was initiated by shadowtj. + +The following contributors are grouped per project and listed in alphabetical order, +based on sources like https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/graphs/contributors , +http://www.caustik.com/cxbx/about.htm , http://emulation.gametechwiki.com/index.php/Cxbx , +and https://github.com/PatrickvL/Dxbx/graphs/contributors . + + +Cxbx-Reloaded Current Development Team: + ergo720 -blueshogun96 +LukeUsher (Luke Usher) [SoullessSentinel] NZJenkins +PatrickvL (Patrick van Logchem) +RadWolfie + + +Cxbx-Reloaded All-Time Contributors: + +aav7fl (Kyle Niewiada) anita999 -dstien -revel8n -Luca1991 (Luca D'Amico) [Luca91] -Fisherman166 -Margen67 -GXTX -Voxel9 -StrikerX3 +BenNottelling (Benjamin Aerni) +blueshogun96 CakeLancelot -jagotu -gandalfthewhite19890404 -donwayo -literalmente-game +darrena092 (Darren Anderson) +DiscoStarslayer (Darren Thompson) +donwayo (Wayo) +Ernegien (Mike Davis) +ergo720 +faha223 (Fred Hallock) +Fisherman166 +gandalfthewhite19890404 gellis713 -darrena092 -JayFoxRox -BenNottelling -Ernegien -phire -jackchentwkh -hrydgard ggKismet -aav7fl -TotalCaesar659 -DiscoStarslayer -(After https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/graphs/contributors) +GXTX (wutno) +hrydgard (Henrik Hydgard) +jackchentwkh +jagotu (JaGoTu) +jarupxx +JayFoxRox (Jannik Vogel) +literalmente-game +Luca1991 (Luca D'Amico) [Luca91] +LukeUsher (Luke Usher) [SoullessSentinel] +Margen67 +NZJenkins +PatrickvL (Patrick van Logchem) +phire (Scott Mansell) +RadWolfie +revel8n +StrikerX3 (Ivan Roberto de Oliveira) +TotalCaesar659 +Voxel9 (Voxel) +x1nixmzeng -Supporters: +Cxbx-Reloaded Supporters: + Cedric Wilson Cisco Martinez Cody Dale Barton @@ -57,5 +79,30 @@ Taylor Stock Yldri Yuri Kunde Schlesner -Special Thanks: + +Cxbx-Reloaded Special Thanks: + All contributors to the original Cxbx and Dxbx projects, without which Cxbx-Reloaded would not exist. + + +Cxbx contributors: + +_SF_ +blueshogun96 +Caustic (Aaron Robinson) +donwayo (Wayo) +dstien (Daniel Stien) +Echelon9 (Rhys Kidd) +Kingofc +Koitsu +martin_sw (Martin) +sopskrutt (Sop Skrutt) +Zomby + + +Dxbx contributors: + +donwayo (Wayo) +PatrickvL (Patrick van Logchem) +revel8n +shadowtj (Shadow_tj) diff --git a/setup.cmd b/setup.bat similarity index 100% rename from setup.cmd rename to setup.bat From 477ab534c5e66310c2920ef27b19848b2e5e864f Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Thu, 7 Nov 2019 18:26:34 +0100 Subject: [PATCH 08/19] This commit solved the fact that X_D3DRS_MULTISAMPLEMODE replaces the older X_D3DRS_MULTISAMPLETYPE (which was available below 4039). This allows restoring X_D3DRS_MULTISAMPLEMODE back to 4361 where it belongs (as far as we know). Adjusted X_D3DRS_MULTISAMPLERENDERTARGETMODE to XDK 4039 (was 4242) Made comments on DxbxRenderStateInfo and _X_D3DRENDERSTATETYPE consistent again. Also use X_D3DRS_* FIRST / LAST defines wherever applicable. This is a subset of work done earlier in https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/commit/67cfc36fcaceb92c12c3d05f818b6389119eeb0f --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 8 +- src/core/hle/D3D8/Direct3D9/RenderStates.cpp | 71 +++++++------ src/core/hle/D3D8/XbConvert.cpp | 103 +++++++++++-------- src/core/hle/D3D8/XbConvert.h | 5 +- src/core/hle/D3D8/XbD3D8Types.h | 22 ++-- 5 files changed, 116 insertions(+), 93 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index 74522f27b..f61482d25 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -6192,8 +6192,8 @@ VOID __fastcall XTL::EMUPATCH(D3DDevice_SetRenderState_Simple) // Fetch the RenderState conversion info for the given input int XboxRenderStateIndex = -1; - for (int i = 0; i <= X_D3DRS_DONOTCULLUNCOMPRESSED; i++) { - if (DxbxRenderStateInfo[i].M == PUSH_METHOD(Method)) { + for (int i = X_D3DRS_FIRST; i <= X_D3DRS_LAST; i++) { + if (GetDxbxRenderStateInfo(i).M == PUSH_METHOD(Method)) { XboxRenderStateIndex = i; break; } @@ -6201,11 +6201,11 @@ VOID __fastcall XTL::EMUPATCH(D3DDevice_SetRenderState_Simple) // If we could not map it, log and return if (XboxRenderStateIndex == -1) { - EmuLog(LOG_LEVEL::WARNING, "RenderState_Simple(0x%.08X (%s), 0x%.08X) could not be found in RenderState table", Method, DxbxRenderStateInfo[XboxRenderStateIndex].S, Value); + EmuLog(LOG_LEVEL::WARNING, "RenderState_Simple(0x%.08X (%s), 0x%.08X) could not be found in RenderState table", Method, GetDxbxRenderStateInfo(XboxRenderStateIndex).S, Value); return; } - EmuLog(LOG_LEVEL::DEBUG, "RenderState_Simple: %s = 0x%08X", DxbxRenderStateInfo[XboxRenderStateIndex].S, Value); + EmuLog(LOG_LEVEL::DEBUG, "RenderState_Simple: %s = 0x%08X", GetDxbxRenderStateInfo(XboxRenderStateIndex).S, Value); XboxRenderStates.SetXboxRenderState(XboxRenderStateIndex, Value); } diff --git a/src/core/hle/D3D8/Direct3D9/RenderStates.cpp b/src/core/hle/D3D8/Direct3D9/RenderStates.cpp index 297080e6c..2bb61989e 100644 --- a/src/core/hle/D3D8/Direct3D9/RenderStates.cpp +++ b/src/core/hle/D3D8/Direct3D9/RenderStates.cpp @@ -68,8 +68,8 @@ void XboxRenderStateConverter::VerifyAndFixDeferredRenderStateOffset() // Calculate index of D3DRS_CULLMODE for this XDK. We start counting from the first deferred state (D3DRS_FOGENABLE) DWORD CullModeIndex = 0; - for (int i = XTL::X_D3DRS_FOGENABLE; i < XTL::X_D3DRS_CULLMODE; i++) { - if (DxbxRenderStateInfo[i].V <= g_LibVersion_D3D8) { + for (int i = XTL::X_D3DRS_DEFERRED_FIRST; i < XTL::X_D3DRS_CULLMODE; i++) { + if (GetDxbxRenderStateInfo(i).V <= g_LibVersion_D3D8) { CullModeIndex++; } } @@ -85,22 +85,22 @@ void XboxRenderStateConverter::VerifyAndFixDeferredRenderStateOffset() void XboxRenderStateConverter::DeriveRenderStateOffsetFromDeferredRenderStateOffset() { // When this function is called. D3D__RenderState actually points to the first deferred render state - // this is D3DRS_FOGENABLE. We can count back from this using our RenderStateInfo table to find + // (this is X_D3DRS_FOGENABLE). We can count back from this using our RenderStateInfo table to find // the start of D3D__RenderStates. - // Count the number of render states (for this XDK) between 0 and D3DRS_FOGENABLE - int FogEnableOffset = 0; - for (unsigned int RenderState = XTL::X_D3DRS_PSALPHAINPUTS0; RenderState < XTL::X_D3DRS_FOGENABLE; RenderState++) { + // Count the number of render states (for this XDK) between 0 and the first deferred render state (D3DRS_FOGENABLE) + int FirstDeferredRenderStateOffset = 0; + for (unsigned int RenderState = XTL::X_D3DRS_FIRST; RenderState < XTL::X_D3DRS_DEFERRED_FIRST; RenderState++) { // if the current renderstate exists in this XDK version, count it - if (DxbxRenderStateInfo[RenderState].V <= g_LibVersion_D3D8) { - FogEnableOffset++; + if (GetDxbxRenderStateInfo(RenderState).V <= g_LibVersion_D3D8) { + FirstDeferredRenderStateOffset++; } } - // At this point, FogEnableOffset should point to the index of D3DRS_FOGENABLE for the given XDK + // At this point, FirstDeferredRenderStateOffset should point to the index of D3DRS_FOGENABLE for the given XDK // This will be correct as long as our table DxbxRenderStateInfo is correct // We can get the correct 0 offset by using a negative index - D3D__RenderState = &D3D__RenderState[-FogEnableOffset]; + D3D__RenderState = &D3D__RenderState[-FirstDeferredRenderStateOffset]; } void XboxRenderStateConverter::BuildRenderStateMappingTable() @@ -110,15 +110,16 @@ void XboxRenderStateConverter::BuildRenderStateMappingTable() XboxRenderStateOffsets.fill(-1); int XboxIndex = 0; - for (unsigned int RenderState = XTL::X_D3DRS_PSALPHAINPUTS0; RenderState <= XTL::X_D3DRS_LAST; RenderState++) { - if (DxbxRenderStateInfo[RenderState].V <= g_LibVersion_D3D8) { + for (unsigned int RenderState = XTL::X_D3DRS_FIRST; RenderState <= XTL::X_D3DRS_LAST; RenderState++) { + auto RenderStateInfo = GetDxbxRenderStateInfo(RenderState); + if (RenderStateInfo.V <= g_LibVersion_D3D8) { XboxRenderStateOffsets[RenderState] = XboxIndex; - EmuLog(LOG_LEVEL::INFO, "%s = %d", DxbxRenderStateInfo[RenderState].S, XboxIndex); + EmuLog(LOG_LEVEL::INFO, "%s = %d", RenderStateInfo.S, XboxIndex); XboxIndex++; continue; } - EmuLog(LOG_LEVEL::INFO, "%s Not Present", DxbxRenderStateInfo[RenderState].S); + EmuLog(LOG_LEVEL::INFO, "%s Not Present", RenderStateInfo.S); } } @@ -153,7 +154,7 @@ bool XboxRenderStateConverter::XboxRenderStateValueChanged(uint32_t State) void XboxRenderStateConverter::SetXboxRenderState(uint32_t State, uint32_t Value) { if (!XboxRenderStateExists(State)) { - EmuLog(LOG_LEVEL::WARNING, "Attempt to write a Renderstate (%s) that does not exist in the current D3D8 XDK Version (%d)", DxbxRenderStateInfo[State].S, g_LibVersion_D3D8); + EmuLog(LOG_LEVEL::WARNING, "Attempt to write a Renderstate (%s) that does not exist in the current D3D8 XDK Version (%d)", GetDxbxRenderStateInfo(State).S, g_LibVersion_D3D8); return; } @@ -163,7 +164,7 @@ void XboxRenderStateConverter::SetXboxRenderState(uint32_t State, uint32_t Value uint32_t XboxRenderStateConverter::GetXboxRenderState(uint32_t State) { if (!XboxRenderStateExists(State)) { - EmuLog(LOG_LEVEL::WARNING, "Attempt to read a Renderstate (%s) that does not exist in the current D3D8 XDK Version (%d)", DxbxRenderStateInfo[State].S, g_LibVersion_D3D8); + EmuLog(LOG_LEVEL::WARNING, "Attempt to read a Renderstate (%s) that does not exist in the current D3D8 XDK Version (%d)", GetDxbxRenderStateInfo(State).S, g_LibVersion_D3D8); return 0; } @@ -172,7 +173,7 @@ uint32_t XboxRenderStateConverter::GetXboxRenderState(uint32_t State) void XboxRenderStateConverter::StoreInitialValues() { - for (unsigned int RenderState = XTL::X_D3DRS_PSALPHAINPUTS0; RenderState <= XTL::X_D3DRS_LAST; RenderState++) { + for (unsigned int RenderState = XTL::X_D3DRS_FIRST; RenderState <= XTL::X_D3DRS_LAST; RenderState++) { // Skip Render States that don't exist within this XDK if (!XboxRenderStateExists(RenderState)) { continue; @@ -203,7 +204,7 @@ void XboxRenderStateConverter::Apply() } auto Value = GetXboxRenderState(RenderState); - EmuLog(LOG_LEVEL::DEBUG, "XboxRenderStateConverter::Apply(%s, %X)\n", DxbxRenderStateInfo[RenderState].S, Value); + EmuLog(LOG_LEVEL::DEBUG, "XboxRenderStateConverter::Apply(%s, %X)\n", GetDxbxRenderStateInfo(RenderState).S, Value); if (RenderState <= XTL::X_D3DRS_SIMPLE_LAST) { ApplySimpleRenderState(RenderState, Value); @@ -219,6 +220,8 @@ void XboxRenderStateConverter::Apply() void XboxRenderStateConverter::ApplySimpleRenderState(uint32_t State, uint32_t Value) { + auto RenderStateInfo = GetDxbxRenderStateInfo(State); + switch (State) { case XTL::X_D3DRS_COLORWRITEENABLE: { DWORD OrigValue = Value; @@ -278,23 +281,25 @@ void XboxRenderStateConverter::ApplySimpleRenderState(uint32_t State, uint32_t V break; default: // Only log missing state if it has a PC counterpart - if (DxbxRenderStateInfo[State].PC != 0) { - EmuLog(LOG_LEVEL::WARNING, "ApplySimpleRenderState(%s, 0x%.08X) is unimplemented!", DxbxRenderStateInfo[State].S, Value); + if (RenderStateInfo.PC != 0) { + EmuLog(LOG_LEVEL::WARNING, "ApplySimpleRenderState(%s, 0x%.08X) is unimplemented!", RenderStateInfo.S, Value); } return; } // Skip RenderStates that don't have a defined PC counterpart - if (DxbxRenderStateInfo[State].PC == 0) { + if (RenderStateInfo.PC == 0) { return; } - g_pD3DDevice->SetRenderState((D3DRENDERSTATETYPE)(DxbxRenderStateInfo[State].PC), Value); + g_pD3DDevice->SetRenderState((D3DRENDERSTATETYPE)(RenderStateInfo.PC), Value); } void XboxRenderStateConverter::ApplyDeferredRenderState(uint32_t State, uint32_t Value) { - // Convert from Xbox Data Formats to PC + auto RenderStateInfo = GetDxbxRenderStateInfo(State); + + // Convert from Xbox Data Formats to PC switch (State) { case XTL::X_D3DRS_FOGSTART: case XTL::X_D3DRS_FOGEND: { @@ -373,23 +378,25 @@ void XboxRenderStateConverter::ApplyDeferredRenderState(uint32_t State, uint32_t } break; default: // Only log missing state if it has a PC counterpart - if (DxbxRenderStateInfo[State].PC != 0) { - EmuLog(LOG_LEVEL::WARNING, "ApplyDeferredRenderState(%s, 0x%.08X) is unimplemented!", DxbxRenderStateInfo[State].S, Value); + if (RenderStateInfo.PC != 0) { + EmuLog(LOG_LEVEL::WARNING, "ApplyDeferredRenderState(%s, 0x%.08X) is unimplemented!", RenderStateInfo.S, Value); } return; } // Skip RenderStates that don't have a defined PC counterpart - if (DxbxRenderStateInfo[State].PC == 0) { + if (RenderStateInfo.PC == 0) { return; } - g_pD3DDevice->SetRenderState(DxbxRenderStateInfo[State].PC, Value); + g_pD3DDevice->SetRenderState(RenderStateInfo.PC, Value); } void XboxRenderStateConverter::ApplyComplexRenderState(uint32_t State, uint32_t Value) { - switch (State) { + auto RenderStateInfo = GetDxbxRenderStateInfo(State); + + switch (State) { case XTL::X_D3DRS_VERTEXBLEND: // convert from Xbox direct3d to PC direct3d enumeration if (Value <= 1) { @@ -439,16 +446,16 @@ void XboxRenderStateConverter::ApplyComplexRenderState(uint32_t State, uint32_t break; default: // Only log missing state if it has a PC counterpart - if (DxbxRenderStateInfo[State].PC != 0) { - EmuLog(LOG_LEVEL::WARNING, "ApplyComplexRenderState(%s, 0x%.08X) is unimplemented!", DxbxRenderStateInfo[State].S, Value); + if (RenderStateInfo.PC != 0) { + EmuLog(LOG_LEVEL::WARNING, "ApplyComplexRenderState(%s, 0x%.08X) is unimplemented!", RenderStateInfo.S, Value); } return; } // Skip RenderStates that don't have a defined PC counterpart - if (DxbxRenderStateInfo[State].PC == 0) { + if (RenderStateInfo.PC == 0) { return; } - g_pD3DDevice->SetRenderState(DxbxRenderStateInfo[State].PC, Value); + g_pD3DDevice->SetRenderState(RenderStateInfo.PC, Value); } diff --git a/src/core/hle/D3D8/XbConvert.cpp b/src/core/hle/D3D8/XbConvert.cpp index fa3bfb111..04a9a34b4 100644 --- a/src/core/hle/D3D8/XbConvert.cpp +++ b/src/core/hle/D3D8/XbConvert.cpp @@ -28,7 +28,9 @@ #define LOG_PREFIX CXBXR_MODULE::D3DCVT -#include "core\kernel\support\Emu.h" +#include "common\Settings.hpp" // for g_LibVersion_D3D8 +#include "core\kernel\support\Emu.h" + #include "XbConvert.h" // About format color components: @@ -1333,7 +1335,7 @@ void EmuUnswizzleBox const RenderStateInfo DxbxRenderStateInfo[] = { - // String Ord Version Type Method Native + // String Ord Version Type Method Native { "D3DRS_PSALPHAINPUTS0" /*= 0*/, 3424, xtDWORD, NV2A_RC_IN_ALPHA(0) }, { "D3DRS_PSALPHAINPUTS1" /*= 1*/, 3424, xtDWORD, NV2A_RC_IN_ALPHA(1) }, { "D3DRS_PSALPHAINPUTS2" /*= 2*/, 3424, xtDWORD, NV2A_RC_IN_ALPHA(2) }, @@ -1413,7 +1415,7 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_BLENDCOLOR" /*= 75*/, 3424, xtD3DCOLOR, NV2A_BLEND_COLOR, D3DRS_BLENDFACTOR, "D3DCOLOR for D3DBLEND_CONSTANTCOLOR" }, // D3D9 D3DRS_BLENDFACTOR : D3DCOLOR used for a constant blend factor during alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR { "D3DRS_SWATHWIDTH" /*= 76*/, 3424, xtD3DSWATH, NV2A_SWATH_WIDTH }, - { "D3DRS_POLYGONOFFSETZSLOPESCALE" /*= 77*/, 3424, xtFloat, NV2A_POLYGON_OFFSET_FACTOR, D3DRS_NONE, "float Z factor for shadow maps" }, + { "D3DRS_POLYGONOFFSETZSLOPESCALE" /*= 77*/, 3424, xtFloat, NV2A_POLYGON_OFFSET_FACTOR, D3DRS_UNSUPPORTED, "float Z factor for shadow maps" }, { "D3DRS_POLYGONOFFSETZOFFSET" /*= 78*/, 3424, xtFloat, NV2A_POLYGON_OFFSET_UNITS }, { "D3DRS_POINTOFFSETENABLE" /*= 79*/, 3424, xtBOOL, NV2A_POLYGON_OFFSET_POINT_ENABLE }, { "D3DRS_WIREFRAMEOFFSETENABLE" /*= 80*/, 3424, xtBOOL, NV2A_POLYGON_OFFSET_LINE_ENABLE }, @@ -1429,43 +1431,44 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_SIMPLE_UNUSED2" /*= 90*/, 4627, xtDWORD, 0 }, { "D3DRS_SIMPLE_UNUSED1" /*= 91*/, 4627, xtDWORD, 0 }, // End of "simple" render states, continuing with "deferred" render states : - { "D3DRS_FOGENABLE" /*= 92*/, 3424, xtBOOL, NV2A_FOG_ENABLE, D3DRS_FOGENABLE }, - { "D3DRS_FOGTABLEMODE" /*= 93*/, 3424, xtD3DFOGMODE, NV2A_FOG_MODE, D3DRS_FOGTABLEMODE }, - { "D3DRS_FOGSTART" /*= 94*/, 3424, xtFloat, NV2A_FOG_COORD_DIST, D3DRS_FOGSTART }, - { "D3DRS_FOGEND" /*= 95*/, 3424, xtFloat, NV2A_FOG_MODE, D3DRS_FOGEND }, - { "D3DRS_FOGDENSITY" /*= 96*/, 3424, xtFloat, NV2A_FOG_EQUATION_CONSTANT, D3DRS_FOGDENSITY }, // + NV2A_FOG_EQUATION_LINEAR + NV2A_FOG_EQUATION_QUADRATIC - { "D3DRS_RANGEFOGENABLE" /*= 97*/, 3424, xtBOOL, NV2A_FOG_COORD_DIST, D3DRS_RANGEFOGENABLE }, - { "D3DRS_WRAP0" /*= 98*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(0), D3DRS_WRAP0 }, - { "D3DRS_WRAP1" /*= 99*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(1), D3DRS_WRAP1 }, - { "D3DRS_WRAP2" /*= 100*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(2), D3DRS_WRAP2 }, - { "D3DRS_WRAP3" /*= 101*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(3), D3DRS_WRAP3 }, - { "D3DRS_LIGHTING" /*= 102*/, 3424, xtBOOL, NV2A_LIGHT_MODEL, D3DRS_LIGHTING }, // TODO : Needs push-buffer data conversion - { "D3DRS_SPECULARENABLE" /*= 103*/, 3424, xtBOOL, NV2A_RC_FINAL0, D3DRS_SPECULARENABLE }, - { "D3DRS_LOCALVIEWER" /*= 104*/, 3424, xtBOOL, 0, D3DRS_LOCALVIEWER }, - { "D3DRS_COLORVERTEX" /*= 105*/, 3424, xtBOOL, 0, D3DRS_COLORVERTEX }, - { "D3DRS_BACKSPECULARMATERIALSOURCE" /*= 106*/, 3424, xtD3DMCS, 0 }, // nsp. - { "D3DRS_BACKDIFFUSEMATERIALSOURCE" /*= 107*/, 3424, xtD3DMCS, 0 }, // nsp. - { "D3DRS_BACKAMBIENTMATERIALSOURCE" /*= 108*/, 3424, xtD3DMCS, 0 }, // nsp. - { "D3DRS_BACKEMISSIVEMATERIALSOURCE" /*= 109*/, 3424, xtD3DMCS, 0 }, // nsp. - { "D3DRS_SPECULARMATERIALSOURCE" /*= 110*/, 3424, xtD3DMCS, NV2A_COLOR_MATERIAL, D3DRS_SPECULARMATERIALSOURCE }, - { "D3DRS_DIFFUSEMATERIALSOURCE" /*= 111*/, 3424, xtD3DMCS, 0, D3DRS_DIFFUSEMATERIALSOURCE }, - { "D3DRS_AMBIENTMATERIALSOURCE" /*= 112*/, 3424, xtD3DMCS, 0, D3DRS_AMBIENTMATERIALSOURCE }, - { "D3DRS_EMISSIVEMATERIALSOURCE" /*= 113*/, 3424, xtD3DMCS, 0, D3DRS_EMISSIVEMATERIALSOURCE }, - { "D3DRS_BACKAMBIENT" /*= 114*/, 3424, xtD3DCOLOR, NV2A_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R }, // ..NV2A_MATERIAL_FACTOR_BACK_B nsp. Was NV2A_LIGHT_MODEL_BACK_AMBIENT_R - { "D3DRS_AMBIENT" /*= 115*/, 3424, xtD3DCOLOR, NV2A_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R, D3DRS_AMBIENT }, // ..NV2A_LIGHT_MODEL_FRONT_AMBIENT_B + NV2A_MATERIAL_FACTOR_FRONT_R..NV2A_MATERIAL_FACTOR_FRONT_A Was NV2A_LIGHT_MODEL_FRONT_AMBIENT_R - { "D3DRS_POINTSIZE" /*= 116*/, 3424, xtFloat, NV2A_POINT_PARAMETER(0), D3DRS_POINTSIZE }, - { "D3DRS_POINTSIZE_MIN" /*= 117*/, 3424, xtFloat, 0, D3DRS_POINTSIZE_MIN }, - { "D3DRS_POINTSPRITEENABLE" /*= 118*/, 3424, xtBOOL, NV2A_POINT_SMOOTH_ENABLE, D3DRS_POINTSPRITEENABLE }, - { "D3DRS_POINTSCALEENABLE" /*= 119*/, 3424, xtBOOL, NV2A_POINT_PARAMETERS_ENABLE, D3DRS_POINTSCALEENABLE }, - { "D3DRS_POINTSCALE_A" /*= 120*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_A }, - { "D3DRS_POINTSCALE_B" /*= 121*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_B }, - { "D3DRS_POINTSCALE_C" /*= 122*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_C }, - { "D3DRS_POINTSIZE_MAX" /*= 123*/, 3424, xtFloat, 0, D3DRS_POINTSIZE_MAX }, - { "D3DRS_PATCHEDGESTYLE" /*= 124*/, 3424, xtDWORD, 0, D3DRS_PATCHEDGESTYLE }, // D3DPATCHEDGESTYLE? - { "D3DRS_PATCHSEGMENTS" /*= 125*/, 3424, xtDWORD, 0 }, // nsp. // D3DRS_PATCHSEGMENTS exists in Direct3D 8, but not in 9 !? + // Verified as XDK 3911 Deferred RenderStates (3424 yet to do) + { "D3DRS_FOGENABLE" /*= 92*/, 3424, xtBOOL, NV2A_FOG_ENABLE, D3DRS_FOGENABLE }, // TRUE to enable fog blending + { "D3DRS_FOGTABLEMODE" /*= 93*/, 3424, xtD3DFOGMODE, NV2A_FOG_MODE, D3DRS_FOGTABLEMODE }, // D3DFOGMODE + { "D3DRS_FOGSTART" /*= 94*/, 3424, xtFloat, NV2A_FOG_COORD_DIST, D3DRS_FOGSTART }, // float fog start (for both vertex and pixel fog) + { "D3DRS_FOGEND" /*= 95*/, 3424, xtFloat, NV2A_FOG_MODE, D3DRS_FOGEND }, // float fog end + { "D3DRS_FOGDENSITY" /*= 96*/, 3424, xtFloat, NV2A_FOG_EQUATION_CONSTANT, D3DRS_FOGDENSITY }, // float fog density // + NV2A_FOG_EQUATION_LINEAR + NV2A_FOG_EQUATION_QUADRATIC + { "D3DRS_RANGEFOGENABLE" /*= 97*/, 3424, xtBOOL, NV2A_FOG_COORD_DIST, D3DRS_RANGEFOGENABLE }, // TRUE to enable range-based fog + { "D3DRS_WRAP0" /*= 98*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(0), D3DRS_WRAP0 }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 1st texture coord. + { "D3DRS_WRAP1" /*= 99*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(1), D3DRS_WRAP1 }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 2nd texture coord. + { "D3DRS_WRAP2" /*= 100*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(2), D3DRS_WRAP2 }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 3rd texture coord. + { "D3DRS_WRAP3" /*= 101*/, 3424, xtD3DWRAP, NV2A_TX_WRAP(3), D3DRS_WRAP3 }, // D3DWRAP* flags (D3DWRAP_U, D3DWRAPCOORD_0, etc.) for 4th texture coord. + { "D3DRS_LIGHTING" /*= 102*/, 3424, xtBOOL, NV2A_LIGHT_MODEL, D3DRS_LIGHTING }, // TRUE to enable lighting // TODO : Needs push-buffer data conversion + { "D3DRS_SPECULARENABLE" /*= 103*/, 3424, xtBOOL, NV2A_RC_FINAL0, D3DRS_SPECULARENABLE }, // TRUE to enable specular + { "D3DRS_LOCALVIEWER" /*= 104*/, 3424, xtBOOL, 0, D3DRS_LOCALVIEWER }, // TRUE to enable camera-relative specular highlights + { "D3DRS_COLORVERTEX" /*= 105*/, 3424, xtBOOL, 0, D3DRS_COLORVERTEX }, // TRUE to enable per-vertex color + { "D3DRS_BACKSPECULARMATERIALSOURCE" /*= 106*/, 3424, xtD3DMCS, 0 }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp. + { "D3DRS_BACKDIFFUSEMATERIALSOURCE" /*= 107*/, 3424, xtD3DMCS, 0 }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp. + { "D3DRS_BACKAMBIENTMATERIALSOURCE" /*= 108*/, 3424, xtD3DMCS, 0 }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp. + { "D3DRS_BACKEMISSIVEMATERIALSOURCE" /*= 109*/, 3424, xtD3DMCS, 0 }, // D3DMATERIALCOLORSOURCE (Xbox extension) nsp. + { "D3DRS_SPECULARMATERIALSOURCE" /*= 110*/, 3424, xtD3DMCS, NV2A_COLOR_MATERIAL, D3DRS_SPECULARMATERIALSOURCE }, // D3DMATERIALCOLORSOURCE + { "D3DRS_DIFFUSEMATERIALSOURCE" /*= 111*/, 3424, xtD3DMCS, 0, D3DRS_DIFFUSEMATERIALSOURCE }, // D3DMATERIALCOLORSOURCE + { "D3DRS_AMBIENTMATERIALSOURCE" /*= 112*/, 3424, xtD3DMCS, 0, D3DRS_AMBIENTMATERIALSOURCE }, // D3DMATERIALCOLORSOURCE + { "D3DRS_EMISSIVEMATERIALSOURCE" /*= 113*/, 3424, xtD3DMCS, 0, D3DRS_EMISSIVEMATERIALSOURCE }, // D3DMATERIALCOLORSOURCE + { "D3DRS_BACKAMBIENT" /*= 114*/, 3424, xtD3DCOLOR, NV2A_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R }, // D3DCOLOR (Xbox extension) // ..NV2A_MATERIAL_FACTOR_BACK_B nsp. Was NV2A_LIGHT_MODEL_BACK_AMBIENT_R + { "D3DRS_AMBIENT" /*= 115*/, 3424, xtD3DCOLOR, NV2A_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R, 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 + { "D3DRS_POINTSIZE" /*= 116*/, 3424, xtFloat, NV2A_POINT_PARAMETER(0), D3DRS_POINTSIZE }, // float point size + { "D3DRS_POINTSIZE_MIN" /*= 117*/, 3424, xtFloat, 0, D3DRS_POINTSIZE_MIN }, // float point size min threshold + { "D3DRS_POINTSPRITEENABLE" /*= 118*/, 3424, xtBOOL, NV2A_POINT_SMOOTH_ENABLE, D3DRS_POINTSPRITEENABLE }, // TRUE to enable point sprites + { "D3DRS_POINTSCALEENABLE" /*= 119*/, 3424, xtBOOL, NV2A_POINT_PARAMETERS_ENABLE, D3DRS_POINTSCALEENABLE }, // TRUE to enable point size scaling + { "D3DRS_POINTSCALE_A" /*= 120*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_A }, // float point attenuation A value + { "D3DRS_POINTSCALE_B" /*= 121*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_B }, // float point attenuation B value + { "D3DRS_POINTSCALE_C" /*= 122*/, 3424, xtFloat, 0, D3DRS_POINTSCALE_C }, // float point attenuation C value + { "D3DRS_POINTSIZE_MAX" /*= 123*/, 3424, xtFloat, 0, D3DRS_POINTSIZE_MAX }, // float point size max threshold + { "D3DRS_PATCHEDGESTYLE" /*= 124*/, 3424, xtDWORD, 0, D3DRS_PATCHEDGESTYLE }, // D3DPATCHEDGESTYLE + { "D3DRS_PATCHSEGMENTS" /*= 125*/, 3424, xtDWORD, 0 }, // 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? - { "D3DRS_SWAPFILTER" /*= 126*/, 4039, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_NONE, "D3DTEXF_LINEAR etc. filter to use for Swap" }, // nsp. - { "D3DRS_PRESENTATIONINTERVAL" /*= 127*/, 4627, xtDWORD, 0 }, // nsp. + { "D3DRS_SWAPFILTER" /*= 126*/, 4039, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "D3DTEXF_LINEAR etc. filter to use for Swap" }, // nsp. + { "D3DRS_PRESENTATIONINTERVAL" /*= 127*/, 4627, xtDWORD, 0 }, // nsp. TODO : Use 4361? { "D3DRS_DEFERRED_UNUSED8" /*= 128*/, 4627, xtDWORD, 0 }, { "D3DRS_DEFERRED_UNUSED7" /*= 129*/, 4627, xtDWORD, 0 }, { "D3DRS_DEFERRED_UNUSED6" /*= 130*/, 4627, xtDWORD, 0 }, @@ -1475,7 +1478,7 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_DEFERRED_UNUSED2" /*= 134*/, 4627, xtDWORD, 0 }, { "D3DRS_DEFERRED_UNUSED1" /*= 135*/, 4627, xtDWORD, 0 }, // End of "deferred" render states, continuing with "complex" render states : - { "D3DRS_PSTEXTUREMODES" /*= 136*/, 3424, xtDWORD, 0 }, + { "D3DRS_PSTEXTUREMODES" /*= 136*/, 3424, xtDWORD, 0 }, // This is where pPSDef->PSTextureModes is stored (outside the pPSDEF - see DxbxUpdateActivePixelShader) { "D3DRS_VERTEXBLEND" /*= 137*/, 3424, xtD3DVERTEXBLENDFLAGS, NV2A_SKIN_MODE, D3DRS_VERTEXBLEND }, { "D3DRS_FOGCOLOR" /*= 138*/, 3424, xtD3DCOLOR, NV2A_FOG_COLOR, D3DRS_FOGCOLOR }, // SwapRgb { "D3DRS_FILLMODE" /*= 139*/, 3424, xtD3DFILLMODE, NV2A_POLYGON_MODE_FRONT, D3DRS_FILLMODE }, @@ -1493,12 +1496,12 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_EDGEANTIALIAS" /*= 151*/, 3424, xtBOOL, NV2A_LINE_SMOOTH_ENABLE, D3DRS_ANTIALIASEDLINEENABLE }, // Was D3DRS_EDGEANTIALIAS. Dxbx note : No Xbox ext. (according to Direct3D8) ! { "D3DRS_MULTISAMPLEANTIALIAS" /*= 152*/, 3424, xtBOOL, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEANTIALIAS }, { "D3DRS_MULTISAMPLEMASK" /*= 153*/, 3424, xtDWORD, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEMASK }, -// { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0 }, // [-3911] \_ aliasses D3DMULTISAMPLE_TYPE - { "D3DRS_MULTISAMPLEMODE" /*= 154*/, 3425 /* really 4361 but shares slot with previous entry */, xtD3DMULTISAMPLEMODE, 0 }, // [4361+] / D3DMULTISAMPLEMODE for the backbuffer - { "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 155*/, 4242, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT }, + // For D3DRS_MULTISAMPLETYPE, see DxbxRenderStateInfo_D3DRS_MULTISAMPLETYPE_below_4039 + { "D3DRS_MULTISAMPLEMODE" /*= 154*/, 4361, xtD3DMULTISAMPLEMODE, 0 }, // D3DMULTISAMPLEMODE for the backbuffer, might get replaced by DxbxRenderStateInfo_D3DRS_MULTISAMPLETYPE_below_4039 + { "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 155*/, 4039, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT }, // Was 4242 { "D3DRS_SHADOWFUNC" /*= 156*/, 3424, xtD3DCMPFUNC, NV2A_TX_RCOMP }, { "D3DRS_LINEWIDTH" /*= 157*/, 3424, xtFloat, NV2A_LINE_WIDTH }, - { "D3DRS_SAMPLEALPHA" /*= 158*/, 4627, xtD3DSAMPLEALPHA, 0 }, // TODO : Later than 3424, but earlier then 4627? + { "D3DRS_SAMPLEALPHA" /*= 158*/, 4627, xtD3DSAMPLEALPHA, 0 }, // TODO : Later than 3424, (still?) not in 4531, but possibly earlier than 4627? { "D3DRS_DXT1NOISEENABLE" /*= 159*/, 3424, xtBOOL, NV2A_CLEAR_DEPTH_VALUE }, { "D3DRS_YUVENABLE" /*= 160*/, 3911, xtBOOL, NV2A_CONTROL0 }, { "D3DRS_OCCLUSIONCULLENABLE" /*= 161*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, @@ -1507,6 +1510,18 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_ROPZREAD" /*= 164*/, 3911, xtBOOL, 0 }, { "D3DRS_DONOTCULLUNCOMPRESSED" /*= 165*/, 3911, xtBOOL, 0 } }; + +const RenderStateInfo DxbxRenderStateInfo_D3DRS_MULTISAMPLETYPE_below_4039 = + { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0 }; // aliasses D3DMULTISAMPLE_TYPE + +const RenderStateInfo& GetDxbxRenderStateInfo(int State) +{ + if (State == XTL::X_D3DRS_MULTISAMPLEMODE) // replace by old X_D3DRS_MULTISAMPLETYPE below 4039 + if (g_LibVersion_D3D8 < 4039) + return DxbxRenderStateInfo_D3DRS_MULTISAMPLETYPE_below_4039; + + return DxbxRenderStateInfo[State]; +} /*Direct3D8 states unused : D3DRS_LINEPATTERN diff --git a/src/core/hle/D3D8/XbConvert.h b/src/core/hle/D3D8/XbConvert.h index 8ee2c3cfe..08e96dc5c 100644 --- a/src/core/hle/D3D8/XbConvert.h +++ b/src/core/hle/D3D8/XbConvert.h @@ -1814,8 +1814,9 @@ typedef struct _RenderStateInfo { } RenderStateInfo; -#define D3DRS_NONE ((D3DRENDERSTATETYPE)0) +#define D3DRS_UNSUPPORTED ((D3DRENDERSTATETYPE)0) + +extern const RenderStateInfo& GetDxbxRenderStateInfo(int State); -extern const RenderStateInfo DxbxRenderStateInfo[]; #endif diff --git a/src/core/hle/D3D8/XbD3D8Types.h b/src/core/hle/D3D8/XbD3D8Types.h index 6131804ab..9e9958c48 100644 --- a/src/core/hle/D3D8/XbD3D8Types.h +++ b/src/core/hle/D3D8/XbD3D8Types.h @@ -84,8 +84,8 @@ #define IDirect3DSwapChain IDirect3DSwapChain9 #define IDirect3DQuery IDirect3DQuery9 -namespace XTL { - +namespace XTL { + // TODO : Declare these aliasses as Xbox type typedef D3DLIGHT9 X_D3DLIGHT8; typedef D3DMATERIAL9 X_D3DMATERIAL8; @@ -649,7 +649,7 @@ typedef enum _X_D3DRENDERSTATETYPE { // Dxbx note : These declarations are from XDK version 5933, the most recent and complete version. // Older versions are slightly different (some members are missing), so we use a mapping table to - // cater for the differences (see DxbxBuildRenderStateMappingTable). This enables to ignore these + // cater for the differences (see XboxRenderStateConverter::BuildRenderStateMappingTable). This enables to ignore these // version-differences in the rest of our code (unless it matters somehow); We write like this : // XboxRenderStates.SetXboxRenderState(X_D3DRENDERSTATETYPE, Value); // @@ -737,14 +737,14 @@ typedef enum _X_D3DRENDERSTATETYPE { X_D3DRS_STENCILMASK = 72, // BYTE mask value used in stencil test X_D3DRS_STENCILWRITEMASK = 73, // BYTE write mask applied to values written to stencil buffer X_D3DRS_BLENDOP = 74, // D3DBLENDOP setting - X_D3DRS_BLENDCOLOR = 75, // D3DCOLOR for D3DBLEND_CONSTANTCOLOR (Xbox ext.) + X_D3DRS_BLENDCOLOR = 75, // D3DCOLOR for D3DBLEND_CONSTANTCOLOR X_D3DRS_SWATHWIDTH = 76, // D3DSWATHWIDTH (Xbox ext.) X_D3DRS_POLYGONOFFSETZSLOPESCALE = 77, // float Z factor for shadow maps (Xbox ext.) X_D3DRS_POLYGONOFFSETZOFFSET = 78, // Xbox ext. X_D3DRS_POINTOFFSETENABLE = 79, // Xbox ext. X_D3DRS_WIREFRAMEOFFSETENABLE = 80, // Xbox ext. X_D3DRS_SOLIDOFFSETENABLE = 81, // Xbox ext. - X_D3DRS_DEPTHCLIPCONTROL = 82, // [4627+] Xbox ext. + X_D3DRS_DEPTHCLIPCONTROL = 82, // [4432+] Xbox ext. X_D3DRS_STIPPLEENABLE = 83, // [4627+] Xbox ext. X_D3DRS_SIMPLE_UNUSED8 = 84, // [4627+] X_D3DRS_SIMPLE_UNUSED7 = 85, // [4627+] @@ -789,8 +789,8 @@ typedef enum _X_D3DRENDERSTATETYPE { X_D3DRS_POINTSIZE_MAX = 123, X_D3DRS_PATCHEDGESTYLE = 124, // Dxbx addition X_D3DRS_PATCHSEGMENTS = 125, - X_D3DRS_SWAPFILTER = 126, // [4361+] Xbox ext. nsp. D3DTEXF_LINEAR etc. filter to use for Swap - X_D3DRS_PRESENTATIONINTERVAL = 127, // [4627+] Xbox ext. nsp. + X_D3DRS_SWAPFILTER = 126, // [4039+] Xbox ext. nsp. D3DTEXF_LINEAR etc. filter to use for Swap + X_D3DRS_PRESENTATIONINTERVAL = 127, // [4627+] Xbox ext. nsp. TODO : Use 4361? X_D3DRS_DEFERRED_UNUSED8 = 128, // [4627+] X_D3DRS_DEFERRED_UNUSED7 = 129, // [4627+] X_D3DRS_DEFERRED_UNUSED6 = 130, // [4627+] @@ -814,13 +814,13 @@ typedef enum _X_D3DRENDERSTATETYPE { X_D3DRS_CULLMODE = 147, X_D3DRS_TEXTUREFACTOR = 148, X_D3DRS_ZBIAS = 149, - X_D3DRS_LOGICOP = 150, // Xbox ext. + X_D3DRS_LOGICOP = 150, // Xbox ext. nsp. X_D3DRS_EDGEANTIALIAS = 151, // Dxbx note : No Xbox ext. (according to Direct3D8) ! X_D3DRS_MULTISAMPLEANTIALIAS = 152, X_D3DRS_MULTISAMPLEMASK = 153, - X_D3DRS_MULTISAMPLETYPE = 154, // [-3911] Xbox ext. \_ aliasses D3DMULTISAMPLE_TYPE + X_D3DRS_MULTISAMPLETYPE = 154, // [-4039] Xbox ext. \_ aliasses D3DMULTISAMPLE_TYPE X_D3DRS_MULTISAMPLEMODE = 154, // [4361+] Xbox ext. / D3DMULTISAMPLEMODE for the backbuffer - X_D3DRS_MULTISAMPLERENDERTARGETMODE = 155, // [4361+] Xbox ext. + X_D3DRS_MULTISAMPLERENDERTARGETMODE = 155, // [4039+] Xbox ext. X_D3DRS_SHADOWFUNC = 156, // D3DCMPFUNC (Xbox extension) X_D3DRS_LINEWIDTH = 157, // Xbox ext. X_D3DRS_SAMPLEALPHA = 158, // Xbox ext. @@ -1211,6 +1211,6 @@ typedef DWORD NV2AMETHOD; // Host vertex shader counts #define CXBX_D3DVS_CONSTREG_VERTEXDATA4F_BASE (X_D3DVS_CONSTREG_COUNT + 1) -} // end of namespace XTL +} // end of namespace XTL #endif From 2c46324320289f90b5f999870a93b4669f5305d9 Mon Sep 17 00:00:00 2001 From: patrickvl Date: Sat, 16 Nov 2019 22:32:49 +0100 Subject: [PATCH 09/19] Replaced two literal numbers by their corresponding symbols (no functional change, just an improvement that was due) --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 4 ++-- src/core/hle/D3D8/XbVertexShader.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index 0fff3e470..c00a212b3 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -3630,8 +3630,8 @@ void UpdateViewPortOffsetAndScaleConstants() float vScale[] = { (2.0f / ViewPort.Width) * g_RenderScaleFactor, (-2.0f / ViewPort.Height) * g_RenderScaleFactor, 0.0f, 0.0f }; static float vOffset[] = { -1.0f, 1.0f, 0.0f, 1.0f }; - g_pD3DDevice->SetVertexShaderConstantF(58, vScale, 1); - g_pD3DDevice->SetVertexShaderConstantF(59, vOffset, 1); + g_pD3DDevice->SetVertexShaderConstantF(X_D3DVS_RESERVED_CONSTANT1_CORRECTED, vScale, 1); + g_pD3DDevice->SetVertexShaderConstantF(X_D3DVS_RESERVED_CONSTANT2_CORRECTED, vOffset, 1); } } diff --git a/src/core/hle/D3D8/XbVertexShader.cpp b/src/core/hle/D3D8/XbVertexShader.cpp index 7b3ec8e4f..8ad3f17a7 100644 --- a/src/core/hle/D3D8/XbVertexShader.cpp +++ b/src/core/hle/D3D8/XbVertexShader.cpp @@ -1468,7 +1468,7 @@ static void VshRemoveScreenSpaceInstructions(VSH_XBOX_SHADER *pShader) MulIntermediate.Parameters[1].Active = TRUE; MulIntermediate.Parameters[1].IndexesWithA0_X = FALSE; MulIntermediate.Parameters[1].Parameter.ParameterType = PARAM_C; - MulIntermediate.Parameters[1].Parameter.Address = ConvertCRegister(58); + MulIntermediate.Parameters[1].Parameter.Address = ConvertCRegister(X_D3DVS_RESERVED_CONSTANT1_CORRECTED); MulIntermediate.Parameters[1].Parameter.Neg = FALSE; VshSetSwizzle(&MulIntermediate.Parameters[1], SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W); MulIntermediate.Parameters[2].Active = FALSE; @@ -1481,7 +1481,7 @@ static void VshRemoveScreenSpaceInstructions(VSH_XBOX_SHADER *pShader) AddIntermediate.Output.Address = OREG_OPOS; AddIntermediate.Parameters[0].Parameter.ParameterType = PARAM_R; AddIntermediate.Parameters[0].Parameter.Address = 13; - AddIntermediate.Parameters[1].Parameter.Address = ConvertCRegister(59); + AddIntermediate.Parameters[1].Parameter.Address = ConvertCRegister(X_D3DVS_RESERVED_CONSTANT2_CORRECTED); VshInsertIntermediate(pShader, &AddIntermediate, ++i); } } From d5a5e9fc9a886ad8a75c23543d001c16716aedbc Mon Sep 17 00:00:00 2001 From: patrickvl Date: Sun, 17 Nov 2019 16:17:10 +0100 Subject: [PATCH 10/19] Disable X_D3DRS_MULTISAMPLETYPE in a simpler way, which also allows for easier disabling of other render states as well (would the need ever arise). --- src/core/hle/D3D8/Direct3D9/RenderStates.cpp | 8 ++++- src/core/hle/D3D8/XbConvert.cpp | 33 ++++++++------------ src/core/hle/D3D8/XbConvert.h | 3 +- src/core/hle/D3D8/XbD3D8Types.h | 27 ++++++++-------- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/RenderStates.cpp b/src/core/hle/D3D8/Direct3D9/RenderStates.cpp index 2bb61989e..61f297468 100644 --- a/src/core/hle/D3D8/Direct3D9/RenderStates.cpp +++ b/src/core/hle/D3D8/Direct3D9/RenderStates.cpp @@ -112,7 +112,13 @@ void XboxRenderStateConverter::BuildRenderStateMappingTable() int XboxIndex = 0; for (unsigned int RenderState = XTL::X_D3DRS_FIRST; RenderState <= XTL::X_D3DRS_LAST; RenderState++) { auto RenderStateInfo = GetDxbxRenderStateInfo(RenderState); - if (RenderStateInfo.V <= g_LibVersion_D3D8) { + bool bIsRenderStateAvailable = (RenderStateInfo.V <= g_LibVersion_D3D8); + if (RenderStateInfo.R > 0) { // Applies to XTL::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 &= (g_LibVersion_D3D8 < RenderStateInfo.R); + } + if (bIsRenderStateAvailable) { XboxRenderStateOffsets[RenderState] = XboxIndex; EmuLog(LOG_LEVEL::INFO, "%s = %d", RenderStateInfo.S, XboxIndex); XboxIndex++; diff --git a/src/core/hle/D3D8/XbConvert.cpp b/src/core/hle/D3D8/XbConvert.cpp index 04a9a34b4..18909b3bd 100644 --- a/src/core/hle/D3D8/XbConvert.cpp +++ b/src/core/hle/D3D8/XbConvert.cpp @@ -1496,30 +1496,23 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_EDGEANTIALIAS" /*= 151*/, 3424, xtBOOL, NV2A_LINE_SMOOTH_ENABLE, D3DRS_ANTIALIASEDLINEENABLE }, // Was D3DRS_EDGEANTIALIAS. Dxbx note : No Xbox ext. (according to Direct3D8) ! { "D3DRS_MULTISAMPLEANTIALIAS" /*= 152*/, 3424, xtBOOL, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEANTIALIAS }, { "D3DRS_MULTISAMPLEMASK" /*= 153*/, 3424, xtDWORD, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEMASK }, - // For D3DRS_MULTISAMPLETYPE, see DxbxRenderStateInfo_D3DRS_MULTISAMPLETYPE_below_4039 - { "D3DRS_MULTISAMPLEMODE" /*= 154*/, 4361, xtD3DMULTISAMPLEMODE, 0 }, // D3DMULTISAMPLEMODE for the backbuffer, might get replaced by DxbxRenderStateInfo_D3DRS_MULTISAMPLETYPE_below_4039 - { "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 155*/, 4039, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT }, // Was 4242 - { "D3DRS_SHADOWFUNC" /*= 156*/, 3424, xtD3DCMPFUNC, NV2A_TX_RCOMP }, - { "D3DRS_LINEWIDTH" /*= 157*/, 3424, xtFloat, NV2A_LINE_WIDTH }, - { "D3DRS_SAMPLEALPHA" /*= 158*/, 4627, xtD3DSAMPLEALPHA, 0 }, // TODO : Later than 3424, (still?) not in 4531, but possibly earlier than 4627? - { "D3DRS_DXT1NOISEENABLE" /*= 159*/, 3424, xtBOOL, NV2A_CLEAR_DEPTH_VALUE }, - { "D3DRS_YUVENABLE" /*= 160*/, 3911, xtBOOL, NV2A_CONTROL0 }, - { "D3DRS_OCCLUSIONCULLENABLE" /*= 161*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, - { "D3DRS_STENCILCULLENABLE" /*= 162*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, - { "D3DRS_ROPZCMPALWAYSREAD" /*= 163*/, 3911, xtBOOL, 0 }, - { "D3DRS_ROPZREAD" /*= 164*/, 3911, xtBOOL, 0 }, - { "D3DRS_DONOTCULLUNCOMPRESSED" /*= 165*/, 3911, xtBOOL, 0 } + { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "aliasses D3DMULTISAMPLE_TYPE, removed from 4039 onward", 4039 }, + { "D3DRS_MULTISAMPLEMODE" /*= 155*/, 4361, xtD3DMULTISAMPLEMODE, 0 }, // D3DMULTISAMPLEMODE for the backbuffer + { "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 156*/, 4039, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT }, // Was 4242 + { "D3DRS_SHADOWFUNC" /*= 157*/, 3424, xtD3DCMPFUNC, NV2A_TX_RCOMP }, + { "D3DRS_LINEWIDTH" /*= 158*/, 3424, xtFloat, NV2A_LINE_WIDTH }, + { "D3DRS_SAMPLEALPHA" /*= 159*/, 4627, xtD3DSAMPLEALPHA, 0 }, // TODO : Later than 3424, (still?) not in 4531, but possibly earlier than 4627? + { "D3DRS_DXT1NOISEENABLE" /*= 160*/, 3424, xtBOOL, NV2A_CLEAR_DEPTH_VALUE }, + { "D3DRS_YUVENABLE" /*= 161*/, 3911, xtBOOL, NV2A_CONTROL0 }, + { "D3DRS_OCCLUSIONCULLENABLE" /*= 162*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, + { "D3DRS_STENCILCULLENABLE" /*= 163*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, + { "D3DRS_ROPZCMPALWAYSREAD" /*= 164*/, 3911, xtBOOL, 0 }, + { "D3DRS_ROPZREAD" /*= 165*/, 3911, xtBOOL, 0 }, + { "D3DRS_DONOTCULLUNCOMPRESSED" /*= 166*/, 3911, xtBOOL, 0 } }; -const RenderStateInfo DxbxRenderStateInfo_D3DRS_MULTISAMPLETYPE_below_4039 = - { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0 }; // aliasses D3DMULTISAMPLE_TYPE - const RenderStateInfo& GetDxbxRenderStateInfo(int State) { - if (State == XTL::X_D3DRS_MULTISAMPLEMODE) // replace by old X_D3DRS_MULTISAMPLETYPE below 4039 - if (g_LibVersion_D3D8 < 4039) - return DxbxRenderStateInfo_D3DRS_MULTISAMPLETYPE_below_4039; - return DxbxRenderStateInfo[State]; } diff --git a/src/core/hle/D3D8/XbConvert.h b/src/core/hle/D3D8/XbConvert.h index 08e96dc5c..a4fec49f7 100644 --- a/src/core/hle/D3D8/XbConvert.h +++ b/src/core/hle/D3D8/XbConvert.h @@ -1810,7 +1810,8 @@ typedef struct _RenderStateInfo { TXBType T = xt_Unknown; // The Xbox data type. Defaults to xt_Unknown. XTL::NV2AMETHOD M; // The related push buffer method. Not always a 1-to-1 mapping. Needs push-buffer interpretation & conversion code. D3DRENDERSTATETYPE PC = (D3DRENDERSTATETYPE)0; // Map XBox to PC render state - char *N; // XDK notes. Defaults to ''. + char *N; // XDK notes. Defaults to ''. + WORD R; // The XDK version since which a render state was removed } RenderStateInfo; diff --git a/src/core/hle/D3D8/XbD3D8Types.h b/src/core/hle/D3D8/XbD3D8Types.h index 9e9958c48..0abff13ee 100644 --- a/src/core/hle/D3D8/XbD3D8Types.h +++ b/src/core/hle/D3D8/XbD3D8Types.h @@ -818,19 +818,20 @@ typedef enum _X_D3DRENDERSTATETYPE { X_D3DRS_EDGEANTIALIAS = 151, // Dxbx note : No Xbox ext. (according to Direct3D8) ! X_D3DRS_MULTISAMPLEANTIALIAS = 152, X_D3DRS_MULTISAMPLEMASK = 153, - X_D3DRS_MULTISAMPLETYPE = 154, // [-4039] Xbox ext. \_ aliasses D3DMULTISAMPLE_TYPE - X_D3DRS_MULTISAMPLEMODE = 154, // [4361+] Xbox ext. / D3DMULTISAMPLEMODE for the backbuffer - X_D3DRS_MULTISAMPLERENDERTARGETMODE = 155, // [4039+] Xbox ext. - X_D3DRS_SHADOWFUNC = 156, // D3DCMPFUNC (Xbox extension) - X_D3DRS_LINEWIDTH = 157, // Xbox ext. - X_D3DRS_SAMPLEALPHA = 158, // Xbox ext. - X_D3DRS_DXT1NOISEENABLE = 159, // Xbox ext. - X_D3DRS_YUVENABLE = 160, // [3911+] Xbox ext. - X_D3DRS_OCCLUSIONCULLENABLE = 161, // [3911+] Xbox ext. - X_D3DRS_STENCILCULLENABLE = 162, // [3911+] Xbox ext. - X_D3DRS_ROPZCMPALWAYSREAD = 163, // [3911+] Xbox ext. - X_D3DRS_ROPZREAD = 164, // [3911+] Xbox ext. - X_D3DRS_DONOTCULLUNCOMPRESSED = 165, // [3911+] Xbox ext. + X_D3DRS_MULTISAMPLETYPE = 154, // [-4039] Xbox ext. + // Note : X_D3DRS_MULTISAMPLETYPE seems the only one that got removed, but it does need a slot, so the rest is increased by 1 compared to 5933. + X_D3DRS_MULTISAMPLEMODE = 155, // [4361+] Xbox ext. // D3DMULTISAMPLEMODE for the backbuffer + X_D3DRS_MULTISAMPLERENDERTARGETMODE = 156, // [4039+] Xbox ext. + X_D3DRS_SHADOWFUNC = 157, // D3DCMPFUNC (Xbox extension) + X_D3DRS_LINEWIDTH = 158, // Xbox ext. + X_D3DRS_SAMPLEALPHA = 159, // Xbox ext. + X_D3DRS_DXT1NOISEENABLE = 160, // Xbox ext. + X_D3DRS_YUVENABLE = 161, // [3911+] Xbox ext. + X_D3DRS_OCCLUSIONCULLENABLE = 162, // [3911+] Xbox ext. + X_D3DRS_STENCILCULLENABLE = 163, // [3911+] Xbox ext. + X_D3DRS_ROPZCMPALWAYSREAD = 164, // [3911+] Xbox ext. + X_D3DRS_ROPZREAD = 165, // [3911+] Xbox ext. + X_D3DRS_DONOTCULLUNCOMPRESSED = 166, // [3911+] Xbox ext. // End of "complex" render states. X_D3DRS_UNK = 0x7fffffff // deferred render state "unknown" flag } X_D3DRENDERSTATETYPE; From 5814eaa7fd8b9a9571c0f92ba126b073381f038f Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 18 Nov 2019 12:06:48 +0100 Subject: [PATCH 11/19] Do the extended availability check of render states everywhere it might have an impact. --- src/core/hle/D3D8/Direct3D9/RenderStates.cpp | 27 ++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/RenderStates.cpp b/src/core/hle/D3D8/Direct3D9/RenderStates.cpp index 61f297468..27ff00bff 100644 --- a/src/core/hle/D3D8/Direct3D9/RenderStates.cpp +++ b/src/core/hle/D3D8/Direct3D9/RenderStates.cpp @@ -57,6 +57,17 @@ bool XboxRenderStateConverter::Init() return true; } +bool IsRenderStateAvailableInCurrentXboxD3D8Lib(RenderStateInfo& aRenderStateInfo) +{ + bool bIsRenderStateAvailable = (aRenderStateInfo.V <= g_LibVersion_D3D8); + if (aRenderStateInfo.R > 0) { // Applies to XTL::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 &= (g_LibVersion_D3D8 < aRenderStateInfo.R); + } + return bIsRenderStateAvailable; +} + void XboxRenderStateConverter::VerifyAndFixDeferredRenderStateOffset() { DWORD CullModeOffset = g_SymbolAddresses["D3DRS_CULLMODE"]; @@ -69,7 +80,8 @@ void XboxRenderStateConverter::VerifyAndFixDeferredRenderStateOffset() // Calculate index of D3DRS_CULLMODE for this XDK. We start counting from the first deferred state (D3DRS_FOGENABLE) DWORD CullModeIndex = 0; for (int i = XTL::X_D3DRS_DEFERRED_FIRST; i < XTL::X_D3DRS_CULLMODE; i++) { - if (GetDxbxRenderStateInfo(i).V <= g_LibVersion_D3D8) { + auto RenderStateInfo = GetDxbxRenderStateInfo(i); + if (IsRenderStateAvailableInCurrentXboxD3D8Lib(RenderStateInfo)) { CullModeIndex++; } } @@ -92,7 +104,8 @@ void XboxRenderStateConverter::DeriveRenderStateOffsetFromDeferredRenderStateOff int FirstDeferredRenderStateOffset = 0; for (unsigned int RenderState = XTL::X_D3DRS_FIRST; RenderState < XTL::X_D3DRS_DEFERRED_FIRST; RenderState++) { // if the current renderstate exists in this XDK version, count it - if (GetDxbxRenderStateInfo(RenderState).V <= g_LibVersion_D3D8) { + auto RenderStateInfo = GetDxbxRenderStateInfo(RenderState); + if (IsRenderStateAvailableInCurrentXboxD3D8Lib(RenderStateInfo)) { FirstDeferredRenderStateOffset++; } } @@ -111,14 +124,8 @@ void XboxRenderStateConverter::BuildRenderStateMappingTable() int XboxIndex = 0; for (unsigned int RenderState = XTL::X_D3DRS_FIRST; RenderState <= XTL::X_D3DRS_LAST; RenderState++) { - auto RenderStateInfo = GetDxbxRenderStateInfo(RenderState); - bool bIsRenderStateAvailable = (RenderStateInfo.V <= g_LibVersion_D3D8); - if (RenderStateInfo.R > 0) { // Applies to XTL::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 &= (g_LibVersion_D3D8 < RenderStateInfo.R); - } - if (bIsRenderStateAvailable) { + auto RenderStateInfo = GetDxbxRenderStateInfo(RenderState); + if (IsRenderStateAvailableInCurrentXboxD3D8Lib(RenderStateInfo)) { XboxRenderStateOffsets[RenderState] = XboxIndex; EmuLog(LOG_LEVEL::INFO, "%s = %d", RenderStateInfo.S, XboxIndex); XboxIndex++; From 9cf3591393798ff7b5d07e78676aa90cb816e91b Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Tue, 5 Sep 2017 11:04:55 +0200 Subject: [PATCH 12/19] Turn Cxbx version define into a variable This is intended to reduce the number of files that need to be recompiled when updating a repository. --- CMakeLists.txt | 1 + src/CxbxVersion.cpp | 44 +++++++++++++++++++++++++++++++ src/CxbxVersion.h | 7 +---- src/common/xbe/XbePrinter.cpp | 6 +++-- src/core/kernel/init/CxbxKrnl.cpp | 2 +- src/gui/DlgAbout.cpp | 17 +++++++----- src/gui/WndMain.cpp | 4 +-- 7 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 src/CxbxVersion.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 66b8dd3ca..5e757c868 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,6 +226,7 @@ file (GLOB CXBXR_SOURCE_COMMON "${CXBXR_ROOT_DIR}/src/common/xdvdfs-tools/buffered_io.cpp" "${CXBXR_ROOT_DIR}/src/common/xdvdfs-tools/xdvdfs.cpp" "${CXBXR_ROOT_DIR}/src/gui/DbgConsole.cpp" + "${CXBXR_ROOT_DIR}/src/CxbxVersion.cpp" "${CXBXR_ROOT_DIR}/src/HighPerformanceGraphicsEnabler.c" ) diff --git a/src/CxbxVersion.cpp b/src/CxbxVersion.cpp new file mode 100644 index 000000000..a0a52a4b1 --- /dev/null +++ b/src/CxbxVersion.cpp @@ -0,0 +1,44 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check it. +// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com +// ****************************************************************** +// * +// * .,-::::: .,:: .::::::::. .,:: .: +// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;; +// * [[[ '[[,,[[' [[[__[[\. '[[,,[[' +// * $$$ Y$$$P $$""""Y$$ Y$$$P +// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, +// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, +// * +// * Cxbx->CxbxVersion.cpp +// * +// * This file is part of the Cxbx project. +// * +// * Cxbx and Cxbe are free software; you can redistribute them +// * and/or modify them under the terms of the GNU General Public +// * License as published by the Free Software Foundation; either +// * version 2 of the license, or (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have recieved a copy of the GNU General Public License +// * along with this program; see the file COPYING. +// * If not, write to the Free Software Foundation, Inc., +// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA. +// * +// * (c) 2017 Patrick van Logchem +// * +// * All rights reserved +// * +// ****************************************************************** +#include "Version.h" +#include "CxbxVersion.h" + +/*! version string dependent on trace flag */ +#ifndef _DEBUG_TRACE +char * CxbxVersionStr = _GIT_VERSION " (" __DATE__ ")"; +#else +char * CxbxVersionStr = _GIT_VERSION "-Trace (" __DATE__ ")"; +#endif \ No newline at end of file diff --git a/src/CxbxVersion.h b/src/CxbxVersion.h index e04b32b3c..85fb54acf 100644 --- a/src/CxbxVersion.h +++ b/src/CxbxVersion.h @@ -2,9 +2,4 @@ #include "version.h" -/*! version string dependent on trace flag */ -#ifndef _DEBUG_TRACE -#define _CXBX_VERSION _GIT_VERSION " (" __DATE__ ")" -#else -#define _CXBX_VERSION _GIT_VERSION "-Trace (" __DATE__ ")" -#endif +extern char * CxbxVersionStr; \ No newline at end of file diff --git a/src/common/xbe/XbePrinter.cpp b/src/common/xbe/XbePrinter.cpp index a09d481c2..1353e9a31 100644 --- a/src/common/xbe/XbePrinter.cpp +++ b/src/common/xbe/XbePrinter.cpp @@ -26,7 +26,7 @@ // ****************************************************************** #include "common\xbe\XbePrinter.h" -#include "CxbxVersion.h" // For _CXBX_VERSION +#include "CxbxVersion.h" // For CxbxVersionStr #include // For ctime #include // For std::stringstream @@ -170,7 +170,9 @@ std::string XbePrinter::GameRatingToString() std::string XbePrinter::GenDumpHeader() { std::string text; - text.append("XBE information generated by Cxbx-Reloaded (Version " _CXBX_VERSION ")\n\n"); + text.append("XBE information generated by Cxbx-Reloaded (Version "); + text.append(CxbxVersionStr); + text.append(")\n\n"); text.append("Title identified as \""); text.append(Xbe_to_print->m_szAsciiTitle); text.append("\"\n\n"); diff --git a/src/core/kernel/init/CxbxKrnl.cpp b/src/core/kernel/init/CxbxKrnl.cpp index 9a71c2ba1..81d9af860 100644 --- a/src/core/kernel/init/CxbxKrnl.cpp +++ b/src/core/kernel/init/CxbxKrnl.cpp @@ -999,7 +999,7 @@ void CxbxKrnlMain(int argc, char* argv[]) // Write a header to the log { - printf("[0x%.4X] INIT: Cxbx-Reloaded Version %s\n", GetCurrentThreadId(), _CXBX_VERSION); + printf("[0x%.4X] INIT: Cxbx-Reloaded Version %s\n", GetCurrentThreadId(), CxbxVersionStr); time_t startTime = time(nullptr); struct tm* tm_info = localtime(&startTime); diff --git a/src/gui/DlgAbout.cpp b/src/gui/DlgAbout.cpp index 8ea02205c..e8f9d572a 100644 --- a/src/gui/DlgAbout.cpp +++ b/src/gui/DlgAbout.cpp @@ -78,13 +78,15 @@ INT_PTR CALLBACK DlgAboutProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa // Get tab pane dimensions RECT tabRect; GetClientRect(GetDlgItem(hWndDlg, IDC_TAB1), &tabRect); - SendMessage(GetDlgItem(hWndDlg, IDC_TAB1), TCM_ADJUSTRECT, FALSE, (LPARAM)&tabRect); + SendMessage(GetDlgItem(hWndDlg, IDC_TAB1), TCM_ADJUSTRECT, FALSE, (LPARAM)&tabRect); // Tab Pane 1 - HWND tab = CreateWindowEx - (NULL, "STATIC", "\nCxbx-Reloaded\nVersion " _CXBX_VERSION "\nŠ The Cxbx-Reloaded Team" + char TabPane1Message[270]; + sprintf(TabPane1Message, "\nCxbx-Reloaded\nVersion %s\nŠ The Cxbx-Reloaded Team" "\nThis software comes with ABSOLUTELY NO WARRANTY." "\nThis is free software, and you are welcome to redistribute it" - "\nunder certain conditions; See our website for details.", + "\nunder certain conditions; See our website for details.", CxbxVersionStr); + HWND tab = CreateWindowEx + (NULL, "STATIC", TabPane1Message, WS_CHILD | WS_VISIBLE, tabRect.left + 10, tabRect.top + 10, tabRect.right - tabRect.left, @@ -148,7 +150,8 @@ INT_PTR CALLBACK DlgAboutProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa aboutTabPanes.push_back(tab); aboutCurrentTab = 0; - UpdateWindow(hWndDlg); + UpdateWindow(hWndDlg); + } break; @@ -186,7 +189,9 @@ INT_PTR CALLBACK DlgAboutProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } // Show the selected tab pane - ShowWindow(aboutTabPanes[aboutCurrentTab], SW_HIDE); ShowWindow(aboutTabPanes[index], SW_SHOW); + ShowWindow(aboutTabPanes[aboutCurrentTab], SW_HIDE); + ShowWindow(aboutTabPanes[index], SW_SHOW); + aboutCurrentTab = index; } break; diff --git a/src/gui/WndMain.cpp b/src/gui/WndMain.cpp index de2f61d0f..a14970869 100644 --- a/src/gui/WndMain.cpp +++ b/src/gui/WndMain.cpp @@ -173,7 +173,7 @@ WndMain::WndMain(HINSTANCE x_hInstance) : // initialize members { m_classname = "WndMain"; - m_wndname = "Cxbx-Reloaded " _CXBX_VERSION; + m_wndname = "Cxbx-Reloaded"; } // load configuration from settings file @@ -1867,7 +1867,7 @@ void WndMain::UpdateCaption() { char AsciiTitle[MAX_PATH]; - int i = sprintf(AsciiTitle, "Cxbx-Reloaded %s", _CXBX_VERSION); + int i = sprintf(AsciiTitle, "Cxbx-Reloaded %s", CxbxVersionStr); if (m_Xbe != nullptr) { if (m_bIsStarted) { i += sprintf(AsciiTitle + i, " : Emulating "); From 0aac02c0c01af1f42c61410b17ad34824d8b61dc Mon Sep 17 00:00:00 2001 From: patrickvl Date: Sat, 16 Nov 2019 16:53:54 +0100 Subject: [PATCH 13/19] Fixed comment header --- src/CxbxVersion.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/CxbxVersion.cpp b/src/CxbxVersion.cpp index a0a52a4b1..edae25b16 100644 --- a/src/CxbxVersion.cpp +++ b/src/CxbxVersion.cpp @@ -2,15 +2,6 @@ // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com // ****************************************************************** // * -// * .,-::::: .,:: .::::::::. .,:: .: -// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;; -// * [[[ '[[,,[[' [[[__[[\. '[[,,[[' -// * $$$ Y$$$P $$""""Y$$ Y$$$P -// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo, -// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm, -// * -// * Cxbx->CxbxVersion.cpp -// * // * This file is part of the Cxbx project. // * // * Cxbx and Cxbe are free software; you can redistribute them @@ -28,7 +19,7 @@ // * If not, write to the Free Software Foundation, Inc., // * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA. // * -// * (c) 2017 Patrick van Logchem +// * (c) 2019 Patrick van Logchem // * // * All rights reserved // * From 61b374356775966c38f496c41e1c542dfbd935e1 Mon Sep 17 00:00:00 2001 From: patrickvl Date: Sat, 16 Nov 2019 21:41:42 +0100 Subject: [PATCH 14/19] Addressed review remarks --- CMakeLists.txt | 2 +- src/CxbxVersion.cpp | 30 +++--------------------------- src/CxbxVersion.h | 2 +- src/common/xbe/XbePrinter.cpp | 6 +++--- 4 files changed, 8 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e757c868..778e66096 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,8 +225,8 @@ file (GLOB CXBXR_SOURCE_COMMON "${CXBXR_ROOT_DIR}/src/common/xbe/XbePrinter.cpp" "${CXBXR_ROOT_DIR}/src/common/xdvdfs-tools/buffered_io.cpp" "${CXBXR_ROOT_DIR}/src/common/xdvdfs-tools/xdvdfs.cpp" - "${CXBXR_ROOT_DIR}/src/gui/DbgConsole.cpp" "${CXBXR_ROOT_DIR}/src/CxbxVersion.cpp" + "${CXBXR_ROOT_DIR}/src/gui/DbgConsole.cpp" "${CXBXR_ROOT_DIR}/src/HighPerformanceGraphicsEnabler.c" ) diff --git a/src/CxbxVersion.cpp b/src/CxbxVersion.cpp index edae25b16..f3b0be0d3 100644 --- a/src/CxbxVersion.cpp +++ b/src/CxbxVersion.cpp @@ -1,35 +1,11 @@ // This is an open source non-commercial project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com -// ****************************************************************** -// * -// * This file is part of the Cxbx project. -// * -// * Cxbx and Cxbe are free software; you can redistribute them -// * and/or modify them under the terms of the GNU General Public -// * License as published by the Free Software Foundation; either -// * version 2 of the license, or (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have recieved a copy of the GNU General Public License -// * along with this program; see the file COPYING. -// * If not, write to the Free Software Foundation, Inc., -// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA. -// * -// * (c) 2019 Patrick van Logchem -// * -// * All rights reserved -// * -// ****************************************************************** #include "Version.h" #include "CxbxVersion.h" /*! version string dependent on trace flag */ #ifndef _DEBUG_TRACE -char * CxbxVersionStr = _GIT_VERSION " (" __DATE__ ")"; +const char* CxbxVersionStr = _GIT_VERSION " (" __DATE__ ")"; #else -char * CxbxVersionStr = _GIT_VERSION "-Trace (" __DATE__ ")"; -#endif \ No newline at end of file +const char* CxbxVersionStr = _GIT_VERSION "-Trace (" __DATE__ ")"; +#endif diff --git a/src/CxbxVersion.h b/src/CxbxVersion.h index 85fb54acf..17983832b 100644 --- a/src/CxbxVersion.h +++ b/src/CxbxVersion.h @@ -2,4 +2,4 @@ #include "version.h" -extern char * CxbxVersionStr; \ No newline at end of file +extern const char* CxbxVersionStr; diff --git a/src/common/xbe/XbePrinter.cpp b/src/common/xbe/XbePrinter.cpp index 1353e9a31..2d7e6ba62 100644 --- a/src/common/xbe/XbePrinter.cpp +++ b/src/common/xbe/XbePrinter.cpp @@ -170,9 +170,9 @@ std::string XbePrinter::GameRatingToString() std::string XbePrinter::GenDumpHeader() { std::string text; - text.append("XBE information generated by Cxbx-Reloaded (Version "); - text.append(CxbxVersionStr); - text.append(")\n\n"); + text.append("XBE information generated by Cxbx-Reloaded (Version "); + text.append(CxbxVersionStr); + text.append(")\n\n"); text.append("Title identified as \""); text.append(Xbe_to_print->m_szAsciiTitle); text.append("\"\n\n"); From ca1d2b27225be66255487b26325f615e463bd4d6 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 18 Nov 2019 11:32:46 +0100 Subject: [PATCH 15/19] Reinstated version string in initial caption bar. --- src/gui/Wnd.cpp | 2 +- src/gui/Wnd.h | 2 +- src/gui/WndMain.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/Wnd.cpp b/src/gui/Wnd.cpp index fb893aed4..24186788b 100644 --- a/src/gui/Wnd.cpp +++ b/src/gui/Wnd.cpp @@ -83,7 +83,7 @@ bool Wnd::ProcessMessages() ( 0, m_classname, - m_wndname, + m_wndname.c_str(), m_wndstyle, m_x, m_y, diff --git a/src/gui/Wnd.h b/src/gui/Wnd.h index 075b0ca16..40b33c1ec 100644 --- a/src/gui/Wnd.h +++ b/src/gui/Wnd.h @@ -84,7 +84,7 @@ public: // ****************************************************************** ATOM m_class; const char *m_classname; - const char *m_wndname; + std::string m_wndname; UINT m_clsstyle; DWORD m_wndstyle; int m_x, m_y, m_w, m_h; diff --git a/src/gui/WndMain.cpp b/src/gui/WndMain.cpp index a14970869..7fb596435 100644 --- a/src/gui/WndMain.cpp +++ b/src/gui/WndMain.cpp @@ -173,7 +173,7 @@ WndMain::WndMain(HINSTANCE x_hInstance) : // initialize members { m_classname = "WndMain"; - m_wndname = "Cxbx-Reloaded"; + m_wndname = "Cxbx-Reloaded " + std::string(CxbxVersionStr); } // load configuration from settings file From ae3fbc67c70d5c727d7d70c402a8f8cca3253d08 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 18 Nov 2019 17:57:02 +0100 Subject: [PATCH 16/19] Rename g_SetStreamSources into g_Xbox_SetStreamSource (which better reflects it's contents) --- src/core/hle/D3D8/XbVertexBuffer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/hle/D3D8/XbVertexBuffer.cpp b/src/core/hle/D3D8/XbVertexBuffer.cpp index 27719ee22..d70fdb87f 100644 --- a/src/core/hle/D3D8/XbVertexBuffer.cpp +++ b/src/core/hle/D3D8/XbVertexBuffer.cpp @@ -57,7 +57,7 @@ UINT g_InlineVertexBuffer_DataSize = 0; extern DWORD g_dwPrimPerFrame = 0; // Copy of active Xbox D3D Vertex Streams (and strides), set by [D3DDevice|CxbxImpl]_SetStreamSource* -XTL::X_STREAMINPUT g_SetStreamSources[X_VSH_MAX_STREAMS] = { 0 }; // Note : .Offset member is never set (so always 0) +XTL::X_STREAMINPUT g_Xbox_SetStreamSource[X_VSH_MAX_STREAMS] = { 0 }; // Note : .Offset member is never set (so always 0) extern XTL::X_D3DSurface* g_pXbox_RenderTarget; extern XTL::X_D3DSurface* g_pXbox_BackBufferSurface; @@ -120,7 +120,7 @@ int CountActiveD3DStreams() { int lastStreamIndex = 0; for (int i = 0; i < X_VSH_MAX_STREAMS; i++) { - if (g_SetStreamSources[i].VertexBuffer != xbnullptr) { + if (g_Xbox_SetStreamSource[i].VertexBuffer != xbnullptr) { lastStreamIndex = i + 1; } } @@ -294,7 +294,7 @@ void CxbxVertexBufferConverter::ConvertStream uiHostVertexStride = (bNeedVertexPatching) ? pVertexShaderStreamInfo->HostVertexStride : uiXboxVertexStride; dwHostVertexDataSize = uiVertexCount * uiHostVertexStride; } else { - XTL::X_D3DVertexBuffer *pXboxVertexBuffer = g_SetStreamSources[uiStream].VertexBuffer; + XTL::X_D3DVertexBuffer *pXboxVertexBuffer = g_Xbox_SetStreamSource[uiStream].VertexBuffer; pXboxVertexData = (uint8_t*)GetDataFromXboxResource(pXboxVertexBuffer); if (pXboxVertexData == xbnullptr) { HRESULT hRet = g_pD3DDevice->SetStreamSource( @@ -310,7 +310,7 @@ void CxbxVertexBufferConverter::ConvertStream return; } - uiXboxVertexStride = g_SetStreamSources[uiStream].Stride; + uiXboxVertexStride = g_Xbox_SetStreamSource[uiStream].Stride; // Set a new (exact) vertex count uiVertexCount = pDrawContext->VerticesInBuffer; // Dxbx note : Don't overwrite pDrawContext.dwVertexCount with uiVertexCount, because an indexed draw @@ -998,6 +998,6 @@ void CxbxImpl_SetStreamSource(UINT StreamNumber, XTL::X_D3DVertexBuffer* pStream assert(StreamNumber < X_VSH_MAX_STREAMS); - g_SetStreamSources[StreamNumber].VertexBuffer = pStreamData; - g_SetStreamSources[StreamNumber].Stride = Stride; + g_Xbox_SetStreamSource[StreamNumber].VertexBuffer = pStreamData; + g_Xbox_SetStreamSource[StreamNumber].Stride = Stride; } From ae05bdba58429f69cada2efdc68554782965648b Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Tue, 19 Nov 2019 15:52:34 +0100 Subject: [PATCH 17/19] Correct D3DRS_MULTISAMPLERENDERTARGETMODE from 4039 to 4034. This has no functional impact anyway, since there's no host renderstate associated with this (and later) render states. --- src/core/hle/D3D8/XbConvert.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/D3D8/XbConvert.cpp b/src/core/hle/D3D8/XbConvert.cpp index 18909b3bd..5565e266b 100644 --- a/src/core/hle/D3D8/XbConvert.cpp +++ b/src/core/hle/D3D8/XbConvert.cpp @@ -1498,7 +1498,7 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_MULTISAMPLEMASK" /*= 153*/, 3424, xtDWORD, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEMASK }, { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "aliasses D3DMULTISAMPLE_TYPE, removed from 4039 onward", 4039 }, { "D3DRS_MULTISAMPLEMODE" /*= 155*/, 4361, xtD3DMULTISAMPLEMODE, 0 }, // D3DMULTISAMPLEMODE for the backbuffer - { "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 156*/, 4039, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT }, // Was 4242 + { "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 156*/, 4034, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT }, // Was 4039 (and 4242 before that). 4034 is based on test-case The Simpsons Road Rage { "D3DRS_SHADOWFUNC" /*= 157*/, 3424, xtD3DCMPFUNC, NV2A_TX_RCOMP }, { "D3DRS_LINEWIDTH" /*= 158*/, 3424, xtFloat, NV2A_LINE_WIDTH }, { "D3DRS_SAMPLEALPHA" /*= 159*/, 4627, xtD3DSAMPLEALPHA, 0 }, // TODO : Later than 3424, (still?) not in 4531, but possibly earlier than 4627? From db90d6a8b8a2d7857251667b1db692a2f8a8437e Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Tue, 19 Nov 2019 17:40:50 +0100 Subject: [PATCH 18/19] Verified all render states; Updated D3DRS_MULTISAMPLEMODE to 4039 (might even be 4034) --- src/core/hle/D3D8/XbConvert.cpp | 70 ++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/src/core/hle/D3D8/XbConvert.cpp b/src/core/hle/D3D8/XbConvert.cpp index 5565e266b..56d51b223 100644 --- a/src/core/hle/D3D8/XbConvert.cpp +++ b/src/core/hle/D3D8/XbConvert.cpp @@ -1332,7 +1332,15 @@ void EmuUnswizzleBox } } } // EmuUnswizzleBox NOPATCH - + +// Notes : +// * most renderstates were introduced in the (lowest known) XDK version : 3424 +// * additional renderstates were introduced between 3434 and 4627 +// * we MUST list exact versions for each of those, since their inserts impacts mapping! +// * renderstates were finalized in 4627 (so no change after that version) +// * renderstates after D3DRS_MULTISAMPLEMASK have no host mapping, thus no impact +// * D3DRS_MULTISAMPLETYPE seems the only renderstate that got removed (after 3944, before 4039) +// * all renderstates marked 3424 are also verified present in 3944 const RenderStateInfo DxbxRenderStateInfo[] = { // String Ord Version Type Method Native @@ -1420,16 +1428,16 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_POINTOFFSETENABLE" /*= 79*/, 3424, xtBOOL, NV2A_POLYGON_OFFSET_POINT_ENABLE }, { "D3DRS_WIREFRAMEOFFSETENABLE" /*= 80*/, 3424, xtBOOL, NV2A_POLYGON_OFFSET_LINE_ENABLE }, { "D3DRS_SOLIDOFFSETENABLE" /*= 81*/, 3424, xtBOOL, NV2A_POLYGON_OFFSET_FILL_ENABLE }, - { "D3DRS_DEPTHCLIPCONTROL" /*= 82*/, 4432, xtD3DDCC, NV2A_DEPTHCLIPCONTROL }, - { "D3DRS_STIPPLEENABLE" /*= 83*/, 4627, xtBOOL, NV2A_POLYGON_STIPPLE_ENABLE }, - { "D3DRS_SIMPLE_UNUSED8" /*= 84*/, 4627, xtDWORD, 0 }, - { "D3DRS_SIMPLE_UNUSED7" /*= 85*/, 4627, xtDWORD, 0 }, - { "D3DRS_SIMPLE_UNUSED6" /*= 86*/, 4627, xtDWORD, 0 }, - { "D3DRS_SIMPLE_UNUSED5" /*= 87*/, 4627, xtDWORD, 0 }, - { "D3DRS_SIMPLE_UNUSED4" /*= 88*/, 4627, xtDWORD, 0 }, - { "D3DRS_SIMPLE_UNUSED3" /*= 89*/, 4627, xtDWORD, 0 }, - { "D3DRS_SIMPLE_UNUSED2" /*= 90*/, 4627, xtDWORD, 0 }, - { "D3DRS_SIMPLE_UNUSED1" /*= 91*/, 4627, xtDWORD, 0 }, + { "D3DRS_DEPTHCLIPCONTROL" /*= 82*/, 4432, xtD3DDCC, NV2A_DEPTHCLIPCONTROL }, // Verified present in 4432, absent in 4361 + { "D3DRS_STIPPLEENABLE" /*= 83*/, 4627, xtBOOL, NV2A_POLYGON_STIPPLE_ENABLE }, // Verified present in 4627, absent in 4531 + { "D3DRS_SIMPLE_UNUSED8" /*= 84*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_SIMPLE_UNUSED7" /*= 85*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_SIMPLE_UNUSED6" /*= 86*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_SIMPLE_UNUSED5" /*= 87*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_SIMPLE_UNUSED4" /*= 88*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_SIMPLE_UNUSED3" /*= 89*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_SIMPLE_UNUSED2" /*= 90*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_SIMPLE_UNUSED1" /*= 91*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 // End of "simple" render states, continuing with "deferred" render states : // Verified as XDK 3911 Deferred RenderStates (3424 yet to do) { "D3DRS_FOGENABLE" /*= 92*/, 3424, xtBOOL, NV2A_FOG_ENABLE, D3DRS_FOGENABLE }, // TRUE to enable fog blending @@ -1467,16 +1475,16 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_PATCHEDGESTYLE" /*= 124*/, 3424, xtDWORD, 0, D3DRS_PATCHEDGESTYLE }, // D3DPATCHEDGESTYLE { "D3DRS_PATCHSEGMENTS" /*= 125*/, 3424, xtDWORD, 0 }, // 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? - { "D3DRS_SWAPFILTER" /*= 126*/, 4039, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "D3DTEXF_LINEAR etc. filter to use for Swap" }, // nsp. - { "D3DRS_PRESENTATIONINTERVAL" /*= 127*/, 4627, xtDWORD, 0 }, // nsp. TODO : Use 4361? - { "D3DRS_DEFERRED_UNUSED8" /*= 128*/, 4627, xtDWORD, 0 }, - { "D3DRS_DEFERRED_UNUSED7" /*= 129*/, 4627, xtDWORD, 0 }, - { "D3DRS_DEFERRED_UNUSED6" /*= 130*/, 4627, xtDWORD, 0 }, - { "D3DRS_DEFERRED_UNUSED5" /*= 131*/, 4627, xtDWORD, 0 }, - { "D3DRS_DEFERRED_UNUSED4" /*= 132*/, 4627, xtDWORD, 0 }, - { "D3DRS_DEFERRED_UNUSED3" /*= 133*/, 4627, xtDWORD, 0 }, - { "D3DRS_DEFERRED_UNUSED2" /*= 134*/, 4627, xtDWORD, 0 }, - { "D3DRS_DEFERRED_UNUSED1" /*= 135*/, 4627, xtDWORD, 0 }, + { "D3DRS_SWAPFILTER" /*= 126*/, 4039, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "D3DTEXF_LINEAR etc. filter to use for Swap" }, // nsp. Verified present in 4039, absent in 3944 TODO : Might be introduced in 4034? + { "D3DRS_PRESENTATIONINTERVAL" /*= 127*/, 4627, xtDWORD, 0 }, // nsp. Verified present in 4627, absent in 4531. TODO : might be inserted before 4627? + { "D3DRS_DEFERRED_UNUSED8" /*= 128*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_DEFERRED_UNUSED7" /*= 129*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_DEFERRED_UNUSED6" /*= 130*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_DEFERRED_UNUSED5" /*= 131*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_DEFERRED_UNUSED4" /*= 132*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_DEFERRED_UNUSED3" /*= 133*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_DEFERRED_UNUSED2" /*= 134*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_DEFERRED_UNUSED1" /*= 135*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 // End of "deferred" render states, continuing with "complex" render states : { "D3DRS_PSTEXTUREMODES" /*= 136*/, 3424, xtDWORD, 0 }, // This is where pPSDef->PSTextureModes is stored (outside the pPSDEF - see DxbxUpdateActivePixelShader) { "D3DRS_VERTEXBLEND" /*= 137*/, 3424, xtD3DVERTEXBLENDFLAGS, NV2A_SKIN_MODE, D3DRS_VERTEXBLEND }, @@ -1496,19 +1504,19 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_EDGEANTIALIAS" /*= 151*/, 3424, xtBOOL, NV2A_LINE_SMOOTH_ENABLE, D3DRS_ANTIALIASEDLINEENABLE }, // Was D3DRS_EDGEANTIALIAS. Dxbx note : No Xbox ext. (according to Direct3D8) ! { "D3DRS_MULTISAMPLEANTIALIAS" /*= 152*/, 3424, xtBOOL, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEANTIALIAS }, { "D3DRS_MULTISAMPLEMASK" /*= 153*/, 3424, xtDWORD, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEMASK }, - { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "aliasses D3DMULTISAMPLE_TYPE, removed from 4039 onward", 4039 }, - { "D3DRS_MULTISAMPLEMODE" /*= 155*/, 4361, xtD3DMULTISAMPLEMODE, 0 }, // D3DMULTISAMPLEMODE for the backbuffer - { "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 156*/, 4034, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT }, // Was 4039 (and 4242 before that). 4034 is based on test-case The Simpsons Road Rage + { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "aliasses D3DMULTISAMPLE_TYPE, removed from 4039 onward", 4039 }, // Verified present in 3944, absent in 4039 TODO : Might be removed in 4034? + { "D3DRS_MULTISAMPLEMODE" /*= 155*/, 4039, xtD3DMULTISAMPLEMODE, 0 }, // D3DMULTISAMPLEMODE for the backbuffer. Verified present in 4039, absent in 3944 TODO : Might be introduced in 4034? + { "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 156*/, 4034, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT }, // Verified present in 4039, absent in 3944. Presence in 4034 is based on test-case The Simpsons Road Rage { "D3DRS_SHADOWFUNC" /*= 157*/, 3424, xtD3DCMPFUNC, NV2A_TX_RCOMP }, { "D3DRS_LINEWIDTH" /*= 158*/, 3424, xtFloat, NV2A_LINE_WIDTH }, - { "D3DRS_SAMPLEALPHA" /*= 159*/, 4627, xtD3DSAMPLEALPHA, 0 }, // TODO : Later than 3424, (still?) not in 4531, but possibly earlier than 4627? + { "D3DRS_SAMPLEALPHA" /*= 159*/, 4627, xtD3DSAMPLEALPHA, 0 }, // Verified present in 4627, absent in 4531 TODO : might be inserted before 4627? { "D3DRS_DXT1NOISEENABLE" /*= 160*/, 3424, xtBOOL, NV2A_CLEAR_DEPTH_VALUE }, - { "D3DRS_YUVENABLE" /*= 161*/, 3911, xtBOOL, NV2A_CONTROL0 }, - { "D3DRS_OCCLUSIONCULLENABLE" /*= 162*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, - { "D3DRS_STENCILCULLENABLE" /*= 163*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, - { "D3DRS_ROPZCMPALWAYSREAD" /*= 164*/, 3911, xtBOOL, 0 }, - { "D3DRS_ROPZREAD" /*= 165*/, 3911, xtBOOL, 0 }, - { "D3DRS_DONOTCULLUNCOMPRESSED" /*= 166*/, 3911, xtBOOL, 0 } + { "D3DRS_YUVENABLE" /*= 161*/, 3911, xtBOOL, NV2A_CONTROL0 }, // Verified present in 3944 + { "D3DRS_OCCLUSIONCULLENABLE" /*= 162*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, // Verified present in 3944 + { "D3DRS_STENCILCULLENABLE" /*= 163*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, // Verified present in 3944 + { "D3DRS_ROPZCMPALWAYSREAD" /*= 164*/, 3911, xtBOOL, 0 }, // Verified present in 3944 + { "D3DRS_ROPZREAD" /*= 165*/, 3911, xtBOOL, 0 }, // Verified present in 3944 + { "D3DRS_DONOTCULLUNCOMPRESSED" /*= 166*/, 3911, xtBOOL, 0 } // Verified present in 3944 }; const RenderStateInfo& GetDxbxRenderStateInfo(int State) From 8aef04f83aa53e68e6db6bb8e04981ddefaf7fe0 Mon Sep 17 00:00:00 2001 From: patrickvl Date: Wed, 20 Nov 2019 16:38:29 +0100 Subject: [PATCH 19/19] Comment-only change, no function impact; Re-orded render state verification comments incrementally, like this: "Verified [absent in X, ]present in Y[ , removed in Z]" (whereby X < Y < Z). This makes these comments easier to read and understand. --- src/core/hle/D3D8/XbConvert.cpp | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/core/hle/D3D8/XbConvert.cpp b/src/core/hle/D3D8/XbConvert.cpp index 56d51b223..ddd6aee47 100644 --- a/src/core/hle/D3D8/XbConvert.cpp +++ b/src/core/hle/D3D8/XbConvert.cpp @@ -1428,16 +1428,16 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_POINTOFFSETENABLE" /*= 79*/, 3424, xtBOOL, NV2A_POLYGON_OFFSET_POINT_ENABLE }, { "D3DRS_WIREFRAMEOFFSETENABLE" /*= 80*/, 3424, xtBOOL, NV2A_POLYGON_OFFSET_LINE_ENABLE }, { "D3DRS_SOLIDOFFSETENABLE" /*= 81*/, 3424, xtBOOL, NV2A_POLYGON_OFFSET_FILL_ENABLE }, - { "D3DRS_DEPTHCLIPCONTROL" /*= 82*/, 4432, xtD3DDCC, NV2A_DEPTHCLIPCONTROL }, // Verified present in 4432, absent in 4361 - { "D3DRS_STIPPLEENABLE" /*= 83*/, 4627, xtBOOL, NV2A_POLYGON_STIPPLE_ENABLE }, // Verified present in 4627, absent in 4531 - { "D3DRS_SIMPLE_UNUSED8" /*= 84*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_SIMPLE_UNUSED7" /*= 85*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_SIMPLE_UNUSED6" /*= 86*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_SIMPLE_UNUSED5" /*= 87*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_SIMPLE_UNUSED4" /*= 88*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_SIMPLE_UNUSED3" /*= 89*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_SIMPLE_UNUSED2" /*= 90*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_SIMPLE_UNUSED1" /*= 91*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_DEPTHCLIPCONTROL" /*= 82*/, 4432, xtD3DDCC, NV2A_DEPTHCLIPCONTROL }, // Verified absent in 4361, present in 4432 TODO : Might be introduced around 4400? + { "D3DRS_STIPPLEENABLE" /*= 83*/, 4627, xtBOOL, NV2A_POLYGON_STIPPLE_ENABLE }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_SIMPLE_UNUSED8" /*= 84*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_SIMPLE_UNUSED7" /*= 85*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_SIMPLE_UNUSED6" /*= 86*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_SIMPLE_UNUSED5" /*= 87*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_SIMPLE_UNUSED4" /*= 88*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_SIMPLE_UNUSED3" /*= 89*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_SIMPLE_UNUSED2" /*= 90*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_SIMPLE_UNUSED1" /*= 91*/, 4627, xtDWORD, 0 }, // 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) { "D3DRS_FOGENABLE" /*= 92*/, 3424, xtBOOL, NV2A_FOG_ENABLE, D3DRS_FOGENABLE }, // TRUE to enable fog blending @@ -1475,16 +1475,16 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_PATCHEDGESTYLE" /*= 124*/, 3424, xtDWORD, 0, D3DRS_PATCHEDGESTYLE }, // D3DPATCHEDGESTYLE { "D3DRS_PATCHSEGMENTS" /*= 125*/, 3424, xtDWORD, 0 }, // 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? - { "D3DRS_SWAPFILTER" /*= 126*/, 4039, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "D3DTEXF_LINEAR etc. filter to use for Swap" }, // nsp. Verified present in 4039, absent in 3944 TODO : Might be introduced in 4034? - { "D3DRS_PRESENTATIONINTERVAL" /*= 127*/, 4627, xtDWORD, 0 }, // nsp. Verified present in 4627, absent in 4531. TODO : might be inserted before 4627? - { "D3DRS_DEFERRED_UNUSED8" /*= 128*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_DEFERRED_UNUSED7" /*= 129*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_DEFERRED_UNUSED6" /*= 130*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_DEFERRED_UNUSED5" /*= 131*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_DEFERRED_UNUSED4" /*= 132*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_DEFERRED_UNUSED3" /*= 133*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_DEFERRED_UNUSED2" /*= 134*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 - { "D3DRS_DEFERRED_UNUSED1" /*= 135*/, 4627, xtDWORD, 0 }, // Verified present in 4627, absent in 4531 + { "D3DRS_SWAPFILTER" /*= 126*/, 4039, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "D3DTEXF_LINEAR etc. filter to use for Swap" }, // nsp. Verified absent in 3944, present in 4039 TODO : Might be introduced in 4034? + { "D3DRS_PRESENTATIONINTERVAL" /*= 127*/, 4627, xtDWORD, 0 }, // nsp. Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_DEFERRED_UNUSED8" /*= 128*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_DEFERRED_UNUSED7" /*= 129*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_DEFERRED_UNUSED6" /*= 130*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_DEFERRED_UNUSED5" /*= 131*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_DEFERRED_UNUSED4" /*= 132*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_DEFERRED_UNUSED3" /*= 133*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_DEFERRED_UNUSED2" /*= 134*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? + { "D3DRS_DEFERRED_UNUSED1" /*= 135*/, 4627, xtDWORD, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? // End of "deferred" render states, continuing with "complex" render states : { "D3DRS_PSTEXTUREMODES" /*= 136*/, 3424, xtDWORD, 0 }, // This is where pPSDef->PSTextureModes is stored (outside the pPSDEF - see DxbxUpdateActivePixelShader) { "D3DRS_VERTEXBLEND" /*= 137*/, 3424, xtD3DVERTEXBLENDFLAGS, NV2A_SKIN_MODE, D3DRS_VERTEXBLEND }, @@ -1504,12 +1504,12 @@ const RenderStateInfo DxbxRenderStateInfo[] = { { "D3DRS_EDGEANTIALIAS" /*= 151*/, 3424, xtBOOL, NV2A_LINE_SMOOTH_ENABLE, D3DRS_ANTIALIASEDLINEENABLE }, // Was D3DRS_EDGEANTIALIAS. Dxbx note : No Xbox ext. (according to Direct3D8) ! { "D3DRS_MULTISAMPLEANTIALIAS" /*= 152*/, 3424, xtBOOL, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEANTIALIAS }, { "D3DRS_MULTISAMPLEMASK" /*= 153*/, 3424, xtDWORD, NV2A_MULTISAMPLE_CONTROL, D3DRS_MULTISAMPLEMASK }, - { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "aliasses D3DMULTISAMPLE_TYPE, removed from 4039 onward", 4039 }, // Verified present in 3944, absent in 4039 TODO : Might be removed in 4034? - { "D3DRS_MULTISAMPLEMODE" /*= 155*/, 4039, xtD3DMULTISAMPLEMODE, 0 }, // D3DMULTISAMPLEMODE for the backbuffer. Verified present in 4039, absent in 3944 TODO : Might be introduced in 4034? - { "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 156*/, 4034, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT }, // Verified present in 4039, absent in 3944. Presence in 4034 is based on test-case The Simpsons Road Rage + { "D3DRS_MULTISAMPLETYPE" /*= 154*/, 3424, xtD3DMULTISAMPLE_TYPE, 0, D3DRS_UNSUPPORTED, "aliasses D3DMULTISAMPLE_TYPE, removed from 4039 onward", 4039 }, // Verified present in 3944, removed in 4039 TODO : Might be removed in 4034? + { "D3DRS_MULTISAMPLEMODE" /*= 155*/, 4039, xtD3DMULTISAMPLEMODE, 0 }, // D3DMULTISAMPLEMODE for the backbuffer. Verified absent in 3944, present in 4039 TODO : Might be introduced in 4034? + { "D3DRS_MULTISAMPLERENDERTARGETMODE" /*= 156*/, 4034, xtD3DMULTISAMPLEMODE, NV2A_RT_FORMAT }, // Verified absent in 3944, present in 4039. Presence in 4034 is based on test-case : The Simpsons Road Rage { "D3DRS_SHADOWFUNC" /*= 157*/, 3424, xtD3DCMPFUNC, NV2A_TX_RCOMP }, { "D3DRS_LINEWIDTH" /*= 158*/, 3424, xtFloat, NV2A_LINE_WIDTH }, - { "D3DRS_SAMPLEALPHA" /*= 159*/, 4627, xtD3DSAMPLEALPHA, 0 }, // Verified present in 4627, absent in 4531 TODO : might be inserted before 4627? + { "D3DRS_SAMPLEALPHA" /*= 159*/, 4627, xtD3DSAMPLEALPHA, 0 }, // Verified absent in 4531, present in 4627 TODO : might be introduced in between? { "D3DRS_DXT1NOISEENABLE" /*= 160*/, 3424, xtBOOL, NV2A_CLEAR_DEPTH_VALUE }, { "D3DRS_YUVENABLE" /*= 161*/, 3911, xtBOOL, NV2A_CONTROL0 }, // Verified present in 3944 { "D3DRS_OCCLUSIONCULLENABLE" /*= 162*/, 3911, xtBOOL, NV2A_OCCLUDE_ZSTENCIL_EN }, // Verified present in 3944