mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxbc] Implemented swapc
This commit is contained in:
parent
a3883411be
commit
8b27dee0e5
@ -1297,11 +1297,12 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxbcCompiler::emitVectorCmov(const DxbcShaderInstruction& ins) {
|
void DxbcCompiler::emitVectorCmov(const DxbcShaderInstruction& ins) {
|
||||||
// movc has four operands:
|
// movc and swapc have the following operands:
|
||||||
// (dst0) The destination register
|
// (dst0) The first destination register
|
||||||
|
// (dst1) The second destination register (swapc only)
|
||||||
// (src0) The condition vector
|
// (src0) The condition vector
|
||||||
// (src0) Vector to select from if the condition is not 0
|
// (src1) Vector to select from if the condition is not 0
|
||||||
// (src0) Vector to select from if the condition is 0
|
// (src2) Vector to select from if the condition is 0
|
||||||
const DxbcRegisterValue condition = emitRegisterLoad(ins.src[0], ins.dst[0].mask);
|
const DxbcRegisterValue condition = emitRegisterLoad(ins.src[0], ins.dst[0].mask);
|
||||||
const DxbcRegisterValue selectTrue = emitRegisterLoad(ins.src[1], 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);
|
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());
|
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
|
for (uint32_t i = 0; i < ins.dstCount; i++) {
|
||||||
DxbcRegisterValue result;
|
DxbcRegisterValue result;
|
||||||
result.type.ctype = ins.dst[0].dataType;
|
result.type.ctype = ins.dst[i].dataType;
|
||||||
result.type.ccount = componentCount;
|
result.type.ccount = componentCount;
|
||||||
result.id = m_module.opSelect(
|
result.id = m_module.opSelect(
|
||||||
getVectorTypeId(result.type),
|
getVectorTypeId(result.type),
|
||||||
m_module.opINotEqual(boolType, condition.id, zero),
|
m_module.opINotEqual(boolType, condition.id, zero),
|
||||||
selectTrue.id, selectFalse.id);
|
i == trueIndex ? selectTrue.id : selectFalse.id,
|
||||||
|
i != trueIndex ? selectTrue.id : selectFalse.id);
|
||||||
// Apply result modifiers to floating-point results
|
|
||||||
result = emitDstOperandModifiers(result, ins.modifiers);
|
result = emitDstOperandModifiers(result, ins.modifiers);
|
||||||
emitRegisterStore(ins.dst[0], result);
|
emitRegisterStore(ins.dst[i], result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DxbcCompiler::emitVectorCmp(const DxbcShaderInstruction& ins) {
|
void DxbcCompiler::emitVectorCmp(const DxbcShaderInstruction& ins) {
|
||||||
|
@ -649,7 +649,13 @@ namespace dxvk {
|
|||||||
/* BfRev */
|
/* BfRev */
|
||||||
{ },
|
{ },
|
||||||
/* Swapc */
|
/* 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 */
|
/* DclStream */
|
||||||
{ },
|
{ },
|
||||||
/* DclFunctionBody */
|
/* DclFunctionBody */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user