1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-01 07:24:12 +01:00

[dxbc] Implemented swapc

This commit is contained in:
Philip Rebohle 2018-01-17 21:47:18 +01:00
parent a3883411be
commit 8b27dee0e5
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 28 additions and 17 deletions

View File

@ -1297,11 +1297,12 @@ namespace dxvk {
void DxbcCompiler::emitVectorCmov(const DxbcShaderInstruction& ins) {
// movc has four operands:
// (dst0) The destination register
// movc and swapc have the following operands:
// (dst0) The first destination register
// (dst1) The second destination register (swapc only)
// (src0) The condition vector
// (src0) Vector to select from if the condition is not 0
// (src0) Vector to select from if the condition is 0
// (src1) Vector to select from if the condition is not 0
// (src2) Vector to select from if the condition is 0
const DxbcRegisterValue condition = emitRegisterLoad(ins.src[0], ins.dst[0].mask);
const DxbcRegisterValue selectTrue = emitRegisterLoad(ins.src[1], ins.dst[0].mask);
const DxbcRegisterValue selectFalse = emitRegisterLoad(ins.src[2], ins.dst[0].mask);
@ -1323,19 +1324,23 @@ namespace dxvk {
zero = m_module.constComposite(zeroType, componentCount, zeroVec.data());
}
// In case of swapc, the second destination operand receives
// the output that a cmov instruction would normally get
const uint32_t trueIndex = ins.op == DxbcOpcode::Swapc ? 1 : 0;
// Use the component mask to select the vector components
DxbcRegisterValue result;
result.type.ctype = ins.dst[0].dataType;
result.type.ccount = componentCount;
result.id = m_module.opSelect(
getVectorTypeId(result.type),
m_module.opINotEqual(boolType, condition.id, zero),
selectTrue.id, selectFalse.id);
// Apply result modifiers to floating-point results
result = emitDstOperandModifiers(result, ins.modifiers);
emitRegisterStore(ins.dst[0], result);
for (uint32_t i = 0; i < ins.dstCount; i++) {
DxbcRegisterValue result;
result.type.ctype = ins.dst[i].dataType;
result.type.ccount = componentCount;
result.id = m_module.opSelect(
getVectorTypeId(result.type),
m_module.opINotEqual(boolType, condition.id, zero),
i == trueIndex ? selectTrue.id : selectFalse.id,
i != trueIndex ? selectTrue.id : selectFalse.id);
result = emitDstOperandModifiers(result, ins.modifiers);
emitRegisterStore(ins.dst[i], result);
}
}
void DxbcCompiler::emitVectorCmp(const DxbcShaderInstruction& ins) {

View File

@ -649,7 +649,13 @@ namespace dxvk {
/* BfRev */
{ },
/* Swapc */
{ },
{ 5, DxbcInstClass::VectorCmov, {
{ DxbcOperandKind::DstReg, DxbcScalarType::Float32 },
{ DxbcOperandKind::DstReg, DxbcScalarType::Float32 },
{ DxbcOperandKind::SrcReg, DxbcScalarType::Uint32 },
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
} },
/* DclStream */
{ },
/* DclFunctionBody */