yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

shader: Remove unused AbufNode Ipa mode

This commit is contained in:
ReinUsesLisp 2019-04-29 23:37:09 -03:00
parent 002ecbea19
commit 06b363c9b5
6 changed files with 14 additions and 35 deletions

View File

@ -317,8 +317,7 @@ private:
void DeclareInputAttributes() { void DeclareInputAttributes() {
const auto& attributes = ir.GetInputAttributes(); const auto& attributes = ir.GetInputAttributes();
for (const auto element : attributes) { for (const auto index : attributes) {
const Attribute::Index index = element.first;
if (index < Attribute::Index::Attribute_0 || index > Attribute::Index::Attribute_31) { if (index < Attribute::Index::Attribute_0 || index > Attribute::Index::Attribute_31) {
// Skip when it's not a generic attribute // Skip when it's not a generic attribute
continue; continue;

View File

@ -194,8 +194,8 @@ public:
for (const auto& sampler : ir.GetSamplers()) { for (const auto& sampler : ir.GetSamplers()) {
entries.samplers.emplace_back(sampler); entries.samplers.emplace_back(sampler);
} }
for (const auto& attr : ir.GetInputAttributes()) { for (const auto& attribute : ir.GetInputAttributes()) {
entries.attributes.insert(GetGenericAttributeLocation(attr.first)); entries.attributes.insert(GetGenericAttributeLocation(attribute));
} }
entries.clip_distances = ir.GetClipDistances(); entries.clip_distances = ir.GetClipDistances();
entries.shader_length = ir.GetLength(); entries.shader_length = ir.GetLength();
@ -322,8 +322,7 @@ private:
} }
void DeclareInputAttributes() { void DeclareInputAttributes() {
for (const auto element : ir.GetInputAttributes()) { for (const auto index : ir.GetInputAttributes()) {
const Attribute::Index index = element.first;
if (!IsGenericAttribute(index)) { if (!IsGenericAttribute(index)) {
continue; continue;
} }

View File

@ -50,16 +50,13 @@ u32 ShaderIR::DecodeMemory(NodeBlock& bb, u32 pc) {
UNIMPLEMENTED_IF_MSG((instr.attribute.fmt20.immediate.Value() % sizeof(u32)) != 0, UNIMPLEMENTED_IF_MSG((instr.attribute.fmt20.immediate.Value() % sizeof(u32)) != 0,
"Unaligned attribute loads are not supported"); "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; u64 next_element = instr.attribute.fmt20.element;
auto next_index = static_cast<u64>(instr.attribute.fmt20.index.Value()); auto next_index = static_cast<u64>(instr.attribute.fmt20.index.Value());
const auto LoadNextElement = [&](u32 reg_offset) { const auto LoadNextElement = [&](u32 reg_offset) {
const Node buffer = GetRegister(instr.gpr39); const Node buffer = GetRegister(instr.gpr39);
const Node attribute = GetInputAttribute(static_cast<Attribute::Index>(next_index), const Node attribute =
next_element, input_mode, buffer); GetInputAttribute(static_cast<Attribute::Index>(next_index), next_element, buffer);
SetRegister(bb, instr.gpr0.Value() + reg_offset, attribute); SetRegister(bb, instr.gpr0.Value() + reg_offset, attribute);

View File

@ -134,7 +134,7 @@ u32 ShaderIR::DecodeOther(NodeBlock& bb, u32 pc) {
const Tegra::Shader::IpaMode input_mode{instr.ipa.interp_mode.Value(), const Tegra::Shader::IpaMode input_mode{instr.ipa.interp_mode.Value(),
instr.ipa.sample_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; Node value = attr;
const Tegra::Shader::Attribute::Index index = attribute.index.Value(); const Tegra::Shader::Attribute::Index index = attribute.index.Value();
if (index >= Tegra::Shader::Attribute::Index::Attribute_0 && if (index >= Tegra::Shader::Attribute::Index::Attribute_0 &&

View File

@ -89,13 +89,9 @@ Node ShaderIR::GetPredicate(bool immediate) {
return GetPredicate(static_cast<u64>(immediate ? Pred::UnusedIndex : Pred::NeverExecute)); return GetPredicate(static_cast<u64>(immediate ? Pred::UnusedIndex : Pred::NeverExecute));
} }
Node ShaderIR::GetInputAttribute(Attribute::Index index, u64 element, Node ShaderIR::GetInputAttribute(Attribute::Index index, u64 element, Node buffer) {
const Tegra::Shader::IpaMode& input_mode, Node buffer) { used_input_attributes.emplace(index);
const auto [entry, is_new] = return StoreNode(AbufNode(index, static_cast<u32>(element), buffer));
used_input_attributes.emplace(std::make_pair(index, std::set<Tegra::Shader::IpaMode>{}));
entry->second.insert(input_mode);
return StoreNode(AbufNode(index, static_cast<u32>(element), input_mode, buffer));
} }
Node ShaderIR::GetOutputAttribute(Attribute::Index index, u64 element, Node buffer) { Node ShaderIR::GetOutputAttribute(Attribute::Index index, u64 element, Node buffer) {

View File

@ -465,17 +465,9 @@ private:
/// Attribute buffer memory (known as attributes or varyings in GLSL terms) /// Attribute buffer memory (known as attributes or varyings in GLSL terms)
class AbufNode final { class AbufNode final {
public: 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, explicit constexpr AbufNode(Tegra::Shader::Attribute::Index index, u32 element,
Node buffer = {}) Node buffer = {})
: input_mode{}, buffer{buffer}, index{index}, element{element} {} : buffer{buffer}, index{index}, element{element} {}
Tegra::Shader::IpaMode GetInputMode() const {
return input_mode;
}
Tegra::Shader::Attribute::Index GetIndex() const { Tegra::Shader::Attribute::Index GetIndex() const {
return index; return index;
@ -490,7 +482,6 @@ public:
} }
private: private:
const Tegra::Shader::IpaMode input_mode;
const Node buffer; const Node buffer;
const Tegra::Shader::Attribute::Index index; const Tegra::Shader::Attribute::Index index;
const u32 element; const u32 element;
@ -585,8 +576,7 @@ public:
return used_predicates; return used_predicates;
} }
const std::map<Tegra::Shader::Attribute::Index, std::set<Tegra::Shader::IpaMode>>& const std::set<Tegra::Shader::Attribute::Index>& GetInputAttributes() const {
GetInputAttributes() const {
return used_input_attributes; return used_input_attributes;
} }
@ -700,8 +690,7 @@ private:
/// Generates a predicate node for an immediate true or false value /// Generates a predicate node for an immediate true or false value
Node GetPredicate(bool immediate); Node GetPredicate(bool immediate);
/// Generates a node representing an input attribute. Keeps track of used attributes. /// Generates a node representing an input attribute. Keeps track of used attributes.
Node GetInputAttribute(Tegra::Shader::Attribute::Index index, u64 element, Node GetInputAttribute(Tegra::Shader::Attribute::Index index, u64 element, Node buffer = {});
const Tegra::Shader::IpaMode& input_mode, Node buffer = {});
/// Generates a node representing an output attribute. Keeps track of used attributes. /// Generates a node representing an output attribute. Keeps track of used attributes.
Node GetOutputAttribute(Tegra::Shader::Attribute::Index index, u64 element, Node buffer); Node GetOutputAttribute(Tegra::Shader::Attribute::Index index, u64 element, Node buffer);
/// Generates a node representing an internal flag /// Generates a node representing an internal flag
@ -876,8 +865,7 @@ private:
std::set<u32> used_registers; std::set<u32> used_registers;
std::set<Tegra::Shader::Pred> used_predicates; std::set<Tegra::Shader::Pred> used_predicates;
std::map<Tegra::Shader::Attribute::Index, std::set<Tegra::Shader::IpaMode>> std::set<Tegra::Shader::Attribute::Index> used_input_attributes;
used_input_attributes;
std::set<Tegra::Shader::Attribute::Index> used_output_attributes; std::set<Tegra::Shader::Attribute::Index> used_output_attributes;
std::map<u32, ConstBuffer> used_cbufs; std::map<u32, ConstBuffer> used_cbufs;
std::set<Sampler> used_samplers; std::set<Sampler> used_samplers;