diff options
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell/program.cpp')
| -rw-r--r-- | src/shader_recompiler/frontend/maxwell/program.cpp | 35 |
1 files changed, 35 insertions, 0 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) { | |||
| 27 | }); | 27 | }); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static void CollectInterpolationInfo(Environment& env, IR::Program& program) { | ||
| 31 | if (program.stage != Stage::Fragment) { | ||
| 32 | return; | ||
| 33 | } | ||
| 34 | const ProgramHeader& sph{env.SPH()}; | ||
| 35 | for (size_t index = 0; index < program.info.input_generics.size(); ++index) { | ||
| 36 | std::optional<PixelImap> imap; | ||
| 37 | for (const PixelImap value : sph.ps.GenericInputMap(static_cast<u32>(index))) { | ||
| 38 | if (value == PixelImap::Unused) { | ||
| 39 | continue; | ||
| 40 | } | ||
| 41 | if (imap && imap != value) { | ||
| 42 | throw NotImplementedException("Per component interpolation"); | ||
| 43 | } | ||
| 44 | imap = value; | ||
| 45 | } | ||
| 46 | if (!imap) { | ||
| 47 | continue; | ||
| 48 | } | ||
| 49 | program.info.input_generics[index].interpolation = [&] { | ||
| 50 | switch (*imap) { | ||
| 51 | case PixelImap::Unused: | ||
| 52 | case PixelImap::Perspective: | ||
| 53 | return Interpolation::Smooth; | ||
| 54 | case PixelImap::Constant: | ||
| 55 | return Interpolation::Flat; | ||
| 56 | case PixelImap::ScreenLinear: | ||
| 57 | return Interpolation::NoPerspective; | ||
| 58 | } | ||
| 59 | throw NotImplementedException("Unknown interpolation {}", *imap); | ||
| 60 | }(); | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 30 | IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool, | 64 | IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool, |
| 31 | Environment& env, Flow::CFG& cfg) { | 65 | Environment& env, Flow::CFG& cfg) { |
| 32 | IR::Program program; | 66 | IR::Program program; |
| @@ -51,6 +85,7 @@ IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Blo | |||
| 51 | Optimization::IdentityRemovalPass(program); | 85 | Optimization::IdentityRemovalPass(program); |
| 52 | Optimization::VerificationPass(program); | 86 | Optimization::VerificationPass(program); |
| 53 | Optimization::CollectShaderInfoPass(program); | 87 | Optimization::CollectShaderInfoPass(program); |
| 88 | CollectInterpolationInfo(env, program); | ||
| 54 | return program; | 89 | return program; |
| 55 | } | 90 | } |
| 56 | 91 | ||