summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler
diff options
context:
space:
mode:
authorFernandoS27 <fsahmkow27@gmail.com>2021-04-03 02:34:07 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:26 +0200
commited6a1b1a3def4b8ed8c8fd1a7774a0a14edefc70 (patch)
treec7ec469906ac5a8d2788316203b3c507286b940c /src/shader_recompiler
parentshader: "Implement" NOP (diff)
downloadyuzu-ed6a1b1a3def4b8ed8c8fd1a7774a0a14edefc70.tar
yuzu-ed6a1b1a3def4b8ed8c8fd1a7774a0a14edefc70.tar.gz
yuzu-ed6a1b1a3def4b8ed8c8fd1a7774a0a14edefc70.tar.bz2
yuzu-ed6a1b1a3def4b8ed8c8fd1a7774a0a14edefc70.tar.lz
yuzu-ed6a1b1a3def4b8ed8c8fd1a7774a0a14edefc70.tar.xz
yuzu-ed6a1b1a3def4b8ed8c8fd1a7774a0a14edefc70.tar.zst
yuzu-ed6a1b1a3def4b8ed8c8fd1a7774a0a14edefc70.zip
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r--src/shader_recompiler/frontend/ir/modifiers.h8
-rw-r--r--src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp20
-rw-r--r--src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp1
3 files changed, 16 insertions, 13 deletions
diff --git a/src/shader_recompiler/frontend/ir/modifiers.h b/src/shader_recompiler/frontend/ir/modifiers.h
index 2aa4ac79b..461671326 100644
--- a/src/shader_recompiler/frontend/ir/modifiers.h
+++ b/src/shader_recompiler/frontend/ir/modifiers.h
@@ -25,7 +25,13 @@ enum class FpRounding : u8 {
RZ, // Round towards zero
};
-enum class MemoryScope : u32 { DontCare, Warp, Workgroup, Device, System };
+enum class MemoryScope : u32 {
+ DontCare,
+ Warp,
+ Workgroup,
+ Device,
+ System,
+};
struct FpControl {
bool no_contraction{false};
diff --git a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
index 8876a5c33..c8bd7b329 100644
--- a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
+++ b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
@@ -46,7 +46,9 @@ using StorageBufferSet =
using StorageInstVector = boost::container::small_vector<StorageInst, 24>;
using VisitedBlocks = boost::container::flat_set<IR::Block*, std::less<IR::Block*>,
boost::container::small_vector<IR::Block*, 4>>;
-using StorageWritesMap = std::map<StorageBufferAddr, bool>;
+using StorageWritesSet =
+ boost::container::flat_set<StorageBufferAddr, std::less<StorageBufferAddr>,
+ boost::container::small_vector<StorageBufferAddr, 16>>;
/// Returns true when the instruction is a global memory instruction
bool IsGlobalMemory(const IR::Inst& inst) {
@@ -266,7 +268,7 @@ std::optional<StorageBufferAddr> Track(IR::Block* block, const IR::Value& value,
/// Collects the storage buffer used by a global memory instruction and the instruction itself
void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageBufferSet& storage_buffer_set,
- StorageInstVector& to_replace, StorageWritesMap& writes_map) {
+ StorageInstVector& to_replace, StorageWritesSet& writes_set) {
// NVN puts storage buffers in a specific range, we have to bias towards these addresses to
// avoid getting false positives
static constexpr Bias nvn_bias{
@@ -295,12 +297,8 @@ void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageBufferSet& s
}
}
// Collect storage buffer and the instruction
- const bool is_a_write{IsGlobalMemoryWrite(inst)};
- auto it{writes_map.find(*storage_buffer)};
- if (it == writes_map.end()) {
- writes_map[*storage_buffer] = is_a_write;
- } else {
- it->second = it->second || is_a_write;
+ if (IsGlobalMemoryWrite(inst)) {
+ writes_set.insert(*storage_buffer);
}
storage_buffer_set.insert(*storage_buffer);
to_replace.push_back(StorageInst{
@@ -375,14 +373,14 @@ void Replace(IR::Block& block, IR::Inst& inst, const IR::U32& storage_index,
void GlobalMemoryToStorageBufferPass(IR::Program& program) {
StorageBufferSet storage_buffers;
StorageInstVector to_replace;
- StorageWritesMap writes_map;
+ StorageWritesSet writes_set;
for (IR::Block* const block : program.post_order_blocks) {
for (IR::Inst& inst : block->Instructions()) {
if (!IsGlobalMemory(inst)) {
continue;
}
- CollectStorageBuffers(*block, inst, storage_buffers, to_replace, writes_map);
+ CollectStorageBuffers(*block, inst, storage_buffers, to_replace, writes_set);
}
}
Info& info{program.info};
@@ -392,7 +390,7 @@ void GlobalMemoryToStorageBufferPass(IR::Program& program) {
.cbuf_index{storage_buffer.index},
.cbuf_offset{storage_buffer.offset},
.count{1},
- .is_written{writes_map[storage_buffer]},
+ .is_written{writes_set.contains(storage_buffer)},
});
++storage_index;
}
diff --git a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp
index 72d4abb77..259233746 100644
--- a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp
+++ b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp
@@ -275,7 +275,6 @@ void VisitInst(Pass& pass, IR::Block* block, IR::Inst& inst) {
case IR::Opcode::GetOFlag:
inst.ReplaceUsesWith(pass.ReadVariable(OverflowFlagTag{}, block));
break;
- break;
default:
break;
}