summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/ir_opt
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2022-12-28 03:39:46 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2023-01-03 22:29:25 +0100
commita045e860dd63a46c1f44d343007d772e6da6b037 (patch)
tree7c910d74f74aa48858a1d4012d543946516cc554 /src/shader_recompiler/ir_opt
parentVulkan: rework stencil tracking. (diff)
downloadyuzu-a045e860dd63a46c1f44d343007d772e6da6b037.tar
yuzu-a045e860dd63a46c1f44d343007d772e6da6b037.tar.gz
yuzu-a045e860dd63a46c1f44d343007d772e6da6b037.tar.bz2
yuzu-a045e860dd63a46c1f44d343007d772e6da6b037.tar.lz
yuzu-a045e860dd63a46c1f44d343007d772e6da6b037.tar.xz
yuzu-a045e860dd63a46c1f44d343007d772e6da6b037.tar.zst
yuzu-a045e860dd63a46c1f44d343007d772e6da6b037.zip
Diffstat (limited to 'src/shader_recompiler/ir_opt')
-rw-r--r--src/shader_recompiler/ir_opt/constant_propagation_pass.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp
index ac10405f3..5275b2c8b 100644
--- a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp
+++ b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp
@@ -677,6 +677,30 @@ void FoldConstBuffer(Environment& env, IR::Block& block, IR::Inst& inst) {
}
}
+void FoldDriverConstBuffer(Environment& env, IR::Block& block, IR::Inst& inst, u32 which_bank,
+ u32 offset_start = 0, u32 offset_end = std::numeric_limits<u16>::max()) {
+ const IR::Value bank{inst.Arg(0)};
+ const IR::Value offset{inst.Arg(1)};
+ if (!bank.IsImmediate() || !offset.IsImmediate()) {
+ return;
+ }
+ const auto bank_value = bank.U32();
+ if (bank_value != which_bank) {
+ return;
+ }
+ const auto offset_value = offset.U32();
+ if (offset_value < offset_start || offset_value >= offset_end) {
+ return;
+ }
+ IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)};
+ if (inst.GetOpcode() == IR::Opcode::GetCbufU32) {
+ inst.ReplaceUsesWith(IR::Value{env.ReadCbufValue(bank_value, offset_value)});
+ } else {
+ inst.ReplaceUsesWith(
+ IR::Value{Common::BitCast<f32>(env.ReadCbufValue(bank_value, offset_value))});
+ }
+}
+
void ConstantPropagation(Environment& env, IR::Block& block, IR::Inst& inst) {
switch (inst.GetOpcode()) {
case IR::Opcode::GetRegister:
@@ -825,13 +849,17 @@ void ConstantPropagation(Environment& env, IR::Block& block, IR::Inst& inst) {
case IR::Opcode::GetCbufF32:
case IR::Opcode::GetCbufU32:
if (env.HasHLEMacroState()) {
- return FoldConstBuffer(env, block, inst);
+ FoldConstBuffer(env, block, inst);
+ }
+ if (env.IsPropietaryDriver()) {
+ FoldDriverConstBuffer(env, block, inst, 1);
}
break;
default:
break;
}
}
+
} // Anonymous namespace
void ConstantPropagationPass(Environment& env, IR::Program& program) {