early-access version 2415

This commit is contained in:
pineappleEA 2022-01-19 04:17:57 +01:00
parent 495ed56df7
commit afb206da79
11 changed files with 83 additions and 26 deletions

View file

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

View file

@ -209,6 +209,13 @@ enum class ButtonNames {
Triangle, Triangle,
Share, Share,
Options, Options,
// Mouse buttons
ButtonMouseWheel,
ButtonBackward,
ButtonForward,
ButtonTask,
ButtonExtra,
}; };
// Callback data consisting of an input type and the equivalent data status // Callback data consisting of an input type and the equivalent data status

View file

@ -1097,14 +1097,14 @@ void KThread::EndWait(ResultCode wait_result_) {
// Lock the scheduler. // Lock the scheduler.
KScopedSchedulerLock sl(kernel); KScopedSchedulerLock sl(kernel);
// Dummy threads are just used by host threads for locking, and will never have a wait_queue.
if (thread_type == ThreadType::Dummy) {
ASSERT_MSG(false, "Dummy threads should never call EndWait!");
return;
}
// If we're waiting, notify our queue that we're available. // If we're waiting, notify our queue that we're available.
if (GetState() == ThreadState::Waiting) { if (GetState() == ThreadState::Waiting) {
if (wait_queue == nullptr) {
// This should never happen, but avoid a hard crash below to get this logged.
ASSERT_MSG(false, "wait_queue is nullptr!");
return;
}
wait_queue->EndWait(this, wait_result_); wait_queue->EndWait(this, wait_result_);
} }
} }

View file

@ -302,12 +302,10 @@ struct KernelCore::Impl {
// Gets the dummy KThread for the caller, allocating a new one if this is the first time // Gets the dummy KThread for the caller, allocating a new one if this is the first time
KThread* GetHostDummyThread() { KThread* GetHostDummyThread() {
auto make_thread = [this]() { auto make_thread = [this]() {
std::lock_guard lk(dummy_thread_lock); KThread* thread = KThread::Create(system.Kernel());
auto& thread = dummy_threads.emplace_back(std::make_unique<KThread>(system.Kernel())); ASSERT(KThread::InitializeDummyThread(thread).IsSuccess());
KAutoObject::Create(thread.get());
ASSERT(KThread::InitializeDummyThread(thread.get()).IsSuccess());
thread->SetName(fmt::format("DummyThread:{}", GetHostThreadId())); thread->SetName(fmt::format("DummyThread:{}", GetHostThreadId()));
return thread.get(); return thread;
}; };
thread_local KThread* saved_thread = make_thread(); thread_local KThread* saved_thread = make_thread();
@ -740,7 +738,6 @@ struct KernelCore::Impl {
std::mutex server_sessions_lock; std::mutex server_sessions_lock;
std::mutex registered_objects_lock; std::mutex registered_objects_lock;
std::mutex registered_in_use_objects_lock; std::mutex registered_in_use_objects_lock;
std::mutex dummy_thread_lock;
std::atomic<u32> next_object_id{0}; std::atomic<u32> next_object_id{0};
std::atomic<u64> next_kernel_process_id{KProcess::InitialKIPIDMin}; std::atomic<u64> next_kernel_process_id{KProcess::InitialKIPIDMin};
@ -798,9 +795,6 @@ struct KernelCore::Impl {
std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{}; std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{};
std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{}; std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{};
// Specifically tracked to be automatically destroyed with kernel
std::vector<std::unique_ptr<KThread>> dummy_threads;
bool is_multicore{}; bool is_multicore{};
std::atomic_bool is_shutting_down{}; std::atomic_bool is_shutting_down{};
bool is_phantom_mode_for_singlecore{}; bool is_phantom_mode_for_singlecore{};

View file

@ -16,6 +16,7 @@ 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 int touch_axis_x = 10; constexpr int touch_axis_x = 10;
constexpr int touch_axis_y = 11; constexpr int touch_axis_y = 11;
constexpr PadIdentifier identifier = { constexpr PadIdentifier identifier = {
@ -30,6 +31,7 @@ Mouse::Mouse(std::string input_engine_) : InputEngine(std::move(input_engine_))
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(identifier, touch_axis_x); PreSetAxis(identifier, touch_axis_x);
PreSetAxis(identifier, touch_axis_y); PreSetAxis(identifier, touch_axis_y);
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); });
@ -48,6 +50,8 @@ void Mouse::UpdateThread(std::stop_token stop_token) {
SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity); SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity);
} }
SetAxis(identifier, motion_wheel_y, 0.0f);
if (mouse_panning_timout++ > 20) { if (mouse_panning_timout++ > 20) {
StopPanning(); StopPanning();
} }
@ -136,6 +140,7 @@ void Mouse::MouseWheelChange(int x, int y) {
wheel_position.y += y; wheel_position.y += y;
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() {
@ -171,13 +176,39 @@ AnalogMapping Mouse::GetAnalogMappingForDevice(
return mapping; return mapping;
} }
Common::Input::ButtonNames Mouse::GetUIButtonName(const Common::ParamPackage& params) const {
const auto button = static_cast<MouseButton>(params.Get("button", 0));
switch (button) {
case MouseButton::Left:
return Common::Input::ButtonNames::ButtonLeft;
case MouseButton::Right:
return Common::Input::ButtonNames::ButtonRight;
case MouseButton::Wheel:
return Common::Input::ButtonNames::ButtonMouseWheel;
case MouseButton::Backward:
return Common::Input::ButtonNames::ButtonBackward;
case MouseButton::Forward:
return Common::Input::ButtonNames::ButtonForward;
case MouseButton::Task:
return Common::Input::ButtonNames::ButtonTask;
case MouseButton::Extra:
return Common::Input::ButtonNames::ButtonExtra;
case MouseButton::Undefined:
default:
return Common::Input::ButtonNames::Undefined;
}
}
Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params) const { Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params) const {
if (params.Has("button")) { if (params.Has("button")) {
return Common::Input::ButtonNames::Value; return GetUIButtonName(params);
} }
if (params.Has("axis")) { if (params.Has("axis")) {
return Common::Input::ButtonNames::Value; return Common::Input::ButtonNames::Value;
} }
if (params.Has("axis_x") && params.Has("axis_y") && params.Has("axis_z")) {
return Common::Input::ButtonNames::Engine;
}
return Common::Input::ButtonNames::Invalid; return Common::Input::ButtonNames::Invalid;
} }

View file

@ -69,6 +69,8 @@ private:
void UpdateThread(std::stop_token stop_token); void UpdateThread(std::stop_token stop_token);
void StopPanning(); void StopPanning();
Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const;
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;

View file

@ -143,6 +143,19 @@ 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 (data.engine == "mouse") {
new_input.Set("axis_x", 1);
new_input.Set("invert_x", "-");
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);
return;
}
switch (data.type) { switch (data.type) {
case EngineInputType::Button: case EngineInputType::Button:
case EngineInputType::HatButton: case EngineInputType::HatButton:

View file

@ -488,8 +488,8 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager&
device_access_memory = []() -> u64 { device_access_memory = []() -> u64 {
if (GLAD_GL_NVX_gpu_memory_info) { if (GLAD_GL_NVX_gpu_memory_info) {
GLint cur_avail_mem_kb = 0; GLint cur_avail_mem_kb = 0;
glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &cur_avail_mem_kb); glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &cur_avail_mem_kb);
return static_cast<u64>(cur_avail_mem_kb) * 1_KiB; return static_cast<u64>(cur_avail_mem_kb) * 1_KiB + 512_MiB;
} }
return 2_GiB; // Return minimum requirements return 2_GiB; // Return minimum requirements
}(); }();

View file

@ -587,10 +587,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
} }
logical = vk::Device::Create(physical, queue_cis, extensions, first_next, dld); logical = vk::Device::Create(physical, queue_cis, extensions, first_next, dld);
is_integrated = (properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU) != 0; is_integrated = properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
is_virtual = (properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) != 0; is_virtual = properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU;
is_non_gpu = (properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_OTHER) != 0 || is_non_gpu = properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_OTHER ||
(properties.deviceType & VK_PHYSICAL_DEVICE_TYPE_CPU) != 0; properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU;
CollectPhysicalMemoryInfo(); CollectPhysicalMemoryInfo();
CollectTelemetryParameters(); CollectTelemetryParameters();
@ -1270,7 +1270,7 @@ void Device::CollectPhysicalMemoryInfo() {
u64 local_memory = 0; u64 local_memory = 0;
for (size_t element = 0; element < num_properties; ++element) { for (size_t element = 0; element < num_properties; ++element) {
const bool is_heap_local = const bool is_heap_local =
mem_properties.memoryHeaps[element].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT != 0; (mem_properties.memoryHeaps[element].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) != 0;
if (!is_integrated && !is_heap_local) { if (!is_integrated && !is_heap_local) {
continue; continue;
} }

View file

@ -102,6 +102,16 @@ QString GetButtonName(Common::Input::ButtonNames button_name) {
return QObject::tr("Share"); return QObject::tr("Share");
case Common::Input::ButtonNames::Options: case Common::Input::ButtonNames::Options:
return QObject::tr("Options"); return QObject::tr("Options");
case Common::Input::ButtonNames::ButtonMouseWheel:
return QObject::tr("Wheel", "Indicates the mouse wheel");
case Common::Input::ButtonNames::ButtonBackward:
return QObject::tr("Backward");
case Common::Input::ButtonNames::ButtonForward:
return QObject::tr("Forward");
case Common::Input::ButtonNames::ButtonTask:
return QObject::tr("Task");
case Common::Input::ButtonNames::ButtonExtra:
return QObject::tr("Extra");
default: default:
return QObject::tr("[undefined]"); return QObject::tr("[undefined]");
} }
@ -1344,10 +1354,10 @@ void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) {
} }
void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) { void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) {
event->ignore();
if (!input_setter || !event) { if (!input_setter || !event) {
return; return;
} }
event->ignore();
if (event->key() != Qt::Key_Escape) { if (event->key() != Qt::Key_Escape) {
input_subsystem->GetKeyboard()->PressKey(event->key()); input_subsystem->GetKeyboard()->PressKey(event->key());
} }

View file

@ -305,10 +305,10 @@ void ConfigureRingController::mousePressEvent(QMouseEvent* event) {
} }
void ConfigureRingController::keyPressEvent(QKeyEvent* event) { void ConfigureRingController::keyPressEvent(QKeyEvent* event) {
event->ignore();
if (!input_setter || !event) { if (!input_setter || !event) {
return; return;
} }
event->ignore();
if (event->key() != Qt::Key_Escape) { if (event->key() != Qt::Key_Escape) {
input_subsystem->GetKeyboard()->PressKey(event->key()); input_subsystem->GetKeyboard()->PressKey(event->key());
} }