From 1bd79c29eb00290b3dbb7cc304f381a675803a9f Mon Sep 17 00:00:00 2001 From: Anthony Miles Date: Sun, 5 May 2019 18:40:29 +1200 Subject: [PATCH] Bumpmap bias tweaks: - Use inputStage for bias check - SCALE_BX2 instead of BIAS - Disable L6V5U5 biasing (for now) --- src/core/hle/D3D8/XbPixelShader.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/core/hle/D3D8/XbPixelShader.cpp b/src/core/hle/D3D8/XbPixelShader.cpp index aa430b604..71c74a6f5 100644 --- a/src/core/hle/D3D8/XbPixelShader.cpp +++ b/src/core/hle/D3D8/XbPixelShader.cpp @@ -2958,7 +2958,7 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS if (m_PSVersion >= D3DPS_VERSION(1, 4)) { - // If the bump-map texture format is X_D3DFMT_X8L8V8U8 or X_D3DFMT_L6V5U5 we need to apply a bias + // If the bump-map texture format is X_D3DFMT_X8L8V8U8 or X_D3DFMT_L6V5U5 we need to apply a bias // This happens because these formats are an alias of unsigned texture formats. // Fixes an issue with the JSRF boost-dash effect // NOTE: This assumes that this shader will only ever be used for the input bumpmap texture @@ -2966,9 +2966,11 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS // and include the texture formats in the shader hash, somehow. extern XTL::X_D3DBaseTexture* XTL::EmuD3DActiveTexture[TEXTURE_STAGES]; extern XTL::X_D3DFORMAT GetXboxPixelContainerFormat(const XTL::X_D3DPixelContainer *pXboxPixelContainer); - auto format = GetXboxPixelContainerFormat(XTL::EmuD3DActiveTexture[0]); + auto format = GetXboxPixelContainerFormat(XTL::EmuD3DActiveTexture[inputStage]); bool bias = false; - if (format == XTL::X_D3DFMT_X8L8V8U8 || format == XTL::X_D3DFMT_L6V5U5) { + auto biasModifier = (1 << ARGMOD_SCALE_BX2); + // TODO L6V5U5 format is converted incorrectly if not supported by the device + if (format == XTL::X_D3DFMT_X8L8V8U8 /*|| format == XTL::X_D3DFMT_L6V5U5*/) { bias = true; } @@ -2978,7 +2980,7 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS Ins.Parameters[1].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + inputStage, MASK_R); if (bias) { - Ins.Parameters[1].Modifiers = (1 << ARGMOD_BIAS); + Ins.Parameters[1].Modifiers = biasModifier; } Ins.Parameters[2].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + Stage, MASK_R); @@ -2988,7 +2990,7 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS Ins.Parameters[0].SetScaleBemLumRegister(XTL::D3DTSS_BUMPENVMAT10, Stage, Recompiled); Ins.Parameters[1].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + inputStage, MASK_G); if (bias) { - Ins.Parameters[1].Modifiers = (1 << ARGMOD_BIAS); + Ins.Parameters[1].Modifiers = biasModifier; } Ins.Parameters[2].SetRegister(PARAM_R, 1, MASK_R); InsertIns.emplace_back(Ins); @@ -2998,7 +3000,7 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS Ins.Parameters[0].SetScaleBemLumRegister(XTL::D3DTSS_BUMPENVMAT01, Stage, Recompiled); Ins.Parameters[1].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + inputStage, MASK_R); if (bias) { - Ins.Parameters[1].Modifiers = (1 << ARGMOD_BIAS); + Ins.Parameters[1].Modifiers = biasModifier; } Ins.Parameters[2].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + Stage, MASK_G); InsertIns.emplace_back(Ins); @@ -3007,7 +3009,7 @@ bool PSH_XBOX_SHADER::InsertTextureModeInstruction(XTL::X_D3DPIXELSHADERDEF *pPS Ins.Parameters[0].SetScaleBemLumRegister(XTL::D3DTSS_BUMPENVMAT11, Stage, Recompiled); Ins.Parameters[1].SetRegister(PARAM_R, PSH_XBOX_MAX_R_REGISTER_COUNT + inputStage, MASK_G); if (bias) { - Ins.Parameters[1].Modifiers = (1 << ARGMOD_BIAS); + Ins.Parameters[1].Modifiers = biasModifier; } Ins.Parameters[2].SetRegister(PARAM_R, 1, MASK_G); InsertIns.emplace_back(Ins);