summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/CMakeLists.txt2
-rw-r--r--src/common/nvidia_flags.cpp27
-rw-r--r--src/common/nvidia_flags.h10
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp22
-rw-r--r--src/core/hle/kernel/hle_ipc.h6
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp17
-rw-r--r--src/core/hle/service/hid/controllers/npad.h5
-rw-r--r--src/core/hle/service/hid/hid.cpp84
-rw-r--r--src/core/hle/service/hid/hid.h3
-rw-r--r--src/core/hle/service/prepo/prepo.cpp66
-rw-r--r--src/video_core/renderer_opengl/gl_device.cpp1
-rw-r--r--src/video_core/renderer_opengl/gl_device.h5
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp13
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp3
-rw-r--r--src/video_core/renderer_vulkan/vk_scheduler.h12
-rw-r--r--src/video_core/vulkan_common/vulkan_device.cpp5
-rw-r--r--src/yuzu/main.cpp3
-rw-r--r--src/yuzu_cmd/yuzu.cpp3
18 files changed, 248 insertions, 39 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index f77575a00..bfd11e76d 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -138,6 +138,8 @@ add_library(common STATIC
138 microprofile.h 138 microprofile.h
139 microprofileui.h 139 microprofileui.h
140 misc.cpp 140 misc.cpp
141 nvidia_flags.cpp
142 nvidia_flags.h
141 page_table.cpp 143 page_table.cpp
142 page_table.h 144 page_table.h
143 param_package.cpp 145 param_package.cpp
diff --git a/src/common/nvidia_flags.cpp b/src/common/nvidia_flags.cpp
new file mode 100644
index 000000000..d537517db
--- /dev/null
+++ b/src/common/nvidia_flags.cpp
@@ -0,0 +1,27 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <filesystem>
6#include <stdlib.h>
7
8#include <fmt/format.h>
9
10#include "common/file_util.h"
11#include "common/nvidia_flags.h"
12
13namespace Common {
14
15void ConfigureNvidiaEnvironmentFlags() {
16#ifdef _WIN32
17 const std::string shader_path = Common::FS::SanitizePath(
18 fmt::format("{}/nvidia/", Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir)));
19 const std::string windows_path =
20 Common::FS::SanitizePath(shader_path, Common::FS::DirectorySeparator::BackwardSlash);
21 void(Common::FS::CreateFullPath(shader_path + '/'));
22 void(_putenv(fmt::format("__GL_SHADER_DISK_CACHE_PATH={}", windows_path).c_str()));
23 void(_putenv("__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1"));
24#endif
25}
26
27} // namespace Common
diff --git a/src/common/nvidia_flags.h b/src/common/nvidia_flags.h
new file mode 100644
index 000000000..75a0233ac
--- /dev/null
+++ b/src/common/nvidia_flags.h
@@ -0,0 +1,10 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5namespace Common {
6
7/// Configure platform specific flags for Nvidia's driver
8void ConfigureNvidiaEnvironmentFlags();
9
10} // namespace Common
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index 83decf6cf..a419f9602 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -338,6 +338,28 @@ std::size_t HLERequestContext::GetWriteBufferSize(std::size_t buffer_index) cons
338 return 0; 338 return 0;
339} 339}
340 340
341bool HLERequestContext::CanReadBuffer(std::size_t buffer_index) const {
342 const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&
343 BufferDescriptorA()[buffer_index].Size()};
344
345 if (is_buffer_a) {
346 return BufferDescriptorA().size() > buffer_index;
347 } else {
348 return BufferDescriptorX().size() > buffer_index;
349 }
350}
351
352bool HLERequestContext::CanWriteBuffer(std::size_t buffer_index) const {
353 const bool is_buffer_b{BufferDescriptorB().size() > buffer_index &&
354 BufferDescriptorB()[buffer_index].Size()};
355
356 if (is_buffer_b) {
357 return BufferDescriptorB().size() > buffer_index;
358 } else {
359 return BufferDescriptorC().size() > buffer_index;
360 }
361}
362
341std::string HLERequestContext::Description() const { 363std::string HLERequestContext::Description() const {
342 if (!command_header) { 364 if (!command_header) {
343 return "No command header available"; 365 return "No command header available";
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index b112e1ebd..698f607e6 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -207,6 +207,12 @@ public:
207 /// Helper function to get the size of the output buffer 207 /// Helper function to get the size of the output buffer
208 std::size_t GetWriteBufferSize(std::size_t buffer_index = 0) const; 208 std::size_t GetWriteBufferSize(std::size_t buffer_index = 0) const;
209 209
210 /// Helper function to test whether the input buffer at buffer_index can be read
211 bool CanReadBuffer(std::size_t buffer_index = 0) const;
212
213 /// Helper function to test whether the output buffer at buffer_index can be written
214 bool CanWriteBuffer(std::size_t buffer_index = 0) const;
215
210 template <typename T> 216 template <typename T>
211 std::shared_ptr<T> GetCopyObject(std::size_t index) { 217 std::shared_ptr<T> GetCopyObject(std::size_t index) {
212 return DynamicObjectCast<T>(copy_objects.at(index)); 218 return DynamicObjectCast<T>(copy_objects.at(index));
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index ff783b3cc..0c227b135 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -946,6 +946,23 @@ void Controller_NPad::SetSixAxisEnabled(bool six_axis_status) {
946 sixaxis_sensors_enabled = six_axis_status; 946 sixaxis_sensors_enabled = six_axis_status;
947} 947}
948 948
949void Controller_NPad::SetSixAxisFusionParameters(f32 parameter1, f32 parameter2) {
950 sixaxis_fusion_parameter1 = parameter1;
951 sixaxis_fusion_parameter2 = parameter2;
952}
953
954std::pair<f32, f32> Controller_NPad::GetSixAxisFusionParameters() {
955 return {
956 sixaxis_fusion_parameter1,
957 sixaxis_fusion_parameter2,
958 };
959}
960
961void Controller_NPad::ResetSixAxisFusionParameters() {
962 sixaxis_fusion_parameter1 = 0.0f;
963 sixaxis_fusion_parameter2 = 0.0f;
964}
965
949void Controller_NPad::MergeSingleJoyAsDualJoy(u32 npad_id_1, u32 npad_id_2) { 966void Controller_NPad::MergeSingleJoyAsDualJoy(u32 npad_id_1, u32 npad_id_2) {
950 const auto npad_index_1 = NPadIdToIndex(npad_id_1); 967 const auto npad_index_1 = NPadIdToIndex(npad_id_1);
951 const auto npad_index_2 = NPadIdToIndex(npad_id_2); 968 const auto npad_index_2 = NPadIdToIndex(npad_id_2);
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index bc85ca4df..2e13922b9 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -202,6 +202,9 @@ public:
202 GyroscopeZeroDriftMode GetGyroscopeZeroDriftMode() const; 202 GyroscopeZeroDriftMode GetGyroscopeZeroDriftMode() const;
203 bool IsSixAxisSensorAtRest() const; 203 bool IsSixAxisSensorAtRest() const;
204 void SetSixAxisEnabled(bool six_axis_status); 204 void SetSixAxisEnabled(bool six_axis_status);
205 void SetSixAxisFusionParameters(f32 parameter1, f32 parameter2);
206 std::pair<f32, f32> GetSixAxisFusionParameters();
207 void ResetSixAxisFusionParameters();
205 LedPattern GetLedPattern(u32 npad_id); 208 LedPattern GetLedPattern(u32 npad_id);
206 bool IsUnintendedHomeButtonInputProtectionEnabled(u32 npad_id) const; 209 bool IsUnintendedHomeButtonInputProtectionEnabled(u32 npad_id) const;
207 void SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled, u32 npad_id); 210 void SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled, u32 npad_id);
@@ -458,6 +461,8 @@ private:
458 std::array<bool, 10> unintended_home_button_input_protection{}; 461 std::array<bool, 10> unintended_home_button_input_protection{};
459 GyroscopeZeroDriftMode gyroscope_zero_drift_mode{GyroscopeZeroDriftMode::Standard}; 462 GyroscopeZeroDriftMode gyroscope_zero_drift_mode{GyroscopeZeroDriftMode::Standard};
460 bool sixaxis_sensors_enabled{true}; 463 bool sixaxis_sensors_enabled{true};
464 f32 sixaxis_fusion_parameter1{};
465 f32 sixaxis_fusion_parameter2{};
461 bool sixaxis_at_rest{true}; 466 bool sixaxis_at_rest{true};
462 std::array<ControllerPad, 10> npad_pad_states{}; 467 std::array<ControllerPad, 10> npad_pad_states{};
463 bool is_in_lr_assignment_mode{false}; 468 bool is_in_lr_assignment_mode{false};
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 2b13d6fe6..5efc1237e 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -209,9 +209,9 @@ Hid::Hid(Core::System& system_) : ServiceFramework{system_, "hid"} {
209 {67, &Hid::StopSixAxisSensor, "StopSixAxisSensor"}, 209 {67, &Hid::StopSixAxisSensor, "StopSixAxisSensor"},
210 {68, nullptr, "IsSixAxisSensorFusionEnabled"}, 210 {68, nullptr, "IsSixAxisSensorFusionEnabled"},
211 {69, &Hid::EnableSixAxisSensorFusion, "EnableSixAxisSensorFusion"}, 211 {69, &Hid::EnableSixAxisSensorFusion, "EnableSixAxisSensorFusion"},
212 {70, nullptr, "SetSixAxisSensorFusionParameters"}, 212 {70, &Hid::SetSixAxisSensorFusionParameters, "SetSixAxisSensorFusionParameters"},
213 {71, nullptr, "GetSixAxisSensorFusionParameters"}, 213 {71, &Hid::GetSixAxisSensorFusionParameters, "GetSixAxisSensorFusionParameters"},
214 {72, nullptr, "ResetSixAxisSensorFusionParameters"}, 214 {72, &Hid::ResetSixAxisSensorFusionParameters, "ResetSixAxisSensorFusionParameters"},
215 {73, nullptr, "SetAccelerometerParameters"}, 215 {73, nullptr, "SetAccelerometerParameters"},
216 {74, nullptr, "GetAccelerometerParameters"}, 216 {74, nullptr, "GetAccelerometerParameters"},
217 {75, nullptr, "ResetAccelerometerParameters"}, 217 {75, nullptr, "ResetAccelerometerParameters"},
@@ -520,6 +520,7 @@ void Hid::EnableSixAxisSensorFusion(Kernel::HLERequestContext& ctx) {
520 Controller_NPad::DeviceHandle sixaxis_handle; 520 Controller_NPad::DeviceHandle sixaxis_handle;
521 u64 applet_resource_user_id; 521 u64 applet_resource_user_id;
522 }; 522 };
523 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
523 524
524 const auto parameters{rp.PopRaw<Parameters>()}; 525 const auto parameters{rp.PopRaw<Parameters>()};
525 526
@@ -534,6 +535,83 @@ void Hid::EnableSixAxisSensorFusion(Kernel::HLERequestContext& ctx) {
534 rb.Push(RESULT_SUCCESS); 535 rb.Push(RESULT_SUCCESS);
535} 536}
536 537
538void Hid::SetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) {
539 IPC::RequestParser rp{ctx};
540 struct Parameters {
541 Controller_NPad::DeviceHandle sixaxis_handle;
542 f32 parameter1;
543 f32 parameter2;
544 u64 applet_resource_user_id;
545 };
546 static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
547
548 const auto parameters{rp.PopRaw<Parameters>()};
549
550 applet_resource->GetController<Controller_NPad>(HidController::NPad)
551 .SetSixAxisFusionParameters(parameters.parameter1, parameters.parameter2);
552
553 LOG_WARNING(Service_HID,
554 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, parameter1={}, "
555 "parameter2={}, applet_resource_user_id={}",
556 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id,
557 parameters.sixaxis_handle.device_index, parameters.parameter1,
558 parameters.parameter2, parameters.applet_resource_user_id);
559
560 IPC::ResponseBuilder rb{ctx, 2};
561 rb.Push(RESULT_SUCCESS);
562}
563
564void Hid::GetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) {
565 IPC::RequestParser rp{ctx};
566 struct Parameters {
567 Controller_NPad::DeviceHandle sixaxis_handle;
568 u64 applet_resource_user_id;
569 };
570 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
571
572 f32 parameter1 = 0;
573 f32 parameter2 = 0;
574 const auto parameters{rp.PopRaw<Parameters>()};
575
576 std::tie(parameter1, parameter2) =
577 applet_resource->GetController<Controller_NPad>(HidController::NPad)
578 .GetSixAxisFusionParameters();
579
580 LOG_WARNING(
581 Service_HID,
582 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
583 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id,
584 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
585
586 IPC::ResponseBuilder rb{ctx, 4};
587 rb.Push(RESULT_SUCCESS);
588 rb.Push(parameter1);
589 rb.Push(parameter2);
590}
591
592void Hid::ResetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx) {
593 IPC::RequestParser rp{ctx};
594 struct Parameters {
595 Controller_NPad::DeviceHandle sixaxis_handle;
596 u64 applet_resource_user_id;
597 };
598 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
599
600 const auto parameters{rp.PopRaw<Parameters>()};
601
602 applet_resource->GetController<Controller_NPad>(HidController::NPad)
603 .ResetSixAxisFusionParameters();
604
605 LOG_WARNING(
606 Service_HID,
607 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
608 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id,
609 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
610
611 IPC::ResponseBuilder rb{ctx, 2};
612 rb.Push(RESULT_SUCCESS);
613}
614
537void Hid::SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) { 615void Hid::SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx) {
538 IPC::RequestParser rp{ctx}; 616 IPC::RequestParser rp{ctx};
539 const auto sixaxis_handle{rp.PopRaw<Controller_NPad::DeviceHandle>()}; 617 const auto sixaxis_handle{rp.PopRaw<Controller_NPad::DeviceHandle>()};
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h
index b87bfdde1..d991bd721 100644
--- a/src/core/hle/service/hid/hid.h
+++ b/src/core/hle/service/hid/hid.h
@@ -97,6 +97,9 @@ private:
97 void StartSixAxisSensor(Kernel::HLERequestContext& ctx); 97 void StartSixAxisSensor(Kernel::HLERequestContext& ctx);
98 void StopSixAxisSensor(Kernel::HLERequestContext& ctx); 98 void StopSixAxisSensor(Kernel::HLERequestContext& ctx);
99 void EnableSixAxisSensorFusion(Kernel::HLERequestContext& ctx); 99 void EnableSixAxisSensorFusion(Kernel::HLERequestContext& ctx);
100 void SetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx);
101 void GetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx);
102 void ResetSixAxisSensorFusionParameters(Kernel::HLERequestContext& ctx);
100 void SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx); 103 void SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
101 void GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx); 104 void GetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
102 void ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx); 105 void ResetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/prepo/prepo.cpp b/src/core/hle/service/prepo/prepo.cpp
index b417624c9..6edd45455 100644
--- a/src/core/hle/service/prepo/prepo.cpp
+++ b/src/core/hle/service/prepo/prepo.cpp
@@ -23,8 +23,8 @@ public:
23 {10101, &PlayReport::SaveReportWithUser<Core::Reporter::PlayReportType::Old>, "SaveReportWithUserOld"}, 23 {10101, &PlayReport::SaveReportWithUser<Core::Reporter::PlayReportType::Old>, "SaveReportWithUserOld"},
24 {10102, &PlayReport::SaveReport<Core::Reporter::PlayReportType::Old2>, "SaveReportOld2"}, 24 {10102, &PlayReport::SaveReport<Core::Reporter::PlayReportType::Old2>, "SaveReportOld2"},
25 {10103, &PlayReport::SaveReportWithUser<Core::Reporter::PlayReportType::Old2>, "SaveReportWithUserOld2"}, 25 {10103, &PlayReport::SaveReportWithUser<Core::Reporter::PlayReportType::Old2>, "SaveReportWithUserOld2"},
26 {10104, nullptr, "SaveReport"}, 26 {10104, &PlayReport::SaveReport<Core::Reporter::PlayReportType::New>, "SaveReport"},
27 {10105, nullptr, "SaveReportWithUser"}, 27 {10105, &PlayReport::SaveReportWithUser<Core::Reporter::PlayReportType::New>, "SaveReportWithUser"},
28 {10200, nullptr, "RequestImmediateTransmission"}, 28 {10200, nullptr, "RequestImmediateTransmission"},
29 {10300, nullptr, "GetTransmissionStatus"}, 29 {10300, nullptr, "GetTransmissionStatus"},
30 {10400, nullptr, "GetSystemSessionId"}, 30 {10400, nullptr, "GetSystemSessionId"},
@@ -59,16 +59,22 @@ private:
59 IPC::RequestParser rp{ctx}; 59 IPC::RequestParser rp{ctx};
60 const auto process_id = rp.PopRaw<u64>(); 60 const auto process_id = rp.PopRaw<u64>();
61 61
62 std::vector<std::vector<u8>> data{ctx.ReadBuffer(0)}; 62 const auto data1 = ctx.ReadBuffer(0);
63 if constexpr (Type == Core::Reporter::PlayReportType::Old2) { 63 const auto data2 = [ctx] {
64 data.emplace_back(ctx.ReadBuffer(1)); 64 if (ctx.CanReadBuffer(1)) {
65 } 65 return ctx.ReadBuffer(1);
66 }
67
68 return std::vector<u8>{};
69 }();
66 70
67 LOG_DEBUG(Service_PREPO, "called, type={:02X}, process_id={:016X}, data1_size={:016X}", 71 LOG_DEBUG(Service_PREPO,
68 Type, process_id, data[0].size()); 72 "called, type={:02X}, process_id={:016X}, data1_size={:016X}, data2_size={:016X}",
73 Type, process_id, data1.size(), data2.size());
69 74
70 const auto& reporter{system.GetReporter()}; 75 const auto& reporter{system.GetReporter()};
71 reporter.SavePlayReport(Type, system.CurrentProcess()->GetTitleID(), data, process_id); 76 reporter.SavePlayReport(Type, system.CurrentProcess()->GetTitleID(), {data1, data2},
77 process_id);
72 78
73 IPC::ResponseBuilder rb{ctx, 2}; 79 IPC::ResponseBuilder rb{ctx, 2};
74 rb.Push(RESULT_SUCCESS); 80 rb.Push(RESULT_SUCCESS);
@@ -79,24 +85,24 @@ private:
79 IPC::RequestParser rp{ctx}; 85 IPC::RequestParser rp{ctx};
80 const auto user_id = rp.PopRaw<u128>(); 86 const auto user_id = rp.PopRaw<u128>();
81 const auto process_id = rp.PopRaw<u64>(); 87 const auto process_id = rp.PopRaw<u64>();
82 std::vector<std::vector<u8>> data{ctx.ReadBuffer(0)};
83 88
84 if constexpr (Type == Core::Reporter::PlayReportType::Old2) { 89 const auto data1 = ctx.ReadBuffer(0);
85 const auto read_buffer_count = 90 const auto data2 = [ctx] {
86 ctx.BufferDescriptorX().size() + ctx.BufferDescriptorA().size(); 91 if (ctx.CanReadBuffer(1)) {
87 if (read_buffer_count > 1) { 92 return ctx.ReadBuffer(1);
88 data.emplace_back(ctx.ReadBuffer(1));
89 } 93 }
90 }
91 94
92 LOG_DEBUG( 95 return std::vector<u8>{};
93 Service_PREPO, 96 }();
94 "called, type={:02X}, user_id={:016X}{:016X}, process_id={:016X}, data1_size={:016X}", 97
95 Type, user_id[1], user_id[0], process_id, data[0].size()); 98 LOG_DEBUG(Service_PREPO,
99 "called, type={:02X}, user_id={:016X}{:016X}, process_id={:016X}, "
100 "data1_size={:016X}, data2_size={:016X}",
101 Type, user_id[1], user_id[0], process_id, data1.size(), data2.size());
96 102
97 const auto& reporter{system.GetReporter()}; 103 const auto& reporter{system.GetReporter()};
98 reporter.SavePlayReport(Type, system.CurrentProcess()->GetTitleID(), data, process_id, 104 reporter.SavePlayReport(Type, system.CurrentProcess()->GetTitleID(), {data1, data2},
99 user_id); 105 process_id, user_id);
100 106
101 IPC::ResponseBuilder rb{ctx, 2}; 107 IPC::ResponseBuilder rb{ctx, 2};
102 rb.Push(RESULT_SUCCESS); 108 rb.Push(RESULT_SUCCESS);
@@ -107,7 +113,13 @@ private:
107 const auto title_id = rp.PopRaw<u64>(); 113 const auto title_id = rp.PopRaw<u64>();
108 114
109 const auto data1 = ctx.ReadBuffer(0); 115 const auto data1 = ctx.ReadBuffer(0);
110 const auto data2 = ctx.ReadBuffer(1); 116 const auto data2 = [ctx] {
117 if (ctx.CanReadBuffer(1)) {
118 return ctx.ReadBuffer(1);
119 }
120
121 return std::vector<u8>{};
122 }();
111 123
112 LOG_DEBUG(Service_PREPO, "called, title_id={:016X}, data1_size={:016X}, data2_size={:016X}", 124 LOG_DEBUG(Service_PREPO, "called, title_id={:016X}, data1_size={:016X}, data2_size={:016X}",
113 title_id, data1.size(), data2.size()); 125 title_id, data1.size(), data2.size());
@@ -125,7 +137,13 @@ private:
125 const auto title_id = rp.PopRaw<u64>(); 137 const auto title_id = rp.PopRaw<u64>();
126 138
127 const auto data1 = ctx.ReadBuffer(0); 139 const auto data1 = ctx.ReadBuffer(0);
128 const auto data2 = ctx.ReadBuffer(1); 140 const auto data2 = [ctx] {
141 if (ctx.CanReadBuffer(1)) {
142 return ctx.ReadBuffer(1);
143 }
144
145 return std::vector<u8>{};
146 }();
129 147
130 LOG_DEBUG(Service_PREPO, 148 LOG_DEBUG(Service_PREPO,
131 "called, user_id={:016X}{:016X}, title_id={:016X}, data1_size={:016X}, " 149 "called, user_id={:016X}{:016X}, title_id={:016X}, data1_size={:016X}, "
diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp
index 81b71edfb..04c267ee4 100644
--- a/src/video_core/renderer_opengl/gl_device.cpp
+++ b/src/video_core/renderer_opengl/gl_device.cpp
@@ -246,6 +246,7 @@ Device::Device()
246 GLAD_GL_NV_transform_feedback && GLAD_GL_NV_transform_feedback2; 246 GLAD_GL_NV_transform_feedback && GLAD_GL_NV_transform_feedback2;
247 247
248 use_asynchronous_shaders = Settings::values.use_asynchronous_shaders.GetValue(); 248 use_asynchronous_shaders = Settings::values.use_asynchronous_shaders.GetValue();
249 use_driver_cache = is_nvidia;
249 250
250 LOG_INFO(Render_OpenGL, "Renderer_VariableAOFFI: {}", has_variable_aoffi); 251 LOG_INFO(Render_OpenGL, "Renderer_VariableAOFFI: {}", has_variable_aoffi);
251 LOG_INFO(Render_OpenGL, "Renderer_ComponentIndexingBug: {}", has_component_indexing_bug); 252 LOG_INFO(Render_OpenGL, "Renderer_ComponentIndexingBug: {}", has_component_indexing_bug);
diff --git a/src/video_core/renderer_opengl/gl_device.h b/src/video_core/renderer_opengl/gl_device.h
index 3e79d1e37..9141de635 100644
--- a/src/video_core/renderer_opengl/gl_device.h
+++ b/src/video_core/renderer_opengl/gl_device.h
@@ -120,6 +120,10 @@ public:
120 return use_asynchronous_shaders; 120 return use_asynchronous_shaders;
121 } 121 }
122 122
123 bool UseDriverCache() const {
124 return use_driver_cache;
125 }
126
123private: 127private:
124 static bool TestVariableAoffi(); 128 static bool TestVariableAoffi();
125 static bool TestPreciseBug(); 129 static bool TestPreciseBug();
@@ -147,6 +151,7 @@ private:
147 bool has_debugging_tool_attached{}; 151 bool has_debugging_tool_attached{};
148 bool use_assembly_shaders{}; 152 bool use_assembly_shaders{};
149 bool use_asynchronous_shaders{}; 153 bool use_asynchronous_shaders{};
154 bool use_driver_cache{};
150}; 155};
151 156
152} // namespace OpenGL 157} // namespace OpenGL
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index d4841fdb7..529570ff0 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -159,6 +159,10 @@ std::unordered_set<GLenum> GetSupportedFormats() {
159 159
160ProgramSharedPtr BuildShader(const Device& device, ShaderType shader_type, u64 unique_identifier, 160ProgramSharedPtr BuildShader(const Device& device, ShaderType shader_type, u64 unique_identifier,
161 const ShaderIR& ir, const Registry& registry, bool hint_retrievable) { 161 const ShaderIR& ir, const Registry& registry, bool hint_retrievable) {
162 if (device.UseDriverCache()) {
163 // Ignore hint retrievable if we are using the driver cache
164 hint_retrievable = false;
165 }
162 const std::string shader_id = MakeShaderID(unique_identifier, shader_type); 166 const std::string shader_id = MakeShaderID(unique_identifier, shader_type);
163 LOG_INFO(Render_OpenGL, "{}", shader_id); 167 LOG_INFO(Render_OpenGL, "{}", shader_id);
164 168
@@ -336,7 +340,7 @@ void ShaderCacheOpenGL::LoadDiskCache(u64 title_id, const std::atomic_bool& stop
336 } 340 }
337 341
338 std::vector<ShaderDiskCachePrecompiled> gl_cache; 342 std::vector<ShaderDiskCachePrecompiled> gl_cache;
339 if (!device.UseAssemblyShaders()) { 343 if (!device.UseAssemblyShaders() && !device.UseDriverCache()) {
340 // Only load precompiled cache when we are not using assembly shaders 344 // Only load precompiled cache when we are not using assembly shaders
341 gl_cache = disk_cache.LoadPrecompiled(); 345 gl_cache = disk_cache.LoadPrecompiled();
342 } 346 }
@@ -356,8 +360,7 @@ void ShaderCacheOpenGL::LoadDiskCache(u64 title_id, const std::atomic_bool& stop
356 std::atomic_bool gl_cache_failed = false; 360 std::atomic_bool gl_cache_failed = false;
357 361
358 const auto find_precompiled = [&gl_cache](u64 id) { 362 const auto find_precompiled = [&gl_cache](u64 id) {
359 return std::find_if(gl_cache.begin(), gl_cache.end(), 363 return std::ranges::find(gl_cache, id, &ShaderDiskCachePrecompiled::unique_identifier);
360 [id](const auto& entry) { return entry.unique_identifier == id; });
361 }; 364 };
362 365
363 const auto worker = [&](Core::Frontend::GraphicsContext* context, std::size_t begin, 366 const auto worker = [&](Core::Frontend::GraphicsContext* context, std::size_t begin,
@@ -432,8 +435,8 @@ void ShaderCacheOpenGL::LoadDiskCache(u64 title_id, const std::atomic_bool& stop
432 return; 435 return;
433 } 436 }
434 437
435 if (device.UseAssemblyShaders()) { 438 if (device.UseAssemblyShaders() || device.UseDriverCache()) {
436 // Don't store precompiled binaries for assembly shaders. 439 // Don't store precompiled binaries for assembly shaders or when using the driver cache
437 return; 440 return;
438 } 441 }
439 442
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 2e1fa252d..c35b71b6b 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -14,6 +14,7 @@
14#include "common/alignment.h" 14#include "common/alignment.h"
15#include "common/assert.h" 15#include "common/assert.h"
16#include "common/common_types.h" 16#include "common/common_types.h"
17#include "common/div_ceil.h"
17#include "common/logging/log.h" 18#include "common/logging/log.h"
18#include "video_core/engines/maxwell_3d.h" 19#include "video_core/engines/maxwell_3d.h"
19#include "video_core/engines/shader_type.h" 20#include "video_core/engines/shader_type.h"
@@ -877,7 +878,7 @@ private:
877 878
878 u32 binding = device.GetBaseBindings(stage).uniform_buffer; 879 u32 binding = device.GetBaseBindings(stage).uniform_buffer;
879 for (const auto& [index, info] : ir.GetConstantBuffers()) { 880 for (const auto& [index, info] : ir.GetConstantBuffers()) {
880 const u32 num_elements = Common::AlignUp(info.GetSize(), 4) / 4; 881 const u32 num_elements = Common::DivCeil(info.GetSize(), 4 * sizeof(u32));
881 const u32 size = info.IsIndirect() ? MAX_CONSTBUFFER_ELEMENTS : num_elements; 882 const u32 size = info.IsIndirect() ? MAX_CONSTBUFFER_ELEMENTS : num_elements;
882 code.AddLine("layout (std140, binding = {}) uniform {} {{", binding++, 883 code.AddLine("layout (std140, binding = {}) uniform {} {{", binding++,
883 GetConstBufferBlock(index)); 884 GetConstBufferBlock(index));
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h
index 4cd43e425..15f2987eb 100644
--- a/src/video_core/renderer_vulkan/vk_scheduler.h
+++ b/src/video_core/renderer_vulkan/vk_scheduler.h
@@ -6,10 +6,12 @@
6 6
7#include <atomic> 7#include <atomic>
8#include <condition_variable> 8#include <condition_variable>
9#include <cstddef>
9#include <memory> 10#include <memory>
10#include <stack> 11#include <stack>
11#include <thread> 12#include <thread>
12#include <utility> 13#include <utility>
14#include "common/alignment.h"
13#include "common/common_types.h" 15#include "common/common_types.h"
14#include "common/threadsafe_queue.h" 16#include "common/threadsafe_queue.h"
15#include "video_core/vulkan_common/vulkan_wrapper.h" 17#include "video_core/vulkan_common/vulkan_wrapper.h"
@@ -130,12 +132,11 @@ private:
130 using FuncType = TypedCommand<T>; 132 using FuncType = TypedCommand<T>;
131 static_assert(sizeof(FuncType) < sizeof(data), "Lambda is too large"); 133 static_assert(sizeof(FuncType) < sizeof(data), "Lambda is too large");
132 134
135 command_offset = Common::AlignUp(command_offset, alignof(FuncType));
133 if (command_offset > sizeof(data) - sizeof(FuncType)) { 136 if (command_offset > sizeof(data) - sizeof(FuncType)) {
134 return false; 137 return false;
135 } 138 }
136 139 Command* const current_last = last;
137 Command* current_last = last;
138
139 last = new (data.data() + command_offset) FuncType(std::move(command)); 140 last = new (data.data() + command_offset) FuncType(std::move(command));
140 141
141 if (current_last) { 142 if (current_last) {
@@ -143,7 +144,6 @@ private:
143 } else { 144 } else {
144 first = last; 145 first = last;
145 } 146 }
146
147 command_offset += sizeof(FuncType); 147 command_offset += sizeof(FuncType);
148 return true; 148 return true;
149 } 149 }
@@ -156,8 +156,8 @@ private:
156 Command* first = nullptr; 156 Command* first = nullptr;
157 Command* last = nullptr; 157 Command* last = nullptr;
158 158
159 std::size_t command_offset = 0; 159 size_t command_offset = 0;
160 std::array<u8, 0x8000> data{}; 160 alignas(std::max_align_t) std::array<u8, 0x8000> data{};
161 }; 161 };
162 162
163 struct State { 163 struct State {
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp
index 5b4209c72..51f53bc39 100644
--- a/src/video_core/vulkan_common/vulkan_device.cpp
+++ b/src/video_core/vulkan_common/vulkan_device.cpp
@@ -421,6 +421,11 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
421 "Blacklisting RADV for VK_EXT_extended_dynamic state, likely due to a bug in yuzu"); 421 "Blacklisting RADV for VK_EXT_extended_dynamic state, likely due to a bug in yuzu");
422 ext_extended_dynamic_state = false; 422 ext_extended_dynamic_state = false;
423 } 423 }
424 if (is_float16_supported && driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS) {
425 // Intel's compiler crashes when using fp16 on Astral Chain, disable it for the time being.
426 LOG_WARNING(Render_Vulkan, "Blacklisting Intel proprietary from float16 math");
427 is_float16_supported = false;
428 }
424 429
425 graphics_queue = logical.GetQueue(graphics_family); 430 graphics_queue = logical.GetQueue(graphics_family);
426 present_queue = logical.GetQueue(present_family); 431 present_queue = logical.GetQueue(present_family);
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 2e74037d1..e76141125 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -16,6 +16,7 @@
16#include "applets/profile_select.h" 16#include "applets/profile_select.h"
17#include "applets/software_keyboard.h" 17#include "applets/software_keyboard.h"
18#include "applets/web_browser.h" 18#include "applets/web_browser.h"
19#include "common/nvidia_flags.h"
19#include "configuration/configure_input.h" 20#include "configuration/configure_input.h"
20#include "configuration/configure_per_game.h" 21#include "configuration/configure_per_game.h"
21#include "configuration/configure_vibration.h" 22#include "configuration/configure_vibration.h"
@@ -3023,6 +3024,8 @@ int main(int argc, char* argv[]) {
3023 MicroProfileOnThreadCreate("Frontend"); 3024 MicroProfileOnThreadCreate("Frontend");
3024 SCOPE_EXIT({ MicroProfileShutdown(); }); 3025 SCOPE_EXIT({ MicroProfileShutdown(); });
3025 3026
3027 Common::ConfigureNvidiaEnvironmentFlags();
3028
3026 // Init settings params 3029 // Init settings params
3027 QCoreApplication::setOrganizationName(QStringLiteral("yuzu team")); 3030 QCoreApplication::setOrganizationName(QStringLiteral("yuzu team"));
3028 QCoreApplication::setApplicationName(QStringLiteral("yuzu")); 3031 QCoreApplication::setApplicationName(QStringLiteral("yuzu"));
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 4faf62ede..0e1f3bdb3 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -17,6 +17,7 @@
17#include "common/logging/filter.h" 17#include "common/logging/filter.h"
18#include "common/logging/log.h" 18#include "common/logging/log.h"
19#include "common/microprofile.h" 19#include "common/microprofile.h"
20#include "common/nvidia_flags.h"
20#include "common/scm_rev.h" 21#include "common/scm_rev.h"
21#include "common/scope_exit.h" 22#include "common/scope_exit.h"
22#include "common/string_util.h" 23#include "common/string_util.h"
@@ -152,6 +153,8 @@ int main(int argc, char** argv) {
152 MicroProfileOnThreadCreate("EmuThread"); 153 MicroProfileOnThreadCreate("EmuThread");
153 SCOPE_EXIT({ MicroProfileShutdown(); }); 154 SCOPE_EXIT({ MicroProfileShutdown(); });
154 155
156 Common::ConfigureNvidiaEnvironmentFlags();
157
155 if (filepath.empty()) { 158 if (filepath.empty()) {
156 LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); 159 LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
157 return -1; 160 return -1;