From 475eb5deb916ad6cc109828b8390f64821c1752b Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Mon, 19 Jul 2021 14:37:17 +0200 Subject: [PATCH] Removed g_UseFixedFunctionVertexShader, as it never changes from true anymore. Also removed related code that's no longer required either : host D3DDevice calls to SetTransform and SetLightEnable, and the EmuXB2PC_D3DTS tooling function. --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 15 +++-------- src/core/hle/D3D8/Direct3D9/TextureStates.cpp | 2 +- src/core/hle/D3D8/XbConvert.h | 26 ------------------- src/core/hle/D3D8/XbVertexShader.cpp | 1 - src/core/hle/D3D8/XbVertexShader.h | 1 - 5 files changed, 4 insertions(+), 41 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index 7fdd83121..8869aa016 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -6858,11 +6858,7 @@ void CxbxImpl_SetTransform LOG_INIT d3d8TransformState.SetTransform(State, pMatrix); - - auto d3d9State = EmuXB2PC_D3DTS(State); - - HRESULT hRet = g_pD3DDevice->SetTransform(d3d9State, pMatrix); - DEBUG_D3DRESULT(hRet, "g_pD3DDevice->SetTransform"); + // Note : SetTransform is handled in our fixed function shader - see UpdateFixedFunctionVertexShaderState() } // MultiplyTransform should call SetTransform, we'd like to know if it didn't @@ -7742,7 +7738,7 @@ void CxbxUpdateHostVertexShaderConstants() // So we can skip updates static bool isXboxConstants = false; - if (g_Xbox_VertexShaderMode == VertexShaderMode::FixedFunction && g_UseFixedFunctionVertexShader) { + if (g_Xbox_VertexShaderMode == VertexShaderMode::FixedFunction) { // Write host FF shader state // TODO dirty tracking like for Xbox constants? UpdateFixedFunctionVertexShaderState(); @@ -8546,12 +8542,7 @@ xbox::hresult_xt WINAPI xbox::EMUPATCH(D3DDevice_LightEnable) xbox::hresult_xt hRet = XB_TRMP(D3DDevice_LightEnable)(Index, bEnable); d3d8LightState.EnableLight(Index, bEnable); -#ifdef CXBX_USE_D3D11 - // Under D3D11, LightEnable relies on our fixed function shader (see if (g_Xbox_VertexShaderMode == VertexShaderMode::FixedFunction && g_UseFixedFunctionVertexShader) { -#else - HRESULT hRet_host = g_pD3DDevice->LightEnable(Index, bEnable); - DEBUG_D3DRESULT(hRet_host, "g_pD3DDevice->LightEnable"); -#endif + // Note : LightEnable is handled in our fixed function shader - see UpdateFixedFunctionVertexShaderState() return hRet; } diff --git a/src/core/hle/D3D8/Direct3D9/TextureStates.cpp b/src/core/hle/D3D8/Direct3D9/TextureStates.cpp index 03043d2cb..6ffe095ad 100644 --- a/src/core/hle/D3D8/Direct3D9/TextureStates.cpp +++ b/src/core/hle/D3D8/Direct3D9/TextureStates.cpp @@ -33,7 +33,7 @@ #include "EmuShared.h" #include "core/hle/Intercept.hpp" #include "RenderStates.h" -#include "core/hle/D3D8/XbVertexShader.h" // For g_UseFixedFunctionVertexShader, g_Xbox_VertexShaderMode and VertexShaderMode::FixedFunction +#include "core/hle/D3D8/XbVertexShader.h" // For g_Xbox_VertexShaderMode and VertexShaderMode::FixedFunction #include "core/hle/D3D8/Direct3D9/Direct3D9.h" // For g_pD3DDevice #include diff --git a/src/core/hle/D3D8/XbConvert.h b/src/core/hle/D3D8/XbConvert.h index e7125afdc..3fe7a830b 100644 --- a/src/core/hle/D3D8/XbConvert.h +++ b/src/core/hle/D3D8/XbConvert.h @@ -94,32 +94,6 @@ else CxbxrAbortEx(LOG_PREFIX_D3DCVT, "Unknown Transform State Type (%d)", State); //*/ -// convert from xbox to pc texture transform state types -inline D3DTRANSFORMSTATETYPE EmuXB2PC_D3DTS(xbox::X_D3DTRANSFORMSTATETYPE State) -{ - // Handle Xbox -> D3D State mapping - switch (State) { - case xbox::X_D3DTS_VIEW: return D3DTS_VIEW; - case xbox::X_D3DTS_PROJECTION: return D3DTS_PROJECTION; - case xbox::X_D3DTS_TEXTURE0: return D3DTS_TEXTURE0; - case xbox::X_D3DTS_TEXTURE1: return D3DTS_TEXTURE1; - case xbox::X_D3DTS_TEXTURE2: return D3DTS_TEXTURE2; - case xbox::X_D3DTS_TEXTURE3: return D3DTS_TEXTURE3; - case xbox::X_D3DTS_WORLD: return D3DTS_WORLD; - case xbox::X_D3DTS_WORLD1: return D3DTS_WORLD1; - case xbox::X_D3DTS_WORLD2: return D3DTS_WORLD2; - case xbox::X_D3DTS_WORLD3: return D3DTS_WORLD3; - } - - // Handle World Matrix offsets - if (State >= 256 && State <= 511) { - return D3DTS_WORLDMATRIX(State - 256); - } - - CxbxrAbortEx(LOG_PREFIX_D3DCVT, "Unknown Transform State Type (%d)", State); - return (D3DTRANSFORMSTATETYPE)0; -} - // convert from xbox to pc blend ops inline D3DBLENDOP EmuXB2PC_D3DBLENDOP(xbox::X_D3DBLENDOP Value) { diff --git a/src/core/hle/D3D8/XbVertexShader.cpp b/src/core/hle/D3D8/XbVertexShader.cpp index 3d8ea9089..9c09c4e27 100644 --- a/src/core/hle/D3D8/XbVertexShader.cpp +++ b/src/core/hle/D3D8/XbVertexShader.cpp @@ -62,7 +62,6 @@ extern XboxRenderStateConverter XboxRenderStates; // Declared in Direct3D9.cpp xbox::X_VERTEXATTRIBUTEFORMAT g_Xbox_SetVertexShaderInput_Attributes = { 0 }; // Read by GetXboxVertexAttributes when g_Xbox_SetVertexShaderInput_Count > 0 VertexShaderMode g_Xbox_VertexShaderMode = VertexShaderMode::FixedFunction; -bool g_UseFixedFunctionVertexShader = true; xbox::dword_xt g_Xbox_VertexShader_Handle = 0; #ifdef CXBX_USE_GLOBAL_VERTEXSHADER_POINTER // TODO : Would this be more accurate / simpler? diff --git a/src/core/hle/D3D8/XbVertexShader.h b/src/core/hle/D3D8/XbVertexShader.h index 7909c5968..459f6aed4 100644 --- a/src/core/hle/D3D8/XbVertexShader.h +++ b/src/core/hle/D3D8/XbVertexShader.h @@ -100,7 +100,6 @@ enum class VertexShaderMode { }; extern VertexShaderMode g_Xbox_VertexShaderMode; -extern bool g_UseFixedFunctionVertexShader; // Intermediate vertex shader structures