diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 2450eab5..604b4976 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -5674,8 +5674,7 @@ namespace dxvk { : VK_COMPARE_OP_ALWAYS; EmitCs([cAlphaOp = alphaOp] (DxvkContext* ctx) { - ctx->setSpecConstant(VK_PIPELINE_BIND_POINT_GRAPHICS, D3D9SpecConstantId::AlphaTestEnable, cAlphaOp != VK_COMPARE_OP_ALWAYS); - ctx->setSpecConstant(VK_PIPELINE_BIND_POINT_GRAPHICS, D3D9SpecConstantId::AlphaCompareOp, cAlphaOp); + ctx->setSpecConstant(VK_PIPELINE_BIND_POINT_GRAPHICS, D3D9SpecConstantId::AlphaCompareOp, cAlphaOp); }); } diff --git a/src/d3d9/d3d9_fixed_function.cpp b/src/d3d9/d3d9_fixed_function.cpp index 826dca8b..be71b9c6 100644 --- a/src/d3d9/d3d9_fixed_function.cpp +++ b/src/d3d9/d3d9_fixed_function.cpp @@ -2211,12 +2211,7 @@ namespace dxvk { uint32_t floatPtr = m_module.defPointerType(m_floatType, spv::StorageClassPushConstant); // Declare spec constants for render states - uint32_t alphaTestId = m_module.specConstBool(false); uint32_t alphaFuncId = m_module.specConst32(m_module.defIntType(32, 0), 0); - - m_module.setDebugName(alphaTestId, "alpha_test"); - m_module.decorateSpecId(alphaTestId, getSpecId(D3D9SpecConstantId::AlphaTestEnable)); - m_module.setDebugName(alphaFuncId, "alpha_func"); m_module.decorateSpecId(alphaFuncId, getSpecId(D3D9SpecConstantId::AlphaCompareOp)); @@ -2241,8 +2236,9 @@ namespace dxvk { uint32_t atestSkipLabel = m_module.allocateId(); // if (alpha_test) { ... } + uint32_t isNotAlways = m_module.opINotEqual(boolType, alphaFuncId, m_module.constu32(VK_COMPARE_OP_ALWAYS)); m_module.opSelectionMerge(atestSkipLabel, spv::SelectionControlMaskNone); - m_module.opBranchConditional(alphaTestId, atestBeginLabel, atestSkipLabel); + m_module.opBranchConditional(isNotAlways, atestBeginLabel, atestSkipLabel); m_module.opLabel(atestBeginLabel); // Load alpha component @@ -2294,8 +2290,6 @@ namespace dxvk { atestVariables.data()); uint32_t atestDiscard = m_module.opLogicalNot(boolType, atestResult); - atestResult = m_module.opLogicalNot(boolType, atestResult); - // if (do_discard) { ... } m_module.opSelectionMerge(atestKeepLabel, spv::SelectionControlMaskNone); m_module.opBranchConditional(atestDiscard, atestDiscardLabel, atestKeepLabel); diff --git a/src/d3d9/d3d9_spec_constants.h b/src/d3d9/d3d9_spec_constants.h index 6b2b8cb5..106b78f7 100644 --- a/src/d3d9/d3d9_spec_constants.h +++ b/src/d3d9/d3d9_spec_constants.h @@ -5,19 +5,18 @@ namespace dxvk { enum D3D9SpecConstantId : uint32_t { - AlphaTestEnable = 0, - AlphaCompareOp = 1, - SamplerType = 2, - FogEnabled = 3, - VertexFogMode = 4, - PixelFogMode = 5, + AlphaCompareOp = 0, + SamplerType = 1, + FogEnabled = 2, + VertexFogMode = 3, + PixelFogMode = 4, - PointMode = 6, - ProjectionType = 7, + PointMode = 5, + ProjectionType = 6, - VertexShaderBools = 8, - PixelShaderBools = 9, - Fetch4 = 10 + VertexShaderBools = 7, + PixelShaderBools = 8, + Fetch4 = 9 }; } \ No newline at end of file diff --git a/src/dxso/dxso_compiler.cpp b/src/dxso/dxso_compiler.cpp index 799b1300..758a5f7a 100644 --- a/src/dxso/dxso_compiler.cpp +++ b/src/dxso/dxso_compiler.cpp @@ -3555,13 +3555,7 @@ void DxsoCompiler::emitControlFlowGenericLoop( uint32_t floatType = m_module.defFloatType(32); uint32_t floatPtr = m_module.defPointerType(floatType, spv::StorageClassPushConstant); - // Declare spec constants for render states - uint32_t alphaTestId = m_module.specConstBool(false); uint32_t alphaFuncId = m_module.specConst32(m_module.defIntType(32, 0), 0); - - m_module.setDebugName (alphaTestId, "alpha_test"); - m_module.decorateSpecId (alphaTestId, getSpecId(D3D9SpecConstantId::AlphaTestEnable)); - m_module.setDebugName (alphaFuncId, "alpha_func"); m_module.decorateSpecId (alphaFuncId, getSpecId(D3D9SpecConstantId::AlphaCompareOp)); @@ -3592,9 +3586,10 @@ void DxsoCompiler::emitControlFlowGenericLoop( uint32_t atestKeepLabel = m_module.allocateId(); uint32_t atestSkipLabel = m_module.allocateId(); - // if (alpha_test) { ... } + // if (alpha_func != ALWAYS) { ... } + uint32_t isNotAlways = m_module.opINotEqual(boolType, alphaFuncId, m_module.constu32(VK_COMPARE_OP_ALWAYS)); m_module.opSelectionMerge(atestSkipLabel, spv::SelectionControlMaskNone); - m_module.opBranchConditional(alphaTestId, atestBeginLabel, atestSkipLabel); + m_module.opBranchConditional(isNotAlways, atestBeginLabel, atestSkipLabel); m_module.opLabel(atestBeginLabel); // Load alpha component @@ -3661,8 +3656,6 @@ void DxsoCompiler::emitControlFlowGenericLoop( atestVariables.data()); uint32_t atestDiscard = m_module.opLogicalNot(boolType, atestResult); - atestResult = m_module.opLogicalNot(boolType, atestResult); - // if (do_discard) { ... } m_module.opSelectionMerge(atestKeepLabel, spv::SelectionControlMaskNone); m_module.opBranchConditional(atestDiscard, atestDiscardLabel, atestKeepLabel);