early-access version 3414

This commit is contained in:
pineappleEA 2023-02-24 12:03:44 +01:00
parent 9a82fd9a3b
commit 008b77bc59
28 changed files with 325 additions and 98 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 3412. This is the source code for early-access 3414.
## Legal Notice ## Legal Notice

View file

@ -23,6 +23,7 @@ public:
buffer{Common::make_unique_for_overwrite<T[]>(initial_capacity)} {} buffer{Common::make_unique_for_overwrite<T[]>(initial_capacity)} {}
~ScratchBuffer() = default; ~ScratchBuffer() = default;
ScratchBuffer(ScratchBuffer&&) = default;
/// This will only grow the buffer's capacity if size is greater than the current capacity. /// This will only grow the buffer's capacity if size is greater than the current capacity.
/// The previously held data will remain intact. /// The previously held data will remain intact.

View file

@ -59,6 +59,7 @@ void LogSettings() {
values.use_asynchronous_gpu_emulation.GetValue()); values.use_asynchronous_gpu_emulation.GetValue());
log_setting("Renderer_NvdecEmulation", values.nvdec_emulation.GetValue()); log_setting("Renderer_NvdecEmulation", values.nvdec_emulation.GetValue());
log_setting("Renderer_AccelerateASTC", values.accelerate_astc.GetValue()); log_setting("Renderer_AccelerateASTC", values.accelerate_astc.GetValue());
log_setting("Renderer_AsyncASTC", values.async_astc.GetValue());
log_setting("Renderer_UseVsync", values.use_vsync.GetValue()); log_setting("Renderer_UseVsync", values.use_vsync.GetValue());
log_setting("Renderer_ShaderBackend", values.shader_backend.GetValue()); log_setting("Renderer_ShaderBackend", values.shader_backend.GetValue());
log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue()); log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue());
@ -76,6 +77,13 @@ void LogSettings() {
log_setting("Debugging_GDBStub", values.use_gdbstub.GetValue()); log_setting("Debugging_GDBStub", values.use_gdbstub.GetValue());
log_setting("Input_EnableMotion", values.motion_enabled.GetValue()); log_setting("Input_EnableMotion", values.motion_enabled.GetValue());
log_setting("Input_EnableVibration", values.vibration_enabled.GetValue()); log_setting("Input_EnableVibration", values.vibration_enabled.GetValue());
log_setting("Input_EnableTouch", values.touchscreen.enabled);
log_setting("Input_EnableMouse", values.mouse_enabled.GetValue());
log_setting("Input_EnableKeyboard", values.keyboard_enabled.GetValue());
log_setting("Input_EnableRingController", values.enable_ring_controller.GetValue());
log_setting("Input_EnableIrSensor", values.enable_ir_sensor.GetValue());
log_setting("Input_EnableCustomJoycon", values.enable_joycon_driver.GetValue());
log_setting("Input_EnableCustomProController", values.enable_procon_driver.GetValue());
log_setting("Input_EnableRawInput", values.enable_raw_input.GetValue()); log_setting("Input_EnableRawInput", values.enable_raw_input.GetValue());
} }
@ -212,6 +220,7 @@ void RestoreGlobalState(bool is_powered_on) {
values.use_asynchronous_gpu_emulation.SetGlobal(true); values.use_asynchronous_gpu_emulation.SetGlobal(true);
values.nvdec_emulation.SetGlobal(true); values.nvdec_emulation.SetGlobal(true);
values.accelerate_astc.SetGlobal(true); values.accelerate_astc.SetGlobal(true);
values.async_astc.SetGlobal(true);
values.use_vsync.SetGlobal(true); values.use_vsync.SetGlobal(true);
values.shader_backend.SetGlobal(true); values.shader_backend.SetGlobal(true);
values.use_asynchronous_shaders.SetGlobal(true); values.use_asynchronous_shaders.SetGlobal(true);

View file

@ -453,6 +453,7 @@ struct Values {
SwitchableSetting<bool> use_asynchronous_gpu_emulation{true, "use_asynchronous_gpu_emulation"}; SwitchableSetting<bool> use_asynchronous_gpu_emulation{true, "use_asynchronous_gpu_emulation"};
SwitchableSetting<NvdecEmulation> nvdec_emulation{NvdecEmulation::GPU, "nvdec_emulation"}; SwitchableSetting<NvdecEmulation> nvdec_emulation{NvdecEmulation::GPU, "nvdec_emulation"};
SwitchableSetting<bool> accelerate_astc{true, "accelerate_astc"}; SwitchableSetting<bool> accelerate_astc{true, "accelerate_astc"};
SwitchableSetting<bool> async_astc{false, "async_astc"};
SwitchableSetting<bool> use_vsync{true, "use_vsync"}; SwitchableSetting<bool> use_vsync{true, "use_vsync"};
SwitchableSetting<ShaderBackend, true> shader_backend{ShaderBackend::GLSL, ShaderBackend::GLSL, SwitchableSetting<ShaderBackend, true> shader_backend{ShaderBackend::GLSL, ShaderBackend::GLSL,
ShaderBackend::SPIRV, "shader_backend"}; ShaderBackend::SPIRV, "shader_backend"};

View file

@ -363,7 +363,17 @@ void EmulatedController::ReloadInput() {
SetMotion(callback, index); SetMotion(callback, index);
}, },
}); });
motion_devices[index]->ForceUpdate();
// Restore motion state
auto& emulated_motion = controller.motion_values[index].emulated;
auto& motion = controller.motion_state[index];
emulated_motion.ResetRotations();
emulated_motion.ResetQuaternion();
motion.accel = emulated_motion.GetAcceleration();
motion.gyro = emulated_motion.GetGyroscope();
motion.rotation = emulated_motion.GetRotations();
motion.orientation = emulated_motion.GetOrientation();
motion.is_at_rest = !emulated_motion.IsMoving(motion_sensitivity);
} }
for (std::size_t index = 0; index < camera_devices.size(); ++index) { for (std::size_t index = 0; index < camera_devices.size(); ++index) {

View file

@ -19,52 +19,53 @@ void EmulatedDevices::ReloadFromSettings() {
void EmulatedDevices::ReloadInput() { void EmulatedDevices::ReloadInput() {
// If you load any device here add the equivalent to the UnloadInput() function // If you load any device here add the equivalent to the UnloadInput() function
// Native Mouse is mapped on port 1, pad 0
const Common::ParamPackage mouse_params{"engine:mouse,port:1,pad:0"};
// Keyboard keys is mapped on port 1, pad 0 for normal keys, pad 1 for moddifier keys
const Common::ParamPackage keyboard_params{"engine:keyboard,port:1"};
std::size_t key_index = 0; std::size_t key_index = 0;
for (auto& mouse_device : mouse_button_devices) { for (auto& mouse_device : mouse_button_devices) {
Common::ParamPackage mouse_params; Common::ParamPackage mouse_button_params = mouse_params;
mouse_params.Set("engine", "mouse"); mouse_button_params.Set("button", static_cast<int>(key_index));
mouse_params.Set("button", static_cast<int>(key_index)); mouse_device = Common::Input::CreateInputDevice(mouse_button_params);
mouse_device = Common::Input::CreateInputDevice(mouse_params);
key_index++; key_index++;
} }
mouse_stick_device = Common::ParamPackage mouse_position_params = mouse_params;
Common::Input::CreateInputDeviceFromString("engine:mouse,axis_x:0,axis_y:1"); mouse_position_params.Set("axis_x", 0);
mouse_position_params.Set("axis_y", 1);
mouse_position_params.Set("deadzone", 0.0f);
mouse_position_params.Set("range", 1.0f);
mouse_position_params.Set("threshold", 0.0f);
mouse_stick_device = Common::Input::CreateInputDevice(mouse_position_params);
// First two axis are reserved for mouse position // First two axis are reserved for mouse position
key_index = 2; key_index = 2;
for (auto& mouse_device : mouse_analog_devices) { for (auto& mouse_device : mouse_wheel_devices) {
// Mouse axis are only mapped on port 1, pad 0 Common::ParamPackage mouse_wheel_params = mouse_params;
Common::ParamPackage mouse_params; mouse_wheel_params.Set("axis", static_cast<int>(key_index));
mouse_params.Set("engine", "mouse"); mouse_device = Common::Input::CreateInputDevice(mouse_wheel_params);
mouse_params.Set("axis", static_cast<int>(key_index));
mouse_params.Set("port", 1);
mouse_params.Set("pad", 0);
mouse_device = Common::Input::CreateInputDevice(mouse_params);
key_index++; key_index++;
} }
key_index = 0; key_index = 0;
for (auto& keyboard_device : keyboard_devices) { for (auto& keyboard_device : keyboard_devices) {
// Keyboard keys are only mapped on port 1, pad 0 Common::ParamPackage keyboard_key_params = keyboard_params;
Common::ParamPackage keyboard_params; keyboard_key_params.Set("button", static_cast<int>(key_index));
keyboard_params.Set("engine", "keyboard"); keyboard_key_params.Set("pad", 0);
keyboard_params.Set("button", static_cast<int>(key_index)); keyboard_device = Common::Input::CreateInputDevice(keyboard_key_params);
keyboard_params.Set("port", 1);
keyboard_params.Set("pad", 0);
keyboard_device = Common::Input::CreateInputDevice(keyboard_params);
key_index++; key_index++;
} }
key_index = 0; key_index = 0;
for (auto& keyboard_device : keyboard_modifier_devices) { for (auto& keyboard_device : keyboard_modifier_devices) {
// Keyboard moddifiers are only mapped on port 1, pad 1 Common::ParamPackage keyboard_moddifier_params = keyboard_params;
Common::ParamPackage keyboard_params; keyboard_moddifier_params.Set("button", static_cast<int>(key_index));
keyboard_params.Set("engine", "keyboard"); keyboard_moddifier_params.Set("pad", 1);
keyboard_params.Set("button", static_cast<int>(key_index)); keyboard_device = Common::Input::CreateInputDevice(keyboard_moddifier_params);
keyboard_params.Set("port", 1);
keyboard_params.Set("pad", 1);
keyboard_device = Common::Input::CreateInputDevice(keyboard_params);
key_index++; key_index++;
} }
@ -80,14 +81,14 @@ void EmulatedDevices::ReloadInput() {
}); });
} }
for (std::size_t index = 0; index < mouse_analog_devices.size(); ++index) { for (std::size_t index = 0; index < mouse_wheel_devices.size(); ++index) {
if (!mouse_analog_devices[index]) { if (!mouse_wheel_devices[index]) {
continue; continue;
} }
mouse_analog_devices[index]->SetCallback({ mouse_wheel_devices[index]->SetCallback({
.on_change = .on_change =
[this, index](const Common::Input::CallbackStatus& callback) { [this, index](const Common::Input::CallbackStatus& callback) {
SetMouseAnalog(callback, index); SetMouseWheel(callback, index);
}, },
}); });
} }
@ -95,7 +96,9 @@ void EmulatedDevices::ReloadInput() {
if (mouse_stick_device) { if (mouse_stick_device) {
mouse_stick_device->SetCallback({ mouse_stick_device->SetCallback({
.on_change = .on_change =
[this](const Common::Input::CallbackStatus& callback) { SetMouseStick(callback); }, [this](const Common::Input::CallbackStatus& callback) {
SetMousePosition(callback);
},
}); });
} }
@ -128,7 +131,7 @@ void EmulatedDevices::UnloadInput() {
for (auto& button : mouse_button_devices) { for (auto& button : mouse_button_devices) {
button.reset(); button.reset();
} }
for (auto& analog : mouse_analog_devices) { for (auto& analog : mouse_wheel_devices) {
analog.reset(); analog.reset();
} }
mouse_stick_device.reset(); mouse_stick_device.reset();
@ -362,18 +365,18 @@ void EmulatedDevices::SetMouseButton(const Common::Input::CallbackStatus& callba
TriggerOnChange(DeviceTriggerType::Mouse); TriggerOnChange(DeviceTriggerType::Mouse);
} }
void EmulatedDevices::SetMouseAnalog(const Common::Input::CallbackStatus& callback, void EmulatedDevices::SetMouseWheel(const Common::Input::CallbackStatus& callback,
std::size_t index) { std::size_t index) {
if (index >= device_status.mouse_analog_values.size()) { if (index >= device_status.mouse_wheel_values.size()) {
return; return;
} }
std::unique_lock lock{mutex}; std::unique_lock lock{mutex};
const auto analog_value = TransformToAnalog(callback); const auto analog_value = TransformToAnalog(callback);
device_status.mouse_analog_values[index] = analog_value; device_status.mouse_wheel_values[index] = analog_value;
if (is_configuring) { if (is_configuring) {
device_status.mouse_position_state = {}; device_status.mouse_wheel_state = {};
lock.unlock(); lock.unlock();
TriggerOnChange(DeviceTriggerType::Mouse); TriggerOnChange(DeviceTriggerType::Mouse);
return; return;
@ -392,7 +395,7 @@ void EmulatedDevices::SetMouseAnalog(const Common::Input::CallbackStatus& callba
TriggerOnChange(DeviceTriggerType::Mouse); TriggerOnChange(DeviceTriggerType::Mouse);
} }
void EmulatedDevices::SetMouseStick(const Common::Input::CallbackStatus& callback) { void EmulatedDevices::SetMousePosition(const Common::Input::CallbackStatus& callback) {
std::unique_lock lock{mutex}; std::unique_lock lock{mutex};
const auto touch_value = TransformToTouch(callback); const auto touch_value = TransformToTouch(callback);

View file

@ -23,8 +23,8 @@ using KeyboardModifierDevices = std::array<std::unique_ptr<Common::Input::InputD
Settings::NativeKeyboard::NumKeyboardMods>; Settings::NativeKeyboard::NumKeyboardMods>;
using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice>,
Settings::NativeMouseButton::NumMouseButtons>; Settings::NativeMouseButton::NumMouseButtons>;
using MouseAnalogDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, using MouseWheelDevices = std::array<std::unique_ptr<Common::Input::InputDevice>,
Settings::NativeMouseWheel::NumMouseWheels>; Settings::NativeMouseWheel::NumMouseWheels>;
using MouseStickDevice = std::unique_ptr<Common::Input::InputDevice>; using MouseStickDevice = std::unique_ptr<Common::Input::InputDevice>;
using MouseButtonParams = using MouseButtonParams =
@ -36,7 +36,7 @@ using KeyboardModifierValues =
std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardMods>; std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardMods>;
using MouseButtonValues = using MouseButtonValues =
std::array<Common::Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>; std::array<Common::Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>;
using MouseAnalogValues = using MouseWheelValues =
std::array<Common::Input::AnalogStatus, Settings::NativeMouseWheel::NumMouseWheels>; std::array<Common::Input::AnalogStatus, Settings::NativeMouseWheel::NumMouseWheels>;
using MouseStickValue = Common::Input::TouchStatus; using MouseStickValue = Common::Input::TouchStatus;
@ -50,7 +50,7 @@ struct DeviceStatus {
KeyboardValues keyboard_values{}; KeyboardValues keyboard_values{};
KeyboardModifierValues keyboard_moddifier_values{}; KeyboardModifierValues keyboard_moddifier_values{};
MouseButtonValues mouse_button_values{}; MouseButtonValues mouse_button_values{};
MouseAnalogValues mouse_analog_values{}; MouseWheelValues mouse_wheel_values{};
MouseStickValue mouse_stick_value{}; MouseStickValue mouse_stick_value{};
// Data for HID serices // Data for HID serices
@ -111,15 +111,6 @@ public:
/// Reverts any mapped changes made that weren't saved /// Reverts any mapped changes made that weren't saved
void RestoreConfig(); void RestoreConfig();
// Returns the current mapped ring device
Common::ParamPackage GetRingParam() const;
/**
* Updates the current mapped ring device
* @param param ParamPackage with ring sensor data to be mapped
*/
void SetRingParam(Common::ParamPackage param);
/// Returns the latest status of button input from the keyboard with parameters /// Returns the latest status of button input from the keyboard with parameters
KeyboardValues GetKeyboardValues() const; KeyboardValues GetKeyboardValues() const;
@ -187,19 +178,13 @@ private:
* @param callback A CallbackStatus containing the wheel status * @param callback A CallbackStatus containing the wheel status
* @param index wheel ID to be updated * @param index wheel ID to be updated
*/ */
void SetMouseAnalog(const Common::Input::CallbackStatus& callback, std::size_t index); void SetMouseWheel(const Common::Input::CallbackStatus& callback, std::size_t index);
/** /**
* Updates the mouse position status of the mouse device * Updates the mouse position status of the mouse device
* @param callback A CallbackStatus containing the position status * @param callback A CallbackStatus containing the position status
*/ */
void SetMouseStick(const Common::Input::CallbackStatus& callback); void SetMousePosition(const Common::Input::CallbackStatus& callback);
/**
* Updates the ring analog sensor status of the ring controller
* @param callback A CallbackStatus containing the force status
*/
void SetRingAnalog(const Common::Input::CallbackStatus& callback);
/** /**
* Triggers a callback that something has changed on the device status * Triggers a callback that something has changed on the device status
@ -212,7 +197,7 @@ private:
KeyboardDevices keyboard_devices; KeyboardDevices keyboard_devices;
KeyboardModifierDevices keyboard_modifier_devices; KeyboardModifierDevices keyboard_modifier_devices;
MouseButtonDevices mouse_button_devices; MouseButtonDevices mouse_button_devices;
MouseAnalogDevices mouse_analog_devices; MouseWheelDevices mouse_wheel_devices;
MouseStickDevice mouse_stick_device; MouseStickDevice mouse_stick_device;
mutable std::mutex mutex; mutable std::mutex mutex;

View file

@ -10,6 +10,8 @@ MotionInput::MotionInput() {
// Initialize PID constants with default values // Initialize PID constants with default values
SetPID(0.3f, 0.005f, 0.0f); SetPID(0.3f, 0.005f, 0.0f);
SetGyroThreshold(ThresholdStandard); SetGyroThreshold(ThresholdStandard);
ResetQuaternion();
ResetRotations();
} }
void MotionInput::SetPID(f32 new_kp, f32 new_ki, f32 new_kd) { void MotionInput::SetPID(f32 new_kp, f32 new_ki, f32 new_kd) {
@ -20,11 +22,19 @@ void MotionInput::SetPID(f32 new_kp, f32 new_ki, f32 new_kd) {
void MotionInput::SetAcceleration(const Common::Vec3f& acceleration) { void MotionInput::SetAcceleration(const Common::Vec3f& acceleration) {
accel = acceleration; accel = acceleration;
accel.x = std::clamp(accel.x, -AccelMaxValue, AccelMaxValue);
accel.y = std::clamp(accel.y, -AccelMaxValue, AccelMaxValue);
accel.z = std::clamp(accel.z, -AccelMaxValue, AccelMaxValue);
} }
void MotionInput::SetGyroscope(const Common::Vec3f& gyroscope) { void MotionInput::SetGyroscope(const Common::Vec3f& gyroscope) {
gyro = gyroscope - gyro_bias; gyro = gyroscope - gyro_bias;
gyro.x = std::clamp(gyro.x, -GyroMaxValue, GyroMaxValue);
gyro.y = std::clamp(gyro.y, -GyroMaxValue, GyroMaxValue);
gyro.z = std::clamp(gyro.z, -GyroMaxValue, GyroMaxValue);
// Auto adjust drift to minimize drift // Auto adjust drift to minimize drift
if (!IsMoving(IsAtRestRelaxed)) { if (!IsMoving(IsAtRestRelaxed)) {
gyro_bias = (gyro_bias * 0.9999f) + (gyroscope * 0.0001f); gyro_bias = (gyro_bias * 0.9999f) + (gyroscope * 0.0001f);
@ -61,6 +71,10 @@ void MotionInput::ResetRotations() {
rotations = {}; rotations = {};
} }
void MotionInput::ResetQuaternion() {
quat = {{0.0f, 0.0f, -1.0f}, 0.0f};
}
bool MotionInput::IsMoving(f32 sensitivity) const { bool MotionInput::IsMoving(f32 sensitivity) const {
return gyro.Length() >= sensitivity || accel.Length() <= 0.9f || accel.Length() >= 1.1f; return gyro.Length() >= sensitivity || accel.Length() <= 0.9f || accel.Length() >= 1.1f;
} }

View file

@ -20,6 +20,9 @@ public:
static constexpr float IsAtRestStandard = 0.01f; static constexpr float IsAtRestStandard = 0.01f;
static constexpr float IsAtRestThight = 0.005f; static constexpr float IsAtRestThight = 0.005f;
static constexpr float GyroMaxValue = 5.0f;
static constexpr float AccelMaxValue = 7.0f;
explicit MotionInput(); explicit MotionInput();
MotionInput(const MotionInput&) = default; MotionInput(const MotionInput&) = default;
@ -40,6 +43,7 @@ public:
void EnableReset(bool reset); void EnableReset(bool reset);
void ResetRotations(); void ResetRotations();
void ResetQuaternion();
void UpdateRotation(u64 elapsed_time); void UpdateRotation(u64 elapsed_time);
void UpdateOrientation(u64 elapsed_time); void UpdateOrientation(u64 elapsed_time);
@ -69,7 +73,7 @@ private:
Common::Vec3f derivative_error; Common::Vec3f derivative_error;
// Quaternion containing the device orientation // Quaternion containing the device orientation
Common::Quaternion<f32> quat{{0.0f, 0.0f, -1.0f}, 0.0f}; Common::Quaternion<f32> quat;
// Number of full rotations in each axis // Number of full rotations in each axis
Common::Vec3f rotations; Common::Vec3f rotations;

View file

@ -65,6 +65,11 @@ void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
} }
void Controller_Gesture::ReadTouchInput() { void Controller_Gesture::ReadTouchInput() {
if (!Settings::values.touchscreen.enabled) {
fingers = {};
return;
}
const auto touch_status = console->GetTouch(); const auto touch_status = console->GetTouch();
for (std::size_t id = 0; id < fingers.size(); ++id) { for (std::size_t id = 0; id < fingers.size(); ++id) {
fingers[id] = touch_status[id]; fingers[id] = touch_status[id];

View file

@ -33,10 +33,11 @@ void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
return; return;
} }
next_state = {};
const auto& last_entry = shared_memory->mouse_lifo.ReadCurrentEntry().state; const auto& last_entry = shared_memory->mouse_lifo.ReadCurrentEntry().state;
next_state.sampling_number = last_entry.sampling_number + 1; next_state.sampling_number = last_entry.sampling_number + 1;
next_state.attribute.raw = 0;
if (Settings::values.mouse_enabled) { if (Settings::values.mouse_enabled) {
const auto& mouse_button_state = emulated_devices->GetMouseButtons(); const auto& mouse_button_state = emulated_devices->GetMouseButtons();
const auto& mouse_position_state = emulated_devices->GetMousePosition(); const auto& mouse_position_state = emulated_devices->GetMousePosition();

View file

@ -58,6 +58,11 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin
} }
if (!finger.pressed && current_touch.pressed) { if (!finger.pressed && current_touch.pressed) {
// Ignore all touch fingers if disabled
if (!Settings::values.touchscreen.enabled) {
continue;
}
finger.attribute.start_touch.Assign(1); finger.attribute.start_touch.Assign(1);
finger.pressed = true; finger.pressed = true;
finger.position = current_touch.position; finger.position = current_touch.position;

View file

@ -10,17 +10,25 @@
#include "input_common/drivers/mouse.h" #include "input_common/drivers/mouse.h"
namespace InputCommon { namespace InputCommon {
constexpr int update_time = 10;
constexpr float default_stick_sensitivity = 0.022f;
constexpr float default_motion_sensitivity = 0.008f;
constexpr int mouse_axis_x = 0; constexpr int mouse_axis_x = 0;
constexpr int mouse_axis_y = 1; constexpr int mouse_axis_y = 1;
constexpr int wheel_axis_x = 2; constexpr int wheel_axis_x = 2;
constexpr int wheel_axis_y = 3; constexpr int wheel_axis_y = 3;
constexpr int motion_wheel_y = 4;
constexpr PadIdentifier identifier = { constexpr PadIdentifier identifier = {
.guid = Common::UUID{}, .guid = Common::UUID{},
.port = 0, .port = 0,
.pad = 0, .pad = 0,
}; };
constexpr PadIdentifier motion_identifier = {
.guid = Common::UUID{},
.port = 0,
.pad = 1,
};
constexpr PadIdentifier real_mouse_identifier = { constexpr PadIdentifier real_mouse_identifier = {
.guid = Common::UUID{}, .guid = Common::UUID{},
.port = 1, .port = 1,
@ -37,47 +45,87 @@ Mouse::Mouse(std::string input_engine_) : InputEngine(std::move(input_engine_))
PreSetController(identifier); PreSetController(identifier);
PreSetController(real_mouse_identifier); PreSetController(real_mouse_identifier);
PreSetController(touch_identifier); PreSetController(touch_identifier);
PreSetController(motion_identifier);
// Initialize all mouse axis // Initialize all mouse axis
PreSetAxis(identifier, mouse_axis_x); PreSetAxis(identifier, mouse_axis_x);
PreSetAxis(identifier, mouse_axis_y); PreSetAxis(identifier, mouse_axis_y);
PreSetAxis(identifier, wheel_axis_x); PreSetAxis(identifier, wheel_axis_x);
PreSetAxis(identifier, wheel_axis_y); PreSetAxis(identifier, wheel_axis_y);
PreSetAxis(identifier, motion_wheel_y);
PreSetAxis(real_mouse_identifier, mouse_axis_x); PreSetAxis(real_mouse_identifier, mouse_axis_x);
PreSetAxis(real_mouse_identifier, mouse_axis_y); PreSetAxis(real_mouse_identifier, mouse_axis_y);
PreSetAxis(touch_identifier, mouse_axis_x); PreSetAxis(touch_identifier, mouse_axis_x);
PreSetAxis(touch_identifier, mouse_axis_y); PreSetAxis(touch_identifier, mouse_axis_y);
// Initialize variables
mouse_origin = {};
last_mouse_position = {};
wheel_position = {};
last_mouse_change = {};
last_motion_change = {};
update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); }); update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); });
} }
void Mouse::UpdateThread(std::stop_token stop_token) { void Mouse::UpdateThread(std::stop_token stop_token) {
Common::SetCurrentThreadName("Mouse"); Common::SetCurrentThreadName("Mouse");
constexpr int update_time = 10;
while (!stop_token.stop_requested()) { while (!stop_token.stop_requested()) {
if (Settings::values.mouse_panning) { UpdateStickInput();
// Slow movement by 4% UpdateMotionInput();
last_mouse_change *= 0.96f;
const float sensitivity =
Settings::values.mouse_panning_sensitivity.GetValue() * 0.022f;
SetAxis(identifier, mouse_axis_x, last_mouse_change.x * sensitivity);
SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity);
}
SetAxis(identifier, motion_wheel_y, 0.0f); if (mouse_panning_timeout++ > 20) {
if (mouse_panning_timout++ > 20) {
StopPanning(); StopPanning();
} }
std::this_thread::sleep_for(std::chrono::milliseconds(update_time)); std::this_thread::sleep_for(std::chrono::milliseconds(update_time));
} }
} }
void Mouse::UpdateStickInput() {
if (!Settings::values.mouse_panning) {
return;
}
const float sensitivity =
Settings::values.mouse_panning_sensitivity.GetValue() * default_stick_sensitivity;
// Slow movement by 4%
last_mouse_change *= 0.96f;
SetAxis(identifier, mouse_axis_x, last_mouse_change.x * sensitivity);
SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity);
}
void Mouse::UpdateMotionInput() {
const float sensitivity =
Settings::values.mouse_panning_sensitivity.GetValue() * default_motion_sensitivity;
// Slow movement by 7%
if (Settings::values.mouse_panning) {
last_motion_change *= 0.93f;
} else {
last_motion_change.z *= 0.93f;
}
const BasicMotion motion_data{
.gyro_x = last_motion_change.x * sensitivity,
.gyro_y = last_motion_change.y * sensitivity,
.gyro_z = last_motion_change.z * sensitivity,
.accel_x = 0,
.accel_y = 0,
.accel_z = 0,
.delta_timestamp = update_time * 1000,
};
SetMotion(motion_identifier, 0, motion_data);
}
void Mouse::Move(int x, int y, int center_x, int center_y) { void Mouse::Move(int x, int y, int center_x, int center_y) {
if (Settings::values.mouse_panning) { if (Settings::values.mouse_panning) {
mouse_panning_timeout = 0;
auto mouse_change = auto mouse_change =
(Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>(); (Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>();
mouse_panning_timout = 0; Common::Vec3<float> motion_change{-mouse_change.y, -mouse_change.x, last_motion_change.z};
const auto move_distance = mouse_change.Length(); const auto move_distance = mouse_change.Length();
if (move_distance == 0) { if (move_distance == 0) {
@ -93,6 +141,7 @@ void Mouse::Move(int x, int y, int center_x, int center_y) {
// Average mouse movements // Average mouse movements
last_mouse_change = (last_mouse_change * 0.91f) + (mouse_change * 0.09f); last_mouse_change = (last_mouse_change * 0.91f) + (mouse_change * 0.09f);
last_motion_change = (last_motion_change * 0.69f) + (motion_change * 0.31f);
const auto last_move_distance = last_mouse_change.Length(); const auto last_move_distance = last_mouse_change.Length();
@ -116,6 +165,12 @@ void Mouse::Move(int x, int y, int center_x, int center_y) {
const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue() * 0.0012f; const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue() * 0.0012f;
SetAxis(identifier, mouse_axis_x, static_cast<float>(mouse_move.x) * sensitivity); SetAxis(identifier, mouse_axis_x, static_cast<float>(mouse_move.x) * sensitivity);
SetAxis(identifier, mouse_axis_y, static_cast<float>(-mouse_move.y) * sensitivity); SetAxis(identifier, mouse_axis_y, static_cast<float>(-mouse_move.y) * sensitivity);
last_motion_change = {
static_cast<float>(-mouse_move.y) / 50.0f,
static_cast<float>(-mouse_move.x) / 50.0f,
last_motion_change.z,
};
} }
} }
@ -157,15 +212,19 @@ void Mouse::ReleaseButton(MouseButton button) {
SetAxis(identifier, mouse_axis_x, 0); SetAxis(identifier, mouse_axis_x, 0);
SetAxis(identifier, mouse_axis_y, 0); SetAxis(identifier, mouse_axis_y, 0);
} }
last_motion_change.x = 0;
last_motion_change.y = 0;
button_pressed = false; button_pressed = false;
} }
void Mouse::MouseWheelChange(int x, int y) { void Mouse::MouseWheelChange(int x, int y) {
wheel_position.x += x; wheel_position.x += x;
wheel_position.y += y; wheel_position.y += y;
last_motion_change.z += static_cast<f32>(y) / 100.0f;
SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x)); SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x));
SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y)); SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y));
SetAxis(identifier, motion_wheel_y, static_cast<f32>(y) / 100.0f);
} }
void Mouse::ReleaseAllButtons() { void Mouse::ReleaseAllButtons() {
@ -234,6 +293,9 @@ Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params)
if (params.Has("axis_x") && params.Has("axis_y") && params.Has("axis_z")) { if (params.Has("axis_x") && params.Has("axis_y") && params.Has("axis_z")) {
return Common::Input::ButtonNames::Engine; return Common::Input::ButtonNames::Engine;
} }
if (params.Has("motion")) {
return Common::Input::ButtonNames::Engine;
}
return Common::Input::ButtonNames::Invalid; return Common::Input::ButtonNames::Invalid;
} }

View file

@ -96,6 +96,8 @@ public:
private: private:
void UpdateThread(std::stop_token stop_token); void UpdateThread(std::stop_token stop_token);
void UpdateStickInput();
void UpdateMotionInput();
void StopPanning(); void StopPanning();
Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const;
@ -103,9 +105,10 @@ private:
Common::Vec2<int> mouse_origin; Common::Vec2<int> mouse_origin;
Common::Vec2<int> last_mouse_position; Common::Vec2<int> last_mouse_position;
Common::Vec2<float> last_mouse_change; Common::Vec2<float> last_mouse_change;
Common::Vec3<float> last_motion_change;
Common::Vec2<int> wheel_position; Common::Vec2<int> wheel_position;
bool button_pressed; bool button_pressed;
int mouse_panning_timout{}; int mouse_panning_timeout{};
std::jthread update_thread; std::jthread update_thread;
}; };

View file

@ -142,14 +142,10 @@ void MappingFactory::RegisterMotion(const MappingData& data) {
new_input.Set("port", static_cast<int>(data.pad.port)); new_input.Set("port", static_cast<int>(data.pad.port));
new_input.Set("pad", static_cast<int>(data.pad.pad)); new_input.Set("pad", static_cast<int>(data.pad.pad));
// If engine is mouse map the mouse position as 3 axis motion // If engine is mouse map it automatically to mouse motion
if (data.engine == "mouse") { if (data.engine == "mouse") {
new_input.Set("axis_x", 1); new_input.Set("motion", 0);
new_input.Set("invert_x", "-"); new_input.Set("pad", 1);
new_input.Set("axis_y", 0);
new_input.Set("axis_z", 4);
new_input.Set("range", 1.0f);
new_input.Set("deadzone", 0.0f);
input_queue.Push(new_input); input_queue.Push(new_input);
return; return;
} }

View file

@ -228,8 +228,9 @@ void ApplySwizzle(GLuint handle, PixelFormat format, std::array<SwizzleSource, 4
[[nodiscard]] bool CanBeAccelerated(const TextureCacheRuntime& runtime, [[nodiscard]] bool CanBeAccelerated(const TextureCacheRuntime& runtime,
const VideoCommon::ImageInfo& info) { const VideoCommon::ImageInfo& info) {
if (IsPixelFormatASTC(info.format)) { if (IsPixelFormatASTC(info.format) && !runtime.HasNativeASTC()) {
return !runtime.HasNativeASTC() && Settings::values.accelerate_astc.GetValue(); return Settings::values.accelerate_astc.GetValue() &&
!Settings::values.async_astc.GetValue();
} }
// Disable other accelerated uploads for now as they don't implement swizzled uploads // Disable other accelerated uploads for now as they don't implement swizzled uploads
return false; return false;
@ -258,6 +259,14 @@ void ApplySwizzle(GLuint handle, PixelFormat format, std::array<SwizzleSource, 4
return format_info.compatibility_class == store_class; return format_info.compatibility_class == store_class;
} }
[[nodiscard]] bool CanBeDecodedAsync(const TextureCacheRuntime& runtime,
const VideoCommon::ImageInfo& info) {
if (IsPixelFormatASTC(info.format) && !runtime.HasNativeASTC()) {
return Settings::values.async_astc.GetValue();
}
return false;
}
[[nodiscard]] CopyOrigin MakeCopyOrigin(VideoCommon::Offset3D offset, [[nodiscard]] CopyOrigin MakeCopyOrigin(VideoCommon::Offset3D offset,
VideoCommon::SubresourceLayers subresource, GLenum target) { VideoCommon::SubresourceLayers subresource, GLenum target) {
switch (target) { switch (target) {
@ -721,7 +730,9 @@ std::optional<size_t> TextureCacheRuntime::StagingBuffers::FindBuffer(size_t req
Image::Image(TextureCacheRuntime& runtime_, const VideoCommon::ImageInfo& info_, GPUVAddr gpu_addr_, Image::Image(TextureCacheRuntime& runtime_, const VideoCommon::ImageInfo& info_, GPUVAddr gpu_addr_,
VAddr cpu_addr_) VAddr cpu_addr_)
: VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), runtime{&runtime_} { : VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), runtime{&runtime_} {
if (CanBeAccelerated(*runtime, info)) { if (CanBeDecodedAsync(*runtime, info)) {
flags |= ImageFlagBits::AsynchronousDecode;
} else if (CanBeAccelerated(*runtime, info)) {
flags |= ImageFlagBits::AcceleratedUpload; flags |= ImageFlagBits::AcceleratedUpload;
} }
if (IsConverted(runtime->device, info.format, info.type)) { if (IsConverted(runtime->device, info.format, info.type)) {

View file

@ -1262,11 +1262,12 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
commit(runtime_.memory_allocator.Commit(original_image, MemoryUsage::DeviceLocal)), commit(runtime_.memory_allocator.Commit(original_image, MemoryUsage::DeviceLocal)),
aspect_mask(ImageAspectMask(info.format)) { aspect_mask(ImageAspectMask(info.format)) {
if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) { if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) {
if (Settings::values.accelerate_astc.GetValue()) { if (Settings::values.async_astc.GetValue()) {
flags |= VideoCommon::ImageFlagBits::AsynchronousDecode;
} else if (Settings::values.accelerate_astc.GetValue()) {
flags |= VideoCommon::ImageFlagBits::AcceleratedUpload; flags |= VideoCommon::ImageFlagBits::AcceleratedUpload;
} else {
flags |= VideoCommon::ImageFlagBits::Converted;
} }
flags |= VideoCommon::ImageFlagBits::Converted;
flags |= VideoCommon::ImageFlagBits::CostlyLoad; flags |= VideoCommon::ImageFlagBits::CostlyLoad;
} }
if (runtime->device.HasDebuggingToolAttached()) { if (runtime->device.HasDebuggingToolAttached()) {

View file

@ -38,6 +38,9 @@ enum class ImageFlagBits : u32 {
Rescaled = 1 << 13, Rescaled = 1 << 13,
CheckingRescalable = 1 << 14, CheckingRescalable = 1 << 14,
IsRescalable = 1 << 15, IsRescalable = 1 << 15,
AsynchronousDecode = 1 << 16,
IsDecoding = 1 << 17, ///< Is currently being decoded asynchornously.
}; };
DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits) DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits)

View file

@ -85,6 +85,11 @@ void TextureCache<P>::RunGarbageCollector() {
} }
--num_iterations; --num_iterations;
auto& image = slot_images[image_id]; auto& image = slot_images[image_id];
if (True(image.flags & ImageFlagBits::IsDecoding)) {
// This image is still being decoded, deleting it will invalidate the slot
// used by the async decoder thread.
return false;
}
const bool must_download = const bool must_download =
image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap); image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap);
if (!high_priority_mode && if (!high_priority_mode &&
@ -133,6 +138,8 @@ void TextureCache<P>::TickFrame() {
sentenced_images.Tick(); sentenced_images.Tick();
sentenced_framebuffers.Tick(); sentenced_framebuffers.Tick();
sentenced_image_view.Tick(); sentenced_image_view.Tick();
TickAsyncDecode();
runtime.TickFrame(); runtime.TickFrame();
critical_gc = 0; critical_gc = 0;
++frame_tick; ++frame_tick;
@ -777,6 +784,10 @@ void TextureCache<P>::RefreshContents(Image& image, ImageId image_id) {
LOG_WARNING(HW_GPU, "MSAA image uploads are not implemented"); LOG_WARNING(HW_GPU, "MSAA image uploads are not implemented");
return; return;
} }
if (True(image.flags & ImageFlagBits::AsynchronousDecode)) {
QueueAsyncDecode(image, image_id);
return;
}
auto staging = runtime.UploadStagingBuffer(MapSizeBytes(image)); auto staging = runtime.UploadStagingBuffer(MapSizeBytes(image));
UploadImageContents(image, staging); UploadImageContents(image, staging);
runtime.InsertUploadMemoryBarrier(); runtime.InsertUploadMemoryBarrier();
@ -989,6 +1000,65 @@ u64 TextureCache<P>::GetScaledImageSizeBytes(const ImageBase& image) {
return fitted_size; return fitted_size;
} }
template <class P>
void TextureCache<P>::QueueAsyncDecode(Image& image, ImageId image_id) {
UNIMPLEMENTED_IF(False(image.flags & ImageFlagBits::Converted));
LOG_INFO(HW_GPU, "Queuing async texture decode");
image.flags |= ImageFlagBits::IsDecoding;
auto decode = std::make_unique<AsyncDecodeContext>();
auto* decode_ptr = decode.get();
decode->image_id = image_id;
async_decodes.push_back(std::move(decode));
Common::ScratchBuffer<u8> local_unswizzle_data_buffer(image.unswizzled_size_bytes);
const size_t guest_size_bytes = image.guest_size_bytes;
swizzle_data_buffer.resize_destructive(guest_size_bytes);
gpu_memory->ReadBlockUnsafe(image.gpu_addr, swizzle_data_buffer.data(), guest_size_bytes);
auto copies = UnswizzleImage(*gpu_memory, image.gpu_addr, image.info, swizzle_data_buffer,
local_unswizzle_data_buffer);
const size_t out_size = MapSizeBytes(image);
auto func = [out_size, copies, info = image.info,
input = std::move(local_unswizzle_data_buffer),
async_decode = decode_ptr]() mutable {
async_decode->decoded_data.resize_destructive(out_size);
std::span copies_span{copies.data(), copies.size()};
ConvertImage(input, info, async_decode->decoded_data, copies_span);
// TODO: Do we need this lock?
std::unique_lock lock{async_decode->mutex};
async_decode->copies = std::move(copies);
async_decode->complete = true;
};
texture_decode_worker.QueueWork(std::move(func));
}
template <class P>
void TextureCache<P>::TickAsyncDecode() {
bool has_uploads{};
auto i = async_decodes.begin();
while (i != async_decodes.end()) {
auto* async_decode = i->get();
std::unique_lock lock{async_decode->mutex};
if (!async_decode->complete) {
++i;
continue;
}
Image& image = slot_images[async_decode->image_id];
auto staging = runtime.UploadStagingBuffer(MapSizeBytes(image));
std::memcpy(staging.mapped_span.data(), async_decode->decoded_data.data(),
async_decode->decoded_data.size());
image.UploadMemory(staging, async_decode->copies);
image.flags &= ~ImageFlagBits::IsDecoding;
has_uploads = true;
i = async_decodes.erase(i);
}
if (has_uploads) {
runtime.InsertUploadMemoryBarrier();
}
}
template <class P> template <class P>
bool TextureCache<P>::ScaleUp(Image& image) { bool TextureCache<P>::ScaleUp(Image& image) {
const bool has_copy = image.HasScaled(); const bool has_copy = image.HasScaled();

View file

@ -3,6 +3,7 @@
#pragma once #pragma once
#include <atomic>
#include <deque> #include <deque>
#include <limits> #include <limits>
#include <mutex> #include <mutex>
@ -18,6 +19,7 @@
#include "common/lru_cache.h" #include "common/lru_cache.h"
#include "common/polyfill_ranges.h" #include "common/polyfill_ranges.h"
#include "common/scratch_buffer.h" #include "common/scratch_buffer.h"
#include "common/thread_worker.h"
#include "video_core/compatible_formats.h" #include "video_core/compatible_formats.h"
#include "video_core/control/channel_state_cache.h" #include "video_core/control/channel_state_cache.h"
#include "video_core/delayed_destruction_ring.h" #include "video_core/delayed_destruction_ring.h"
@ -54,6 +56,14 @@ struct ImageViewInOut {
ImageViewId id{}; ImageViewId id{};
}; };
struct AsyncDecodeContext {
ImageId image_id;
Common::ScratchBuffer<u8> decoded_data;
std::vector<BufferImageCopy> copies;
std::mutex mutex;
std::atomic_bool complete;
};
using TextureCacheGPUMap = std::unordered_map<u64, std::vector<ImageId>, Common::IdentityHash<u64>>; using TextureCacheGPUMap = std::unordered_map<u64, std::vector<ImageId>, Common::IdentityHash<u64>>;
class TextureCacheChannelInfo : public ChannelInfo { class TextureCacheChannelInfo : public ChannelInfo {
@ -382,6 +392,9 @@ private:
bool ScaleDown(Image& image); bool ScaleDown(Image& image);
u64 GetScaledImageSizeBytes(const ImageBase& image); u64 GetScaledImageSizeBytes(const ImageBase& image);
void QueueAsyncDecode(Image& image, ImageId image_id);
void TickAsyncDecode();
Runtime& runtime; Runtime& runtime;
VideoCore::RasterizerInterface& rasterizer; VideoCore::RasterizerInterface& rasterizer;
@ -435,6 +448,9 @@ private:
u64 modification_tick = 0; u64 modification_tick = 0;
u64 frame_tick = 0; u64 frame_tick = 0;
Common::ThreadWorker texture_decode_worker{1, "TextureDecoder"};
std::vector<std::unique_ptr<AsyncDecodeContext>> async_decodes;
}; };
} // namespace VideoCommon } // namespace VideoCommon

View file

@ -1656,8 +1656,8 @@ void Decompress(std::span<const uint8_t> data, uint32_t width, uint32_t height,
const u32 rows = Common::DivideUp(height, block_height); const u32 rows = Common::DivideUp(height, block_height);
const u32 cols = Common::DivideUp(width, block_width); const u32 cols = Common::DivideUp(width, block_width);
Common::ThreadWorker workers{std::max(std::thread::hardware_concurrency(), 2U) / 2, static Common::ThreadWorker workers{std::max(std::thread::hardware_concurrency(), 2U) / 2,
"ASTCDecompress"}; "ASTCDecompress"};
for (u32 z = 0; z < depth; ++z) { for (u32 z = 0; z < depth; ++z) {
const u32 depth_offset = z * height * width * 4; const u32 depth_offset = z * height * width * 4;

View file

@ -707,6 +707,7 @@ void Config::ReadRendererValues() {
ReadGlobalSetting(Settings::values.use_asynchronous_gpu_emulation); ReadGlobalSetting(Settings::values.use_asynchronous_gpu_emulation);
ReadGlobalSetting(Settings::values.nvdec_emulation); ReadGlobalSetting(Settings::values.nvdec_emulation);
ReadGlobalSetting(Settings::values.accelerate_astc); ReadGlobalSetting(Settings::values.accelerate_astc);
ReadGlobalSetting(Settings::values.async_astc);
ReadGlobalSetting(Settings::values.use_vsync); ReadGlobalSetting(Settings::values.use_vsync);
ReadGlobalSetting(Settings::values.shader_backend); ReadGlobalSetting(Settings::values.shader_backend);
ReadGlobalSetting(Settings::values.use_asynchronous_shaders); ReadGlobalSetting(Settings::values.use_asynchronous_shaders);
@ -1350,6 +1351,7 @@ void Config::SaveRendererValues() {
static_cast<u32>(Settings::values.nvdec_emulation.GetDefault()), static_cast<u32>(Settings::values.nvdec_emulation.GetDefault()),
Settings::values.nvdec_emulation.UsingGlobal()); Settings::values.nvdec_emulation.UsingGlobal());
WriteGlobalSetting(Settings::values.accelerate_astc); WriteGlobalSetting(Settings::values.accelerate_astc);
WriteGlobalSetting(Settings::values.async_astc);
WriteGlobalSetting(Settings::values.use_vsync); WriteGlobalSetting(Settings::values.use_vsync);
WriteSetting(QString::fromStdString(Settings::values.shader_backend.GetLabel()), WriteSetting(QString::fromStdString(Settings::values.shader_backend.GetLabel()),
static_cast<u32>(Settings::values.shader_backend.GetValue(global)), static_cast<u32>(Settings::values.shader_backend.GetValue(global)),

View file

@ -23,11 +23,13 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
const bool runtime_lock = !system.IsPoweredOn(); const bool runtime_lock = !system.IsPoweredOn();
ui->use_vsync->setEnabled(runtime_lock); ui->use_vsync->setEnabled(runtime_lock);
ui->renderer_force_max_clock->setEnabled(runtime_lock); ui->renderer_force_max_clock->setEnabled(runtime_lock);
ui->async_astc->setEnabled(runtime_lock);
ui->use_asynchronous_shaders->setEnabled(runtime_lock); ui->use_asynchronous_shaders->setEnabled(runtime_lock);
ui->anisotropic_filtering_combobox->setEnabled(runtime_lock); ui->anisotropic_filtering_combobox->setEnabled(runtime_lock);
ui->renderer_force_max_clock->setChecked(Settings::values.renderer_force_max_clock.GetValue()); ui->renderer_force_max_clock->setChecked(Settings::values.renderer_force_max_clock.GetValue());
ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue()); ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue());
ui->async_astc->setChecked(Settings::values.async_astc.GetValue());
ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue()); ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue());
ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue()); ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue());
ui->use_pessimistic_flushes->setChecked(Settings::values.use_pessimistic_flushes.GetValue()); ui->use_pessimistic_flushes->setChecked(Settings::values.use_pessimistic_flushes.GetValue());
@ -60,6 +62,8 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() {
ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy, ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy,
ui->anisotropic_filtering_combobox); ui->anisotropic_filtering_combobox);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync); ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.async_astc, ui->async_astc,
async_astc);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_shaders, ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_shaders,
ui->use_asynchronous_shaders, ui->use_asynchronous_shaders,
use_asynchronous_shaders); use_asynchronous_shaders);
@ -91,6 +95,7 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
ui->renderer_force_max_clock->setEnabled( ui->renderer_force_max_clock->setEnabled(
Settings::values.renderer_force_max_clock.UsingGlobal()); Settings::values.renderer_force_max_clock.UsingGlobal());
ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal()); ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal());
ui->async_astc->setEnabled(Settings::values.async_astc.UsingGlobal());
ui->use_asynchronous_shaders->setEnabled( ui->use_asynchronous_shaders->setEnabled(
Settings::values.use_asynchronous_shaders.UsingGlobal()); Settings::values.use_asynchronous_shaders.UsingGlobal());
ui->use_fast_gpu_time->setEnabled(Settings::values.use_fast_gpu_time.UsingGlobal()); ui->use_fast_gpu_time->setEnabled(Settings::values.use_fast_gpu_time.UsingGlobal());
@ -108,6 +113,8 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
Settings::values.renderer_force_max_clock, Settings::values.renderer_force_max_clock,
renderer_force_max_clock); renderer_force_max_clock);
ConfigurationShared::SetColoredTristate(ui->use_vsync, Settings::values.use_vsync, use_vsync); ConfigurationShared::SetColoredTristate(ui->use_vsync, Settings::values.use_vsync, use_vsync);
ConfigurationShared::SetColoredTristate(ui->async_astc, Settings::values.async_astc,
async_astc);
ConfigurationShared::SetColoredTristate(ui->use_asynchronous_shaders, ConfigurationShared::SetColoredTristate(ui->use_asynchronous_shaders,
Settings::values.use_asynchronous_shaders, Settings::values.use_asynchronous_shaders,
use_asynchronous_shaders); use_asynchronous_shaders);

View file

@ -38,6 +38,7 @@ private:
ConfigurationShared::CheckState renderer_force_max_clock; ConfigurationShared::CheckState renderer_force_max_clock;
ConfigurationShared::CheckState use_vsync; ConfigurationShared::CheckState use_vsync;
ConfigurationShared::CheckState async_astc;
ConfigurationShared::CheckState use_asynchronous_shaders; ConfigurationShared::CheckState use_asynchronous_shaders;
ConfigurationShared::CheckState use_fast_gpu_time; ConfigurationShared::CheckState use_fast_gpu_time;
ConfigurationShared::CheckState use_pessimistic_flushes; ConfigurationShared::CheckState use_pessimistic_flushes;

View file

@ -89,6 +89,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="async_astc">
<property name="toolTip">
<string>Enables asynchronous ASTC texture decoding, which may reduce load time stutter. This feature is experimental.</string>
</property>
<property name="text">
<string>Decode ASTC textures asynchronously (Hack)</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="use_asynchronous_shaders"> <widget class="QCheckBox" name="use_asynchronous_shaders">
<property name="toolTip"> <property name="toolTip">

View file

@ -75,6 +75,8 @@ void DiscordImpl::Update() {
// New Check for game cover // New Check for game cover
httplib::Client cli(game_cover_url); httplib::Client cli(game_cover_url);
cli.set_connection_timeout(std::chrono::seconds(3));
cli.set_read_timeout(std::chrono::seconds(3));
if (auto res = cli.Head(fmt::format("/images/game/boxart/{}.png", icon_name))) { if (auto res = cli.Head(fmt::format("/images/game/boxart/{}.png", icon_name))) {
if (res->status == 200) { if (res->status == 200) {

View file

@ -324,6 +324,7 @@ void Config::ReadValues() {
ReadSetting("Renderer", Settings::values.use_asynchronous_shaders); ReadSetting("Renderer", Settings::values.use_asynchronous_shaders);
ReadSetting("Renderer", Settings::values.nvdec_emulation); ReadSetting("Renderer", Settings::values.nvdec_emulation);
ReadSetting("Renderer", Settings::values.accelerate_astc); ReadSetting("Renderer", Settings::values.accelerate_astc);
ReadSetting("Renderer", Settings::values.async_astc);
ReadSetting("Renderer", Settings::values.use_fast_gpu_time); ReadSetting("Renderer", Settings::values.use_fast_gpu_time);
ReadSetting("Renderer", Settings::values.use_pessimistic_flushes); ReadSetting("Renderer", Settings::values.use_pessimistic_flushes);
ReadSetting("Renderer", Settings::values.use_vulkan_driver_pipeline_cache); ReadSetting("Renderer", Settings::values.use_vulkan_driver_pipeline_cache);

View file

@ -342,6 +342,10 @@ nvdec_emulation =
# 0: Off, 1 (default): On # 0: Off, 1 (default): On
accelerate_astc = accelerate_astc =
# Decode ASTC textures asynchronously.
# 0 (default): Off, 1: On
async_astc =
# Turns on the speed limiter, which will limit the emulation speed to the desired speed limit value # Turns on the speed limiter, which will limit the emulation speed to the desired speed limit value
# 0: Off, 1: On (default) # 0: Off, 1: On (default)
use_speed_limit = use_speed_limit =