summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler
diff options
context:
space:
mode:
authorFengChen <vonchenplus@gmail.com>2022-09-10 11:09:45 +0200
committerFengChen <vonchenplus@gmail.com>2022-09-20 06:03:31 +0200
commitd4cb0eac87c9dea121a0f6bd2355fa5e6c641274 (patch)
tree292908a4b59bc6443d252fd313aaeb3da9dd2be8 /src/shader_recompiler
parentMerge pull request #8863 from german77/triggers (diff)
downloadyuzu-d4cb0eac87c9dea121a0f6bd2355fa5e6c641274.tar
yuzu-d4cb0eac87c9dea121a0f6bd2355fa5e6c641274.tar.gz
yuzu-d4cb0eac87c9dea121a0f6bd2355fa5e6c641274.tar.bz2
yuzu-d4cb0eac87c9dea121a0f6bd2355fa5e6c641274.tar.lz
yuzu-d4cb0eac87c9dea121a0f6bd2355fa5e6c641274.tar.xz
yuzu-d4cb0eac87c9dea121a0f6bd2355fa5e6c641274.tar.zst
yuzu-d4cb0eac87c9dea121a0f6bd2355fa5e6c641274.zip
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate_program.cpp39
-rw-r--r--src/shader_recompiler/runtime_info.h2
-rw-r--r--src/shader_recompiler/shader_info.h3
3 files changed, 29 insertions, 15 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.cpp b/src/shader_recompiler/frontend/maxwell/translate_program.cpp
index 77efb4f57..3aee33a96 100644
--- a/src/shader_recompiler/frontend/maxwell/translate_program.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate_program.cpp
@@ -137,28 +137,35 @@ bool IsLegacyAttribute(IR::Attribute attribute) {
}
std::map<IR::Attribute, IR::Attribute> GenerateLegacyToGenericMappings(
- const VaryingState& state, std::queue<IR::Attribute> ununsed_generics) {
+ const VaryingState& state, std::queue<IR::Attribute> unused_generics,
+ const std::map<IR::Attribute, IR::Attribute>& previous_stage_mapping) {
std::map<IR::Attribute, IR::Attribute> mapping;
+ auto update_mapping = [&mapping, &unused_generics, previous_stage_mapping](IR::Attribute attr,
+ size_t count) {
+ if (previous_stage_mapping.find(attr) != previous_stage_mapping.end()) {
+ for (size_t i = 0; i < count; ++i) {
+ mapping.insert({attr + i, previous_stage_mapping.at(attr + i)});
+ }
+ } else {
+ for (size_t i = 0; i < count; ++i) {
+ mapping.insert({attr + i, unused_generics.front() + i});
+ }
+ unused_generics.pop();
+ }
+ };
for (size_t index = 0; index < 4; ++index) {
auto attr = IR::Attribute::ColorFrontDiffuseR + index * 4;
if (state.AnyComponent(attr)) {
- for (size_t i = 0; i < 4; ++i) {
- mapping.insert({attr + i, ununsed_generics.front() + i});
- }
- ununsed_generics.pop();
+ update_mapping(attr, 4);
}
}
if (state[IR::Attribute::FogCoordinate]) {
- mapping.insert({IR::Attribute::FogCoordinate, ununsed_generics.front()});
- ununsed_generics.pop();
+ update_mapping(IR::Attribute::FogCoordinate, 1);
}
for (size_t index = 0; index < IR::NUM_FIXEDFNCTEXTURE; ++index) {
auto attr = IR::Attribute::FixedFncTexture0S + index * 4;
if (state.AnyComponent(attr)) {
- for (size_t i = 0; i < 4; ++i) {
- mapping.insert({attr + i, ununsed_generics.front() + i});
- }
- ununsed_generics.pop();
+ update_mapping(attr, 4);
}
}
return mapping;
@@ -271,15 +278,16 @@ void ConvertLegacyToGeneric(IR::Program& program, const Shader::RuntimeInfo& run
ununsed_output_generics.push(IR::Attribute::Generic0X + index * 4);
}
}
- auto mappings = GenerateLegacyToGenericMappings(stores, ununsed_output_generics);
+ program.info.legacy_stores_mapping =
+ GenerateLegacyToGenericMappings(stores, ununsed_output_generics, {});
for (IR::Block* const block : program.post_order_blocks) {
for (IR::Inst& inst : block->Instructions()) {
switch (inst.GetOpcode()) {
case IR::Opcode::SetAttribute: {
const auto attr = inst.Arg(0).Attribute();
if (IsLegacyAttribute(attr)) {
- stores.Set(mappings[attr], true);
- inst.SetArg(0, Shader::IR::Value(mappings[attr]));
+ stores.Set(program.info.legacy_stores_mapping[attr], true);
+ inst.SetArg(0, Shader::IR::Value(program.info.legacy_stores_mapping[attr]));
}
break;
}
@@ -300,7 +308,8 @@ void ConvertLegacyToGeneric(IR::Program& program, const Shader::RuntimeInfo& run
ununsed_input_generics.push(IR::Attribute::Generic0X + index * 4);
}
}
- auto mappings = GenerateLegacyToGenericMappings(loads, ununsed_input_generics);
+ auto mappings = GenerateLegacyToGenericMappings(
+ loads, ununsed_input_generics, runtime_info.previous_stage_legacy_stores_mapping);
for (IR::Block* const block : program.post_order_blocks) {
for (IR::Inst& inst : block->Instructions()) {
switch (inst.GetOpcode()) {
diff --git a/src/shader_recompiler/runtime_info.h b/src/shader_recompiler/runtime_info.h
index dcb5ab158..549b81ef7 100644
--- a/src/shader_recompiler/runtime_info.h
+++ b/src/shader_recompiler/runtime_info.h
@@ -4,6 +4,7 @@
#pragma once
#include <array>
+#include <map>
#include <optional>
#include <vector>
@@ -60,6 +61,7 @@ struct TransformFeedbackVarying {
struct RuntimeInfo {
std::array<AttributeType, 32> generic_input_types{};
VaryingState previous_stage_stores;
+ std::map<IR::Attribute, IR::Attribute> previous_stage_legacy_stores_mapping;
bool convert_depth_mode{};
bool force_early_z{};
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h
index f5690805c..c3c586ada 100644
--- a/src/shader_recompiler/shader_info.h
+++ b/src/shader_recompiler/shader_info.h
@@ -5,6 +5,7 @@
#include <array>
#include <bitset>
+#include <map>
#include "common/common_types.h"
#include "shader_recompiler/frontend/ir/type.h"
@@ -123,6 +124,8 @@ struct Info {
VaryingState stores;
VaryingState passthrough;
+ std::map<IR::Attribute, IR::Attribute> legacy_stores_mapping;
+
bool loads_indexed_attributes{};
std::array<bool, 8> stores_frag_color{};