diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-03-27 08:59:58 +0100 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:24 +0200 |
commit | dbd882ddeb1a1a9233c0085d0b8ccb022db385b2 (patch) | |
tree | 5a8456364cc41a0a53acf93e22e3f9ce855bd413 /src/shader_recompiler/frontend/maxwell | |
parent | spirv: Remove dependencies on Environment when generating SPIR-V (diff) | |
download | yuzu-dbd882ddeb1a1a9233c0085d0b8ccb022db385b2.tar yuzu-dbd882ddeb1a1a9233c0085d0b8ccb022db385b2.tar.gz yuzu-dbd882ddeb1a1a9233c0085d0b8ccb022db385b2.tar.bz2 yuzu-dbd882ddeb1a1a9233c0085d0b8ccb022db385b2.tar.lz yuzu-dbd882ddeb1a1a9233c0085d0b8ccb022db385b2.tar.xz yuzu-dbd882ddeb1a1a9233c0085d0b8ccb022db385b2.tar.zst yuzu-dbd882ddeb1a1a9233c0085d0b8ccb022db385b2.zip |
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell')
-rw-r--r-- | src/shader_recompiler/frontend/maxwell/program.cpp | 35 | ||||
-rw-r--r-- | src/shader_recompiler/frontend/maxwell/translate/impl/load_store_attribute.cpp | 10 |
2 files changed, 36 insertions, 9 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/program.cpp b/src/shader_recompiler/frontend/maxwell/program.cpp index 6efaf6ee0..a914a91f4 100644 --- a/src/shader_recompiler/frontend/maxwell/program.cpp +++ b/src/shader_recompiler/frontend/maxwell/program.cpp @@ -27,6 +27,40 @@ static void RemoveUnreachableBlocks(IR::Program& program) { }); } +static void CollectInterpolationInfo(Environment& env, IR::Program& program) { + if (program.stage != Stage::Fragment) { + return; + } + const ProgramHeader& sph{env.SPH()}; + for (size_t index = 0; index < program.info.input_generics.size(); ++index) { + std::optional<PixelImap> imap; + for (const PixelImap value : sph.ps.GenericInputMap(static_cast<u32>(index))) { + if (value == PixelImap::Unused) { + continue; + } + if (imap && imap != value) { + throw NotImplementedException("Per component interpolation"); + } + imap = value; + } + if (!imap) { + continue; + } + program.info.input_generics[index].interpolation = [&] { + switch (*imap) { + case PixelImap::Unused: + case PixelImap::Perspective: + return Interpolation::Smooth; + case PixelImap::Constant: + return Interpolation::Flat; + case PixelImap::ScreenLinear: + return Interpolation::NoPerspective; + } + throw NotImplementedException("Unknown interpolation {}", *imap); + }(); + } +} + IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool, Environment& env, Flow::CFG& cfg) { IR::Program program; @@ -51,6 +85,7 @@ IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Blo Optimization::IdentityRemovalPass(program); Optimization::VerificationPass(program); Optimization::CollectShaderInfoPass(program); + CollectInterpolationInfo(env, program); return program; } diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/load_store_attribute.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/load_store_attribute.cpp index 516ffec2d..54bc1e34c 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/load_store_attribute.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/load_store_attribute.cpp @@ -151,16 +151,8 @@ void TranslatorVisitor::IPA(u64 insn) { value = ir.FPMul(value, position_w); } } - switch (ipa.interpolation_mode) { - case InterpolationMode::Pass: - break; - case InterpolationMode::Multiply: + if (ipa.interpolation_mode == InterpolationMode::Multiply) { value = ir.FPMul(value, F(ipa.multiplier)); - break; - case InterpolationMode::Constant: - throw NotImplementedException("IPA.CONSTANT"); - case InterpolationMode::Sc: - throw NotImplementedException("IPA.SC"); } // Saturated IPAs are generally generated out of clamped varyings. |