summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/fs/file.h5
-rw-r--r--src/common/input.h2
-rw-r--r--src/common/wall_clock.cpp16
-rw-r--r--src/common/wall_clock.h8
-rw-r--r--src/common/x64/native_clock.cpp6
-rw-r--r--src/core/hle/kernel/svc.cpp2
-rw-r--r--src/input_common/drivers/udp_client.cpp15
-rw-r--r--src/input_common/drivers/udp_client.h4
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_instructions.h31
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_memory.cpp107
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp142
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_instructions.h31
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp119
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_instructions.h30
-rw-r--r--src/shader_recompiler/frontend/ir/microinstruction.cpp19
-rw-r--r--src/shader_recompiler/frontend/ir/opcodes.inc19
-rw-r--r--src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp18
-rw-r--r--src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp49
-rw-r--r--src/shader_recompiler/ir_opt/lower_int64_to_int32.cpp20
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h47
-rw-r--r--src/video_core/engines/engine_upload.cpp7
-rw-r--r--src/video_core/engines/engine_upload.h8
-rw-r--r--src/video_core/engines/kepler_compute.cpp1
-rw-r--r--src/video_core/engines/kepler_memory.cpp4
-rw-r--r--src/video_core/engines/kepler_memory.h7
-rw-r--r--src/video_core/engines/maxwell_3d.cpp1
-rw-r--r--src/video_core/engines/maxwell_3d.h3
-rw-r--r--src/video_core/gpu.cpp8
-rw-r--r--src/video_core/memory_manager.h4
-rw-r--r--src/video_core/rasterizer_interface.h3
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp22
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h2
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp22
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.h2
-rw-r--r--src/video_core/shader_cache.cpp4
-rw-r--r--src/video_core/shader_cache.h3
-rw-r--r--src/yuzu/configuration/configure_dialog.cpp2
-rw-r--r--src/yuzu/configuration/configure_filesystem.cpp16
-rw-r--r--src/yuzu/configuration/configure_filesystem.h8
-rw-r--r--src/yuzu/configuration/configure_hotkeys.cpp32
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp27
-rw-r--r--src/yuzu/configuration/configure_motion_touch.cpp38
-rw-r--r--src/yuzu/game_list.cpp2
43 files changed, 829 insertions, 87 deletions
diff --git a/src/common/fs/file.h b/src/common/fs/file.h
index 2c4ab4332..a4f7944cd 100644
--- a/src/common/fs/file.h
+++ b/src/common/fs/file.h
@@ -188,9 +188,8 @@ public:
188 188
189#ifdef _WIN32 189#ifdef _WIN32
190 template <typename Path> 190 template <typename Path>
191 [[nodiscard]] void Open(const Path& path, FileAccessMode mode, 191 void Open(const Path& path, FileAccessMode mode, FileType type = FileType::BinaryFile,
192 FileType type = FileType::BinaryFile, 192 FileShareFlag flag = FileShareFlag::ShareReadOnly) {
193 FileShareFlag flag = FileShareFlag::ShareReadOnly) {
194 using ValueType = typename Path::value_type; 193 using ValueType = typename Path::value_type;
195 if constexpr (IsChar<ValueType>) { 194 if constexpr (IsChar<ValueType>) {
196 Open(ToU8String(path), mode, type, flag); 195 Open(ToU8String(path), mode, type, flag);
diff --git a/src/common/input.h b/src/common/input.h
index f4f9eb30a..54fcb24b0 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -209,6 +209,8 @@ enum class ButtonNames {
209 Triangle, 209 Triangle,
210 Share, 210 Share,
211 Options, 211 Options,
212 Home,
213 Touch,
212 214
213 // Mouse buttons 215 // Mouse buttons
214 ButtonMouseWheel, 216 ButtonMouseWheel,
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp
index ffa282e88..9acf7551e 100644
--- a/src/common/wall_clock.cpp
+++ b/src/common/wall_clock.cpp
@@ -65,16 +65,20 @@ private:
65 65
66#ifdef ARCHITECTURE_x86_64 66#ifdef ARCHITECTURE_x86_64
67 67
68std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, 68std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
69 u32 emulated_clock_frequency) { 69 u64 emulated_clock_frequency) {
70 const auto& caps = GetCPUCaps(); 70 const auto& caps = GetCPUCaps();
71 u64 rtsc_frequency = 0; 71 u64 rtsc_frequency = 0;
72 if (caps.invariant_tsc) { 72 if (caps.invariant_tsc) {
73 rtsc_frequency = EstimateRDTSCFrequency(); 73 rtsc_frequency = EstimateRDTSCFrequency();
74 } 74 }
75 75
76 // Fallback to StandardWallClock if rtsc period is higher than a nano second 76 // Fallback to StandardWallClock if the hardware TSC does not have the precision greater than:
77 if (rtsc_frequency <= 1000000000) { 77 // - A nanosecond
78 // - The emulated CPU frequency
79 // - The emulated clock counter frequency (CNTFRQ)
80 if (rtsc_frequency <= WallClock::NS_RATIO || rtsc_frequency <= emulated_cpu_frequency ||
81 rtsc_frequency <= emulated_clock_frequency) {
78 return std::make_unique<StandardWallClock>(emulated_cpu_frequency, 82 return std::make_unique<StandardWallClock>(emulated_cpu_frequency,
79 emulated_clock_frequency); 83 emulated_clock_frequency);
80 } else { 84 } else {
@@ -85,8 +89,8 @@ std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
85 89
86#else 90#else
87 91
88std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, 92std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
89 u32 emulated_clock_frequency) { 93 u64 emulated_clock_frequency) {
90 return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency); 94 return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency);
91} 95}
92 96
diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h
index cef3e9499..874448c27 100644
--- a/src/common/wall_clock.h
+++ b/src/common/wall_clock.h
@@ -13,6 +13,10 @@ namespace Common {
13 13
14class WallClock { 14class WallClock {
15public: 15public:
16 static constexpr u64 NS_RATIO = 1'000'000'000;
17 static constexpr u64 US_RATIO = 1'000'000;
18 static constexpr u64 MS_RATIO = 1'000;
19
16 virtual ~WallClock() = default; 20 virtual ~WallClock() = default;
17 21
18 /// Returns current wall time in nanoseconds 22 /// Returns current wall time in nanoseconds
@@ -49,7 +53,7 @@ private:
49 bool is_native; 53 bool is_native;
50}; 54};
51 55
52[[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, 56[[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
53 u32 emulated_clock_frequency); 57 u64 emulated_clock_frequency);
54 58
55} // namespace Common 59} // namespace Common
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp
index 82ee2c8a1..91b842829 100644
--- a/src/common/x64/native_clock.cpp
+++ b/src/common/x64/native_clock.cpp
@@ -47,9 +47,9 @@ NativeClock::NativeClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequen
47 _mm_mfence(); 47 _mm_mfence();
48 time_point.inner.last_measure = __rdtsc(); 48 time_point.inner.last_measure = __rdtsc();
49 time_point.inner.accumulated_ticks = 0U; 49 time_point.inner.accumulated_ticks = 0U;
50 ns_rtsc_factor = GetFixedPoint64Factor(1000000000, rtsc_frequency); 50 ns_rtsc_factor = GetFixedPoint64Factor(NS_RATIO, rtsc_frequency);
51 us_rtsc_factor = GetFixedPoint64Factor(1000000, rtsc_frequency); 51 us_rtsc_factor = GetFixedPoint64Factor(US_RATIO, rtsc_frequency);
52 ms_rtsc_factor = GetFixedPoint64Factor(1000, rtsc_frequency); 52 ms_rtsc_factor = GetFixedPoint64Factor(MS_RATIO, rtsc_frequency);
53 clock_rtsc_factor = GetFixedPoint64Factor(emulated_clock_frequency, rtsc_frequency); 53 clock_rtsc_factor = GetFixedPoint64Factor(emulated_clock_frequency, rtsc_frequency);
54 cpu_rtsc_factor = GetFixedPoint64Factor(emulated_cpu_frequency, rtsc_frequency); 54 cpu_rtsc_factor = GetFixedPoint64Factor(emulated_cpu_frequency, rtsc_frequency);
55} 55}
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 40bb893ac..4f7aebf3f 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -2613,7 +2613,7 @@ static const FunctionDef SVC_Table_32[] = {
2613 {0x33, SvcWrap32<GetThreadContext32>, "GetThreadContext32"}, 2613 {0x33, SvcWrap32<GetThreadContext32>, "GetThreadContext32"},
2614 {0x34, SvcWrap32<WaitForAddress32>, "WaitForAddress32"}, 2614 {0x34, SvcWrap32<WaitForAddress32>, "WaitForAddress32"},
2615 {0x35, SvcWrap32<SignalToAddress32>, "SignalToAddress32"}, 2615 {0x35, SvcWrap32<SignalToAddress32>, "SignalToAddress32"},
2616 {0x36, nullptr, "Unknown"}, 2616 {0x36, SvcWrap32<SynchronizePreemptionState>, "SynchronizePreemptionState32"},
2617 {0x37, nullptr, "Unknown"}, 2617 {0x37, nullptr, "Unknown"},
2618 {0x38, nullptr, "Unknown"}, 2618 {0x38, nullptr, "Unknown"},
2619 {0x39, nullptr, "Unknown"}, 2619 {0x39, nullptr, "Unknown"},
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp
index d1cdb1ab2..333173e3d 100644
--- a/src/input_common/drivers/udp_client.cpp
+++ b/src/input_common/drivers/udp_client.cpp
@@ -271,7 +271,7 @@ void UDPClient::OnPadData(Response::PadData data, std::size_t client) {
271 const auto touch_axis_y_id = 271 const auto touch_axis_y_id =
272 static_cast<int>(id == 0 ? PadAxes::Touch1Y : PadAxes::Touch2Y); 272 static_cast<int>(id == 0 ? PadAxes::Touch1Y : PadAxes::Touch2Y);
273 const auto touch_button_id = 273 const auto touch_button_id =
274 static_cast<int>(id == 0 ? PadButton::Touch1 : PadButton::touch2); 274 static_cast<int>(id == 0 ? PadButton::Touch1 : PadButton::Touch2);
275 275
276 // TODO: Use custom calibration per device 276 // TODO: Use custom calibration per device
277 const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue()); 277 const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue());
@@ -319,6 +319,9 @@ void UDPClient::OnPadData(Response::PadData data, std::size_t client) {
319 SetButton(identifier, button, button_status); 319 SetButton(identifier, button, button_status);
320 } 320 }
321 321
322 SetButton(identifier, static_cast<int>(PadButton::Home), data.home != 0);
323 SetButton(identifier, static_cast<int>(PadButton::TouchHardPress), data.touch_hard_press != 0);
324
322 SetBattery(identifier, GetBatteryLevel(data.info.battery)); 325 SetBattery(identifier, GetBatteryLevel(data.info.battery));
323} 326}
324 327
@@ -393,7 +396,7 @@ std::vector<Common::ParamPackage> UDPClient::GetInputDevices() const {
393 396
394ButtonMapping UDPClient::GetButtonMappingForDevice(const Common::ParamPackage& params) { 397ButtonMapping UDPClient::GetButtonMappingForDevice(const Common::ParamPackage& params) {
395 // This list excludes any button that can't be really mapped 398 // This list excludes any button that can't be really mapped
396 static constexpr std::array<std::pair<Settings::NativeButton::Values, PadButton>, 18> 399 static constexpr std::array<std::pair<Settings::NativeButton::Values, PadButton>, 20>
397 switch_to_dsu_button = { 400 switch_to_dsu_button = {
398 std::pair{Settings::NativeButton::A, PadButton::Circle}, 401 std::pair{Settings::NativeButton::A, PadButton::Circle},
399 {Settings::NativeButton::B, PadButton::Cross}, 402 {Settings::NativeButton::B, PadButton::Cross},
@@ -413,6 +416,8 @@ ButtonMapping UDPClient::GetButtonMappingForDevice(const Common::ParamPackage& p
413 {Settings::NativeButton::SR, PadButton::R2}, 416 {Settings::NativeButton::SR, PadButton::R2},
414 {Settings::NativeButton::LStick, PadButton::L3}, 417 {Settings::NativeButton::LStick, PadButton::L3},
415 {Settings::NativeButton::RStick, PadButton::R3}, 418 {Settings::NativeButton::RStick, PadButton::R3},
419 {Settings::NativeButton::Home, PadButton::Home},
420 {Settings::NativeButton::Screenshot, PadButton::TouchHardPress},
416 }; 421 };
417 if (!params.Has("guid") || !params.Has("port") || !params.Has("pad")) { 422 if (!params.Has("guid") || !params.Has("port") || !params.Has("pad")) {
418 return {}; 423 return {};
@@ -517,6 +522,12 @@ Common::Input::ButtonNames UDPClient::GetUIButtonName(const Common::ParamPackage
517 return Common::Input::ButtonNames::Share; 522 return Common::Input::ButtonNames::Share;
518 case PadButton::Options: 523 case PadButton::Options:
519 return Common::Input::ButtonNames::Options; 524 return Common::Input::ButtonNames::Options;
525 case PadButton::Home:
526 return Common::Input::ButtonNames::Home;
527 case PadButton::Touch1:
528 case PadButton::Touch2:
529 case PadButton::TouchHardPress:
530 return Common::Input::ButtonNames::Touch;
520 default: 531 default:
521 return Common::Input::ButtonNames::Undefined; 532 return Common::Input::ButtonNames::Undefined;
522 } 533 }
diff --git a/src/input_common/drivers/udp_client.h b/src/input_common/drivers/udp_client.h
index 30d7c2682..e9c178139 100644
--- a/src/input_common/drivers/udp_client.h
+++ b/src/input_common/drivers/udp_client.h
@@ -84,7 +84,9 @@ private:
84 Cross = 0x4000, 84 Cross = 0x4000,
85 Square = 0x8000, 85 Square = 0x8000,
86 Touch1 = 0x10000, 86 Touch1 = 0x10000,
87 touch2 = 0x20000, 87 Touch2 = 0x20000,
88 Home = 0x40000,
89 TouchHardPress = 0x80000,
88 }; 90 };
89 91
90 enum class PadAxes : u8 { 92 enum class PadAxes : u8 {
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
index b48007856..5efbe4e6f 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
@@ -372,6 +372,8 @@ void EmitSharedAtomicExchange32(EmitContext& ctx, IR::Inst& inst, ScalarU32 poin
372 ScalarU32 value); 372 ScalarU32 value);
373void EmitSharedAtomicExchange64(EmitContext& ctx, IR::Inst& inst, ScalarU32 pointer_offset, 373void EmitSharedAtomicExchange64(EmitContext& ctx, IR::Inst& inst, ScalarU32 pointer_offset,
374 Register value); 374 Register value);
375void EmitSharedAtomicExchange32x2(EmitContext& ctx, IR::Inst& inst, ScalarU32 pointer_offset,
376 Register value);
375void EmitStorageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 377void EmitStorageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
376 ScalarU32 offset, ScalarU32 value); 378 ScalarU32 offset, ScalarU32 value);
377void EmitStorageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 379void EmitStorageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
@@ -412,6 +414,24 @@ void EmitStorageAtomicXor64(EmitContext& ctx, IR::Inst& inst, const IR::Value& b
412 ScalarU32 offset, Register value); 414 ScalarU32 offset, Register value);
413void EmitStorageAtomicExchange64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 415void EmitStorageAtomicExchange64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
414 ScalarU32 offset, Register value); 416 ScalarU32 offset, Register value);
417void EmitStorageAtomicIAdd32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
418 ScalarU32 offset, Register value);
419void EmitStorageAtomicSMin32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
420 ScalarU32 offset, Register value);
421void EmitStorageAtomicUMin32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
422 ScalarU32 offset, Register value);
423void EmitStorageAtomicSMax32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
424 ScalarU32 offset, Register value);
425void EmitStorageAtomicUMax32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
426 ScalarU32 offset, Register value);
427void EmitStorageAtomicAnd32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
428 ScalarU32 offset, Register value);
429void EmitStorageAtomicOr32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
430 ScalarU32 offset, Register value);
431void EmitStorageAtomicXor32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
432 ScalarU32 offset, Register value);
433void EmitStorageAtomicExchange32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
434 ScalarU32 offset, Register value);
415void EmitStorageAtomicAddF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 435void EmitStorageAtomicAddF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
416 ScalarU32 offset, ScalarF32 value); 436 ScalarU32 offset, ScalarF32 value);
417void EmitStorageAtomicAddF16x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 437void EmitStorageAtomicAddF16x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
@@ -448,6 +468,17 @@ void EmitGlobalAtomicAnd64(EmitContext& ctx);
448void EmitGlobalAtomicOr64(EmitContext& ctx); 468void EmitGlobalAtomicOr64(EmitContext& ctx);
449void EmitGlobalAtomicXor64(EmitContext& ctx); 469void EmitGlobalAtomicXor64(EmitContext& ctx);
450void EmitGlobalAtomicExchange64(EmitContext& ctx); 470void EmitGlobalAtomicExchange64(EmitContext& ctx);
471void EmitGlobalAtomicIAdd32x2(EmitContext& ctx);
472void EmitGlobalAtomicSMin32x2(EmitContext& ctx);
473void EmitGlobalAtomicUMin32x2(EmitContext& ctx);
474void EmitGlobalAtomicSMax32x2(EmitContext& ctx);
475void EmitGlobalAtomicUMax32x2(EmitContext& ctx);
476void EmitGlobalAtomicInc32x2(EmitContext& ctx);
477void EmitGlobalAtomicDec32x2(EmitContext& ctx);
478void EmitGlobalAtomicAnd32x2(EmitContext& ctx);
479void EmitGlobalAtomicOr32x2(EmitContext& ctx);
480void EmitGlobalAtomicXor32x2(EmitContext& ctx);
481void EmitGlobalAtomicExchange32x2(EmitContext& ctx);
451void EmitGlobalAtomicAddF32(EmitContext& ctx); 482void EmitGlobalAtomicAddF32(EmitContext& ctx);
452void EmitGlobalAtomicAddF16x2(EmitContext& ctx); 483void EmitGlobalAtomicAddF16x2(EmitContext& ctx);
453void EmitGlobalAtomicAddF32x2(EmitContext& ctx); 484void EmitGlobalAtomicAddF32x2(EmitContext& ctx);
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_memory.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_memory.cpp
index f135b67f5..f0fd94a28 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_memory.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_memory.cpp
@@ -311,6 +311,13 @@ void EmitSharedAtomicExchange64(EmitContext& ctx, IR::Inst& inst, ScalarU32 poin
311 ctx.LongAdd("ATOMS.EXCH.U64 {}.x,{},shared_mem[{}];", inst, value, pointer_offset); 311 ctx.LongAdd("ATOMS.EXCH.U64 {}.x,{},shared_mem[{}];", inst, value, pointer_offset);
312} 312}
313 313
314void EmitSharedAtomicExchange32x2([[maybe_unused]] EmitContext& ctx,
315 [[maybe_unused]] IR::Inst& inst,
316 [[maybe_unused]] ScalarU32 pointer_offset,
317 [[maybe_unused]] Register value) {
318 throw NotImplementedException("GLASM instruction");
319}
320
314void EmitStorageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 321void EmitStorageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
315 ScalarU32 offset, ScalarU32 value) { 322 ScalarU32 offset, ScalarU32 value) {
316 Atom(ctx, inst, binding, offset, value, "ADD", "U32"); 323 Atom(ctx, inst, binding, offset, value, "ADD", "U32");
@@ -411,6 +418,62 @@ void EmitStorageAtomicExchange64(EmitContext& ctx, IR::Inst& inst, const IR::Val
411 Atom(ctx, inst, binding, offset, value, "EXCH", "U64"); 418 Atom(ctx, inst, binding, offset, value, "EXCH", "U64");
412} 419}
413 420
421void EmitStorageAtomicIAdd32x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
422 [[maybe_unused]] const IR::Value& binding,
423 [[maybe_unused]] ScalarU32 offset, [[maybe_unused]] Register value) {
424 throw NotImplementedException("GLASM instruction");
425}
426
427void EmitStorageAtomicSMin32x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
428 [[maybe_unused]] const IR::Value& binding,
429 [[maybe_unused]] ScalarU32 offset, [[maybe_unused]] Register value) {
430 throw NotImplementedException("GLASM instruction");
431}
432
433void EmitStorageAtomicUMin32x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
434 [[maybe_unused]] const IR::Value& binding,
435 [[maybe_unused]] ScalarU32 offset, [[maybe_unused]] Register value) {
436 throw NotImplementedException("GLASM instruction");
437}
438
439void EmitStorageAtomicSMax32x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
440 [[maybe_unused]] const IR::Value& binding,
441 [[maybe_unused]] ScalarU32 offset, [[maybe_unused]] Register value) {
442 throw NotImplementedException("GLASM instruction");
443}
444
445void EmitStorageAtomicUMax32x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
446 [[maybe_unused]] const IR::Value& binding,
447 [[maybe_unused]] ScalarU32 offset, [[maybe_unused]] Register value) {
448 throw NotImplementedException("GLASM instruction");
449}
450
451void EmitStorageAtomicAnd32x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
452 [[maybe_unused]] const IR::Value& binding,
453 [[maybe_unused]] ScalarU32 offset, [[maybe_unused]] Register value) {
454 throw NotImplementedException("GLASM instruction");
455}
456
457void EmitStorageAtomicOr32x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
458 [[maybe_unused]] const IR::Value& binding,
459 [[maybe_unused]] ScalarU32 offset, [[maybe_unused]] Register value) {
460 throw NotImplementedException("GLASM instruction");
461}
462
463void EmitStorageAtomicXor32x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
464 [[maybe_unused]] const IR::Value& binding,
465 [[maybe_unused]] ScalarU32 offset, [[maybe_unused]] Register value) {
466 throw NotImplementedException("GLASM instruction");
467}
468
469void EmitStorageAtomicExchange32x2([[maybe_unused]] EmitContext& ctx,
470 [[maybe_unused]] IR::Inst& inst,
471 [[maybe_unused]] const IR::Value& binding,
472 [[maybe_unused]] ScalarU32 offset,
473 [[maybe_unused]] Register value) {
474 throw NotImplementedException("GLASM instruction");
475}
476
414void EmitStorageAtomicAddF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 477void EmitStorageAtomicAddF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
415 ScalarU32 offset, ScalarF32 value) { 478 ScalarU32 offset, ScalarF32 value) {
416 Atom(ctx, inst, binding, offset, value, "ADD", "F32"); 479 Atom(ctx, inst, binding, offset, value, "ADD", "F32");
@@ -537,6 +600,50 @@ void EmitGlobalAtomicExchange64(EmitContext&) {
537 throw NotImplementedException("GLASM instruction"); 600 throw NotImplementedException("GLASM instruction");
538} 601}
539 602
603void EmitGlobalAtomicIAdd32x2(EmitContext&) {
604 throw NotImplementedException("GLASM instruction");
605}
606
607void EmitGlobalAtomicSMin32x2(EmitContext&) {
608 throw NotImplementedException("GLASM instruction");
609}
610
611void EmitGlobalAtomicUMin32x2(EmitContext&) {
612 throw NotImplementedException("GLASM instruction");
613}
614
615void EmitGlobalAtomicSMax32x2(EmitContext&) {
616 throw NotImplementedException("GLASM instruction");
617}
618
619void EmitGlobalAtomicUMax32x2(EmitContext&) {
620 throw NotImplementedException("GLASM instruction");
621}
622
623void EmitGlobalAtomicInc32x2(EmitContext&) {
624 throw NotImplementedException("GLASM instruction");
625}
626
627void EmitGlobalAtomicDec32x2(EmitContext&) {
628 throw NotImplementedException("GLASM instruction");
629}
630
631void EmitGlobalAtomicAnd32x2(EmitContext&) {
632 throw NotImplementedException("GLASM instruction");
633}
634
635void EmitGlobalAtomicOr32x2(EmitContext&) {
636 throw NotImplementedException("GLASM instruction");
637}
638
639void EmitGlobalAtomicXor32x2(EmitContext&) {
640 throw NotImplementedException("GLASM instruction");
641}
642
643void EmitGlobalAtomicExchange32x2(EmitContext&) {
644 throw NotImplementedException("GLASM instruction");
645}
646
540void EmitGlobalAtomicAddF32(EmitContext&) { 647void EmitGlobalAtomicAddF32(EmitContext&) {
541 throw NotImplementedException("GLASM instruction"); 648 throw NotImplementedException("GLASM instruction");
542} 649}
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp
index dc377b053..a409a7ab3 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp
@@ -105,6 +105,13 @@ void EmitSharedAtomicExchange64(EmitContext& ctx, IR::Inst& inst, std::string_vi
105 pointer_offset, value, pointer_offset, value); 105 pointer_offset, value, pointer_offset, value);
106} 106}
107 107
108void EmitSharedAtomicExchange32x2(EmitContext& ctx, IR::Inst& inst, std::string_view pointer_offset,
109 std::string_view value) {
110 LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to non-atomic");
111 ctx.AddU32x2("{}=uvec2(smem[{}>>2],smem[({}+4)>>2]);", inst, pointer_offset, pointer_offset);
112 ctx.Add("smem[{}>>2]={}.x;smem[({}+4)>>2]={}.y;", pointer_offset, value, pointer_offset, value);
113}
114
108void EmitStorageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 115void EmitStorageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
109 const IR::Value& offset, std::string_view value) { 116 const IR::Value& offset, std::string_view value) {
110 ctx.AddU32("{}=atomicAdd({}_ssbo{}[{}>>2],{});", inst, ctx.stage_name, binding.U32(), 117 ctx.AddU32("{}=atomicAdd({}_ssbo{}[{}>>2],{});", inst, ctx.stage_name, binding.U32(),
@@ -265,6 +272,97 @@ void EmitStorageAtomicExchange64(EmitContext& ctx, IR::Inst& inst, const IR::Val
265 ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value); 272 ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value);
266} 273}
267 274
275void EmitStorageAtomicIAdd32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
276 const IR::Value& offset, std::string_view value) {
277 LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to non-atomic");
278 ctx.AddU32x2("{}=uvec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]);", inst, ctx.stage_name,
279 binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, binding.U32(),
280 ctx.var_alloc.Consume(offset));
281 ctx.Add("{}_ssbo{}[{}>>2]+={}.x;{}_ssbo{}[({}>>2)+1]+={}.y;", ctx.stage_name, binding.U32(),
282 ctx.var_alloc.Consume(offset), value, ctx.stage_name, binding.U32(),
283 ctx.var_alloc.Consume(offset), value);
284}
285
286void EmitStorageAtomicSMin32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
287 const IR::Value& offset, std::string_view value) {
288 LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to non-atomic");
289 ctx.AddU32x2("{}=ivec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]);", inst, ctx.stage_name,
290 binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, binding.U32(),
291 ctx.var_alloc.Consume(offset));
292 ctx.Add("for(int "
293 "i=0;i<2;++i){{{}_ssbo{}[({}>>2)+i]=uint(min(int({}_ssbo{}[({}>>2)+i]),int({}[i])));}}",
294 ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name,
295 binding.U32(), ctx.var_alloc.Consume(offset), value);
296}
297
298void EmitStorageAtomicUMin32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
299 const IR::Value& offset, std::string_view value) {
300 LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to non-atomic");
301 ctx.AddU32x2("{}=uvec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]);", inst, ctx.stage_name,
302 binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, binding.U32(),
303 ctx.var_alloc.Consume(offset));
304 ctx.Add("for(int i=0;i<2;++i){{ "
305 "{}_ssbo{}[({}>>2)+i]=min({}_ssbo{}[({}>>2)+i],{}[i]);}}",
306 ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name,
307 binding.U32(), ctx.var_alloc.Consume(offset), value);
308}
309
310void EmitStorageAtomicSMax32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
311 const IR::Value& offset, std::string_view value) {
312 LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to non-atomic");
313 ctx.AddU32x2("{}=ivec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]);", inst, ctx.stage_name,
314 binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, binding.U32(),
315 ctx.var_alloc.Consume(offset));
316 ctx.Add("for(int "
317 "i=0;i<2;++i){{{}_ssbo{}[({}>>2)+i]=uint(max(int({}_ssbo{}[({}>>2)+i]),int({}[i])));}}",
318 ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name,
319 binding.U32(), ctx.var_alloc.Consume(offset), value);
320}
321
322void EmitStorageAtomicUMax32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
323 const IR::Value& offset, std::string_view value) {
324 LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to non-atomic");
325 ctx.AddU32x2("{}=uvec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]);", inst, ctx.stage_name,
326 binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name, binding.U32(),
327 ctx.var_alloc.Consume(offset));
328 ctx.Add("for(int i=0;i<2;++i){{{}_ssbo{}[({}>>2)+i]=max({}_ssbo{}[({}>>2)+i],{}[i]);}}",
329 ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name,
330 binding.U32(), ctx.var_alloc.Consume(offset), value);
331}
332
333void EmitStorageAtomicAnd32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
334 const IR::Value& offset, std::string_view value) {
335 LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to 32x2");
336 ctx.AddU32x2("{}=uvec2(atomicAnd({}_ssbo{}[{}>>2],{}.x),atomicAnd({}_ssbo{}[({}>>2)+1],{}.y));",
337 inst, ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value,
338 ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value);
339}
340
341void EmitStorageAtomicOr32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
342 const IR::Value& offset, std::string_view value) {
343 LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to 32x2");
344 ctx.AddU32x2("{}=uvec2(atomicOr({}_ssbo{}[{}>>2],{}.x),atomicOr({}_ssbo{}[({}>>2)+1],{}.y));",
345 inst, ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value,
346 ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value);
347}
348
349void EmitStorageAtomicXor32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
350 const IR::Value& offset, std::string_view value) {
351 LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to 32x2");
352 ctx.AddU32x2("{}=uvec2(atomicXor({}_ssbo{}[{}>>2],{}.x),atomicXor({}_ssbo{}[({}>>2)+1],{}.y));",
353 inst, ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value,
354 ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value);
355}
356
357void EmitStorageAtomicExchange32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
358 const IR::Value& offset, std::string_view value) {
359 LOG_WARNING(Shader_GLSL, "Int64 atomics not supported, fallback to 32x2");
360 ctx.AddU32x2("{}=uvec2(atomicExchange({}_ssbo{}[{}>>2],{}.x),atomicExchange({}_ssbo{}[({}>>2)+"
361 "1],{}.y));",
362 inst, ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value,
363 ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), value);
364}
365
268void EmitStorageAtomicAddF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 366void EmitStorageAtomicAddF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
269 const IR::Value& offset, std::string_view value) { 367 const IR::Value& offset, std::string_view value) {
270 SsboCasFunctionF32(ctx, inst, binding, offset, value, "CasFloatAdd"); 368 SsboCasFunctionF32(ctx, inst, binding, offset, value, "CasFloatAdd");
@@ -388,6 +486,50 @@ void EmitGlobalAtomicExchange64(EmitContext&) {
388 throw NotImplementedException("GLSL Instrucion"); 486 throw NotImplementedException("GLSL Instrucion");
389} 487}
390 488
489void EmitGlobalAtomicIAdd32x2(EmitContext&) {
490 throw NotImplementedException("GLSL Instrucion");
491}
492
493void EmitGlobalAtomicSMin32x2(EmitContext&) {
494 throw NotImplementedException("GLSL Instrucion");
495}
496
497void EmitGlobalAtomicUMin32x2(EmitContext&) {
498 throw NotImplementedException("GLSL Instrucion");
499}
500
501void EmitGlobalAtomicSMax32x2(EmitContext&) {
502 throw NotImplementedException("GLSL Instrucion");
503}
504
505void EmitGlobalAtomicUMax32x2(EmitContext&) {
506 throw NotImplementedException("GLSL Instrucion");
507}
508
509void EmitGlobalAtomicInc32x2(EmitContext&) {
510 throw NotImplementedException("GLSL Instrucion");
511}
512
513void EmitGlobalAtomicDec32x2(EmitContext&) {
514 throw NotImplementedException("GLSL Instrucion");
515}
516
517void EmitGlobalAtomicAnd32x2(EmitContext&) {
518 throw NotImplementedException("GLSL Instrucion");
519}
520
521void EmitGlobalAtomicOr32x2(EmitContext&) {
522 throw NotImplementedException("GLSL Instrucion");
523}
524
525void EmitGlobalAtomicXor32x2(EmitContext&) {
526 throw NotImplementedException("GLSL Instrucion");
527}
528
529void EmitGlobalAtomicExchange32x2(EmitContext&) {
530 throw NotImplementedException("GLSL Instrucion");
531}
532
391void EmitGlobalAtomicAddF32(EmitContext&) { 533void EmitGlobalAtomicAddF32(EmitContext&) {
392 throw NotImplementedException("GLSL Instrucion"); 534 throw NotImplementedException("GLSL Instrucion");
393} 535}
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h
index 6cabbc717..704baddc9 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h
@@ -442,6 +442,8 @@ void EmitSharedAtomicExchange32(EmitContext& ctx, IR::Inst& inst, std::string_vi
442 std::string_view value); 442 std::string_view value);
443void EmitSharedAtomicExchange64(EmitContext& ctx, IR::Inst& inst, std::string_view pointer_offset, 443void EmitSharedAtomicExchange64(EmitContext& ctx, IR::Inst& inst, std::string_view pointer_offset,
444 std::string_view value); 444 std::string_view value);
445void EmitSharedAtomicExchange32x2(EmitContext& ctx, IR::Inst& inst, std::string_view pointer_offset,
446 std::string_view value);
445void EmitStorageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 447void EmitStorageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
446 const IR::Value& offset, std::string_view value); 448 const IR::Value& offset, std::string_view value);
447void EmitStorageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 449void EmitStorageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
@@ -482,6 +484,24 @@ void EmitStorageAtomicXor64(EmitContext& ctx, IR::Inst& inst, const IR::Value& b
482 const IR::Value& offset, std::string_view value); 484 const IR::Value& offset, std::string_view value);
483void EmitStorageAtomicExchange64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 485void EmitStorageAtomicExchange64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
484 const IR::Value& offset, std::string_view value); 486 const IR::Value& offset, std::string_view value);
487void EmitStorageAtomicIAdd32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
488 const IR::Value& offset, std::string_view value);
489void EmitStorageAtomicSMin32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
490 const IR::Value& offset, std::string_view value);
491void EmitStorageAtomicUMin32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
492 const IR::Value& offset, std::string_view value);
493void EmitStorageAtomicSMax32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
494 const IR::Value& offset, std::string_view value);
495void EmitStorageAtomicUMax32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
496 const IR::Value& offset, std::string_view value);
497void EmitStorageAtomicAnd32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
498 const IR::Value& offset, std::string_view value);
499void EmitStorageAtomicOr32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
500 const IR::Value& offset, std::string_view value);
501void EmitStorageAtomicXor32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
502 const IR::Value& offset, std::string_view value);
503void EmitStorageAtomicExchange32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
504 const IR::Value& offset, std::string_view value);
485void EmitStorageAtomicAddF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 505void EmitStorageAtomicAddF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
486 const IR::Value& offset, std::string_view value); 506 const IR::Value& offset, std::string_view value);
487void EmitStorageAtomicAddF16x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, 507void EmitStorageAtomicAddF16x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
@@ -518,6 +538,17 @@ void EmitGlobalAtomicAnd64(EmitContext& ctx);
518void EmitGlobalAtomicOr64(EmitContext& ctx); 538void EmitGlobalAtomicOr64(EmitContext& ctx);
519void EmitGlobalAtomicXor64(EmitContext& ctx); 539void EmitGlobalAtomicXor64(EmitContext& ctx);
520void EmitGlobalAtomicExchange64(EmitContext& ctx); 540void EmitGlobalAtomicExchange64(EmitContext& ctx);
541void EmitGlobalAtomicIAdd32x2(EmitContext& ctx);
542void EmitGlobalAtomicSMin32x2(EmitContext& ctx);
543void EmitGlobalAtomicUMin32x2(EmitContext& ctx);
544void EmitGlobalAtomicSMax32x2(EmitContext& ctx);
545void EmitGlobalAtomicUMax32x2(EmitContext& ctx);
546void EmitGlobalAtomicInc32x2(EmitContext& ctx);
547void EmitGlobalAtomicDec32x2(EmitContext& ctx);
548void EmitGlobalAtomicAnd32x2(EmitContext& ctx);
549void EmitGlobalAtomicOr32x2(EmitContext& ctx);
550void EmitGlobalAtomicXor32x2(EmitContext& ctx);
551void EmitGlobalAtomicExchange32x2(EmitContext& ctx);
521void EmitGlobalAtomicAddF32(EmitContext& ctx); 552void EmitGlobalAtomicAddF32(EmitContext& ctx);
522void EmitGlobalAtomicAddF16x2(EmitContext& ctx); 553void EmitGlobalAtomicAddF16x2(EmitContext& ctx);
523void EmitGlobalAtomicAddF32x2(EmitContext& ctx); 554void EmitGlobalAtomicAddF32x2(EmitContext& ctx);
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp
index 46ba52a25..d3cbb14a9 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp
@@ -82,6 +82,17 @@ Id StorageAtomicU64(EmitContext& ctx, const IR::Value& binding, const IR::Value&
82 ctx.OpStore(pointer, ctx.OpBitcast(ctx.U32[2], result)); 82 ctx.OpStore(pointer, ctx.OpBitcast(ctx.U32[2], result));
83 return original_value; 83 return original_value;
84} 84}
85
86Id StorageAtomicU32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, Id value,
87 Id (Sirit::Module::*non_atomic_func)(Id, Id, Id)) {
88 LOG_WARNING(Shader_SPIRV, "Int64 atomics not supported, fallback to non-atomic");
89 const Id pointer{StoragePointer(ctx, ctx.storage_types.U32x2, &StorageDefinitions::U32x2,
90 binding, offset, sizeof(u32[2]))};
91 const Id original_value{ctx.OpLoad(ctx.U32[2], pointer)};
92 const Id result{(ctx.*non_atomic_func)(ctx.U32[2], value, original_value)};
93 ctx.OpStore(pointer, result);
94 return original_value;
95}
85} // Anonymous namespace 96} // Anonymous namespace
86 97
87Id EmitSharedAtomicIAdd32(EmitContext& ctx, Id offset, Id value) { 98Id EmitSharedAtomicIAdd32(EmitContext& ctx, Id offset, Id value) {
@@ -141,7 +152,7 @@ Id EmitSharedAtomicExchange64(EmitContext& ctx, Id offset, Id value) {
141 const auto [scope, semantics]{AtomicArgs(ctx)}; 152 const auto [scope, semantics]{AtomicArgs(ctx)};
142 return ctx.OpAtomicExchange(ctx.U64, pointer, scope, semantics, value); 153 return ctx.OpAtomicExchange(ctx.U64, pointer, scope, semantics, value);
143 } 154 }
144 LOG_ERROR(Shader_SPIRV, "Int64 atomics not supported, fallback to non-atomic"); 155 LOG_WARNING(Shader_SPIRV, "Int64 atomics not supported, fallback to non-atomic");
145 const Id pointer_1{SharedPointer(ctx, offset, 0)}; 156 const Id pointer_1{SharedPointer(ctx, offset, 0)};
146 const Id pointer_2{SharedPointer(ctx, offset, 1)}; 157 const Id pointer_2{SharedPointer(ctx, offset, 1)};
147 const Id value_1{ctx.OpLoad(ctx.U32[1], pointer_1)}; 158 const Id value_1{ctx.OpLoad(ctx.U32[1], pointer_1)};
@@ -152,6 +163,18 @@ Id EmitSharedAtomicExchange64(EmitContext& ctx, Id offset, Id value) {
152 return ctx.OpBitcast(ctx.U64, ctx.OpCompositeConstruct(ctx.U32[2], value_1, value_2)); 163 return ctx.OpBitcast(ctx.U64, ctx.OpCompositeConstruct(ctx.U32[2], value_1, value_2));
153} 164}
154 165
166Id EmitSharedAtomicExchange32x2(EmitContext& ctx, Id offset, Id value) {
167 LOG_WARNING(Shader_SPIRV, "Int64 atomics not supported, fallback to non-atomic");
168 const Id pointer_1{SharedPointer(ctx, offset, 0)};
169 const Id pointer_2{SharedPointer(ctx, offset, 1)};
170 const Id value_1{ctx.OpLoad(ctx.U32[1], pointer_1)};
171 const Id value_2{ctx.OpLoad(ctx.U32[1], pointer_2)};
172 const Id new_vector{ctx.OpBitcast(ctx.U32[2], value)};
173 ctx.OpStore(pointer_1, ctx.OpCompositeExtract(ctx.U32[1], new_vector, 0U));
174 ctx.OpStore(pointer_2, ctx.OpCompositeExtract(ctx.U32[1], new_vector, 1U));
175 return ctx.OpCompositeConstruct(ctx.U32[2], value_1, value_2);
176}
177
155Id EmitStorageAtomicIAdd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, 178Id EmitStorageAtomicIAdd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
156 Id value) { 179 Id value) {
157 return StorageAtomicU32(ctx, binding, offset, value, &Sirit::Module::OpAtomicIAdd); 180 return StorageAtomicU32(ctx, binding, offset, value, &Sirit::Module::OpAtomicIAdd);
@@ -275,6 +298,56 @@ Id EmitStorageAtomicExchange64(EmitContext& ctx, const IR::Value& binding, const
275 return original; 298 return original;
276} 299}
277 300
301Id EmitStorageAtomicIAdd32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
302 Id value) {
303 return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpIAdd);
304}
305
306Id EmitStorageAtomicSMin32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
307 Id value) {
308 return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpSMin);
309}
310
311Id EmitStorageAtomicUMin32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
312 Id value) {
313 return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpUMin);
314}
315
316Id EmitStorageAtomicSMax32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
317 Id value) {
318 return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpSMax);
319}
320
321Id EmitStorageAtomicUMax32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
322 Id value) {
323 return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpUMax);
324}
325
326Id EmitStorageAtomicAnd32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
327 Id value) {
328 return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpBitwiseAnd);
329}
330
331Id EmitStorageAtomicOr32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
332 Id value) {
333 return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpBitwiseOr);
334}
335
336Id EmitStorageAtomicXor32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
337 Id value) {
338 return StorageAtomicU32x2(ctx, binding, offset, value, &Sirit::Module::OpBitwiseXor);
339}
340
341Id EmitStorageAtomicExchange32x2(EmitContext& ctx, const IR::Value& binding,
342 const IR::Value& offset, Id value) {
343 LOG_WARNING(Shader_SPIRV, "Int64 atomics not supported, fallback to non-atomic");
344 const Id pointer{StoragePointer(ctx, ctx.storage_types.U32x2, &StorageDefinitions::U32x2,
345 binding, offset, sizeof(u32[2]))};
346 const Id original{ctx.OpLoad(ctx.U32[2], pointer)};
347 ctx.OpStore(pointer, value);
348 return original;
349}
350
278Id EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, 351Id EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
279 Id value) { 352 Id value) {
280 const Id ssbo{ctx.ssbos[binding.U32()].U32}; 353 const Id ssbo{ctx.ssbos[binding.U32()].U32};
@@ -418,6 +491,50 @@ Id EmitGlobalAtomicExchange64(EmitContext&) {
418 throw NotImplementedException("SPIR-V Instruction"); 491 throw NotImplementedException("SPIR-V Instruction");
419} 492}
420 493
494Id EmitGlobalAtomicIAdd32x2(EmitContext&) {
495 throw NotImplementedException("SPIR-V Instruction");
496}
497
498Id EmitGlobalAtomicSMin32x2(EmitContext&) {
499 throw NotImplementedException("SPIR-V Instruction");
500}
501
502Id EmitGlobalAtomicUMin32x2(EmitContext&) {
503 throw NotImplementedException("SPIR-V Instruction");
504}
505
506Id EmitGlobalAtomicSMax32x2(EmitContext&) {
507 throw NotImplementedException("SPIR-V Instruction");
508}
509
510Id EmitGlobalAtomicUMax32x2(EmitContext&) {
511 throw NotImplementedException("SPIR-V Instruction");
512}
513
514Id EmitGlobalAtomicInc32x2(EmitContext&) {
515 throw NotImplementedException("SPIR-V Instruction");
516}
517
518Id EmitGlobalAtomicDec32x2(EmitContext&) {
519 throw NotImplementedException("SPIR-V Instruction");
520}
521
522Id EmitGlobalAtomicAnd32x2(EmitContext&) {
523 throw NotImplementedException("SPIR-V Instruction");
524}
525
526Id EmitGlobalAtomicOr32x2(EmitContext&) {
527 throw NotImplementedException("SPIR-V Instruction");
528}
529
530Id EmitGlobalAtomicXor32x2(EmitContext&) {
531 throw NotImplementedException("SPIR-V Instruction");
532}
533
534Id EmitGlobalAtomicExchange32x2(EmitContext&) {
535 throw NotImplementedException("SPIR-V Instruction");
536}
537
421Id EmitGlobalAtomicAddF32(EmitContext&) { 538Id EmitGlobalAtomicAddF32(EmitContext&) {
422 throw NotImplementedException("SPIR-V Instruction"); 539 throw NotImplementedException("SPIR-V Instruction");
423} 540}
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h
index 887112deb..f263b41b0 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h
@@ -335,6 +335,7 @@ Id EmitSharedAtomicOr32(EmitContext& ctx, Id pointer_offset, Id value);
335Id EmitSharedAtomicXor32(EmitContext& ctx, Id pointer_offset, Id value); 335Id EmitSharedAtomicXor32(EmitContext& ctx, Id pointer_offset, Id value);
336Id EmitSharedAtomicExchange32(EmitContext& ctx, Id pointer_offset, Id value); 336Id EmitSharedAtomicExchange32(EmitContext& ctx, Id pointer_offset, Id value);
337Id EmitSharedAtomicExchange64(EmitContext& ctx, Id pointer_offset, Id value); 337Id EmitSharedAtomicExchange64(EmitContext& ctx, Id pointer_offset, Id value);
338Id EmitSharedAtomicExchange32x2(EmitContext& ctx, Id pointer_offset, Id value);
338Id EmitStorageAtomicIAdd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, 339Id EmitStorageAtomicIAdd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
339 Id value); 340 Id value);
340Id EmitStorageAtomicSMin32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, 341Id EmitStorageAtomicSMin32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
@@ -375,6 +376,24 @@ Id EmitStorageAtomicXor64(EmitContext& ctx, const IR::Value& binding, const IR::
375 Id value); 376 Id value);
376Id EmitStorageAtomicExchange64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, 377Id EmitStorageAtomicExchange64(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
377 Id value); 378 Id value);
379Id EmitStorageAtomicIAdd32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
380 Id value);
381Id EmitStorageAtomicSMin32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
382 Id value);
383Id EmitStorageAtomicUMin32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
384 Id value);
385Id EmitStorageAtomicSMax32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
386 Id value);
387Id EmitStorageAtomicUMax32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
388 Id value);
389Id EmitStorageAtomicAnd32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
390 Id value);
391Id EmitStorageAtomicOr32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
392 Id value);
393Id EmitStorageAtomicXor32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
394 Id value);
395Id EmitStorageAtomicExchange32x2(EmitContext& ctx, const IR::Value& binding,
396 const IR::Value& offset, Id value);
378Id EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, 397Id EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
379 Id value); 398 Id value);
380Id EmitStorageAtomicAddF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, 399Id EmitStorageAtomicAddF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
@@ -411,6 +430,17 @@ Id EmitGlobalAtomicAnd64(EmitContext& ctx);
411Id EmitGlobalAtomicOr64(EmitContext& ctx); 430Id EmitGlobalAtomicOr64(EmitContext& ctx);
412Id EmitGlobalAtomicXor64(EmitContext& ctx); 431Id EmitGlobalAtomicXor64(EmitContext& ctx);
413Id EmitGlobalAtomicExchange64(EmitContext& ctx); 432Id EmitGlobalAtomicExchange64(EmitContext& ctx);
433Id EmitGlobalAtomicIAdd32x2(EmitContext& ctx);
434Id EmitGlobalAtomicSMin32x2(EmitContext& ctx);
435Id EmitGlobalAtomicUMin32x2(EmitContext& ctx);
436Id EmitGlobalAtomicSMax32x2(EmitContext& ctx);
437Id EmitGlobalAtomicUMax32x2(EmitContext& ctx);
438Id EmitGlobalAtomicInc32x2(EmitContext& ctx);
439Id EmitGlobalAtomicDec32x2(EmitContext& ctx);
440Id EmitGlobalAtomicAnd32x2(EmitContext& ctx);
441Id EmitGlobalAtomicOr32x2(EmitContext& ctx);
442Id EmitGlobalAtomicXor32x2(EmitContext& ctx);
443Id EmitGlobalAtomicExchange32x2(EmitContext& ctx);
414Id EmitGlobalAtomicAddF32(EmitContext& ctx); 444Id EmitGlobalAtomicAddF32(EmitContext& ctx);
415Id EmitGlobalAtomicAddF16x2(EmitContext& ctx); 445Id EmitGlobalAtomicAddF16x2(EmitContext& ctx);
416Id EmitGlobalAtomicAddF32x2(EmitContext& ctx); 446Id EmitGlobalAtomicAddF32x2(EmitContext& ctx);
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp
index 97e2bf6af..631446cf7 100644
--- a/src/shader_recompiler/frontend/ir/microinstruction.cpp
+++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp
@@ -118,6 +118,7 @@ bool Inst::MayHaveSideEffects() const noexcept {
118 case Opcode::SharedAtomicXor32: 118 case Opcode::SharedAtomicXor32:
119 case Opcode::SharedAtomicExchange32: 119 case Opcode::SharedAtomicExchange32:
120 case Opcode::SharedAtomicExchange64: 120 case Opcode::SharedAtomicExchange64:
121 case Opcode::SharedAtomicExchange32x2:
121 case Opcode::GlobalAtomicIAdd32: 122 case Opcode::GlobalAtomicIAdd32:
122 case Opcode::GlobalAtomicSMin32: 123 case Opcode::GlobalAtomicSMin32:
123 case Opcode::GlobalAtomicUMin32: 124 case Opcode::GlobalAtomicUMin32:
@@ -138,6 +139,15 @@ bool Inst::MayHaveSideEffects() const noexcept {
138 case Opcode::GlobalAtomicOr64: 139 case Opcode::GlobalAtomicOr64:
139 case Opcode::GlobalAtomicXor64: 140 case Opcode::GlobalAtomicXor64:
140 case Opcode::GlobalAtomicExchange64: 141 case Opcode::GlobalAtomicExchange64:
142 case Opcode::GlobalAtomicIAdd32x2:
143 case Opcode::GlobalAtomicSMin32x2:
144 case Opcode::GlobalAtomicUMin32x2:
145 case Opcode::GlobalAtomicSMax32x2:
146 case Opcode::GlobalAtomicUMax32x2:
147 case Opcode::GlobalAtomicAnd32x2:
148 case Opcode::GlobalAtomicOr32x2:
149 case Opcode::GlobalAtomicXor32x2:
150 case Opcode::GlobalAtomicExchange32x2:
141 case Opcode::GlobalAtomicAddF32: 151 case Opcode::GlobalAtomicAddF32:
142 case Opcode::GlobalAtomicAddF16x2: 152 case Opcode::GlobalAtomicAddF16x2:
143 case Opcode::GlobalAtomicAddF32x2: 153 case Opcode::GlobalAtomicAddF32x2:
@@ -165,6 +175,15 @@ bool Inst::MayHaveSideEffects() const noexcept {
165 case Opcode::StorageAtomicOr64: 175 case Opcode::StorageAtomicOr64:
166 case Opcode::StorageAtomicXor64: 176 case Opcode::StorageAtomicXor64:
167 case Opcode::StorageAtomicExchange64: 177 case Opcode::StorageAtomicExchange64:
178 case Opcode::StorageAtomicIAdd32x2:
179 case Opcode::StorageAtomicSMin32x2:
180 case Opcode::StorageAtomicUMin32x2:
181 case Opcode::StorageAtomicSMax32x2:
182 case Opcode::StorageAtomicUMax32x2:
183 case Opcode::StorageAtomicAnd32x2:
184 case Opcode::StorageAtomicOr32x2:
185 case Opcode::StorageAtomicXor32x2:
186 case Opcode::StorageAtomicExchange32x2:
168 case Opcode::StorageAtomicAddF32: 187 case Opcode::StorageAtomicAddF32:
169 case Opcode::StorageAtomicAddF16x2: 188 case Opcode::StorageAtomicAddF16x2:
170 case Opcode::StorageAtomicAddF32x2: 189 case Opcode::StorageAtomicAddF32x2:
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc
index b94ce7406..efb6bfac3 100644
--- a/src/shader_recompiler/frontend/ir/opcodes.inc
+++ b/src/shader_recompiler/frontend/ir/opcodes.inc
@@ -341,6 +341,7 @@ OPCODE(SharedAtomicOr32, U32, U32,
341OPCODE(SharedAtomicXor32, U32, U32, U32, ) 341OPCODE(SharedAtomicXor32, U32, U32, U32, )
342OPCODE(SharedAtomicExchange32, U32, U32, U32, ) 342OPCODE(SharedAtomicExchange32, U32, U32, U32, )
343OPCODE(SharedAtomicExchange64, U64, U32, U64, ) 343OPCODE(SharedAtomicExchange64, U64, U32, U64, )
344OPCODE(SharedAtomicExchange32x2, U32x2, U32, U32x2, )
344 345
345OPCODE(GlobalAtomicIAdd32, U32, U64, U32, ) 346OPCODE(GlobalAtomicIAdd32, U32, U64, U32, )
346OPCODE(GlobalAtomicSMin32, U32, U64, U32, ) 347OPCODE(GlobalAtomicSMin32, U32, U64, U32, )
@@ -362,6 +363,15 @@ OPCODE(GlobalAtomicAnd64, U64, U64,
362OPCODE(GlobalAtomicOr64, U64, U64, U64, ) 363OPCODE(GlobalAtomicOr64, U64, U64, U64, )
363OPCODE(GlobalAtomicXor64, U64, U64, U64, ) 364OPCODE(GlobalAtomicXor64, U64, U64, U64, )
364OPCODE(GlobalAtomicExchange64, U64, U64, U64, ) 365OPCODE(GlobalAtomicExchange64, U64, U64, U64, )
366OPCODE(GlobalAtomicIAdd32x2, U32x2, U32x2, U32x2, )
367OPCODE(GlobalAtomicSMin32x2, U32x2, U32x2, U32x2, )
368OPCODE(GlobalAtomicUMin32x2, U32x2, U32x2, U32x2, )
369OPCODE(GlobalAtomicSMax32x2, U32x2, U32x2, U32x2, )
370OPCODE(GlobalAtomicUMax32x2, U32x2, U32x2, U32x2, )
371OPCODE(GlobalAtomicAnd32x2, U32x2, U32x2, U32x2, )
372OPCODE(GlobalAtomicOr32x2, U32x2, U32x2, U32x2, )
373OPCODE(GlobalAtomicXor32x2, U32x2, U32x2, U32x2, )
374OPCODE(GlobalAtomicExchange32x2, U32x2, U32x2, U32x2, )
365OPCODE(GlobalAtomicAddF32, F32, U64, F32, ) 375OPCODE(GlobalAtomicAddF32, F32, U64, F32, )
366OPCODE(GlobalAtomicAddF16x2, U32, U64, F16x2, ) 376OPCODE(GlobalAtomicAddF16x2, U32, U64, F16x2, )
367OPCODE(GlobalAtomicAddF32x2, U32, U64, F32x2, ) 377OPCODE(GlobalAtomicAddF32x2, U32, U64, F32x2, )
@@ -390,6 +400,15 @@ OPCODE(StorageAtomicAnd64, U64, U32,
390OPCODE(StorageAtomicOr64, U64, U32, U32, U64, ) 400OPCODE(StorageAtomicOr64, U64, U32, U32, U64, )
391OPCODE(StorageAtomicXor64, U64, U32, U32, U64, ) 401OPCODE(StorageAtomicXor64, U64, U32, U32, U64, )
392OPCODE(StorageAtomicExchange64, U64, U32, U32, U64, ) 402OPCODE(StorageAtomicExchange64, U64, U32, U32, U64, )
403OPCODE(StorageAtomicIAdd32x2, U32x2, U32, U32, U32x2, )
404OPCODE(StorageAtomicSMin32x2, U32x2, U32, U32, U32x2, )
405OPCODE(StorageAtomicUMin32x2, U32x2, U32, U32, U32x2, )
406OPCODE(StorageAtomicSMax32x2, U32x2, U32, U32, U32x2, )
407OPCODE(StorageAtomicUMax32x2, U32x2, U32, U32, U32x2, )
408OPCODE(StorageAtomicAnd32x2, U32x2, U32, U32, U32x2, )
409OPCODE(StorageAtomicOr32x2, U32x2, U32, U32, U32x2, )
410OPCODE(StorageAtomicXor32x2, U32x2, U32, U32, U32x2, )
411OPCODE(StorageAtomicExchange32x2, U32x2, U32, U32, U32x2, )
393OPCODE(StorageAtomicAddF32, F32, U32, U32, F32, ) 412OPCODE(StorageAtomicAddF32, F32, U32, U32, F32, )
394OPCODE(StorageAtomicAddF16x2, U32, U32, U32, F16x2, ) 413OPCODE(StorageAtomicAddF16x2, U32, U32, U32, F16x2, )
395OPCODE(StorageAtomicAddF32x2, U32, U32, U32, F32x2, ) 414OPCODE(StorageAtomicAddF32x2, U32, U32, U32, F32x2, )
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 b6a20f904..bfd2ae650 100644
--- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
+++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp
@@ -360,6 +360,15 @@ void VisitUsages(Info& info, IR::Inst& inst) {
360 case IR::Opcode::GlobalAtomicOr64: 360 case IR::Opcode::GlobalAtomicOr64:
361 case IR::Opcode::GlobalAtomicXor64: 361 case IR::Opcode::GlobalAtomicXor64:
362 case IR::Opcode::GlobalAtomicExchange64: 362 case IR::Opcode::GlobalAtomicExchange64:
363 case IR::Opcode::GlobalAtomicIAdd32x2:
364 case IR::Opcode::GlobalAtomicSMin32x2:
365 case IR::Opcode::GlobalAtomicUMin32x2:
366 case IR::Opcode::GlobalAtomicSMax32x2:
367 case IR::Opcode::GlobalAtomicUMax32x2:
368 case IR::Opcode::GlobalAtomicAnd32x2:
369 case IR::Opcode::GlobalAtomicOr32x2:
370 case IR::Opcode::GlobalAtomicXor32x2:
371 case IR::Opcode::GlobalAtomicExchange32x2:
363 case IR::Opcode::GlobalAtomicAddF32: 372 case IR::Opcode::GlobalAtomicAddF32:
364 case IR::Opcode::GlobalAtomicAddF16x2: 373 case IR::Opcode::GlobalAtomicAddF16x2:
365 case IR::Opcode::GlobalAtomicAddF32x2: 374 case IR::Opcode::GlobalAtomicAddF32x2:
@@ -597,6 +606,15 @@ void VisitUsages(Info& info, IR::Inst& inst) {
597 break; 606 break;
598 case IR::Opcode::LoadStorage64: 607 case IR::Opcode::LoadStorage64:
599 case IR::Opcode::WriteStorage64: 608 case IR::Opcode::WriteStorage64:
609 case IR::Opcode::StorageAtomicIAdd32x2:
610 case IR::Opcode::StorageAtomicSMin32x2:
611 case IR::Opcode::StorageAtomicUMin32x2:
612 case IR::Opcode::StorageAtomicSMax32x2:
613 case IR::Opcode::StorageAtomicUMax32x2:
614 case IR::Opcode::StorageAtomicAnd32x2:
615 case IR::Opcode::StorageAtomicOr32x2:
616 case IR::Opcode::StorageAtomicXor32x2:
617 case IR::Opcode::StorageAtomicExchange32x2:
600 info.used_storage_buffer_types |= IR::Type::U32x2; 618 info.used_storage_buffer_types |= IR::Type::U32x2;
601 break; 619 break;
602 case IR::Opcode::LoadStorage128: 620 case IR::Opcode::LoadStorage128:
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 4197b0095..38592afd0 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
@@ -92,6 +92,15 @@ bool IsGlobalMemory(const IR::Inst& inst) {
92 case IR::Opcode::GlobalAtomicOr64: 92 case IR::Opcode::GlobalAtomicOr64:
93 case IR::Opcode::GlobalAtomicXor64: 93 case IR::Opcode::GlobalAtomicXor64:
94 case IR::Opcode::GlobalAtomicExchange64: 94 case IR::Opcode::GlobalAtomicExchange64:
95 case IR::Opcode::GlobalAtomicIAdd32x2:
96 case IR::Opcode::GlobalAtomicSMin32x2:
97 case IR::Opcode::GlobalAtomicUMin32x2:
98 case IR::Opcode::GlobalAtomicSMax32x2:
99 case IR::Opcode::GlobalAtomicUMax32x2:
100 case IR::Opcode::GlobalAtomicAnd32x2:
101 case IR::Opcode::GlobalAtomicOr32x2:
102 case IR::Opcode::GlobalAtomicXor32x2:
103 case IR::Opcode::GlobalAtomicExchange32x2:
95 case IR::Opcode::GlobalAtomicAddF32: 104 case IR::Opcode::GlobalAtomicAddF32:
96 case IR::Opcode::GlobalAtomicAddF16x2: 105 case IR::Opcode::GlobalAtomicAddF16x2:
97 case IR::Opcode::GlobalAtomicAddF32x2: 106 case IR::Opcode::GlobalAtomicAddF32x2:
@@ -135,6 +144,15 @@ bool IsGlobalMemoryWrite(const IR::Inst& inst) {
135 case IR::Opcode::GlobalAtomicOr64: 144 case IR::Opcode::GlobalAtomicOr64:
136 case IR::Opcode::GlobalAtomicXor64: 145 case IR::Opcode::GlobalAtomicXor64:
137 case IR::Opcode::GlobalAtomicExchange64: 146 case IR::Opcode::GlobalAtomicExchange64:
147 case IR::Opcode::GlobalAtomicIAdd32x2:
148 case IR::Opcode::GlobalAtomicSMin32x2:
149 case IR::Opcode::GlobalAtomicUMin32x2:
150 case IR::Opcode::GlobalAtomicSMax32x2:
151 case IR::Opcode::GlobalAtomicUMax32x2:
152 case IR::Opcode::GlobalAtomicAnd32x2:
153 case IR::Opcode::GlobalAtomicOr32x2:
154 case IR::Opcode::GlobalAtomicXor32x2:
155 case IR::Opcode::GlobalAtomicExchange32x2:
138 case IR::Opcode::GlobalAtomicAddF32: 156 case IR::Opcode::GlobalAtomicAddF32:
139 case IR::Opcode::GlobalAtomicAddF16x2: 157 case IR::Opcode::GlobalAtomicAddF16x2:
140 case IR::Opcode::GlobalAtomicAddF32x2: 158 case IR::Opcode::GlobalAtomicAddF32x2:
@@ -199,6 +217,8 @@ IR::Opcode GlobalToStorage(IR::Opcode opcode) {
199 return IR::Opcode::StorageAtomicOr32; 217 return IR::Opcode::StorageAtomicOr32;
200 case IR::Opcode::GlobalAtomicXor32: 218 case IR::Opcode::GlobalAtomicXor32:
201 return IR::Opcode::StorageAtomicXor32; 219 return IR::Opcode::StorageAtomicXor32;
220 case IR::Opcode::GlobalAtomicExchange32:
221 return IR::Opcode::StorageAtomicExchange32;
202 case IR::Opcode::GlobalAtomicIAdd64: 222 case IR::Opcode::GlobalAtomicIAdd64:
203 return IR::Opcode::StorageAtomicIAdd64; 223 return IR::Opcode::StorageAtomicIAdd64;
204 case IR::Opcode::GlobalAtomicSMin64: 224 case IR::Opcode::GlobalAtomicSMin64:
@@ -215,10 +235,26 @@ IR::Opcode GlobalToStorage(IR::Opcode opcode) {
215 return IR::Opcode::StorageAtomicOr64; 235 return IR::Opcode::StorageAtomicOr64;
216 case IR::Opcode::GlobalAtomicXor64: 236 case IR::Opcode::GlobalAtomicXor64:
217 return IR::Opcode::StorageAtomicXor64; 237 return IR::Opcode::StorageAtomicXor64;
218 case IR::Opcode::GlobalAtomicExchange32:
219 return IR::Opcode::StorageAtomicExchange32;
220 case IR::Opcode::GlobalAtomicExchange64: 238 case IR::Opcode::GlobalAtomicExchange64:
221 return IR::Opcode::StorageAtomicExchange64; 239 return IR::Opcode::StorageAtomicExchange64;
240 case IR::Opcode::GlobalAtomicIAdd32x2:
241 return IR::Opcode::StorageAtomicIAdd32x2;
242 case IR::Opcode::GlobalAtomicSMin32x2:
243 return IR::Opcode::StorageAtomicSMin32x2;
244 case IR::Opcode::GlobalAtomicUMin32x2:
245 return IR::Opcode::StorageAtomicUMin32x2;
246 case IR::Opcode::GlobalAtomicSMax32x2:
247 return IR::Opcode::StorageAtomicSMax32x2;
248 case IR::Opcode::GlobalAtomicUMax32x2:
249 return IR::Opcode::StorageAtomicUMax32x2;
250 case IR::Opcode::GlobalAtomicAnd32x2:
251 return IR::Opcode::StorageAtomicAnd32x2;
252 case IR::Opcode::GlobalAtomicOr32x2:
253 return IR::Opcode::StorageAtomicOr32x2;
254 case IR::Opcode::GlobalAtomicXor32x2:
255 return IR::Opcode::StorageAtomicXor32x2;
256 case IR::Opcode::GlobalAtomicExchange32x2:
257 return IR::Opcode::StorageAtomicExchange32x2;
222 case IR::Opcode::GlobalAtomicAddF32: 258 case IR::Opcode::GlobalAtomicAddF32:
223 return IR::Opcode::StorageAtomicAddF32; 259 return IR::Opcode::StorageAtomicAddF32;
224 case IR::Opcode::GlobalAtomicAddF16x2: 260 case IR::Opcode::GlobalAtomicAddF16x2:
@@ -454,6 +490,15 @@ void Replace(IR::Block& block, IR::Inst& inst, const IR::U32& storage_index,
454 case IR::Opcode::GlobalAtomicOr64: 490 case IR::Opcode::GlobalAtomicOr64:
455 case IR::Opcode::GlobalAtomicXor64: 491 case IR::Opcode::GlobalAtomicXor64:
456 case IR::Opcode::GlobalAtomicExchange64: 492 case IR::Opcode::GlobalAtomicExchange64:
493 case IR::Opcode::GlobalAtomicIAdd32x2:
494 case IR::Opcode::GlobalAtomicSMin32x2:
495 case IR::Opcode::GlobalAtomicUMin32x2:
496 case IR::Opcode::GlobalAtomicSMax32x2:
497 case IR::Opcode::GlobalAtomicUMax32x2:
498 case IR::Opcode::GlobalAtomicAnd32x2:
499 case IR::Opcode::GlobalAtomicOr32x2:
500 case IR::Opcode::GlobalAtomicXor32x2:
501 case IR::Opcode::GlobalAtomicExchange32x2:
457 case IR::Opcode::GlobalAtomicAddF32: 502 case IR::Opcode::GlobalAtomicAddF32:
458 case IR::Opcode::GlobalAtomicAddF16x2: 503 case IR::Opcode::GlobalAtomicAddF16x2:
459 case IR::Opcode::GlobalAtomicAddF32x2: 504 case IR::Opcode::GlobalAtomicAddF32x2:
diff --git a/src/shader_recompiler/ir_opt/lower_int64_to_int32.cpp b/src/shader_recompiler/ir_opt/lower_int64_to_int32.cpp
index e80d3d1d9..c2654cd9b 100644
--- a/src/shader_recompiler/ir_opt/lower_int64_to_int32.cpp
+++ b/src/shader_recompiler/ir_opt/lower_int64_to_int32.cpp
@@ -199,6 +199,26 @@ void Lower(IR::Block& block, IR::Inst& inst) {
199 return ShiftRightLogical64To32(block, inst); 199 return ShiftRightLogical64To32(block, inst);
200 case IR::Opcode::ShiftRightArithmetic64: 200 case IR::Opcode::ShiftRightArithmetic64:
201 return ShiftRightArithmetic64To32(block, inst); 201 return ShiftRightArithmetic64To32(block, inst);
202 case IR::Opcode::SharedAtomicExchange64:
203 return inst.ReplaceOpcode(IR::Opcode::SharedAtomicExchange32x2);
204 case IR::Opcode::GlobalAtomicIAdd64:
205 return inst.ReplaceOpcode(IR::Opcode::GlobalAtomicIAdd32x2);
206 case IR::Opcode::GlobalAtomicSMin64:
207 return inst.ReplaceOpcode(IR::Opcode::GlobalAtomicSMin32x2);
208 case IR::Opcode::GlobalAtomicUMin64:
209 return inst.ReplaceOpcode(IR::Opcode::GlobalAtomicUMin32x2);
210 case IR::Opcode::GlobalAtomicSMax64:
211 return inst.ReplaceOpcode(IR::Opcode::GlobalAtomicSMax32x2);
212 case IR::Opcode::GlobalAtomicUMax64:
213 return inst.ReplaceOpcode(IR::Opcode::GlobalAtomicUMax32x2);
214 case IR::Opcode::GlobalAtomicAnd64:
215 return inst.ReplaceOpcode(IR::Opcode::GlobalAtomicAnd32x2);
216 case IR::Opcode::GlobalAtomicOr64:
217 return inst.ReplaceOpcode(IR::Opcode::GlobalAtomicOr32x2);
218 case IR::Opcode::GlobalAtomicXor64:
219 return inst.ReplaceOpcode(IR::Opcode::GlobalAtomicXor32x2);
220 case IR::Opcode::GlobalAtomicExchange64:
221 return inst.ReplaceOpcode(IR::Opcode::GlobalAtomicExchange32x2);
202 default: 222 default:
203 break; 223 break;
204 } 224 }
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index 048dba4f3..fa26eb8b0 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -131,6 +131,8 @@ public:
131 131
132 void DownloadMemory(VAddr cpu_addr, u64 size); 132 void DownloadMemory(VAddr cpu_addr, u64 size);
133 133
134 bool InlineMemory(VAddr dest_address, size_t copy_size, std::span<u8> inlined_buffer);
135
134 void BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr, u32 size); 136 void BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr, u32 size);
135 137
136 void DisableGraphicsUniformBuffer(size_t stage, u32 index); 138 void DisableGraphicsUniformBuffer(size_t stage, u32 index);
@@ -808,6 +810,8 @@ void BufferCache<P>::CommitAsyncFlushesHigh() {
808 return; 810 return;
809 } 811 }
810 MICROPROFILE_SCOPE(GPU_DownloadMemory); 812 MICROPROFILE_SCOPE(GPU_DownloadMemory);
813 const bool is_accuracy_normal =
814 Settings::values.gpu_accuracy.GetValue() == Settings::GPUAccuracy::Normal;
811 815
812 boost::container::small_vector<std::pair<BufferCopy, BufferId>, 1> downloads; 816 boost::container::small_vector<std::pair<BufferCopy, BufferId>, 1> downloads;
813 u64 total_size_bytes = 0; 817 u64 total_size_bytes = 0;
@@ -819,6 +823,9 @@ void BufferCache<P>::CommitAsyncFlushesHigh() {
819 ForEachBufferInRange(cpu_addr, size, [&](BufferId buffer_id, Buffer& buffer) { 823 ForEachBufferInRange(cpu_addr, size, [&](BufferId buffer_id, Buffer& buffer) {
820 buffer.ForEachDownloadRangeAndClear( 824 buffer.ForEachDownloadRangeAndClear(
821 cpu_addr, size, [&](u64 range_offset, u64 range_size) { 825 cpu_addr, size, [&](u64 range_offset, u64 range_size) {
826 if (is_accuracy_normal) {
827 return;
828 }
822 const VAddr buffer_addr = buffer.CpuAddr(); 829 const VAddr buffer_addr = buffer.CpuAddr();
823 const auto add_download = [&](VAddr start, VAddr end) { 830 const auto add_download = [&](VAddr start, VAddr end) {
824 const u64 new_offset = start - buffer_addr; 831 const u64 new_offset = start - buffer_addr;
@@ -1417,10 +1424,8 @@ void BufferCache<P>::MarkWrittenBuffer(BufferId buffer_id, VAddr cpu_addr, u32 s
1417 const IntervalType base_interval{cpu_addr, cpu_addr + size}; 1424 const IntervalType base_interval{cpu_addr, cpu_addr + size};
1418 common_ranges.add(base_interval); 1425 common_ranges.add(base_interval);
1419 1426
1420 const bool is_accuracy_high =
1421 Settings::values.gpu_accuracy.GetValue() == Settings::GPUAccuracy::High;
1422 const bool is_async = Settings::values.use_asynchronous_gpu_emulation.GetValue(); 1427 const bool is_async = Settings::values.use_asynchronous_gpu_emulation.GetValue();
1423 if (!is_async && !is_accuracy_high) { 1428 if (!is_async) {
1424 return; 1429 return;
1425 } 1430 }
1426 uncommitted_ranges.add(base_interval); 1431 uncommitted_ranges.add(base_interval);
@@ -1644,6 +1649,42 @@ void BufferCache<P>::MappedUploadMemory(Buffer& buffer, u64 total_size_bytes,
1644} 1649}
1645 1650
1646template <class P> 1651template <class P>
1652bool BufferCache<P>::InlineMemory(VAddr dest_address, size_t copy_size,
1653 std::span<u8> inlined_buffer) {
1654 const bool is_dirty = IsRegionRegistered(dest_address, copy_size);
1655 if (!is_dirty) {
1656 return false;
1657 }
1658 if (!IsRegionGpuModified(dest_address, copy_size)) {
1659 return false;
1660 }
1661
1662 const IntervalType subtract_interval{dest_address, dest_address + copy_size};
1663 ClearDownload(subtract_interval);
1664 common_ranges.subtract(subtract_interval);
1665
1666 BufferId buffer_id = FindBuffer(dest_address, static_cast<u32>(copy_size));
1667 auto& buffer = slot_buffers[buffer_id];
1668 SynchronizeBuffer(buffer, dest_address, static_cast<u32>(copy_size));
1669
1670 if constexpr (USE_MEMORY_MAPS) {
1671 std::array copies{BufferCopy{
1672 .src_offset = 0,
1673 .dst_offset = buffer.Offset(dest_address),
1674 .size = copy_size,
1675 }};
1676 auto upload_staging = runtime.UploadStagingBuffer(copy_size);
1677 u8* const src_pointer = upload_staging.mapped_span.data();
1678 std::memcpy(src_pointer, inlined_buffer.data(), copy_size);
1679 runtime.CopyBuffer(buffer, upload_staging.buffer, copies);
1680 } else {
1681 buffer.ImmediateUpload(buffer.Offset(dest_address), inlined_buffer.first(copy_size));
1682 }
1683
1684 return true;
1685}
1686
1687template <class P>
1647void BufferCache<P>::DownloadBufferMemory(Buffer& buffer) { 1688void BufferCache<P>::DownloadBufferMemory(Buffer& buffer) {
1648 DownloadBufferMemory(buffer, buffer.CpuAddr(), buffer.SizeBytes()); 1689 DownloadBufferMemory(buffer, buffer.CpuAddr(), buffer.SizeBytes());
1649} 1690}
diff --git a/src/video_core/engines/engine_upload.cpp b/src/video_core/engines/engine_upload.cpp
index 71d7e1473..351b110fe 100644
--- a/src/video_core/engines/engine_upload.cpp
+++ b/src/video_core/engines/engine_upload.cpp
@@ -7,6 +7,7 @@
7#include "common/assert.h" 7#include "common/assert.h"
8#include "video_core/engines/engine_upload.h" 8#include "video_core/engines/engine_upload.h"
9#include "video_core/memory_manager.h" 9#include "video_core/memory_manager.h"
10#include "video_core/rasterizer_interface.h"
10#include "video_core/textures/decoders.h" 11#include "video_core/textures/decoders.h"
11 12
12namespace Tegra::Engines::Upload { 13namespace Tegra::Engines::Upload {
@@ -16,6 +17,10 @@ State::State(MemoryManager& memory_manager_, Registers& regs_)
16 17
17State::~State() = default; 18State::~State() = default;
18 19
20void State::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) {
21 rasterizer = rasterizer_;
22}
23
19void State::ProcessExec(const bool is_linear_) { 24void State::ProcessExec(const bool is_linear_) {
20 write_offset = 0; 25 write_offset = 0;
21 copy_size = regs.line_length_in * regs.line_count; 26 copy_size = regs.line_length_in * regs.line_count;
@@ -32,7 +37,7 @@ void State::ProcessData(const u32 data, const bool is_last_call) {
32 } 37 }
33 const GPUVAddr address{regs.dest.Address()}; 38 const GPUVAddr address{regs.dest.Address()};
34 if (is_linear) { 39 if (is_linear) {
35 memory_manager.WriteBlock(address, inner_buffer.data(), copy_size); 40 rasterizer->AccelerateInlineToMemory(address, copy_size, inner_buffer);
36 } else { 41 } else {
37 UNIMPLEMENTED_IF(regs.dest.z != 0); 42 UNIMPLEMENTED_IF(regs.dest.z != 0);
38 UNIMPLEMENTED_IF(regs.dest.depth != 1); 43 UNIMPLEMENTED_IF(regs.dest.depth != 1);
diff --git a/src/video_core/engines/engine_upload.h b/src/video_core/engines/engine_upload.h
index 1c7f1effa..c9c5ec8c3 100644
--- a/src/video_core/engines/engine_upload.h
+++ b/src/video_core/engines/engine_upload.h
@@ -12,6 +12,10 @@ namespace Tegra {
12class MemoryManager; 12class MemoryManager;
13} 13}
14 14
15namespace VideoCore {
16class RasterizerInterface;
17}
18
15namespace Tegra::Engines::Upload { 19namespace Tegra::Engines::Upload {
16 20
17struct Registers { 21struct Registers {
@@ -60,6 +64,9 @@ public:
60 void ProcessExec(bool is_linear_); 64 void ProcessExec(bool is_linear_);
61 void ProcessData(u32 data, bool is_last_call); 65 void ProcessData(u32 data, bool is_last_call);
62 66
67 /// Binds a rasterizer to this engine.
68 void BindRasterizer(VideoCore::RasterizerInterface* rasterizer);
69
63private: 70private:
64 u32 write_offset = 0; 71 u32 write_offset = 0;
65 u32 copy_size = 0; 72 u32 copy_size = 0;
@@ -68,6 +75,7 @@ private:
68 bool is_linear = false; 75 bool is_linear = false;
69 Registers& regs; 76 Registers& regs;
70 MemoryManager& memory_manager; 77 MemoryManager& memory_manager;
78 VideoCore::RasterizerInterface* rasterizer = nullptr;
71}; 79};
72 80
73} // namespace Tegra::Engines::Upload 81} // namespace Tegra::Engines::Upload
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp
index 492b4c5a3..5a1c12076 100644
--- a/src/video_core/engines/kepler_compute.cpp
+++ b/src/video_core/engines/kepler_compute.cpp
@@ -22,6 +22,7 @@ KeplerCompute::~KeplerCompute() = default;
22 22
23void KeplerCompute::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) { 23void KeplerCompute::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) {
24 rasterizer = rasterizer_; 24 rasterizer = rasterizer_;
25 upload_state.BindRasterizer(rasterizer);
25} 26}
26 27
27void KeplerCompute::CallMethod(u32 method, u32 method_argument, bool is_last_call) { 28void KeplerCompute::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
diff --git a/src/video_core/engines/kepler_memory.cpp b/src/video_core/engines/kepler_memory.cpp
index 560551157..8aed16caa 100644
--- a/src/video_core/engines/kepler_memory.cpp
+++ b/src/video_core/engines/kepler_memory.cpp
@@ -19,6 +19,10 @@ KeplerMemory::KeplerMemory(Core::System& system_, MemoryManager& memory_manager)
19 19
20KeplerMemory::~KeplerMemory() = default; 20KeplerMemory::~KeplerMemory() = default;
21 21
22void KeplerMemory::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) {
23 upload_state.BindRasterizer(rasterizer_);
24}
25
22void KeplerMemory::CallMethod(u32 method, u32 method_argument, bool is_last_call) { 26void KeplerMemory::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
23 ASSERT_MSG(method < Regs::NUM_REGS, 27 ASSERT_MSG(method < Regs::NUM_REGS,
24 "Invalid KeplerMemory register, increase the size of the Regs structure"); 28 "Invalid KeplerMemory register, increase the size of the Regs structure");
diff --git a/src/video_core/engines/kepler_memory.h b/src/video_core/engines/kepler_memory.h
index 0d8ea09a9..949e2fae1 100644
--- a/src/video_core/engines/kepler_memory.h
+++ b/src/video_core/engines/kepler_memory.h
@@ -22,6 +22,10 @@ namespace Tegra {
22class MemoryManager; 22class MemoryManager;
23} 23}
24 24
25namespace VideoCore {
26class RasterizerInterface;
27}
28
25namespace Tegra::Engines { 29namespace Tegra::Engines {
26 30
27/** 31/**
@@ -38,6 +42,9 @@ public:
38 explicit KeplerMemory(Core::System& system_, MemoryManager& memory_manager); 42 explicit KeplerMemory(Core::System& system_, MemoryManager& memory_manager);
39 ~KeplerMemory() override; 43 ~KeplerMemory() override;
40 44
45 /// Binds a rasterizer to this engine.
46 void BindRasterizer(VideoCore::RasterizerInterface* rasterizer);
47
41 /// Write the value to the register identified by method. 48 /// Write the value to the register identified by method.
42 void CallMethod(u32 method, u32 method_argument, bool is_last_call) override; 49 void CallMethod(u32 method, u32 method_argument, bool is_last_call) override;
43 50
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index c38ebd670..5d6d217bb 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -31,6 +31,7 @@ Maxwell3D::~Maxwell3D() = default;
31 31
32void Maxwell3D::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) { 32void Maxwell3D::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) {
33 rasterizer = rasterizer_; 33 rasterizer = rasterizer_;
34 upload_state.BindRasterizer(rasterizer_);
34} 35}
35 36
36void Maxwell3D::InitializeRegisterDefaults() { 37void Maxwell3D::InitializeRegisterDefaults() {
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index f22342dfb..dc9df6c8b 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -1557,7 +1557,8 @@ private:
1557 1557
1558 static constexpr u32 null_cb_data = 0xFFFFFFFF; 1558 static constexpr u32 null_cb_data = 0xFFFFFFFF;
1559 struct CBDataState { 1559 struct CBDataState {
1560 std::array<std::array<u32, 0x4000>, 16> buffer; 1560 static constexpr size_t inline_size = 0x4000;
1561 std::array<std::array<u32, inline_size>, 16> buffer;
1561 u32 current{null_cb_data}; 1562 u32 current{null_cb_data};
1562 u32 id{null_cb_data}; 1563 u32 id{null_cb_data};
1563 u32 start_pos{}; 1564 u32 start_pos{};
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 705765c99..ba9ba082f 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -59,6 +59,7 @@ struct GPU::Impl {
59 maxwell_3d->BindRasterizer(rasterizer); 59 maxwell_3d->BindRasterizer(rasterizer);
60 fermi_2d->BindRasterizer(rasterizer); 60 fermi_2d->BindRasterizer(rasterizer);
61 kepler_compute->BindRasterizer(rasterizer); 61 kepler_compute->BindRasterizer(rasterizer);
62 kepler_memory->BindRasterizer(rasterizer);
62 maxwell_dma->BindRasterizer(rasterizer); 63 maxwell_dma->BindRasterizer(rasterizer);
63 } 64 }
64 65
@@ -502,8 +503,13 @@ struct GPU::Impl {
502 case BufferMethods::SemaphoreAddressHigh: 503 case BufferMethods::SemaphoreAddressHigh:
503 case BufferMethods::SemaphoreAddressLow: 504 case BufferMethods::SemaphoreAddressLow:
504 case BufferMethods::SemaphoreSequence: 505 case BufferMethods::SemaphoreSequence:
506 break;
505 case BufferMethods::UnkCacheFlush: 507 case BufferMethods::UnkCacheFlush:
508 rasterizer->SyncGuestHost();
509 break;
506 case BufferMethods::WrcacheFlush: 510 case BufferMethods::WrcacheFlush:
511 rasterizer->SignalReference();
512 break;
507 case BufferMethods::FenceValue: 513 case BufferMethods::FenceValue:
508 break; 514 break;
509 case BufferMethods::RefCnt: 515 case BufferMethods::RefCnt:
@@ -513,7 +519,7 @@ struct GPU::Impl {
513 ProcessFenceActionMethod(); 519 ProcessFenceActionMethod();
514 break; 520 break;
515 case BufferMethods::WaitForInterrupt: 521 case BufferMethods::WaitForInterrupt:
516 ProcessWaitForInterruptMethod(); 522 rasterizer->WaitForIdle();
517 break; 523 break;
518 case BufferMethods::SemaphoreTrigger: { 524 case BufferMethods::SemaphoreTrigger: {
519 ProcessSemaphoreTriggerMethod(); 525 ProcessSemaphoreTriggerMethod();
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h
index 38d8d9d74..61bfe47c7 100644
--- a/src/video_core/memory_manager.h
+++ b/src/video_core/memory_manager.h
@@ -143,6 +143,8 @@ public:
143 [[nodiscard]] GPUVAddr Allocate(std::size_t size, std::size_t align); 143 [[nodiscard]] GPUVAddr Allocate(std::size_t size, std::size_t align);
144 void Unmap(GPUVAddr gpu_addr, std::size_t size); 144 void Unmap(GPUVAddr gpu_addr, std::size_t size);
145 145
146 void FlushRegion(GPUVAddr gpu_addr, size_t size) const;
147
146private: 148private:
147 [[nodiscard]] PageEntry GetPageEntry(GPUVAddr gpu_addr) const; 149 [[nodiscard]] PageEntry GetPageEntry(GPUVAddr gpu_addr) const;
148 void SetPageEntry(GPUVAddr gpu_addr, PageEntry page_entry, std::size_t size = page_size); 150 void SetPageEntry(GPUVAddr gpu_addr, PageEntry page_entry, std::size_t size = page_size);
@@ -153,8 +155,6 @@ private:
153 void TryLockPage(PageEntry page_entry, std::size_t size); 155 void TryLockPage(PageEntry page_entry, std::size_t size);
154 void TryUnlockPage(PageEntry page_entry, std::size_t size); 156 void TryUnlockPage(PageEntry page_entry, std::size_t size);
155 157
156 void FlushRegion(GPUVAddr gpu_addr, size_t size) const;
157
158 void ReadBlockImpl(GPUVAddr gpu_src_addr, void* dest_buffer, std::size_t size, 158 void ReadBlockImpl(GPUVAddr gpu_src_addr, void* dest_buffer, std::size_t size,
159 bool is_safe) const; 159 bool is_safe) const;
160 void WriteBlockImpl(GPUVAddr gpu_dest_addr, const void* src_buffer, std::size_t size, 160 void WriteBlockImpl(GPUVAddr gpu_dest_addr, const void* src_buffer, std::size_t size,
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h
index b094fc064..1f1f12291 100644
--- a/src/video_core/rasterizer_interface.h
+++ b/src/video_core/rasterizer_interface.h
@@ -123,6 +123,9 @@ public:
123 123
124 [[nodiscard]] virtual Tegra::Engines::AccelerateDMAInterface& AccessAccelerateDMA() = 0; 124 [[nodiscard]] virtual Tegra::Engines::AccelerateDMAInterface& AccessAccelerateDMA() = 0;
125 125
126 virtual void AccelerateInlineToMemory(GPUVAddr address, size_t copy_size,
127 std::span<u8> memory) = 0;
128
126 /// Attempt to use a faster method to display the framebuffer to screen 129 /// Attempt to use a faster method to display the framebuffer to screen
127 [[nodiscard]] virtual bool AccelerateDisplay(const Tegra::FramebufferConfig& config, 130 [[nodiscard]] virtual bool AccelerateDisplay(const Tegra::FramebufferConfig& config,
128 VAddr framebuffer_addr, u32 pixel_stride) { 131 VAddr framebuffer_addr, u32 pixel_stride) {
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 9b516c64f..142412a8e 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -484,6 +484,28 @@ Tegra::Engines::AccelerateDMAInterface& RasterizerOpenGL::AccessAccelerateDMA()
484 return accelerate_dma; 484 return accelerate_dma;
485} 485}
486 486
487void RasterizerOpenGL::AccelerateInlineToMemory(GPUVAddr address, size_t copy_size,
488 std::span<u8> memory) {
489 auto cpu_addr = gpu_memory.GpuToCpuAddress(address);
490 if (!cpu_addr) [[unlikely]] {
491 gpu_memory.WriteBlock(address, memory.data(), copy_size);
492 return;
493 }
494 gpu_memory.WriteBlockUnsafe(address, memory.data(), copy_size);
495 {
496 std::unique_lock<std::mutex> lock{buffer_cache.mutex};
497 if (!buffer_cache.InlineMemory(*cpu_addr, copy_size, memory)) {
498 buffer_cache.WriteMemory(*cpu_addr, copy_size);
499 }
500 }
501 {
502 std::scoped_lock lock_texture{texture_cache.mutex};
503 texture_cache.WriteMemory(*cpu_addr, copy_size);
504 }
505 shader_cache.InvalidateRegion(*cpu_addr, copy_size);
506 query_cache.InvalidateRegion(*cpu_addr, copy_size);
507}
508
487bool RasterizerOpenGL::AccelerateDisplay(const Tegra::FramebufferConfig& config, 509bool RasterizerOpenGL::AccelerateDisplay(const Tegra::FramebufferConfig& config,
488 VAddr framebuffer_addr, u32 pixel_stride) { 510 VAddr framebuffer_addr, u32 pixel_stride) {
489 if (framebuffer_addr == 0) { 511 if (framebuffer_addr == 0) {
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index d0397b745..98f6fd342 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -106,6 +106,8 @@ public:
106 const Tegra::Engines::Fermi2D::Surface& dst, 106 const Tegra::Engines::Fermi2D::Surface& dst,
107 const Tegra::Engines::Fermi2D::Config& copy_config) override; 107 const Tegra::Engines::Fermi2D::Config& copy_config) override;
108 Tegra::Engines::AccelerateDMAInterface& AccessAccelerateDMA() override; 108 Tegra::Engines::AccelerateDMAInterface& AccessAccelerateDMA() override;
109 void AccelerateInlineToMemory(GPUVAddr address, size_t copy_size,
110 std::span<u8> memory) override;
109 bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr, 111 bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr,
110 u32 pixel_stride) override; 112 u32 pixel_stride) override;
111 void LoadDiskResources(u64 title_id, std::stop_token stop_loading, 113 void LoadDiskResources(u64 title_id, std::stop_token stop_loading,
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index fd334a146..2227d9197 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -548,6 +548,28 @@ Tegra::Engines::AccelerateDMAInterface& RasterizerVulkan::AccessAccelerateDMA()
548 return accelerate_dma; 548 return accelerate_dma;
549} 549}
550 550
551void RasterizerVulkan::AccelerateInlineToMemory(GPUVAddr address, size_t copy_size,
552 std::span<u8> memory) {
553 auto cpu_addr = gpu_memory.GpuToCpuAddress(address);
554 if (!cpu_addr) [[unlikely]] {
555 gpu_memory.WriteBlock(address, memory.data(), copy_size);
556 return;
557 }
558 gpu_memory.WriteBlockUnsafe(address, memory.data(), copy_size);
559 {
560 std::unique_lock<std::mutex> lock{buffer_cache.mutex};
561 if (!buffer_cache.InlineMemory(*cpu_addr, copy_size, memory)) {
562 buffer_cache.WriteMemory(*cpu_addr, copy_size);
563 }
564 }
565 {
566 std::scoped_lock lock_texture{texture_cache.mutex};
567 texture_cache.WriteMemory(*cpu_addr, copy_size);
568 }
569 pipeline_cache.InvalidateRegion(*cpu_addr, copy_size);
570 query_cache.InvalidateRegion(*cpu_addr, copy_size);
571}
572
551bool RasterizerVulkan::AccelerateDisplay(const Tegra::FramebufferConfig& config, 573bool RasterizerVulkan::AccelerateDisplay(const Tegra::FramebufferConfig& config,
552 VAddr framebuffer_addr, u32 pixel_stride) { 574 VAddr framebuffer_addr, u32 pixel_stride) {
553 if (!framebuffer_addr) { 575 if (!framebuffer_addr) {
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h
index 866827247..5af2e275b 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.h
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.h
@@ -99,6 +99,8 @@ public:
99 const Tegra::Engines::Fermi2D::Surface& dst, 99 const Tegra::Engines::Fermi2D::Surface& dst,
100 const Tegra::Engines::Fermi2D::Config& copy_config) override; 100 const Tegra::Engines::Fermi2D::Config& copy_config) override;
101 Tegra::Engines::AccelerateDMAInterface& AccessAccelerateDMA() override; 101 Tegra::Engines::AccelerateDMAInterface& AccessAccelerateDMA() override;
102 void AccelerateInlineToMemory(GPUVAddr address, size_t copy_size,
103 std::span<u8> memory) override;
102 bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr, 104 bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr,
103 u32 pixel_stride) override; 105 u32 pixel_stride) override;
104 void LoadDiskResources(u64 title_id, std::stop_token stop_loading, 106 void LoadDiskResources(u64 title_id, std::stop_token stop_loading,
diff --git a/src/video_core/shader_cache.cpp b/src/video_core/shader_cache.cpp
index 78bf90c48..87636857d 100644
--- a/src/video_core/shader_cache.cpp
+++ b/src/video_core/shader_cache.cpp
@@ -170,7 +170,7 @@ void ShaderCache::RemovePendingShaders() {
170 marked_for_removal.clear(); 170 marked_for_removal.clear();
171 171
172 if (!removed_shaders.empty()) { 172 if (!removed_shaders.empty()) {
173 RemoveShadersFromStorage(std::move(removed_shaders)); 173 RemoveShadersFromStorage(removed_shaders);
174 } 174 }
175} 175}
176 176
@@ -213,7 +213,7 @@ void ShaderCache::UnmarkMemory(Entry* entry) {
213 rasterizer.UpdatePagesCachedCount(addr, size, -1); 213 rasterizer.UpdatePagesCachedCount(addr, size, -1);
214} 214}
215 215
216void ShaderCache::RemoveShadersFromStorage(std::vector<ShaderInfo*> removed_shaders) { 216void ShaderCache::RemoveShadersFromStorage(std::span<ShaderInfo*> removed_shaders) {
217 // Remove them from the cache 217 // Remove them from the cache
218 std::erase_if(storage, [&removed_shaders](const std::unique_ptr<ShaderInfo>& shader) { 218 std::erase_if(storage, [&removed_shaders](const std::unique_ptr<ShaderInfo>& shader) {
219 return std::ranges::find(removed_shaders, shader.get()) != removed_shaders.end(); 219 return std::ranges::find(removed_shaders, shader.get()) != removed_shaders.end();
diff --git a/src/video_core/shader_cache.h b/src/video_core/shader_cache.h
index 136fe294c..8836bc8c6 100644
--- a/src/video_core/shader_cache.h
+++ b/src/video_core/shader_cache.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <algorithm>
8#include <array> 7#include <array>
9#include <memory> 8#include <memory>
10#include <mutex> 9#include <mutex>
@@ -138,7 +137,7 @@ private:
138 /// @param removed_shaders Shaders to be removed from the storage 137 /// @param removed_shaders Shaders to be removed from the storage
139 /// @pre invalidation_mutex is locked 138 /// @pre invalidation_mutex is locked
140 /// @pre lookup_mutex is locked 139 /// @pre lookup_mutex is locked
141 void RemoveShadersFromStorage(std::vector<ShaderInfo*> removed_shaders); 140 void RemoveShadersFromStorage(std::span<ShaderInfo*> removed_shaders);
142 141
143 /// @brief Creates a new entry in the lookup cache and returns its pointer 142 /// @brief Creates a new entry in the lookup cache and returns its pointer
144 /// @pre lookup_mutex is locked 143 /// @pre lookup_mutex is locked
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp
index 464e7a489..19133ccf5 100644
--- a/src/yuzu/configuration/configure_dialog.cpp
+++ b/src/yuzu/configuration/configure_dialog.cpp
@@ -109,7 +109,7 @@ void ConfigureDialog::ApplyConfiguration() {
109 ui_tab->ApplyConfiguration(); 109 ui_tab->ApplyConfiguration();
110 system_tab->ApplyConfiguration(); 110 system_tab->ApplyConfiguration();
111 profile_tab->ApplyConfiguration(); 111 profile_tab->ApplyConfiguration();
112 filesystem_tab->applyConfiguration(); 112 filesystem_tab->ApplyConfiguration();
113 input_tab->ApplyConfiguration(); 113 input_tab->ApplyConfiguration();
114 hotkeys_tab->ApplyConfiguration(registry); 114 hotkeys_tab->ApplyConfiguration(registry);
115 cpu_tab->ApplyConfiguration(); 115 cpu_tab->ApplyConfiguration();
diff --git a/src/yuzu/configuration/configure_filesystem.cpp b/src/yuzu/configuration/configure_filesystem.cpp
index 9cb317822..d6fb43f8b 100644
--- a/src/yuzu/configuration/configure_filesystem.cpp
+++ b/src/yuzu/configuration/configure_filesystem.cpp
@@ -14,7 +14,7 @@
14ConfigureFilesystem::ConfigureFilesystem(QWidget* parent) 14ConfigureFilesystem::ConfigureFilesystem(QWidget* parent)
15 : QWidget(parent), ui(std::make_unique<Ui::ConfigureFilesystem>()) { 15 : QWidget(parent), ui(std::make_unique<Ui::ConfigureFilesystem>()) {
16 ui->setupUi(this); 16 ui->setupUi(this);
17 this->setConfiguration(); 17 SetConfiguration();
18 18
19 connect(ui->nand_directory_button, &QToolButton::pressed, this, 19 connect(ui->nand_directory_button, &QToolButton::pressed, this,
20 [this] { SetDirectory(DirectoryTarget::NAND, ui->nand_directory_edit); }); 20 [this] { SetDirectory(DirectoryTarget::NAND, ui->nand_directory_edit); });
@@ -38,7 +38,15 @@ ConfigureFilesystem::ConfigureFilesystem(QWidget* parent)
38 38
39ConfigureFilesystem::~ConfigureFilesystem() = default; 39ConfigureFilesystem::~ConfigureFilesystem() = default;
40 40
41void ConfigureFilesystem::setConfiguration() { 41void ConfigureFilesystem::changeEvent(QEvent* event) {
42 if (event->type() == QEvent::LanguageChange) {
43 RetranslateUI();
44 }
45
46 QWidget::changeEvent(event);
47}
48
49void ConfigureFilesystem::SetConfiguration() {
42 ui->nand_directory_edit->setText( 50 ui->nand_directory_edit->setText(
43 QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir))); 51 QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir)));
44 ui->sdmc_directory_edit->setText( 52 ui->sdmc_directory_edit->setText(
@@ -60,7 +68,7 @@ void ConfigureFilesystem::setConfiguration() {
60 UpdateEnabledControls(); 68 UpdateEnabledControls();
61} 69}
62 70
63void ConfigureFilesystem::applyConfiguration() { 71void ConfigureFilesystem::ApplyConfiguration() {
64 Common::FS::SetYuzuPath(Common::FS::YuzuPath::NANDDir, 72 Common::FS::SetYuzuPath(Common::FS::YuzuPath::NANDDir,
65 ui->nand_directory_edit->text().toStdString()); 73 ui->nand_directory_edit->text().toStdString());
66 Common::FS::SetYuzuPath(Common::FS::YuzuPath::SDMCDir, 74 Common::FS::SetYuzuPath(Common::FS::YuzuPath::SDMCDir,
@@ -143,6 +151,6 @@ void ConfigureFilesystem::UpdateEnabledControls() {
143 !ui->gamecard_current_game->isChecked()); 151 !ui->gamecard_current_game->isChecked());
144} 152}
145 153
146void ConfigureFilesystem::retranslateUi() { 154void ConfigureFilesystem::RetranslateUI() {
147 ui->retranslateUi(this); 155 ui->retranslateUi(this);
148} 156}
diff --git a/src/yuzu/configuration/configure_filesystem.h b/src/yuzu/configuration/configure_filesystem.h
index 2147cd405..b4f9355eb 100644
--- a/src/yuzu/configuration/configure_filesystem.h
+++ b/src/yuzu/configuration/configure_filesystem.h
@@ -20,11 +20,13 @@ public:
20 explicit ConfigureFilesystem(QWidget* parent = nullptr); 20 explicit ConfigureFilesystem(QWidget* parent = nullptr);
21 ~ConfigureFilesystem() override; 21 ~ConfigureFilesystem() override;
22 22
23 void applyConfiguration(); 23 void ApplyConfiguration();
24 void retranslateUi();
25 24
26private: 25private:
27 void setConfiguration(); 26 void changeEvent(QEvent* event) override;
27
28 void RetranslateUI();
29 void SetConfiguration();
28 30
29 enum class DirectoryTarget { 31 enum class DirectoryTarget {
30 NAND, 32 NAND,
diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp
index be10e0a31..53e629a5e 100644
--- a/src/yuzu/configuration/configure_hotkeys.cpp
+++ b/src/yuzu/configuration/configure_hotkeys.cpp
@@ -178,52 +178,52 @@ void ConfigureHotkeys::SetPollingResult(Core::HID::NpadButton button, const bool
178QString ConfigureHotkeys::GetButtonName(Core::HID::NpadButton button) const { 178QString ConfigureHotkeys::GetButtonName(Core::HID::NpadButton button) const {
179 Core::HID::NpadButtonState state{button}; 179 Core::HID::NpadButtonState state{button};
180 if (state.a) { 180 if (state.a) {
181 return tr("A"); 181 return QStringLiteral("A");
182 } 182 }
183 if (state.b) { 183 if (state.b) {
184 return tr("B"); 184 return QStringLiteral("B");
185 } 185 }
186 if (state.x) { 186 if (state.x) {
187 return tr("X"); 187 return QStringLiteral("X");
188 } 188 }
189 if (state.y) { 189 if (state.y) {
190 return tr("Y"); 190 return QStringLiteral("Y");
191 } 191 }
192 if (state.l || state.right_sl || state.left_sl) { 192 if (state.l || state.right_sl || state.left_sl) {
193 return tr("L"); 193 return QStringLiteral("L");
194 } 194 }
195 if (state.r || state.right_sr || state.left_sr) { 195 if (state.r || state.right_sr || state.left_sr) {
196 return tr("R"); 196 return QStringLiteral("R");
197 } 197 }
198 if (state.zl) { 198 if (state.zl) {
199 return tr("ZL"); 199 return QStringLiteral("ZL");
200 } 200 }
201 if (state.zr) { 201 if (state.zr) {
202 return tr("ZR"); 202 return QStringLiteral("ZR");
203 } 203 }
204 if (state.left) { 204 if (state.left) {
205 return tr("Dpad_Left"); 205 return QStringLiteral("Dpad_Left");
206 } 206 }
207 if (state.right) { 207 if (state.right) {
208 return tr("Dpad_Right"); 208 return QStringLiteral("Dpad_Right");
209 } 209 }
210 if (state.up) { 210 if (state.up) {
211 return tr("Dpad_Up"); 211 return QStringLiteral("Dpad_Up");
212 } 212 }
213 if (state.down) { 213 if (state.down) {
214 return tr("Dpad_Down"); 214 return QStringLiteral("Dpad_Down");
215 } 215 }
216 if (state.stick_l) { 216 if (state.stick_l) {
217 return tr("Left_Stick"); 217 return QStringLiteral("Left_Stick");
218 } 218 }
219 if (state.stick_r) { 219 if (state.stick_r) {
220 return tr("Right_Stick"); 220 return QStringLiteral("Right_Stick");
221 } 221 }
222 if (state.minus) { 222 if (state.minus) {
223 return tr("Minus"); 223 return QStringLiteral("Minus");
224 } 224 }
225 if (state.plus) { 225 if (state.plus) {
226 return tr("Plus"); 226 return QStringLiteral("Plus");
227 } 227 }
228 return tr("Invalid"); 228 return tr("Invalid");
229} 229}
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 752504236..cc0534907 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -102,6 +102,10 @@ QString GetButtonName(Common::Input::ButtonNames button_name) {
102 return QObject::tr("Share"); 102 return QObject::tr("Share");
103 case Common::Input::ButtonNames::Options: 103 case Common::Input::ButtonNames::Options:
104 return QObject::tr("Options"); 104 return QObject::tr("Options");
105 case Common::Input::ButtonNames::Home:
106 return QObject::tr("Home");
107 case Common::Input::ButtonNames::Touch:
108 return QObject::tr("Touch");
105 case Common::Input::ButtonNames::ButtonMouseWheel: 109 case Common::Input::ButtonNames::ButtonMouseWheel:
106 return QObject::tr("Wheel", "Indicates the mouse wheel"); 110 return QObject::tr("Wheel", "Indicates the mouse wheel");
107 case Common::Input::ButtonNames::ButtonBackward: 111 case Common::Input::ButtonNames::ButtonBackward:
@@ -326,7 +330,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
326 connect(button, &QPushButton::clicked, [=, this] { 330 connect(button, &QPushButton::clicked, [=, this] {
327 HandleClick( 331 HandleClick(
328 button, button_id, 332 button, button_id,
329 [=, this](Common::ParamPackage params) { 333 [=, this](const Common::ParamPackage& params) {
330 emulated_controller->SetButtonParam(button_id, params); 334 emulated_controller->SetButtonParam(button_id, params);
331 }, 335 },
332 InputCommon::Polling::InputType::Button); 336 InputCommon::Polling::InputType::Button);
@@ -392,7 +396,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
392 connect(button, &QPushButton::clicked, [=, this] { 396 connect(button, &QPushButton::clicked, [=, this] {
393 HandleClick( 397 HandleClick(
394 button, motion_id, 398 button, motion_id,
395 [=, this](Common::ParamPackage params) { 399 [=, this](const Common::ParamPackage& params) {
396 emulated_controller->SetMotionParam(motion_id, params); 400 emulated_controller->SetMotionParam(motion_id, params);
397 }, 401 },
398 InputCommon::Polling::InputType::Motion); 402 InputCommon::Polling::InputType::Motion);
@@ -497,10 +501,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
497 param.Set("invert_y", invert_str); 501 param.Set("invert_y", invert_str);
498 emulated_controller->SetStickParam(analog_id, param); 502 emulated_controller->SetStickParam(analog_id, param);
499 } 503 }
500 for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; 504 for (int analog_sub_button_id = 0;
501 ++sub_button_id) { 505 analog_sub_button_id < ANALOG_SUB_BUTTONS_NUM;
502 analog_map_buttons[analog_id][sub_button_id]->setText( 506 ++analog_sub_button_id) {
503 AnalogToText(param, analog_sub_buttons[sub_button_id])); 507 analog_map_buttons[analog_id][analog_sub_button_id]->setText(
508 AnalogToText(param, analog_sub_buttons[analog_sub_button_id]));
504 } 509 }
505 }); 510 });
506 context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal( 511 context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(
@@ -783,7 +788,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() {
783 if (devices.size() == 1) { 788 if (devices.size() == 1) {
784 const auto devices_it = std::find_if( 789 const auto devices_it = std::find_if(
785 input_devices.begin(), input_devices.end(), 790 input_devices.begin(), input_devices.end(),
786 [first_engine, first_guid, first_port, first_pad](const Common::ParamPackage param) { 791 [first_engine, first_guid, first_port, first_pad](const Common::ParamPackage& param) {
787 return param.Get("engine", "") == first_engine && 792 return param.Get("engine", "") == first_engine &&
788 param.Get("guid", "") == first_guid && param.Get("port", 0) == first_port && 793 param.Get("guid", "") == first_guid && param.Get("port", 0) == first_port &&
789 param.Get("pad", 0) == first_pad; 794 param.Get("pad", 0) == first_pad;
@@ -814,7 +819,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() {
814 if (is_engine_equal && is_port_equal) { 819 if (is_engine_equal && is_port_equal) {
815 const auto devices_it = std::find_if( 820 const auto devices_it = std::find_if(
816 input_devices.begin(), input_devices.end(), 821 input_devices.begin(), input_devices.end(),
817 [first_engine, first_guid, second_guid, first_port](const Common::ParamPackage param) { 822 [first_engine, first_guid, second_guid, first_port](const Common::ParamPackage& param) {
818 const bool is_guid_valid = 823 const bool is_guid_valid =
819 (param.Get("guid", "") == first_guid && 824 (param.Get("guid", "") == first_guid &&
820 param.Get("guid2", "") == second_guid) || 825 param.Get("guid2", "") == second_guid) ||
@@ -1026,7 +1031,7 @@ int ConfigureInputPlayer::GetIndexFromControllerType(Core::HID::NpadStyleIndex t
1026void ConfigureInputPlayer::UpdateInputDevices() { 1031void ConfigureInputPlayer::UpdateInputDevices() {
1027 input_devices = input_subsystem->GetInputDevices(); 1032 input_devices = input_subsystem->GetInputDevices();
1028 ui->comboDevices->clear(); 1033 ui->comboDevices->clear();
1029 for (auto device : input_devices) { 1034 for (const auto& device : input_devices) {
1030 ui->comboDevices->addItem(QString::fromStdString(device.Get("display", "Unknown")), {}); 1035 ui->comboDevices->addItem(QString::fromStdString(device.Get("display", "Unknown")), {});
1031 } 1036 }
1032} 1037}
@@ -1308,7 +1313,7 @@ void ConfigureInputPlayer::HandleClick(
1308 } 1313 }
1309 button->setFocus(); 1314 button->setFocus();
1310 1315
1311 input_setter = new_input_setter; 1316 input_setter = std::move(new_input_setter);
1312 1317
1313 input_subsystem->BeginMapping(type); 1318 input_subsystem->BeginMapping(type);
1314 1319
@@ -1358,7 +1363,7 @@ bool ConfigureInputPlayer::IsInputAcceptable(const Common::ParamPackage& params)
1358 return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse"; 1363 return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse";
1359 } 1364 }
1360 1365
1361 const auto current_input_device = input_devices[ui->comboDevices->currentIndex()]; 1366 const auto& current_input_device = input_devices[ui->comboDevices->currentIndex()];
1362 return params.Get("engine", "") == current_input_device.Get("engine", "") && 1367 return params.Get("engine", "") == current_input_device.Get("engine", "") &&
1363 (params.Get("guid", "") == current_input_device.Get("guid", "") || 1368 (params.Get("guid", "") == current_input_device.Get("guid", "") ||
1364 params.Get("guid", "") == current_input_device.Get("guid2", "")) && 1369 params.Get("guid", "") == current_input_device.Get("guid2", "")) &&
diff --git a/src/yuzu/configuration/configure_motion_touch.cpp b/src/yuzu/configuration/configure_motion_touch.cpp
index 8539a5c8b..4340de304 100644
--- a/src/yuzu/configuration/configure_motion_touch.cpp
+++ b/src/yuzu/configuration/configure_motion_touch.cpp
@@ -42,23 +42,25 @@ CalibrationConfigurationDialog::CalibrationConfigurationDialog(QWidget* parent,
42 job = std::make_unique<CalibrationConfigurationJob>( 42 job = std::make_unique<CalibrationConfigurationJob>(
43 host, port, 43 host, port,
44 [this](CalibrationConfigurationJob::Status status) { 44 [this](CalibrationConfigurationJob::Status status) {
45 QString text; 45 QMetaObject::invokeMethod(this, [status, this] {
46 switch (status) { 46 QString text;
47 case CalibrationConfigurationJob::Status::Ready: 47 switch (status) {
48 text = tr("Touch the top left corner <br>of your touchpad."); 48 case CalibrationConfigurationJob::Status::Ready:
49 break; 49 text = tr("Touch the top left corner <br>of your touchpad.");
50 case CalibrationConfigurationJob::Status::Stage1Completed: 50 break;
51 text = tr("Now touch the bottom right corner <br>of your touchpad."); 51 case CalibrationConfigurationJob::Status::Stage1Completed:
52 break; 52 text = tr("Now touch the bottom right corner <br>of your touchpad.");
53 case CalibrationConfigurationJob::Status::Completed: 53 break;
54 text = tr("Configuration completed!"); 54 case CalibrationConfigurationJob::Status::Completed:
55 break; 55 text = tr("Configuration completed!");
56 default: 56 break;
57 break; 57 default:
58 } 58 break;
59 QMetaObject::invokeMethod(this, "UpdateLabelText", Q_ARG(QString, text)); 59 }
60 UpdateLabelText(text);
61 });
60 if (status == CalibrationConfigurationJob::Status::Completed) { 62 if (status == CalibrationConfigurationJob::Status::Completed) {
61 QMetaObject::invokeMethod(this, "UpdateButtonText", Q_ARG(QString, tr("OK"))); 63 QMetaObject::invokeMethod(this, [this] { UpdateButtonText(tr("OK")); });
62 } 64 }
63 }, 65 },
64 [this](u16 min_x_, u16 min_y_, u16 max_x_, u16 max_y_) { 66 [this](u16 min_x_, u16 min_y_, u16 max_x_, u16 max_y_) {
@@ -215,11 +217,11 @@ void ConfigureMotionTouch::OnCemuhookUDPTest() {
215 ui->udp_server->text().toStdString(), static_cast<u16>(ui->udp_port->text().toInt()), 217 ui->udp_server->text().toStdString(), static_cast<u16>(ui->udp_port->text().toInt()),
216 [this] { 218 [this] {
217 LOG_INFO(Frontend, "UDP input test success"); 219 LOG_INFO(Frontend, "UDP input test success");
218 QMetaObject::invokeMethod(this, "ShowUDPTestResult", Q_ARG(bool, true)); 220 QMetaObject::invokeMethod(this, [this] { ShowUDPTestResult(true); });
219 }, 221 },
220 [this] { 222 [this] {
221 LOG_ERROR(Frontend, "UDP input test failed"); 223 LOG_ERROR(Frontend, "UDP input test failed");
222 QMetaObject::invokeMethod(this, "ShowUDPTestResult", Q_ARG(bool, false)); 224 QMetaObject::invokeMethod(this, [this] { ShowUDPTestResult(false); });
223 }); 225 });
224} 226}
225 227
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 8b5c4a10a..e3661b390 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -161,7 +161,7 @@ GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} {
161 * @return true if the haystack contains all words of userinput 161 * @return true if the haystack contains all words of userinput
162 */ 162 */
163static bool ContainsAllWords(const QString& haystack, const QString& userinput) { 163static bool ContainsAllWords(const QString& haystack, const QString& userinput) {
164 const QStringList userinput_split = userinput.split(QLatin1Char{' '}, QString::SkipEmptyParts); 164 const QStringList userinput_split = userinput.split(QLatin1Char{' '}, Qt::SkipEmptyParts);
165 165
166 return std::all_of(userinput_split.begin(), userinput_split.end(), 166 return std::all_of(userinput_split.begin(), userinput_split.end(),
167 [&haystack](const QString& s) { return haystack.contains(s); }); 167 [&haystack](const QString& s) { return haystack.contains(s); });