diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index 9b3973a3..9ebdb291 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -2607,13 +2607,19 @@ namespace dxvk { // The 'Hi' variants are counted from the MSB in DXBC // rather than the LSB, so we have to invert the number - if (ins.op == DxbcOpcode::FirstBitHi - || ins.op == DxbcOpcode::FirstBitShi) { + if (ins.op == DxbcOpcode::FirstBitHi || ins.op == DxbcOpcode::FirstBitShi) { + uint32_t boolTypeId = m_module.defBoolType(); + + if (dst.type.ccount > 1) + boolTypeId = m_module.defVectorType(boolTypeId, dst.type.ccount); + + DxbcRegisterValue const31 = emitBuildConstVecu32(31u, 31u, 31u, 31u, ins.dst[0].mask); + DxbcRegisterValue constff = emitBuildConstVecu32(~0u, ~0u, ~0u, ~0u, ins.dst[0].mask); + dst.id = m_module.opSelect(typeId, - m_module.opINotEqual(m_module.defBoolType(), - dst.id, m_module.constu32(0xFFFFFFFF)), - m_module.opISub(typeId, m_module.constu32(31), dst.id), - m_module.constu32(0xFFFFFFFF)); + m_module.opINotEqual(boolTypeId, dst.id, constff.id), + m_module.opISub(typeId, const31.id, dst.id), + constff.id); } // No modifiers are supported