From 02f9c5ffd204fb1641c6b5cedc1bc30529cfe3c3 Mon Sep 17 00:00:00 2001 From: CamilleLaVey Date: Sun, 8 Mar 2026 01:07:59 -0400 Subject: [PATCH] Revert "[test] Histogram debug - shader float control -> initial target: Adreno" --- .../frontend/maxwell/translate_program.cpp | 219 ------------------ 1 file changed, 219 deletions(-) diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.cpp b/src/shader_recompiler/frontend/maxwell/translate_program.cpp index 6cca023330..b1c1fc528b 100644 --- a/src/shader_recompiler/frontend/maxwell/translate_program.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate_program.cpp @@ -5,9 +5,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include -#include #include -#include #include #include @@ -25,214 +23,6 @@ namespace Shader::Maxwell { namespace { -struct FpControlHistogram { - std::array total{}; - std::array no_contraction{}; - std::array, 2> rounding{}; - std::array, 2> fmz{}; - std::array, 5>, 2> combos{}; -}; - -[[nodiscard]] constexpr std::string_view StageName(Stage stage) noexcept { - switch (stage) { - case Stage::VertexA: - return "VertexA"; - case Stage::VertexB: - return "VertexB"; - case Stage::TessellationControl: - return "TessellationControl"; - case Stage::TessellationEval: - return "TessellationEval"; - case Stage::Geometry: - return "Geometry"; - case Stage::Fragment: - return "Fragment"; - case Stage::Compute: - return "Compute"; - } - return "Unknown"; -} - -[[nodiscard]] constexpr std::string_view RoundingName(IR::FpRounding rounding) noexcept { - switch (rounding) { - case IR::FpRounding::DontCare: - return "DontCare"; - case IR::FpRounding::RN: - return "RN"; - case IR::FpRounding::RM: - return "RM"; - case IR::FpRounding::RP: - return "RP"; - case IR::FpRounding::RZ: - return "RZ"; - } - return "Unknown"; -} - -[[nodiscard]] constexpr std::string_view FmzName(IR::FmzMode fmz_mode) noexcept { - switch (fmz_mode) { - case IR::FmzMode::DontCare: - return "DontCare"; - case IR::FmzMode::FTZ: - return "FTZ"; - case IR::FmzMode::FMZ: - return "FMZ"; - case IR::FmzMode::None: - return "None"; - } - return "Unknown"; -} - -[[nodiscard]] constexpr std::optional FpControlBucket(const IR::Opcode opcode) noexcept { - switch (opcode) { - case IR::Opcode::FPAdd16: - case IR::Opcode::FPFma16: - case IR::Opcode::FPMul16: - case IR::Opcode::FPRoundEven16: - case IR::Opcode::FPFloor16: - case IR::Opcode::FPCeil16: - case IR::Opcode::FPTrunc16: - return 0; - case IR::Opcode::FPAdd32: - case IR::Opcode::FPFma32: - case IR::Opcode::FPMul32: - case IR::Opcode::FPRoundEven32: - case IR::Opcode::FPFloor32: - case IR::Opcode::FPCeil32: - case IR::Opcode::FPTrunc32: - case IR::Opcode::FPOrdEqual32: - case IR::Opcode::FPUnordEqual32: - case IR::Opcode::FPOrdNotEqual32: - case IR::Opcode::FPUnordNotEqual32: - case IR::Opcode::FPOrdLessThan32: - case IR::Opcode::FPUnordLessThan32: - case IR::Opcode::FPOrdGreaterThan32: - case IR::Opcode::FPUnordGreaterThan32: - case IR::Opcode::FPOrdLessThanEqual32: - case IR::Opcode::FPUnordLessThanEqual32: - case IR::Opcode::FPOrdGreaterThanEqual32: - case IR::Opcode::FPUnordGreaterThanEqual32: - case IR::Opcode::ConvertF16F32: - case IR::Opcode::ConvertF64F32: - return 1; - default: - return std::nullopt; - } -} - -FpControlHistogram CollectFpControlHistogram(const IR::Program& program) { - FpControlHistogram histogram{}; - 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()}; - ++histogram.total[*bucket]; - if (flags.no_contraction) { - ++histogram.no_contraction[*bucket]; - } - ++histogram.rounding[*bucket][static_cast(flags.rounding)]; - ++histogram.fmz[*bucket][static_cast(flags.fmz_mode)]; - ++histogram.combos[*bucket][static_cast(flags.rounding)] - [static_cast(flags.fmz_mode)]; - } - } - 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) { - return; - } - - LOG_INFO(Shader, "FP_HIST {} shader blocks={} post_order_blocks={}", - StageName(program.stage), program.blocks.size(), program.post_order_blocks.size()); - - constexpr std::array precision_names{"fp16", "fp32"}; - for (size_t bucket = 0; bucket < precision_names.size(); ++bucket) { - if (histogram.total[bucket] == 0) { - continue; - } - - LOG_INFO(Shader, - "FP_HIST {} total={} no_contraction={} rounding[DontCare={}, RN={}, RM={}, RP={}, RZ={}] fmz[DontCare={}, FTZ={}, FMZ={}, None={}]", - precision_names[bucket], histogram.total[bucket], histogram.no_contraction[bucket], - histogram.rounding[bucket][static_cast(IR::FpRounding::DontCare)], - histogram.rounding[bucket][static_cast(IR::FpRounding::RN)], - histogram.rounding[bucket][static_cast(IR::FpRounding::RM)], - histogram.rounding[bucket][static_cast(IR::FpRounding::RP)], - histogram.rounding[bucket][static_cast(IR::FpRounding::RZ)], - histogram.fmz[bucket][static_cast(IR::FmzMode::DontCare)], - histogram.fmz[bucket][static_cast(IR::FmzMode::FTZ)], - histogram.fmz[bucket][static_cast(IR::FmzMode::FMZ)], - histogram.fmz[bucket][static_cast(IR::FmzMode::None)]); - - for (size_t rounding = 0; rounding < histogram.combos[bucket].size(); ++rounding) { - for (size_t fmz = 0; fmz < histogram.combos[bucket][rounding].size(); ++fmz) { - const u32 count{histogram.combos[bucket][rounding][fmz]}; - if (count == 0) { - continue; - } - LOG_INFO(Shader, "FP_HIST {} combo {} / {} = {}", precision_names[bucket], - RoundingName(static_cast(rounding)), - FmzName(static_cast(fmz)), count); - } - } - } -} - IR::BlockList GenerateBlocks(const IR::AbstractSyntaxList& syntax_list) { size_t num_syntax_blocks{}; for (const auto& node : syntax_list) { @@ -527,11 +317,6 @@ IR::Program TranslateProgram(ObjectPool& inst_pool, ObjectPool