From 310ab6da640b0849c54bdc2f40b81d0327344f31 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sat, 8 Feb 2020 23:08:48 +0000 Subject: [PATCH] [d3d9] Implement D3DTOP_BUMPENVMAPLUMINANCE --- src/d3d9/d3d9_fixed_function.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/d3d9/d3d9_fixed_function.cpp b/src/d3d9/d3d9_fixed_function.cpp index 7d840e34c..22344a710 100644 --- a/src/d3d9/d3d9_fixed_function.cpp +++ b/src/d3d9/d3d9_fixed_function.cpp @@ -1610,6 +1610,26 @@ namespace dxvk { else texture = m_module.opImageSampleImplicitLod(m_vec4Type, imageVarId, texcoord, imageOperands); + if (i != 0 && m_fsKey.Stages[i - 1].Contents.ColorOp == D3DTOP_BUMPENVMAPLUMINANCE) { + uint32_t index = m_module.constu32(D3D9SharedPSStages_Count * (i - 1) + D3D9SharedPSStages_BumpEnvLScale); + uint32_t lScale = m_module.opAccessChain(m_module.defPointerType(m_floatType, spv::StorageClassUniform), + m_ps.sharedState, 1, &index); + lScale = m_module.opLoad(m_vec2Type, lScale); + + index = m_module.constu32(D3D9SharedPSStages_Count * (i - 1) + D3D9SharedPSStages_BumpEnvLOffset); + uint32_t lOffset = m_module.opAccessChain(m_module.defPointerType(m_floatType, spv::StorageClassUniform), + m_ps.sharedState, 1, &index); + lOffset = m_module.opLoad(m_vec2Type, lOffset); + + uint32_t zIndex = 2; + uint32_t scale = m_module.opCompositeExtract(m_floatType, texture, 1, &zIndex); + scale = m_module.opFMul(m_floatType, scale, lScale); + scale = m_module.opFAdd(m_floatType, scale, lOffset); + scale = m_module.opFClamp(m_floatType, scale, m_module.constf32(0.0f), m_module.constf32(1.0)); + + texture = m_module.opVectorTimesScalar(m_vec4Type, texture, scale); + } + uint32_t bool_t = m_module.defBoolType(); uint32_t bvec4_t = m_module.defVectorType(bool_t, 4); std::array boundIndices = { m_ps.samplers[i].bound, m_ps.samplers[i].bound, m_ps.samplers[i].bound, m_ps.samplers[i].bound };