Skip to content

Commit

Permalink
[dxso] Implement zerowins for Lerp.
Browse files Browse the repository at this point in the history
  • Loading branch information
DadSchoorse authored and misyltoad committed Mar 16, 2022
1 parent 1f88ee5 commit 630fee5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/dxso/dxso_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,25 @@ namespace dxvk {
return dot;
}

DxsoRegisterValue DxsoCompiler::emitMix(
DxsoRegisterValue x,
DxsoRegisterValue y,
DxsoRegisterValue a) {
uint32_t typeId = getVectorTypeId(x.type);

if (m_moduleInfo.options.d3d9FloatEmulation != D3D9FloatEmulation::Strict)
return {x.type, m_module.opFMix(typeId, x.id, y.id, a.id)};

uint32_t oneId = m_module.constfReplicant(1.0f, a.type.ccount);

DxsoRegisterValue revA;
revA.type = a.type;
revA.id = m_module.opFSub(typeId, oneId, a.id);

DxsoRegisterValue xRevA = emitMul(x, revA);
return emitFma(a, y, xRevA);
}


DxsoRegisterValue DxsoCompiler::emitCross(
DxsoRegisterValue a,
Expand Down Expand Up @@ -2226,10 +2245,10 @@ namespace dxvk {
}
break;
case DxsoOpcode::Lrp:
result.id = m_module.opFMix(typeId,
emitRegisterLoad(src[2], mask).id,
emitRegisterLoad(src[1], mask).id,
emitRegisterLoad(src[0], mask).id);
result.id = emitMix(
emitRegisterLoad(src[2], mask),
emitRegisterLoad(src[1], mask),
emitRegisterLoad(src[0], mask)).id;
break;
case DxsoOpcode::Frc:
result.id = m_module.opFract(typeId,
Expand Down
5 changes: 5 additions & 0 deletions src/dxso/dxso_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ namespace dxvk {
DxsoRegisterValue a,
DxsoRegisterValue b);

DxsoRegisterValue emitMix(
DxsoRegisterValue x,
DxsoRegisterValue y,
DxsoRegisterValue a);

DxsoRegisterValue emitCross(
DxsoRegisterValue a,
DxsoRegisterValue b);
Expand Down

0 comments on commit 630fee5

Please sign in to comment.