mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-12 13:08:50 +01:00
[dxso] Implement bem instruction
This commit is contained in:
parent
a79772322b
commit
404c984f9c
@ -128,6 +128,7 @@ namespace dxvk {
|
|||||||
case DxsoOpcode::Lrp:
|
case DxsoOpcode::Lrp:
|
||||||
case DxsoOpcode::Frc:
|
case DxsoOpcode::Frc:
|
||||||
case DxsoOpcode::Cmp:
|
case DxsoOpcode::Cmp:
|
||||||
|
case DxsoOpcode::Bem:
|
||||||
case DxsoOpcode::Cnd:
|
case DxsoOpcode::Cnd:
|
||||||
case DxsoOpcode::Dp2Add:
|
case DxsoOpcode::Dp2Add:
|
||||||
case DxsoOpcode::DsX:
|
case DxsoOpcode::DsX:
|
||||||
@ -2196,6 +2197,41 @@ namespace dxvk {
|
|||||||
emitRegisterLoad(src[2], mask).id);
|
emitRegisterLoad(src[2], mask).id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case DxsoOpcode::Bem: {
|
||||||
|
DxsoRegisterValue src0 = emitRegisterLoad(src[0], mask);
|
||||||
|
DxsoRegisterValue src1 = emitRegisterLoad(src[1], mask);
|
||||||
|
|
||||||
|
// dst.x = src0.x + [bm00(m) * src1.x + bm10(m) * src1.y]
|
||||||
|
// dst.y = src0.y + [bm01(m) * src1.x + bm11(m) * src1.y]
|
||||||
|
|
||||||
|
// But we flipped the bm indices so we can use dot here...
|
||||||
|
|
||||||
|
// dst.x = src0.x + dot(bm0, src1)
|
||||||
|
// dst.y = src0.y + dot(bm1, src1)
|
||||||
|
|
||||||
|
std::array<uint32_t, 2> values = { m_module.constf32(0.0f), m_module.constf32(0.0f) };
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < 2; i++) {
|
||||||
|
uint32_t fl_t = getScalarTypeId(DxsoScalarType::Float32);
|
||||||
|
uint32_t vec2_t = getVectorTypeId({ DxsoScalarType::Float32, 2 });
|
||||||
|
std::array<uint32_t, 4> indices = { 0, 1, 2, 3 };
|
||||||
|
|
||||||
|
uint32_t tc_m_n = m_module.opCompositeExtract(fl_t, src0.id, 1, &i);
|
||||||
|
|
||||||
|
uint32_t offset = m_module.constu32(D3D9SharedPSStages_Count * ctx.dst.id.num + D3D9SharedPSStages_BumpEnvMat0 + i);
|
||||||
|
uint32_t bm = m_module.opAccessChain(m_module.defPointerType(vec2_t, spv::StorageClassUniform),
|
||||||
|
m_ps.sharedState, 1, &offset);
|
||||||
|
bm = m_module.opLoad(vec2_t, bm);
|
||||||
|
|
||||||
|
uint32_t t = m_module.opVectorShuffle(vec2_t, src1.id, src1.id, 2, indices.data());
|
||||||
|
|
||||||
|
uint32_t dot = m_module.opDot(fl_t, bm, t);
|
||||||
|
|
||||||
|
values[i] = m_module.opFAdd(fl_t, tc_m_n, dot);
|
||||||
|
}
|
||||||
|
result.id = m_module.opCompositeConstruct(typeId, values.size(), values.data());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case DxsoOpcode::Cnd: {
|
case DxsoOpcode::Cnd: {
|
||||||
const uint32_t boolTypeId =
|
const uint32_t boolTypeId =
|
||||||
getVectorTypeId({ DxsoScalarType::Bool, result.type.ccount });
|
getVectorTypeId({ DxsoScalarType::Bool, result.type.ccount });
|
||||||
|
Loading…
Reference in New Issue
Block a user