diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.cpp b/src/shader_recompiler/frontend/maxwell/translate_program.cpp index d7cf548c63..f52a3e72de 100644 --- a/src/shader_recompiler/frontend/maxwell/translate_program.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate_program.cpp @@ -142,6 +142,55 @@ FpControlHistogram CollectFpControlHistogram(const IR::Program& program) { return histogram; } +void LogRzFpControlTrace(Environment& env, const IR::Program& program) { + std::array totals{}; + for (const IR::Block* const block : program.post_order_blocks) { + for (const IR::Inst& inst : block->Instructions()) { + const std::optional bucket{FpControlBucket(inst.GetOpcode())}; + if (!bucket) { + continue; + } + const auto flags{inst.Flags()}; + if (flags.rounding != IR::FpRounding::RZ) { + continue; + } + ++totals[*bucket]; + } + } + + if (totals[0] == 0 && totals[1] == 0) { + return; + } + + constexpr std::array precision_names{"fp16", "fp32"}; + LOG_INFO(Shader, + "FP_RZ {} shader start={:#010x} blocks={} post_order_blocks={} fp16={} fp32={}", + StageName(program.stage), env.StartAddress(), program.blocks.size(), + program.post_order_blocks.size(), totals[0], totals[1]); + + for (const IR::Block* const block : program.post_order_blocks) { + u32 inst_index{}; + for (const IR::Inst& inst : block->Instructions()) { + const std::optional bucket{FpControlBucket(inst.GetOpcode())}; + if (!bucket) { + ++inst_index; + continue; + } + const auto flags{inst.Flags()}; + if (flags.rounding != IR::FpRounding::RZ) { + ++inst_index; + continue; + } + LOG_INFO(Shader, + "FP_RZ {} start={:#010x} block_order={} inst_index={} precision={} opcode={} no_contraction={} fmz={}", + StageName(program.stage), env.StartAddress(), block->GetOrder(), inst_index, + precision_names[*bucket], inst.GetOpcode(), flags.no_contraction, + FmzName(flags.fmz_mode)); + ++inst_index; + } + } +} + void LogFpControlHistogram(const IR::Program& program) { const FpControlHistogram histogram{CollectFpControlHistogram(program)}; if (histogram.total[0] == 0 && histogram.total[1] == 0) { @@ -479,6 +528,7 @@ IR::Program TranslateProgram(ObjectPool& inst_pool, ObjectPool