VERY experimental Nintendo Switch 2 emulator
C++
shader: Address feedback
FernandoS27ffb90d59c6fc
diff --git a/src/shader_recompiler/frontend/ir/modifiers.h b/src/shader_recompiler/frontend/ir/modifiers.hindex 2aa4ac79b3..461671326b 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.cppindex 8876a5c336..c8bd7b329b 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 instructionbool 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 itselfvoid 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 positivesstatic 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.cppindex 72d4abb774..2592337461 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;}