From 06b363c9b5ccb64cfe7ac4d001ae35bff30828de Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Mon, 29 Apr 2019 23:37:09 -0300 Subject: [PATCH] shader: Remove unused AbufNode Ipa mode --- .../renderer_opengl/gl_shader_decompiler.cpp | 3 +-- .../renderer_vulkan/vk_shader_decompiler.cpp | 7 +++---- src/video_core/shader/decode/memory.cpp | 7 ++----- src/video_core/shader/decode/other.cpp | 2 +- src/video_core/shader/shader_ir.cpp | 10 +++------- src/video_core/shader/shader_ir.h | 20 ++++--------------- 6 files changed, 14 insertions(+), 35 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index ef1a1995f..33c0edca9 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -317,8 +317,7 @@ private: void DeclareInputAttributes() { const auto& attributes = ir.GetInputAttributes(); - for (const auto element : attributes) { - const Attribute::Index index = element.first; + for (const auto index : attributes) { if (index < Attribute::Index::Attribute_0 || index > Attribute::Index::Attribute_31) { // Skip when it's not a generic attribute continue; diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index 23d9b10db..850085f35 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp @@ -194,8 +194,8 @@ public: for (const auto& sampler : ir.GetSamplers()) { entries.samplers.emplace_back(sampler); } - for (const auto& attr : ir.GetInputAttributes()) { - entries.attributes.insert(GetGenericAttributeLocation(attr.first)); + for (const auto& attribute : ir.GetInputAttributes()) { + entries.attributes.insert(GetGenericAttributeLocation(attribute)); } entries.clip_distances = ir.GetClipDistances(); entries.shader_length = ir.GetLength(); @@ -322,8 +322,7 @@ private: } void DeclareInputAttributes() { - for (const auto element : ir.GetInputAttributes()) { - const Attribute::Index index = element.first; + for (const auto index : ir.GetInputAttributes()) { if (!IsGenericAttribute(index)) { continue; } diff --git a/src/video_core/shader/decode/memory.cpp b/src/video_core/shader/decode/memory.cpp index 4aa74965f..84db4d4dc 100644 --- a/src/video_core/shader/decode/memory.cpp +++ b/src/video_core/shader/decode/memory.cpp @@ -50,16 +50,13 @@ u32 ShaderIR::DecodeMemory(NodeBlock& bb, u32 pc) { UNIMPLEMENTED_IF_MSG((instr.attribute.fmt20.immediate.Value() % sizeof(u32)) != 0, "Unaligned attribute loads are not supported"); - Tegra::Shader::IpaMode input_mode{Tegra::Shader::IpaInterpMode::Pass, - Tegra::Shader::IpaSampleMode::Default}; - u64 next_element = instr.attribute.fmt20.element; auto next_index = static_cast(instr.attribute.fmt20.index.Value()); const auto LoadNextElement = [&](u32 reg_offset) { const Node buffer = GetRegister(instr.gpr39); - const Node attribute = GetInputAttribute(static_cast(next_index), - next_element, input_mode, buffer); + const Node attribute = + GetInputAttribute(static_cast(next_index), next_element, buffer); SetRegister(bb, instr.gpr0.Value() + reg_offset, attribute); diff --git a/src/video_core/shader/decode/other.cpp b/src/video_core/shader/decode/other.cpp index d750a2936..776bdb931 100644 --- a/src/video_core/shader/decode/other.cpp +++ b/src/video_core/shader/decode/other.cpp @@ -134,7 +134,7 @@ u32 ShaderIR::DecodeOther(NodeBlock& bb, u32 pc) { const Tegra::Shader::IpaMode input_mode{instr.ipa.interp_mode.Value(), instr.ipa.sample_mode.Value()}; - const Node attr = GetInputAttribute(attribute.index, attribute.element, input_mode); + const Node attr = GetInputAttribute(attribute.index, attribute.element); Node value = attr; const Tegra::Shader::Attribute::Index index = attribute.index.Value(); if (index >= Tegra::Shader::Attribute::Index::Attribute_0 && diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp index e4eb0dfd9..0307ae5b0 100644 --- a/src/video_core/shader/shader_ir.cpp +++ b/src/video_core/shader/shader_ir.cpp @@ -89,13 +89,9 @@ Node ShaderIR::GetPredicate(bool immediate) { return GetPredicate(static_cast(immediate ? Pred::UnusedIndex : Pred::NeverExecute)); } -Node ShaderIR::GetInputAttribute(Attribute::Index index, u64 element, - const Tegra::Shader::IpaMode& input_mode, Node buffer) { - const auto [entry, is_new] = - used_input_attributes.emplace(std::make_pair(index, std::set{})); - entry->second.insert(input_mode); - - return StoreNode(AbufNode(index, static_cast(element), input_mode, buffer)); +Node ShaderIR::GetInputAttribute(Attribute::Index index, u64 element, Node buffer) { + used_input_attributes.emplace(index); + return StoreNode(AbufNode(index, static_cast(element), buffer)); } Node ShaderIR::GetOutputAttribute(Attribute::Index index, u64 element, Node buffer) { diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index b157608b7..6aff64394 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h @@ -465,17 +465,9 @@ private: /// Attribute buffer memory (known as attributes or varyings in GLSL terms) class AbufNode final { public: - explicit constexpr AbufNode(Tegra::Shader::Attribute::Index index, u32 element, - const Tegra::Shader::IpaMode& input_mode, Node buffer = {}) - : input_mode{input_mode}, buffer{buffer}, index{index}, element{element} {} - explicit constexpr AbufNode(Tegra::Shader::Attribute::Index index, u32 element, Node buffer = {}) - : input_mode{}, buffer{buffer}, index{index}, element{element} {} - - Tegra::Shader::IpaMode GetInputMode() const { - return input_mode; - } + : buffer{buffer}, index{index}, element{element} {} Tegra::Shader::Attribute::Index GetIndex() const { return index; @@ -490,7 +482,6 @@ public: } private: - const Tegra::Shader::IpaMode input_mode; const Node buffer; const Tegra::Shader::Attribute::Index index; const u32 element; @@ -585,8 +576,7 @@ public: return used_predicates; } - const std::map>& - GetInputAttributes() const { + const std::set& GetInputAttributes() const { return used_input_attributes; } @@ -700,8 +690,7 @@ private: /// Generates a predicate node for an immediate true or false value Node GetPredicate(bool immediate); /// Generates a node representing an input attribute. Keeps track of used attributes. - Node GetInputAttribute(Tegra::Shader::Attribute::Index index, u64 element, - const Tegra::Shader::IpaMode& input_mode, Node buffer = {}); + Node GetInputAttribute(Tegra::Shader::Attribute::Index index, u64 element, Node buffer = {}); /// Generates a node representing an output attribute. Keeps track of used attributes. Node GetOutputAttribute(Tegra::Shader::Attribute::Index index, u64 element, Node buffer); /// Generates a node representing an internal flag @@ -876,8 +865,7 @@ private: std::set used_registers; std::set used_predicates; - std::map> - used_input_attributes; + std::set used_input_attributes; std::set used_output_attributes; std::map used_cbufs; std::set used_samplers;