summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/ir_opt
diff options
context:
space:
mode:
authorFernandoS27 <fsahmkow27@gmail.com>2021-04-04 06:47:14 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:26 +0200
commit1d51803169f72f79e19995072fb9e8a371dbdcbf (patch)
treeeb668d924985e4b0bd599a695a0a2eee30fd0090 /src/shader_recompiler/ir_opt
parentshader: Implement AL2P (diff)
downloadyuzu-1d51803169f72f79e19995072fb9e8a371dbdcbf.tar
yuzu-1d51803169f72f79e19995072fb9e8a371dbdcbf.tar.gz
yuzu-1d51803169f72f79e19995072fb9e8a371dbdcbf.tar.bz2
yuzu-1d51803169f72f79e19995072fb9e8a371dbdcbf.tar.lz
yuzu-1d51803169f72f79e19995072fb9e8a371dbdcbf.tar.xz
yuzu-1d51803169f72f79e19995072fb9e8a371dbdcbf.tar.zst
yuzu-1d51803169f72f79e19995072fb9e8a371dbdcbf.zip
Diffstat (limited to 'src/shader_recompiler/ir_opt')
-rw-r--r--src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp36
-rw-r--r--src/shader_recompiler/ir_opt/passes.h2
2 files changed, 36 insertions, 2 deletions
diff --git a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
index 0f870535b..dbe9f1f40 100644
--- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
+++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
@@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include "shader_recompiler/environment.h"
#include "shader_recompiler/frontend/ir/microinstruction.h"
#include "shader_recompiler/frontend/ir/modifiers.h"
#include "shader_recompiler/frontend/ir/program.h"
@@ -323,6 +324,12 @@ void VisitUsages(Info& info, IR::Inst& inst) {
case IR::Opcode::SetAttribute:
SetAttribute(info, inst.Arg(0).Attribute());
break;
+ case IR::Opcode::GetAttributeIndexed:
+ info.loads_indexed_attributes = true;
+ break;
+ case IR::Opcode::SetAttributeIndexed:
+ info.stores_indexed_attributes = true;
+ break;
case IR::Opcode::SetFragColor:
info.stores_frag_color[inst.Arg(0).U32()] = true;
break;
@@ -502,15 +509,42 @@ void Visit(Info& info, IR::Inst& inst) {
VisitUsages(info, inst);
VisitFpModifiers(info, inst);
}
+
+void GatherInfoFromHeader(Environment& env, Info& info) {
+ auto stage = env.ShaderStage();
+ if (stage == Stage::Compute) {
+ return;
+ }
+ const auto& header = env.SPH();
+ if (stage == Stage::Fragment) {
+ for (size_t i = 0; i < info.input_generics.size(); i++) {
+ info.input_generics[i].used =
+ info.input_generics[i].used || header.ps.IsGenericVectorActive(i);
+ }
+ return;
+ }
+ for (size_t i = 0; i < info.input_generics.size(); i++) {
+ info.input_generics[i].used =
+ info.input_generics[i].used || header.vtg.IsInputGenericVectorActive(i);
+ }
+ for (size_t i = 0; i < info.stores_generics.size(); i++) {
+ info.stores_generics[i] =
+ info.stores_generics[i] || header.vtg.IsOutputGenericVectorActive(i);
+ }
+ info.stores_clip_distance =
+ info.stores_clip_distance || header.vtg.omap_systemc.clip_distances != 0;
+}
+
} // Anonymous namespace
-void CollectShaderInfoPass(IR::Program& program) {
+void CollectShaderInfoPass(Environment& env, IR::Program& program) {
Info& info{program.info};
for (IR::Block* const block : program.post_order_blocks) {
for (IR::Inst& inst : block->Instructions()) {
Visit(info, inst);
}
}
+ GatherInfoFromHeader(env, info);
}
} // namespace Shader::Optimization
diff --git a/src/shader_recompiler/ir_opt/passes.h b/src/shader_recompiler/ir_opt/passes.h
index 5c1fc166c..186104713 100644
--- a/src/shader_recompiler/ir_opt/passes.h
+++ b/src/shader_recompiler/ir_opt/passes.h
@@ -12,7 +12,7 @@
namespace Shader::Optimization {
-void CollectShaderInfoPass(IR::Program& program);
+void CollectShaderInfoPass(Environment& env, IR::Program& program);
void ConstantPropagationPass(IR::Program& program);
void DeadCodeEliminationPass(IR::Program& program);
void GlobalMemoryToStorageBufferPass(IR::Program& program);