From 477ab534c5e66310c2920ef27b19848b2e5e864f Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Thu, 7 Nov 2019 18:26:34 +0100 Subject: [PATCH 1/6] 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 d5a5e9fc9a886ad8a75c23543d001c16716aedbc Mon Sep 17 00:00:00 2001 From: patrickvl Date: Sun, 17 Nov 2019 16:17:10 +0100 Subject: [PATCH 2/6] 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 3/6] 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 ae05bdba58429f69cada2efdc68554782965648b Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Tue, 19 Nov 2019 15:52:34 +0100 Subject: [PATCH 4/6] 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 5/6] 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 6/6] 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