shader: Better but still partial interpolation support

This commit is contained in:
ReinUsesLisp 2021-03-21 21:01:47 -03:00 committed by ameerj
parent e4e1cc11b8
commit 96b7ced6ec

View File

@ -141,14 +141,16 @@ void TranslatorVisitor::IPA(u64 insn) {
const IR::Attribute attribute{ipa.attribute}; const IR::Attribute attribute{ipa.attribute};
IR::F32 value{ir.GetAttribute(attribute)}; IR::F32 value{ir.GetAttribute(attribute)};
if (IR::IsGeneric(attribute)) { if (IR::IsGeneric(attribute)) {
// const bool is_perspective{UnimplementedReadHeader(GenericAttributeIndex(attribute))}; const ProgramHeader& sph{env.SPH()};
const bool is_perspective{false}; const u32 attr_index{IR::GenericAttributeIndex(attribute)};
const u32 element{static_cast<u32>(attribute) % 4};
const std::array input_map{sph.ps.GenericInputMap(attr_index)};
const bool is_perspective{input_map[element] == Shader::PixelImap::Perspective};
if (is_perspective) { if (is_perspective) {
const IR::F32 rcp_position_w{ir.FPRecip(ir.GetAttribute(IR::Attribute::PositionW))}; const IR::F32 position_w{ir.GetAttribute(IR::Attribute::PositionW)};
value = ir.FPMul(value, rcp_position_w); value = ir.FPMul(value, position_w);
} }
} }
switch (ipa.interpolation_mode) { switch (ipa.interpolation_mode) {
case InterpolationMode::Pass: case InterpolationMode::Pass:
break; break;