From a8a779c79b48f020a1432274114f1ddaff0b1dec Mon Sep 17 00:00:00 2001 From: DanielSvoboda Date: Fri, 24 Jan 2025 05:11:48 -0300 Subject: [PATCH 01/72] Fix AutoUpdate Changelog (#2224) --- src/qt_gui/check_update.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qt_gui/check_update.cpp b/src/qt_gui/check_update.cpp index e3e019144..0c1cce5da 100644 --- a/src/qt_gui/check_update.cpp +++ b/src/qt_gui/check_update.cpp @@ -146,14 +146,14 @@ void CheckUpdate::CheckForUpdates(const bool showMessage) { } QString currentRev = (updateChannel == "Nightly") - ? QString::fromStdString(Common::g_scm_rev).left(7) + ? QString::fromStdString(Common::g_scm_rev) : "v." + QString::fromStdString(Common::VERSION); QString currentDate = Common::g_scm_date; QDateTime dateTime = QDateTime::fromString(latestDate, Qt::ISODate); latestDate = dateTime.isValid() ? dateTime.toString("yyyy-MM-dd HH:mm:ss") : "Unknown date"; - if (latestRev == currentRev) { + if (latestRev == currentRev.left(7)) { if (showMessage) { QMessageBox::information(this, tr("Auto Updater"), tr("Your version is already up to date!")); @@ -190,7 +190,7 @@ void CheckUpdate::setupUI(const QString& downloadUrl, const QString& latestDate, QString("


" + tr("Update Channel") + ":
" + updateChannel + "
" + tr("Current Version") + ": %1 (%2)
" + tr("Latest Version") + ": %3 (%4)

" + tr("Do you want to update?") + "

") - .arg(currentRev, currentDate, latestRev, latestDate); + .arg(currentRev.left(7), currentDate, latestRev, latestDate); QLabel* updateLabel = new QLabel(updateText, this); layout->addWidget(updateLabel); From 91444a05453ba1468b29c575d844ae173cc7e738 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 24 Jan 2025 00:21:32 -0800 Subject: [PATCH 02/72] liverpool: Fix tiled check for color buffer. (#2227) --- src/video_core/amdgpu/liverpool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video_core/amdgpu/liverpool.h b/src/video_core/amdgpu/liverpool.h index a29bde4ce..ec9c92ef1 100644 --- a/src/video_core/amdgpu/liverpool.h +++ b/src/video_core/amdgpu/liverpool.h @@ -904,7 +904,7 @@ struct Liverpool { } bool IsTiled() const { - return !info.linear_general; + return GetTilingMode() != TilingMode::Display_Linear; } [[nodiscard]] DataFormat GetDataFmt() const { From 74710116f6bdd805c39ffe7fff4be017df3ac910 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 24 Jan 2025 00:21:56 -0800 Subject: [PATCH 03/72] renderer_vulkan: Remove dead code. (#2228) --- CMakeLists.txt | 2 - .../vk_descriptor_update_queue.cpp | 108 ------------------ .../vk_descriptor_update_queue.h | 51 --------- 3 files changed, 161 deletions(-) delete mode 100644 src/video_core/renderer_vulkan/vk_descriptor_update_queue.cpp delete mode 100644 src/video_core/renderer_vulkan/vk_descriptor_update_queue.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 131809c8e..3db142be7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -751,8 +751,6 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp src/video_core/renderer_vulkan/vk_common.h src/video_core/renderer_vulkan/vk_compute_pipeline.cpp src/video_core/renderer_vulkan/vk_compute_pipeline.h - src/video_core/renderer_vulkan/vk_descriptor_update_queue.cpp - src/video_core/renderer_vulkan/vk_descriptor_update_queue.h src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp src/video_core/renderer_vulkan/vk_graphics_pipeline.h src/video_core/renderer_vulkan/vk_instance.cpp diff --git a/src/video_core/renderer_vulkan/vk_descriptor_update_queue.cpp b/src/video_core/renderer_vulkan/vk_descriptor_update_queue.cpp deleted file mode 100644 index 7699bea9d..000000000 --- a/src/video_core/renderer_vulkan/vk_descriptor_update_queue.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "video_core/renderer_vulkan/vk_descriptor_update_queue.h" -#include "video_core/renderer_vulkan/vk_instance.h" - -namespace Vulkan { - -DescriptorUpdateQueue::DescriptorUpdateQueue(const Instance& instance, u32 descriptor_write_max_) - : device{instance.GetDevice()}, descriptor_write_max{descriptor_write_max_} { - descriptor_infos = std::make_unique(descriptor_write_max); - descriptor_writes = std::make_unique(descriptor_write_max); -} - -void DescriptorUpdateQueue::Flush() { - if (descriptor_write_end == 0) { - return; - } - device.updateDescriptorSets({std::span(descriptor_writes.get(), descriptor_write_end)}, {}); - descriptor_write_end = 0; -} - -void DescriptorUpdateQueue::AddStorageImage(vk::DescriptorSet target, u8 binding, - vk::ImageView image_view, - vk::ImageLayout image_layout) { - if (descriptor_write_end >= descriptor_write_max) [[unlikely]] { - Flush(); - } - - auto& image_info = descriptor_infos[descriptor_write_end].image_info; - image_info.sampler = VK_NULL_HANDLE; - image_info.imageView = image_view; - image_info.imageLayout = image_layout; - - descriptor_writes[descriptor_write_end++] = vk::WriteDescriptorSet{ - .dstSet = target, - .dstBinding = binding, - .dstArrayElement = 0, - .descriptorCount = 1, - .descriptorType = vk::DescriptorType::eStorageImage, - .pImageInfo = &image_info, - }; -} - -void DescriptorUpdateQueue::AddImageSampler(vk::DescriptorSet target, u8 binding, u8 array_index, - vk::ImageView image_view, vk::Sampler sampler, - vk::ImageLayout image_layout) { - if (descriptor_write_end >= descriptor_write_max) [[unlikely]] { - Flush(); - } - - auto& image_info = descriptor_infos[descriptor_write_end].image_info; - image_info.sampler = sampler; - image_info.imageView = image_view; - image_info.imageLayout = image_layout; - - descriptor_writes[descriptor_write_end++] = vk::WriteDescriptorSet{ - .dstSet = target, - .dstBinding = binding, - .dstArrayElement = array_index, - .descriptorCount = 1, - .descriptorType = - sampler ? vk::DescriptorType::eCombinedImageSampler : vk::DescriptorType::eSampledImage, - .pImageInfo = &image_info, - }; -} - -void DescriptorUpdateQueue::AddBuffer(vk::DescriptorSet target, u8 binding, vk::Buffer buffer, - vk::DeviceSize offset, vk::DeviceSize size, - vk::DescriptorType type) { - if (descriptor_write_end >= descriptor_write_max) [[unlikely]] { - Flush(); - } - - auto& buffer_info = descriptor_infos[descriptor_write_end].buffer_info; - buffer_info.buffer = buffer; - buffer_info.offset = offset; - buffer_info.range = size; - - descriptor_writes[descriptor_write_end++] = vk::WriteDescriptorSet{ - .dstSet = target, - .dstBinding = binding, - .dstArrayElement = 0, - .descriptorCount = 1, - .descriptorType = type, - .pBufferInfo = &buffer_info, - }; -} - -void DescriptorUpdateQueue::AddTexelBuffer(vk::DescriptorSet target, u8 binding, - vk::BufferView buffer_view) { - if (descriptor_write_end >= descriptor_write_max) [[unlikely]] { - Flush(); - } - - auto& buffer_info = descriptor_infos[descriptor_write_end].buffer_view; - buffer_info = buffer_view; - descriptor_writes[descriptor_write_end++] = vk::WriteDescriptorSet{ - .dstSet = target, - .dstBinding = binding, - .dstArrayElement = 0, - .descriptorCount = 1, - .descriptorType = vk::DescriptorType::eUniformTexelBuffer, - .pTexelBufferView = &buffer_info, - }; -} - -} // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/vk_descriptor_update_queue.h b/src/video_core/renderer_vulkan/vk_descriptor_update_queue.h deleted file mode 100644 index 9e864db6e..000000000 --- a/src/video_core/renderer_vulkan/vk_descriptor_update_queue.h +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include - -#include "common/types.h" -#include "video_core/renderer_vulkan/vk_common.h" - -namespace Vulkan { - -class Instance; - -struct DescriptorInfoUnion { - DescriptorInfoUnion() {} - - union { - vk::DescriptorImageInfo image_info; - vk::DescriptorBufferInfo buffer_info; - vk::BufferView buffer_view; - }; -}; - -class DescriptorUpdateQueue { -public: - explicit DescriptorUpdateQueue(const Instance& instance, u32 descriptor_write_max = 2048); - ~DescriptorUpdateQueue() = default; - - void Flush(); - - void AddStorageImage(vk::DescriptorSet target, u8 binding, vk::ImageView image_view, - vk::ImageLayout image_layout = vk::ImageLayout::eGeneral); - - void AddImageSampler(vk::DescriptorSet target, u8 binding, u8 array_index, - vk::ImageView image_view, vk::Sampler sampler, - vk::ImageLayout imageLayout = vk::ImageLayout::eGeneral); - - void AddBuffer(vk::DescriptorSet target, u8 binding, vk::Buffer buffer, vk::DeviceSize offset, - vk::DeviceSize size = VK_WHOLE_SIZE, - vk::DescriptorType type = vk::DescriptorType::eUniformBufferDynamic); - - void AddTexelBuffer(vk::DescriptorSet target, u8 binding, vk::BufferView buffer_view); - -private: - const vk::Device device; - const u32 descriptor_write_max; - std::unique_ptr descriptor_infos; - std::unique_ptr descriptor_writes; - u32 descriptor_write_end = 0; -}; - -} // namespace Vulkan From d1b9a5adcceb0c61e03293db9840ca6844442398 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 24 Jan 2025 00:23:18 -0800 Subject: [PATCH 04/72] texture_cache: Do not overwrite overlap hit with a miss. (#2217) --- src/video_core/texture_cache/texture_cache.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/video_core/texture_cache/texture_cache.cpp b/src/video_core/texture_cache/texture_cache.cpp index 04711539c..e995b10b2 100644 --- a/src/video_core/texture_cache/texture_cache.cpp +++ b/src/video_core/texture_cache/texture_cache.cpp @@ -345,8 +345,13 @@ ImageId TextureCache::FindImage(BaseDesc& desc, FindFlags flags) { view_slice = -1; const auto& merged_info = image_id ? slot_images[image_id].info : info; - std::tie(image_id, view_mip, view_slice) = + auto [overlap_image_id, overlap_view_mip, overlap_view_slice] = ResolveOverlap(merged_info, desc.type, cache_id, image_id); + if (overlap_image_id) { + image_id = overlap_image_id; + view_mip = overlap_view_mip; + view_slice = overlap_view_slice; + } } } From 481f420a892e02ac30bfe3e4966368900c69ead2 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 24 Jan 2025 10:28:14 +0200 Subject: [PATCH 05/72] Update building-linux.md --- documents/building-linux.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/documents/building-linux.md b/documents/building-linux.md index 2342e9afc..4aa66aac6 100644 --- a/documents/building-linux.md +++ b/documents/building-linux.md @@ -29,7 +29,9 @@ sudo dnf install clang git cmake libatomic alsa-lib-devel pipewire-jack-audio-co sudo pacman -S base-devel clang git cmake sndio jack2 openal qt6-base qt6-declarative qt6-multimedia sdl2 vulkan-validation-layers ``` -**Note** : The `shadps4-git` AUR package is not maintained by any of the developers, and it uses the default compiler, which is often set to GCC. Use at your own discretion.#### OpenSUSE +**Note** : The `shadps4-git` AUR package is not maintained by any of the developers, and it uses the default compiler, which is often set to GCC. Use at your own discretion. + +#### OpenSUSE ``` sudo zypper install clang git cmake libasound2 libpulse-devel libsndio7 libjack-devel openal-soft-devel libopenssl-devel zlib-devel libedit-devel systemd-devel libevdev-devel qt6-base-devel qt6-multimedia-devel qt6-svg-devel qt6-linguist-devel qt6-gui-private-devel vulkan-devel vulkan-validationlayers @@ -48,6 +50,7 @@ distrobox create --name archlinux --init --image archlinux:latest and install the dependencies on that container as cited above. This option is **highly recommended** for NixOS and distributions with immutable/atomic filesystems (example: Fedora Kinoite, SteamOS). + ### Cloning ``` From 0f69697acb7504e57abe2b15238b2c92414a0d8f Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 24 Jan 2025 00:48:39 -0800 Subject: [PATCH 06/72] documents: Update CPU requirements. (#2229) --- documents/Quickstart/Quickstart.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/documents/Quickstart/Quickstart.md b/documents/Quickstart/Quickstart.md index b2931e51e..2f2751887 100644 --- a/documents/Quickstart/Quickstart.md +++ b/documents/Quickstart/Quickstart.md @@ -22,7 +22,10 @@ SPDX-License-Identifier: GPL-2.0-or-later - A processor with at least 4 cores and 6 threads - Above 2.5 GHz frequency -- required support AVX2 extension or Rosetta 2 on ARM +- A CPU supporting the following instruction sets: MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, F16C, CLMUL, AES, BMI1, MOVBE, XSAVE, ABM + - **Intel**: Haswell generation or newer + - **AMD**: Jaguar generation or newer + - **Apple**: Rosetta 2 on macOS 15 or newer ### GPU From 9dcf40e261c6775a997b92d26a4bd8113821c6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Miko=C5=82ajczyk?= Date: Fri, 24 Jan 2025 11:07:36 +0000 Subject: [PATCH 07/72] Handle more 64bit shifts in Translator (#1825) --- .../frontend/translate/scalar_alu.cpp | 22 ++++++++++++++++++- .../frontend/translate/translate.h | 2 ++ .../frontend/translate/vector_alu.cpp | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/shader_recompiler/frontend/translate/scalar_alu.cpp b/src/shader_recompiler/frontend/translate/scalar_alu.cpp index 7f34126f5..b1b260fde 100644 --- a/src/shader_recompiler/frontend/translate/scalar_alu.cpp +++ b/src/shader_recompiler/frontend/translate/scalar_alu.cpp @@ -72,10 +72,14 @@ void Translator::EmitScalarAlu(const GcnInst& inst) { return S_OR_B64(NegateMode::Result, true, inst); case Opcode::S_LSHL_B32: return S_LSHL_B32(inst); + case Opcode::S_LSHL_B64: + return S_LSHL_B64(inst); case Opcode::S_LSHR_B32: return S_LSHR_B32(inst); case Opcode::S_ASHR_I32: return S_ASHR_I32(inst); + case Opcode::S_ASHR_I64: + return S_ASHR_I64(inst); case Opcode::S_BFM_B32: return S_BFM_B32(inst); case Opcode::S_MUL_I32: @@ -420,6 +424,14 @@ void Translator::S_LSHL_B32(const GcnInst& inst) { ir.SetScc(ir.INotEqual(result, ir.Imm32(0))); } +void Translator::S_LSHL_B64(const GcnInst& inst) { + const IR::U64 src0{GetSrc64(inst.src[0])}; + const IR::U64 src1{GetSrc64(inst.src[1])}; + const IR::U64 result = ir.ShiftLeftLogical(src0, ir.BitwiseAnd(src1, ir.Imm64(u64(0x3F)))); + SetDst64(inst.dst[0], result); + ir.SetScc(ir.INotEqual(result, ir.Imm64(u64(0)))); +} + void Translator::S_LSHR_B32(const GcnInst& inst) { const IR::U32 src0{GetSrc(inst.src[0])}; const IR::U32 src1{GetSrc(inst.src[1])}; @@ -431,11 +443,19 @@ void Translator::S_LSHR_B32(const GcnInst& inst) { void Translator::S_ASHR_I32(const GcnInst& inst) { const IR::U32 src0{GetSrc(inst.src[0])}; const IR::U32 src1{GetSrc(inst.src[1])}; - const IR::U32 result{ir.ShiftRightArithmetic(src0, src1)}; + const IR::U32 result{ir.ShiftRightArithmetic(src0, ir.BitwiseAnd(src1, ir.Imm32(0x1F)))}; SetDst(inst.dst[0], result); ir.SetScc(ir.INotEqual(result, ir.Imm32(0))); } +void Translator::S_ASHR_I64(const GcnInst& inst) { + const IR::U64 src0{GetSrc64(inst.src[0])}; + const IR::U64 src1{GetSrc64(inst.src[1])}; + const IR::U64 result{ir.ShiftRightArithmetic(src0, ir.BitwiseAnd(src1, ir.Imm64(u64(0x3F))))}; + SetDst64(inst.dst[0], result); + ir.SetScc(ir.INotEqual(result, ir.Imm64(u64(0)))); +} + void Translator::S_BFM_B32(const GcnInst& inst) { const IR::U32 src0{ir.BitwiseAnd(GetSrc(inst.src[0]), ir.Imm32(0x1F))}; const IR::U32 src1{ir.BitwiseAnd(GetSrc(inst.src[1]), ir.Imm32(0x1F))}; diff --git a/src/shader_recompiler/frontend/translate/translate.h b/src/shader_recompiler/frontend/translate/translate.h index bef61f997..496455b50 100644 --- a/src/shader_recompiler/frontend/translate/translate.h +++ b/src/shader_recompiler/frontend/translate/translate.h @@ -90,8 +90,10 @@ public: void S_OR_B64(NegateMode negate, bool is_xor, const GcnInst& inst); void S_XOR_B32(const GcnInst& inst); void S_LSHL_B32(const GcnInst& inst); + void S_LSHL_B64(const GcnInst& inst); void S_LSHR_B32(const GcnInst& inst); void S_ASHR_I32(const GcnInst& inst); + void S_ASHR_I64(const GcnInst& inst); void S_BFM_B32(const GcnInst& inst); void S_MUL_I32(const GcnInst& inst); void S_BFE(const GcnInst& inst, bool is_signed); diff --git a/src/shader_recompiler/frontend/translate/vector_alu.cpp b/src/shader_recompiler/frontend/translate/vector_alu.cpp index b2863f6a8..ac72293e4 100644 --- a/src/shader_recompiler/frontend/translate/vector_alu.cpp +++ b/src/shader_recompiler/frontend/translate/vector_alu.cpp @@ -1273,6 +1273,10 @@ void Translator::V_LSHL_B64(const GcnInst& inst) { ir.SetVectorReg(dst_reg + 1, ir.Imm32(static_cast(result >> 32))); return; } + + const IR::U64 result = ir.ShiftLeftLogical(src0, ir.BitwiseAnd(src1, ir.Imm64(u64(0x3F)))); + SetDst64(inst.dst[0], result); + return; } UNREACHABLE_MSG("Unimplemented V_LSHL_B64 arguments"); } From 4d12de8149cce521916f7752a0830430170144db Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 24 Jan 2025 03:11:13 -0800 Subject: [PATCH 08/72] hotfix: 64-bit shift fixups --- .../backend/spirv/emit_spirv_instructions.h | 3 ++- .../backend/spirv/emit_spirv_integer.cpp | 6 ++++- .../frontend/translate/vector_alu.cpp | 23 +------------------ src/shader_recompiler/ir/ir_emitter.cpp | 14 +++++++++-- src/shader_recompiler/ir/ir_emitter.h | 2 +- src/shader_recompiler/ir/opcodes.inc | 3 ++- .../ir/passes/constant_propagation_pass.cpp | 5 +++- 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index f0bb9fd7e..4833dc9d0 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h @@ -348,7 +348,8 @@ Id EmitSLessThanEqual(EmitContext& ctx, Id lhs, Id rhs); Id EmitULessThanEqual(EmitContext& ctx, Id lhs, Id rhs); Id EmitSGreaterThan(EmitContext& ctx, Id lhs, Id rhs); Id EmitUGreaterThan(EmitContext& ctx, Id lhs, Id rhs); -Id EmitINotEqual(EmitContext& ctx, Id lhs, Id rhs); +Id EmitINotEqual32(EmitContext& ctx, Id lhs, Id rhs); +Id EmitINotEqual64(EmitContext& ctx, Id lhs, Id rhs); Id EmitSGreaterThanEqual(EmitContext& ctx, Id lhs, Id rhs); Id EmitUGreaterThanEqual(EmitContext& ctx, Id lhs, Id rhs); Id EmitLogicalOr(EmitContext& ctx, Id a, Id b); diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp index 70411ecec..e2d702389 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp @@ -324,7 +324,11 @@ Id EmitUGreaterThan(EmitContext& ctx, Id lhs, Id rhs) { return ctx.OpUGreaterThan(ctx.U1[1], lhs, rhs); } -Id EmitINotEqual(EmitContext& ctx, Id lhs, Id rhs) { +Id EmitINotEqual32(EmitContext& ctx, Id lhs, Id rhs) { + return ctx.OpINotEqual(ctx.U1[1], lhs, rhs); +} + +Id EmitINotEqual64(EmitContext& ctx, Id lhs, Id rhs) { return ctx.OpINotEqual(ctx.U1[1], lhs, rhs); } diff --git a/src/shader_recompiler/frontend/translate/vector_alu.cpp b/src/shader_recompiler/frontend/translate/vector_alu.cpp index ac72293e4..42dbcc513 100644 --- a/src/shader_recompiler/frontend/translate/vector_alu.cpp +++ b/src/shader_recompiler/frontend/translate/vector_alu.cpp @@ -1257,28 +1257,7 @@ void Translator::V_CVT_PK_U8_F32(const GcnInst& inst) { void Translator::V_LSHL_B64(const GcnInst& inst) { const IR::U64 src0{GetSrc64(inst.src[0])}; const IR::U64 src1{GetSrc64(inst.src[1])}; - const IR::VectorReg dst_reg{inst.dst[0].code}; - if (src0.IsImmediate()) { - if (src0.U64() == -1) { - // If src0 is a fixed -1, the result will always be -1. - ir.SetVectorReg(dst_reg, ir.Imm32(0xFFFFFFFF)); - ir.SetVectorReg(dst_reg + 1, ir.Imm32(0xFFFFFFFF)); - return; - } - if (src1.IsImmediate()) { - // If both src0 and src1 are immediates, we can calculate the result now. - // Note that according to the manual, only bits 4:0 are used from src1. - const u64 result = src0.U64() << (src1.U64() & 0x1F); - ir.SetVectorReg(dst_reg, ir.Imm32(static_cast(result))); - ir.SetVectorReg(dst_reg + 1, ir.Imm32(static_cast(result >> 32))); - return; - } - - const IR::U64 result = ir.ShiftLeftLogical(src0, ir.BitwiseAnd(src1, ir.Imm64(u64(0x3F)))); - SetDst64(inst.dst[0], result); - return; - } - UNREACHABLE_MSG("Unimplemented V_LSHL_B64 arguments"); + SetDst64(inst.dst[0], ir.ShiftLeftLogical(src0, ir.BitwiseAnd(src1, ir.Imm64(u64(0x3F))))); } void Translator::V_MUL_F64(const GcnInst& inst) { diff --git a/src/shader_recompiler/ir/ir_emitter.cpp b/src/shader_recompiler/ir/ir_emitter.cpp index 5ac08e7dc..f0558665b 100644 --- a/src/shader_recompiler/ir/ir_emitter.cpp +++ b/src/shader_recompiler/ir/ir_emitter.cpp @@ -1461,8 +1461,18 @@ U1 IREmitter::IGreaterThan(const U32& lhs, const U32& rhs, bool is_signed) { return Inst(is_signed ? Opcode::SGreaterThan : Opcode::UGreaterThan, lhs, rhs); } -U1 IREmitter::INotEqual(const U32& lhs, const U32& rhs) { - return Inst(Opcode::INotEqual, lhs, rhs); +U1 IREmitter::INotEqual(const U32U64& lhs, const U32U64& rhs) { + if (lhs.Type() != rhs.Type()) { + UNREACHABLE_MSG("Mismatching types {} and {}", lhs.Type(), rhs.Type()); + } + switch (lhs.Type()) { + case Type::U32: + return Inst(Opcode::INotEqual32, lhs, rhs); + case Type::U64: + return Inst(Opcode::INotEqual64, lhs, rhs); + default: + ThrowInvalidType(lhs.Type()); + } } U1 IREmitter::IGreaterThanEqual(const U32& lhs, const U32& rhs, bool is_signed) { diff --git a/src/shader_recompiler/ir/ir_emitter.h b/src/shader_recompiler/ir/ir_emitter.h index d1dc44d74..5dd49ce7a 100644 --- a/src/shader_recompiler/ir/ir_emitter.h +++ b/src/shader_recompiler/ir/ir_emitter.h @@ -258,7 +258,7 @@ public: [[nodiscard]] U1 IEqual(const U32U64& lhs, const U32U64& rhs); [[nodiscard]] U1 ILessThanEqual(const U32& lhs, const U32& rhs, bool is_signed); [[nodiscard]] U1 IGreaterThan(const U32& lhs, const U32& rhs, bool is_signed); - [[nodiscard]] U1 INotEqual(const U32& lhs, const U32& rhs); + [[nodiscard]] U1 INotEqual(const U32U64& lhs, const U32U64& rhs); [[nodiscard]] U1 IGreaterThanEqual(const U32& lhs, const U32& rhs, bool is_signed); [[nodiscard]] U1 LogicalOr(const U1& a, const U1& b); diff --git a/src/shader_recompiler/ir/opcodes.inc b/src/shader_recompiler/ir/opcodes.inc index b45151dba..63a4e1e62 100644 --- a/src/shader_recompiler/ir/opcodes.inc +++ b/src/shader_recompiler/ir/opcodes.inc @@ -321,7 +321,8 @@ OPCODE(SLessThanEqual, U1, U32, OPCODE(ULessThanEqual, U1, U32, U32, ) OPCODE(SGreaterThan, U1, U32, U32, ) OPCODE(UGreaterThan, U1, U32, U32, ) -OPCODE(INotEqual, U1, U32, U32, ) +OPCODE(INotEqual32, U1, U32, U32, ) +OPCODE(INotEqual64, U1, U64, U64, ) OPCODE(SGreaterThanEqual, U1, U32, U32, ) OPCODE(UGreaterThanEqual, U1, U32, U32, ) diff --git a/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp b/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp index 26d819d8e..12a1b56e9 100644 --- a/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp +++ b/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp @@ -403,9 +403,12 @@ void ConstantPropagation(IR::Block& block, IR::Inst& inst) { case IR::Opcode::IEqual64: FoldWhenAllImmediates(inst, [](u64 a, u64 b) { return a == b; }); return; - case IR::Opcode::INotEqual: + case IR::Opcode::INotEqual32: FoldWhenAllImmediates(inst, [](u32 a, u32 b) { return a != b; }); return; + case IR::Opcode::INotEqual64: + FoldWhenAllImmediates(inst, [](u64 a, u64 b) { return a != b; }); + return; case IR::Opcode::BitwiseAnd32: FoldWhenAllImmediates(inst, [](u32 a, u32 b) { return a & b; }); return; From 4f426b723f2f015af022e2f9c48813448c264d7b Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:30:55 +0100 Subject: [PATCH 09/72] Rebase of "Handle munmap over multiple VMAs" (#2233) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Unmap memory in chunks if spanning over multiple VMAs * clang * Merge fixups * Minor code style changes * Update function declarations --------- Co-authored-by: Marcin Mikołajczyk --- src/core/memory.cpp | 49 +++++++++++++++++++++++++++++---------------- src/core/memory.h | 4 +++- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index f90d4e6aa..a8dd72acc 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -389,32 +389,29 @@ s32 MemoryManager::UnmapMemory(VAddr virtual_addr, size_t size) { return UnmapMemoryImpl(virtual_addr, size); } -s32 MemoryManager::UnmapMemoryImpl(VAddr virtual_addr, size_t size) { - const auto it = FindVMA(virtual_addr); - const auto& vma_base = it->second; - ASSERT_MSG(vma_base.Contains(virtual_addr, size), - "Existing mapping does not contain requested unmap range"); - - const auto type = vma_base.type; - if (type == VMAType::Free) { - return ORBIS_OK; - } - +u64 MemoryManager::UnmapBytesFromEntry(VAddr virtual_addr, VirtualMemoryArea vma_base, u64 size) { const auto vma_base_addr = vma_base.base; const auto vma_base_size = vma_base.size; + const auto type = vma_base.type; const auto phys_base = vma_base.phys_base; const bool is_exec = vma_base.is_exec; const auto start_in_vma = virtual_addr - vma_base_addr; + const auto adjusted_size = + vma_base_size - start_in_vma < size ? vma_base_size - start_in_vma : size; const bool has_backing = type == VMAType::Direct || type == VMAType::File; + + if (type == VMAType::Free) { + return adjusted_size; + } if (type == VMAType::Direct || type == VMAType::Pooled) { - rasterizer->UnmapMemory(virtual_addr, size); + rasterizer->UnmapMemory(virtual_addr, adjusted_size); } if (type == VMAType::Flexible) { - flexible_usage -= size; + flexible_usage -= adjusted_size; } // Mark region as free and attempt to coalesce it with neighbours. - const auto new_it = CarveVMA(virtual_addr, size); + const auto new_it = CarveVMA(virtual_addr, adjusted_size); auto& vma = new_it->second; vma.type = VMAType::Free; vma.prot = MemoryProt::NoAccess; @@ -423,13 +420,25 @@ s32 MemoryManager::UnmapMemoryImpl(VAddr virtual_addr, size_t size) { vma.name = ""; MergeAdjacent(vma_map, new_it); bool readonly_file = vma.prot == MemoryProt::CpuRead && type == VMAType::File; - if (type != VMAType::Reserved && type != VMAType::PoolReserved) { // Unmap the memory region. - impl.Unmap(vma_base_addr, vma_base_size, start_in_vma, start_in_vma + size, phys_base, - is_exec, has_backing, readonly_file); + impl.Unmap(vma_base_addr, vma_base_size, start_in_vma, start_in_vma + adjusted_size, + phys_base, is_exec, has_backing, readonly_file); TRACK_FREE(virtual_addr, "VMEM"); } + return adjusted_size; +} + +s32 MemoryManager::UnmapMemoryImpl(VAddr virtual_addr, u64 size) { + u64 unmapped_bytes = 0; + do { + auto it = FindVMA(virtual_addr + unmapped_bytes); + auto& vma_base = it->second; + auto unmapped = + UnmapBytesFromEntry(virtual_addr + unmapped_bytes, vma_base, size - unmapped_bytes); + ASSERT_MSG(unmapped > 0, "Failed to unmap memory, progress is impossible"); + unmapped_bytes += unmapped; + } while (unmapped_bytes < size); return ORBIS_OK; } @@ -651,6 +660,12 @@ MemoryManager::VMAHandle MemoryManager::CarveVMA(VAddr virtual_addr, size_t size const VAddr start_in_vma = virtual_addr - vma.base; const VAddr end_in_vma = start_in_vma + size; + + if (start_in_vma == 0 && size == vma.size) { + // if requsting the whole VMA, return it + return vma_handle; + } + ASSERT_MSG(end_in_vma <= vma.size, "Mapping cannot fit inside free region"); if (end_in_vma != vma.size) { diff --git a/src/core/memory.h b/src/core/memory.h index 615ecc3eb..59e48b248 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -252,7 +252,9 @@ private: DMemHandle Split(DMemHandle dmem_handle, size_t offset_in_area); - s32 UnmapMemoryImpl(VAddr virtual_addr, size_t size); + u64 UnmapBytesFromEntry(VAddr virtual_addr, VirtualMemoryArea vma_base, u64 size); + + s32 UnmapMemoryImpl(VAddr virtual_addr, u64 size); private: AddressSpace impl; From a4eba8e827c062b5e6874255ff810346943d0ea2 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 24 Jan 2025 19:22:06 +0200 Subject: [PATCH 10/72] stubbed webbrowserdialog,npparty (#2234) * stubbed webbrowserdialog,npparty * added poly's suggestions --- CMakeLists.txt | 4 + src/common/logging/filter.cpp | 2 + src/common/logging/types.h | 2 + src/core/libraries/libs.cpp | 4 + src/core/libraries/np_party/np_party.cpp | 195 ++++++++++++++++++ src/core/libraries/np_party/np_party.h | 44 ++++ .../web_browser_dialog/webbrowserdialog.cpp | 112 ++++++++++ .../web_browser_dialog/webbrowserdialog.h | 30 +++ 8 files changed, 393 insertions(+) create mode 100644 src/core/libraries/np_party/np_party.cpp create mode 100644 src/core/libraries/np_party/np_party.h create mode 100644 src/core/libraries/web_browser_dialog/webbrowserdialog.cpp create mode 100644 src/core/libraries/web_browser_dialog/webbrowserdialog.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 3db142be7..4c9dad307 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,6 +344,8 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp src/core/libraries/razor_cpu/razor_cpu.h src/core/libraries/mouse/mouse.cpp src/core/libraries/mouse/mouse.h + src/core/libraries/web_browser_dialog/webbrowserdialog.cpp + src/core/libraries/web_browser_dialog/webbrowserdialog.h ) set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h @@ -434,6 +436,8 @@ set(NP_LIBS src/core/libraries/np_common/np_common.cpp src/core/libraries/np_trophy/np_trophy_error.h src/core/libraries/np_web_api/np_web_api.cpp src/core/libraries/np_web_api/np_web_api.h + src/core/libraries/np_party/np_party.cpp + src/core/libraries/np_party/np_party.h ) set(MISC_LIBS src/core/libraries/screenshot/screenshot.cpp diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 168d03948..f1d3a9499 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -131,6 +131,8 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { SUB(Lib, Videodec) \ SUB(Lib, RazorCpu) \ SUB(Lib, Mouse) \ + SUB(Lib, WebBrowserDialog) \ + SUB(Lib, NpParty) \ CLS(Frontend) \ CLS(Render) \ SUB(Render, Vulkan) \ diff --git a/src/common/logging/types.h b/src/common/logging/types.h index 4ca88e1be..d5530312c 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -98,6 +98,8 @@ enum class Class : u8 { Lib_Videodec, ///< The LibSceVideodec implementation. Lib_RazorCpu, ///< The LibRazorCpu implementation. Lib_Mouse, ///< The LibSceMouse implementation + Lib_WebBrowserDialog, ///< The LibSceWebBrowserDialog implementation + Lib_NpParty, ///< The LibSceNpParty implementation Frontend, ///< Emulator UI Render, ///< Video Core Render_Vulkan, ///< Vulkan backend diff --git a/src/core/libraries/libs.cpp b/src/core/libraries/libs.cpp index 6dc455028..e09de1cee 100644 --- a/src/core/libraries/libs.cpp +++ b/src/core/libraries/libs.cpp @@ -28,6 +28,7 @@ #include "core/libraries/network/ssl2.h" #include "core/libraries/np_common/np_common.h" #include "core/libraries/np_manager/np_manager.h" +#include "core/libraries/np_party/np_party.h" #include "core/libraries/np_score/np_score.h" #include "core/libraries/np_trophy/np_trophy.h" #include "core/libraries/np_web_api/np_web_api.h" @@ -52,6 +53,7 @@ #include "core/libraries/videodec/videodec.h" #include "core/libraries/videodec/videodec2.h" #include "core/libraries/videoout/video_out.h" +#include "core/libraries/web_browser_dialog/webbrowserdialog.h" #include "fiber/fiber.h" #include "jpeg/jpegenc.h" @@ -107,6 +109,8 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { Libraries::Fiber::RegisterlibSceFiber(sym); Libraries::JpegEnc::RegisterlibSceJpegEnc(sym); Libraries::Mouse::RegisterlibSceMouse(sym); + Libraries::WebBrowserDialog::RegisterlibSceWebBrowserDialog(sym); + Libraries::NpParty::RegisterlibSceNpParty(sym); } } // namespace Libraries diff --git a/src/core/libraries/np_party/np_party.cpp b/src/core/libraries/np_party/np_party.cpp new file mode 100644 index 000000000..8a66ccb22 --- /dev/null +++ b/src/core/libraries/np_party/np_party.cpp @@ -0,0 +1,195 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/libs.h" +#include "core/libraries/np_party/np_party.h" + +namespace Libraries::NpParty { + +s32 PS4_SYSV_ABI sceNpPartyCheckCallback() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyCreate() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyCreateA() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyGetId() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyGetMemberInfo() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyGetMemberInfoA() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyGetMembers() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyGetMembersA() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyGetMemberSessionInfo() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyGetMemberVoiceInfo() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyGetState() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyGetStateAsUser() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyGetStateAsUserA() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyGetVoiceChatPriority() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyInitialize() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyJoin() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyLeave() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyRegisterHandler() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyRegisterHandlerA() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyRegisterPrivateHandler() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartySendBinaryMessage() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartySetVoiceChatPriority() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyShowInvitationList() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyShowInvitationListA() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyTerminate() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpPartyUnregisterPrivateHandler() { + LOG_ERROR(Lib_NpParty, "(STUBBED) called"); + return ORBIS_OK; +} + +void RegisterlibSceNpParty(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("3e4k2mzLkmc", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyCheckCallback); + LIB_FUNCTION("nOZRy-slBoA", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyCreate); + LIB_FUNCTION("XQSUbbnpPBA", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyCreateA); + LIB_FUNCTION("DRA3ay-1DFQ", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyGetId); + LIB_FUNCTION("F1P+-wpxQow", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyGetMemberInfo); + LIB_FUNCTION("v2RYVGrJDkM", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyGetMemberInfoA); + LIB_FUNCTION("T2UOKf00ZN0", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyGetMembers); + LIB_FUNCTION("TaNw7W25QJw", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyGetMembersA); + LIB_FUNCTION("4gOMfNYzllw", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyGetMemberSessionInfo); + LIB_FUNCTION("EKi1jx59SP4", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyGetMemberVoiceInfo); + LIB_FUNCTION("aEzKdJzATZ0", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyGetState); + LIB_FUNCTION("o7grRhiGHYI", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyGetStateAsUser); + LIB_FUNCTION("EjyAI+QNgFw", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyGetStateAsUserA); + LIB_FUNCTION("-lc6XZnQXvM", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyGetVoiceChatPriority); + LIB_FUNCTION("lhYCTQmBkds", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyInitialize); + LIB_FUNCTION("RXNCDw2GDEg", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyJoin); + LIB_FUNCTION("J8jAi-tfJHc", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyLeave); + LIB_FUNCTION("kA88gbv71ao", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyRegisterHandler); + LIB_FUNCTION("+v4fVHMwFWc", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyRegisterHandlerA); + LIB_FUNCTION("zo4G5WWYpKg", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyRegisterPrivateHandler); + LIB_FUNCTION("U6VdUe-PNAY", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartySendBinaryMessage); + LIB_FUNCTION("nazKyHygHhY", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartySetVoiceChatPriority); + LIB_FUNCTION("-MFiL7hEnPE", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyShowInvitationList); + LIB_FUNCTION("yARHEYLajs0", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyShowInvitationListA); + LIB_FUNCTION("oLYkibiHqRA", "libSceNpParty", 1, "libSceNpParty", 1, 1, sceNpPartyTerminate); + LIB_FUNCTION("zQ7gIvt11Pc", "libSceNpParty", 1, "libSceNpParty", 1, 1, + sceNpPartyUnregisterPrivateHandler); + LIB_FUNCTION("nOZRy-slBoA", "libSceNpPartyCompat", 1, "libSceNpParty", 1, 1, sceNpPartyCreate); + LIB_FUNCTION("F1P+-wpxQow", "libSceNpPartyCompat", 1, "libSceNpParty", 1, 1, + sceNpPartyGetMemberInfo); + LIB_FUNCTION("T2UOKf00ZN0", "libSceNpPartyCompat", 1, "libSceNpParty", 1, 1, + sceNpPartyGetMembers); + LIB_FUNCTION("o7grRhiGHYI", "libSceNpPartyCompat", 1, "libSceNpParty", 1, 1, + sceNpPartyGetStateAsUser); + LIB_FUNCTION("kA88gbv71ao", "libSceNpPartyCompat", 1, "libSceNpParty", 1, 1, + sceNpPartyRegisterHandler); + LIB_FUNCTION("-MFiL7hEnPE", "libSceNpPartyCompat", 1, "libSceNpParty", 1, 1, + sceNpPartyShowInvitationList); +}; + +} // namespace Libraries::NpParty \ No newline at end of file diff --git a/src/core/libraries/np_party/np_party.h b/src/core/libraries/np_party/np_party.h new file mode 100644 index 000000000..d5f20e4f8 --- /dev/null +++ b/src/core/libraries/np_party/np_party.h @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::NpParty { + +s32 PS4_SYSV_ABI sceNpPartyCheckCallback(); +s32 PS4_SYSV_ABI sceNpPartyCreate(); +s32 PS4_SYSV_ABI sceNpPartyCreateA(); +s32 PS4_SYSV_ABI sceNpPartyGetId(); +s32 PS4_SYSV_ABI sceNpPartyGetMemberInfo(); +s32 PS4_SYSV_ABI sceNpPartyGetMemberInfoA(); +s32 PS4_SYSV_ABI sceNpPartyGetMembers(); +s32 PS4_SYSV_ABI sceNpPartyGetMembersA(); +s32 PS4_SYSV_ABI sceNpPartyGetMemberSessionInfo(); +s32 PS4_SYSV_ABI sceNpPartyGetMemberVoiceInfo(); +s32 PS4_SYSV_ABI sceNpPartyGetState(); +s32 PS4_SYSV_ABI sceNpPartyGetStateAsUser(); +s32 PS4_SYSV_ABI sceNpPartyGetStateAsUserA(); +s32 PS4_SYSV_ABI sceNpPartyGetVoiceChatPriority(); +s32 PS4_SYSV_ABI sceNpPartyInitialize(); +s32 PS4_SYSV_ABI sceNpPartyJoin(); +s32 PS4_SYSV_ABI sceNpPartyLeave(); +s32 PS4_SYSV_ABI sceNpPartyRegisterHandler(); +s32 PS4_SYSV_ABI sceNpPartyRegisterHandlerA(); +s32 PS4_SYSV_ABI sceNpPartyRegisterPrivateHandler(); +s32 PS4_SYSV_ABI sceNpPartySendBinaryMessage(); +s32 PS4_SYSV_ABI sceNpPartySetVoiceChatPriority(); +s32 PS4_SYSV_ABI sceNpPartyShowInvitationList(); +s32 PS4_SYSV_ABI sceNpPartyShowInvitationListA(); +s32 PS4_SYSV_ABI sceNpPartyTerminate(); +s32 PS4_SYSV_ABI sceNpPartyUnregisterPrivateHandler(); +s32 PS4_SYSV_ABI module_start(); +s32 PS4_SYSV_ABI module_stop(); + +void RegisterlibSceNpParty(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::NpParty \ No newline at end of file diff --git a/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp b/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp new file mode 100644 index 000000000..ee434f96a --- /dev/null +++ b/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp @@ -0,0 +1,112 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/libs.h" +#include "core/libraries/web_browser_dialog/webbrowserdialog.h" + +namespace Libraries::WebBrowserDialog { + +s32 PS4_SYSV_ABI sceWebBrowserDialogClose() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogGetEvent() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogGetResult() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogGetStatus() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogInitialize() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogNavigate() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogOpen() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogOpenForPredeterminedContent() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogResetCookie() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogSetCookie() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogSetZoom() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogTerminate() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceWebBrowserDialogUpdateStatus() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI Func_F2BE042771625F8C() { + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + return ORBIS_OK; +} + +void RegisterlibSceWebBrowserDialog(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("PSK+Eik919Q", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogClose); + LIB_FUNCTION("Wit4LjeoeX4", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogGetEvent); + LIB_FUNCTION("vCaW0fgVQmc", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogGetResult); + LIB_FUNCTION("CFTG6a8TjOU", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogGetStatus); + LIB_FUNCTION("jqb7HntFQFc", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogInitialize); + LIB_FUNCTION("uYELOMVnmNQ", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogNavigate); + LIB_FUNCTION("FraP7debcdg", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogOpen); + LIB_FUNCTION("O7dIZQrwVFY", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogOpenForPredeterminedContent); + LIB_FUNCTION("Cya+jvTtPqg", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogResetCookie); + LIB_FUNCTION("TZnDVkP91Rg", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogSetCookie); + LIB_FUNCTION("RLhKBOoNyXY", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogSetZoom); + LIB_FUNCTION("ocHtyBwHfys", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogTerminate); + LIB_FUNCTION("h1dR-t5ISgg", "libSceWebBrowserDialog", 1, "libSceWebBrowserDialog", 1, 1, + sceWebBrowserDialogUpdateStatus); + LIB_FUNCTION("8r4EJ3FiX4w", "libSceWebBrowserDialogLimited", 1, "libSceWebBrowserDialog", 1, 1, + Func_F2BE042771625F8C); +}; + +} // namespace Libraries::WebBrowserDialog \ No newline at end of file diff --git a/src/core/libraries/web_browser_dialog/webbrowserdialog.h b/src/core/libraries/web_browser_dialog/webbrowserdialog.h new file mode 100644 index 000000000..aa118fe45 --- /dev/null +++ b/src/core/libraries/web_browser_dialog/webbrowserdialog.h @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::WebBrowserDialog { + +s32 PS4_SYSV_ABI sceWebBrowserDialogClose(); +s32 PS4_SYSV_ABI sceWebBrowserDialogGetEvent(); +s32 PS4_SYSV_ABI sceWebBrowserDialogGetResult(); +s32 PS4_SYSV_ABI sceWebBrowserDialogGetStatus(); +s32 PS4_SYSV_ABI sceWebBrowserDialogInitialize(); +s32 PS4_SYSV_ABI sceWebBrowserDialogNavigate(); +s32 PS4_SYSV_ABI sceWebBrowserDialogOpen(); +s32 PS4_SYSV_ABI sceWebBrowserDialogOpenForPredeterminedContent(); +s32 PS4_SYSV_ABI sceWebBrowserDialogResetCookie(); +s32 PS4_SYSV_ABI sceWebBrowserDialogSetCookie(); +s32 PS4_SYSV_ABI sceWebBrowserDialogSetZoom(); +s32 PS4_SYSV_ABI sceWebBrowserDialogTerminate(); +s32 PS4_SYSV_ABI sceWebBrowserDialogUpdateStatus(); +s32 PS4_SYSV_ABI Func_F2BE042771625F8C(); + +void RegisterlibSceWebBrowserDialog(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::WebBrowserDialog \ No newline at end of file From b3c573f7989ffe3cc0fe15ce69f620bcaab9c61b Mon Sep 17 00:00:00 2001 From: poly <47796739+polybiusproxy@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:37:34 +0100 Subject: [PATCH 11/72] libraries/fiber: print fiber ctx size on stack overflow --- src/core/libraries/fiber/fiber.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/libraries/fiber/fiber.cpp b/src/core/libraries/fiber/fiber.cpp index b77b5b5b6..345f0834d 100644 --- a/src/core/libraries/fiber/fiber.cpp +++ b/src/core/libraries/fiber/fiber.cpp @@ -37,8 +37,9 @@ extern "C" void PS4_SYSV_ABI _sceFiberForceQuit(u64 ret) { void PS4_SYSV_ABI _sceFiberCheckStackOverflow(OrbisFiberContext* ctx) { u64* stack_base = reinterpret_cast(ctx->current_fiber->addr_context); + u64 stack_size = ctx->current_fiber->size_context; if (stack_base && *stack_base != kFiberStackSignature) { - UNREACHABLE_MSG("Stack overflow detected in fiber."); + UNREACHABLE_MSG("Stack overflow detected in fiber with size = 0x{:x}", stack_size); } } From 56f4b8a2b860fa14421b0e6884532b441ea34a12 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 24 Jan 2025 10:41:58 -0800 Subject: [PATCH 12/72] shader_recompiler: Implement shader export formats. (#2226) --- externals/sirit | 2 +- .../spirv/emit_spirv_bitwise_conversion.cpp | 44 +++++ .../backend/spirv/emit_spirv_instructions.h | 8 + .../frontend/translate/export.cpp | 152 ++++++++++++++---- .../frontend/translate/translate.h | 9 ++ .../frontend/translate/vector_alu.cpp | 33 ++-- src/shader_recompiler/ir/ir_emitter.cpp | 32 ++++ src/shader_recompiler/ir/ir_emitter.h | 8 + src/shader_recompiler/ir/opcodes.inc | 8 + .../ir/passes/constant_propagation_pass.cpp | 16 ++ src/shader_recompiler/runtime_info.h | 1 + src/video_core/amdgpu/liverpool.h | 4 + .../renderer_vulkan/vk_graphics_pipeline.h | 5 +- .../renderer_vulkan/vk_pipeline_cache.cpp | 21 ++- 14 files changed, 286 insertions(+), 57 deletions(-) diff --git a/externals/sirit b/externals/sirit index 26ad5a9d0..d6f3c0d99 160000 --- a/externals/sirit +++ b/externals/sirit @@ -1 +1 @@ -Subproject commit 26ad5a9d0fe13260b0d7d6c64419d01a196b2e32 +Subproject commit d6f3c0d99862ab2ff8f95e9ac221560f1f97e29a diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_bitwise_conversion.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_bitwise_conversion.cpp index 02ac74e19..539c6cb81 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_bitwise_conversion.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_bitwise_conversion.cpp @@ -58,4 +58,48 @@ Id EmitUnpackHalf2x16(EmitContext& ctx, Id value) { return ctx.OpUnpackHalf2x16(ctx.F32[2], value); } +Id EmitPackUnorm2x16(EmitContext& ctx, Id value) { + return ctx.OpPackUnorm2x16(ctx.U32[1], value); +} + +Id EmitUnpackUnorm2x16(EmitContext& ctx, Id value) { + return ctx.OpUnpackUnorm2x16(ctx.F32[2], value); +} + +Id EmitPackSnorm2x16(EmitContext& ctx, Id value) { + return ctx.OpPackSnorm2x16(ctx.U32[1], value); +} + +Id EmitUnpackSnorm2x16(EmitContext& ctx, Id value) { + return ctx.OpUnpackSnorm2x16(ctx.F32[2], value); +} + +Id EmitPackUint2x16(EmitContext& ctx, Id value) { + // No SPIR-V instruction for this, do it manually. + const auto x{ctx.OpCompositeExtract(ctx.U32[1], value, 0)}; + const auto y{ctx.OpCompositeExtract(ctx.U32[1], value, 1)}; + return ctx.OpBitFieldInsert(ctx.U32[1], x, y, ctx.ConstU32(16U), ctx.ConstU32(16U)); +} + +Id EmitUnpackUint2x16(EmitContext& ctx, Id value) { + // No SPIR-V instruction for this, do it manually. + const auto x{ctx.OpBitFieldUExtract(ctx.U32[1], value, ctx.ConstU32(0U), ctx.ConstU32(16U))}; + const auto y{ctx.OpBitFieldUExtract(ctx.U32[1], value, ctx.ConstU32(16U), ctx.ConstU32(16U))}; + return ctx.OpCompositeConstruct(ctx.U32[2], x, y); +} + +Id EmitPackSint2x16(EmitContext& ctx, Id value) { + // No SPIR-V instruction for this, do it manually. + const auto x{ctx.OpCompositeExtract(ctx.U32[1], value, 0)}; + const auto y{ctx.OpCompositeExtract(ctx.U32[1], value, 1)}; + return ctx.OpBitFieldInsert(ctx.U32[1], x, y, ctx.ConstU32(16U), ctx.ConstU32(16U)); +} + +Id EmitUnpackSint2x16(EmitContext& ctx, Id value) { + // No SPIR-V instruction for this, do it manually. + const auto x{ctx.OpBitFieldSExtract(ctx.U32[1], value, ctx.ConstU32(0U), ctx.ConstU32(16U))}; + const auto y{ctx.OpBitFieldSExtract(ctx.U32[1], value, ctx.ConstU32(16U), ctx.ConstU32(16U))}; + return ctx.OpCompositeConstruct(ctx.U32[2], x, y); +} + } // namespace Shader::Backend::SPIRV diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index 4833dc9d0..842b13207 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h @@ -197,6 +197,14 @@ Id EmitPackFloat2x16(EmitContext& ctx, Id value); Id EmitUnpackFloat2x16(EmitContext& ctx, Id value); Id EmitPackHalf2x16(EmitContext& ctx, Id value); Id EmitUnpackHalf2x16(EmitContext& ctx, Id value); +Id EmitPackUnorm2x16(EmitContext& ctx, Id value); +Id EmitUnpackUnorm2x16(EmitContext& ctx, Id value); +Id EmitPackSnorm2x16(EmitContext& ctx, Id value); +Id EmitUnpackSnorm2x16(EmitContext& ctx, Id value); +Id EmitPackUint2x16(EmitContext& ctx, Id value); +Id EmitUnpackUint2x16(EmitContext& ctx, Id value); +Id EmitPackSint2x16(EmitContext& ctx, Id value); +Id EmitUnpackSint2x16(EmitContext& ctx, Id value); Id EmitFPAbs16(EmitContext& ctx, Id value); Id EmitFPAbs32(EmitContext& ctx, Id value); Id EmitFPAbs64(EmitContext& ctx, Id value); diff --git a/src/shader_recompiler/frontend/translate/export.cpp b/src/shader_recompiler/frontend/translate/export.cpp index 38ff9ae14..84c2ee658 100644 --- a/src/shader_recompiler/frontend/translate/export.cpp +++ b/src/shader_recompiler/frontend/translate/export.cpp @@ -7,6 +7,125 @@ namespace Shader::Gcn { +u32 SwizzleMrtComponent(const FragmentRuntimeInfo::PsColorBuffer& color_buffer, u32 comp) { + const auto [r, g, b, a] = color_buffer.swizzle; + const std::array swizzle_array = {r, g, b, a}; + const auto swizzled_comp_type = static_cast(swizzle_array[comp]); + constexpr auto min_comp_type = static_cast(AmdGpu::CompSwizzle::Red); + return swizzled_comp_type >= min_comp_type ? swizzled_comp_type - min_comp_type : comp; +} + +void Translator::ExportMrtValue(IR::Attribute attribute, u32 comp, const IR::F32& value, + const FragmentRuntimeInfo::PsColorBuffer& color_buffer) { + const auto converted = ApplyWriteNumberConversion(ir, value, color_buffer.num_conversion); + ir.SetAttribute(attribute, converted, comp); +} + +void Translator::ExportMrtCompressed(IR::Attribute attribute, u32 idx, const IR::U32& value) { + const u32 color_buffer_idx = + static_cast(attribute) - static_cast(IR::Attribute::RenderTarget0); + const auto color_buffer = runtime_info.fs_info.color_buffers[color_buffer_idx]; + + IR::Value unpacked_value; + bool is_integer = false; + switch (color_buffer.export_format) { + case AmdGpu::Liverpool::ShaderExportFormat::Zero: + // No export + return; + case AmdGpu::Liverpool::ShaderExportFormat::ABGR_FP16: + unpacked_value = ir.UnpackHalf2x16(value); + break; + case AmdGpu::Liverpool::ShaderExportFormat::ABGR_UNORM16: + unpacked_value = ir.UnpackUnorm2x16(value); + break; + case AmdGpu::Liverpool::ShaderExportFormat::ABGR_SNORM16: + unpacked_value = ir.UnpackSnorm2x16(value); + break; + case AmdGpu::Liverpool::ShaderExportFormat::ABGR_UINT16: + unpacked_value = ir.UnpackUint2x16(value); + is_integer = true; + break; + case AmdGpu::Liverpool::ShaderExportFormat::ABGR_SINT16: + unpacked_value = ir.UnpackSint2x16(value); + is_integer = true; + break; + default: + UNREACHABLE_MSG("Unimplemented compressed MRT export format {}", + static_cast(color_buffer.export_format)); + break; + } + + const auto r = ir.CompositeExtract(unpacked_value, 0); + const auto g = ir.CompositeExtract(unpacked_value, 1); + const IR::F32 float_r = is_integer ? ir.BitCast(IR::U32{r}) : IR::F32{r}; + const IR::F32 float_g = is_integer ? ir.BitCast(IR::U32{g}) : IR::F32{g}; + + const auto swizzled_r = SwizzleMrtComponent(color_buffer, idx * 2); + const auto swizzled_g = SwizzleMrtComponent(color_buffer, idx * 2 + 1); + + ExportMrtValue(attribute, swizzled_r, float_r, color_buffer); + ExportMrtValue(attribute, swizzled_g, float_g, color_buffer); +} + +void Translator::ExportMrtUncompressed(IR::Attribute attribute, u32 comp, const IR::F32& value) { + const u32 color_buffer_idx = + static_cast(attribute) - static_cast(IR::Attribute::RenderTarget0); + const auto color_buffer = runtime_info.fs_info.color_buffers[color_buffer_idx]; + const auto swizzled_comp = SwizzleMrtComponent(color_buffer, comp); + + switch (color_buffer.export_format) { + case AmdGpu::Liverpool::ShaderExportFormat::Zero: + // No export + return; + case AmdGpu::Liverpool::ShaderExportFormat::R_32: + // Red only + if (swizzled_comp != 0) { + return; + } + break; + case AmdGpu::Liverpool::ShaderExportFormat::GR_32: + // Red and Green only + if (swizzled_comp != 0 && swizzled_comp != 1) { + return; + } + break; + case AmdGpu::Liverpool::ShaderExportFormat::AR_32: + // Red and Alpha only + if (swizzled_comp != 0 && swizzled_comp != 3) { + return; + } + break; + case AmdGpu::Liverpool::ShaderExportFormat::ABGR_32: + // All components + break; + default: + UNREACHABLE_MSG("Unimplemented uncompressed MRT export format {}", + static_cast(color_buffer.export_format)); + break; + } + ExportMrtValue(attribute, swizzled_comp, value, color_buffer); +} + +void Translator::ExportCompressed(IR::Attribute attribute, u32 idx, const IR::U32& value) { + if (IsMrt(attribute)) { + ExportMrtCompressed(attribute, idx, value); + return; + } + const IR::Value unpacked_value = ir.UnpackHalf2x16(value); + const IR::F32 r = IR::F32{ir.CompositeExtract(unpacked_value, 0)}; + const IR::F32 g = IR::F32{ir.CompositeExtract(unpacked_value, 1)}; + ir.SetAttribute(attribute, r, idx * 2); + ir.SetAttribute(attribute, g, idx * 2 + 1); +} + +void Translator::ExportUncompressed(IR::Attribute attribute, u32 comp, const IR::F32& value) { + if (IsMrt(attribute)) { + ExportMrtUncompressed(attribute, comp, value); + return; + } + ir.SetAttribute(attribute, value, comp); +} + void Translator::EmitExport(const GcnInst& inst) { if (ir.block->has_multiple_predecessors && info.stage == Stage::Fragment) { ir.Discard(ir.LogicalNot(ir.GetExec())); @@ -26,41 +145,15 @@ void Translator::EmitExport(const GcnInst& inst) { IR::VectorReg(inst.src[3].code), }; - const auto set_attribute = [&](u32 comp, IR::F32 value) { - if (!IR::IsMrt(attrib)) { - ir.SetAttribute(attrib, value, comp); - return; - } - const u32 index = u32(attrib) - u32(IR::Attribute::RenderTarget0); - const auto col_buf = runtime_info.fs_info.color_buffers[index]; - const auto converted = IR::ApplyWriteNumberConversion(ir, value, col_buf.num_conversion); - const auto [r, g, b, a] = col_buf.swizzle; - const std::array swizzle_array = {r, g, b, a}; - const auto swizzled_comp = swizzle_array[comp]; - if (u32(swizzled_comp) < u32(AmdGpu::CompSwizzle::Red)) { - ir.SetAttribute(attrib, converted, comp); - return; - } - ir.SetAttribute(attrib, converted, u32(swizzled_comp) - u32(AmdGpu::CompSwizzle::Red)); - }; - - const auto unpack = [&](u32 idx) { - const IR::Value value = ir.UnpackHalf2x16(ir.GetVectorReg(vsrc[idx])); - const IR::F32 r = IR::F32{ir.CompositeExtract(value, 0)}; - const IR::F32 g = IR::F32{ir.CompositeExtract(value, 1)}; - set_attribute(idx * 2, r); - set_attribute(idx * 2 + 1, g); - }; - // Components are float16 packed into a VGPR if (exp.compr) { // Export R, G if (exp.en & 1) { - unpack(0); + ExportCompressed(attrib, 0, ir.GetVectorReg(vsrc[0])); } // Export B, A if ((exp.en >> 2) & 1) { - unpack(1); + ExportCompressed(attrib, 1, ir.GetVectorReg(vsrc[1])); } } else { // Components are float32 into separate VGPRS @@ -69,8 +162,7 @@ void Translator::EmitExport(const GcnInst& inst) { if ((mask & 1) == 0) { continue; } - const IR::F32 comp = ir.GetVectorReg(vsrc[i]); - set_attribute(i, comp); + ExportUncompressed(attrib, i, ir.GetVectorReg(vsrc[i])); } } if (IR::IsMrt(attrib)) { diff --git a/src/shader_recompiler/frontend/translate/translate.h b/src/shader_recompiler/frontend/translate/translate.h index 496455b50..287885854 100644 --- a/src/shader_recompiler/frontend/translate/translate.h +++ b/src/shader_recompiler/frontend/translate/translate.h @@ -170,6 +170,7 @@ public: void V_SUBBREV_U32(const GcnInst& inst); void V_LDEXP_F32(const GcnInst& inst); void V_CVT_PKNORM_U16_F32(const GcnInst& inst); + void V_CVT_PKNORM_I16_F32(const GcnInst& inst); void V_CVT_PKRTZ_F16_F32(const GcnInst& inst); // VOP1 @@ -244,6 +245,7 @@ public: void V_SAD(const GcnInst& inst); void V_SAD_U32(const GcnInst& inst); void V_CVT_PK_U16_U32(const GcnInst& inst); + void V_CVT_PK_I16_I32(const GcnInst& inst); void V_CVT_PK_U8_F32(const GcnInst& inst); void V_LSHL_B64(const GcnInst& inst); void V_MUL_F64(const GcnInst& inst); @@ -306,6 +308,13 @@ private: IR::F32 SelectCubeResult(const IR::F32& x, const IR::F32& y, const IR::F32& z, const IR::F32& x_res, const IR::F32& y_res, const IR::F32& z_res); + void ExportMrtValue(IR::Attribute attribute, u32 comp, const IR::F32& value, + const FragmentRuntimeInfo::PsColorBuffer& color_buffer); + void ExportMrtCompressed(IR::Attribute attribute, u32 idx, const IR::U32& value); + void ExportMrtUncompressed(IR::Attribute attribute, u32 comp, const IR::F32& value); + void ExportCompressed(IR::Attribute attribute, u32 idx, const IR::U32& value); + void ExportUncompressed(IR::Attribute attribute, u32 comp, const IR::F32& value); + void LogMissingOpcode(const GcnInst& inst); private: diff --git a/src/shader_recompiler/frontend/translate/vector_alu.cpp b/src/shader_recompiler/frontend/translate/vector_alu.cpp index 42dbcc513..f73618dbe 100644 --- a/src/shader_recompiler/frontend/translate/vector_alu.cpp +++ b/src/shader_recompiler/frontend/translate/vector_alu.cpp @@ -96,6 +96,8 @@ void Translator::EmitVectorAlu(const GcnInst& inst) { return V_LDEXP_F32(inst); case Opcode::V_CVT_PKNORM_U16_F32: return V_CVT_PKNORM_U16_F32(inst); + case Opcode::V_CVT_PKNORM_I16_F32: + return V_CVT_PKNORM_I16_F32(inst); case Opcode::V_CVT_PKRTZ_F16_F32: return V_CVT_PKRTZ_F16_F32(inst); @@ -376,6 +378,8 @@ void Translator::EmitVectorAlu(const GcnInst& inst) { return V_SAD_U32(inst); case Opcode::V_CVT_PK_U16_U32: return V_CVT_PK_U16_U32(inst); + case Opcode::V_CVT_PK_I16_I32: + return V_CVT_PK_I16_I32(inst); case Opcode::V_CVT_PK_U8_F32: return V_CVT_PK_U8_F32(inst); case Opcode::V_LSHL_B64: @@ -645,12 +649,15 @@ void Translator::V_LDEXP_F32(const GcnInst& inst) { } void Translator::V_CVT_PKNORM_U16_F32(const GcnInst& inst) { - const IR::F32 src0{GetSrc(inst.src[0])}; - const IR::F32 src1{GetSrc(inst.src[1])}; - const IR::U32 dst0 = ir.ConvertFToU(32, ir.FPMul(src0, ir.Imm32(65535.f))); - const IR::U32 dst1 = ir.ConvertFToU(32, ir.FPMul(src1, ir.Imm32(65535.f))); - const IR::VectorReg dst_reg{inst.dst[0].code}; - ir.SetVectorReg(dst_reg, ir.BitFieldInsert(dst0, dst1, ir.Imm32(16), ir.Imm32(16))); + const IR::Value vec_f32 = + ir.CompositeConstruct(GetSrc(inst.src[0]), GetSrc(inst.src[1])); + SetDst(inst.dst[0], ir.PackUnorm2x16(vec_f32)); +} + +void Translator::V_CVT_PKNORM_I16_F32(const GcnInst& inst) { + const IR::Value vec_f32 = + ir.CompositeConstruct(GetSrc(inst.src[0]), GetSrc(inst.src[1])); + SetDst(inst.dst[0], ir.PackSnorm2x16(vec_f32)); } void Translator::V_CVT_PKRTZ_F16_F32(const GcnInst& inst) { @@ -1237,11 +1244,15 @@ void Translator::V_SAD_U32(const GcnInst& inst) { } void Translator::V_CVT_PK_U16_U32(const GcnInst& inst) { - const IR::U32 src0{GetSrc(inst.src[0])}; - const IR::U32 src1{GetSrc(inst.src[1])}; - const IR::U32 lo = ir.IMin(src0, ir.Imm32(0xFFFF), false); - const IR::U32 hi = ir.IMin(src1, ir.Imm32(0xFFFF), false); - SetDst(inst.dst[0], ir.BitFieldInsert(lo, hi, ir.Imm32(16), ir.Imm32(16))); + const IR::Value vec_u32 = + ir.CompositeConstruct(GetSrc(inst.src[0]), GetSrc(inst.src[1])); + SetDst(inst.dst[0], ir.PackUint2x16(vec_u32)); +} + +void Translator::V_CVT_PK_I16_I32(const GcnInst& inst) { + const IR::Value vec_u32 = + ir.CompositeConstruct(GetSrc(inst.src[0]), GetSrc(inst.src[1])); + SetDst(inst.dst[0], ir.PackSint2x16(vec_u32)); } void Translator::V_CVT_PK_U8_F32(const GcnInst& inst) { diff --git a/src/shader_recompiler/ir/ir_emitter.cpp b/src/shader_recompiler/ir/ir_emitter.cpp index f0558665b..ecbe1f838 100644 --- a/src/shader_recompiler/ir/ir_emitter.cpp +++ b/src/shader_recompiler/ir/ir_emitter.cpp @@ -795,6 +795,38 @@ Value IREmitter::UnpackHalf2x16(const U32& value) { return Inst(Opcode::UnpackHalf2x16, value); } +U32 IREmitter::PackUnorm2x16(const Value& vector) { + return Inst(Opcode::PackUnorm2x16, vector); +} + +Value IREmitter::UnpackUnorm2x16(const U32& value) { + return Inst(Opcode::UnpackUnorm2x16, value); +} + +U32 IREmitter::PackSnorm2x16(const Value& vector) { + return Inst(Opcode::PackSnorm2x16, vector); +} + +Value IREmitter::UnpackSnorm2x16(const U32& value) { + return Inst(Opcode::UnpackSnorm2x16, value); +} + +U32 IREmitter::PackUint2x16(const Value& value) { + return Inst(Opcode::PackUint2x16, value); +} + +Value IREmitter::UnpackUint2x16(const U32& value) { + return Inst(Opcode::UnpackUint2x16, value); +} + +U32 IREmitter::PackSint2x16(const Value& value) { + return Inst(Opcode::PackSint2x16, value); +} + +Value IREmitter::UnpackSint2x16(const U32& value) { + return Inst(Opcode::UnpackSint2x16, value); +} + F32F64 IREmitter::FPMul(const F32F64& a, const F32F64& b) { if (a.Type() != b.Type()) { UNREACHABLE_MSG("Mismatching types {} and {}", a.Type(), b.Type()); diff --git a/src/shader_recompiler/ir/ir_emitter.h b/src/shader_recompiler/ir/ir_emitter.h index 5dd49ce7a..97b94187a 100644 --- a/src/shader_recompiler/ir/ir_emitter.h +++ b/src/shader_recompiler/ir/ir_emitter.h @@ -175,6 +175,14 @@ public: [[nodiscard]] U32 PackHalf2x16(const Value& vector); [[nodiscard]] Value UnpackHalf2x16(const U32& value); + [[nodiscard]] U32 PackUnorm2x16(const Value& vector); + [[nodiscard]] Value UnpackUnorm2x16(const U32& value); + [[nodiscard]] U32 PackSnorm2x16(const Value& vector); + [[nodiscard]] Value UnpackSnorm2x16(const U32& value); + [[nodiscard]] U32 PackUint2x16(const Value& value); + [[nodiscard]] Value UnpackUint2x16(const U32& value); + [[nodiscard]] U32 PackSint2x16(const Value& value); + [[nodiscard]] Value UnpackSint2x16(const U32& value); [[nodiscard]] F32F64 FPAdd(const F32F64& a, const F32F64& b); [[nodiscard]] F32F64 FPSub(const F32F64& a, const F32F64& b); diff --git a/src/shader_recompiler/ir/opcodes.inc b/src/shader_recompiler/ir/opcodes.inc index 63a4e1e62..6750be5a6 100644 --- a/src/shader_recompiler/ir/opcodes.inc +++ b/src/shader_recompiler/ir/opcodes.inc @@ -187,6 +187,14 @@ OPCODE(PackFloat2x16, U32, F16x OPCODE(UnpackFloat2x16, F16x2, U32, ) OPCODE(PackHalf2x16, U32, F32x2, ) OPCODE(UnpackHalf2x16, F32x2, U32, ) +OPCODE(PackUnorm2x16, U32, F32x2, ) +OPCODE(UnpackUnorm2x16, F32x2, U32, ) +OPCODE(PackSnorm2x16, U32, F32x2, ) +OPCODE(UnpackSnorm2x16, F32x2, U32, ) +OPCODE(PackUint2x16, U32, U32x2, ) +OPCODE(UnpackUint2x16, U32x2, U32, ) +OPCODE(PackSint2x16, U32, U32x2, ) +OPCODE(UnpackSint2x16, U32x2, U32, ) // Floating-point operations OPCODE(FPAbs32, F32, F32, ) diff --git a/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp b/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp index 12a1b56e9..c72b9e835 100644 --- a/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp +++ b/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp @@ -348,6 +348,22 @@ void ConstantPropagation(IR::Block& block, IR::Inst& inst) { return FoldInverseFunc(inst, IR::Opcode::UnpackFloat2x16); case IR::Opcode::UnpackFloat2x16: return FoldInverseFunc(inst, IR::Opcode::PackFloat2x16); + case IR::Opcode::PackUnorm2x16: + return FoldInverseFunc(inst, IR::Opcode::UnpackUnorm2x16); + case IR::Opcode::UnpackUnorm2x16: + return FoldInverseFunc(inst, IR::Opcode::PackUnorm2x16); + case IR::Opcode::PackSnorm2x16: + return FoldInverseFunc(inst, IR::Opcode::UnpackSnorm2x16); + case IR::Opcode::UnpackSnorm2x16: + return FoldInverseFunc(inst, IR::Opcode::PackSnorm2x16); + case IR::Opcode::PackUint2x16: + return FoldInverseFunc(inst, IR::Opcode::UnpackUint2x16); + case IR::Opcode::UnpackUint2x16: + return FoldInverseFunc(inst, IR::Opcode::PackUint2x16); + case IR::Opcode::PackSint2x16: + return FoldInverseFunc(inst, IR::Opcode::UnpackSint2x16); + case IR::Opcode::UnpackSint2x16: + return FoldInverseFunc(inst, IR::Opcode::PackSint2x16); case IR::Opcode::SelectU1: case IR::Opcode::SelectU8: case IR::Opcode::SelectU16: diff --git a/src/shader_recompiler/runtime_info.h b/src/shader_recompiler/runtime_info.h index 2bf5e3f0a..103c1faa8 100644 --- a/src/shader_recompiler/runtime_info.h +++ b/src/shader_recompiler/runtime_info.h @@ -184,6 +184,7 @@ struct FragmentRuntimeInfo { AmdGpu::NumberFormat num_format; AmdGpu::NumberConversion num_conversion; AmdGpu::CompMapping swizzle; + AmdGpu::Liverpool::ShaderExportFormat export_format; auto operator<=>(const PsColorBuffer&) const noexcept = default; }; diff --git a/src/video_core/amdgpu/liverpool.h b/src/video_core/amdgpu/liverpool.h index ec9c92ef1..67821b0f2 100644 --- a/src/video_core/amdgpu/liverpool.h +++ b/src/video_core/amdgpu/liverpool.h @@ -266,6 +266,10 @@ struct Liverpool { BitField<20, 4, ShaderExportFormat> col5; BitField<24, 4, ShaderExportFormat> col6; BitField<28, 4, ShaderExportFormat> col7; + + [[nodiscard]] ShaderExportFormat GetFormat(const u32 buf_idx) const { + return static_cast((raw >> (buf_idx * 4)) & 0xfu); + } }; union VsOutputControl { diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h index 9a20f94c1..8c5cb1f3b 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h @@ -35,9 +35,8 @@ struct GraphicsPipelineKey { std::array stage_hashes; u32 num_color_attachments; std::array color_formats; - std::array color_num_formats; - std::array color_num_conversions; - std::array color_swizzles; + std::array + color_buffers; vk::Format depth_format; vk::Format stencil_format; diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index c6a56745d..3728a55fb 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -167,11 +167,7 @@ const Shader::RuntimeInfo& PipelineCache::BuildRuntimeInfo(Stage stage, LogicalS }; } for (u32 i = 0; i < Shader::MaxColorBuffers; i++) { - info.fs_info.color_buffers[i] = { - .num_format = graphics_key.color_num_formats[i], - .num_conversion = graphics_key.color_num_conversions[i], - .swizzle = graphics_key.color_swizzles[i], - }; + info.fs_info.color_buffers[i] = graphics_key.color_buffers[i]; } break; } @@ -309,11 +305,9 @@ bool PipelineCache::RefreshGraphicsKey() { // order. We need to do some arrays compaction at this stage key.num_color_attachments = 0; key.color_formats.fill(vk::Format::eUndefined); - key.color_num_formats.fill(AmdGpu::NumberFormat::Unorm); - key.color_num_conversions.fill(AmdGpu::NumberConversion::None); + key.color_buffers.fill({}); key.blend_controls.fill({}); key.write_masks.fill({}); - key.color_swizzles.fill({}); key.vertex_buffer_formats.fill(vk::Format::eUndefined); key.patch_control_points = 0; @@ -338,9 +332,12 @@ bool PipelineCache::RefreshGraphicsKey() { key.color_formats[remapped_cb] = LiverpoolToVK::SurfaceFormat(col_buf.GetDataFmt(), col_buf.GetNumberFmt()); - key.color_num_formats[remapped_cb] = col_buf.GetNumberFmt(); - key.color_num_conversions[remapped_cb] = col_buf.GetNumberConversion(); - key.color_swizzles[remapped_cb] = col_buf.Swizzle(); + key.color_buffers[remapped_cb] = { + .num_format = col_buf.GetNumberFmt(), + .num_conversion = col_buf.GetNumberConversion(), + .swizzle = col_buf.Swizzle(), + .export_format = regs.color_export_format.GetFormat(cb), + }; } fetch_shader = std::nullopt; @@ -456,7 +453,7 @@ bool PipelineCache::RefreshGraphicsKey() { // of the latter we need to change format to undefined, and either way we need to // increment the index for the null attachment binding. key.color_formats[remapped_cb] = vk::Format::eUndefined; - key.color_swizzles[remapped_cb] = {}; + key.color_buffers[remapped_cb] = {}; ++remapped_cb; continue; } From a51c8c17e07063065fe1780d648c3b4808f31d59 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 24 Jan 2025 12:47:04 -0800 Subject: [PATCH 13/72] shader_recompiler: Fix image write swizzles. (#2236) --- .../ir/passes/resource_tracking_pass.cpp | 4 +-- src/video_core/amdgpu/types.h | 31 ++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp index d94c5223a..43d125bf0 100644 --- a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp +++ b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp @@ -569,7 +569,7 @@ void PatchTextureBufferArgs(IR::Block& block, IR::Inst& inst, Info& info) { inst.SetArg(1, CalculateBufferAddress(ir, inst, info, buffer, 1U)); if (inst.GetOpcode() == IR::Opcode::StoreBufferFormatF32) { - const auto swizzled = ApplySwizzle(ir, inst.Arg(2), buffer.DstSelect()); + const auto swizzled = ApplySwizzle(ir, inst.Arg(2), buffer.DstSelect().Inverse()); const auto converted = ApplyWriteNumberConversionVec4(ir, swizzled, buffer.GetNumberConversion()); inst.SetArg(2, converted); @@ -829,7 +829,7 @@ void PatchImageArgs(IR::Block& block, IR::Inst& inst, Info& info) { auto texel = inst.Arg(4); if (is_storage) { // Storage image requires shader swizzle. - texel = ApplySwizzle(ir, texel, image.DstSelect()); + texel = ApplySwizzle(ir, texel, image.DstSelect().Inverse()); } const auto converted = ApplyWriteNumberConversionVec4(ir, texel, image.GetNumberConversion()); diff --git a/src/video_core/amdgpu/types.h b/src/video_core/amdgpu/types.h index 63e184cc5..b442b2f1e 100644 --- a/src/video_core/amdgpu/types.h +++ b/src/video_core/amdgpu/types.h @@ -200,10 +200,10 @@ enum class NumberConversion : u32 { }; struct CompMapping { - CompSwizzle r : 3; - CompSwizzle g : 3; - CompSwizzle b : 3; - CompSwizzle a : 3; + CompSwizzle r; + CompSwizzle g; + CompSwizzle b; + CompSwizzle a; auto operator<=>(const CompMapping& other) const = default; @@ -217,6 +217,15 @@ struct CompMapping { }; } + [[nodiscard]] CompMapping Inverse() const { + CompMapping result{}; + InverseSingle(result.r, CompSwizzle::Red); + InverseSingle(result.g, CompSwizzle::Green); + InverseSingle(result.b, CompSwizzle::Blue); + InverseSingle(result.a, CompSwizzle::Alpha); + return result; + } + private: template T ApplySingle(const std::array& data, const CompSwizzle swizzle) const { @@ -237,6 +246,20 @@ private: UNREACHABLE(); } } + + void InverseSingle(CompSwizzle& dst, const CompSwizzle target) const { + if (r == target) { + dst = CompSwizzle::Red; + } else if (g == target) { + dst = CompSwizzle::Green; + } else if (b == target) { + dst = CompSwizzle::Blue; + } else if (a == target) { + dst = CompSwizzle::Alpha; + } else { + dst = CompSwizzle::Zero; + } + } }; inline DataFormat RemapDataFormat(const DataFormat format) { From 361532418ce8a252fd873eacff0d0b83504eeffb Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 24 Jan 2025 12:47:24 -0800 Subject: [PATCH 14/72] externals: Update SPIRV-Cross for MoltenVK (#2237) --- externals/MoltenVK/SPIRV-Cross | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/MoltenVK/SPIRV-Cross b/externals/MoltenVK/SPIRV-Cross index 6173e24b3..1a7b7ef6d 160000 --- a/externals/MoltenVK/SPIRV-Cross +++ b/externals/MoltenVK/SPIRV-Cross @@ -1 +1 @@ -Subproject commit 6173e24b31f09a0c3217103a130e74c4ddec14a6 +Subproject commit 1a7b7ef6de02cf6767e42b10ddad217c45e90d47 From 7072dfc99fdca87e833bf588587debef3e9b08bd Mon Sep 17 00:00:00 2001 From: hspir404 Date: Fri, 24 Jan 2025 21:56:21 +0000 Subject: [PATCH 15/72] Fix stale heap read in UnmapMemoryImpl (#2232) --- src/core/memory.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index a8dd72acc..271092eaf 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -418,8 +418,9 @@ u64 MemoryManager::UnmapBytesFromEntry(VAddr virtual_addr, VirtualMemoryArea vma vma.phys_base = 0; vma.disallow_merge = false; vma.name = ""; - MergeAdjacent(vma_map, new_it); - bool readonly_file = vma.prot == MemoryProt::CpuRead && type == VMAType::File; + const auto post_merge_it = MergeAdjacent(vma_map, new_it); + auto& post_merge_vma = post_merge_it->second; + bool readonly_file = post_merge_vma.prot == MemoryProt::CpuRead && type == VMAType::File; if (type != VMAType::Reserved && type != VMAType::PoolReserved) { // Unmap the memory region. impl.Unmap(vma_base_addr, vma_base_size, start_in_vma, start_in_vma + adjusted_size, From 73b7d344600a6a7aabb55d44dfe888deb8df312f Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:55:27 -0800 Subject: [PATCH 16/72] hotfix: Drop scePadSetLightBar log to debug level. Some games like to spam this a lot, and we already handle it. --- src/core/libraries/pad/pad.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/libraries/pad/pad.cpp b/src/core/libraries/pad/pad.cpp index f2b81fbe0..d940d0cfa 100644 --- a/src/core/libraries/pad/pad.cpp +++ b/src/core/libraries/pad/pad.cpp @@ -473,7 +473,7 @@ int PS4_SYSV_ABI scePadSetForceIntercepted() { int PS4_SYSV_ABI scePadSetLightBar(s32 handle, const OrbisPadLightBarParam* pParam) { if (pParam != nullptr) { - LOG_INFO(Lib_Pad, "scePadSetLightBar called handle = {} rgb = {} {} {}", handle, pParam->r, + LOG_DEBUG(Lib_Pad, "called handle = {} rgb = {} {} {}", handle, pParam->r, pParam->g, pParam->b); if (pParam->r < 0xD && pParam->g < 0xD && pParam->b < 0xD) { From e433f3116dd9a36a353d054e1a371e7ff257f87a Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:57:04 -0800 Subject: [PATCH 17/72] hotfix 2: clang format --- src/core/libraries/pad/pad.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/libraries/pad/pad.cpp b/src/core/libraries/pad/pad.cpp index d940d0cfa..18709bcb2 100644 --- a/src/core/libraries/pad/pad.cpp +++ b/src/core/libraries/pad/pad.cpp @@ -473,8 +473,8 @@ int PS4_SYSV_ABI scePadSetForceIntercepted() { int PS4_SYSV_ABI scePadSetLightBar(s32 handle, const OrbisPadLightBarParam* pParam) { if (pParam != nullptr) { - LOG_DEBUG(Lib_Pad, "called handle = {} rgb = {} {} {}", handle, pParam->r, - pParam->g, pParam->b); + LOG_DEBUG(Lib_Pad, "called handle = {} rgb = {} {} {}", handle, pParam->r, pParam->g, + pParam->b); if (pParam->r < 0xD && pParam->g < 0xD && pParam->b < 0xD) { LOG_INFO(Lib_Pad, "Invalid lightbar setting"); From 564dbc7b94b02c70febd901f613ccb567923cb5e Mon Sep 17 00:00:00 2001 From: Ian Carpenter Date: Sat, 25 Jan 2025 04:00:52 -0500 Subject: [PATCH 18/72] system_service: Add simple event queue and push an EntitlementUpdate event to it when app content is initialized (#2238) --- .../libraries/app_content/app_content.cpp | 10 ++++++++ src/core/libraries/system/systemservice.cpp | 23 ++++++++++++++++--- src/core/libraries/system/systemservice.h | 4 ++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/core/libraries/app_content/app_content.cpp b/src/core/libraries/app_content/app_content.cpp index 1d23e7f44..1223022c5 100644 --- a/src/core/libraries/app_content/app_content.cpp +++ b/src/core/libraries/app_content/app_content.cpp @@ -12,6 +12,7 @@ #include "core/file_sys/fs.h" #include "core/libraries/app_content/app_content_error.h" #include "core/libraries/libs.h" +#include "core/libraries/system/systemservice.h" namespace Libraries::AppContent { @@ -262,6 +263,15 @@ int PS4_SYSV_ABI sceAppContentInitialize(const OrbisAppContentInitParam* initPar entitlement_label.copy(info.entitlement_label, sizeof(info.entitlement_label)); } } + + if (addcont_count > 0) { + SystemService::OrbisSystemServiceEvent event{}; + event.event_type = SystemService::OrbisSystemServiceEventType::EntitlementUpdate; + event.service_entitlement_update.user_id = 0; + event.service_entitlement_update.np_service_label = 0; + SystemService::PushSystemServiceEvent(event); + } + return ORBIS_OK; } diff --git a/src/core/libraries/system/systemservice.cpp b/src/core/libraries/system/systemservice.cpp index ebb9f4392..a67b9a2fc 100644 --- a/src/core/libraries/system/systemservice.cpp +++ b/src/core/libraries/system/systemservice.cpp @@ -10,6 +10,8 @@ namespace Libraries::SystemService { bool g_splash_status{true}; +std::queue g_event_queue; +std::mutex g_event_queue_mutex; bool IsSplashVisible() { return Config::showSplash() && g_splash_status; @@ -1772,7 +1774,9 @@ s32 PS4_SYSV_ABI sceSystemServiceGetStatus(OrbisSystemServiceStatus* status) { LOG_ERROR(Lib_SystemService, "OrbisSystemServiceStatus is null"); return ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER; } - status->event_num = 0; + + std::lock_guard lock(g_event_queue_mutex); + status->event_num = static_cast(g_event_queue.size()); status->is_system_ui_overlaid = false; status->is_in_background_execution = false; status->is_cpu_mode7_cpu_normal = true; @@ -1940,11 +1944,19 @@ int PS4_SYSV_ABI sceSystemServiceRaiseExceptionLocalProcess() { } s32 PS4_SYSV_ABI sceSystemServiceReceiveEvent(OrbisSystemServiceEvent* event) { - LOG_ERROR(Lib_SystemService, "(STUBBED) called"); + LOG_TRACE(Lib_SystemService, "called"); if (event == nullptr) { return ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER; } - return ORBIS_SYSTEM_SERVICE_ERROR_NO_EVENT; + + std::lock_guard lock(g_event_queue_mutex); + if (g_event_queue.empty()) { + return ORBIS_SYSTEM_SERVICE_ERROR_NO_EVENT; + } + + *event = g_event_queue.front(); + g_event_queue.pop(); + return ORBIS_OK; } int PS4_SYSV_ABI sceSystemServiceReenableMusicPlayer() { @@ -2412,6 +2424,11 @@ int PS4_SYSV_ABI Func_CB5E885E225F69F0() { return ORBIS_OK; } +void PushSystemServiceEvent(const OrbisSystemServiceEvent& event) { + std::lock_guard lock(g_event_queue_mutex); + g_event_queue.push(event); +} + void RegisterlibSceSystemService(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("alZfRdr2RP8", "libSceAppMessaging", 1, "libSceSystemService", 1, 1, sceAppMessagingClearEventFlag); diff --git a/src/core/libraries/system/systemservice.h b/src/core/libraries/system/systemservice.h index cdd3c15e8..c22ccc88f 100644 --- a/src/core/libraries/system/systemservice.h +++ b/src/core/libraries/system/systemservice.h @@ -4,6 +4,8 @@ // https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain/blob/master/include/orbis/_types/sys_service.h #pragma once +#include +#include #include "common/types.h" namespace Core::Loader { @@ -603,5 +605,7 @@ int PS4_SYSV_ABI sceSystemServiceReenableVoiceRecognition(); int PS4_SYSV_ABI Func_6B1CDB955F0EBD65(); int PS4_SYSV_ABI Func_CB5E885E225F69F0(); +void PushSystemServiceEvent(const OrbisSystemServiceEvent& event); + void RegisterlibSceSystemService(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::SystemService From a5a1253185fc6b3231e30477ebb8dba5375ac936 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sat, 25 Jan 2025 04:12:18 -0800 Subject: [PATCH 19/72] liverpool: Implement PM4 MEM_SEMAPHORE. (#2235) --- src/video_core/amdgpu/liverpool.cpp | 24 ++++++++++++ src/video_core/amdgpu/pm4_cmds.h | 61 +++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/src/video_core/amdgpu/liverpool.cpp b/src/video_core/amdgpu/liverpool.cpp index 8355dd1e6..2f40d4136 100644 --- a/src/video_core/amdgpu/liverpool.cpp +++ b/src/video_core/amdgpu/liverpool.cpp @@ -636,6 +636,18 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span dcb, std::span(header); + if (mem_semaphore->IsSignaling()) { + mem_semaphore->Signal(); + } else { + while (!mem_semaphore->Signaled()) { + YIELD_GFX(); + } + mem_semaphore->Decrement(); + } + break; + } case PM4ItOpcode::AcquireMem: { // const auto* acquire_mem = reinterpret_cast(header); break; @@ -848,6 +860,18 @@ Liverpool::Task Liverpool::ProcessCompute(std::span acb, u32 vqid) { } break; } + case PM4ItOpcode::MemSemaphore: { + const auto* mem_semaphore = reinterpret_cast(header); + if (mem_semaphore->IsSignaling()) { + mem_semaphore->Signal(); + } else { + while (!mem_semaphore->Signaled()) { + YIELD_ASC(vqid); + } + mem_semaphore->Decrement(); + } + break; + } case PM4ItOpcode::WaitRegMem: { const auto* wait_reg_mem = reinterpret_cast(header); ASSERT(wait_reg_mem->engine.Value() == PM4CmdWaitRegMem::Engine::Me); diff --git a/src/video_core/amdgpu/pm4_cmds.h b/src/video_core/amdgpu/pm4_cmds.h index 311f4d4d0..e92ba17fa 100644 --- a/src/video_core/amdgpu/pm4_cmds.h +++ b/src/video_core/amdgpu/pm4_cmds.h @@ -884,4 +884,65 @@ struct PM4CmdDrawIndexIndirectMulti { u32 draw_initiator; ///< Draw Initiator Register }; +struct PM4CmdMemSemaphore { + enum class ClientCode : u32 { + CommandProcessor = 0u, + CommandBuffer = 1u, + DataBuffer = 2u, + }; + enum class Select : u32 { + SignalSemaphore = 6u, + WaitSemaphore = 7u, + }; + enum class SignalType : u32 { + Increment = 0u, + Write = 1u, + }; + + PM4Type3Header header; ///< header + union { + u32 dw1; + BitField<3, 29, u32> addr_lo; ///< Semaphore address bits [31:3] + }; + union { + u32 dw2; + BitField<0, 8, u32> addr_hi; ///< Semaphore address bits [39:32] + BitField<16, 1, u32> use_mailbox; ///< Enables waiting until mailbox is written to + BitField<20, 1, SignalType> signal_type; ///< Indicates the type of signal sent + BitField<24, 2, ClientCode> client_code; + BitField<29, 3, Select> sem_sel; ///< Indicates whether to do a signal or wait operation + }; + + template + [[nodiscard]] T Address() const { + return std::bit_cast(u64(addr_lo) << 3 | (u64(addr_hi) << 32)); + } + + [[nodiscard]] bool IsSignaling() const { + return sem_sel == Select::SignalSemaphore; + } + + [[nodiscard]] bool Signaled() const { + return *Address() > 0; + } + + void Decrement() const { + *Address() -= 1; + } + + void Signal() const { + auto* ptr = Address(); + switch (signal_type) { + case SignalType::Increment: + *ptr += 1; + break; + case SignalType::Write: + *ptr = 1; + break; + default: + UNREACHABLE_MSG("Unknown signal type {}", static_cast(signal_type.Value())); + } + } +}; + } // namespace AmdGpu From f1bc3b4f3dc492f4c067693a97e5932c8be38491 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sat, 25 Jan 2025 14:59:18 -0800 Subject: [PATCH 20/72] shader_recompiler: Add another constant propagation pass near the end. (#2231) --- src/shader_recompiler/recompiler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/shader_recompiler/recompiler.cpp b/src/shader_recompiler/recompiler.cpp index bb027a11e..01518ab8f 100644 --- a/src/shader_recompiler/recompiler.cpp +++ b/src/shader_recompiler/recompiler.cpp @@ -90,6 +90,7 @@ IR::Program TranslateProgram(std::span code, Pools& pools, Info& info Shader::Optimization::ResourceTrackingPass(program); Shader::Optimization::IdentityRemovalPass(program.blocks); Shader::Optimization::DeadCodeEliminationPass(program); + Shader::Optimization::ConstantPropagationPass(program.post_order_blocks); Shader::Optimization::CollectShaderInfoPass(program); Shader::Optimization::SharedMemoryBarrierPass(program, profile); From 3960283a67af70fbaf2a64a1ac97f695acf47a16 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sun, 26 Jan 2025 01:00:22 -0800 Subject: [PATCH 21/72] hotfix: Fix missing embedded PS shader address bits. If the emulator code is above a 40-bit address, the embedded shaders need to use address-hi to work. Embedded VS shader already supplies it, PS shader should as well. --- src/core/libraries/gnmdriver/gnmdriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/libraries/gnmdriver/gnmdriver.cpp b/src/core/libraries/gnmdriver/gnmdriver.cpp index fdc3a1acd..06124167c 100644 --- a/src/core/libraries/gnmdriver/gnmdriver.cpp +++ b/src/core/libraries/gnmdriver/gnmdriver.cpp @@ -1366,7 +1366,7 @@ s32 PS4_SYSV_ABI sceGnmSetEmbeddedPsShader(u32* cmdbuf, u32 size, u32 shader_id, // pointer to a stack memory, so the check will likely fail. To workaround it we will // repeat set shader functionality here as it is trivial. cmdbuf = PM4CmdSetData::SetShReg(cmdbuf, 8u, ps_regs[0], - 0u); // SPI_SHADER_PGM_LO_PS/SPI_SHADER_PGM_HI_PS + ps_regs[1]); // SPI_SHADER_PGM_LO_PS/SPI_SHADER_PGM_HI_PS cmdbuf = PM4CmdSetData::SetShReg(cmdbuf, 10u, ps_regs[2], ps_regs[3]); // SPI_SHADER_PGM_RSRC1_PS/SPI_SHADER_PGM_RSRC2_PS cmdbuf = PM4CmdSetData::SetContextReg(cmdbuf, 0x1c4u, ps_regs[4], From 461148c22706ea35c8ae4985f21d695e46be01ff Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sun, 26 Jan 2025 04:32:14 -0800 Subject: [PATCH 22/72] qt: Prevent interacting with empty grid cells. (#2243) --- src/qt_gui/game_grid_frame.cpp | 3 ++- src/qt_gui/gui_context_menus.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qt_gui/game_grid_frame.cpp b/src/qt_gui/game_grid_frame.cpp index 2ebb09e5d..d719ac878 100644 --- a/src/qt_gui/game_grid_frame.cpp +++ b/src/qt_gui/game_grid_frame.cpp @@ -38,17 +38,18 @@ GameGridFrame::GameGridFrame(std::shared_ptr game_info_get, void GameGridFrame::onCurrentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) { - cellClicked = true; crtRow = currentRow; crtColumn = currentColumn; columnCnt = this->columnCount(); auto itemID = (crtRow * columnCnt) + currentColumn; if (itemID > m_game_info->m_games.count() - 1) { + cellClicked = false; validCellSelected = false; BackgroundMusicPlayer::getInstance().stopMusic(); return; } + cellClicked = true; validCellSelected = true; SetGridBackgroundImage(crtRow, crtColumn); auto snd0Path = QString::fromStdString(m_game_info->m_games[itemID].snd0_path.string()); diff --git a/src/qt_gui/gui_context_menus.h b/src/qt_gui/gui_context_menus.h index 0e8675c0c..72affeca7 100644 --- a/src/qt_gui/gui_context_menus.h +++ b/src/qt_gui/gui_context_menus.h @@ -41,8 +41,8 @@ public: itemID = widget->currentRow() * widget->columnCount() + widget->currentColumn(); } - // Do not show the menu if an item is selected - if (itemID == -1) { + // Do not show the menu if no item is selected + if (itemID < 0 || itemID >= m_games.size()) { return; } From 46b5437fdfea7e7b3add555d62540766daa4534d Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sun, 26 Jan 2025 08:01:15 -0800 Subject: [PATCH 23/72] emulator: Use correct game folder mount when opening update eboot directly. (#2244) --- src/emulator.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/emulator.cpp b/src/emulator.cpp index e77c2b87f..97215c06f 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -100,9 +100,21 @@ Emulator::~Emulator() { } void Emulator::Run(const std::filesystem::path& file, const std::vector args) { + const auto eboot_name = file.filename().string(); + auto game_folder = file.parent_path(); + if (const auto game_folder_name = game_folder.filename().string(); + game_folder_name.ends_with("-UPDATE")) { + // If an executable was launched from a separate update directory, + // use the base game directory as the game folder. + const auto base_name = game_folder_name.substr(0, game_folder_name.size() - 7); + const auto base_path = game_folder.parent_path() / base_name; + if (std::filesystem::is_directory(base_path)) { + game_folder = base_path; + } + } + // Applications expect to be run from /app0 so mount the file's parent path as app0. auto* mnt = Common::Singleton::Instance(); - const auto game_folder = file.parent_path(); mnt->Mount(game_folder, "/app0"); // Certain games may use /hostapp as well such as CUSA001100 mnt->Mount(game_folder, "/hostapp"); @@ -223,7 +235,7 @@ void Emulator::Run(const std::filesystem::path& file, const std::vectorGetHLESymbols()); // Load the module with the linker - const auto eboot_path = mnt->GetHostPath("/app0/" + file.filename().string()); + const auto eboot_path = mnt->GetHostPath("/app0/" + eboot_name); linker->LoadModule(eboot_path); // check if we have system modules to load From 7d1631f9f43f3b781a20dd91d7ebc0980b55b8ee Mon Sep 17 00:00:00 2001 From: Ian Carpenter Date: Sun, 26 Jan 2025 18:46:59 -0500 Subject: [PATCH 24/72] memory_patcher: Remove hardcoded repositories when loading patches (#2241) --- src/common/memory_patcher.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/common/memory_patcher.cpp b/src/common/memory_patcher.cpp index 6b79edb9f..f81a0ed83 100644 --- a/src/common/memory_patcher.cpp +++ b/src/common/memory_patcher.cpp @@ -7,6 +7,7 @@ #include #include #ifdef ENABLE_QT_GUI +#include #include #include #include @@ -189,14 +190,16 @@ void OnGameLoaded() { // We use the QT headers for the xml and json parsing, this define is only true on QT builds QString patchDir; Common::FS::PathToQString(patchDir, Common::FS::GetUserPath(Common::FS::PathType::PatchesDir)); - QString repositories[] = {"GoldHEN", "shadPS4"}; + QDir dir(patchDir); + QStringList folders = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); - for (const QString& repository : repositories) { - QString filesJsonPath = patchDir + "/" + repository + "/files.json"; + for (const QString& folder : folders) { + QString filesJsonPath = patchDir + "/" + folder + "/files.json"; QFile jsonFile(filesJsonPath); if (!jsonFile.open(QIODevice::ReadOnly)) { - LOG_ERROR(Loader, "Unable to open files.json for reading."); + LOG_ERROR(Loader, "Unable to open files.json for reading in repository {}", + folder.toStdString()); continue; } @@ -220,11 +223,12 @@ void OnGameLoaded() { } if (selectedFileName.isEmpty()) { - LOG_ERROR(Loader, "No patch file found for the current serial."); + LOG_ERROR(Loader, "No patch file found for the current serial in repository {}", + folder.toStdString()); continue; } - QString filePath = patchDir + "/" + repository + "/" + selectedFileName; + QString filePath = patchDir + "/" + folder + "/" + selectedFileName; QFile file(filePath); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { LOG_ERROR(Loader, "Unable to open the file for reading."); From 6f04ea18e4f3d87e9a89f0fefcc1c8c722a87de6 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sun, 26 Jan 2025 19:28:58 -0800 Subject: [PATCH 25/72] externals: Update MoltenVK (#2249) Fixes broken vertex binding dynamic stride when used with tessellation. --- externals/MoltenVK/MoltenVK | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/MoltenVK/MoltenVK b/externals/MoltenVK/MoltenVK index 2473ce6f0..6fa077fb8 160000 --- a/externals/MoltenVK/MoltenVK +++ b/externals/MoltenVK/MoltenVK @@ -1 +1 @@ -Subproject commit 2473ce6f0ab7d5d8a49aa91b2e37f3447a939f18 +Subproject commit 6fa077fb8ed8dac4e4cd66b6b1ebd7b4d955a754 From 191e64bfa11e45992e869e7a9df787d6fbe5038b Mon Sep 17 00:00:00 2001 From: Vladislav Mikhalin Date: Mon, 27 Jan 2025 11:17:23 +0300 Subject: [PATCH 26/72] renderer: respect zmin/zmax even if clipping is disabled (#2250) --- src/video_core/renderer_vulkan/vk_rasterizer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 88b510eca..7a0652ed7 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -1172,6 +1172,8 @@ void Rasterizer::UpdateViewportScissorState(const GraphicsPipeline& pipeline) { continue; } + const auto zoffset = vp_ctl.zoffset_enable ? vp.zoffset : 0.f; + const auto zscale = vp_ctl.zscale_enable ? vp.zscale : 1.f; if (pipeline.IsClipDisabled()) { // In case if clipping is disabled we patch the shader to convert vertex position // from screen space coordinates to NDC by defining a render space as full hardware @@ -1181,16 +1183,14 @@ void Rasterizer::UpdateViewportScissorState(const GraphicsPipeline& pipeline) { .y = 0.f, .width = float(std::min(instance.GetMaxViewportWidth(), 16_KB)), .height = float(std::min(instance.GetMaxViewportHeight(), 16_KB)), - .minDepth = 0.0, - .maxDepth = 1.0, + .minDepth = zoffset - zscale * reduce_z, + .maxDepth = zscale + zoffset, }); } else { const auto xoffset = vp_ctl.xoffset_enable ? vp.xoffset : 0.f; const auto xscale = vp_ctl.xscale_enable ? vp.xscale : 1.f; const auto yoffset = vp_ctl.yoffset_enable ? vp.yoffset : 0.f; const auto yscale = vp_ctl.yscale_enable ? vp.yscale : 1.f; - const auto zoffset = vp_ctl.zoffset_enable ? vp.zoffset : 0.f; - const auto zscale = vp_ctl.zscale_enable ? vp.zscale : 1.f; viewports.push_back({ .x = xoffset - xscale, .y = yoffset - yscale, From 665261efc574562aad240466a9eed8b05b6b9a50 Mon Sep 17 00:00:00 2001 From: F1219R <109141852+F1219R@users.noreply.github.com> Date: Mon, 27 Jan 2025 16:39:27 +0100 Subject: [PATCH 27/72] Update sq translation (#2251) --- src/qt_gui/translations/sq.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qt_gui/translations/sq.ts b/src/qt_gui/translations/sq.ts index 2f88b4390..15c18d2f6 100644 --- a/src/qt_gui/translations/sq.ts +++ b/src/qt_gui/translations/sq.ts @@ -249,7 +249,7 @@ Open shadPS4 Folder - Open shadPS4 Folder + Hap dosjen e shadPS4 Exit @@ -542,7 +542,7 @@ Fullscreen Mode - Modaliteti i Plotë + Mënyra me ekran të plotë Enable Separate Update Folder @@ -550,7 +550,7 @@ Default tab when opening settings - Skeda e parazgjedhur kur hapni cilësimet + Skeda e parazgjedhur kur hapen cilësimet Show Game Size In List @@ -594,7 +594,7 @@ Open Log Location - Hap vendndodhjen e regjistrit + Hap vendndodhjen e Ditarit Input @@ -630,11 +630,11 @@ Gui - Ndërfaqe + Ndërfaqja User - Përdorues + Përdoruesi Graphics Device @@ -822,7 +822,7 @@ GUIMusicGroupBox - Luaj muzikën e titullit:\nNëse një lojë e mbështet, aktivizohet luajtja e muzikës të veçantë kur të zgjidhësh lojën në GUI. + Luaj muzikën e titullit:\nNëse një lojë e mbështet, aktivizohet luajtja e muzikës të veçantë kur të zgjidhësh lojën në ndërfaqe. disableTrophycheckBox From 2837d848eddf2c4b2b361626c220aa415f8b241c Mon Sep 17 00:00:00 2001 From: panzone91 <150828896+panzone91@users.noreply.github.com> Date: Mon, 27 Jan 2025 21:40:58 +0100 Subject: [PATCH 28/72] linker: handle relocation for exported modules (#2247) --- src/core/linker.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/linker.h b/src/core/linker.h index 00da3a08c..357b39664 100644 --- a/src/core/linker.h +++ b/src/core/linker.h @@ -109,10 +109,13 @@ public: void RelocateAnyImports(Module* m) { Relocate(m); - for (auto& module : m_modules) { - const auto imports = module->GetImportModules(); - if (std::ranges::contains(imports, m->name, &ModuleInfo::name)) { - Relocate(module.get()); + const auto exports = m->GetExportModules(); + for (auto& export_mod : exports) { + for (auto& module : m_modules) { + const auto imports = module->GetImportModules(); + if (std::ranges::contains(imports, export_mod.name, &ModuleInfo::name)) { + Relocate(module.get()); + } } } } From d2127b38deace732f0c41b6cc1881e21f4ed268b Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Tue, 28 Jan 2025 00:12:48 -0800 Subject: [PATCH 29/72] vk_rasterizer: Keep viewport depth offset even without native depth clip control. (#2257) --- src/video_core/renderer_vulkan/vk_rasterizer.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 7a0652ed7..7c77f2519 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -1155,10 +1155,7 @@ void Rasterizer::UpdateViewportScissorState(const GraphicsPipeline& pipeline) { const auto& vp_ctl = regs.viewport_control; const float reduce_z = - instance.IsDepthClipControlSupported() && - regs.clipper_control.clip_space == AmdGpu::Liverpool::ClipSpace::MinusWToW - ? 1.0f - : 0.0f; + regs.clipper_control.clip_space == AmdGpu::Liverpool::ClipSpace::MinusWToW ? 1.0f : 0.0f; if (regs.polygon_control.enable_window_offset) { LOG_ERROR(Render_Vulkan, From 8379922f8ab1209d25b4cbec14303401aa75eec9 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Tue, 28 Jan 2025 02:31:26 -0800 Subject: [PATCH 30/72] hotfix: Reduce requested videodec memory block sizes. This really needs a more accurate implementation, but for the stub lowering the value helps games that run out of memory space if it is too large. --- src/core/libraries/videodec/videodec.cpp | 2 +- src/core/libraries/videodec/videodec2.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/libraries/videodec/videodec.cpp b/src/core/libraries/videodec/videodec.cpp index 6c9a9b8c0..79001e76f 100644 --- a/src/core/libraries/videodec/videodec.cpp +++ b/src/core/libraries/videodec/videodec.cpp @@ -9,7 +9,7 @@ namespace Libraries::Videodec { -static constexpr u64 kMinimumMemorySize = 32_MB; ///> Fake minimum memory size for querying +static constexpr u64 kMinimumMemorySize = 8_MB; ///> Fake minimum memory size for querying int PS4_SYSV_ABI sceVideodecCreateDecoder(const OrbisVideodecConfigInfo* pCfgInfoIn, const OrbisVideodecResourceInfo* pRsrcInfoIn, diff --git a/src/core/libraries/videodec/videodec2.cpp b/src/core/libraries/videodec/videodec2.cpp index 07f7a274b..be0db4ea3 100644 --- a/src/core/libraries/videodec/videodec2.cpp +++ b/src/core/libraries/videodec/videodec2.cpp @@ -10,7 +10,7 @@ namespace Libraries::Vdec2 { -static constexpr u64 kMinimumMemorySize = 32_MB; ///> Fake minimum memory size for querying +static constexpr u64 kMinimumMemorySize = 8_MB; ///> Fake minimum memory size for querying s32 PS4_SYSV_ABI sceVideodec2QueryComputeMemoryInfo(OrbisVideodec2ComputeMemoryInfo* computeMemInfo) { From 4b93b8b57460c83421d0d859e243dd05a864bdc1 Mon Sep 17 00:00:00 2001 From: Martin <67326368+Martini-141@users.noreply.github.com> Date: Tue, 28 Jan 2025 17:47:00 +0100 Subject: [PATCH 31/72] add missing translations and other corrections nb (#2253) --- src/qt_gui/translations/nb.ts | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/qt_gui/translations/nb.ts b/src/qt_gui/translations/nb.ts index d6d4090df..0b7d2699a 100644 --- a/src/qt_gui/translations/nb.ts +++ b/src/qt_gui/translations/nb.ts @@ -98,7 +98,7 @@ Open Folder... - Åpne mappen... + Åpne mappe... Open Game Folder @@ -126,7 +126,7 @@ Copy All - Kopier alle + Kopier alt Delete... @@ -146,19 +146,19 @@ Compatibility... - Compatibility... + Kompatibilitet... Update database - Update database + Oppdater database View report - View report + Vis rapport Submit a report - Submit a report + Send inn en rapport Shortcut creation @@ -574,11 +574,11 @@ Trophy Key - Trophy Key + Trofénøkkel Trophy - Trophy + Trofé Logger @@ -658,7 +658,7 @@ Enable Shaders Dumping - Aktiver dumping av skyggelegger + Aktiver skyggeleggerdumping Enable NULL GPU @@ -666,7 +666,7 @@ Paths - Stier + Mapper Game Folders @@ -686,7 +686,7 @@ Enable Debug Dumping - Aktiver dumping av feilretting + Aktiver feilrettingsdumping Enable Vulkan Validation Layers @@ -718,7 +718,7 @@ GUI Settings - GUI-innstillinger + Grensesnitt-innstillinger Disable Trophy Pop-ups @@ -730,7 +730,7 @@ Update Compatibility Database On Startup - Oppdater kompatibilitets-database ved oppstart + Oppdater database ved oppstart Game Compatibility @@ -750,7 +750,7 @@ Audio Backend - Audio Backend + Lydsystem Save @@ -806,7 +806,7 @@ TrophyKey - Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. + Trofénøkkel:\nNøkkel brukes til å dekryptere trofeer. Må hentes fra din konsoll (jailbroken).\nMå bare inneholde sekskantede tegn. logTypeGroupBox @@ -846,7 +846,7 @@ checkCompatibilityOnStartupCheckBox - Oppdater kompatibilitets-data ved oppstart:\nOppdaterer kompatibilitets-databasen automatisk når shadPS4 starter. + Oppdater database ved oppstart:\nOppdaterer kompatibilitets-databasen automatisk når shadPS4 starter. updateCompatibilityButton @@ -894,7 +894,7 @@ dumpShadersCheckBox - Aktiver dumping av skyggelegger:\nFor teknisk feilsøking lagrer skyggeleggerne fra spillet i en mappe mens de gjengis. + Aktiver skyggeleggerdumping:\nFor teknisk feilsøking lagrer skyggeleggerne fra spillet i en mappe mens de gjengis. nullGpuCheckBox @@ -914,7 +914,7 @@ debugDump - Aktiver dumping av feilsøking:\nLagrer import- og eksport-symbolene og filoverskriftsinformasjonen til det nåværende kjørende PS4-programmet i en katalog. + Aktiver feilrettingsdumping:\nLagrer import- og eksport-symbolene og filoverskriftsinformasjonen til det nåværende kjørende PS4-programmet i en katalog. vkValidationCheckBox @@ -1188,7 +1188,7 @@ Path - Sti + Adresse Play Time @@ -1232,7 +1232,7 @@ Game can be completed with playable performance and no major glitches - Spillet kan fullføres med spillbar ytelse og ingen store feil + Spillet kan fullføres med spillbar ytelse og uten store feil @@ -1361,4 +1361,4 @@ TB - \ No newline at end of file + From 2cdd873681dd3b03d0752bda5c84412f06f4f0b8 Mon Sep 17 00:00:00 2001 From: slick-daddy <129640104+slick-daddy@users.noreply.github.com> Date: Tue, 28 Jan 2025 19:47:12 +0300 Subject: [PATCH 32/72] Update tr_TR.ts (#2255) --- src/qt_gui/translations/tr_TR.ts | 54 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/qt_gui/translations/tr_TR.ts b/src/qt_gui/translations/tr_TR.ts index 6436278de..a2368bfee 100644 --- a/src/qt_gui/translations/tr_TR.ts +++ b/src/qt_gui/translations/tr_TR.ts @@ -546,7 +546,7 @@ Enable Separate Update Folder - Enable Separate Update Folder + Ayrı Güncelleme Klasörünü Etkinleştir Default tab when opening settings @@ -554,7 +554,7 @@ Show Game Size In List - Göster oyun boyutunu listede + Oyun Boyutunu Listede Göster Show Splash @@ -574,11 +574,11 @@ Trophy Key - Trophy Key + Kupa Anahtarı Trophy - Trophy + Kupa Logger @@ -722,7 +722,7 @@ Disable Trophy Pop-ups - Disable Trophy Pop-ups + Kupa Açılır Pencerelerini Devre Dışı Bırak Play title music @@ -730,23 +730,23 @@ Update Compatibility Database On Startup - Update Compatibility Database On Startup + Başlangıçta Uyumluluk Veritabanını Güncelle Game Compatibility - Game Compatibility + Oyun Uyumluluğu Display Compatibility Data - Display Compatibility Data + Uyumluluk Verilerini Göster Update Compatibility Database - Update Compatibility Database + Uyumluluk Veritabanını Güncelle Volume - Ses seviyesi + Ses Seviyesi Audio Backend @@ -1105,11 +1105,11 @@ The game is in version: %1 - Oyun sürümde: %1 + Oyun sürümü: %1 The downloaded patch only works on version: %1 - İndirilen yamanın sadece sürümde çalışıyor: %1 + İndirilen yama sadece şu sürümde çalışıyor: %1 You may need to update your game. @@ -1168,7 +1168,7 @@ Compatibility - Compatibility + Uyumluluk Region @@ -1196,35 +1196,35 @@ Never Played - Never Played + Hiç Oynanmadı h - h + sa m - m + dk s - s + sn Compatibility is untested - Compatibility is untested + Uyumluluk test edilmemiş Game does not initialize properly / crashes the emulator - Game does not initialize properly / crashes the emulator + Oyun düzgün bir şekilde başlatılamıyor / emülatörü çökertiyor Game boots, but only displays a blank screen - Game boots, but only displays a blank screen + Oyun başlatılabiliyor ancak yalnızca boş bir ekran gösteriyor Game displays an image but does not go past the menu - Game displays an image but does not go past the menu + Oyun bir resim gösteriyor ancak menüleri geçemiyor Game has game-breaking glitches or unplayable performance @@ -1232,7 +1232,7 @@ Game can be completed with playable performance and no major glitches - Game can be completed with playable performance and no major glitches + Oyun, oynanabilir performansla tamamlanabilir ve büyük aksaklık yok @@ -1267,7 +1267,7 @@ Your version is already up to date! - Versiyonunuz zaten güncel! + Sürümünüz zaten güncel! Update Available @@ -1279,11 +1279,11 @@ Current Version - Mevcut Versiyon + Mevcut Sürüm Latest Version - Son Versiyon + Son Sürüm Do you want to update? @@ -1335,7 +1335,7 @@ Failed to create the update script file - Güncelleme betiği dosyası oluşturulamadı + Güncelleme komut dosyası oluşturulamadı @@ -1361,4 +1361,4 @@ TB - \ No newline at end of file + From a78f8afe58a995cecdb4eb1f1e6d6e58320444f6 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Tue, 28 Jan 2025 08:48:19 -0800 Subject: [PATCH 33/72] libraries: Implement libSceZlib. (#2256) * libraries: add zlib hle skeleton/stub * libraries: Implement libSceZlib. * zlib: Make variables static. --------- Co-authored-by: Nenkai --- CMakeLists.txt | 6 + src/common/logging/filter.cpp | 1 + src/common/logging/types.h | 1 + src/core/libraries/libs.cpp | 2 + src/core/libraries/zlib/zlib.cpp | 183 +++++++++++++++++++++++++++ src/core/libraries/zlib/zlib_error.h | 18 +++ src/core/libraries/zlib/zlib_sce.h | 21 +++ 7 files changed, 232 insertions(+) create mode 100644 src/core/libraries/zlib/zlib.cpp create mode 100644 src/core/libraries/zlib/zlib_error.h create mode 100644 src/core/libraries/zlib/zlib_sce.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c9dad307..78e3c7997 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -440,6 +440,11 @@ set(NP_LIBS src/core/libraries/np_common/np_common.cpp src/core/libraries/np_party/np_party.h ) +set(ZLIB_LIB src/core/libraries/zlib/zlib.cpp + src/core/libraries/zlib/zlib_sce.h + src/core/libraries/zlib/zlib_error.h +) + set(MISC_LIBS src/core/libraries/screenshot/screenshot.cpp src/core/libraries/screenshot/screenshot.h src/core/libraries/move/move.cpp @@ -612,6 +617,7 @@ set(CORE src/core/aerolib/stubs.cpp ${PLAYGO_LIB} ${RANDOM_LIB} ${USBD_LIB} + ${ZLIB_LIB} ${MISC_LIBS} ${IME_LIB} ${FIBER_LIB} diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index f1d3a9499..dd708c528 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -133,6 +133,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { SUB(Lib, Mouse) \ SUB(Lib, WebBrowserDialog) \ SUB(Lib, NpParty) \ + SUB(Lib, Zlib) \ CLS(Frontend) \ CLS(Render) \ SUB(Render, Vulkan) \ diff --git a/src/common/logging/types.h b/src/common/logging/types.h index d5530312c..54f8cdd0b 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -100,6 +100,7 @@ enum class Class : u8 { Lib_Mouse, ///< The LibSceMouse implementation Lib_WebBrowserDialog, ///< The LibSceWebBrowserDialog implementation Lib_NpParty, ///< The LibSceNpParty implementation + Lib_Zlib, ///< The LibSceZlib implementation. Frontend, ///< Emulator UI Render, ///< Video Core Render_Vulkan, ///< Vulkan backend diff --git a/src/core/libraries/libs.cpp b/src/core/libraries/libs.cpp index e09de1cee..8cf286d13 100644 --- a/src/core/libraries/libs.cpp +++ b/src/core/libraries/libs.cpp @@ -54,6 +54,7 @@ #include "core/libraries/videodec/videodec2.h" #include "core/libraries/videoout/video_out.h" #include "core/libraries/web_browser_dialog/webbrowserdialog.h" +#include "core/libraries/zlib/zlib_sce.h" #include "fiber/fiber.h" #include "jpeg/jpegenc.h" @@ -111,6 +112,7 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { Libraries::Mouse::RegisterlibSceMouse(sym); Libraries::WebBrowserDialog::RegisterlibSceWebBrowserDialog(sym); Libraries::NpParty::RegisterlibSceNpParty(sym); + Libraries::Zlib::RegisterlibSceZlib(sym); } } // namespace Libraries diff --git a/src/core/libraries/zlib/zlib.cpp b/src/core/libraries/zlib/zlib.cpp new file mode 100644 index 000000000..899cb5bf6 --- /dev/null +++ b/src/core/libraries/zlib/zlib.cpp @@ -0,0 +1,183 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include +#include + +#include "common/logging/log.h" +#include "common/thread.h" +#include "core/libraries/kernel/threads.h" +#include "core/libraries/libs.h" +#include "core/libraries/zlib/zlib_error.h" +#include "core/libraries/zlib/zlib_sce.h" + +namespace Libraries::Zlib { + +struct InflateTask { + u64 request_id; + const void* src; + u32 src_length; + void* dst; + u32 dst_length; +}; + +struct InflateResult { + u32 length; + s32 status; +}; + +static Kernel::Thread task_thread; + +static std::mutex mutex; +static std::queue task_queue; +static std::condition_variable_any task_queue_cv; +static std::queue done_queue; +static std::condition_variable_any done_queue_cv; +static std::unordered_map results; +static u64 next_request_id; + +void ZlibTaskThread(const std::stop_token& stop) { + Common::SetCurrentThreadName("shadPS4:ZlibTaskThread"); + + while (!stop.stop_requested()) { + InflateTask task; + { + // Lock and pop from the task queue, unless stop has been requested. + std::unique_lock lock(mutex); + if (!task_queue_cv.wait(lock, stop, [&] { return !task_queue.empty(); })) { + break; + } + task = task_queue.back(); + task_queue.pop(); + } + + uLongf decompressed_length = task.dst_length; + const auto ret = uncompress(static_cast(task.dst), &decompressed_length, + static_cast(task.src), task.src_length); + + { + // Lock, insert the new result, and push the finished request ID to the done queue. + std::unique_lock lock(mutex); + results[task.request_id] = InflateResult{ + .length = static_cast(decompressed_length), + .status = ret == Z_BUF_ERROR ? ORBIS_ZLIB_ERROR_NOSPACE + : ret == Z_OK ? ORBIS_OK + : ORBIS_ZLIB_ERROR_FATAL, + }; + done_queue.push(task.request_id); + } + done_queue_cv.notify_one(); + } +} + +s32 PS4_SYSV_ABI sceZlibInitialize(const void* buffer, u32 length) { + LOG_INFO(Lib_Zlib, "called"); + if (task_thread.Joinable()) { + return ORBIS_ZLIB_ERROR_ALREADY_INITIALIZED; + } + + // Initialize with empty task data + task_queue = std::queue(); + done_queue = std::queue(); + results.clear(); + next_request_id = 1; + + task_thread.Run([](const std::stop_token& stop) { ZlibTaskThread(stop); }); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceZlibInflate(const void* src, u32 src_len, void* dst, u32 dst_len, + u64* request_id) { + LOG_DEBUG(Lib_Zlib, "(STUBBED) called"); + if (!task_thread.Joinable()) { + return ORBIS_ZLIB_ERROR_NOT_INITIALIZED; + } + if (!src || !src_len || !dst || !dst_len || !request_id || dst_len > 64_KB || + dst_len % 2_KB != 0) { + return ORBIS_ZLIB_ERROR_INVALID; + } + + { + std::unique_lock lock(mutex); + *request_id = next_request_id++; + task_queue.emplace(InflateTask{ + .request_id = *request_id, + .src = src, + .src_length = src_len, + .dst = dst, + .dst_length = dst_len, + }); + task_queue_cv.notify_one(); + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceZlibWaitForDone(u64* request_id, const u32* timeout) { + LOG_DEBUG(Lib_Zlib, "(STUBBED) called"); + if (!task_thread.Joinable()) { + return ORBIS_ZLIB_ERROR_NOT_INITIALIZED; + } + if (!request_id) { + return ORBIS_ZLIB_ERROR_INVALID; + } + + { + // Pop from the done queue, unless the timeout is reached. + std::unique_lock lock(mutex); + const auto pred = [] { return !done_queue.empty(); }; + if (timeout) { + if (!done_queue_cv.wait_for(lock, std::chrono::milliseconds(*timeout), pred)) { + return ORBIS_ZLIB_ERROR_TIMEDOUT; + } + } else { + done_queue_cv.wait(lock, pred); + } + *request_id = done_queue.back(); + done_queue.pop(); + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceZlibGetResult(const u64 request_id, u32* dst_length, s32* status) { + LOG_DEBUG(Lib_Zlib, "(STUBBED) called"); + if (!task_thread.Joinable()) { + return ORBIS_ZLIB_ERROR_NOT_INITIALIZED; + } + if (!dst_length || !status) { + return ORBIS_ZLIB_ERROR_INVALID; + } + + { + std::unique_lock lock(mutex); + if (!results.contains(request_id)) { + return ORBIS_ZLIB_ERROR_NOT_FOUND; + } + const auto result = results[request_id]; + *dst_length = result.length; + *status = result.status; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceZlibFinalize() { + LOG_INFO(Lib_Zlib, "called"); + if (!task_thread.Joinable()) { + return ORBIS_ZLIB_ERROR_NOT_INITIALIZED; + } + task_thread.Stop(); + return ORBIS_OK; +} + +void RegisterlibSceZlib(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("m1YErdIXCp4", "libSceZlib", 1, "libSceZlib", 1, 1, sceZlibInitialize); + LIB_FUNCTION("6na+Sa-B83w", "libSceZlib", 1, "libSceZlib", 1, 1, sceZlibFinalize); + LIB_FUNCTION("TLar1HULv1Q", "libSceZlib", 1, "libSceZlib", 1, 1, sceZlibInflate); + LIB_FUNCTION("uB8VlDD4e0s", "libSceZlib", 1, "libSceZlib", 1, 1, sceZlibWaitForDone); + LIB_FUNCTION("2eDcGHC0YaM", "libSceZlib", 1, "libSceZlib", 1, 1, sceZlibGetResult); +}; + +} // namespace Libraries::Zlib diff --git a/src/core/libraries/zlib/zlib_error.h b/src/core/libraries/zlib/zlib_error.h new file mode 100644 index 000000000..59574f0b2 --- /dev/null +++ b/src/core/libraries/zlib/zlib_error.h @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "core/libraries/error_codes.h" + +// Zlib library +constexpr int ORBIS_ZLIB_ERROR_NOT_FOUND = 0x81120002; +constexpr int ORBIS_ZLIB_ERROR_BUSY = 0x8112000B; +constexpr int ORBIS_ZLIB_ERROR_FAULT = 0x8112000E; +constexpr int ORBIS_ZLIB_ERROR_INVALID = 0x81120016; +constexpr int ORBIS_ZLIB_ERROR_NOSPACE = 0x8112001C; +constexpr int ORBIS_ZLIB_ERROR_NOT_SUPPORTED = 0x81120025; +constexpr int ORBIS_ZLIB_ERROR_TIMEDOUT = 0x81120027; +constexpr int ORBIS_ZLIB_ERROR_NOT_INITIALIZED = 0x81120032; +constexpr int ORBIS_ZLIB_ERROR_ALREADY_INITIALIZED = 0x81120033; +constexpr int ORBIS_ZLIB_ERROR_FATAL = 0x811200FF; diff --git a/src/core/libraries/zlib/zlib_sce.h b/src/core/libraries/zlib/zlib_sce.h new file mode 100644 index 000000000..6f8cf9468 --- /dev/null +++ b/src/core/libraries/zlib/zlib_sce.h @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} +namespace Libraries::Zlib { + +s32 PS4_SYSV_ABI sceZlibInitialize(const void* buffer, u32 length); +s32 PS4_SYSV_ABI sceZlibInflate(const void* src, u32 src_len, void* dst, u32 dst_len, + u64* request_id); +s32 PS4_SYSV_ABI sceZlibWaitForDone(u64* request_id, const u32* timeout); +s32 PS4_SYSV_ABI sceZlibGetResult(u64 request_id, u32* dst_length, s32* status); +s32 PS4_SYSV_ABI sceZlibFinalize(); + +void RegisterlibSceZlib(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::Zlib \ No newline at end of file From 0575853be18d8f0504482b4a5a407fb14a23d492 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Tue, 28 Jan 2025 17:56:05 -0800 Subject: [PATCH 34/72] externals: Update MoltenVK. (#2264) Adds support for VK_EXT_depth_clip_control --- externals/MoltenVK/MoltenVK | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/MoltenVK/MoltenVK b/externals/MoltenVK/MoltenVK index 6fa077fb8..aba997657 160000 --- a/externals/MoltenVK/MoltenVK +++ b/externals/MoltenVK/MoltenVK @@ -1 +1 @@ -Subproject commit 6fa077fb8ed8dac4e4cd66b6b1ebd7b4d955a754 +Subproject commit aba997657b94d6de1794ebad36ce5634341252c7 From 78a0a755c5f2ff06c340ec0dc3431fc247aaa3e4 Mon Sep 17 00:00:00 2001 From: ElBread3 <92335081+ElBread3@users.noreply.github.com> Date: Tue, 28 Jan 2025 21:14:47 -0600 Subject: [PATCH 35/72] qt_gui: Some game install features and fixes (#2261) * open update folder + delete save folder + bulk install checkbox * delete pkg on install checkbox + use game icon for finish window --- src/qt_gui/gui_context_menus.h | 45 ++++++++++++++++++++++++++++--- src/qt_gui/install_dir_select.cpp | 24 ++++++++++++++--- src/qt_gui/install_dir_select.h | 12 +++++++++ src/qt_gui/main_window.cpp | 26 +++++++++++++++--- src/qt_gui/main_window.h | 4 +++ 5 files changed, 101 insertions(+), 10 deletions(-) diff --git a/src/qt_gui/gui_context_menus.h b/src/qt_gui/gui_context_menus.h index 72affeca7..bdc2aec0c 100644 --- a/src/qt_gui/gui_context_menus.h +++ b/src/qt_gui/gui_context_menus.h @@ -52,10 +52,12 @@ public: // "Open Folder..." submenu QMenu* openFolderMenu = new QMenu(tr("Open Folder..."), widget); QAction* openGameFolder = new QAction(tr("Open Game Folder"), widget); + QAction* openUpdateFolder = new QAction(tr("Open Update Folder"), widget); QAction* openSaveDataFolder = new QAction(tr("Open Save Data Folder"), widget); QAction* openLogFolder = new QAction(tr("Open Log Folder"), widget); openFolderMenu->addAction(openGameFolder); + openFolderMenu->addAction(openUpdateFolder); openFolderMenu->addAction(openSaveDataFolder); openFolderMenu->addAction(openLogFolder); @@ -87,10 +89,12 @@ public: QMenu* deleteMenu = new QMenu(tr("Delete..."), widget); QAction* deleteGame = new QAction(tr("Delete Game"), widget); QAction* deleteUpdate = new QAction(tr("Delete Update"), widget); + QAction* deleteSaveData = new QAction(tr("Delete Save Data"), widget); QAction* deleteDLC = new QAction(tr("Delete DLC"), widget); deleteMenu->addAction(deleteGame); deleteMenu->addAction(deleteUpdate); + deleteMenu->addAction(deleteSaveData); deleteMenu->addAction(deleteDLC); menu.addMenu(deleteMenu); @@ -122,6 +126,18 @@ public: QDesktopServices::openUrl(QUrl::fromLocalFile(folderPath)); } + if (selected == openUpdateFolder) { + QString open_update_path; + Common::FS::PathToQString(open_update_path, m_games[itemID].path); + open_update_path += "-UPDATE"; + if (!std::filesystem::exists(Common::FS::PathFromQString(open_update_path))) { + QMessageBox::critical(nullptr, tr("Error"), + QString(tr("This game has no update folder to open!"))); + } else { + QDesktopServices::openUrl(QUrl::fromLocalFile(open_update_path)); + } + } + if (selected == openSaveDataFolder) { QString userPath; Common::FS::PathToQString(userPath, @@ -143,7 +159,7 @@ public: PSF psf; std::filesystem::path game_folder_path = m_games[itemID].path; std::filesystem::path game_update_path = game_folder_path; - game_update_path += "UPDATE"; + game_update_path += "-UPDATE"; if (std::filesystem::exists(game_update_path)) { game_folder_path = game_update_path; } @@ -238,6 +254,11 @@ public: QString trophyPath, gameTrpPath; Common::FS::PathToQString(trophyPath, m_games[itemID].serial); Common::FS::PathToQString(gameTrpPath, m_games[itemID].path); + auto game_update_path = Common::FS::PathFromQString(gameTrpPath); + game_update_path += "-UPDATE"; + if (std::filesystem::exists(game_update_path)) { + Common::FS::PathToQString(gameTrpPath, game_update_path); + } TrophyViewer* trophyViewer = new TrophyViewer(trophyPath, gameTrpPath); trophyViewer->show(); connect(widget->parent(), &QWidget::destroyed, trophyViewer, @@ -335,14 +356,18 @@ public: clipboard->setText(combinedText); } - if (selected == deleteGame || selected == deleteUpdate || selected == deleteDLC) { + if (selected == deleteGame || selected == deleteUpdate || selected == deleteDLC || + selected == deleteSaveData) { bool error = false; - QString folder_path, game_update_path, dlc_path; + QString folder_path, game_update_path, dlc_path, save_data_path; Common::FS::PathToQString(folder_path, m_games[itemID].path); game_update_path = folder_path + "-UPDATE"; Common::FS::PathToQString( dlc_path, Config::getAddonInstallDir() / Common::FS::PathFromQString(folder_path).parent_path().filename()); + Common::FS::PathToQString(save_data_path, + Common::FS::GetUserPath(Common::FS::PathType::UserDir) / + "savedata/1" / m_games[itemID].serial); QString message_type = tr("Game"); if (selected == deleteUpdate) { @@ -363,6 +388,15 @@ public: folder_path = dlc_path; message_type = tr("DLC"); } + } else if (selected == deleteSaveData) { + if (!std::filesystem::exists(Common::FS::PathFromQString(save_data_path))) { + QMessageBox::critical(nullptr, tr("Error"), + QString(tr("This game has no save data to delete!"))); + error = true; + } else { + folder_path = save_data_path; + message_type = tr("Save Data"); + } } if (!error) { QString gameName = QString::fromStdString(m_games[itemID].name); @@ -374,7 +408,10 @@ public: QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { dir.removeRecursively(); - widget->removeRow(itemID); + if (selected == deleteGame) { + widget->removeRow(itemID); + m_games.removeAt(itemID); + } } } } diff --git a/src/qt_gui/install_dir_select.cpp b/src/qt_gui/install_dir_select.cpp index e0951b123..e90a10ee6 100644 --- a/src/qt_gui/install_dir_select.cpp +++ b/src/qt_gui/install_dir_select.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include #include @@ -15,10 +16,11 @@ #include "install_dir_select.h" InstallDirSelect::InstallDirSelect() : selected_dir() { - selected_dir = Config::getGameInstallDirs().empty() ? "" : Config::getGameInstallDirs().front(); + auto install_dirs = Config::getGameInstallDirs(); + selected_dir = install_dirs.empty() ? "" : install_dirs.front(); - if (!Config::getGameInstallDirs().empty() && Config::getGameInstallDirs().size() == 1) { - reject(); + if (!install_dirs.empty() && install_dirs.size() == 1) { + accept(); } auto layout = new QVBoxLayout(this); @@ -53,6 +55,14 @@ QWidget* InstallDirSelect::SetupInstallDirList() { vlayout->addWidget(m_path_list); + auto checkbox = new QCheckBox(tr("Install All Queued to Selected Folder")); + connect(checkbox, &QCheckBox::toggled, this, &InstallDirSelect::setUseForAllQueued); + vlayout->addWidget(checkbox); + + auto checkbox2 = new QCheckBox(tr("Delete PKG File on Install")); + connect(checkbox2, &QCheckBox::toggled, this, &InstallDirSelect::setDeleteFileOnInstall); + vlayout->addWidget(checkbox2); + group->setLayout(vlayout); return group; } @@ -66,6 +76,14 @@ void InstallDirSelect::setSelectedDirectory(QListWidgetItem* item) { } } +void InstallDirSelect::setUseForAllQueued(bool enabled) { + use_for_all_queued = enabled; +} + +void InstallDirSelect::setDeleteFileOnInstall(bool enabled) { + delete_file_on_install = enabled; +} + QWidget* InstallDirSelect::SetupDialogActions() { auto actions = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); diff --git a/src/qt_gui/install_dir_select.h b/src/qt_gui/install_dir_select.h index e3e81575a..e11cbf381 100644 --- a/src/qt_gui/install_dir_select.h +++ b/src/qt_gui/install_dir_select.h @@ -22,9 +22,21 @@ public: return selected_dir; } + bool useForAllQueued() { + return use_for_all_queued; + } + + bool deleteFileOnInstall() { + return delete_file_on_install; + } + private: QWidget* SetupInstallDirList(); QWidget* SetupDialogActions(); void setSelectedDirectory(QListWidgetItem* item); + void setDeleteFileOnInstall(bool enabled); + void setUseForAllQueued(bool enabled); std::filesystem::path selected_dir; + bool delete_file_on_install = false; + bool use_for_all_queued = false; }; diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index 3ee392613..3678b3a82 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -725,9 +725,20 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int return; } auto category = psf.GetString("CATEGORY"); - InstallDirSelect ids; - ids.exec(); - auto game_install_dir = ids.getSelectedDirectory(); + + if (!use_for_all_queued || pkgNum == 1) { + InstallDirSelect ids; + const auto selected = ids.exec(); + if (selected == QDialog::Rejected) { + return; + } + + last_install_dir = ids.getSelectedDirectory(); + delete_file_on_install = ids.deleteFileOnInstall(); + use_for_all_queued = ids.useForAllQueued(); + } + std::filesystem::path game_install_dir = last_install_dir; + auto game_folder_path = game_install_dir / pkg.GetTitleID(); QString pkgType = QString::fromStdString(pkg.GetPkgFlags()); bool use_game_update = pkgType.contains("PATCH") && Config::getSeparateUpdateEnabled(); @@ -879,8 +890,14 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int if (pkgNum == nPkg) { QString path; Common::FS::PathToQString(path, game_install_dir); + QIcon windowIcon( + Common::FS::PathToUTF8String(game_folder_path / "sce_sys/icon0.png") + .c_str()); QMessageBox extractMsgBox(this); extractMsgBox.setWindowTitle(tr("Extraction Finished")); + if (!windowIcon.isNull()) { + extractMsgBox.setWindowIcon(windowIcon); + } extractMsgBox.setText( QString(tr("Game successfully installed at %1")).arg(path)); extractMsgBox.addButton(QMessageBox::Ok); @@ -894,6 +911,9 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int }); extractMsgBox.exec(); } + if (delete_file_on_install) { + std::filesystem::remove(file); + } }); connect(&dialog, &QProgressDialog::canceled, [&]() { futureWatcher.cancel(); }); connect(&futureWatcher, &QFutureWatcher::progressValueChanged, &dialog, diff --git a/src/qt_gui/main_window.h b/src/qt_gui/main_window.h index f4163defa..5ac56e44c 100644 --- a/src/qt_gui/main_window.h +++ b/src/qt_gui/main_window.h @@ -123,4 +123,8 @@ protected: } void resizeEvent(QResizeEvent* event) override; + + std::filesystem::path last_install_dir = ""; + bool delete_file_on_install = false; + bool use_for_all_queued = false; }; From 9bad66b24d4082240d00849a3d342d4d4a7c52d3 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Wed, 29 Jan 2025 01:29:52 -0800 Subject: [PATCH 36/72] hotfix: Raise videodec memory back up to 16MB. Found a game that needs more, still should be low enough compared to before to fix some games. --- src/core/libraries/videodec/videodec.cpp | 2 +- src/core/libraries/videodec/videodec2.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/libraries/videodec/videodec.cpp b/src/core/libraries/videodec/videodec.cpp index 79001e76f..02ea61509 100644 --- a/src/core/libraries/videodec/videodec.cpp +++ b/src/core/libraries/videodec/videodec.cpp @@ -9,7 +9,7 @@ namespace Libraries::Videodec { -static constexpr u64 kMinimumMemorySize = 8_MB; ///> Fake minimum memory size for querying +static constexpr u64 kMinimumMemorySize = 16_MB; ///> Fake minimum memory size for querying int PS4_SYSV_ABI sceVideodecCreateDecoder(const OrbisVideodecConfigInfo* pCfgInfoIn, const OrbisVideodecResourceInfo* pRsrcInfoIn, diff --git a/src/core/libraries/videodec/videodec2.cpp b/src/core/libraries/videodec/videodec2.cpp index be0db4ea3..a7e520b41 100644 --- a/src/core/libraries/videodec/videodec2.cpp +++ b/src/core/libraries/videodec/videodec2.cpp @@ -10,7 +10,7 @@ namespace Libraries::Vdec2 { -static constexpr u64 kMinimumMemorySize = 8_MB; ///> Fake minimum memory size for querying +static constexpr u64 kMinimumMemorySize = 16_MB; ///> Fake minimum memory size for querying s32 PS4_SYSV_ABI sceVideodec2QueryComputeMemoryInfo(OrbisVideodec2ComputeMemoryInfo* computeMemInfo) { From aa847de043e2e04512d5d01b4d9e40adc4706b0a Mon Sep 17 00:00:00 2001 From: isshininu Date: Wed, 29 Jan 2025 13:54:08 +0400 Subject: [PATCH 37/72] Update ru_RU translation (#2267) Several changes in ru_RU translation file. --- src/qt_gui/translations/ru_RU.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/qt_gui/translations/ru_RU.ts b/src/qt_gui/translations/ru_RU.ts index 6423f5ba4..0fddb1e7f 100644 --- a/src/qt_gui/translations/ru_RU.ts +++ b/src/qt_gui/translations/ru_RU.ts @@ -126,11 +126,11 @@ Copy All - Копировать все + Копировать всё Delete... - Удаление... + Удалить... Delete Game @@ -158,7 +158,7 @@ Submit a report - Отправить отчет + Отправить отчёт Shortcut creation @@ -297,7 +297,7 @@ Elf Viewer - Elf + Исполняемый файл Game Install Directory @@ -542,7 +542,7 @@ Fullscreen Mode - Режим Полного Экран + Тип полноэкранного режима Enable Separate Update Folder @@ -574,11 +574,11 @@ Trophy Key - Trophy Key + Ключ трофеев Trophy - Trophy + Трофеи Logger @@ -750,7 +750,7 @@ Audio Backend - Звуковая Подсистема + Звуковая подсистема Save @@ -826,7 +826,7 @@ disableTrophycheckBox - Отключить уведомления о трофеях:\nОтключает внутриигровые уведомления о трофеях. Прогресс трофеев по прежнему можно отслеживать в меню Просмотр трофеев (правая кнопка мыши по игре в главном окне). + Отключить уведомления о трофеях:\nОтключает внутриигровые уведомления о трофеях. Прогресс трофеев по прежнему можно отслеживать в меню просмотра трофеев (правая кнопка мыши по игре в главном окне). hideCursorGroupBox @@ -1192,11 +1192,11 @@ Play Time - Времени в игре + Время в игре Never Played - Вы не играли + Нет h @@ -1361,4 +1361,4 @@ ТБ - \ No newline at end of file + From 4bb578f9fb73ce77680e26621717db460a93b0e8 Mon Sep 17 00:00:00 2001 From: Missake212 Date: Wed, 29 Jan 2025 11:45:44 +0100 Subject: [PATCH 38/72] updates french translation (#2262) * updates the french translation * fix space at the end * forgot to translate a line * final changes * final changes 2 --- src/qt_gui/translations/fr.ts | 66 +++++++++++++++++------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/qt_gui/translations/fr.ts b/src/qt_gui/translations/fr.ts index 601ece8b4..0f87b087b 100644 --- a/src/qt_gui/translations/fr.ts +++ b/src/qt_gui/translations/fr.ts @@ -146,19 +146,19 @@ Compatibility... - Compatibility... + Compatibilité... Update database - Update database + Mettre à jour la base de données View report - View report + Voir rapport Submit a report - Submit a report + Soumettre un rapport Shortcut creation @@ -186,7 +186,7 @@ requiresEnableSeparateUpdateFolder_MSG - This feature requires the 'Enable Separate Update Folder' config option to work. If you want to use this feature, please enable it. + Cette fonctionnalité nécessite l'option 'Dossier séparé pour les mises à jour' pour fonctionner. Si vous voulez utiliser cette fonctionnalité, veuillez l'activer. This game has no update to delete! @@ -546,7 +546,7 @@ Enable Separate Update Folder - Dossier séparé pour les mises à jours + Dossier séparé pour les mises à jour Default tab when opening settings @@ -574,11 +574,11 @@ Trophy Key - Trophy Key + Clé de trophée Trophy - Trophy + Trophée Logger @@ -586,11 +586,11 @@ Log Type - Type + Type de journal Log Filter - Filtre + Filtre du journal Open Log Location @@ -722,7 +722,7 @@ Disable Trophy Pop-ups - Disable Trophy Pop-ups + Désactiver les notifications de trophées Play title music @@ -730,19 +730,19 @@ Update Compatibility Database On Startup - Update Compatibility Database On Startup + Mettre à jour la base de données de compatibilité au lancement Game Compatibility - Game Compatibility + Compatibilité du jeu Display Compatibility Data - Display Compatibility Data + Afficher les données de compatibilité Update Compatibility Database - Update Compatibility Database + Mettre à jour la base de données de compatibilité Volume @@ -750,7 +750,7 @@ Audio Backend - Audio Backend + Back-end audio Save @@ -786,7 +786,7 @@ separateUpdatesCheckBox - Dossier séparé pour les mises à jours:\nInstalle les mises à jours des jeux dans un dossier séparé pour une gestion plus facile. + Dossier séparé pour les mises à jour:\nInstalle les mises à jours des jeux dans un dossier séparé pour une gestion plus facile. showSplashCheckBox @@ -806,7 +806,7 @@ TrophyKey - Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. + Clé de trophées:\nClé utilisée pour décrypter les trophées. Doit être obtenu à partir de votre console jailbreakée.\nDoit contenir des caractères hexadécimaux uniquement. logTypeGroupBox @@ -826,7 +826,7 @@ disableTrophycheckBox - Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). + Désactiver les notifications de trophées:\nDésactive les notifications de trophées en jeu. La progression des trophées peut toujours être suivie à l'aide de la Visionneuse de trophées (clique droit sur le jeu sur la fenêtre principale). hideCursorGroupBox @@ -842,15 +842,15 @@ enableCompatibilityCheckBox - Display Compatibility Data:\nDisplays game compatibility information in table view. Enable "Update Compatibility On Startup" to get up-to-date information. + Afficher les données de compatibilité:\nAffiche les informations de compatibilité des jeux dans une colonne dédiée. Activez "Mettre à jour la compatibilité au démarrage" pour avoir des informations à jour. checkCompatibilityOnStartupCheckBox - Update Compatibility On Startup:\nAutomatically update the compatibility database when shadPS4 starts. + Mettre à jour la compatibilité au démarrage:\nMettre à jour automatiquement la base de données de compatibilité au démarrage de shadPS4. updateCompatibilityButton - Update Compatibility Database:\nImmediately update the compatibility database. + Mettre à jour la compatibilité au démarrage:\nMet à jour immédiatement la base de données de compatibilité. Never @@ -1093,7 +1093,7 @@ DownloadComplete_MSG - Patchs téléchargés avec succès ! Tous les patches disponibles pour tous les jeux ont été téléchargés, il n'est pas nécessaire de les télécharger individuellement pour chaque jeu comme c'est le cas pour les Cheats. Si le correctif n'apparaît pas, il se peut qu'il n'existe pas pour le numéro de série et la version spécifiques du jeu. + Patchs téléchargés avec succès ! Tous les patches disponibles pour tous les jeux ont été téléchargés, il n'est pas nécessaire de les télécharger individuellement pour chaque jeu comme c'est le cas pour les Cheats. Si le correctif n'apparaît pas, il se peut qu'il n'existe pas pour la série et la version spécifiques du jeu. Failed to parse JSON data from HTML. @@ -1113,7 +1113,7 @@ You may need to update your game. - Vous devrez peut-être mettre à jour votre jeu. + Vous devriez peut-être mettre à jour votre jeu. Incompatibility Notice @@ -1137,7 +1137,7 @@ Directory does not exist: - Répertoire n'existe pas: + Le répertoire n'existe pas: Failed to open files.json for reading. @@ -1149,7 +1149,7 @@ Can't apply cheats before the game is started - Impossible d'appliquer les Cheats avant que le jeu ne commence. + Impossible d'appliquer les cheats avant que le jeu ne soit lancé @@ -1168,7 +1168,7 @@ Compatibility - Compatibility + Compatibilité Region @@ -1212,27 +1212,27 @@ Compatibility is untested - Compatibility is untested + La compatibilité n'a pas été testé Game does not initialize properly / crashes the emulator - Game does not initialize properly / crashes the emulator + Le jeu ne se lance pas correctement / crash l'émulateur Game boots, but only displays a blank screen - Game boots, but only displays a blank screen + Le jeu démarre, mais n'affiche qu'un écran noir Game displays an image but does not go past the menu - Game displays an image but does not go past the menu + Le jeu affiche une image mais ne dépasse pas le menu Game has game-breaking glitches or unplayable performance - Game has game-breaking glitches or unplayable performance + Le jeu a des problèmes majeurs ou des performances qui le rendent injouable Game can be completed with playable performance and no major glitches - Game can be completed with playable performance and no major glitches + Le jeu peut être terminé avec des performances acceptables et sans problèmes majeurs From 929e15260d8d7a618c10a5f396b1f9e872970425 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Wed, 29 Jan 2025 18:14:36 -0800 Subject: [PATCH 39/72] shader_recompiler: Fix cube sampling coordinates. (#2266) --- .../ir/passes/resource_tracking_pass.cpp | 25 ++++++++++++++----- src/shader_recompiler/specialization.h | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp index 43d125bf0..c5f98e5b9 100644 --- a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp +++ b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp @@ -583,6 +583,18 @@ void PatchTextureBufferArgs(IR::Block& block, IR::Inst& inst, Info& info) { } } +IR::Value FixCubeCoords(IR::IREmitter& ir, const AmdGpu::Image& image, const IR::Value& x, + const IR::Value& y, const IR::Value& face) { + if (!image.IsCube()) { + return ir.CompositeConstruct(x, y, face); + } + // AMD cube math results in coordinates in the range [1.0, 2.0]. We need + // to convert this to the range [0.0, 1.0] to get correct results. + const auto fixed_x = ir.FPSub(IR::F32{x}, ir.Imm32(1.f)); + const auto fixed_y = ir.FPSub(IR::F32{y}, ir.Imm32(1.f)); + return ir.CompositeConstruct(fixed_x, fixed_y, face); +} + void PatchImageSampleArgs(IR::Block& block, IR::Inst& inst, Info& info, const ImageResource& image_res, const AmdGpu::Image& image) { const auto handle = inst.Arg(0); @@ -643,8 +655,8 @@ void PatchImageSampleArgs(IR::Block& block, IR::Inst& inst, Info& info, case AmdGpu::ImageType::Color1DArray: return read(0); case AmdGpu::ImageType::Color2D: - case AmdGpu::ImageType::Color2DArray: case AmdGpu::ImageType::Color2DMsaa: + case AmdGpu::ImageType::Color2DArray: return ir.CompositeConstruct(read(0), read(8)); case AmdGpu::ImageType::Color3D: return ir.CompositeConstruct(read(0), read(8), read(16)); @@ -665,8 +677,8 @@ void PatchImageSampleArgs(IR::Block& block, IR::Inst& inst, Info& info, addr_reg = addr_reg + 2; return {get_addr_reg(addr_reg - 2), get_addr_reg(addr_reg - 1)}; case AmdGpu::ImageType::Color2D: - case AmdGpu::ImageType::Color2DArray: case AmdGpu::ImageType::Color2DMsaa: + case AmdGpu::ImageType::Color2DArray: // (du/dx, dv/dx), (du/dy, dv/dy) addr_reg = addr_reg + 4; return {ir.CompositeConstruct(get_addr_reg(addr_reg - 4), get_addr_reg(addr_reg - 3)), @@ -711,12 +723,13 @@ void PatchImageSampleArgs(IR::Block& block, IR::Inst& inst, Info& info, case AmdGpu::ImageType::Color2D: // x, y addr_reg = addr_reg + 2; return ir.CompositeConstruct(get_coord(addr_reg - 2, 0), get_coord(addr_reg - 1, 1)); - case AmdGpu::ImageType::Color2DArray: // x, y, slice - [[fallthrough]]; case AmdGpu::ImageType::Color2DMsaa: // x, y, frag + [[fallthrough]]; + case AmdGpu::ImageType::Color2DArray: // x, y, slice addr_reg = addr_reg + 3; - return ir.CompositeConstruct(get_coord(addr_reg - 3, 0), get_coord(addr_reg - 2, 1), - get_addr_reg(addr_reg - 1)); + // Note we can use FixCubeCoords with fallthrough cases since it checks for image type. + return FixCubeCoords(ir, image, get_coord(addr_reg - 3, 0), get_coord(addr_reg - 2, 1), + get_addr_reg(addr_reg - 1)); case AmdGpu::ImageType::Color3D: // x, y, z addr_reg = addr_reg + 3; return ir.CompositeConstruct(get_coord(addr_reg - 3, 0), get_coord(addr_reg - 2, 1), diff --git a/src/shader_recompiler/specialization.h b/src/shader_recompiler/specialization.h index 523e63497..eb0085965 100644 --- a/src/shader_recompiler/specialization.h +++ b/src/shader_recompiler/specialization.h @@ -47,6 +47,7 @@ struct ImageSpecialization { AmdGpu::ImageType type = AmdGpu::ImageType::Color2D; bool is_integer = false; bool is_storage = false; + bool is_cube = false; AmdGpu::CompMapping dst_select{}; AmdGpu::NumberConversion num_conversion{}; @@ -127,6 +128,7 @@ struct StageSpecialization { spec.type = sharp.GetViewType(desc.is_array); spec.is_integer = AmdGpu::IsInteger(sharp.GetNumberFmt()); spec.is_storage = desc.is_written; + spec.is_cube = sharp.IsCube(); if (spec.is_storage) { spec.dst_select = sharp.DstSelect(); } From 0358271b93160a97079376c408b5c270e807826c Mon Sep 17 00:00:00 2001 From: Vinicius Rangel Date: Thu, 30 Jan 2025 04:45:48 -0300 Subject: [PATCH 40/72] Savefixes vii (#2279) * savedata: rewrite save memory functions to handle slot id & better backup management * savedata: auto-restore backup if needed * safe save backup shutdown replaced exit by quick_exit --- src/common/elf_info.h | 1 + src/core/libraries/save_data/save_backup.cpp | 21 +- src/core/libraries/save_data/save_backup.h | 2 + .../libraries/save_data/save_instance.cpp | 53 +-- src/core/libraries/save_data/save_instance.h | 5 +- src/core/libraries/save_data/save_memory.cpp | 365 ++++++++---------- src/core/libraries/save_data/save_memory.h | 36 +- src/core/libraries/save_data/savedata.cpp | 108 ++++-- src/emulator.cpp | 3 +- 9 files changed, 285 insertions(+), 309 deletions(-) diff --git a/src/common/elf_info.h b/src/common/elf_info.h index cb32679bb..d885709cd 100644 --- a/src/common/elf_info.h +++ b/src/common/elf_info.h @@ -80,6 +80,7 @@ public: static constexpr u32 FW_40 = 0x4000000; static constexpr u32 FW_45 = 0x4500000; static constexpr u32 FW_50 = 0x5000000; + static constexpr u32 FW_55 = 0x5500000; static constexpr u32 FW_80 = 0x8000000; static ElfInfo& Instance() { diff --git a/src/core/libraries/save_data/save_backup.cpp b/src/core/libraries/save_data/save_backup.cpp index 5261cdb11..f85845f70 100644 --- a/src/core/libraries/save_data/save_backup.cpp +++ b/src/core/libraries/save_data/save_backup.cpp @@ -121,15 +121,17 @@ static void BackupThreadBody() { std::scoped_lock lk{g_backup_queue_mutex}; g_backup_queue.front().done = true; } - std::this_thread::sleep_for(std::chrono::seconds(5)); // Don't backup too often { std::scoped_lock lk{g_backup_queue_mutex}; g_backup_queue.pop_front(); - g_result_queue.push_back(std::move(req)); - if (g_result_queue.size() > 20) { - g_result_queue.pop_front(); + if (req.origin != OrbisSaveDataEventType::__DO_NOT_SAVE) { + g_result_queue.push_back(std::move(req)); + if (g_result_queue.size() > 20) { + g_result_queue.pop_front(); + } } } + std::this_thread::sleep_for(std::chrono::seconds(5)); // Don't backup too often } g_backup_status = WorkerStatus::NotStarted; } @@ -141,6 +143,15 @@ void StartThread() { LOG_DEBUG(Lib_SaveData, "Starting backup thread"); g_backup_status = WorkerStatus::Waiting; g_backup_thread = std::jthread{BackupThreadBody}; + static std::once_flag flag; + std::call_once(flag, [] { + std::at_quick_exit([] { + StopThread(); + while (GetWorkerStatus() != WorkerStatus::NotStarted) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + }); + }); } void StopThread() { @@ -148,12 +159,12 @@ void StopThread() { return; } LOG_DEBUG(Lib_SaveData, "Stopping backup thread"); + g_backup_status = WorkerStatus::Stopping; { std::scoped_lock lk{g_backup_queue_mutex}; g_backup_queue.emplace_back(BackupRequest{}); } g_backup_thread_semaphore.release(); - g_backup_status = WorkerStatus::Stopping; } bool NewRequest(OrbisUserServiceUserId user_id, std::string_view title_id, diff --git a/src/core/libraries/save_data/save_backup.h b/src/core/libraries/save_data/save_backup.h index e49c69f60..83a263c9b 100644 --- a/src/core/libraries/save_data/save_backup.h +++ b/src/core/libraries/save_data/save_backup.h @@ -25,6 +25,8 @@ enum class OrbisSaveDataEventType : u32 { UMOUNT_BACKUP = 1, BACKUP = 2, SAVE_DATA_MEMORY_SYNC = 3, + + __DO_NOT_SAVE = 1000000, // This value is only for the backup thread }; struct BackupRequest { diff --git a/src/core/libraries/save_data/save_instance.cpp b/src/core/libraries/save_data/save_instance.cpp index c2b7dca3c..26708d2d6 100644 --- a/src/core/libraries/save_data/save_instance.cpp +++ b/src/core/libraries/save_data/save_instance.cpp @@ -10,6 +10,7 @@ #include "common/path_util.h" #include "common/singleton.h" #include "core/file_sys/fs.h" +#include "save_backup.h" #include "save_instance.h" constexpr auto OrbisSaveDataBlocksMin2 = 96; // 3MiB @@ -45,14 +46,13 @@ static const std::unordered_map default_title = { namespace Libraries::SaveData { -std::filesystem::path SaveInstance::MakeTitleSavePath(OrbisUserServiceUserId user_id, - std::string_view game_serial) { +fs::path SaveInstance::MakeTitleSavePath(OrbisUserServiceUserId user_id, + std::string_view game_serial) { return Config::GetSaveDataPath() / std::to_string(user_id) / game_serial; } -std::filesystem::path SaveInstance::MakeDirSavePath(OrbisUserServiceUserId user_id, - std::string_view game_serial, - std::string_view dir_name) { +fs::path SaveInstance::MakeDirSavePath(OrbisUserServiceUserId user_id, std::string_view game_serial, + std::string_view dir_name) { return Config::GetSaveDataPath() / std::to_string(user_id) / game_serial / dir_name; } @@ -65,7 +65,7 @@ uint64_t SaveInstance::GetMaxBlockFromSFO(const PSF& psf) { return *(uint64_t*)value.data(); } -std::filesystem::path SaveInstance::GetParamSFOPath(const std::filesystem::path& dir_path) { +fs::path SaveInstance::GetParamSFOPath(const fs::path& dir_path) { return dir_path / sce_sys / "param.sfo"; } @@ -129,7 +129,6 @@ SaveInstance& SaveInstance::operator=(SaveInstance&& other) noexcept { save_path = std::move(other.save_path); param_sfo_path = std::move(other.param_sfo_path); corrupt_file_path = std::move(other.corrupt_file_path); - corrupt_file = std::move(other.corrupt_file); param_sfo = std::move(other.param_sfo); mount_point = std::move(other.mount_point); max_blocks = other.max_blocks; @@ -142,7 +141,8 @@ SaveInstance& SaveInstance::operator=(SaveInstance&& other) noexcept { return *this; } -void SaveInstance::SetupAndMount(bool read_only, bool copy_icon, bool ignore_corrupt) { +void SaveInstance::SetupAndMount(bool read_only, bool copy_icon, bool ignore_corrupt, + bool dont_restore_backup) { if (mounted) { UNREACHABLE_MSG("Save instance is already mounted"); } @@ -161,25 +161,27 @@ void SaveInstance::SetupAndMount(bool read_only, bool copy_icon, bool ignore_cor } exists = true; } else { + std::optional err; if (!ignore_corrupt && fs::exists(corrupt_file_path)) { - throw std::filesystem::filesystem_error( - "Corrupted save data", corrupt_file_path, - std::make_error_code(std::errc::illegal_byte_sequence)); + err = fs::filesystem_error("Corrupted save data", corrupt_file_path, + std::make_error_code(std::errc::illegal_byte_sequence)); + } else if (!param_sfo.Open(param_sfo_path)) { + err = fs::filesystem_error("Failed to read param.sfo", param_sfo_path, + std::make_error_code(std::errc::illegal_byte_sequence)); } - if (!param_sfo.Open(param_sfo_path)) { - throw std::filesystem::filesystem_error( - "Failed to read param.sfo", param_sfo_path, - std::make_error_code(std::errc::illegal_byte_sequence)); + if (err.has_value()) { + if (dont_restore_backup) { + throw err.value(); + } + if (Backup::Restore(save_path)) { + return SetupAndMount(read_only, copy_icon, ignore_corrupt, true); + } } } if (!ignore_corrupt && !read_only) { - int err = corrupt_file.Open(corrupt_file_path, Common::FS::FileAccessMode::Write); - if (err != 0) { - throw std::filesystem::filesystem_error( - "Failed to open corrupted file", corrupt_file_path, - std::make_error_code(std::errc::illegal_byte_sequence)); - } + Common::FS::IOFile f(corrupt_file_path, Common::FS::FileAccessMode::Write); + f.Close(); } max_blocks = static_cast(GetMaxBlockFromSFO(param_sfo)); @@ -197,12 +199,11 @@ void SaveInstance::Umount() { mounted = false; const bool ok = param_sfo.Encode(param_sfo_path); if (!ok) { - throw std::filesystem::filesystem_error("Failed to write param.sfo", param_sfo_path, - std::make_error_code(std::errc::permission_denied)); + throw fs::filesystem_error("Failed to write param.sfo", param_sfo_path, + std::make_error_code(std::errc::permission_denied)); } param_sfo = PSF(); - corrupt_file.Close(); fs::remove(corrupt_file_path); g_mnt->Unmount(save_path, mount_point); } @@ -216,8 +217,8 @@ void SaveInstance::CreateFiles() { const bool ok = param_sfo.Encode(param_sfo_path); if (!ok) { - throw std::filesystem::filesystem_error("Failed to write param.sfo", param_sfo_path, - std::make_error_code(std::errc::permission_denied)); + throw fs::filesystem_error("Failed to write param.sfo", param_sfo_path, + std::make_error_code(std::errc::permission_denied)); } } diff --git a/src/core/libraries/save_data/save_instance.h b/src/core/libraries/save_data/save_instance.h index 3be5c4595..6e7ac8f66 100644 --- a/src/core/libraries/save_data/save_instance.h +++ b/src/core/libraries/save_data/save_instance.h @@ -42,8 +42,6 @@ class SaveInstance { std::filesystem::path param_sfo_path; std::filesystem::path corrupt_file_path; - Common::FS::IOFile corrupt_file; - PSF param_sfo; std::string mount_point; @@ -80,7 +78,8 @@ public: SaveInstance& operator=(const SaveInstance& other) = delete; SaveInstance& operator=(SaveInstance&& other) noexcept; - void SetupAndMount(bool read_only = false, bool copy_icon = false, bool ignore_corrupt = false); + void SetupAndMount(bool read_only = false, bool copy_icon = false, bool ignore_corrupt = false, + bool dont_restore_backup = false); void Umount(); diff --git a/src/core/libraries/save_data/save_memory.cpp b/src/core/libraries/save_data/save_memory.cpp index 84179bc27..13e122c60 100644 --- a/src/core/libraries/save_data/save_memory.cpp +++ b/src/core/libraries/save_data/save_memory.cpp @@ -6,14 +6,16 @@ #include #include #include +#include #include #include #include #include "common/assert.h" +#include "common/elf_info.h" #include "common/logging/log.h" -#include "common/polyfill_thread.h" +#include "common/path_util.h" #include "common/singleton.h" #include "common/thread.h" #include "core/file_sys/fs.h" @@ -23,265 +25,202 @@ using Common::FS::IOFile; namespace fs = std::filesystem; constexpr std::string_view sce_sys = "sce_sys"; // system folder inside save -constexpr std::string_view DirnameSaveDataMemory = "sce_sdmemory"; +constexpr std::string_view StandardDirnameSaveDataMemory = "sce_sdmemory"; constexpr std::string_view FilenameSaveDataMemory = "memory.dat"; +constexpr std::string_view IconName = "icon0.png"; +constexpr std::string_view CorruptFileName = "corrupted"; namespace Libraries::SaveData::SaveMemory { static Core::FileSys::MntPoints* g_mnt = Common::Singleton::Instance(); -static OrbisUserServiceUserId g_user_id{}; -static std::string g_game_serial{}; -static std::filesystem::path g_save_path{}; -static std::filesystem::path g_param_sfo_path{}; -static PSF g_param_sfo; +struct SlotData { + OrbisUserServiceUserId user_id; + std::string game_serial; + std::filesystem::path folder_path; + PSF sfo; + std::vector memory_cache; +}; -static bool g_save_memory_initialized = false; -static std::mutex g_saving_memory_mutex; -static std::vector g_save_memory; +static std::mutex g_slot_mtx; +static std::unordered_map g_attached_slots; -static std::filesystem::path g_icon_path; -static std::vector g_icon_memory; +void PersistMemory(u32 slot_id, bool lock) { + std::unique_lock lck{g_slot_mtx, std::defer_lock}; + if (lock) { + lck.lock(); + } + auto& data = g_attached_slots[slot_id]; + auto memoryPath = data.folder_path / FilenameSaveDataMemory; + fs::create_directories(memoryPath.parent_path()); -static std::condition_variable g_trigger_save_memory; -static std::atomic_bool g_saving_memory = false; -static std::atomic_bool g_save_event = false; -static std::jthread g_save_memory_thread; - -static std::atomic_bool g_memory_dirty = false; -static std::atomic_bool g_param_dirty = false; -static std::atomic_bool g_icon_dirty = false; - -static void SaveFileSafe(void* buf, size_t count, const std::filesystem::path& path) { - const auto& dir = path.parent_path(); - const auto& name = path.filename(); - const auto tmp_path = dir / (name.string() + ".tmp"); - - IOFile file(tmp_path, Common::FS::FileAccessMode::Write); - file.WriteRaw(buf, count); - file.Close(); - - fs::remove(path); - fs::rename(tmp_path, path); -} - -[[noreturn]] void SaveThreadLoop() { - Common::SetCurrentThreadName("shadPS4:SaveData:SaveDataMemoryThread"); - std::mutex mtx; - while (true) { - { - std::unique_lock lk{mtx}; - g_trigger_save_memory.wait(lk); - } - // Save the memory - g_saving_memory = true; - std::scoped_lock lk{g_saving_memory_mutex}; + int n = 0; + std::string errMsg; + while (n++ < 10) { try { - LOG_DEBUG(Lib_SaveData, "Saving save data memory {}", fmt::UTF(g_save_path.u8string())); - - if (g_memory_dirty) { - g_memory_dirty = false; - SaveFileSafe(g_save_memory.data(), g_save_memory.size(), - g_save_path / FilenameSaveDataMemory); + IOFile f; + int r = f.Open(memoryPath, Common::FS::FileAccessMode::Write); + if (f.IsOpen()) { + f.WriteRaw(data.memory_cache.data(), data.memory_cache.size()); + f.Close(); + return; } - if (g_param_dirty) { - g_param_dirty = false; - static std::vector buf; - g_param_sfo.Encode(buf); - SaveFileSafe(buf.data(), buf.size(), g_param_sfo_path); - } - if (g_icon_dirty) { - g_icon_dirty = false; - SaveFileSafe(g_icon_memory.data(), g_icon_memory.size(), g_icon_path); - } - - if (g_save_event) { - Backup::PushBackupEvent(Backup::BackupRequest{ - .user_id = g_user_id, - .title_id = g_game_serial, - .dir_name = std::string{DirnameSaveDataMemory}, - .origin = Backup::OrbisSaveDataEventType::SAVE_DATA_MEMORY_SYNC, - .save_path = g_save_path, - }); - g_save_event = false; - } - } catch (const fs::filesystem_error& e) { - LOG_ERROR(Lib_SaveData, "Failed to save save data memory: {}", e.what()); - MsgDialog::ShowMsgDialog(MsgDialog::MsgDialogState{ - MsgDialog::MsgDialogState::UserState{ - .type = MsgDialog::ButtonType::OK, - .msg = fmt::format("Failed to save save data memory.\nCode: <{}>\n{}", - e.code().message(), e.what()), - }, - }); + const auto err = std::error_code{r, std::iostream_category()}; + throw std::filesystem::filesystem_error{err.message(), err}; + } catch (const std::filesystem::filesystem_error& e) { + errMsg = std::string{e.what()}; + std::this_thread::sleep_for(std::chrono::seconds(1)); } - g_saving_memory = false; } + const MsgDialog::MsgDialogState dialog{MsgDialog::MsgDialogState::UserState{ + .type = MsgDialog::ButtonType::OK, + .msg = "Failed to persist save memory:\n" + errMsg + "\nat " + + Common::FS::PathToUTF8String(memoryPath), + }}; + MsgDialog::ShowMsgDialog(dialog); } -void SetDirectories(OrbisUserServiceUserId user_id, std::string _game_serial) { - g_user_id = user_id; - g_game_serial = std::move(_game_serial); - g_save_path = SaveInstance::MakeDirSavePath(user_id, g_game_serial, DirnameSaveDataMemory); - g_param_sfo_path = SaveInstance::GetParamSFOPath(g_save_path); - g_param_sfo = PSF(); - g_icon_path = g_save_path / sce_sys / "icon0.png"; +std::string GetSaveDir(u32 slot_id) { + std::string dir(StandardDirnameSaveDataMemory); + if (slot_id > 0) { + dir += std::to_string(slot_id); + } + return dir; } -const std::filesystem::path& GetSavePath() { - return g_save_path; +std::filesystem::path GetSavePath(OrbisUserServiceUserId user_id, u32 slot_id, + std::string_view game_serial) { + std::string dir(StandardDirnameSaveDataMemory); + if (slot_id > 0) { + dir += std::to_string(slot_id); + } + return SaveInstance::MakeDirSavePath(user_id, Common::ElfInfo::Instance().GameSerial(), dir); } -size_t CreateSaveMemory(size_t memory_size) { - size_t existed_size = 0; +size_t SetupSaveMemory(OrbisUserServiceUserId user_id, u32 slot_id, std::string_view game_serial) { + std::lock_guard lck{g_slot_mtx}; - static std::once_flag init_save_thread_flag; - std::call_once(init_save_thread_flag, - [] { g_save_memory_thread = std::jthread{SaveThreadLoop}; }); + const auto save_dir = GetSavePath(user_id, slot_id, game_serial); - g_save_memory.resize(memory_size); - SaveInstance::SetupDefaultParamSFO(g_param_sfo, std::string{DirnameSaveDataMemory}, - g_game_serial); + auto& data = g_attached_slots[slot_id]; + data = SlotData{ + .user_id = user_id, + .game_serial = std::string{game_serial}, + .folder_path = save_dir, + .sfo = {}, + .memory_cache = {}, + }; - g_save_memory_initialized = true; + SaveInstance::SetupDefaultParamSFO(data.sfo, GetSaveDir(slot_id), std::string{game_serial}); - if (!fs::exists(g_param_sfo_path)) { - // Create save memory - fs::create_directories(g_save_path / sce_sys); - - IOFile memory_file{g_save_path / FilenameSaveDataMemory, Common::FS::FileAccessMode::Write}; - bool ok = memory_file.SetSize(memory_size); - if (!ok) { - LOG_ERROR(Lib_SaveData, "Failed to set memory size"); - throw std::filesystem::filesystem_error( - "Failed to set save memory size", g_save_path / FilenameSaveDataMemory, - std::make_error_code(std::errc::no_space_on_device)); - } - memory_file.Close(); - } else { - // Load save memory - - bool ok = g_param_sfo.Open(g_param_sfo_path); - if (!ok) { - LOG_ERROR(Lib_SaveData, "Failed to open SFO at {}", - fmt::UTF(g_param_sfo_path.u8string())); - throw std::filesystem::filesystem_error( - "failed to open SFO", g_param_sfo_path, - std::make_error_code(std::errc::illegal_byte_sequence)); - } - - IOFile memory_file{g_save_path / FilenameSaveDataMemory, Common::FS::FileAccessMode::Read}; - if (!memory_file.IsOpen()) { - LOG_ERROR(Lib_SaveData, "Failed to open save memory"); - throw std::filesystem::filesystem_error( - "failed to open save memory", g_save_path / FilenameSaveDataMemory, - std::make_error_code(std::errc::permission_denied)); - } - size_t save_size = memory_file.GetSize(); - existed_size = save_size; - memory_file.Seek(0); - memory_file.ReadRaw(g_save_memory.data(), std::min(save_size, memory_size)); - memory_file.Close(); + auto param_sfo_path = SaveInstance::GetParamSFOPath(save_dir); + if (!fs::exists(param_sfo_path)) { + return 0; } - return existed_size; + if (!data.sfo.Open(param_sfo_path) || fs::exists(save_dir / CorruptFileName)) { + if (!Backup::Restore(save_dir)) { // Could not restore the backup + return 0; + } + } + + const auto memory = save_dir / FilenameSaveDataMemory; + if (fs::exists(memory)) { + return fs::file_size(memory); + } + + return 0; } -void SetIcon(void* buf, size_t buf_size) { +void SetIcon(u32 slot_id, void* buf, size_t buf_size) { + std::lock_guard lck{g_slot_mtx}; + const auto& data = g_attached_slots[slot_id]; + const auto icon_path = data.folder_path / sce_sys / "icon0.png"; if (buf == nullptr) { const auto& src_icon = g_mnt->GetHostPath("/app0/sce_sys/save_data.png"); - if (fs::exists(src_icon)) { - if (fs::exists(g_icon_path)) { - fs::remove(g_icon_path); - } - fs::copy_file(src_icon, g_icon_path); + if (fs::exists(icon_path)) { + fs::remove(icon_path); } - if (fs::exists(g_icon_path)) { - IOFile file(g_icon_path, Common::FS::FileAccessMode::Read); - size_t size = file.GetSize(); - file.Seek(0); - g_icon_memory.resize(size); - file.ReadRaw(g_icon_memory.data(), size); - file.Close(); + if (fs::exists(src_icon)) { + fs::create_directories(icon_path.parent_path()); + fs::copy_file(src_icon, icon_path); } } else { - g_icon_memory.resize(buf_size); - std::memcpy(g_icon_memory.data(), buf, buf_size); - IOFile file(g_icon_path, Common::FS::FileAccessMode::Write); - file.Seek(0); - file.WriteRaw(g_icon_memory.data(), buf_size); + IOFile file(icon_path, Common::FS::FileAccessMode::Write); + file.WriteRaw(buf, buf_size); file.Close(); } } -void WriteIcon(void* buf, size_t buf_size) { - if (buf_size != g_icon_memory.size()) { - g_icon_memory.resize(buf_size); +bool IsSaveMemoryInitialized(u32 slot_id) { + std::lock_guard lck{g_slot_mtx}; + return g_attached_slots.contains(slot_id); +} + +PSF& GetParamSFO(u32 slot_id) { + std::lock_guard lck{g_slot_mtx}; + auto& data = g_attached_slots[slot_id]; + return data.sfo; +} + +std::vector GetIcon(u32 slot_id) { + std::lock_guard lck{g_slot_mtx}; + auto& data = g_attached_slots[slot_id]; + const auto icon_path = data.folder_path / sce_sys / "icon0.png"; + IOFile f{icon_path, Common::FS::FileAccessMode::Read}; + if (!f.IsOpen()) { + return {}; } - std::memcpy(g_icon_memory.data(), buf, buf_size); - g_icon_dirty = true; + const u64 size = f.GetSize(); + std::vector ret; + ret.resize(size); + f.ReadSpan(std::span{ret}); + return ret; } -bool IsSaveMemoryInitialized() { - return g_save_memory_initialized; -} - -PSF& GetParamSFO() { - return g_param_sfo; -} - -std::span GetIcon() { - return {g_icon_memory}; -} - -void SaveSFO(bool sync) { - if (!sync) { - g_param_dirty = true; - return; - } - const bool ok = g_param_sfo.Encode(g_param_sfo_path); +void SaveSFO(u32 slot_id) { + std::lock_guard lck{g_slot_mtx}; + const auto& data = g_attached_slots[slot_id]; + const auto sfo_path = SaveInstance::GetParamSFOPath(data.folder_path); + fs::create_directories(sfo_path.parent_path()); + const bool ok = data.sfo.Encode(sfo_path); if (!ok) { LOG_ERROR(Lib_SaveData, "Failed to encode param.sfo"); - throw std::filesystem::filesystem_error("Failed to write param.sfo", g_param_sfo_path, + throw std::filesystem::filesystem_error("Failed to write param.sfo", sfo_path, std::make_error_code(std::errc::permission_denied)); } } -bool IsSaving() { - return g_saving_memory; + +void ReadMemory(u32 slot_id, void* buf, size_t buf_size, int64_t offset) { + std::lock_guard lk{g_slot_mtx}; + auto& data = g_attached_slots[slot_id]; + auto& memory = data.memory_cache; + if (memory.empty()) { // Load file + IOFile f{data.folder_path / FilenameSaveDataMemory, Common::FS::FileAccessMode::Read}; + if (f.IsOpen()) { + memory.resize(f.GetSize()); + f.Seek(0); + f.ReadSpan(std::span{memory}); + } + } + s64 read_size = buf_size; + if (read_size + offset > memory.size()) { + read_size = memory.size() - offset; + } + std::memcpy(buf, memory.data() + offset, read_size); } -bool TriggerSaveWithoutEvent() { - if (g_saving_memory) { - return false; +void WriteMemory(u32 slot_id, void* buf, size_t buf_size, int64_t offset) { + std::lock_guard lk{g_slot_mtx}; + auto& data = g_attached_slots[slot_id]; + auto& memory = data.memory_cache; + if (offset + buf_size > memory.size()) { + memory.resize(offset + buf_size); } - g_trigger_save_memory.notify_one(); - return true; -} - -bool TriggerSave() { - if (g_saving_memory) { - return false; - } - g_save_event = true; - g_trigger_save_memory.notify_one(); - return true; -} - -void ReadMemory(void* buf, size_t buf_size, int64_t offset) { - std::scoped_lock lk{g_saving_memory_mutex}; - if (offset + buf_size > g_save_memory.size()) { - UNREACHABLE_MSG("ReadMemory out of bounds"); - } - std::memcpy(buf, g_save_memory.data() + offset, buf_size); -} - -void WriteMemory(void* buf, size_t buf_size, int64_t offset) { - std::scoped_lock lk{g_saving_memory_mutex}; - if (offset + buf_size > g_save_memory.size()) { - g_save_memory.resize(offset + buf_size); - } - std::memcpy(g_save_memory.data() + offset, buf, buf_size); - g_memory_dirty = true; + std::memcpy(memory.data() + offset, buf, buf_size); + PersistMemory(slot_id, false); + Backup::NewRequest(data.user_id, data.game_serial, GetSaveDir(slot_id), + Backup::OrbisSaveDataEventType::__DO_NOT_SAVE); } } // namespace Libraries::SaveData::SaveMemory \ No newline at end of file diff --git a/src/core/libraries/save_data/save_memory.h b/src/core/libraries/save_data/save_memory.h index 04eeaa652..681865634 100644 --- a/src/core/libraries/save_data/save_memory.h +++ b/src/core/libraries/save_data/save_memory.h @@ -3,7 +3,7 @@ #pragma once -#include +#include #include "save_backup.h" class PSF; @@ -14,36 +14,30 @@ using OrbisUserServiceUserId = s32; namespace Libraries::SaveData::SaveMemory { -void SetDirectories(OrbisUserServiceUserId user_id, std::string game_serial); +void PersistMemory(u32 slot_id, bool lock = true); -[[nodiscard]] const std::filesystem::path& GetSavePath(); +[[nodiscard]] std::string GetSaveDir(u32 slot_id); -// returns the size of the existed save memory -size_t CreateSaveMemory(size_t memory_size); +[[nodiscard]] std::filesystem::path GetSavePath(OrbisUserServiceUserId user_id, u32 slot_id, + std::string_view game_serial); -// Initialize the icon. Set buf to null to read the standard icon. -void SetIcon(void* buf, size_t buf_size); +// returns the size of the save memory if exists +size_t SetupSaveMemory(OrbisUserServiceUserId user_id, u32 slot_id, std::string_view game_serial); -// Update the icon -void WriteIcon(void* buf, size_t buf_size); +// Write the icon. Set buf to null to read the standard icon. +void SetIcon(u32 slot_id, void* buf = nullptr, size_t buf_size = 0); -[[nodiscard]] bool IsSaveMemoryInitialized(); +[[nodiscard]] bool IsSaveMemoryInitialized(u32 slot_id); -[[nodiscard]] PSF& GetParamSFO(); +[[nodiscard]] PSF& GetParamSFO(u32 slot_id); -[[nodiscard]] std::span GetIcon(); +[[nodiscard]] std::vector GetIcon(u32 slot_id); // Save now or wait for the background thread to save -void SaveSFO(bool sync = false); +void SaveSFO(u32 slot_id); -[[nodiscard]] bool IsSaving(); +void ReadMemory(u32 slot_id, void* buf, size_t buf_size, int64_t offset); -bool TriggerSaveWithoutEvent(); - -bool TriggerSave(); - -void ReadMemory(void* buf, size_t buf_size, int64_t offset); - -void WriteMemory(void* buf, size_t buf_size, int64_t offset); +void WriteMemory(u32 slot_id, void* buf, size_t buf_size, int64_t offset); } // namespace Libraries::SaveData::SaveMemory \ No newline at end of file diff --git a/src/core/libraries/save_data/savedata.cpp b/src/core/libraries/save_data/savedata.cpp index b573ded1e..e9ad77d69 100644 --- a/src/core/libraries/save_data/savedata.cpp +++ b/src/core/libraries/save_data/savedata.cpp @@ -177,7 +177,8 @@ struct OrbisSaveDataMemoryGet2 { OrbisSaveDataMemoryData* data; OrbisSaveDataParam* param; OrbisSaveDataIcon* icon; - std::array _reserved; + u32 slotId; + std::array _reserved; }; struct OrbisSaveDataMemorySet2 { @@ -186,6 +187,8 @@ struct OrbisSaveDataMemorySet2 { const OrbisSaveDataMemoryData* data; const OrbisSaveDataParam* param; const OrbisSaveDataIcon* icon; + u32 dataNum; + u32 slotId; std::array _reserved; }; @@ -198,7 +201,8 @@ struct OrbisSaveDataMemorySetup2 { const OrbisSaveDataParam* initParam; // +4.5 const OrbisSaveDataIcon* initIcon; - std::array _reserved; + u32 slotId; + std::array _reserved; }; struct OrbisSaveDataMemorySetupResult { @@ -206,9 +210,16 @@ struct OrbisSaveDataMemorySetupResult { std::array _reserved; }; +enum OrbisSaveDataMemorySyncOption : u32 { + NONE = 0, + BLOCKING = 1, +}; + struct OrbisSaveDataMemorySync { OrbisUserServiceUserId userId; - std::array _reserved; + u32 slotId; + OrbisSaveDataMemorySyncOption option; + std::array _reserved; }; struct OrbisSaveDataMount2 { @@ -327,6 +338,7 @@ static void initialize() { g_initialized = true; g_game_serial = ElfInfo::Instance().GameSerial(); g_fw_ver = ElfInfo::Instance().FirmwareVer(); + Backup::StartThread(); } // game_00other | game*other @@ -558,7 +570,6 @@ Error PS4_SYSV_ABI sceSaveDataBackup(const OrbisSaveDataBackup* backup) { } } - Backup::StartThread(); Backup::NewRequest(backup->userId, title, dir_name, OrbisSaveDataEventType::BACKUP); return Error::OK; @@ -1136,22 +1147,27 @@ Error PS4_SYSV_ABI sceSaveDataGetSaveDataMemory2(OrbisSaveDataMemoryGet2* getPar LOG_INFO(Lib_SaveData, "called with invalid parameter"); return Error::PARAMETER; } - if (!SaveMemory::IsSaveMemoryInitialized()) { + + u32 slot_id = 0; + if (g_fw_ver > ElfInfo::FW_50) { + slot_id = getParam->slotId; + } + if (!SaveMemory::IsSaveMemoryInitialized(slot_id)) { LOG_INFO(Lib_SaveData, "called without save memory initialized"); return Error::MEMORY_NOT_READY; } LOG_DEBUG(Lib_SaveData, "called"); auto data = getParam->data; if (data != nullptr) { - SaveMemory::ReadMemory(data->buf, data->bufSize, data->offset); + SaveMemory::ReadMemory(slot_id, data->buf, data->bufSize, data->offset); } auto param = getParam->param; if (param != nullptr) { - param->FromSFO(SaveMemory::GetParamSFO()); + param->FromSFO(SaveMemory::GetParamSFO(slot_id)); } auto icon = getParam->icon; if (icon != nullptr) { - auto icon_mem = SaveMemory::GetIcon(); + auto icon_mem = SaveMemory::GetIcon(slot_id); size_t total = std::min(icon->bufSize, icon_mem.size()); std::memcpy(icon->buf, icon_mem.data(), total); icon->dataSize = total; @@ -1494,36 +1510,37 @@ Error PS4_SYSV_ABI sceSaveDataSetSaveDataMemory2(const OrbisSaveDataMemorySet2* LOG_INFO(Lib_SaveData, "called with invalid parameter"); return Error::PARAMETER; } - if (!SaveMemory::IsSaveMemoryInitialized()) { + u32 slot_id = 0; + u32 data_num = 1; + if (g_fw_ver > ElfInfo::FW_50) { + slot_id = setParam->slotId; + if (setParam->dataNum > 1) { + data_num = setParam->dataNum; + } + } + if (!SaveMemory::IsSaveMemoryInitialized(slot_id)) { LOG_INFO(Lib_SaveData, "called without save memory initialized"); return Error::MEMORY_NOT_READY; } - if (SaveMemory::IsSaving()) { - int count = 0; - while (++count < 100 && SaveMemory::IsSaving()) { // try for more 10 seconds - std::this_thread::sleep_for(chrono::milliseconds(100)); - } - if (SaveMemory::IsSaving()) { - LOG_TRACE(Lib_SaveData, "called while saving"); - return Error::BUSY_FOR_SAVING; - } - } + LOG_DEBUG(Lib_SaveData, "called"); auto data = setParam->data; if (data != nullptr) { - SaveMemory::WriteMemory(data->buf, data->bufSize, data->offset); + for (int i = 0; i < data_num; i++) { + SaveMemory::WriteMemory(slot_id, data[i].buf, data[i].bufSize, data[i].offset); + } } auto param = setParam->param; if (param != nullptr) { - param->ToSFO(SaveMemory::GetParamSFO()); - SaveMemory::SaveSFO(); - } - auto icon = setParam->icon; - if (icon != nullptr) { - SaveMemory::WriteIcon(icon->buf, icon->bufSize); + param->ToSFO(SaveMemory::GetParamSFO(slot_id)); + SaveMemory::SaveSFO(slot_id); + } + + auto icon = setParam->icon; + if (icon != nullptr) { + SaveMemory::SetIcon(slot_id, icon->buf, icon->bufSize); } - SaveMemory::TriggerSaveWithoutEvent(); return Error::OK; } @@ -1563,9 +1580,12 @@ Error PS4_SYSV_ABI sceSaveDataSetupSaveDataMemory2(const OrbisSaveDataMemorySetu } LOG_DEBUG(Lib_SaveData, "called"); - SaveMemory::SetDirectories(setupParam->userId, g_game_serial); + u32 slot_id = 0; + if (g_fw_ver > ElfInfo::FW_50) { + slot_id = setupParam->slotId; + } - const auto& save_path = SaveMemory::GetSavePath(); + const auto& save_path = SaveMemory::GetSavePath(setupParam->userId, slot_id, g_game_serial); for (const auto& instance : g_mount_slots) { if (instance.has_value() && instance->GetSavePath() == save_path) { return Error::BUSY; @@ -1573,21 +1593,21 @@ Error PS4_SYSV_ABI sceSaveDataSetupSaveDataMemory2(const OrbisSaveDataMemorySetu } try { - size_t existed_size = SaveMemory::CreateSaveMemory(setupParam->memorySize); + size_t existed_size = + SaveMemory::SetupSaveMemory(setupParam->userId, slot_id, g_game_serial); if (existed_size == 0) { // Just created if (g_fw_ver >= ElfInfo::FW_45 && setupParam->initParam != nullptr) { - auto& sfo = SaveMemory::GetParamSFO(); + auto& sfo = SaveMemory::GetParamSFO(slot_id); setupParam->initParam->ToSFO(sfo); } - SaveMemory::SaveSFO(); + SaveMemory::SaveSFO(slot_id); auto init_icon = setupParam->initIcon; if (g_fw_ver >= ElfInfo::FW_45 && init_icon != nullptr) { - SaveMemory::SetIcon(init_icon->buf, init_icon->bufSize); + SaveMemory::SetIcon(slot_id, init_icon->buf, init_icon->bufSize); } else { - SaveMemory::SetIcon(nullptr, 0); + SaveMemory::SetIcon(slot_id); } - SaveMemory::TriggerSaveWithoutEvent(); } if (g_fw_ver >= ElfInfo::FW_45 && result != nullptr) { result->existedMemorySize = existed_size; @@ -1631,15 +1651,23 @@ Error PS4_SYSV_ABI sceSaveDataSyncSaveDataMemory(OrbisSaveDataMemorySync* syncPa LOG_INFO(Lib_SaveData, "called with invalid parameter"); return Error::PARAMETER; } - if (!SaveMemory::IsSaveMemoryInitialized()) { + + u32 slot_id = 0; + if (g_fw_ver > ElfInfo::FW_50) { + slot_id = syncParam->slotId; + } + + if (!SaveMemory::IsSaveMemoryInitialized(slot_id)) { LOG_INFO(Lib_SaveData, "called without save memory initialized"); return Error::MEMORY_NOT_READY; } LOG_DEBUG(Lib_SaveData, "called"); - bool ok = SaveMemory::TriggerSave(); - if (!ok) { - return Error::BUSY_FOR_SAVING; - } + + SaveMemory::PersistMemory(slot_id); + const auto& save_path = SaveMemory::GetSaveDir(slot_id); + Backup::NewRequest(syncParam->userId, g_game_serial, save_path, + OrbisSaveDataEventType::SAVE_DATA_MEMORY_SYNC); + return Error::OK; } diff --git a/src/emulator.cpp b/src/emulator.cpp index 97215c06f..d873b3462 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -33,6 +33,7 @@ #include "core/libraries/ngs2/ngs2.h" #include "core/libraries/np_trophy/np_trophy.h" #include "core/libraries/rtc/rtc.h" +#include "core/libraries/save_data/save_backup.h" #include "core/linker.h" #include "core/memory.h" #include "emulator.h" @@ -271,7 +272,7 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector Date: Thu, 30 Jan 2025 00:09:11 -0800 Subject: [PATCH 41/72] sdl_window: Allow alternate face button keys on any system. (#2275) * sdl_window: Allow alternate face button keys on any system. * readme: Fix typo --- README.md | 55 ++++++++++++++++++++++++---------------------- src/sdl_window.cpp | 27 ++++++++--------------- 2 files changed, 38 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index fd40d2d63..89aed29b4 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,9 @@ For more information on how to test, debug and report issues with the emulator o # Keyboard mapping +> [!NOTE] +> Some keyboards may also require you to hold the Fn key to use the F\* keys. Mac users should use the Command key instead of Control, and need to use Command+F11 for full screen to avoid conflicting with system key bindings. + | Button | Function | |-------------|-------------| F10 | FPS Counter @@ -86,32 +89,32 @@ F12 | Trigger RenderDoc Capture > [!NOTE] > Xbox and DualShock controllers work out of the box. -| Controller button | Keyboard equivelant | Mac alternative | -|-------------|-------------|--------------| -LEFT AXIS UP | W | | -LEFT AXIS DOWN | S | | -LEFT AXIS LEFT | A | | -LEFT AXIS RIGHT | D | | -RIGHT AXIS UP | I | | -RIGHT AXIS DOWN | K | | -RIGHT AXIS LEFT | J | | -RIGHT AXIS RIGHT | L | | -TRIANGLE | Numpad 8 | C | -CIRCLE | Numpad 6 | B | -CROSS | Numpad 2 | N | -SQUARE | Numpad 4 | V | -PAD UP | UP | | -PAD DOWN | DOWN | | -PAD LEFT | LEFT | | -PAD RIGHT | RIGHT | | -OPTIONS | RETURN | | -BACK BUTTON / TOUCH PAD | SPACE | | -L1 | Q | | -R1 | U | | -L2 | E | | -R2 | O | | -L3 | X | | -R3 | M | | +| Controller button | Keyboard equivalent | +|-------------|-------------| +LEFT AXIS UP | W | +LEFT AXIS DOWN | S | +LEFT AXIS LEFT | A | +LEFT AXIS RIGHT | D | +RIGHT AXIS UP | I | +RIGHT AXIS DOWN | K | +RIGHT AXIS LEFT | J | +RIGHT AXIS RIGHT | L | +TRIANGLE | Numpad 8 or C | +CIRCLE | Numpad 6 or B | +CROSS | Numpad 2 or N | +SQUARE | Numpad 4 or V | +PAD UP | UP | +PAD DOWN | DOWN | +PAD LEFT | LEFT | +PAD RIGHT | RIGHT | +OPTIONS | RETURN | +BACK BUTTON / TOUCH PAD | SPACE | +L1 | Q | +R1 | U | +L2 | E | +R2 | O | +L3 | X | +R3 | M | # Main team diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index d1fe6bbab..9b7617925 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -382,20 +382,6 @@ void WindowSDL::OnResize() { } void WindowSDL::OnKeyPress(const SDL_Event* event) { -#ifdef __APPLE__ - // Use keys that are more friendly for keyboards without a keypad. - // Once there are key binding options this won't be necessary. - constexpr SDL_Keycode CrossKey = SDLK_N; - constexpr SDL_Keycode CircleKey = SDLK_B; - constexpr SDL_Keycode SquareKey = SDLK_V; - constexpr SDL_Keycode TriangleKey = SDLK_C; -#else - constexpr SDL_Keycode CrossKey = SDLK_KP_2; - constexpr SDL_Keycode CircleKey = SDLK_KP_6; - constexpr SDL_Keycode SquareKey = SDLK_KP_4; - constexpr SDL_Keycode TriangleKey = SDLK_KP_8; -#endif - auto button = OrbisPadButtonDataOffset::None; Input::Axis axis = Input::Axis::AxisMax; int axisvalue = 0; @@ -414,16 +400,21 @@ void WindowSDL::OnKeyPress(const SDL_Event* event) { case SDLK_RIGHT: button = OrbisPadButtonDataOffset::Right; break; - case TriangleKey: + // Provide alternatives for face buttons for users without a numpad. + case SDLK_KP_8: + case SDLK_C: button = OrbisPadButtonDataOffset::Triangle; break; - case CircleKey: + case SDLK_KP_6: + case SDLK_B: button = OrbisPadButtonDataOffset::Circle; break; - case CrossKey: + case SDLK_KP_2: + case SDLK_N: button = OrbisPadButtonDataOffset::Cross; break; - case SquareKey: + case SDLK_KP_4: + case SDLK_V: button = OrbisPadButtonDataOffset::Square; break; case SDLK_RETURN: From d8b411429638b48db375c03682fd1bcc3efdfd11 Mon Sep 17 00:00:00 2001 From: Bhaal42 Date: Thu, 30 Jan 2025 09:25:29 +0100 Subject: [PATCH 42/72] Patch 1 (#2278) * Update fr.ts Corrected some typos * Update fr.ts forgot plural --- src/qt_gui/translations/fr.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qt_gui/translations/fr.ts b/src/qt_gui/translations/fr.ts index 0f87b087b..250b8f3c3 100644 --- a/src/qt_gui/translations/fr.ts +++ b/src/qt_gui/translations/fr.ts @@ -373,7 +373,7 @@ toolBar - Bare d'outils + Barre d'outils Game List @@ -489,7 +489,7 @@ Game successfully installed at %1 - Jeu installé avec succès à %1 + Jeu installé avec succès dans %1 File doesn't appear to be a valid PKG file @@ -554,7 +554,7 @@ Show Game Size In List - Afficher la taille du jeu dans la liste + Afficher la taille des jeux dans la liste Show Splash @@ -945,7 +945,7 @@ Serial: - Série: + Numéro de série: Version: @@ -1164,7 +1164,7 @@ Serial - Série + Numéro de série Compatibility @@ -1361,4 +1361,4 @@ TB - \ No newline at end of file + From 132a9d7d357727ab7e16e974647890434dfcd0d6 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Thu, 30 Jan 2025 01:38:34 -0800 Subject: [PATCH 43/72] externals: Update MoltenVK (#2280) Small fix for pipeline serialization from last change. --- externals/MoltenVK/MoltenVK | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/MoltenVK/MoltenVK b/externals/MoltenVK/MoltenVK index aba997657..0c090001c 160000 --- a/externals/MoltenVK/MoltenVK +++ b/externals/MoltenVK/MoltenVK @@ -1 +1 @@ -Subproject commit aba997657b94d6de1794ebad36ce5634341252c7 +Subproject commit 0c090001cb42997031cfe43914340e2639944972 From 3a163002d712ba9a22e2d0fac09302de6f324c61 Mon Sep 17 00:00:00 2001 From: Missake212 Date: Thu, 30 Jan 2025 13:06:55 +0100 Subject: [PATCH 44/72] Update README.md (#2281) Lot of people seem to think that building is required to use shad, adding a little note in the README to redirect them to tabs where they can simply download it. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 89aed29b4..30efeb263 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,9 @@ This project began as a fun project. Given our limited free time, it may take so # Building +> [!IMPORTANT] +> If you want to use shadPS4 to play your games, you don't have to follow the build instructions, you can simply download the emulator from either the [**release tab**](https://github.com/shadps4-emu/shadPS4/releases) or the [**action tab**](https://github.com/shadps4-emu/shadPS4/actions). + ## Windows Check the build instructions for [**Windows**](https://github.com/shadps4-emu/shadPS4/blob/main/documents/building-windows.md). From 19bbbf994c541e009fc88ab5366c8e21f27d8a49 Mon Sep 17 00:00:00 2001 From: Zaid Ismail <64991232+zaid-ismail031@users.noreply.github.com> Date: Thu, 30 Jan 2025 14:09:50 +0200 Subject: [PATCH 45/72] Fix game title sorting bug from Issue #2260 (#2284) * Fix alphabetical sorting bug caused by case-sensitive string comparisons in GameListFrame. * Fix bug with incorrect use of std::tolower. * Fix clang-format error. --------- Co-authored-by: Zaid Ismail --- src/qt_gui/game_list_frame.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/qt_gui/game_list_frame.h b/src/qt_gui/game_list_frame.h index 8c6fcb1e2..90d021093 100644 --- a/src/qt_gui/game_list_frame.h +++ b/src/qt_gui/game_list_frame.h @@ -3,6 +3,9 @@ #pragma once +#include // std::transform +#include // std::tolower + #include #include #include @@ -65,8 +68,12 @@ public: static bool CompareStringsAscending(GameInfo a, GameInfo b, int columnIndex) { switch (columnIndex) { - case 1: - return a.name < b.name; + case 1: { + std::string name_a = a.name, name_b = b.name; + std::transform(name_a.begin(), name_a.end(), name_a.begin(), ::tolower); + std::transform(name_b.begin(), name_b.end(), name_b.begin(), ::tolower); + return name_a < name_b; + } case 2: return a.compatibility.status < b.compatibility.status; case 3: @@ -90,8 +97,12 @@ public: static bool CompareStringsDescending(GameInfo a, GameInfo b, int columnIndex) { switch (columnIndex) { - case 1: - return a.name > b.name; + case 1: { + std::string name_a = a.name, name_b = b.name; + std::transform(name_a.begin(), name_a.end(), name_a.begin(), ::tolower); + std::transform(name_b.begin(), name_b.end(), name_b.begin(), ::tolower); + return name_a > name_b; + } case 2: return a.compatibility.status > b.compatibility.status; case 3: From c89c7e8fed8b296204a0175e0414b4c867a84a1c Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Thu, 30 Jan 2025 09:17:03 -0800 Subject: [PATCH 46/72] cpu_patches: Always use AVX for certain patches. (#2274) --- src/core/cpu_patches.cpp | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/src/core/cpu_patches.cpp b/src/core/cpu_patches.cpp index b812e5444..57d528a81 100644 --- a/src/core/cpu_patches.cpp +++ b/src/core/cpu_patches.cpp @@ -30,16 +30,6 @@ using namespace Xbyak::util; -#define MAYBE_AVX(OPCODE, ...) \ - [&] { \ - Cpu cpu; \ - if (cpu.has(Cpu::tAVX)) { \ - c.v##OPCODE(__VA_ARGS__); \ - } else { \ - c.OPCODE(__VA_ARGS__); \ - } \ - }() - namespace Core { static Xbyak::Reg ZydisToXbyakRegister(const ZydisRegister reg) { @@ -643,7 +633,7 @@ static void GenerateEXTRQ(const ZydisDecodedOperand* operands, Xbyak::CodeGenera ASSERT_MSG(length + index <= 64, "length + index must be less than or equal to 64."); // Get lower qword from xmm register - MAYBE_AVX(movq, scratch1, xmm_dst); + c.vmovq(scratch1, xmm_dst); if (index != 0) { c.shr(scratch1, index); @@ -656,7 +646,7 @@ static void GenerateEXTRQ(const ZydisDecodedOperand* operands, Xbyak::CodeGenera // Writeback to xmm register, extrq instruction says top 64-bits are undefined so we don't // care to preserve them - MAYBE_AVX(movq, xmm_dst, scratch1); + c.vmovq(xmm_dst, scratch1); c.pop(scratch2); c.pop(scratch1); @@ -690,7 +680,7 @@ static void GenerateEXTRQ(const ZydisDecodedOperand* operands, Xbyak::CodeGenera c.push(mask); // Construct the mask out of the length that resides in bottom 6 bits of source xmm - MAYBE_AVX(movq, scratch1, xmm_src); + c.vmovq(scratch1, xmm_src); c.mov(scratch2, scratch1); c.and_(scratch2, 0x3F); c.jz(length_zero); @@ -711,10 +701,10 @@ static void GenerateEXTRQ(const ZydisDecodedOperand* operands, Xbyak::CodeGenera c.and_(scratch1, 0x3F); c.mov(scratch2, scratch1); // cl now contains the shift amount - MAYBE_AVX(movq, scratch1, xmm_dst); + c.vmovq(scratch1, xmm_dst); c.shr(scratch1, cl); c.and_(scratch1, mask); - MAYBE_AVX(movq, xmm_dst, scratch1); + c.vmovq(xmm_dst, scratch1); c.pop(mask); c.pop(scratch2); @@ -765,8 +755,8 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene ASSERT_MSG(length + index <= 64, "length + index must be less than or equal to 64."); - MAYBE_AVX(movq, scratch1, xmm_src); - MAYBE_AVX(movq, scratch2, xmm_dst); + c.vmovq(scratch1, xmm_src); + c.vmovq(scratch2, xmm_dst); c.mov(mask, mask_value); // src &= mask @@ -784,12 +774,7 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene c.or_(scratch2, scratch1); // Insert scratch2 into low 64 bits of dst, upper 64 bits are unaffected - Cpu cpu; - if (cpu.has(Cpu::tAVX)) { - c.vpinsrq(xmm_dst, xmm_dst, scratch2, 0); - } else { - c.pinsrq(xmm_dst, scratch2, 0); - } + c.vpinsrq(xmm_dst, xmm_dst, scratch2, 0); c.pop(mask); c.pop(scratch2); @@ -816,7 +801,7 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene c.push(mask); // Get upper 64 bits of src and copy it to mask and index - MAYBE_AVX(pextrq, index, xmm_src, 1); + c.vpextrq(index, xmm_src, 1); c.mov(mask, index); // When length is 0, set it to 64 @@ -839,7 +824,7 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene c.and_(index, 0x3F); // src &= mask - MAYBE_AVX(movq, scratch1, xmm_src); + c.vmovq(scratch1, xmm_src); c.and_(scratch1, mask); // mask = ~(mask << index) @@ -851,12 +836,12 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene c.shl(scratch1, cl); // dst = (dst & mask) | src - MAYBE_AVX(movq, scratch2, xmm_dst); + c.vmovq(scratch2, xmm_dst); c.and_(scratch2, mask); c.or_(scratch2, scratch1); // Upper 64 bits are undefined in insertq - MAYBE_AVX(movq, xmm_dst, scratch2); + c.vmovq(xmm_dst, scratch2); c.pop(mask); c.pop(index); From e805b9752097a5292a8c41ca7a5a6c27934a1b94 Mon Sep 17 00:00:00 2001 From: tomboylover93 <95257311+tomboylover93@users.noreply.github.com> Date: Thu, 30 Jan 2025 14:34:31 -0300 Subject: [PATCH 47/72] Add Vulkan debug options to the Debug tab (#2254) Co-authored-by: DanielSvoboda --- documents/building-linux.md | 2 +- src/common/config.cpp | 24 +- src/common/config.h | 9 +- src/emulator.cpp | 6 +- src/imgui/renderer/imgui_core.cpp | 4 +- src/imgui/renderer/texture_manager.cpp | 2 +- src/qt_gui/settings_dialog.cpp | 31 +- src/qt_gui/settings_dialog.ui | 286 ++++++++++++------ src/qt_gui/translations/ar.ts | 44 +++ src/qt_gui/translations/da_DK.ts | 44 +++ src/qt_gui/translations/de.ts | 44 +++ src/qt_gui/translations/el.ts | 44 +++ src/qt_gui/translations/en.ts | 47 ++- src/qt_gui/translations/es_ES.ts | 44 +++ src/qt_gui/translations/fa_IR.ts | 44 +++ src/qt_gui/translations/fi.ts | 44 +++ src/qt_gui/translations/fr.ts | 44 +++ src/qt_gui/translations/hu_HU.ts | 44 +++ src/qt_gui/translations/id.ts | 44 +++ src/qt_gui/translations/it.ts | 44 +++ src/qt_gui/translations/ja_JP.ts | 44 +++ src/qt_gui/translations/ko_KR.ts | 44 +++ src/qt_gui/translations/lt_LT.ts | 44 +++ src/qt_gui/translations/nb.ts | 44 +++ src/qt_gui/translations/nl.ts | 44 +++ src/qt_gui/translations/pl_PL.ts | 44 +++ src/qt_gui/translations/pt_BR.ts | 82 +++-- src/qt_gui/translations/ro_RO.ts | 44 +++ src/qt_gui/translations/ru_RU.ts | 44 +++ src/qt_gui/translations/sq.ts | 44 +++ src/qt_gui/translations/sv.ts | 44 +++ src/qt_gui/translations/tr_TR.ts | 44 +++ src/qt_gui/translations/uk_UA.ts | 44 +++ src/qt_gui/translations/vi_VN.ts | 44 +++ src/qt_gui/translations/zh_CN.ts | 44 +++ src/qt_gui/translations/zh_TW.ts | 44 +++ src/video_core/renderer_vulkan/vk_platform.h | 4 +- .../renderer_vulkan/vk_presenter.cpp | 14 +- .../renderer_vulkan/vk_rasterizer.cpp | 16 +- 39 files changed, 1518 insertions(+), 153 deletions(-) diff --git a/documents/building-linux.md b/documents/building-linux.md index 4aa66aac6..d9ae2e54c 100644 --- a/documents/building-linux.md +++ b/documents/building-linux.md @@ -29,7 +29,7 @@ sudo dnf install clang git cmake libatomic alsa-lib-devel pipewire-jack-audio-co sudo pacman -S base-devel clang git cmake sndio jack2 openal qt6-base qt6-declarative qt6-multimedia sdl2 vulkan-validation-layers ``` -**Note** : The `shadps4-git` AUR package is not maintained by any of the developers, and it uses the default compiler, which is often set to GCC. Use at your own discretion. +**Note**: The `shadps4-git` AUR package is not maintained by any of the developers, and it uses the default compiler, which is often set to GCC. Use at your own discretion. #### OpenSUSE diff --git a/src/common/config.cpp b/src/common/config.cpp index a57b6d35c..70b062951 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -267,18 +267,28 @@ bool vkValidationGpuEnabled() { return vkValidationGpu; } -bool vkCrashDiagnosticEnabled() { +bool getVkCrashDiagnosticEnabled() { return vkCrashDiagnostic; } -bool vkHostMarkersEnabled() { - // Forced on when crash diagnostic enabled. - return vkHostMarkers || vkCrashDiagnostic; +bool getVkHostMarkersEnabled() { + return vkHostMarkers; } -bool vkGuestMarkersEnabled() { - // Forced on when crash diagnostic enabled. - return vkGuestMarkers || vkCrashDiagnostic; +bool getVkGuestMarkersEnabled() { + return vkGuestMarkers; +} + +void setVkCrashDiagnosticEnabled(bool enable) { + vkCrashDiagnostic = enable; +} + +void setVkHostMarkersEnabled(bool enable) { + vkHostMarkers = enable; +} + +void setVkGuestMarkersEnabled(bool enable) { + vkGuestMarkers = enable; } bool getSeparateUpdateEnabled() { diff --git a/src/common/config.h b/src/common/config.h index 15937606e..356cf77fc 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -106,9 +106,12 @@ void setRdocEnabled(bool enable); bool vkValidationEnabled(); bool vkValidationSyncEnabled(); bool vkValidationGpuEnabled(); -bool vkCrashDiagnosticEnabled(); -bool vkHostMarkersEnabled(); -bool vkGuestMarkersEnabled(); +bool getVkCrashDiagnosticEnabled(); +bool getVkHostMarkersEnabled(); +bool getVkGuestMarkersEnabled(); +void setVkCrashDiagnosticEnabled(bool enable); +void setVkHostMarkersEnabled(bool enable); +void setVkGuestMarkersEnabled(bool enable); // Gui void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h); diff --git a/src/emulator.cpp b/src/emulator.cpp index d873b3462..81c4d814d 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -67,9 +67,9 @@ Emulator::Emulator() { LOG_INFO(Config, "Vulkan vkValidation: {}", Config::vkValidationEnabled()); LOG_INFO(Config, "Vulkan vkValidationSync: {}", Config::vkValidationSyncEnabled()); LOG_INFO(Config, "Vulkan vkValidationGpu: {}", Config::vkValidationGpuEnabled()); - LOG_INFO(Config, "Vulkan crashDiagnostics: {}", Config::vkCrashDiagnosticEnabled()); - LOG_INFO(Config, "Vulkan hostMarkers: {}", Config::vkHostMarkersEnabled()); - LOG_INFO(Config, "Vulkan guestMarkers: {}", Config::vkGuestMarkersEnabled()); + LOG_INFO(Config, "Vulkan crashDiagnostics: {}", Config::getVkCrashDiagnosticEnabled()); + LOG_INFO(Config, "Vulkan hostMarkers: {}", Config::getVkHostMarkersEnabled()); + LOG_INFO(Config, "Vulkan guestMarkers: {}", Config::getVkGuestMarkersEnabled()); LOG_INFO(Config, "Vulkan rdocEnable: {}", Config::isRdocEnabled()); // Create stdin/stdout/stderr diff --git a/src/imgui/renderer/imgui_core.cpp b/src/imgui/renderer/imgui_core.cpp index 26253822c..d9530dd70 100644 --- a/src/imgui/renderer/imgui_core.cpp +++ b/src/imgui/renderer/imgui_core.cpp @@ -208,7 +208,7 @@ void Render(const vk::CommandBuffer& cmdbuf, const vk::ImageView& image_view, return; } - if (Config::vkHostMarkersEnabled()) { + if (Config::getVkHostMarkersEnabled()) { cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{ .pLabelName = "ImGui Render", }); @@ -233,7 +233,7 @@ void Render(const vk::CommandBuffer& cmdbuf, const vk::ImageView& image_view, cmdbuf.beginRendering(render_info); Vulkan::RenderDrawData(*draw_data, cmdbuf); cmdbuf.endRendering(); - if (Config::vkHostMarkersEnabled()) { + if (Config::getVkHostMarkersEnabled()) { cmdbuf.endDebugUtilsLabelEXT(); } } diff --git a/src/imgui/renderer/texture_manager.cpp b/src/imgui/renderer/texture_manager.cpp index d7516a3a5..e217cd130 100644 --- a/src/imgui/renderer/texture_manager.cpp +++ b/src/imgui/renderer/texture_manager.cpp @@ -152,7 +152,7 @@ void WorkerLoop() { g_job_list.pop_front(); g_job_list_mtx.unlock(); - if (Config::vkCrashDiagnosticEnabled()) { + if (Config::getVkCrashDiagnosticEnabled()) { // FIXME: Crash diagnostic hangs when building the command buffer here continue; } diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index b41fde745..802325126 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -285,6 +285,11 @@ SettingsDialog::SettingsDialog(std::span physical_devices, ui->vkValidationCheckBox->installEventFilter(this); ui->vkSyncValidationCheckBox->installEventFilter(this); ui->rdocCheckBox->installEventFilter(this); + ui->crashDiagnosticsCheckBox->installEventFilter(this); + ui->guestMarkersCheckBox->installEventFilter(this); + ui->hostMarkersCheckBox->installEventFilter(this); + ui->collectShaderCheckBox->installEventFilter(this); + ui->copyGPUBuffersCheckBox->installEventFilter(this); } } @@ -360,6 +365,15 @@ void SettingsDialog::LoadValuesFromConfig() { ui->vkSyncValidationCheckBox->setChecked( toml::find_or(data, "Vulkan", "validation_sync", false)); ui->rdocCheckBox->setChecked(toml::find_or(data, "Vulkan", "rdocEnable", false)); + ui->crashDiagnosticsCheckBox->setChecked( + toml::find_or(data, "Vulkan", "crashDiagnostic", false)); + ui->guestMarkersCheckBox->setChecked( + toml::find_or(data, "Vulkan", "guestMarkers", false)); + ui->hostMarkersCheckBox->setChecked(toml::find_or(data, "Vulkan", "hostMarkers", false)); + ui->copyGPUBuffersCheckBox->setChecked( + toml::find_or(data, "GPU", "copyGPUBuffers", false)); + ui->collectShaderCheckBox->setChecked( + toml::find_or(data, "Debug", "CollectShader", false)); ui->enableCompatibilityCheckBox->setChecked( toml::find_or(data, "General", "compatibilityEnabled", false)); ui->checkCompatibilityOnStartupCheckBox->setChecked( @@ -380,7 +394,7 @@ void SettingsDialog::LoadValuesFromConfig() { std::string chooseHomeTab = toml::find_or(data, "General", "chooseHomeTab", ""); ui->chooseHomeTabComboBox->setCurrentText(QString::fromStdString(chooseHomeTab)); - QStringList tabNames = {tr("General"), tr("Gui"), tr("Graphics"), tr("User"), + QStringList tabNames = {tr("General"), tr("GUI"), tr("Graphics"), tr("User"), tr("Input"), tr("Paths"), tr("Debug")}; QString chooseHomeTabQString = QString::fromStdString(chooseHomeTab); int indexTab = tabNames.indexOf(chooseHomeTabQString); @@ -551,6 +565,16 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) { text = tr("vkSyncValidationCheckBox"); } else if (elementName == "rdocCheckBox") { text = tr("rdocCheckBox"); + } else if (elementName == "crashDiagnosticsCheckBox") { + text = tr("crashDiagnosticsCheckBox"); + } else if (elementName == "guestMarkersCheckBox") { + text = tr("guestMarkersCheckBox"); + } else if (elementName == "hostMarkersCheckBox") { + text = tr("hostMarkersCheckBox"); + } else if (elementName == "copyGPUBuffersCheckBox") { + text = tr("copyGPUBuffersCheckBox"); + } else if (elementName == "collectShaderCheckBox") { + text = tr("collectShaderCheckBox"); } ui->descriptionText->setText(text.replace("\\n", "\n")); @@ -604,6 +628,11 @@ void SettingsDialog::UpdateSettings() { Config::setVkValidation(ui->vkValidationCheckBox->isChecked()); Config::setVkSyncValidation(ui->vkSyncValidationCheckBox->isChecked()); Config::setRdocEnabled(ui->rdocCheckBox->isChecked()); + Config::setVkHostMarkersEnabled(ui->hostMarkersCheckBox->isChecked()); + Config::setVkGuestMarkersEnabled(ui->guestMarkersCheckBox->isChecked()); + Config::setVkCrashDiagnosticEnabled(ui->crashDiagnosticsCheckBox->isChecked()); + Config::setCollectShaderForDebug(ui->collectShaderCheckBox->isChecked()); + Config::setCopyGPUCmdBuffers(ui->copyGPUBuffersCheckBox->isChecked()); Config::setAutoUpdate(ui->updateCheckBox->isChecked()); Config::setUpdateChannel(ui->updateComboBox->currentText().toStdString()); Config::setChooseHomeTab(ui->chooseHomeTabComboBox->currentText().toStdString()); diff --git a/src/qt_gui/settings_dialog.ui b/src/qt_gui/settings_dialog.ui index 5da6a8198..4e7440af5 100644 --- a/src/qt_gui/settings_dialog.ui +++ b/src/qt_gui/settings_dialog.ui @@ -12,7 +12,7 @@ 0 0 970 - 600 + 750 @@ -74,7 +74,7 @@ 0 0 946 - 386 + 536 @@ -476,7 +476,7 @@ true - Gui + GUI @@ -484,7 +484,7 @@ 0 0 946 - 386 + 536 @@ -497,14 +497,14 @@ 0 - + 0 - + 0 0 @@ -530,7 +530,7 @@ Default tab when opening settings - + @@ -546,7 +546,7 @@ - Gui + GUI @@ -594,6 +594,18 @@ 0 + + + 0 + 100 + + + + + 16777215 + 16777215 + + 11 @@ -605,62 +617,16 @@ false - + Title Music false - - - - 10 - 80 - 416 - 29 - - - - - 0 - 0 - - - - Set the volume of the background music. - - - 100 - - - 10 - - - 20 - - - 50 - - - Qt::Orientation::Horizontal - - - false - - - false - - - QSlider::TickPosition::NoTicks - - - 10 - - - 10 - 22 + 9 + 30 416 26 @@ -675,45 +641,119 @@ Play title music - + - 10 - 54 - 416 - 20 + 0 + 50 + 431 + 47 - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Volume - + + + 9 + + + 9 + + + 9 + + + 9 + + + 9 + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Volume + + + + + + + + 0 + 0 + + + + Set the volume of the background music. + + + 100 + + + 10 + + + 20 + + + 50 + + + Qt::Orientation::Horizontal + + + false + + + false + + + QSlider::TickPosition::NoTicks + + + 10 + + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + - + 6 - 210 + 0 @@ -790,6 +830,19 @@ + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + @@ -810,7 +863,7 @@ 0 0 946 - 386 + 536 @@ -1054,10 +1107,10 @@ 0 0 946 - 386 + 536 - + @@ -1198,7 +1251,7 @@ 0 0 946 - 386 + 536 @@ -1482,7 +1535,7 @@ 0 0 946 - 386 + 536 @@ -1572,10 +1625,10 @@ 0 0 946 - 386 + 536 - + @@ -1585,7 +1638,7 @@ 0 - + @@ -1728,20 +1781,57 @@ - - - Qt::Orientation::Vertical + + + + 0 + 0 + - - QSizePolicy::Policy::MinimumExpanding + + Advanced - - - 0 - 0 - + + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop - + + + + + Enable Crash Diagnostics + + + + + + + Collect Shaders + + + + + + + Copy GPU Buffers + + + + + + + Host Debug Markers + + + + + + + Guest Debug Markers + + + + + diff --git a/src/qt_gui/translations/ar.ts b/src/qt_gui/translations/ar.ts index f7b93028a..617753ab8 100644 --- a/src/qt_gui/translations/ar.ts +++ b/src/qt_gui/translations/ar.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging RenderDoc تمكين تصحيح أخطاء + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update تحديث @@ -720,6 +740,10 @@ GUI Settings إعدادات الواجهة + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox تمكين تصحيح RenderDoc:\nإذا تم التمكين، سيوفر المحاكي توافقًا مع Renderdoc لالتقاط وتحليل الإطار الذي يتم عرضه حاليًا. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/da_DK.ts b/src/qt_gui/translations/da_DK.ts index 61d2f68bf..abde6ff72 100644 --- a/src/qt_gui/translations/da_DK.ts +++ b/src/qt_gui/translations/da_DK.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Enable RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Opdatering @@ -720,6 +740,10 @@ GUI Settings GUI-Indstillinger + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox Aktiver RenderDoc-fejlfinding:\nHvis aktiveret, giver det emulatoren mulighed for kompatibilitet med Renderdoc til at fange og analysere det aktuelle gengivne billede. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/de.ts b/src/qt_gui/translations/de.ts index 9d99a7048..b8fa22881 100644 --- a/src/qt_gui/translations/de.ts +++ b/src/qt_gui/translations/de.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging RenderDoc-Debugging aktivieren + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Aktualisieren @@ -720,6 +740,10 @@ GUI Settings GUI-Einstellungen + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox RenderDoc-Debugging aktivieren:\nWenn aktiviert, bietet der Emulator Kompatibilität mit Renderdoc zur Erfassung und Analyse des aktuell gerenderten Frames. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/el.ts b/src/qt_gui/translations/el.ts index 66c3c07cd..828b99248 100644 --- a/src/qt_gui/translations/el.ts +++ b/src/qt_gui/translations/el.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Enable RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Ενημέρωση @@ -720,6 +740,10 @@ GUI Settings Ρυθμίσεις GUI + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox Ενεργοποίηση Καταγραφής RenderDoc:\nΌταν είναι ενεργοποιημένο, ο εξομοιωτής είναι συμβατός με το RenderDoc για τη λήψη και ανάλυση του τρέχοντος καρέ. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/en.ts b/src/qt_gui/translations/en.ts index 8b6c3c69f..7ad2f15c0 100644 --- a/src/qt_gui/translations/en.ts +++ b/src/qt_gui/translations/en.ts @@ -700,6 +700,27 @@ Enable RenderDoc Debugging Enable RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + + Update Update @@ -720,6 +741,10 @@ GUI Settings GUI Settings + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +953,26 @@ rdocCheckBox Enable RenderDoc Debugging:\nIf enabled, the emulator will provide compatibility with Renderdoc to allow capture and analysis of the currently rendered frame. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + saveDataBox Save Data Path:\nThe folder where game save data will be saved. @@ -1369,4 +1414,4 @@ TB - \ No newline at end of file + diff --git a/src/qt_gui/translations/es_ES.ts b/src/qt_gui/translations/es_ES.ts index 8f7a09b5d..8af34c042 100644 --- a/src/qt_gui/translations/es_ES.ts +++ b/src/qt_gui/translations/es_ES.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Habilitar depuración de RenderDoc + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Actualización @@ -720,6 +740,10 @@ GUI Settings Configuraciones de la Interfaz + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox Habilitar Depuración de RenderDoc:\nSi se habilita, el emulador proporcionará compatibilidad con Renderdoc para permitir la captura y análisis del fotograma actualmente renderizado. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/fa_IR.ts b/src/qt_gui/translations/fa_IR.ts index 043d782c2..16f6533b6 100644 --- a/src/qt_gui/translations/fa_IR.ts +++ b/src/qt_gui/translations/fa_IR.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update به‌روزرسانی @@ -720,6 +740,10 @@ GUI Settings تنظیمات رابط کاربری + + Title Music + Title Music + Disable Trophy Pop-ups غیرفعال کردن نمایش جوایز @@ -928,6 +952,26 @@ rdocCheckBox Enable RenderDoc Debugging:\nIf enabled, the emulator will provide compatibility with Renderdoc to allow capture and analysis of the currently rendered frame. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/fi.ts b/src/qt_gui/translations/fi.ts index 86f6a6d3c..7269b4125 100644 --- a/src/qt_gui/translations/fi.ts +++ b/src/qt_gui/translations/fi.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Ota Käyttöön RenderDoc Virheenkorjaus + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Päivitys @@ -720,6 +740,10 @@ GUI Settings GUI-asetukset + + Title Music + Title Music + Disable Trophy Pop-ups Poista Trophy Pop-upit Käytöstä @@ -928,6 +952,26 @@ rdocCheckBox Ota Käyttöön RenderDoc Virheenkorjaus:\nJos käytössä, emulaattori tarjoaa Renderdoc-yhteensopivuuden, mikä mahdollistaa renderöidyn kehyksen tallennuksen ja analysoinnin. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/fr.ts b/src/qt_gui/translations/fr.ts index 250b8f3c3..b93af15a6 100644 --- a/src/qt_gui/translations/fr.ts +++ b/src/qt_gui/translations/fr.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Activer le débogage RenderDoc + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Mise à jour @@ -720,6 +740,10 @@ GUI Settings Paramètres de l'interface + + Title Music + Title Music + Disable Trophy Pop-ups Désactiver les notifications de trophées @@ -928,6 +952,26 @@ rdocCheckBox Activer le débogage RenderDoc:\nS'il est activé, l'émulateur fournit une compatibilité avec Renderdoc, permettant d'enregistrer et d'analyser la trame rendue actuelle. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/hu_HU.ts b/src/qt_gui/translations/hu_HU.ts index fe71e8120..98491aa87 100644 --- a/src/qt_gui/translations/hu_HU.ts +++ b/src/qt_gui/translations/hu_HU.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging RenderDoc Debugolás Engedélyezése + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Frissítés @@ -720,6 +740,10 @@ GUI Settings GUI Beállítások + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox RenderDoc hibakeresés engedélyezése:\nHa engedélyezve van, az emulátor kompatibilitást biztosít a Renderdoc számára, hogy lehetővé tegye a jelenleg renderelt keret rögzítését és elemzését. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/id.ts b/src/qt_gui/translations/id.ts index acfde43a7..931244209 100644 --- a/src/qt_gui/translations/id.ts +++ b/src/qt_gui/translations/id.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Enable RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Pembaruan @@ -720,6 +740,10 @@ GUI Settings Pengaturan GUI + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox Aktifkan Debugging RenderDoc:\nJika diaktifkan, emulator akan menyediakan kompatibilitas dengan Renderdoc untuk memungkinkan pengambilan dan analisis bingkai yang sedang dirender. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/it.ts b/src/qt_gui/translations/it.ts index 93c6233a6..384272137 100644 --- a/src/qt_gui/translations/it.ts +++ b/src/qt_gui/translations/it.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Abilita RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Aggiornamento @@ -720,6 +740,10 @@ GUI Settings Impostazioni GUI + + Title Music + Title Music + Disable Trophy Pop-ups Disabilita Notifica Trofei @@ -928,6 +952,26 @@ rdocCheckBox Abilita Debugging RenderDoc:\nSe abilitato, l'emulatore fornirà compatibilità con Renderdoc per consentire la cattura e l'analisi del frame attualmente reso. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/ja_JP.ts b/src/qt_gui/translations/ja_JP.ts index 921af52bb..2aae35987 100644 --- a/src/qt_gui/translations/ja_JP.ts +++ b/src/qt_gui/translations/ja_JP.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging RenderDocデバッグを有効にする + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update 更新 @@ -720,6 +740,10 @@ GUI Settings GUI設定 + + Title Music + Title Music + Disable Trophy Pop-ups トロフィーのポップアップを無効化 @@ -928,6 +952,26 @@ rdocCheckBox RenderDocデバッグを有効にする:\n有効にすると、エミュレーターはRenderdocとの互換性を提供し、現在レンダリング中のフレームのキャプチャと分析を可能にします。 + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/ko_KR.ts b/src/qt_gui/translations/ko_KR.ts index 2491959a6..56e891214 100644 --- a/src/qt_gui/translations/ko_KR.ts +++ b/src/qt_gui/translations/ko_KR.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Enable RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Update @@ -720,6 +740,10 @@ GUI Settings GUI Settings + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox Enable RenderDoc Debugging:\nIf enabled, the emulator will provide compatibility with Renderdoc to allow capture and analysis of the currently rendered frame. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/lt_LT.ts b/src/qt_gui/translations/lt_LT.ts index 23a52e948..c73a43917 100644 --- a/src/qt_gui/translations/lt_LT.ts +++ b/src/qt_gui/translations/lt_LT.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Enable RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Atnaujinimas @@ -720,6 +740,10 @@ GUI Settings GUI Nustatymai + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox Įjungti RenderDoc derinimą:\nJei įjungta, emuliatorius suteiks suderinamumą su Renderdoc, kad būtų galima užfiksuoti ir analizuoti šiuo metu renderuojamą kadrą. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/nb.ts b/src/qt_gui/translations/nb.ts index 0b7d2699a..3e6f5fedd 100644 --- a/src/qt_gui/translations/nb.ts +++ b/src/qt_gui/translations/nb.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Aktiver RenderDoc feilretting + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Oppdatering @@ -720,6 +740,10 @@ GUI Settings Grensesnitt-innstillinger + + Title Music + Title Music + Disable Trophy Pop-ups Deaktiver trofé hurtigmeny @@ -928,6 +952,26 @@ rdocCheckBox Aktiver RenderDoc feilsøking:\nHvis aktivert, vil etterligneren gi kompatibilitet med Renderdoc for å tillate opptak og analyse av det nåværende gjengitte bildet. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/nl.ts b/src/qt_gui/translations/nl.ts index 1dabda8b4..95ac19ef3 100644 --- a/src/qt_gui/translations/nl.ts +++ b/src/qt_gui/translations/nl.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Enable RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Bijwerken @@ -720,6 +740,10 @@ GUI Settings GUI-Instellingen + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox RenderDoc foutopsporing inschakelen:\nAls ingeschakeld, biedt de emulator compatibiliteit met Renderdoc om de momenteel gerenderde frame vast te leggen en te analyseren. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/pl_PL.ts b/src/qt_gui/translations/pl_PL.ts index 85eb63bfb..89f165de2 100644 --- a/src/qt_gui/translations/pl_PL.ts +++ b/src/qt_gui/translations/pl_PL.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Włącz debugowanie RenderDoc + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Aktualizacja @@ -720,6 +740,10 @@ GUI Settings Ustawienia Interfejsu + + Title Music + Title Music + Disable Trophy Pop-ups Wyłącz wyskakujące okienka trofeów @@ -928,6 +952,26 @@ rdocCheckBox Włącz debugowanie RenderDoc:\nJeśli włączone, emulator zapewnia kompatybilność z Renderdoc, aby umożliwić nagrywanie i analizowanie aktualnie renderowanej klatki. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/pt_BR.ts b/src/qt_gui/translations/pt_BR.ts index fde1d3b63..0bce16dcf 100644 --- a/src/qt_gui/translations/pt_BR.ts +++ b/src/qt_gui/translations/pt_BR.ts @@ -538,7 +538,7 @@ Enable Fullscreen - Ativar Tela Cheia + Habilitar Tela Cheia Fullscreen Mode @@ -566,7 +566,7 @@ Enable Discord Rich Presence - Ativar Discord Rich Presence + Habilitar Discord Rich Presence Username @@ -574,7 +574,7 @@ Trophy Key - Trophy Key + Chave de Troféu Trophy @@ -582,7 +582,7 @@ Logger - Registro + Registro-Log Log Type @@ -594,7 +594,7 @@ Open Log Location - Abrir local do log + Abrir local do registro Input @@ -658,11 +658,11 @@ Enable Shaders Dumping - Ativar Dumping de Shaders + Habilitar Dumping de Shaders Enable NULL GPU - Ativar GPU NULA + Habilitar GPU NULA Paths @@ -686,19 +686,39 @@ Enable Debug Dumping - Ativar Depuração de Dumping + Habilitar Depuração de Dumping Enable Vulkan Validation Layers - Ativar Camadas de Validação do Vulkan + Habilitar Camadas de Validação do Vulkan Enable Vulkan Synchronization Validation - Ativar Validação de Sincronização do Vulkan + Habilitar Validação de Sincronização do Vulkan Enable RenderDoc Debugging - Ativar Depuração por RenderDoc + Habilitar Depuração do RenderDoc + + + Enable Crash Diagnostics + Habilitar Diagnóstico de Falhas + + + Collect Shaders + Coletar Shaders + + + Copy GPU Buffers + Copiar Buffers de GPU + + + Host Debug Markers + Marcadores de Depuração do Host + + + Guest Debug Markers + Marcadores de Depuração do Convidado Update @@ -720,6 +740,10 @@ GUI Settings Configurações da Interface + + Title Music + Música no Menu + Disable Trophy Pop-ups Desabilitar Pop-ups dos Troféus @@ -782,7 +806,7 @@ fullscreenCheckBox - Ativar Tela Cheia:\nAltera a janela do jogo para o modo tela cheia.\nIsso pode ser alterado pressionando a tecla F11. + Habilitar Tela Cheia:\nAltera a janela do jogo para o modo tela cheia.\nIsso pode ser alterado pressionando a tecla F11. separateUpdatesCheckBox @@ -798,7 +822,7 @@ discordRPCCheckbox - Ativar Discord Rich Presence:\nExibe o ícone do emulador e informações relevantes no seu perfil do Discord. + Habilitar Discord Rich Presence:\nExibe o ícone do emulador e informações relevantes no seu perfil do Discord. userName @@ -898,11 +922,11 @@ dumpShadersCheckBox - Ativar Dumping de Shaders:\nArmazena os shaders do jogo em uma pasta durante a renderização para fins de depuração técnica. + Habilitar Dumping de Shaders:\nArmazena os shaders do jogo em uma pasta durante a renderização para fins de depuração técnica. nullGpuCheckBox - Ativar GPU NULA:\nDesativa a renderização do jogo para fins de depuração técnica, como se não houvesse nenhuma placa gráfica. + Habilitar GPU NULA:\nDesativa a renderização do jogo para fins de depuração técnica, como se não houvesse nenhuma placa gráfica. gameFoldersBox @@ -918,19 +942,39 @@ debugDump - Ativar Depuração de Dumping:\nArmazena os símbolos de importação e exportação e as informações do cabeçalho do arquivo do programa PS4 atual em um diretório. + Habilitar Depuração de Dumping:\nArmazena os símbolos de importação e exportação e as informações do cabeçalho do arquivo do programa PS4 atual em um diretório. vkValidationCheckBox - Ativar Camadas de Validação do Vulkan:\nAtiva um sistema que valida o estado do renderizador Vulkan e registra informações sobre seu estado interno.\nIsso diminui o desempenho e pode alterar o comportamento da emulação. + Habilitar Camadas de Validação do Vulkan:\nAtiva um sistema que valida o estado do renderizador Vulkan e registra informações sobre seu estado interno.\nIsso diminui o desempenho e pode alterar o comportamento da emulação. vkSyncValidationCheckBox - Ativar Validação de Sincronização do Vulkan:\nAtiva um sistema que valida o agendamento de tarefas de renderização Vulkan.\nIsso diminui o desempenho e pode alterar o comportamento da emulação. + Habilitar Validação de Sincronização do Vulkan:\nAtiva um sistema que valida o agendamento de tarefas de renderização Vulkan.\nIsso diminui o desempenho e pode alterar o comportamento da emulação. rdocCheckBox - Ativar depuração por RenderDoc:\nSe ativado, permite que o emulador tenha compatibilidade com RenderDoc para gravação e análise do quadro renderizado atual. + Habilitar Depuração por RenderDoc:\nSe ativado, permite que o emulador tenha compatibilidade com RenderDoc para gravação e análise do quadro renderizado atual. + + + collectShaderCheckBox + Coletar Shaders:\nVocê precisa habilitar isso para editar shaders com o menu de depuração (Ctrl + F10). + + + crashDiagnosticsCheckBox + Diagnósticos de Falha:\nCria um arquivo .yaml com informações sobre o estado do Vulkan no momento da falha.\nÚtil para depurar erros de 'Device lost'. Se você tiver isso habilitado, você deve habilitar os Marcadores de Depuração de Host e de Convidado.\nNão funciona em GPUs da Intel.\nVocê precisa ter as Camadas de Validação Vulkan habilitadas e o SDK do Vulkan para que isso funcione. + + + copyGPUBuffersCheckBox + Copiar Buffers de GPU:\nContorna condições de corrida envolvendo envios de GPU.\nPode ou não ajudar com travamentos do PM4 tipo 0. + + + hostMarkersCheckBox + Marcadores de Depuração de Host:\nInsere informações do lado do emulador, como marcadores para comandos AMDGPU específicos em torno de comandos Vulkan, além de fornecer nomes de depuração aos recursos.\nSe isso estiver habilitado, você deve habilitar o "Diagnóstico de Falha".\nÚtil para programas como o RenderDoc. + + + guestMarkersCheckBox + Marcadores de Depuração de Convidado:\nInsere quaisquer marcadores de depuração que o próprio jogo adicionou ao buffer de comando.\nSe isso estiver habilitado, você deve habilitar "Diagnóstico de Falha".\nÚtil para programas como o RenderDoc. diff --git a/src/qt_gui/translations/ro_RO.ts b/src/qt_gui/translations/ro_RO.ts index 9791a7682..f60de9823 100644 --- a/src/qt_gui/translations/ro_RO.ts +++ b/src/qt_gui/translations/ro_RO.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Enable RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Actualizare @@ -720,6 +740,10 @@ GUI Settings Setări GUI + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox Activează depanarea RenderDoc:\nDacă este activat, emulatorul va oferi compatibilitate cu Renderdoc pentru a permite capturarea și analiza cadrului redat în prezent. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/ru_RU.ts b/src/qt_gui/translations/ru_RU.ts index 0fddb1e7f..270396a6d 100644 --- a/src/qt_gui/translations/ru_RU.ts +++ b/src/qt_gui/translations/ru_RU.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Включить отладку RenderDoc + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Обновление @@ -720,6 +740,10 @@ GUI Settings Интерфейс + + Title Music + Title Music + Disable Trophy Pop-ups Отключить уведомления о трофеях @@ -928,6 +952,26 @@ rdocCheckBox Включить отладку RenderDoc:\nЕсли включено, эмулятор обеспечит совместимость с Renderdoc, позволяя захватывать и анализировать текущие кадры во время рендеринга. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/sq.ts b/src/qt_gui/translations/sq.ts index 15c18d2f6..1d37fa9c3 100644 --- a/src/qt_gui/translations/sq.ts +++ b/src/qt_gui/translations/sq.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Aktivizo Korrigjimin RenderDoc + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Përditëso @@ -720,6 +740,10 @@ GUI Settings Cilësimet e GUI-së + + Title Music + Title Music + Disable Trophy Pop-ups Çaktivizo njoftimet për Trofetë @@ -928,6 +952,26 @@ rdocCheckBox Aktivizo korrigjimin RenderDoc:\nNëse aktivizohet, emulatori do të ofrojë pajtueshmëri me Renderdoc për të lejuar kapjen dhe analizën e pamjes të pasqyruar në moment. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/sv.ts b/src/qt_gui/translations/sv.ts index e17944f12..c5fbce991 100644 --- a/src/qt_gui/translations/sv.ts +++ b/src/qt_gui/translations/sv.ts @@ -1188,6 +1188,26 @@ Enable RenderDoc Debugging Aktivera RenderDoc-felsökning + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Uppdatera @@ -1208,6 +1228,10 @@ GUI Settings Gränssnittsinställningar + + Title Music + Title Music + Disable Trophy Pop-ups Inaktivera popup för troféer @@ -1408,6 +1432,26 @@ rdocCheckBox Aktivera RenderDoc-felsökning:\nOm aktiverad kommer emulatorn att tillhandahålla kompatibilitet med Renderdoc för att tillåta fångst och analys för aktuell renderad bildruta + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Release Release diff --git a/src/qt_gui/translations/tr_TR.ts b/src/qt_gui/translations/tr_TR.ts index a2368bfee..12794e088 100644 --- a/src/qt_gui/translations/tr_TR.ts +++ b/src/qt_gui/translations/tr_TR.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging RenderDoc Hata Ayıklamayı Etkinleştir + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Güncelle @@ -720,6 +740,10 @@ GUI Settings GUI Ayarları + + Title Music + Title Music + Disable Trophy Pop-ups Kupa Açılır Pencerelerini Devre Dışı Bırak @@ -928,6 +952,26 @@ rdocCheckBox RenderDoc Hata Ayıklamayı Etkinleştir:\nEğer etkinleştirilirse, emülatör mevcut render edilmiş çerçeveyi yakalamak ve analiz etmek için Renderdoc ile uyumluluk sunar. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/uk_UA.ts b/src/qt_gui/translations/uk_UA.ts index 720ad5b99..e80d363d3 100644 --- a/src/qt_gui/translations/uk_UA.ts +++ b/src/qt_gui/translations/uk_UA.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Увімкнути налагодження RenderDoc + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Оновлення @@ -720,6 +740,10 @@ GUI Settings Інтерфейс + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox Увімкнути налагодження RenderDoc:\nЯкщо увімкнено, емулятор забезпечить сумісність із Renderdoc, даючи змогу захоплювати й аналізувати поточні кадри під час рендерингу. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/vi_VN.ts b/src/qt_gui/translations/vi_VN.ts index a81630fad..32841af81 100644 --- a/src/qt_gui/translations/vi_VN.ts +++ b/src/qt_gui/translations/vi_VN.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Enable RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update Cập nhật @@ -720,6 +740,10 @@ GUI Settings Cài đặt GUI + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox Bật gỡ lỗi RenderDoc:\nNếu được kích hoạt, trình giả lập sẽ cung cấp tính tương thích với Renderdoc để cho phép bắt và phân tích khung hình hiện tại đang được kết xuất. + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/qt_gui/translations/zh_CN.ts b/src/qt_gui/translations/zh_CN.ts index 16ae03f94..00f4337c0 100644 --- a/src/qt_gui/translations/zh_CN.ts +++ b/src/qt_gui/translations/zh_CN.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging 启用 RenderDoc 调试 + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update 更新 @@ -720,6 +740,10 @@ GUI Settings 界面设置 + + Title Music + Title Music + Disable Trophy Pop-ups 禁止弹出奖杯 @@ -928,6 +952,26 @@ rdocCheckBox 启用 RenderDoc 调试:\n启用后模拟器将提供与 Renderdoc 的兼容性,允许在渲染过程中捕获和分析当前渲染的帧。 + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + saveDataBox 存档数据路径:\n保存游戏存档数据的目录。 diff --git a/src/qt_gui/translations/zh_TW.ts b/src/qt_gui/translations/zh_TW.ts index 9f6758797..c18e173e4 100644 --- a/src/qt_gui/translations/zh_TW.ts +++ b/src/qt_gui/translations/zh_TW.ts @@ -700,6 +700,26 @@ Enable RenderDoc Debugging Enable RenderDoc Debugging + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + Update 更新 @@ -720,6 +740,10 @@ GUI Settings 介面設置 + + Title Music + Title Music + Disable Trophy Pop-ups Disable Trophy Pop-ups @@ -928,6 +952,26 @@ rdocCheckBox 啟用RenderDoc調試:\n如果啟用,模擬器將提供與Renderdoc的兼容性,以允許捕獲和分析當前渲染的幀。 + + collectShaderCheckBox + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + crashDiagnosticsCheckBox + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + copyGPUBuffersCheckBox + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + hostMarkersCheckBox + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + guestMarkersCheckBox + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + CheatsPatches diff --git a/src/video_core/renderer_vulkan/vk_platform.h b/src/video_core/renderer_vulkan/vk_platform.h index d05d12997..4e9587e46 100644 --- a/src/video_core/renderer_vulkan/vk_platform.h +++ b/src/video_core/renderer_vulkan/vk_platform.h @@ -33,7 +33,7 @@ concept VulkanHandleType = vk::isVulkanHandleType::value; template void SetObjectName(vk::Device device, const HandleType& handle, std::string_view debug_name) { - if (!Config::vkHostMarkersEnabled()) { + if (!Config::getVkHostMarkersEnabled()) { return; } const vk::DebugUtilsObjectNameInfoEXT name_info = { @@ -50,7 +50,7 @@ void SetObjectName(vk::Device device, const HandleType& handle, std::string_view template void SetObjectName(vk::Device device, const HandleType& handle, const char* format, const Args&... args) { - if (!Config::vkHostMarkersEnabled()) { + if (!Config::getVkHostMarkersEnabled()) { return; } const std::string debug_name = fmt::vformat(format, fmt::make_format_args(args...)); diff --git a/src/video_core/renderer_vulkan/vk_presenter.cpp b/src/video_core/renderer_vulkan/vk_presenter.cpp index 35ab4318a..c2be1c3e8 100644 --- a/src/video_core/renderer_vulkan/vk_presenter.cpp +++ b/src/video_core/renderer_vulkan/vk_presenter.cpp @@ -294,7 +294,7 @@ void Presenter::CreatePostProcessPipeline() { Presenter::Presenter(Frontend::WindowSDL& window_, AmdGpu::Liverpool* liverpool_) : window{window_}, liverpool{liverpool_}, instance{window, Config::getGpuId(), Config::vkValidationEnabled(), - Config::vkCrashDiagnosticEnabled()}, + Config::getVkCrashDiagnosticEnabled()}, draw_scheduler{instance}, present_scheduler{instance}, flip_scheduler{instance}, swapchain{instance, window}, rasterizer{std::make_unique(instance, draw_scheduler, liverpool)}, @@ -467,7 +467,7 @@ bool Presenter::ShowSplash(Frame* frame /*= nullptr*/) { draw_scheduler.EndRendering(); const auto cmdbuf = draw_scheduler.CommandBuffer(); - if (Config::vkHostMarkersEnabled()) { + if (Config::getVkHostMarkersEnabled()) { cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{ .pLabelName = "ShowSplash", }); @@ -541,7 +541,7 @@ bool Presenter::ShowSplash(Frame* frame /*= nullptr*/) { .pImageMemoryBarriers = &post_barrier, }); - if (Config::vkHostMarkersEnabled()) { + if (Config::getVkHostMarkersEnabled()) { cmdbuf.endDebugUtilsLabelEXT(); } @@ -573,7 +573,7 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop) auto& scheduler = is_eop ? draw_scheduler : flip_scheduler; scheduler.EndRendering(); const auto cmdbuf = scheduler.CommandBuffer(); - if (Config::vkHostMarkersEnabled()) { + if (Config::getVkHostMarkersEnabled()) { const auto label = fmt::format("PrepareFrameInternal:{}", image_id.index); cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{ .pLabelName = label.c_str(), @@ -704,7 +704,7 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop) .pImageMemoryBarriers = &post_barrier, }); - if (Config::vkHostMarkersEnabled()) { + if (Config::getVkHostMarkersEnabled()) { cmdbuf.endDebugUtilsLabelEXT(); } @@ -755,7 +755,7 @@ void Presenter::Present(Frame* frame, bool is_reusing_frame) { auto& scheduler = present_scheduler; const auto cmdbuf = scheduler.CommandBuffer(); - if (Config::vkHostMarkersEnabled()) { + if (Config::getVkHostMarkersEnabled()) { cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{ .pLabelName = "Present", }); @@ -857,7 +857,7 @@ void Presenter::Present(Frame* frame, bool is_reusing_frame) { } } - if (Config::vkHostMarkersEnabled()) { + if (Config::getVkHostMarkersEnabled()) { cmdbuf.endDebugUtilsLabelEXT(); } diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 7c77f2519..fde87fcfb 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -1239,8 +1239,8 @@ void Rasterizer::UpdateViewportScissorState(const GraphicsPipeline& pipeline) { } void Rasterizer::ScopeMarkerBegin(const std::string_view& str, bool from_guest) { - if ((from_guest && !Config::vkGuestMarkersEnabled()) || - (!from_guest && !Config::vkHostMarkersEnabled())) { + if ((from_guest && !Config::getVkGuestMarkersEnabled()) || + (!from_guest && !Config::getVkHostMarkersEnabled())) { return; } const auto cmdbuf = scheduler.CommandBuffer(); @@ -1250,8 +1250,8 @@ void Rasterizer::ScopeMarkerBegin(const std::string_view& str, bool from_guest) } void Rasterizer::ScopeMarkerEnd(bool from_guest) { - if ((from_guest && !Config::vkGuestMarkersEnabled()) || - (!from_guest && !Config::vkHostMarkersEnabled())) { + if ((from_guest && !Config::getVkGuestMarkersEnabled()) || + (!from_guest && !Config::getVkHostMarkersEnabled())) { return; } const auto cmdbuf = scheduler.CommandBuffer(); @@ -1259,8 +1259,8 @@ void Rasterizer::ScopeMarkerEnd(bool from_guest) { } void Rasterizer::ScopedMarkerInsert(const std::string_view& str, bool from_guest) { - if ((from_guest && !Config::vkGuestMarkersEnabled()) || - (!from_guest && !Config::vkHostMarkersEnabled())) { + if ((from_guest && !Config::getVkGuestMarkersEnabled()) || + (!from_guest && !Config::getVkHostMarkersEnabled())) { return; } const auto cmdbuf = scheduler.CommandBuffer(); @@ -1271,8 +1271,8 @@ void Rasterizer::ScopedMarkerInsert(const std::string_view& str, bool from_guest void Rasterizer::ScopedMarkerInsertColor(const std::string_view& str, const u32 color, bool from_guest) { - if ((from_guest && !Config::vkGuestMarkersEnabled()) || - (!from_guest && !Config::vkHostMarkersEnabled())) { + if ((from_guest && !Config::getVkGuestMarkersEnabled()) || + (!from_guest && !Config::getVkHostMarkersEnabled())) { return; } const auto cmdbuf = scheduler.CommandBuffer(); From ad5bd91a13ec891395efdacfbc00cd78c2a58ea6 Mon Sep 17 00:00:00 2001 From: DanielSvoboda Date: Thu, 30 Jan 2025 15:34:42 -0300 Subject: [PATCH 48/72] Fix game title sorting (#2286) * Fix game title sorting * fix * fix * fix --- src/qt_gui/game_list_frame.cpp | 9 +++++++-- src/qt_gui/game_list_frame.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/qt_gui/game_list_frame.cpp b/src/qt_gui/game_list_frame.cpp index 9753f511b..8255c0daf 100644 --- a/src/qt_gui/game_list_frame.cpp +++ b/src/qt_gui/game_list_frame.cpp @@ -69,7 +69,7 @@ GameListFrame::GameListFrame(std::shared_ptr game_info_get, ListSortedAsc = true; } this->clearContents(); - PopulateGameList(); + PopulateGameList(false); }); connect(this, &QTableWidget::customContextMenuRequested, this, [=, this](const QPoint& pos) { @@ -103,7 +103,7 @@ void GameListFrame::PlayBackgroundMusic(QTableWidgetItem* item) { BackgroundMusicPlayer::getInstance().playMusic(snd0path); } -void GameListFrame::PopulateGameList() { +void GameListFrame::PopulateGameList(bool isInitialPopulation) { // Do not show status column if it is not enabled this->setColumnHidden(2, !Config::getCompatibilityEnabled()); this->setColumnHidden(6, !Config::GetLoadGameSizeEnabled()); @@ -111,6 +111,11 @@ void GameListFrame::PopulateGameList() { this->setRowCount(m_game_info->m_games.size()); ResizeIcons(icon_size); + if (isInitialPopulation) { + SortNameAscending(1); // Column 1 = Name + ResizeIcons(icon_size); + } + for (int i = 0; i < m_game_info->m_games.size(); i++) { SetTableItem(i, 1, QString::fromStdString(m_game_info->m_games[i].name)); SetTableItem(i, 3, QString::fromStdString(m_game_info->m_games[i].serial)); diff --git a/src/qt_gui/game_list_frame.h b/src/qt_gui/game_list_frame.h index 90d021093..7e37c4ea7 100644 --- a/src/qt_gui/game_list_frame.h +++ b/src/qt_gui/game_list_frame.h @@ -46,7 +46,7 @@ private: bool ListSortedAsc = true; public: - void PopulateGameList(); + void PopulateGameList(bool isInitialPopulation = true); void ResizeIcons(int iconSize); QImage backgroundImage; From 52df7f6fe5bbb9a599c3fbc9e9de27a033c65426 Mon Sep 17 00:00:00 2001 From: Missake212 Date: Thu, 30 Jan 2025 21:18:45 +0100 Subject: [PATCH 49/72] add french tl (#2289) --- src/qt_gui/translations/fr.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/qt_gui/translations/fr.ts b/src/qt_gui/translations/fr.ts index b93af15a6..f2ea4fcc7 100644 --- a/src/qt_gui/translations/fr.ts +++ b/src/qt_gui/translations/fr.ts @@ -702,23 +702,23 @@ Enable Crash Diagnostics - Enable Crash Diagnostics + Activer le diagnostic de crash Collect Shaders - Collect Shaders + Collecter les shaders Copy GPU Buffers - Copy GPU Buffers + Copier la mémoire tampon GPU Host Debug Markers - Host Debug Markers + Marqueur de débogage hôte Guest Debug Markers - Guest Debug Markers + Marqueur de débogage invité Update @@ -954,30 +954,30 @@ collectShaderCheckBox - Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + Collecter les Shaders:\nVous devez activer cette option pour modifier les shaders avec le menu de débogage (Ctrl + F10). crashDiagnosticsCheckBox - Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + Diagnostic de crash:\nCrée un fichier .yaml avec des informations sur l'état de Vulkan au moment du crash.\nUtile pour déboguer les erreurs "Device lost". Si cette option est activée, vous devez aussi activer Marqueur de débogage hôte ET invité.\nNe marche pas pour les GPUs Intel.\nVous devez activer le Vulkan Validation Layers ainsi que le Vulkan SDK pour que cela fonctionne. copyGPUBuffersCheckBox - Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + Copier la mémoire tampon GPU:\nContourne les conditions de course impliquant des soumissions GPU.\nPeut aider ou non en cas de crash PM4 type 0. hostMarkersCheckBox - Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Marqueur de débogage hôte:\nInsère des informations côté émulateur telles que des marqueurs pour des commandes spécifiques AMDGPU autour des commandes Vulkan, ainsi que donner les noms de débogages des ressources.\nSi cette option est activée, vous devriez activer "Diagnostic de crash".\nUtile pour des programmes comme RenderDoc. guestMarkersCheckBox - Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Marqueur de débogage invité:\nInsère tous les marqueurs de débogage que le jeu a ajouté a la commande mémoire tampon.\nSi cette option est activée, vous devriez activer "Diagnostic de crash".\nUtile pour des programmes comme RenderDoc. CheatsPatches Cheats / Patches for - Cheats/Patchs pour + Cheats / Patchs pour defaultTextEdit_MSG From c77f62a7380aa8a504420fa33b80f8fe38f3350c Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Thu, 30 Jan 2025 21:45:49 +0100 Subject: [PATCH 50/72] Detect and log if the user is using a fork (#2219) * Added fork detection * Fallback to "origin" if branch is not found * Add fork names to window titles * clang --- CMakeLists.txt | 24 ++++++++++++++++++++++++ src/common/scm_rev.cpp.in | 12 ++++++++---- src/common/scm_rev.h | 2 ++ src/emulator.cpp | 12 ++++++++++-- src/qt_gui/main_window.cpp | 11 +++++++++-- 5 files changed, 53 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78e3c7997..340715e78 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,6 +106,30 @@ git_describe(GIT_DESC --always --long --dirty) git_branch_name(GIT_BRANCH) string(TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S") +# Get current remote name and branch +execute_process( + COMMAND git rev-parse --abbrev-ref --symbolic-full-name @{u} + OUTPUT_VARIABLE GIT_REMOTE_NAME + RESULT_VARIABLE GIT_BRANCH_RESULT + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +# Default to origin if branch is not set +if (GIT_BRANCH_RESULT OR GIT_REMOTE_NAME STREQUAL "") + set(GIT_REMOTE_NAME "origin") +else() + # Extract remote name from full name + string(FIND "${GIT_REMOTE_NAME}" "/" INDEX) + string(SUBSTRING "${GIT_REMOTE_NAME}" 0 "${INDEX}" GIT_REMOTE_NAME) +endif() + +# Get remote link +execute_process( + COMMAND git config --get remote.${GIT_REMOTE_NAME}.url + OUTPUT_VARIABLE GIT_REMOTE_URL + OUTPUT_STRIP_TRAILING_WHITESPACE +) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/src/common/scm_rev.cpp" @ONLY) find_package(Boost 1.84.0 CONFIG) diff --git a/src/common/scm_rev.cpp.in b/src/common/scm_rev.cpp.in index 642e6373d..2de04e0be 100644 --- a/src/common/scm_rev.cpp.in +++ b/src/common/scm_rev.cpp.in @@ -6,14 +6,18 @@ #define GIT_REV "@GIT_REV@" #define GIT_BRANCH "@GIT_BRANCH@" #define GIT_DESC "@GIT_DESC@" +#define GIT_REMOTE_NAME "@GIT_REMOTE_NAME@" +#define GIT_REMOTE_URL "@GIT_REMOTE_URL@" #define BUILD_DATE "@BUILD_DATE@" namespace Common { -const char g_scm_rev[] = GIT_REV; -const char g_scm_branch[] = GIT_BRANCH; -const char g_scm_desc[] = GIT_DESC; -const char g_scm_date[] = BUILD_DATE; +const char g_scm_rev[] = GIT_REV; +const char g_scm_branch[] = GIT_BRANCH; +const char g_scm_desc[] = GIT_DESC; +const char g_scm_remote_name[] = GIT_REMOTE_NAME; +const char g_scm_remote_url[] = GIT_REMOTE_URL; +const char g_scm_date[] = BUILD_DATE; } // namespace diff --git a/src/common/scm_rev.h b/src/common/scm_rev.h index 005099d2d..f38efff42 100644 --- a/src/common/scm_rev.h +++ b/src/common/scm_rev.h @@ -8,6 +8,8 @@ namespace Common { extern const char g_scm_rev[]; extern const char g_scm_branch[]; extern const char g_scm_desc[]; +extern const char g_scm_remote_name[]; +extern const char g_scm_remote_url[]; extern const char g_scm_date[]; } // namespace Common diff --git a/src/emulator.cpp b/src/emulator.cpp index 81c4d814d..3ab26d484 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -57,6 +57,7 @@ Emulator::Emulator() { LOG_INFO(Loader, "Revision {}", Common::g_scm_rev); LOG_INFO(Loader, "Branch {}", Common::g_scm_branch); LOG_INFO(Loader, "Description {}", Common::g_scm_desc); + LOG_INFO(Loader, "Remote {}", Common::g_scm_remote_url); LOG_INFO(Config, "General LogType: {}", Config::getLogType()); LOG_INFO(Config, "General isNeo: {}", Config::isNeoModeConsole()); @@ -199,8 +200,15 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector( Config::getScreenWidth(), Config::getScreenHeight(), controller, window_title); diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index 3678b3a82..ce7b7b19e 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -57,8 +57,15 @@ bool MainWindow::Init() { if (Common::isRelease) { window_title = fmt::format("shadPS4 v{}", Common::VERSION); } else { - window_title = fmt::format("shadPS4 v{} {} {}", Common::VERSION, Common::g_scm_branch, - Common::g_scm_desc); + std::string remote_url(Common::g_scm_remote_url); + if (remote_url == "https://github.com/shadps4-emu/shadPS4.git") { + window_title = fmt::format("shadPS4 v{} {} {}", Common::VERSION, Common::g_scm_branch, + Common::g_scm_desc); + } else { + std::string remote_host = remote_url.substr(19, remote_url.rfind('/') - 19); + window_title = fmt::format("shadPS4 v{} {}/{} {}", Common::VERSION, remote_host, + Common::g_scm_branch, Common::g_scm_desc); + } } setWindowTitle(QString::fromStdString(window_title)); this->show(); From b5d63a31ccc9eefc98818577e87b418af225005e Mon Sep 17 00:00:00 2001 From: C4ndyF1sh <128715345+C4ndyF1sh@users.noreply.github.com> Date: Thu, 30 Jan 2025 23:05:50 +0100 Subject: [PATCH 51/72] update german ts (#2290) * Update de.ts (p1) * Update de.ts (p2) --- src/qt_gui/translations/de.ts | 110 +++++++++++++++++----------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/src/qt_gui/translations/de.ts b/src/qt_gui/translations/de.ts index b8fa22881..d1ae21cca 100644 --- a/src/qt_gui/translations/de.ts +++ b/src/qt_gui/translations/de.ts @@ -52,7 +52,7 @@ Select which directory you want to install to. - Select which directory you want to install to. + Wählen Sie das Verzeichnis aus, in das Sie installieren möchten. @@ -130,35 +130,35 @@ Delete... - Delete... + Löschen... Delete Game - Delete Game + Lösche Spiel Delete Update - Delete Update + Lösche Aktualisierung Delete DLC - Delete DLC + Lösche DLC Compatibility... - Compatibility... + Kompatibilität... Update database - Update database + Aktualisiere Datenbank View report - View report + Bericht ansehen Submit a report - Submit a report + Einen Bericht einreichen Shortcut creation @@ -182,23 +182,23 @@ Game - Game + Spiel requiresEnableSeparateUpdateFolder_MSG - This feature requires the 'Enable Separate Update Folder' config option to work. If you want to use this feature, please enable it. + Damit diese Funktion funktioniert, ist die Konfigurationsoption „Separaten Update-Ordner aktivieren“ erforderlich. Wenn Sie diese Funktion nutzen möchten, aktivieren Sie sie bitte. This game has no update to delete! - This game has no update to delete! + Dieses Spiel hat keine Aktualisierung zum löschen! Update - Update + Aktualisieren This game has no DLC to delete! - This game has no DLC to delete! + Dieses Spiel hat kein DLC zum aktualisieren! DLC @@ -206,11 +206,11 @@ Delete %1 - Delete %1 + Lösche %1 Are you sure you want to delete %1's %2 directory? - Are you sure you want to delete %1's %2 directory? + Sind Sie sicher dass Sie %1 %2 Ordner löschen wollen? @@ -249,7 +249,7 @@ Open shadPS4 Folder - Open shadPS4 Folder + Öffne shadPS4 Ordner Exit @@ -305,7 +305,7 @@ Download Cheats/Patches - Cheats / Patches herunterladen + Cheats/Patches herunterladen Dump Game List @@ -313,7 +313,7 @@ PKG Viewer - PKG-Ansicht + PKG-Anschauer Search... @@ -329,11 +329,11 @@ Game List Icons - Game List Icons + Spiellisten-Symbole Game List Mode - Spiellisten-Symoble + Spiellisten-Modus Settings @@ -373,7 +373,7 @@ toolBar - toolBar + Werkzeugleiste Game List @@ -461,7 +461,7 @@ Would you like to install DLC: %1? - Willst du den DLC installieren: %1? + Willst du das DLC installieren: %1? DLC already installed: @@ -546,7 +546,7 @@ Enable Separate Update Folder - Enable Separate Update Folder + Separaten Update-Ordner aktivieren Default tab when opening settings @@ -574,11 +574,11 @@ Trophy Key - Trophy Key + Trophäenschlüssel Trophy - Trophy + Trophäe Logger @@ -702,23 +702,23 @@ Enable Crash Diagnostics - Enable Crash Diagnostics + Absturz-Diagnostik aktivieren Collect Shaders - Collect Shaders + Sammle Shader Copy GPU Buffers - Copy GPU Buffers + Kopiere GPU Puffer Host Debug Markers - Host Debug Markers + Host-Debug-Markierungen Guest Debug Markers - Guest Debug Markers + Guest-Debug-Markierungen Update @@ -746,7 +746,7 @@ Disable Trophy Pop-ups - Disable Trophy Pop-ups + Deaktiviere Trophäen Pop-ups Play title music @@ -754,19 +754,19 @@ Update Compatibility Database On Startup - Update Compatibility Database On Startup + Aktualisiere Kompatibilitätsdatenbank beim Start Game Compatibility - Game Compatibility + Spielkompatibilität Display Compatibility Data - Display Compatibility Data + Zeige Kompatibilitätsdaten Update Compatibility Database - Update Compatibility Database + Aktualisiere Kompatibilitätsdatenbank Volume @@ -810,7 +810,7 @@ separateUpdatesCheckBox - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management. + Separaten Update-Ordner aktivieren:\nErmöglicht die Installation von Spielaktualiserungen in einem separaten Ordner zur einfachen Verwaltung. showSplashCheckBox @@ -866,15 +866,15 @@ enableCompatibilityCheckBox - Display Compatibility Data:\nDisplays game compatibility information in table view. Enable "Update Compatibility On Startup" to get up-to-date information. + Kompatibilitätsdaten anzeigen:\nZeigt Spielkompatibilitätsinformationen in Tabellenansicht an. Aktivieren Sie „Aktualisiere Kompatibilitätsdatenbank beim Start“, um aktuelle Informationen zu erhalten. checkCompatibilityOnStartupCheckBox - Update Compatibility On Startup:\nAutomatically update the compatibility database when shadPS4 starts. + Kompatibilität beim Start aktualisieren:\nAktualisiert die Kompatibilitätsdatenbank automatisch, wenn shadPS4 startet. updateCompatibilityButton - Update Compatibility Database:\nImmediately update the compatibility database. + Aktualisiere Kompatibilitätsdatenbank:\nAktualisiere sofort die Kompatibilitätsdatenbank. Never @@ -954,23 +954,23 @@ collectShaderCheckBox - Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + Shader sammeln:\nSie müssen diese Option aktivieren, um Shader mit dem Debug-Menü (Strg + F10) bearbeiten zu können. crashDiagnosticsCheckBox - Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + Absturzdiagnose:\nErstellt eine .yaml-Datei mit Informationen über den Vulkan-Status zum Zeitpunkt des Absturzes.\nNützlich zum Debuggen von „Gerät verloren“-Fehlern. Wenn Sie dies aktiviert haben, sollten Sie Host- UND Gast-Debug-Markierungen aktivieren.\nFunktioniert nicht auf Intel-GPUs.\nDamit dies funktioniert, müssen Vulkan Validationsschichten aktiviert und das Vulkan SDK installiert sein. copyGPUBuffersCheckBox - Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + GPU-Puffer kopieren:\nUmgeht Race-Bedingungen mit GPU-Übermittlungen.\nKann bei PM4-Abstürzen vom Typ 0 hilfreich sein oder auch nicht. hostMarkersCheckBox - Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Host-Debug-Marker:\nFügt emulatorseitige Informationen wie Marker für bestimmte AMDGPU-Befehle rund um Vulkan-Befehle ein und gibt Ressourcen-Debug-Namen an.\nWenn Sie dies aktiviert haben, sollten Sie die Absturzdiagnose aktivieren.\nNützlich für Programme wie RenderDoc. guestMarkersCheckBox - Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Gast-Debug-Markierer:\nFügt alle Debug-Markierer, die das Spiel selbst hinzugefügt hat, in den Befehlspuffer ein.\nWenn Sie dies aktiviert haben, sollten Sie die Absturzdiagnose aktivieren.\nNützlich für Programme wie RenderDoc. @@ -1165,7 +1165,7 @@ Failed to open file: - Fehler beim Öffnen der Datei: + Öffnung der Datei fehlgeschlagen: XML ERROR: @@ -1212,7 +1212,7 @@ Compatibility - Compatibility + Kompatibilität Region @@ -1240,7 +1240,7 @@ Never Played - Never Played + Niemals gespielt h @@ -1256,27 +1256,27 @@ Compatibility is untested - Compatibility is untested + Kompatibilität wurde noch nicht getested Game does not initialize properly / crashes the emulator - Game does not initialize properly / crashes the emulator + Das Spiel wird nicht richtig initialisiert / stürzt den Emulator ab Game boots, but only displays a blank screen - Game boots, but only displays a blank screen + Spiel startet, aber zeigt nur einen blanken Bildschirm Game displays an image but does not go past the menu - Game displays an image but does not go past the menu + Spiel zeigt ein Bild aber geht nicht über das Menü hinaus Game has game-breaking glitches or unplayable performance - Game has game-breaking glitches or unplayable performance + Spiel hat spiel-brechende Störungen oder unspielbare Leistung Game can be completed with playable performance and no major glitches - Game can be completed with playable performance and no major glitches + Spiel kann mit spielbarer Leistung und keinen großen Störungen abgeschlossen werden @@ -1405,4 +1405,4 @@ TB - \ No newline at end of file + From be74f65864eb46f86e6b247db63fcc3cba5a4aed Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Thu, 30 Jan 2025 23:14:13 +0100 Subject: [PATCH 52/72] Fix ccrash if remote is not set (#2291) --- CMakeLists.txt | 14 ++++++++++---- src/emulator.cpp | 3 ++- src/qt_gui/main_window.cpp | 3 ++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 340715e78..e10fcfb98 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,21 +106,27 @@ git_describe(GIT_DESC --always --long --dirty) git_branch_name(GIT_BRANCH) string(TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S") -# Get current remote name and branch +# Try to get the upstream remote and branch execute_process( COMMAND git rev-parse --abbrev-ref --symbolic-full-name @{u} OUTPUT_VARIABLE GIT_REMOTE_NAME RESULT_VARIABLE GIT_BRANCH_RESULT + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) -# Default to origin if branch is not set +# Default to origin if there's no upstream set or if the command failed if (GIT_BRANCH_RESULT OR GIT_REMOTE_NAME STREQUAL "") set(GIT_REMOTE_NAME "origin") else() - # Extract remote name from full name + # Extract remote name if the output contains a remote/branch format string(FIND "${GIT_REMOTE_NAME}" "/" INDEX) - string(SUBSTRING "${GIT_REMOTE_NAME}" 0 "${INDEX}" GIT_REMOTE_NAME) + if (INDEX GREATER -1) + string(SUBSTRING "${GIT_REMOTE_NAME}" 0 "${INDEX}" GIT_REMOTE_NAME) + else() + # If no remote is present (only a branch name), default to origin + set(GIT_REMOTE_NAME "origin") + endif() endif() # Get remote link diff --git a/src/emulator.cpp b/src/emulator.cpp index 3ab26d484..ba8d8917c 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -201,7 +201,8 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector Date: Thu, 30 Jan 2025 19:41:17 -0300 Subject: [PATCH 53/72] Fix minor issue with 'Emulator' group box (#2292) --- src/qt_gui/settings_dialog.ui | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/qt_gui/settings_dialog.ui b/src/qt_gui/settings_dialog.ui index 4e7440af5..d15f49efe 100644 --- a/src/qt_gui/settings_dialog.ui +++ b/src/qt_gui/settings_dialog.ui @@ -108,9 +108,6 @@ Emulator - - Qt::AlignmentFlag::AlignBottom|Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft - false From 647694d1b9eb6c34b4567b627ac8752ffeb468c9 Mon Sep 17 00:00:00 2001 From: bigol83 <38129260+bigol83@users.noreply.github.com> Date: Fri, 31 Jan 2025 07:34:42 +0100 Subject: [PATCH 54/72] Update Italian translation (#2293) * Update it.ts Update Italian translation * Update Italian translation * Update Italian translation --- src/qt_gui/translations/it.ts | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/qt_gui/translations/it.ts b/src/qt_gui/translations/it.ts index 384272137..106d09de0 100644 --- a/src/qt_gui/translations/it.ts +++ b/src/qt_gui/translations/it.ts @@ -146,19 +146,19 @@ Compatibility... - Compatibility... + Compatibilità... Update database - Update database + Aggiorna database View report - View report + Visualizza rapporto Submit a report - Submit a report + Invia rapporto Shortcut creation @@ -194,7 +194,7 @@ Update - Update + Aggiornamento This game has no DLC to delete! @@ -249,7 +249,7 @@ Open shadPS4 Folder - Open shadPS4 Folder + Apri Cartella shadps4 Exit @@ -574,11 +574,11 @@ Trophy Key - Trophy Key + Chiave Trofei Trophy - Trophy + Trofei Logger @@ -702,23 +702,23 @@ Enable Crash Diagnostics - Enable Crash Diagnostics + Abilita Diagnostica Crash Collect Shaders - Collect Shaders + Raccogli Shaders Copy GPU Buffers - Copy GPU Buffers + Copia Buffer GPU Host Debug Markers - Host Debug Markers + Marcatori di Debug dell'Host Guest Debug Markers - Guest Debug Markers + Marcatori di Debug del Guest Update @@ -742,7 +742,7 @@ Title Music - Title Music + Musica del Titolo Disable Trophy Pop-ups @@ -774,7 +774,7 @@ Audio Backend - Audio Backend + Backend Audio Save @@ -830,7 +830,7 @@ TrophyKey - Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. + Chiave Trofei:\nChiave utilizzata per la decrittazione dei trofei. Deve essere estratta dalla vostra console con jailbreak.\nDeve contenere solo caratteri esadecimali. logTypeGroupBox @@ -850,7 +850,7 @@ disableTrophycheckBox - Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). + Disabilita Notifica Trofei:\nDisabilita notifiche in gioco dei trofei. Il progresso dei Trofei può ancora essere controllato con il Visualizzatore Trofei (clicca tasto destro sul gioco nella finestra principale). hideCursorGroupBox @@ -954,30 +954,30 @@ collectShaderCheckBox - Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + Raccogli Shader:\nBisogna attivare questa opzione per poter modificare gli shader nel menu di debug (Ctrl + F10). crashDiagnosticsCheckBox - Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + Diagnostica Crash:\nCrea un file .yaml che contiene informazioni riguardo lo stato del renderer Vulkan nel momento in cui si verifica un crash.\nUtile per poter effettuare il debug degli errori di tipo "Device Lost". Se hai questa opzione attiva dovresti abilitare anche Marcatori di Debug Host e Guest.\nNon è funzionante su GPU Intel.\nVulkan Validation Layers deve essere abilitato e bisogna aver installato l'SDK Vulkan per poter utilizzare questa funzione. copyGPUBuffersCheckBox - Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + Copia Buffer GPU:\nCerca di aggirare le race conditions che riguardano gli invii alla GPU.\nPotrebbe aiutare ad evitare crash che riguardano i PM4 di tipo 0. hostMarkersCheckBox - Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Marcatori di Debug dell'Host:\nInserisce nel log informazioni ottenute dall'emulatore come ad esempio marcatori per comandi specifici AMDGPU quando si hanno comandi Vulkan e associa nomi di debug per le risorse.\nSe hai questa opzione abilitata dovresti abilitare anche Diagnostica Crash.\nUtile per programmi come RenderDoc. guestMarkersCheckBox - Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Marcatori di Debug del Guest:\nInserisce nel log marcatori di debug che il gioco stesso ha aggiunto al buffer dei comandi.\nSe hai abilitato questa opzione dovresti abilitare anche Diagnostica Crash.\nUtile per programmi come RenderDoc. CheatsPatches Cheats / Patches for - Cheats / Patches for + Cheats / Patch per defaultTextEdit_MSG @@ -1244,7 +1244,7 @@ h - h + o m @@ -1405,4 +1405,4 @@ TB - \ No newline at end of file + From 6e58c6c5131a0a1bd27833136e1b50f6a652adbf Mon Sep 17 00:00:00 2001 From: C4ndyF1sh <128715345+C4ndyF1sh@users.noreply.github.com> Date: Fri, 31 Jan 2025 07:35:06 +0100 Subject: [PATCH 55/72] update german ts (#2294) * Update de.ts (p1) * Update de.ts (p2) * Update de.ts (p3) * Update de.ts (p4) --- src/qt_gui/translations/de.ts | 36 +++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/qt_gui/translations/de.ts b/src/qt_gui/translations/de.ts index d1ae21cca..71ee066c1 100644 --- a/src/qt_gui/translations/de.ts +++ b/src/qt_gui/translations/de.ts @@ -105,7 +105,11 @@ Spielordner öffnen - Open Save Data Folder + Open Update Folder + Öffne Update-Ordner + + + Open Save Data Folder Speicherordner öffnen @@ -139,7 +143,11 @@ Delete Update Lösche Aktualisierung - + + + Delete Save Data + Lösche Speicherdaten + Delete DLC Lösche DLC @@ -513,7 +521,11 @@ SettingsDialog - Settings + Save Data Path + Speicherdaten-Pfad + + + Settings Einstellungen @@ -554,7 +566,7 @@ Show Game Size In List - Zeigen Sie die Spielgröße in der Liste + Zeige Spielgröße in der Liste Show Splash @@ -599,6 +611,10 @@ Input Eingabe + + + Enable Motion Controls + Aktiviere Bewegungssteuerung Cursor @@ -714,11 +730,11 @@ Host Debug Markers - Host-Debug-Markierungen + Host-Debug-Markierer Guest Debug Markers - Guest-Debug-Markierungen + Guest-Debug-Markierer Update @@ -742,7 +758,7 @@ Title Music - Title Music + Titelmusik Disable Trophy Pop-ups @@ -830,7 +846,7 @@ TrophyKey - Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. + Trophäenschlüssel:\nSchlüssel zum Entschlüsseln von Trophäen. Muss von Ihrer gejailbreakten Konsole abgerufen werden.\nDarf nur Hex-Zeichen enthalten. logTypeGroupBox @@ -850,7 +866,7 @@ disableTrophycheckBox - Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). + Trophäen-Popups deaktivieren:\nDeaktivieren Sie Trophäenbenachrichtigungen im Spiel. Der Trophäenfortschritt kann weiterhin mit dem Trophäen-Viewer verfolgt werden (klicken Sie mit der rechten Maustaste auf das Spiel im Hauptfenster).. hideCursorGroupBox @@ -977,7 +993,7 @@ CheatsPatches Cheats / Patches for - Cheats / Patches for + Cheats / Patches für defaultTextEdit_MSG From a55cec1954e62ffe2096aa136749283ffcbe6702 Mon Sep 17 00:00:00 2001 From: Martin <67326368+Martini-141@users.noreply.github.com> Date: Fri, 31 Jan 2025 07:35:31 +0100 Subject: [PATCH 56/72] add advdebug translation nb (#2296) * add advdebug translation nb * vvl is a project so no tr --- src/qt_gui/translations/nb.ts | 50 ++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/qt_gui/translations/nb.ts b/src/qt_gui/translations/nb.ts index 3e6f5fedd..bce5791af 100644 --- a/src/qt_gui/translations/nb.ts +++ b/src/qt_gui/translations/nb.ts @@ -629,7 +629,7 @@ Grafikk - Gui + GUI Grensesnitt @@ -680,6 +680,22 @@ Remove Fjern + + Save Data Path + Lagrede datamappe + + + Browse + Endre mappe + + + saveDataBox + Lagrede datamappe:\nListe over data shadPS4 lagrer. + + + browseButton + Endre mappe:\nEndrer hvilken mappe shadPS4 skal lagre data til. + Debug Feilretting @@ -690,7 +706,7 @@ Enable Vulkan Validation Layers - Aktiver Vulkan valideringslag + Aktiver Vulkan Validation Layers Enable Vulkan Synchronization Validation @@ -702,23 +718,23 @@ Enable Crash Diagnostics - Enable Crash Diagnostics + Aktiver krasjdiagnostikk Collect Shaders - Collect Shaders + Lagre skyggeleggere Copy GPU Buffers - Copy GPU Buffers + Kopier GPU-buffere Host Debug Markers - Host Debug Markers + Vertsfeilsøkingsmarkører Guest Debug Markers - Guest Debug Markers + Gjestefeilsøkingsmarkører Update @@ -742,7 +758,7 @@ Title Music - Title Music + Tittelmusikk Disable Trophy Pop-ups @@ -926,7 +942,7 @@ gameFoldersBox - Spillmapper:\nListen over mapper som brukes for å se etter installerte spill. + Spillmapper:\nListe over mapper som brukes for å se etter installerte spill. addFolderButton @@ -942,7 +958,7 @@ vkValidationCheckBox - Aktiver Vulkan valideringslag:\nAktiverer et system som validerer tilstanden til Vulkan-gjengiveren og logger informasjon om dens indre tilstand. Dette vil redusere ytelsen og sannsynligvis endre etterlignerens atferd. + Aktiver Vulkan Validation Layers:\nAktiverer et system som validerer tilstanden til Vulkan-gjengiveren og logger informasjon om dens indre tilstand. Dette vil redusere ytelsen og sannsynligvis endre etterlignerens atferd. vkSyncValidationCheckBox @@ -954,23 +970,23 @@ collectShaderCheckBox - Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + Lagre skyggeleggere:\nDu trenger dette aktivert for å redigere skyggeleggerne med feilsøkingsmenyen (Ctrl + F10). crashDiagnosticsCheckBox - Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + Krasjdiagnostikk:\nOppretter en .yaml-fil med informasjon om Vulkan-tilstanden ved krasj.\nNyttig for feilsøking 'Device lost' feil. Hvis du har dette aktivert, burde du aktivere vert OG gjestefeilsøkingsmarkører.\nFunker ikke med Intel GPU-er.\nDu trenger Vulkan Validation Layers og Vulkan SDK for at dette skal fungere. copyGPUBuffersCheckBox - Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + Kopier GPU-buffere:\nKommer rundt løpsforhold som involverer GPU-innsendinger.\nKan muligens hjelpe med PM4 type 0 krasj. hostMarkersCheckBox - Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Vertsfeilsøkingsmarkører:\nSetter inn etterligner-side informasjon som markører for spesifikke AMDGPU-kommandoer rundt Vulkan-kommandoer, i tillegg til å gi ressurser feilrettingsnavn.\nHvis du har dette aktivert, burde du aktivere krasjdiagnostikk.\nNyttig for programmer som RenderDoc. guestMarkersCheckBox - Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Gjestefeilsøkingsmarkører:\nSetter inn eventuelle feilsøkingsmarkører spillet selv har lagt til kommandobufferen.\nHvis du har dette aktivert, burde du aktivere krasjdiagnostikk.\nNyttig for programmer som RenderDoc. @@ -1015,6 +1031,10 @@ Delete File Slett fil + + Close + Lukk + No files selected. Ingen filer valgt. From ec7a5412633f68228dab2dc59b5c79ca4be0b1fb Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 31 Jan 2025 09:53:35 +0200 Subject: [PATCH 57/72] tagged 0.6.0 release --- src/common/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/version.h b/src/common/version.h index c903b1db6..0305b929e 100644 --- a/src/common/version.h +++ b/src/common/version.h @@ -8,7 +8,7 @@ namespace Common { -constexpr char VERSION[] = "0.5.1 WIP"; -constexpr bool isRelease = false; +constexpr char VERSION[] = "0.6.0"; +constexpr bool isRelease = true; } // namespace Common From 8057ed408c32ae30197b8ec027d5665fe5524adb Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 31 Jan 2025 10:33:17 +0200 Subject: [PATCH 58/72] started 0.6.1 WIP --- src/common/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/version.h b/src/common/version.h index 0305b929e..e7f6cc817 100644 --- a/src/common/version.h +++ b/src/common/version.h @@ -8,7 +8,7 @@ namespace Common { -constexpr char VERSION[] = "0.6.0"; -constexpr bool isRelease = true; +constexpr char VERSION[] = "0.6.1 WIP"; +constexpr bool isRelease = false; } // namespace Common From f3c33b29dd249aaf0c78985ff920762289a838ed Mon Sep 17 00:00:00 2001 From: pdaloxd <31321612+pablodrake@users.noreply.github.com> Date: Fri, 31 Jan 2025 09:50:02 +0100 Subject: [PATCH 59/72] Fix issue #1684 (#2277) * Added recursive game scan and only using game directories * Added recursion depth limit to scan directories * Added recursive search by ID in cli mode * Added recursive search to pkg installing --- src/common/path_util.cpp | 28 +++++++++++++++++++++++++ src/common/path_util.h | 15 +++++++++++++ src/main.cpp | 8 +++---- src/qt_gui/game_info.cpp | 35 ++++++++++++++++++++++++------- src/qt_gui/main.cpp | 8 +++---- src/qt_gui/main_window.cpp | 43 +++++++++++++++++++++++++++++++++----- 6 files changed, 117 insertions(+), 20 deletions(-) diff --git a/src/common/path_util.cpp b/src/common/path_util.cpp index 53eb123dc..a4312fada 100644 --- a/src/common/path_util.cpp +++ b/src/common/path_util.cpp @@ -176,6 +176,34 @@ void SetUserPath(PathType shad_path, const fs::path& new_path) { UserPaths.insert_or_assign(shad_path, new_path); } +std::optional FindGameByID(const fs::path& dir, const std::string& game_id, + int max_depth) { + if (max_depth < 0) { + return std::nullopt; + } + + // Check if this is the game we're looking for + if (dir.filename() == game_id && fs::exists(dir / "sce_sys" / "param.sfo")) { + auto eboot_path = dir / "eboot.bin"; + if (fs::exists(eboot_path)) { + return eboot_path; + } + } + + // Recursively search subdirectories + std::error_code ec; + for (const auto& entry : fs::directory_iterator(dir, ec)) { + if (!entry.is_directory()) { + continue; + } + if (auto found = FindGameByID(entry.path(), game_id, max_depth - 1)) { + return found; + } + } + + return std::nullopt; +} + #ifdef ENABLE_QT_GUI void PathToQString(QString& result, const std::filesystem::path& path) { #ifdef _WIN32 diff --git a/src/common/path_util.h b/src/common/path_util.h index 09b7a3337..7190378d6 100644 --- a/src/common/path_util.h +++ b/src/common/path_util.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #ifdef ENABLE_QT_GUI @@ -115,4 +116,18 @@ void PathToQString(QString& result, const std::filesystem::path& path); [[nodiscard]] std::filesystem::path PathFromQString(const QString& path); #endif +/** + * Recursively searches for a game directory by its ID. + * Limits search depth to prevent excessive filesystem traversal. + * + * @param dir Base directory to start the search from + * @param game_id The game ID to search for + * @param max_depth Maximum directory depth to search + * + * @returns Path to eboot.bin if found, std::nullopt otherwise + */ +[[nodiscard]] std::optional FindGameByID(const std::filesystem::path& dir, + const std::string& game_id, + int max_depth); + } // namespace Common::FS diff --git a/src/main.cpp b/src/main.cpp index fad3b1f53..6b334e446 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -167,12 +167,12 @@ int main(int argc, char* argv[]) { // Check if the provided path is a valid file if (!std::filesystem::exists(eboot_path)) { - // If not a file, treat it as a game ID and search in install directories + // If not a file, treat it as a game ID and search in install directories recursively bool game_found = false; + const int max_depth = 5; for (const auto& install_dir : Config::getGameInstallDirs()) { - const auto candidate_path = install_dir / game_path / "eboot.bin"; - if (std::filesystem::exists(candidate_path)) { - eboot_path = candidate_path; + if (auto found_path = Common::FS::FindGameByID(install_dir, game_path, max_depth)) { + eboot_path = *found_path; game_found = true; break; } diff --git a/src/qt_gui/game_info.cpp b/src/qt_gui/game_info.cpp index e4750fa1d..adbf392ed 100644 --- a/src/qt_gui/game_info.cpp +++ b/src/qt_gui/game_info.cpp @@ -7,6 +7,33 @@ #include "compatibility_info.h" #include "game_info.h" +// Maximum depth to search for games in subdirectories +const int max_recursion_depth = 5; + +void ScanDirectoryRecursively(const QString& dir, QStringList& filePaths, int current_depth = 0) { + // Stop recursion if we've reached the maximum depth + if (current_depth >= max_recursion_depth) { + return; + } + + QDir directory(dir); + QFileInfoList entries = directory.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + + for (const auto& entry : entries) { + if (entry.fileName().endsWith("-UPDATE")) { + continue; + } + + // Check if this directory contains a PS4 game (has sce_sys/param.sfo) + if (QFile::exists(entry.filePath() + "/sce_sys/param.sfo")) { + filePaths.append(entry.absoluteFilePath()); + } else { + // If not a game directory, recursively scan it with increased depth + ScanDirectoryRecursively(entry.absoluteFilePath(), filePaths, current_depth + 1); + } + } +} + GameInfoClass::GameInfoClass() = default; GameInfoClass::~GameInfoClass() = default; @@ -15,13 +42,7 @@ void GameInfoClass::GetGameInfo(QWidget* parent) { for (const auto& installLoc : Config::getGameInstallDirs()) { QString installDir; Common::FS::PathToQString(installDir, installLoc); - QDir parentFolder(installDir); - QFileInfoList fileList = parentFolder.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); - for (const auto& fileInfo : fileList) { - if (fileInfo.isDir() && !fileInfo.filePath().endsWith("-UPDATE")) { - filePaths.append(fileInfo.absoluteFilePath()); - } - } + ScanDirectoryRecursively(installDir, filePaths, 0); } m_games = QtConcurrent::mapped(filePaths, [&](const QString& path) { diff --git a/src/qt_gui/main.cpp b/src/qt_gui/main.cpp index 8babadc35..052f73f25 100644 --- a/src/qt_gui/main.cpp +++ b/src/qt_gui/main.cpp @@ -181,12 +181,12 @@ int main(int argc, char* argv[]) { // Check if the provided path is a valid file if (!std::filesystem::exists(game_file_path)) { - // If not a file, treat it as a game ID and search in install directories + // If not a file, treat it as a game ID and search in install directories recursively bool game_found = false; + const int max_depth = 5; for (const auto& install_dir : Config::getGameInstallDirs()) { - auto potential_game_path = install_dir / game_path / "eboot.bin"; - if (std::filesystem::exists(potential_game_path)) { - game_file_path = potential_game_path; + if (auto found_path = Common::FS::FindGameByID(install_dir, game_path, max_depth)) { + game_file_path = *found_path; game_found = true; break; } diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index 945210776..aa02d1237 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -747,12 +747,42 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int } std::filesystem::path game_install_dir = last_install_dir; - auto game_folder_path = game_install_dir / pkg.GetTitleID(); QString pkgType = QString::fromStdString(pkg.GetPkgFlags()); bool use_game_update = pkgType.contains("PATCH") && Config::getSeparateUpdateEnabled(); - auto game_update_path = use_game_update - ? game_install_dir / (std::string(pkg.GetTitleID()) + "-UPDATE") - : game_folder_path; + + // Default paths + auto game_folder_path = game_install_dir / pkg.GetTitleID(); + auto game_update_path = use_game_update ? game_folder_path.parent_path() / + (std::string{pkg.GetTitleID()} + "-UPDATE") + : game_folder_path; + const int max_depth = 5; + + if (pkgType.contains("PATCH")) { + // For patches, try to find the game recursively + auto found_game = Common::FS::FindGameByID(game_install_dir, + std::string{pkg.GetTitleID()}, max_depth); + if (found_game.has_value()) { + game_folder_path = found_game.value().parent_path(); + game_update_path = use_game_update ? game_folder_path.parent_path() / + (std::string{pkg.GetTitleID()} + "-UPDATE") + : game_folder_path; + } + } else { + // For base games, we check if the game is already installed + auto found_game = Common::FS::FindGameByID(game_install_dir, + std::string{pkg.GetTitleID()}, max_depth); + if (found_game.has_value()) { + game_folder_path = found_game.value().parent_path(); + } + // If the game is not found, we install it in the game install directory + else { + game_folder_path = game_install_dir / pkg.GetTitleID(); + } + game_update_path = use_game_update ? game_folder_path.parent_path() / + (std::string{pkg.GetTitleID()} + "-UPDATE") + : game_folder_path; + } + QString gameDirPath; Common::FS::PathToQString(gameDirPath, game_folder_path); QDir game_dir(gameDirPath); @@ -897,10 +927,13 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int connect(&futureWatcher, &QFutureWatcher::finished, this, [=, this]() { if (pkgNum == nPkg) { QString path; - Common::FS::PathToQString(path, game_install_dir); + + // We want to show the parent path instead of the full path + Common::FS::PathToQString(path, game_folder_path.parent_path()); QIcon windowIcon( Common::FS::PathToUTF8String(game_folder_path / "sce_sys/icon0.png") .c_str()); + QMessageBox extractMsgBox(this); extractMsgBox.setWindowTitle(tr("Extraction Finished")); if (!windowIcon.isNull()) { From 49fc210833e0cb80f87980556256e03e5cd6f57e Mon Sep 17 00:00:00 2001 From: Daniel Nylander Date: Fri, 31 Jan 2025 09:50:40 +0100 Subject: [PATCH 60/72] Updated Swedish translation (#2270) * Adding Swedish translation * Updated Swedish translation with additional strings Updated the Swedish translations using lupdate to found additional strings cd src/qt_gui/treanslations lupdate ../../../../shadPS4/ -tr-function-alias QT_TRANSLATE_NOOP+=TRANSLATE,QT_TRANSLATE_NOOP+=TRANSLATE_SV,QT_TRANSLATE_NOOP+=TRANSLATE_STR,QT_TRANSLATE_NOOP+=TRANSLATE_FS,QT_TRANSLATE_N_NOOP3+=TRANSLATE_FMT,QT_TRANSLATE_NOOP+=TRANSLATE_NOOP,translate+=TRANSLATE_PLURAL_STR,translate+=TRANSLATE_PLURAL_FS -no-obsolete -locations none -source-language en -ts sv.ts * Update sv.ts * Updated Swedish translation * Adding copyright boilerplate --- src/qt_gui/translations/sv.ts | 82 +++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 9 deletions(-) diff --git a/src/qt_gui/translations/sv.ts b/src/qt_gui/translations/sv.ts index c5fbce991..deefa99d8 100644 --- a/src/qt_gui/translations/sv.ts +++ b/src/qt_gui/translations/sv.ts @@ -1,9 +1,9 @@ - - + AboutDialog About shadPS4 @@ -252,6 +252,10 @@ ERROR FEL + + Close + Stäng + CheckUpdate @@ -676,6 +680,26 @@ Failed to convert icon. Misslyckades med att konvertera ikon. + + Open Update Folder + Öppna uppdateringsmapp + + + Delete Save Data + Ta bort sparat data + + + This game has no update folder to open! + Detta spel har ingen uppdateringsmapp att öppna! + + + This game has no save data to delete! + Detta spel har inget sparat data att ta bort! + + + Save Data + Sparat data + InstallDirSelect @@ -687,6 +711,14 @@ Select which directory you want to install to. Välj vilken katalog som du vill installera till. + + Install All Queued to Selected Folder + Installera alla köade till markerad mapp + + + Delete PKG File on Install + Ta bort PKG-fil efter installation + MainWindow @@ -1040,11 +1072,11 @@ Enable Separate Update Folder Aktivera separat uppdateringsmapp - - Default tab when opening settings - Standardflik när inställningar öppnas - - + + Default tab when opening settings + Standardflik när inställningar öppnas + + Show Game Size In List Visa spelstorlek i listan @@ -1142,7 +1174,7 @@ Advanced - Avancerat + Avancerat Enable Shaders Dumping @@ -1322,7 +1354,7 @@ updaterGroupBox - updaterGroupBox + Uppdatering:\nRelease: Officiella versioner som släpps varje månad som kan vara mycket utdaterade, men är mer pålitliga och testade.\nNightly: Utvecklingsversioner som har de senaste funktionerna och fixarna, men kan innehålla fel och är mindre stabila GUIMusicGroupBox @@ -1476,6 +1508,38 @@ Directory to install games Katalog att installera spel till + + Borderless + Fönster utan kanter + + + True + Sant + + + Enable Motion Controls + Aktivera rörelsekontroller + + + Save Data Path + Sökväg för sparat data + + + Browse + Bläddra + + + Directory to save data + Katalog för sparat data + + + saveDataBox + Sökväg för sparat data:\nSökvägen där spelets sparade data kommer att sparas + + + browseButton + Bläddra:\nBläddra efter en mapp att ställa in som sökväg för sparat data + TrophyViewer From ec0cf25097fdd746d220f3035e25e4dee82df778 Mon Sep 17 00:00:00 2001 From: panzone91 <150828896+panzone91@users.noreply.github.com> Date: Fri, 31 Jan 2025 09:51:03 +0100 Subject: [PATCH 61/72] libkernel: handle special case in path for load module (#2269) * libkernel: handle special case for load module * fix linting --- src/core/libraries/kernel/process.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/libraries/kernel/process.cpp b/src/core/libraries/kernel/process.cpp index c21257c50..a904152ff 100644 --- a/src/core/libraries/kernel/process.cpp +++ b/src/core/libraries/kernel/process.cpp @@ -41,8 +41,13 @@ s32 PS4_SYSV_ABI sceKernelLoadStartModule(const char* moduleFileName, size_t arg return ORBIS_KERNEL_ERROR_EINVAL; } + std::string guest_path(moduleFileName); + if (moduleFileName[0] != '/') { + guest_path = "/app0/" + guest_path; + } + auto* mnt = Common::Singleton::Instance(); - const auto path = mnt->GetHostPath(moduleFileName); + const auto path = mnt->GetHostPath(guest_path); // Load PRX module and relocate any modules that import it. auto* linker = Common::Singleton::Instance(); From 8aea0fc7eeccc2f3a8594634e3539c49e2411ac7 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 31 Jan 2025 12:54:16 +0200 Subject: [PATCH 62/72] Revert "libkernel: handle special case in path for load module (#2269)" (#2298) This reverts commit ec0cf25097fdd746d220f3035e25e4dee82df778. --- src/core/libraries/kernel/process.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/core/libraries/kernel/process.cpp b/src/core/libraries/kernel/process.cpp index a904152ff..c21257c50 100644 --- a/src/core/libraries/kernel/process.cpp +++ b/src/core/libraries/kernel/process.cpp @@ -41,13 +41,8 @@ s32 PS4_SYSV_ABI sceKernelLoadStartModule(const char* moduleFileName, size_t arg return ORBIS_KERNEL_ERROR_EINVAL; } - std::string guest_path(moduleFileName); - if (moduleFileName[0] != '/') { - guest_path = "/app0/" + guest_path; - } - auto* mnt = Common::Singleton::Instance(); - const auto path = mnt->GetHostPath(guest_path); + const auto path = mnt->GetHostPath(moduleFileName); // Load PRX module and relocate any modules that import it. auto* linker = Common::Singleton::Instance(); From eed4de1da9c5c76efd982a6172a4dcf68226c4a1 Mon Sep 17 00:00:00 2001 From: poly <47796739+polybiusproxy@users.noreply.github.com> Date: Fri, 31 Jan 2025 12:52:31 +0100 Subject: [PATCH 63/72] renderer_vulkan: use LDS buffer as SSBO on unsupported shared memory size (#2245) * renderer_vulkan: use LDS buffer as SSBO on unsupported shared memory size * shader_recompiler: add `v_trunc_f64` on inst format table --- .../spirv/emit_spirv_shared_memory.cpp | 74 +++++++++++++++---- .../backend/spirv/spirv_emit_context.cpp | 45 ++++++++--- .../backend/spirv/spirv_emit_context.h | 4 +- src/shader_recompiler/frontend/decode.cpp | 4 +- src/shader_recompiler/frontend/format.cpp | 4 +- src/shader_recompiler/info.h | 2 + src/shader_recompiler/profile.h | 1 + src/shader_recompiler/runtime_info.h | 1 - src/shader_recompiler/specialization.h | 9 +++ src/video_core/buffer_cache/buffer_cache.cpp | 6 +- src/video_core/buffer_cache/buffer_cache.h | 6 ++ .../renderer_vulkan/vk_compute_pipeline.cpp | 8 ++ .../renderer_vulkan/vk_pipeline_cache.cpp | 2 +- .../renderer_vulkan/vk_rasterizer.cpp | 17 ++++- 14 files changed, 147 insertions(+), 36 deletions(-) diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_shared_memory.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_shared_memory.cpp index 57ea476f1..6ab213864 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_shared_memory.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_shared_memory.cpp @@ -9,18 +9,33 @@ namespace Shader::Backend::SPIRV { Id EmitLoadSharedU32(EmitContext& ctx, Id offset) { const Id shift_id{ctx.ConstU32(2U)}; const Id index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift_id)}; - const Id pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, index)}; - return ctx.OpLoad(ctx.U32[1], pointer); + if (ctx.info.has_emulated_shared_memory) { + const Id pointer = + ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, ctx.u32_zero_value, index); + return ctx.OpLoad(ctx.U32[1], pointer); + } else { + const Id pointer = ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, index); + return ctx.OpLoad(ctx.U32[1], pointer); + } } Id EmitLoadSharedU64(EmitContext& ctx, Id offset) { const Id shift_id{ctx.ConstU32(2U)}; const Id base_index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift_id)}; const Id next_index{ctx.OpIAdd(ctx.U32[1], base_index, ctx.ConstU32(1U))}; - const Id lhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, base_index)}; - const Id rhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, next_index)}; - return ctx.OpCompositeConstruct(ctx.U32[2], ctx.OpLoad(ctx.U32[1], lhs_pointer), - ctx.OpLoad(ctx.U32[1], rhs_pointer)); + if (ctx.info.has_emulated_shared_memory) { + const Id lhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, + ctx.u32_zero_value, base_index)}; + const Id rhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, + ctx.u32_zero_value, next_index)}; + return ctx.OpCompositeConstruct(ctx.U32[2], ctx.OpLoad(ctx.U32[1], lhs_pointer), + ctx.OpLoad(ctx.U32[1], rhs_pointer)); + } else { + const Id lhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, base_index)}; + const Id rhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, next_index)}; + return ctx.OpCompositeConstruct(ctx.U32[2], ctx.OpLoad(ctx.U32[1], lhs_pointer), + ctx.OpLoad(ctx.U32[1], rhs_pointer)); + } } Id EmitLoadSharedU128(EmitContext& ctx, Id offset) { @@ -29,8 +44,14 @@ Id EmitLoadSharedU128(EmitContext& ctx, Id offset) { std::array values{}; for (u32 i = 0; i < 4; ++i) { const Id index{i == 0 ? base_index : ctx.OpIAdd(ctx.U32[1], base_index, ctx.ConstU32(i))}; - const Id pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, index)}; - values[i] = ctx.OpLoad(ctx.U32[1], pointer); + if (ctx.info.has_emulated_shared_memory) { + const Id pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, + ctx.u32_zero_value, index)}; + values[i] = ctx.OpLoad(ctx.U32[1], pointer); + } else { + const Id pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, index)}; + values[i] = ctx.OpLoad(ctx.U32[1], pointer); + } } return ctx.OpCompositeConstruct(ctx.U32[4], values); } @@ -38,18 +59,33 @@ Id EmitLoadSharedU128(EmitContext& ctx, Id offset) { void EmitWriteSharedU32(EmitContext& ctx, Id offset, Id value) { const Id shift{ctx.ConstU32(2U)}; const Id word_offset{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift)}; - const Id pointer = ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, word_offset); - ctx.OpStore(pointer, value); + if (ctx.info.has_emulated_shared_memory) { + const Id pointer = ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, + ctx.u32_zero_value, word_offset); + ctx.OpStore(pointer, value); + } else { + const Id pointer = ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, word_offset); + ctx.OpStore(pointer, value); + } } void EmitWriteSharedU64(EmitContext& ctx, Id offset, Id value) { const Id shift{ctx.ConstU32(2U)}; const Id word_offset{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift)}; const Id next_offset{ctx.OpIAdd(ctx.U32[1], word_offset, ctx.ConstU32(1U))}; - const Id lhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, word_offset)}; - const Id rhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, next_offset)}; - ctx.OpStore(lhs_pointer, ctx.OpCompositeExtract(ctx.U32[1], value, 0U)); - ctx.OpStore(rhs_pointer, ctx.OpCompositeExtract(ctx.U32[1], value, 1U)); + if (ctx.info.has_emulated_shared_memory) { + const Id lhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, + ctx.u32_zero_value, word_offset)}; + const Id rhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, + ctx.u32_zero_value, next_offset)}; + ctx.OpStore(lhs_pointer, ctx.OpCompositeExtract(ctx.U32[1], value, 0U)); + ctx.OpStore(rhs_pointer, ctx.OpCompositeExtract(ctx.U32[1], value, 1U)); + } else { + const Id lhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, word_offset)}; + const Id rhs_pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, next_offset)}; + ctx.OpStore(lhs_pointer, ctx.OpCompositeExtract(ctx.U32[1], value, 0U)); + ctx.OpStore(rhs_pointer, ctx.OpCompositeExtract(ctx.U32[1], value, 1U)); + } } void EmitWriteSharedU128(EmitContext& ctx, Id offset, Id value) { @@ -57,8 +93,14 @@ void EmitWriteSharedU128(EmitContext& ctx, Id offset, Id value) { const Id base_index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift)}; for (u32 i = 0; i < 4; ++i) { const Id index{i == 0 ? base_index : ctx.OpIAdd(ctx.U32[1], base_index, ctx.ConstU32(i))}; - const Id pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, index)}; - ctx.OpStore(pointer, ctx.OpCompositeExtract(ctx.U32[1], value, i)); + if (ctx.info.has_emulated_shared_memory) { + const Id pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, + ctx.u32_zero_value, index)}; + ctx.OpStore(pointer, ctx.OpCompositeExtract(ctx.U32[1], value, i)); + } else { + const Id pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, index)}; + ctx.OpStore(pointer, ctx.OpCompositeExtract(ctx.U32[1], value, i)); + } } } diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index b0bf5aa0a..2a0c28563 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -65,17 +65,17 @@ void Name(EmitContext& ctx, Id object, std::string_view format_str, Args&&... ar } // Anonymous namespace -EmitContext::EmitContext(const Profile& profile_, const RuntimeInfo& runtime_info_, - const Info& info_, Bindings& binding_) +EmitContext::EmitContext(const Profile& profile_, const RuntimeInfo& runtime_info_, Info& info_, + Bindings& binding_) : Sirit::Module(profile_.supported_spirv), info{info_}, runtime_info{runtime_info_}, profile{profile_}, stage{info.stage}, l_stage{info.l_stage}, binding{binding_} { AddCapability(spv::Capability::Shader); DefineArithmeticTypes(); DefineInterfaces(); + DefineSharedMemory(); DefineBuffers(); DefineTextureBuffers(); DefineImagesAndSamplers(); - DefineSharedMemory(); } EmitContext::~EmitContext() = default; @@ -852,20 +852,45 @@ void EmitContext::DefineSharedMemory() { if (!info.uses_shared) { return; } + const u32 max_shared_memory_size = profile.max_shared_memory_size; u32 shared_memory_size = runtime_info.cs_info.shared_memory_size; if (shared_memory_size == 0) { shared_memory_size = DefaultSharedMemSize; } - const u32 max_shared_memory_size = runtime_info.cs_info.max_shared_memory_size; - ASSERT(shared_memory_size <= max_shared_memory_size); - const u32 num_elements{Common::DivCeil(shared_memory_size, 4U)}; const Id type{TypeArray(U32[1], ConstU32(num_elements))}; - shared_memory_u32_type = TypePointer(spv::StorageClass::Workgroup, type); - shared_u32 = TypePointer(spv::StorageClass::Workgroup, U32[1]); - shared_memory_u32 = AddGlobalVariable(shared_memory_u32_type, spv::StorageClass::Workgroup); - interfaces.push_back(shared_memory_u32); + + if (shared_memory_size <= max_shared_memory_size) { + shared_memory_u32_type = TypePointer(spv::StorageClass::Workgroup, type); + shared_u32 = TypePointer(spv::StorageClass::Workgroup, U32[1]); + shared_memory_u32 = AddGlobalVariable(shared_memory_u32_type, spv::StorageClass::Workgroup); + Name(shared_memory_u32, "shared_mem"); + interfaces.push_back(shared_memory_u32); + } else { + shared_memory_u32_type = TypePointer(spv::StorageClass::StorageBuffer, type); + shared_u32 = TypePointer(spv::StorageClass::StorageBuffer, U32[1]); + + Decorate(type, spv::Decoration::ArrayStride, 4); + + const Id struct_type{TypeStruct(type)}; + Name(struct_type, "shared_memory_buf"); + Decorate(struct_type, spv::Decoration::Block); + MemberName(struct_type, 0, "data"); + MemberDecorate(struct_type, 0, spv::Decoration::Offset, 0U); + + const Id struct_pointer_type{TypePointer(spv::StorageClass::StorageBuffer, struct_type)}; + const Id ssbo_id{AddGlobalVariable(struct_pointer_type, spv::StorageClass::StorageBuffer)}; + Decorate(ssbo_id, spv::Decoration::Binding, binding.unified++); + Decorate(ssbo_id, spv::Decoration::DescriptorSet, 0U); + Name(ssbo_id, "shared_mem_ssbo"); + + shared_memory_u32 = ssbo_id; + + info.has_emulated_shared_memory = true; + info.shared_memory_size = shared_memory_size; + interfaces.push_back(ssbo_id); + } } } // namespace Shader::Backend::SPIRV diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.h b/src/shader_recompiler/backend/spirv/spirv_emit_context.h index f552055c0..ab42ecc5b 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.h +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.h @@ -37,7 +37,7 @@ struct VectorIds { class EmitContext final : public Sirit::Module { public: - explicit EmitContext(const Profile& profile, const RuntimeInfo& runtime_info, const Info& info, + explicit EmitContext(const Profile& profile, const RuntimeInfo& runtime_info, Info& info, Bindings& binding); ~EmitContext(); @@ -132,7 +132,7 @@ public: return ConstantComposite(type, constituents); } - const Info& info; + Info& info; const RuntimeInfo& runtime_info; const Profile& profile; Stage stage; diff --git a/src/shader_recompiler/frontend/decode.cpp b/src/shader_recompiler/frontend/decode.cpp index a5187aebd..20b78e869 100644 --- a/src/shader_recompiler/frontend/decode.cpp +++ b/src/shader_recompiler/frontend/decode.cpp @@ -259,9 +259,9 @@ void GcnDecodeContext::updateInstructionMeta(InstEncoding encoding) { ASSERT_MSG(instFormat.src_type != ScalarType::Undefined && instFormat.dst_type != ScalarType::Undefined, - "Instruction format table incomplete for opcode {} ({}, encoding = {})", + "Instruction format table incomplete for opcode {} ({}, encoding = 0x{:x})", magic_enum::enum_name(m_instruction.opcode), u32(m_instruction.opcode), - magic_enum::enum_name(encoding)); + u32(encoding)); m_instruction.inst_class = instFormat.inst_class; m_instruction.category = instFormat.inst_category; diff --git a/src/shader_recompiler/frontend/format.cpp b/src/shader_recompiler/frontend/format.cpp index 2fcac7c10..76b1cc818 100644 --- a/src/shader_recompiler/frontend/format.cpp +++ b/src/shader_recompiler/frontend/format.cpp @@ -1836,7 +1836,9 @@ constexpr std::array InstructionFormatVOP1 = {{ {InstClass::VectorConv, InstCategory::VectorALU, 1, 1, ScalarType::Float64, ScalarType::Uint32}, // 22 = V_CVT_F64_U32 {InstClass::VectorConv, InstCategory::VectorALU, 1, 1, ScalarType::Uint32, ScalarType::Float64}, - {}, + // 23 = V_TRUNC_F64 + {InstClass::VectorConv, InstCategory::VectorALU, 1, 1, ScalarType::Float64, + ScalarType::Float64}, {}, {}, {}, diff --git a/src/shader_recompiler/info.h b/src/shader_recompiler/info.h index 2cde30629..9469eaad7 100644 --- a/src/shader_recompiler/info.h +++ b/src/shader_recompiler/info.h @@ -207,7 +207,9 @@ struct Info { bool stores_tess_level_outer{}; bool stores_tess_level_inner{}; bool translation_failed{}; // indicates that shader has unsupported instructions + bool has_emulated_shared_memory{}; bool has_readconst{}; + u32 shared_memory_size{}; u8 mrt_mask{0u}; bool has_fetch_shader{false}; u32 fetch_shader_sgpr_base{0u}; diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h index f8b91a283..f359a7dcc 100644 --- a/src/shader_recompiler/profile.h +++ b/src/shader_recompiler/profile.h @@ -32,6 +32,7 @@ struct Profile { u64 min_ssbo_alignment{}; u32 max_viewport_width{}; u32 max_viewport_height{}; + u32 max_shared_memory_size{}; }; } // namespace Shader diff --git a/src/shader_recompiler/runtime_info.h b/src/shader_recompiler/runtime_info.h index 103c1faa8..138a707b3 100644 --- a/src/shader_recompiler/runtime_info.h +++ b/src/shader_recompiler/runtime_info.h @@ -201,7 +201,6 @@ struct FragmentRuntimeInfo { struct ComputeRuntimeInfo { u32 shared_memory_size; - u32 max_shared_memory_size; std::array workgroup_size; std::array tgid_enable; diff --git a/src/shader_recompiler/specialization.h b/src/shader_recompiler/specialization.h index eb0085965..2083d11a9 100644 --- a/src/shader_recompiler/specialization.h +++ b/src/shader_recompiler/specialization.h @@ -101,6 +101,9 @@ struct StageSpecialization { }); } u32 binding{}; + if (info->has_emulated_shared_memory) { + binding++; + } if (info->has_readconst) { binding++; } @@ -197,9 +200,15 @@ struct StageSpecialization { } } u32 binding{}; + if (info->has_emulated_shared_memory != other.info->has_emulated_shared_memory) { + return false; + } if (info->has_readconst != other.info->has_readconst) { return false; } + if (info->has_emulated_shared_memory) { + binding++; + } if (info->has_readconst) { binding++; } diff --git a/src/video_core/buffer_cache/buffer_cache.cpp b/src/video_core/buffer_cache/buffer_cache.cpp index 11ad0e96f..c779c1c45 100644 --- a/src/video_core/buffer_cache/buffer_cache.cpp +++ b/src/video_core/buffer_cache/buffer_cache.cpp @@ -17,7 +17,7 @@ namespace VideoCore { -static constexpr size_t GdsBufferSize = 64_KB; +static constexpr size_t DataShareBufferSize = 64_KB; static constexpr size_t StagingBufferSize = 1_GB; static constexpr size_t UboStreamBufferSize = 64_MB; @@ -28,9 +28,11 @@ BufferCache::BufferCache(const Vulkan::Instance& instance_, Vulkan::Scheduler& s texture_cache{texture_cache_}, tracker{tracker_}, staging_buffer{instance, scheduler, MemoryUsage::Upload, StagingBufferSize}, stream_buffer{instance, scheduler, MemoryUsage::Stream, UboStreamBufferSize}, - gds_buffer{instance, scheduler, MemoryUsage::Stream, 0, AllFlags, GdsBufferSize}, + gds_buffer{instance, scheduler, MemoryUsage::Stream, 0, AllFlags, DataShareBufferSize}, + lds_buffer{instance, scheduler, MemoryUsage::DeviceLocal, 0, AllFlags, DataShareBufferSize}, memory_tracker{&tracker} { Vulkan::SetObjectName(instance.GetDevice(), gds_buffer.Handle(), "GDS Buffer"); + Vulkan::SetObjectName(instance.GetDevice(), lds_buffer.Handle(), "LDS Buffer"); // Ensure the first slot is used for the null buffer const auto null_id = diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 575ee2c60..088c22c12 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -68,6 +68,11 @@ public: return &gds_buffer; } + /// Returns a pointer to LDS device local buffer. + [[nodiscard]] const Buffer* GetLdsBuffer() const noexcept { + return &lds_buffer; + } + /// Retrieves the buffer with the specified id. [[nodiscard]] Buffer& GetBuffer(BufferId id) { return slot_buffers[id]; @@ -154,6 +159,7 @@ private: StreamBuffer staging_buffer; StreamBuffer stream_buffer; Buffer gds_buffer; + Buffer lds_buffer; std::shared_mutex mutex; Common::SlotVector slot_buffers; RangeSet gpu_modified_ranges; diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp index 23faacfc2..afa598fca 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp @@ -29,6 +29,14 @@ ComputePipeline::ComputePipeline(const Instance& instance_, Scheduler& scheduler u32 binding{}; boost::container::small_vector bindings; + if (info->has_emulated_shared_memory) { + bindings.push_back({ + .binding = binding++, + .descriptorType = vk::DescriptorType::eStorageBuffer, + .descriptorCount = 1, + .stageFlags = vk::ShaderStageFlagBits::eCompute, + }); + } if (info->has_readconst) { bindings.push_back({ .binding = binding++, diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 3728a55fb..629899a33 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -180,7 +180,6 @@ const Shader::RuntimeInfo& PipelineCache::BuildRuntimeInfo(Stage stage, LogicalS info.cs_info.tgid_enable = {cs_pgm.IsTgidEnabled(0), cs_pgm.IsTgidEnabled(1), cs_pgm.IsTgidEnabled(2)}; info.cs_info.shared_memory_size = cs_pgm.SharedMemSize(); - info.cs_info.max_shared_memory_size = instance.MaxComputeSharedMemorySize(); break; } default: @@ -209,6 +208,7 @@ PipelineCache::PipelineCache(const Instance& instance_, Scheduler& scheduler_, instance.GetDriverID() == vk::DriverId::eMoltenvk, .max_viewport_width = instance.GetMaxViewportWidth(), .max_viewport_height = instance.GetMaxViewportHeight(), + .max_shared_memory_size = instance.MaxComputeSharedMemorySize(), }; auto [cache_result, cache] = instance.GetDevice().createPipelineCacheUnique({}); ASSERT_MSG(cache_result == vk::Result::eSuccess, "Failed to create pipeline cache: {}", diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index fde87fcfb..1c90c6c27 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -175,7 +175,7 @@ RenderState Rasterizer::PrepareRenderState(u32 mrt_mask) { const bool is_depth_clear = regs.depth_render_control.depth_clear_enable || texture_cache.IsMetaCleared(htile_address, slice); const bool is_stencil_clear = regs.depth_render_control.stencil_clear_enable; - ASSERT(desc.view_info.range.extent.layers == 1); + ASSERT(desc.view_info.range.extent.levels == 1); state.width = std::min(state.width, image.info.size.width); state.height = std::min(state.height, image.info.size.height); @@ -554,6 +554,21 @@ void Rasterizer::BindBuffers(const Shader::Info& stage, Shader::Backend::Binding } } + // Bind a SSBO to act as shared memory in case of not being able to use a workgroup buffer + // (e.g. when the compute shared memory is bigger than the GPU's shared memory) + if (stage.has_emulated_shared_memory) { + const auto* lds_buf = buffer_cache.GetLdsBuffer(); + buffer_infos.emplace_back(lds_buf->Handle(), 0, lds_buf->SizeBytes()); + set_writes.push_back({ + .dstSet = VK_NULL_HANDLE, + .dstBinding = binding.unified++, + .dstArrayElement = 0, + .descriptorCount = 1, + .descriptorType = vk::DescriptorType::eStorageBuffer, + .pBufferInfo = &buffer_infos.back(), + }); + } + // Bind the flattened user data buffer as a UBO so it's accessible to the shader if (stage.has_readconst) { const auto [vk_buffer, offset] = buffer_cache.ObtainHostUBO(stage.flattened_ud_buf); From fda8f1afa37210861c3684edc4b51c9003b7b89c Mon Sep 17 00:00:00 2001 From: Sn0wCrack <442287+Sn0wCrack@users.noreply.github.com> Date: Fri, 31 Jan 2025 23:22:57 +1100 Subject: [PATCH 64/72] feat: set desktop file name to get icon on wayland (#2299) --- src/qt_gui/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt_gui/main.cpp b/src/qt_gui/main.cpp index 052f73f25..36dc226ae 100644 --- a/src/qt_gui/main.cpp +++ b/src/qt_gui/main.cpp @@ -26,6 +26,8 @@ int main(int argc, char* argv[]) { QApplication a(argc, argv); + QApplication::setDesktopFileName("net.shadps4.shadPS4"); + // Load configurations and initialize Qt application const auto user_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); Config::load(user_dir / "config.toml"); From f3810cebeacbf85496b2bb153374d5fcfcdfbedf Mon Sep 17 00:00:00 2001 From: jarred wilson <20207921+jardon@users.noreply.github.com> Date: Fri, 31 Jan 2025 06:55:14 -0600 Subject: [PATCH 65/72] add 0.6.0 release to metainfo (#2300) --- dist/net.shadps4.shadPS4.metainfo.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dist/net.shadps4.shadPS4.metainfo.xml b/dist/net.shadps4.shadPS4.metainfo.xml index d8f51baac..c8c9d5c23 100644 --- a/dist/net.shadps4.shadPS4.metainfo.xml +++ b/dist/net.shadps4.shadPS4.metainfo.xml @@ -37,6 +37,9 @@ Game + + https://github.com/shadps4-emu/shadPS4/releases/tag/v.0.6.0 + https://github.com/shadps4-emu/shadPS4/releases/tag/v.0.5.0 From c4bfaa60312c6e224c26eca9a00b7b573253aa42 Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Fri, 31 Jan 2025 15:36:14 +0100 Subject: [PATCH 66/72] Added keyboard and mouse input remapping, mouse movement to joystick logic, GUI and more (#1356) * added support for loading keyboard config from file * final minor update before pull request * fix messing up the merge * fix waitEvent to correctly handle mouse inputs * add license * Applied coding style fixes * clang-format fucked up the .ini file * actually fix clang changing ini syntax use relative path for the ini file * remove big commented out code blocks, and fixed platform-dependent code * fix windows hating me * added mouse config option * added toggle for mouse movement input (f7) * fix license and style * add numpad support i accidentally left out * added support for mouse wheel (to buttons only) * if keyboard config doesn't exist, autogenerate it * added keybinds for "walk mode" * Mouse movement input is now off by default * code cleanup and misc fixes * delete config file since it is now autogenerated * F6 = F7 + F9 * added better mouse handling with config options * Added capslock support * fix clang-format * Added support for mod key toggle key * F6 and F7 are removed, F9 captures and enables the mouse * Encapsulated globals and new classes in a new namespace * Added mouse side button support * Added per-game config * relocated input parser to the new namespace * changed parser parameters to make it possible to use it from the gui * added home, end, pgup and pgdown * Resolved merge conflict and refactored code * Updated default keybindings * Changed input handling to be single-threaded * General code cleanup * Start working on new backend * Mouse polling, CMakeLists, and basic framework * Output update handling, and reworked file creating, reading and parsing * Parsing works now * Single key button inputs work now * Axis outputs work now * Wheel works now (for me), l2/r2 handling improvements, and misc bugfixes * Downgraded prints to log_debug, and implemented input hierarchy * Implemented key toggle * Added mouse parameter parsing * clang-format * Fixed clang and added a const keyword for mac * Fix input hierarchy * Fixed joysick halfmodes, and possibly the last update on input hierarchy * clang-format * Rewrote the default config to reflect new changes * clang * Update code style * Updated sorting to accomodate for that one specific edge case * Fix default config and the latest bug with input hiearchy * Fix typo * Temporarily added my GUI * Update cmakelists * Possible fix for Gravity Rush * Update Help text, default config, and clang * Updated README with the new keybind info * okay so maybe the gravity rush fix might have slightly broken the joystick halfmode and key toggle * Fixed mistakenly overwriting the last opened config with the default one if the GUI is opened multiple times in a session * Updated Help descriptions and fixed mouse movement default parameters * Fix crash if the Help dialog was opened a second time If it's closed with the top right close button instead of clicking the Help button again, a required flag wasn't reset, making the next click on Help try to close a nonexistent window and segfault * Added closing the config also closing the Help window, and fixed more segfaults due to mismatched flags * Initial controller support * clang and debug print cleanup * Initial axis-to-button logic * Updated Help text * Added 'Reset to Default' button in GUI * Minor text and description updates + fixed an issue with Help text box rendering * Fix button-to-touchpad logic and l2/r2 handling, as they are both axes and buttons The touchpad's button state was correctly handled, so games that use that were fine, but the touchDown flag was always set to true, so games that use this flag had problems, like Gravity Rush * Fix merge conflict * Clang * Added back back button to touchpad binding * Added touchpad button handling * Added end-of-line comments and fixed some crashes happening with the VS debugger * Apply recent changes from kbm-only * Deadzone + initial directional axis-to-button mapping * Added that one missing space in the README. Are you all happy now? * Fixups from making everything use SDL * Revert directional joystick code and fix a memory leak * Change config directory name again to conform to project standards * Clang * Revert the old deeadzone code and properly add the new one * Clang --- CMakeLists.txt | 8 + README.md | 56 +-- src/common/config.cpp | 121 +++++- src/common/config.h | 5 +- src/core/libraries/pad/pad.cpp | 8 +- src/imgui/renderer/imgui_core.cpp | 2 +- src/input/input_handler.cpp | 676 ++++++++++++++++++++++++++++++ src/input/input_handler.h | 407 ++++++++++++++++++ src/input/input_mouse.cpp | 74 ++++ src/input/input_mouse.h | 18 + src/qt_gui/kbm_config_dialog.cpp | 237 +++++++++++ src/qt_gui/kbm_config_dialog.h | 38 ++ src/qt_gui/kbm_help_dialog.cpp | 112 +++++ src/qt_gui/kbm_help_dialog.h | 169 ++++++++ src/qt_gui/main_window.cpp | 10 + src/sdl_window.cpp | 336 +++++---------- src/sdl_window.h | 5 +- 17 files changed, 1996 insertions(+), 286 deletions(-) create mode 100644 src/input/input_handler.cpp create mode 100644 src/input/input_handler.h create mode 100644 src/input/input_mouse.cpp create mode 100644 src/input/input_mouse.h create mode 100644 src/qt_gui/kbm_config_dialog.cpp create mode 100644 src/qt_gui/kbm_config_dialog.h create mode 100644 src/qt_gui/kbm_help_dialog.cpp create mode 100644 src/qt_gui/kbm_help_dialog.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e10fcfb98..4822658c6 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -854,6 +854,10 @@ set(IMGUI src/imgui/imgui_config.h set(INPUT src/input/controller.cpp src/input/controller.h + src/input/input_handler.cpp + src/input/input_handler.h + src/input/input_mouse.cpp + src/input/input_mouse.h ) set(EMULATOR src/emulator.cpp @@ -903,6 +907,10 @@ set(QT_GUI src/qt_gui/about_dialog.cpp src/qt_gui/trophy_viewer.h src/qt_gui/elf_viewer.cpp src/qt_gui/elf_viewer.h + src/qt_gui/kbm_config_dialog.cpp + src/qt_gui/kbm_config_dialog.h + src/qt_gui/kbm_help_dialog.cpp + src/qt_gui/kbm_help_dialog.h src/qt_gui/main_window_themes.cpp src/qt_gui/main_window_themes.h src/qt_gui/settings_dialog.cpp diff --git a/README.md b/README.md index 30efeb263..0e5ba7e39 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Check the build instructions for [**macOS**](https://github.com/shadps4-emu/shad For more information on how to test, debug and report issues with the emulator or games, read the [**Debugging documentation**](https://github.com/shadps4-emu/shadPS4/blob/main/documents/Debugging/Debugging.md). -# Keyboard mapping +# Keyboard and Mouse Mappings > [!NOTE] > Some keyboards may also require you to hold the Fn key to use the F\* keys. Mac users should use the Command key instead of Control, and need to use Command+F11 for full screen to avoid conflicting with system key bindings. @@ -92,32 +92,34 @@ F12 | Trigger RenderDoc Capture > [!NOTE] > Xbox and DualShock controllers work out of the box. -| Controller button | Keyboard equivalent | -|-------------|-------------| -LEFT AXIS UP | W | -LEFT AXIS DOWN | S | -LEFT AXIS LEFT | A | -LEFT AXIS RIGHT | D | -RIGHT AXIS UP | I | -RIGHT AXIS DOWN | K | -RIGHT AXIS LEFT | J | -RIGHT AXIS RIGHT | L | -TRIANGLE | Numpad 8 or C | -CIRCLE | Numpad 6 or B | -CROSS | Numpad 2 or N | -SQUARE | Numpad 4 or V | -PAD UP | UP | -PAD DOWN | DOWN | -PAD LEFT | LEFT | -PAD RIGHT | RIGHT | -OPTIONS | RETURN | -BACK BUTTON / TOUCH PAD | SPACE | -L1 | Q | -R1 | U | -L2 | E | -R2 | O | -L3 | X | -R3 | M | +The default controls are inspired by the *Elden Ring* PC controls. Inputs support up to three keys per binding, mouse buttons, mouse movement mapped to joystick input, and more. + +| Action | Default Key(s) | +|-------------|-----------------------------| +| Triangle | F | +| Circle | Space | +| Cross | E | +| Square | R | +| Pad Up | W, LAlt / Mouse Wheel Up | +| Pad Down | S, LAlt / Mouse Wheel Down | +| Pad Left | A, LAlt / Mouse Wheel Left | +| Pad Right | D, LAlt / Mouse Wheel Right | +| L1 | Right Button, LShift | +| R1 | Left Button | +| L2 | Right Button | +| R2 | Left Button, LShift | +| L3 | X | +| R3 | Q / Middle Button | +| Options | Escape | +| Touchpad | G | + +| Joystick | Default Input | +|--------------------|----------------| +| Left Joystick | WASD | +| Right Joystick | Mouse movement | + +Keyboard and mouse inputs can be customized in the settings menu by clicking the Controller button, and further details and help on controls are also found there. Custom bindings are saved per-game. + # Main team diff --git a/src/common/config.cpp b/src/common/config.cpp index 70b062951..e79a52796 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -46,8 +46,6 @@ static std::string logType = "async"; static std::string userName = "shadPS4"; static std::string updateChannel; static std::string chooseHomeTab; -static u16 deadZoneLeft = 2.0; -static u16 deadZoneRight = 2.0; static std::string backButtonBehavior = "left"; static bool useSpecialPad = false; static int specialPadClass = 1; @@ -151,14 +149,6 @@ bool getEnableDiscordRPC() { return enableDiscordRPC; } -u16 leftDeadZone() { - return deadZoneLeft; -} - -u16 rightDeadZone() { - return deadZoneRight; -} - s16 getCursorState() { return cursorState; } @@ -661,8 +651,6 @@ void load(const std::filesystem::path& path) { if (data.contains("Input")) { const toml::value& input = data.at("Input"); - deadZoneLeft = toml::find_or(input, "deadZoneLeft", 2.0); - deadZoneRight = toml::find_or(input, "deadZoneRight", 2.0); cursorState = toml::find_or(input, "cursorState", HideCursorState::Idle); cursorHideTimeout = toml::find_or(input, "cursorHideTimeout", 5); backButtonBehavior = toml::find_or(input, "backButtonBehavior", "left"); @@ -785,8 +773,6 @@ void save(const std::filesystem::path& path) { data["General"]["separateUpdateEnabled"] = separateupdatefolder; data["General"]["compatibilityEnabled"] = compatibilityData; data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup; - data["Input"]["deadZoneLeft"] = deadZoneLeft; - data["Input"]["deadZoneRight"] = deadZoneRight; data["Input"]["cursorState"] = cursorState; data["Input"]["cursorHideTimeout"] = cursorHideTimeout; data["Input"]["backButtonBehavior"] = backButtonBehavior; @@ -919,4 +905,109 @@ void setDefaultValues() { checkCompatibilityOnStartup = false; } -} // namespace Config \ No newline at end of file +constexpr std::string_view GetDefaultKeyboardConfig() { + return R"(#Feeling lost? Check out the Help section! + +#Keyboard bindings + +triangle = f +circle = space +cross = e +square = r + +pad_up = w, lalt +pad_up = mousewheelup +pad_down = s, lalt +pad_down = mousewheeldown +pad_left = a, lalt +pad_left = mousewheelleft +pad_right = d, lalt +pad_right = mousewheelright + +l1 = rightbutton, lshift +r1 = leftbutton +l2 = rightbutton +r2 = leftbutton, lshift +l3 = x +r3 = q +r3 = middlebutton + +options = escape +touchpad = g + +key_toggle = i, lalt +mouse_to_joystick = right +mouse_movement_params = 0.5, 1, 0.125 +leftjoystick_halfmode = lctrl + +axis_left_x_minus = a +axis_left_x_plus = d +axis_left_y_minus = w +axis_left_y_plus = s + +#Controller bindings + +triangle = triangle +cross = cross +square = square +circle = circle + +l1 = l1 +l2 = l2 +l3 = l3 +r1 = r1 +r2 = r2 +r3 = r3 + +pad_up = pad_up +pad_down = pad_down +pad_left = pad_left +pad_right = pad_right + +options = options +touchpad = back + +axis_left_x = axis_left_x +axis_left_y = axis_left_y + +axis_right_x = axis_right_x +axis_right_y = axis_right_y +)"; +} +std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id) { + // Read configuration file of the game, and if it doesn't exist, generate it from default + // If that doesn't exist either, generate that from getDefaultConfig() and try again + // If even the folder is missing, we start with that. + + const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "input_config"; + const auto config_file = config_dir / (game_id + ".ini"); + const auto default_config_file = config_dir / "default.ini"; + + // Ensure the config directory exists + if (!std::filesystem::exists(config_dir)) { + std::filesystem::create_directories(config_dir); + } + + // Check if the default config exists + if (!std::filesystem::exists(default_config_file)) { + // If the default config is also missing, create it from getDefaultConfig() + const auto default_config = GetDefaultKeyboardConfig(); + std::ofstream default_config_stream(default_config_file); + if (default_config_stream) { + default_config_stream << default_config; + } + } + + // if empty, we only need to execute the function up until this point + if (game_id.empty()) { + return default_config_file; + } + + // If game-specific config doesn't exist, create it from the default config + if (!std::filesystem::exists(config_file)) { + std::filesystem::copy(default_config_file, config_file); + } + return config_file; +} + +} // namespace Config diff --git a/src/common/config.h b/src/common/config.h index 356cf77fc..f726f840c 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -37,8 +37,6 @@ std::string getUserName(); std::string getUpdateChannel(); std::string getChooseHomeTab(); -u16 leftDeadZone(); -u16 rightDeadZone(); s16 getCursorState(); int getCursorHideTimeout(); std::string getBackButtonBehavior(); @@ -152,6 +150,9 @@ std::string getEmulatorLanguage(); void setDefaultValues(); +// todo: name and function location pending +std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id = ""); + // settings u32 GetLanguage(); }; // namespace Config diff --git a/src/core/libraries/pad/pad.cpp b/src/core/libraries/pad/pad.cpp index 18709bcb2..173b78382 100644 --- a/src/core/libraries/pad/pad.cpp +++ b/src/core/libraries/pad/pad.cpp @@ -95,8 +95,8 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn pInfo->touchPadInfo.pixelDensity = 1; pInfo->touchPadInfo.resolution.x = 1920; pInfo->touchPadInfo.resolution.y = 950; - pInfo->stickInfo.deadZoneLeft = Config::leftDeadZone(); - pInfo->stickInfo.deadZoneRight = Config::rightDeadZone(); + pInfo->stickInfo.deadZoneLeft = 1; + pInfo->stickInfo.deadZoneRight = 1; pInfo->connectionType = ORBIS_PAD_PORT_TYPE_STANDARD; pInfo->connectedCount = 1; pInfo->connected = false; @@ -106,8 +106,8 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn pInfo->touchPadInfo.pixelDensity = 1; pInfo->touchPadInfo.resolution.x = 1920; pInfo->touchPadInfo.resolution.y = 950; - pInfo->stickInfo.deadZoneLeft = Config::leftDeadZone(); - pInfo->stickInfo.deadZoneRight = Config::rightDeadZone(); + pInfo->stickInfo.deadZoneLeft = 1; + pInfo->stickInfo.deadZoneRight = 1; pInfo->connectionType = ORBIS_PAD_PORT_TYPE_STANDARD; pInfo->connectedCount = 1; pInfo->connected = true; diff --git a/src/imgui/renderer/imgui_core.cpp b/src/imgui/renderer/imgui_core.cpp index d9530dd70..ab43b281e 100644 --- a/src/imgui/renderer/imgui_core.cpp +++ b/src/imgui/renderer/imgui_core.cpp @@ -148,7 +148,7 @@ bool ProcessEvent(SDL_Event* event) { case SDL_EVENT_MOUSE_BUTTON_DOWN: { const auto& io = GetIO(); return io.WantCaptureMouse && io.Ctx->NavWindow != nullptr && - io.Ctx->NavWindow->ID != dock_id; + (io.Ctx->NavWindow->Flags & ImGuiWindowFlags_NoNav) == 0; } case SDL_EVENT_TEXT_INPUT: case SDL_EVENT_KEY_DOWN: { diff --git a/src/input/input_handler.cpp b/src/input/input_handler.cpp new file mode 100644 index 000000000..a78a54131 --- /dev/null +++ b/src/input/input_handler.cpp @@ -0,0 +1,676 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "input_handler.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SDL3/SDL_events.h" +#include "SDL3/SDL_timer.h" + +#include "common/config.h" +#include "common/elf_info.h" +#include "common/io_file.h" +#include "common/path_util.h" +#include "common/version.h" +#include "input/controller.h" +#include "input/input_mouse.h" + +namespace Input { +/* +Project structure: +n to m connection between inputs and outputs +Keyup and keydown events update a dynamic list* of u32 'flags' (what is currently in the list is +'pressed') On every event, after flag updates, we check for every input binding -> controller output +pair if all their flags are 'on' If not, disable; if so, enable them. For axes, we gather their data +into a struct cumulatively from all inputs, then after we checked all of those, we update them all +at once. Wheel inputs generate a timer that doesn't turn off their outputs automatically, but push a +userevent to do so. + +What structs are needed? +InputBinding(key1, key2, key3) +ControllerOutput(button, axis) - we only need a const array of these, and one of the attr-s is +always 0 BindingConnection(inputBinding (member), controllerOutput (ref to the array element)) + +Things to always test before pushing like a dumbass: +Button outputs +Axis outputs +Input hierarchy +Multi key inputs +Mouse to joystick +Key toggle +Joystick halfmode + +Don't be an idiot and test only the changed part expecting everything else to not be broken +*/ + +bool leftjoystick_halfmode = false, rightjoystick_halfmode = false; +int leftjoystick_deadzone, rightjoystick_deadzone, lefttrigger_deadzone, righttrigger_deadzone; + +std::list> pressed_keys; +std::list toggled_keys; +static std::vector connections; + +auto output_array = std::array{ + // Important: these have to be the first, or else they will update in the wrong order + ControllerOutput(LEFTJOYSTICK_HALFMODE), + ControllerOutput(RIGHTJOYSTICK_HALFMODE), + ControllerOutput(KEY_TOGGLE), + + // Button mappings + ControllerOutput(SDL_GAMEPAD_BUTTON_NORTH), // Triangle + ControllerOutput(SDL_GAMEPAD_BUTTON_EAST), // Circle + ControllerOutput(SDL_GAMEPAD_BUTTON_SOUTH), // Cross + ControllerOutput(SDL_GAMEPAD_BUTTON_WEST), // Square + ControllerOutput(SDL_GAMEPAD_BUTTON_LEFT_SHOULDER), // L1 + ControllerOutput(SDL_GAMEPAD_BUTTON_LEFT_STICK), // L3 + ControllerOutput(SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER), // R1 + ControllerOutput(SDL_GAMEPAD_BUTTON_RIGHT_STICK), // R3 + ControllerOutput(SDL_GAMEPAD_BUTTON_START), // Options + ControllerOutput(SDL_GAMEPAD_BUTTON_TOUCHPAD), // TouchPad + ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_UP), // Up + ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_DOWN), // Down + ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_LEFT), // Left + ControllerOutput(SDL_GAMEPAD_BUTTON_DPAD_RIGHT), // Right + + // Axis mappings + // ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_LEFTX, false), + // ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_LEFTY, false), + // ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_RIGHTX, false), + // ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_RIGHTY, false), + ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_LEFTX), + ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_LEFTY), + ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_RIGHTX), + ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_RIGHTY), + + ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_LEFT_TRIGGER), + ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER), + + ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, SDL_GAMEPAD_AXIS_INVALID), +}; + +void ControllerOutput::LinkJoystickAxes() { + // for (int i = 17; i < 23; i += 2) { + // delete output_array[i].new_param; + // output_array[i].new_param = output_array[i + 1].new_param; + // } +} + +static OrbisPadButtonDataOffset SDLGamepadToOrbisButton(u8 button) { + using OPBDO = OrbisPadButtonDataOffset; + + switch (button) { + case SDL_GAMEPAD_BUTTON_DPAD_DOWN: + return OPBDO::Down; + case SDL_GAMEPAD_BUTTON_DPAD_UP: + return OPBDO::Up; + case SDL_GAMEPAD_BUTTON_DPAD_LEFT: + return OPBDO::Left; + case SDL_GAMEPAD_BUTTON_DPAD_RIGHT: + return OPBDO::Right; + case SDL_GAMEPAD_BUTTON_SOUTH: + return OPBDO::Cross; + case SDL_GAMEPAD_BUTTON_NORTH: + return OPBDO::Triangle; + case SDL_GAMEPAD_BUTTON_WEST: + return OPBDO::Square; + case SDL_GAMEPAD_BUTTON_EAST: + return OPBDO::Circle; + case SDL_GAMEPAD_BUTTON_START: + return OPBDO::Options; + case SDL_GAMEPAD_BUTTON_TOUCHPAD: + return OPBDO::TouchPad; + case SDL_GAMEPAD_BUTTON_BACK: + return OPBDO::TouchPad; + case SDL_GAMEPAD_BUTTON_LEFT_SHOULDER: + return OPBDO::L1; + case SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER: + return OPBDO::R1; + case SDL_GAMEPAD_BUTTON_LEFT_STICK: + return OPBDO::L3; + case SDL_GAMEPAD_BUTTON_RIGHT_STICK: + return OPBDO::R3; + default: + return OPBDO::None; + } +} + +Axis GetAxisFromSDLAxis(u8 sdl_axis) { + switch (sdl_axis) { + case SDL_GAMEPAD_AXIS_LEFTX: + return Axis::LeftX; + case SDL_GAMEPAD_AXIS_LEFTY: + return Axis::LeftY; + case SDL_GAMEPAD_AXIS_RIGHTX: + return Axis::RightX; + case SDL_GAMEPAD_AXIS_RIGHTY: + return Axis::RightY; + case SDL_GAMEPAD_AXIS_LEFT_TRIGGER: + return Axis::TriggerLeft; + case SDL_GAMEPAD_AXIS_RIGHT_TRIGGER: + return Axis::TriggerRight; + default: + return Axis::AxisMax; + } +} + +// syntax: 'name, name,name' or 'name,name' or 'name' +InputBinding GetBindingFromString(std::string& line) { + std::array keys = {InputID(), InputID(), InputID()}; + + // Check and process tokens + for (const auto token : std::views::split(line, ',')) { // Split by comma + const std::string t(token.begin(), token.end()); + InputID input; + + if (string_to_keyboard_key_map.find(t) != string_to_keyboard_key_map.end()) { + input = InputID(InputType::KeyboardMouse, string_to_keyboard_key_map.at(t)); + } else if (string_to_axis_map.find(t) != string_to_axis_map.end()) { + input = InputID(InputType::Axis, (u32)string_to_axis_map.at(t).axis); + } else if (string_to_cbutton_map.find(t) != string_to_cbutton_map.end()) { + input = InputID(InputType::Controller, string_to_cbutton_map.at(t)); + } else { + // Invalid token found; return default binding + LOG_DEBUG(Input, "Invalid token found: {}", t); + return InputBinding(); + } + + // Assign to the first available slot + for (auto& key : keys) { + if (!key.IsValid()) { + key = input; + break; + } + } + } + LOG_DEBUG(Input, "Parsed line: {}", InputBinding(keys[0], keys[1], keys[2]).ToString()); + return InputBinding(keys[0], keys[1], keys[2]); +} + +void ParseInputConfig(const std::string game_id = "") { + const auto config_file = Config::GetFoolproofKbmConfigFile(game_id); + + if (game_id == "") { + return; + } + + // we reset these here so in case the user fucks up or doesn't include some of these, + // we can fall back to default + connections.clear(); + float mouse_deadzone_offset = 0.5; + float mouse_speed = 1; + float mouse_speed_offset = 0.125; + + leftjoystick_deadzone = 1; + rightjoystick_deadzone = 1; + lefttrigger_deadzone = 1; + righttrigger_deadzone = 1; + + int lineCount = 0; + + std::ifstream file(config_file); + std::string line = ""; + while (std::getline(file, line)) { + lineCount++; + + // Strip the ; and whitespace + line.erase(std::remove_if(line.begin(), line.end(), + [](unsigned char c) { return std::isspace(c); }), + line.end()); + + if (line.empty()) { + continue; + } + // Truncate lines starting at # + std::size_t comment_pos = line.find('#'); + if (comment_pos != std::string::npos) { + line = line.substr(0, comment_pos); + } + // Remove trailing semicolon + if (!line.empty() && line[line.length() - 1] == ';') { + line = line.substr(0, line.length() - 1); + } + if (line.empty()) { + continue; + } + + // Split the line by '=' + std::size_t equal_pos = line.find('='); + if (equal_pos == std::string::npos) { + LOG_WARNING(Input, "Invalid format at line: {}, data: \"{}\", skipping line.", + lineCount, line); + continue; + } + + std::string output_string = line.substr(0, equal_pos); + std::string input_string = line.substr(equal_pos + 1); + std::size_t comma_pos = input_string.find(','); + + if (output_string == "mouse_to_joystick") { + if (input_string == "left") { + SetMouseToJoystick(1); + } else if (input_string == "right") { + SetMouseToJoystick(2); + } else { + LOG_WARNING(Input, "Invalid argument for mouse-to-joystick binding"); + SetMouseToJoystick(0); + } + continue; + } else if (output_string == "key_toggle") { + if (comma_pos != std::string::npos) { + // handle key-to-key toggling (separate list?) + InputBinding toggle_keys = GetBindingFromString(input_string); + if (toggle_keys.KeyCount() != 2) { + LOG_WARNING(Input, + "Syntax error: Please provide exactly 2 keys: " + "first is the toggler, the second is the key to toggle: {}", + line); + continue; + } + ControllerOutput* toggle_out = + &*std::ranges::find(output_array, ControllerOutput(KEY_TOGGLE)); + BindingConnection toggle_connection = BindingConnection( + InputBinding(toggle_keys.keys[0]), toggle_out, 0, toggle_keys.keys[1]); + connections.insert(connections.end(), toggle_connection); + continue; + } + LOG_WARNING(Input, "Invalid format at line: {}, data: \"{}\", skipping line.", + lineCount, line); + continue; + } else if (output_string == "mouse_movement_params") { + std::stringstream ss(input_string); + char comma; // To hold the comma separators between the floats + ss >> mouse_deadzone_offset >> comma >> mouse_speed >> comma >> mouse_speed_offset; + + // Check for invalid input (in case there's an unexpected format) + if (ss.fail()) { + LOG_WARNING(Input, "Failed to parse mouse movement parameters from line: {}", line); + continue; + } + SetMouseParams(mouse_deadzone_offset, mouse_speed, mouse_speed_offset); + continue; + } else if (output_string == "analog_deadzone") { + std::stringstream ss(input_string); + std::string device; + int deadzone; + std::getline(ss, device, ','); + ss >> deadzone; + if (ss.fail()) { + LOG_WARNING(Input, "Failed to parse deadzone config from line: {}", line); + continue; + } else { + LOG_DEBUG(Input, "Parsed deadzone: {} {}", device, deadzone); + } + if (device == "leftjoystick") { + leftjoystick_deadzone = deadzone; + } else if (device == "rightjoystick") { + rightjoystick_deadzone = deadzone; + } else if (device == "l2") { + lefttrigger_deadzone = deadzone; + } else if (device == "r2") { + righttrigger_deadzone = deadzone; + } else { + LOG_WARNING(Input, "Invalid axis name at line: {}, data: \"{}\", skipping line.", + lineCount, line); + } + continue; + } + + // normal cases + InputBinding binding = GetBindingFromString(input_string); + BindingConnection connection(InputID(), nullptr); + auto button_it = string_to_cbutton_map.find(output_string); + auto axis_it = string_to_axis_map.find(output_string); + + if (binding.IsEmpty()) { + LOG_WARNING(Input, "Invalid format at line: {}, data: \"{}\", skipping line.", + lineCount, line); + continue; + } + if (button_it != string_to_cbutton_map.end()) { + connection = BindingConnection( + binding, &*std::ranges::find(output_array, ControllerOutput(button_it->second))); + connections.insert(connections.end(), connection); + + } else if (axis_it != string_to_axis_map.end()) { + int value_to_set = binding.keys[2].type == InputType::Axis ? 0 : axis_it->second.value; + connection = BindingConnection( + binding, + &*std::ranges::find(output_array, ControllerOutput(SDL_GAMEPAD_BUTTON_INVALID, + axis_it->second.axis, + axis_it->second.value >= 0)), + value_to_set); + connections.insert(connections.end(), connection); + } else { + LOG_WARNING(Input, "Invalid format at line: {}, data: \"{}\", skipping line.", + lineCount, line); + continue; + } + LOG_DEBUG(Input, "Succesfully parsed line {}", lineCount); + } + file.close(); + std::sort(connections.begin(), connections.end()); + for (auto& c : connections) { + LOG_DEBUG(Input, "Binding: {} : {}", c.output->ToString(), c.binding.ToString()); + } + LOG_DEBUG(Input, "Done parsing the input config!"); +} + +u32 GetMouseWheelEvent(const SDL_Event& event) { + if (event.type != SDL_EVENT_MOUSE_WHEEL && event.type != SDL_EVENT_MOUSE_WHEEL_OFF) { + LOG_WARNING(Input, "Something went wrong with wheel input parsing!"); + return (u32)-1; + } + if (event.wheel.y > 0) { + return SDL_MOUSE_WHEEL_UP; + } else if (event.wheel.y < 0) { + return SDL_MOUSE_WHEEL_DOWN; + } else if (event.wheel.x > 0) { + return SDL_MOUSE_WHEEL_RIGHT; + } else if (event.wheel.x < 0) { + return SDL_MOUSE_WHEEL_LEFT; + } + return (u32)-1; +} + +InputEvent InputBinding::GetInputEventFromSDLEvent(const SDL_Event& e) { + switch (e.type) { + case SDL_EVENT_KEY_DOWN: + case SDL_EVENT_KEY_UP: + return InputEvent(InputType::KeyboardMouse, e.key.key, e.key.down, 0); + case SDL_EVENT_MOUSE_BUTTON_DOWN: + case SDL_EVENT_MOUSE_BUTTON_UP: + return InputEvent(InputType::KeyboardMouse, (u32)e.button.button, e.button.down, 0); + case SDL_EVENT_MOUSE_WHEEL: + case SDL_EVENT_MOUSE_WHEEL_OFF: + return InputEvent(InputType::KeyboardMouse, GetMouseWheelEvent(e), + e.type == SDL_EVENT_MOUSE_WHEEL, 0); + case SDL_EVENT_GAMEPAD_BUTTON_DOWN: + case SDL_EVENT_GAMEPAD_BUTTON_UP: + return InputEvent(InputType::Controller, (u32)e.gbutton.button, e.gbutton.down, 0); + case SDL_EVENT_GAMEPAD_AXIS_MOTION: + return InputEvent(InputType::Axis, (u32)e.gaxis.axis, true, e.gaxis.value / 256); + default: + return InputEvent(); + } +} + +GameController* ControllerOutput::controller = nullptr; +void ControllerOutput::SetControllerOutputController(GameController* c) { + ControllerOutput::controller = c; +} + +void ToggleKeyInList(InputID input) { + if (input.type == InputType::Axis) { + LOG_ERROR(Input, "Toggling analog inputs is not supported!"); + return; + } + auto it = std::find(toggled_keys.begin(), toggled_keys.end(), input); + if (it == toggled_keys.end()) { + toggled_keys.insert(toggled_keys.end(), input); + LOG_DEBUG(Input, "Added {} to toggled keys", input.ToString()); + } else { + toggled_keys.erase(it); + LOG_DEBUG(Input, "Removed {} from toggled keys", input.ToString()); + } +} + +void ControllerOutput::ResetUpdate() { + state_changed = false; + new_button_state = false; + *new_param = 0; // bruh +} +void ControllerOutput::AddUpdate(InputEvent event) { + state_changed = true; + if (button == KEY_TOGGLE) { + if (event.active) { + ToggleKeyInList(event.input); + } + } else if (button != SDL_GAMEPAD_BUTTON_INVALID) { + if (event.input.type == InputType::Axis) { + bool temp = event.axis_value * (positive_axis ? 1 : -1) > 0x40; + new_button_state |= event.active && event.axis_value * (positive_axis ? 1 : -1) > 0x40; + if (temp) { + LOG_DEBUG(Input, "Toggled a button from an axis"); + } + } else { + new_button_state |= event.active; + } + + } else if (axis != SDL_GAMEPAD_AXIS_INVALID) { + switch (axis) { + case SDL_GAMEPAD_AXIS_LEFT_TRIGGER: + case SDL_GAMEPAD_AXIS_RIGHT_TRIGGER: + // if it's a button input, then we know the value to set, so the param is 0. + // if it's an analog input, then the param isn't 0 + *new_param = (event.active ? event.axis_value : 0) + *new_param; + break; + default: + *new_param = (event.active ? event.axis_value : 0) + *new_param; + break; + } + } +} +void ControllerOutput::FinalizeUpdate() { + if (!state_changed) { + // return; + } + + old_button_state = new_button_state; + old_param = *new_param; + float touchpad_x = 0; + if (button != SDL_GAMEPAD_BUTTON_INVALID) { + switch (button) { + case SDL_GAMEPAD_BUTTON_TOUCHPAD: + touchpad_x = Config::getBackButtonBehavior() == "left" ? 0.25f + : Config::getBackButtonBehavior() == "right" ? 0.75f + : 0.5f; + controller->SetTouchpadState(0, new_button_state, touchpad_x, 0.5f); + controller->CheckButton(0, SDLGamepadToOrbisButton(button), new_button_state); + break; + case LEFTJOYSTICK_HALFMODE: + leftjoystick_halfmode = new_button_state; + break; + case RIGHTJOYSTICK_HALFMODE: + rightjoystick_halfmode = new_button_state; + break; + // KEY_TOGGLE isn't handled here anymore, as this function doesn't have the necessary data + // to do it, and it would be inconvenient to force it here, when AddUpdate does the job just + // fine, and a toggle doesn't have to checked against every input that's bound to it, it's + // enough that one is pressed + default: // is a normal key (hopefully) + controller->CheckButton(0, SDLGamepadToOrbisButton(button), new_button_state); + break; + } + } else if (axis != SDL_GAMEPAD_AXIS_INVALID && positive_axis) { + // avoid double-updating axes, but don't skip directional button bindings + float multiplier = 1.0; + int deadzone = 0; + auto ApplyDeadzone = [](s16* value, int deadzone) { + if (std::abs(*value) <= deadzone) { + *value = 0; + } + }; + Axis c_axis = GetAxisFromSDLAxis(axis); + switch (c_axis) { + case Axis::LeftX: + case Axis::LeftY: + ApplyDeadzone(new_param, leftjoystick_deadzone); + multiplier = leftjoystick_halfmode ? 0.5 : 1.0; + break; + case Axis::RightX: + case Axis::RightY: + ApplyDeadzone(new_param, rightjoystick_deadzone); + multiplier = rightjoystick_halfmode ? 0.5 : 1.0; + break; + case Axis::TriggerLeft: + ApplyDeadzone(new_param, lefttrigger_deadzone); + controller->Axis(0, c_axis, GetAxis(0x0, 0x80, *new_param)); + controller->CheckButton(0, OrbisPadButtonDataOffset::L2, *new_param > 0x20); + return; + case Axis::TriggerRight: + ApplyDeadzone(new_param, righttrigger_deadzone); + controller->Axis(0, c_axis, GetAxis(0x0, 0x80, *new_param)); + controller->CheckButton(0, OrbisPadButtonDataOffset::R2, *new_param > 0x20); + return; + default: + break; + } + controller->Axis(0, c_axis, GetAxis(-0x80, 0x80, *new_param * multiplier)); + } +} + +// Updates the list of pressed keys with the given input. +// Returns whether the list was updated or not. +bool UpdatePressedKeys(InputEvent event) { + // Skip invalid inputs + InputID input = event.input; + if (input.sdl_id == (u32)-1) { + return false; + } + if (input.type == InputType::Axis) { + // analog input, it gets added when it first sends an event, + // and from there, it only changes the parameter + auto it = std::lower_bound(pressed_keys.begin(), pressed_keys.end(), input, + [](const std::pair& e, InputID i) { + return std::tie(e.first.input.type, e.first.input.sdl_id) < + std::tie(i.type, i.sdl_id); + }); + if (it == pressed_keys.end() || it->first.input != input) { + pressed_keys.insert(it, {event, false}); + LOG_DEBUG(Input, "Added axis {} to the input list", event.input.sdl_id); + } else { + it->first.axis_value = event.axis_value; + } + return true; + } else if (event.active) { + // Find the correct position for insertion to maintain order + auto it = std::lower_bound(pressed_keys.begin(), pressed_keys.end(), input, + [](const std::pair& e, InputID i) { + return std::tie(e.first.input.type, e.first.input.sdl_id) < + std::tie(i.type, i.sdl_id); + }); + + // Insert only if 'value' is not already in the list + if (it == pressed_keys.end() || it->first.input != input) { + pressed_keys.insert(it, {event, false}); + return true; + } + } else { + // Remove 'value' from the list if it's not pressed + auto it = std::find_if( + pressed_keys.begin(), pressed_keys.end(), + [input](const std::pair& e) { return e.first.input == input; }); + if (it != pressed_keys.end()) { + pressed_keys.erase(it); + return true; + } + } + LOG_DEBUG(Input, "No change was made!"); + return false; +} +// Check if the binding's all keys are currently active. +// It also extracts the analog inputs' parameters, and updates the input hierarchy flags. +InputEvent BindingConnection::ProcessBinding() { + // the last key is always set (if the connection isn't empty), + // and the analog inputs are always the last one due to how they are sorted, + // so this signifies whether or not the input is analog + InputEvent event = InputEvent(binding.keys[0]); + if (pressed_keys.empty()) { + return event; + } + if (event.input.type != InputType::Axis) { + // for button inputs + event.axis_value = axis_param; + } + // it's a bit scuffed, but if the output is a toggle, then we put the key here + if (output->button == KEY_TOGGLE) { + event.input = toggle; + } + + // Extract keys from InputBinding and ignore unused or toggled keys + std::list input_keys = {binding.keys[0], binding.keys[1], binding.keys[2]}; + input_keys.remove(InputID()); + for (auto key = input_keys.begin(); key != input_keys.end();) { + if (std::find(toggled_keys.begin(), toggled_keys.end(), *key) != toggled_keys.end()) { + key = input_keys.erase(key); // Use the returned iterator + } else { + ++key; // Increment only if no erase happened + } + } + if (input_keys.empty()) { + LOG_DEBUG(Input, "No actual inputs to check, returning true"); + event.active = true; + return event; + } + + // Iterator for pressed_keys, starting from the beginning + auto pressed_it = pressed_keys.begin(); + + // Store pointers to flags in pressed_keys that need to be set if all keys are active + std::list flags_to_set; + + // Check if all keys in input_keys are active + for (InputID key : input_keys) { + bool key_found = false; + + while (pressed_it != pressed_keys.end()) { + if (pressed_it->first.input == key && (pressed_it->second == false)) { + key_found = true; + if (output->positive_axis) { + flags_to_set.push_back(&pressed_it->second); + } + if (pressed_it->first.input.type == InputType::Axis) { + event.axis_value = pressed_it->first.axis_value; + } + ++pressed_it; + break; + } + ++pressed_it; + } + if (!key_found) { + return event; + } + } + + for (bool* flag : flags_to_set) { + *flag = true; + } + if (binding.keys[0].type != InputType::Axis) { // the axes spam inputs, making this unreadable + LOG_DEBUG(Input, "Input found: {}", binding.ToString()); + } + event.active = true; + return event; // All keys are active +} + +void ActivateOutputsFromInputs() { + // Reset values and flags + for (auto& it : pressed_keys) { + it.second = false; + } + for (auto& it : output_array) { + it.ResetUpdate(); + } + + // Iterate over all inputs, and update their respecive outputs accordingly + for (auto& it : connections) { + it.output->AddUpdate(it.ProcessBinding()); + } + + // Update all outputs + for (auto& it : output_array) { + it.FinalizeUpdate(); + } +} + +} // namespace Input diff --git a/src/input/input_handler.h b/src/input/input_handler.h new file mode 100644 index 000000000..0178e7937 --- /dev/null +++ b/src/input/input_handler.h @@ -0,0 +1,407 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include +#include + +#include "SDL3/SDL_events.h" +#include "SDL3/SDL_timer.h" + +#include "common/logging/log.h" +#include "common/types.h" +#include "core/libraries/pad/pad.h" +#include "fmt/format.h" +#include "input/controller.h" + +// +1 and +2 is taken +#define SDL_MOUSE_WHEEL_UP SDL_EVENT_MOUSE_WHEEL + 3 +#define SDL_MOUSE_WHEEL_DOWN SDL_EVENT_MOUSE_WHEEL + 4 +#define SDL_MOUSE_WHEEL_LEFT SDL_EVENT_MOUSE_WHEEL + 5 +#define SDL_MOUSE_WHEEL_RIGHT SDL_EVENT_MOUSE_WHEEL + 7 + +// idk who already used what where so I just chose a big number +#define SDL_EVENT_MOUSE_WHEEL_OFF SDL_EVENT_USER + 10 + +#define LEFTJOYSTICK_HALFMODE 0x00010000 +#define RIGHTJOYSTICK_HALFMODE 0x00020000 +#define BACK_BUTTON 0x00040000 + +#define KEY_TOGGLE 0x00200000 + +namespace Input { +using Input::Axis; +using Libraries::Pad::OrbisPadButtonDataOffset; + +struct AxisMapping { + u32 axis; + s16 value; + AxisMapping(SDL_GamepadAxis a, s16 v) : axis(a), value(v) {} +}; + +enum class InputType { Axis, KeyboardMouse, Controller, Count }; +const std::array input_type_names = {"Axis", "KBM", "Controller", "Unknown"}; + +class InputID { +public: + InputType type; + u32 sdl_id; + InputID(InputType d = InputType::Count, u32 i = (u32)-1) : type(d), sdl_id(i) {} + bool operator==(const InputID& o) const { + return type == o.type && sdl_id == o.sdl_id; + } + bool operator!=(const InputID& o) const { + return type != o.type || sdl_id != o.sdl_id; + } + bool operator<=(const InputID& o) const { + return type <= o.type && sdl_id <= o.sdl_id; + } + bool IsValid() const { + return *this != InputID(); + } + std::string ToString() { + return fmt::format("({}: {:x})", input_type_names[(u8)type], sdl_id); + } +}; + +class InputEvent { +public: + InputID input; + bool active; + s8 axis_value; + + InputEvent(InputID i = InputID(), bool a = false, s8 v = 0) + : input(i), active(a), axis_value(v) {} + InputEvent(InputType d, u32 i, bool a = false, s8 v = 0) + : input(d, i), active(a), axis_value(v) {} +}; + +// i strongly suggest you collapse these maps +const std::map string_to_cbutton_map = { + {"triangle", SDL_GAMEPAD_BUTTON_NORTH}, + {"circle", SDL_GAMEPAD_BUTTON_EAST}, + {"cross", SDL_GAMEPAD_BUTTON_SOUTH}, + {"square", SDL_GAMEPAD_BUTTON_WEST}, + {"l1", SDL_GAMEPAD_BUTTON_LEFT_SHOULDER}, + {"r1", SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER}, + {"l3", SDL_GAMEPAD_BUTTON_LEFT_STICK}, + {"r3", SDL_GAMEPAD_BUTTON_RIGHT_STICK}, + {"pad_up", SDL_GAMEPAD_BUTTON_DPAD_UP}, + {"pad_down", SDL_GAMEPAD_BUTTON_DPAD_DOWN}, + {"pad_left", SDL_GAMEPAD_BUTTON_DPAD_LEFT}, + {"pad_right", SDL_GAMEPAD_BUTTON_DPAD_RIGHT}, + {"options", SDL_GAMEPAD_BUTTON_START}, + + // these are outputs only (touchpad can only be bound to itself) + {"touchpad", SDL_GAMEPAD_BUTTON_TOUCHPAD}, + {"leftjoystick_halfmode", LEFTJOYSTICK_HALFMODE}, + {"rightjoystick_halfmode", RIGHTJOYSTICK_HALFMODE}, + + // this is only for input + {"back", SDL_GAMEPAD_BUTTON_BACK}, +}; + +const std::map string_to_axis_map = { + {"axis_left_x_plus", {SDL_GAMEPAD_AXIS_LEFTX, 127}}, + {"axis_left_x_minus", {SDL_GAMEPAD_AXIS_LEFTX, -127}}, + {"axis_left_y_plus", {SDL_GAMEPAD_AXIS_LEFTY, 127}}, + {"axis_left_y_minus", {SDL_GAMEPAD_AXIS_LEFTY, -127}}, + {"axis_right_x_plus", {SDL_GAMEPAD_AXIS_RIGHTX, 127}}, + {"axis_right_x_minus", {SDL_GAMEPAD_AXIS_RIGHTX, -127}}, + {"axis_right_y_plus", {SDL_GAMEPAD_AXIS_RIGHTY, 127}}, + {"axis_right_y_minus", {SDL_GAMEPAD_AXIS_RIGHTY, -127}}, + + {"l2", {SDL_GAMEPAD_AXIS_LEFT_TRIGGER, 127}}, + {"r2", {SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, 127}}, + + // should only use these to bind analog inputs to analog outputs + {"axis_left_x", {SDL_GAMEPAD_AXIS_LEFTX, 127}}, + {"axis_left_y", {SDL_GAMEPAD_AXIS_LEFTY, 127}}, + {"axis_right_x", {SDL_GAMEPAD_AXIS_RIGHTX, 127}}, + {"axis_right_y", {SDL_GAMEPAD_AXIS_RIGHTY, 127}}, +}; +const std::map string_to_keyboard_key_map = { + {"a", SDLK_A}, + {"b", SDLK_B}, + {"c", SDLK_C}, + {"d", SDLK_D}, + {"e", SDLK_E}, + {"f", SDLK_F}, + {"g", SDLK_G}, + {"h", SDLK_H}, + {"i", SDLK_I}, + {"j", SDLK_J}, + {"k", SDLK_K}, + {"l", SDLK_L}, + {"m", SDLK_M}, + {"n", SDLK_N}, + {"o", SDLK_O}, + {"p", SDLK_P}, + {"q", SDLK_Q}, + {"r", SDLK_R}, + {"s", SDLK_S}, + {"t", SDLK_T}, + {"u", SDLK_U}, + {"v", SDLK_V}, + {"w", SDLK_W}, + {"x", SDLK_X}, + {"y", SDLK_Y}, + {"z", SDLK_Z}, + {"0", SDLK_0}, + {"1", SDLK_1}, + {"2", SDLK_2}, + {"3", SDLK_3}, + {"4", SDLK_4}, + {"5", SDLK_5}, + {"6", SDLK_6}, + {"7", SDLK_7}, + {"8", SDLK_8}, + {"9", SDLK_9}, + {"kp0", SDLK_KP_0}, + {"kp1", SDLK_KP_1}, + {"kp2", SDLK_KP_2}, + {"kp3", SDLK_KP_3}, + {"kp4", SDLK_KP_4}, + {"kp5", SDLK_KP_5}, + {"kp6", SDLK_KP_6}, + {"kp7", SDLK_KP_7}, + {"kp8", SDLK_KP_8}, + {"kp9", SDLK_KP_9}, + {"comma", SDLK_COMMA}, + {"period", SDLK_PERIOD}, + {"question", SDLK_QUESTION}, + {"semicolon", SDLK_SEMICOLON}, + {"minus", SDLK_MINUS}, + {"underscore", SDLK_UNDERSCORE}, + {"lparenthesis", SDLK_LEFTPAREN}, + {"rparenthesis", SDLK_RIGHTPAREN}, + {"lbracket", SDLK_LEFTBRACKET}, + {"rbracket", SDLK_RIGHTBRACKET}, + {"lbrace", SDLK_LEFTBRACE}, + {"rbrace", SDLK_RIGHTBRACE}, + {"backslash", SDLK_BACKSLASH}, + {"dash", SDLK_SLASH}, + {"enter", SDLK_RETURN}, + {"space", SDLK_SPACE}, + {"tab", SDLK_TAB}, + {"backspace", SDLK_BACKSPACE}, + {"escape", SDLK_ESCAPE}, + {"left", SDLK_LEFT}, + {"right", SDLK_RIGHT}, + {"up", SDLK_UP}, + {"down", SDLK_DOWN}, + {"lctrl", SDLK_LCTRL}, + {"rctrl", SDLK_RCTRL}, + {"lshift", SDLK_LSHIFT}, + {"rshift", SDLK_RSHIFT}, + {"lalt", SDLK_LALT}, + {"ralt", SDLK_RALT}, + {"lmeta", SDLK_LGUI}, + {"rmeta", SDLK_RGUI}, + {"lwin", SDLK_LGUI}, + {"rwin", SDLK_RGUI}, + {"home", SDLK_HOME}, + {"end", SDLK_END}, + {"pgup", SDLK_PAGEUP}, + {"pgdown", SDLK_PAGEDOWN}, + {"leftbutton", SDL_BUTTON_LEFT}, + {"rightbutton", SDL_BUTTON_RIGHT}, + {"middlebutton", SDL_BUTTON_MIDDLE}, + {"sidebuttonback", SDL_BUTTON_X1}, + {"sidebuttonforward", SDL_BUTTON_X2}, + {"mousewheelup", SDL_MOUSE_WHEEL_UP}, + {"mousewheeldown", SDL_MOUSE_WHEEL_DOWN}, + {"mousewheelleft", SDL_MOUSE_WHEEL_LEFT}, + {"mousewheelright", SDL_MOUSE_WHEEL_RIGHT}, + {"kpperiod", SDLK_KP_PERIOD}, + {"kpcomma", SDLK_KP_COMMA}, + {"kpdivide", SDLK_KP_DIVIDE}, + {"kpmultiply", SDLK_KP_MULTIPLY}, + {"kpminus", SDLK_KP_MINUS}, + {"kpplus", SDLK_KP_PLUS}, + {"kpenter", SDLK_KP_ENTER}, + {"kpequals", SDLK_KP_EQUALS}, + {"capslock", SDLK_CAPSLOCK}, +}; + +void ParseInputConfig(const std::string game_id); + +class InputBinding { +public: + InputID keys[3]; + InputBinding(InputID k1 = InputID(), InputID k2 = InputID(), InputID k3 = InputID()) { + // we format the keys so comparing them will be very fast, because we will only have to + // compare 3 sorted elements, where the only possible duplicate item is 0 + + // duplicate entries get changed to one original, one null + if (k1 == k2 && k1 != InputID()) { + k2 = InputID(); + } + if (k1 == k3 && k1 != InputID()) { + k3 = InputID(); + } + if (k3 == k2 && k2 != InputID()) { + k2 = InputID(); + } + // this sorts them + if (k1 <= k2 && k1 <= k3) { + keys[0] = k1; + if (k2 <= k3) { + keys[1] = k2; + keys[2] = k3; + } else { + keys[1] = k3; + keys[2] = k2; + } + } else if (k2 <= k1 && k2 <= k3) { + keys[0] = k2; + if (k1 <= k3) { + keys[1] = k1; + keys[2] = k3; + } else { + keys[1] = k3; + keys[2] = k1; + } + } else { + keys[0] = k3; + if (k1 <= k2) { + keys[1] = k1; + keys[2] = k2; + } else { + keys[1] = k2; + keys[3] = k1; + } + } + } + // copy ctor + InputBinding(const InputBinding& o) { + keys[0] = o.keys[0]; + keys[1] = o.keys[1]; + keys[2] = o.keys[2]; + } + + inline bool operator==(const InputBinding& o) { + // InputID() signifies an unused slot + return (keys[0] == o.keys[0] || keys[0] == InputID() || o.keys[0] == InputID()) && + (keys[1] == o.keys[1] || keys[1] == InputID() || o.keys[1] == InputID()) && + (keys[2] == o.keys[2] || keys[2] == InputID() || o.keys[2] == InputID()); + // it is already very fast, + // but reverse order makes it check the actual keys first instead of possible 0-s, + // potenially skipping the later expressions of the three-way AND + } + inline int KeyCount() const { + return (keys[0].IsValid() ? 1 : 0) + (keys[1].IsValid() ? 1 : 0) + + (keys[2].IsValid() ? 1 : 0); + } + // Sorts by the amount of non zero keys - left side is 'bigger' here + bool operator<(const InputBinding& other) const { + return KeyCount() > other.KeyCount(); + } + inline bool IsEmpty() { + return !(keys[0].IsValid() || keys[1].IsValid() || keys[2].IsValid()); + } + std::string ToString() { // todo add device type + switch (KeyCount()) { + case 1: + return fmt::format("({})", keys[0].ToString()); + case 2: + return fmt::format("({}, {})", keys[0].ToString(), keys[1].ToString()); + case 3: + return fmt::format("({}, {}, {})", keys[0].ToString(), keys[1].ToString(), + keys[2].ToString()); + default: + return "Empty"; + } + } + + // returns an InputEvent based on the event type (keyboard, mouse buttons/wheel, or controller) + static InputEvent GetInputEventFromSDLEvent(const SDL_Event& e); +}; +class ControllerOutput { + static GameController* controller; + +public: + static void SetControllerOutputController(GameController* c); + static void LinkJoystickAxes(); + + u32 button; + u32 axis; + // these are only used as s8, + // but I added some padding to avoid overflow if it's activated by multiple inputs + // axis_plus and axis_minus pairs share a common new_param, the other outputs have their own + s16 old_param; + s16* new_param; + bool old_button_state, new_button_state, state_changed, positive_axis; + + ControllerOutput(const u32 b, u32 a = SDL_GAMEPAD_AXIS_INVALID, bool p = true) { + button = b; + axis = a; + new_param = new s16(0); + old_param = 0; + positive_axis = p; + } + ControllerOutput(const ControllerOutput& o) : button(o.button), axis(o.axis) { + new_param = new s16(*o.new_param); + } + ~ControllerOutput() { + delete new_param; + } + inline bool operator==(const ControllerOutput& o) const { // fucking consts everywhere + return button == o.button && axis == o.axis; + } + inline bool operator!=(const ControllerOutput& o) const { + return button != o.button || axis != o.axis; + } + std::string ToString() const { + return fmt::format("({}, {}, {})", (s32)button, (int)axis, old_param); + } + inline bool IsButton() const { + return axis == SDL_GAMEPAD_AXIS_INVALID && button != SDL_GAMEPAD_BUTTON_INVALID; + } + inline bool IsAxis() const { + return axis != SDL_GAMEPAD_AXIS_INVALID && button == SDL_GAMEPAD_BUTTON_INVALID; + } + + void ResetUpdate(); + void AddUpdate(InputEvent event); + void FinalizeUpdate(); +}; +class BindingConnection { +public: + InputBinding binding; + ControllerOutput* output; + u32 axis_param; + InputID toggle; + + BindingConnection(InputBinding b, ControllerOutput* out, u32 param = 0, InputID t = InputID()) { + binding = b; + axis_param = param; + output = out; + toggle = t; + } + bool operator<(const BindingConnection& other) const { + // a button is a higher priority than an axis, as buttons can influence axes + // (e.g. joystick_halfmode) + if (output->IsButton() && + (other.output->IsAxis() && (other.output->axis != SDL_GAMEPAD_AXIS_LEFT_TRIGGER && + other.output->axis != SDL_GAMEPAD_AXIS_RIGHT_TRIGGER))) { + return true; + } + if (binding < other.binding) { + return true; + } + return false; + } + InputEvent ProcessBinding(); +}; + +// Updates the list of pressed keys with the given input. +// Returns whether the list was updated or not. +bool UpdatePressedKeys(InputEvent event); + +void ActivateOutputsFromInputs(); + +} // namespace Input diff --git a/src/input/input_mouse.cpp b/src/input/input_mouse.cpp new file mode 100644 index 000000000..11feaeebb --- /dev/null +++ b/src/input/input_mouse.cpp @@ -0,0 +1,74 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include + +#include "common/types.h" +#include "input/controller.h" +#include "input_mouse.h" + +#include "SDL3/SDL.h" + +namespace Input { + +int mouse_joystick_binding = 0; +float mouse_deadzone_offset = 0.5, mouse_speed = 1, mouse_speed_offset = 0.1250; +Uint32 mouse_polling_id = 0; +bool mouse_enabled = false; + +// We had to go through 3 files of indirection just to update a flag +void ToggleMouseEnabled() { + mouse_enabled = !mouse_enabled; +} + +void SetMouseToJoystick(int joystick) { + mouse_joystick_binding = joystick; +} + +void SetMouseParams(float mdo, float ms, float mso) { + mouse_deadzone_offset = mdo; + mouse_speed = ms; + mouse_speed_offset = mso; +} + +Uint32 MousePolling(void* param, Uint32 id, Uint32 interval) { + auto* controller = (GameController*)param; + if (!mouse_enabled) + return interval; + + Axis axis_x, axis_y; + switch (mouse_joystick_binding) { + case 1: + axis_x = Axis::LeftX; + axis_y = Axis::LeftY; + break; + case 2: + axis_x = Axis::RightX; + axis_y = Axis::RightY; + break; + default: + return interval; // no update needed + } + + float d_x = 0, d_y = 0; + SDL_GetRelativeMouseState(&d_x, &d_y); + + float output_speed = + SDL_clamp((sqrt(d_x * d_x + d_y * d_y) + mouse_speed_offset * 128) * mouse_speed, + mouse_deadzone_offset * 128, 128.0); + + float angle = atan2(d_y, d_x); + float a_x = cos(angle) * output_speed, a_y = sin(angle) * output_speed; + + if (d_x != 0 && d_y != 0) { + controller->Axis(0, axis_x, GetAxis(-0x80, 0x80, a_x)); + controller->Axis(0, axis_y, GetAxis(-0x80, 0x80, a_y)); + } else { + controller->Axis(0, axis_x, GetAxis(-0x80, 0x80, 0)); + controller->Axis(0, axis_y, GetAxis(-0x80, 0x80, 0)); + } + + return interval; +} + +} // namespace Input diff --git a/src/input/input_mouse.h b/src/input/input_mouse.h new file mode 100644 index 000000000..da18ee04e --- /dev/null +++ b/src/input/input_mouse.h @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "SDL3/SDL.h" +#include "common/types.h" + +namespace Input { + +void ToggleMouseEnabled(); +void SetMouseToJoystick(int joystick); +void SetMouseParams(float mouse_deadzone_offset, float mouse_speed, float mouse_speed_offset); + +// Polls the mouse for changes, and simulates joystick movement from it. +Uint32 MousePolling(void* param, Uint32 id, Uint32 interval); + +} // namespace Input diff --git a/src/qt_gui/kbm_config_dialog.cpp b/src/qt_gui/kbm_config_dialog.cpp new file mode 100644 index 000000000..af198f79d --- /dev/null +++ b/src/qt_gui/kbm_config_dialog.cpp @@ -0,0 +1,237 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "kbm_config_dialog.h" +#include "kbm_help_dialog.h" + +#include +#include +#include +#include "common/config.h" +#include "common/path_util.h" +#include "game_info.h" +#include "src/sdl_window.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +QString previous_game = "default"; +bool isHelpOpen = false; +HelpDialog* helpDialog; + +EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) { + + setWindowTitle("Edit Keyboard + Mouse and Controller input bindings"); + resize(600, 400); + + // Create the editor widget + editor = new QPlainTextEdit(this); + editorFont.setPointSize(10); // Set default text size + editor->setFont(editorFont); // Apply font to the editor + + // Create the game selection combo box + gameComboBox = new QComboBox(this); + gameComboBox->addItem("default"); // Add default option + /* + gameComboBox = new QComboBox(this); + layout->addWidget(gameComboBox); // Add the combobox for selecting game configurations + + // Populate the combo box with game configurations + QStringList gameConfigs = GameInfoClass::GetGameInfo(this); + gameComboBox->addItems(gameConfigs); + gameComboBox->setCurrentText("default.ini"); // Set the default selection + */ + // Load all installed games + loadInstalledGames(); + + // Create Save, Cancel, and Help buttons + QPushButton* saveButton = new QPushButton("Save", this); + QPushButton* cancelButton = new QPushButton("Cancel", this); + QPushButton* helpButton = new QPushButton("Help", this); + QPushButton* defaultButton = new QPushButton("Default", this); + + // Layout for the game selection and buttons + QHBoxLayout* topLayout = new QHBoxLayout(); + topLayout->addWidget(gameComboBox); + topLayout->addStretch(); + topLayout->addWidget(saveButton); + topLayout->addWidget(cancelButton); + topLayout->addWidget(defaultButton); + topLayout->addWidget(helpButton); + + // Main layout with editor and buttons + QVBoxLayout* layout = new QVBoxLayout(this); + layout->addLayout(topLayout); + layout->addWidget(editor); + + // Load the default config file content into the editor + loadFile(gameComboBox->currentText()); + + // Connect button and combo box signals + connect(saveButton, &QPushButton::clicked, this, &EditorDialog::onSaveClicked); + connect(cancelButton, &QPushButton::clicked, this, &EditorDialog::onCancelClicked); + connect(helpButton, &QPushButton::clicked, this, &EditorDialog::onHelpClicked); + connect(defaultButton, &QPushButton::clicked, this, &EditorDialog::onResetToDefaultClicked); + connect(gameComboBox, &QComboBox::currentTextChanged, this, + &EditorDialog::onGameSelectionChanged); +} + +void EditorDialog::loadFile(QString game) { + + const auto config_file = Config::GetFoolproofKbmConfigFile(game.toStdString()); + QFile file(config_file); + + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&file); + editor->setPlainText(in.readAll()); + originalConfig = editor->toPlainText(); + file.close(); + } else { + QMessageBox::warning(this, "Error", "Could not open the file for reading"); + } +} + +void EditorDialog::saveFile(QString game) { + + const auto config_file = Config::GetFoolproofKbmConfigFile(game.toStdString()); + QFile file(config_file); + + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QTextStream out(&file); + out << editor->toPlainText(); + file.close(); + } else { + QMessageBox::warning(this, "Error", "Could not open the file for writing"); + } +} + +// Override the close event to show the save confirmation dialog only if changes were made +void EditorDialog::closeEvent(QCloseEvent* event) { + if (isHelpOpen) { + helpDialog->close(); + isHelpOpen = false; + // at this point I might have to add this flag and the help dialog to the class itself + } + if (hasUnsavedChanges()) { + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this, "Save Changes", "Do you want to save changes?", + QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); + + if (reply == QMessageBox::Yes) { + saveFile(gameComboBox->currentText()); + event->accept(); // Close the dialog + } else if (reply == QMessageBox::No) { + event->accept(); // Close the dialog without saving + } else { + event->ignore(); // Cancel the close event + } + } else { + event->accept(); // No changes, close the dialog without prompting + } +} +void EditorDialog::keyPressEvent(QKeyEvent* event) { + if (event->key() == Qt::Key_Escape) { + if (isHelpOpen) { + helpDialog->close(); + isHelpOpen = false; + } + close(); // Trigger the close action, same as pressing the close button + } else { + QDialog::keyPressEvent(event); // Call the base class implementation for other keys + } +} + +void EditorDialog::onSaveClicked() { + if (isHelpOpen) { + helpDialog->close(); + isHelpOpen = false; + } + saveFile(gameComboBox->currentText()); + reject(); // Close the dialog +} + +void EditorDialog::onCancelClicked() { + if (isHelpOpen) { + helpDialog->close(); + isHelpOpen = false; + } + reject(); // Close the dialog +} + +void EditorDialog::onHelpClicked() { + if (!isHelpOpen) { + helpDialog = new HelpDialog(&isHelpOpen, this); + helpDialog->setWindowTitle("Help"); + helpDialog->setAttribute(Qt::WA_DeleteOnClose); // Clean up on close + // Get the position and size of the Config window + QRect configGeometry = this->geometry(); + int helpX = configGeometry.x() + configGeometry.width() + 10; // 10 pixels offset + int helpY = configGeometry.y(); + // Move the Help dialog to the right side of the Config window + helpDialog->move(helpX, helpY); + helpDialog->show(); + isHelpOpen = true; + } else { + helpDialog->close(); + isHelpOpen = false; + } +} + +void EditorDialog::onResetToDefaultClicked() { + bool default_default = gameComboBox->currentText() == "default"; + QString prompt = + default_default + ? "Do you want to reset your custom default config to the original default config?" + : "Do you want to reset this config to your custom default config?"; + QMessageBox::StandardButton reply = + QMessageBox::question(this, "Reset to Default", prompt, QMessageBox::Yes | QMessageBox::No); + + if (reply == QMessageBox::Yes) { + if (default_default) { + const auto default_file = Config::GetFoolproofKbmConfigFile("default"); + std::filesystem::remove(default_file); + } + const auto config_file = Config::GetFoolproofKbmConfigFile("default"); + QFile file(config_file); + + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&file); + editor->setPlainText(in.readAll()); + file.close(); + } else { + QMessageBox::warning(this, "Error", "Could not open the file for reading"); + } + // saveFile(gameComboBox->currentText()); + } +} + +bool EditorDialog::hasUnsavedChanges() { + // Compare the current content with the original content to check if there are unsaved changes + return editor->toPlainText() != originalConfig; +} +void EditorDialog::loadInstalledGames() { + previous_game = "default"; + QStringList filePaths; + for (const auto& installLoc : Config::getGameInstallDirs()) { + QString installDir; + Common::FS::PathToQString(installDir, installLoc); + QDir parentFolder(installDir); + QFileInfoList fileList = parentFolder.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + for (const auto& fileInfo : fileList) { + if (fileInfo.isDir() && !fileInfo.filePath().endsWith("-UPDATE")) { + gameComboBox->addItem(fileInfo.fileName()); // Add game name to combo box + } + } + } +} +void EditorDialog::onGameSelectionChanged(const QString& game) { + saveFile(previous_game); + loadFile(gameComboBox->currentText()); // Reload file based on the selected game + previous_game = gameComboBox->currentText(); +} diff --git a/src/qt_gui/kbm_config_dialog.h b/src/qt_gui/kbm_config_dialog.h new file mode 100644 index 000000000..f436b4a71 --- /dev/null +++ b/src/qt_gui/kbm_config_dialog.h @@ -0,0 +1,38 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include +#include "string" + +class EditorDialog : public QDialog { + Q_OBJECT // Necessary for using Qt's meta-object system (signals/slots) + public : explicit EditorDialog(QWidget* parent = nullptr); // Constructor + +protected: + void closeEvent(QCloseEvent* event) override; // Override close event + void keyPressEvent(QKeyEvent* event) override; + +private: + QPlainTextEdit* editor; // Editor widget for the config file + QFont editorFont; // To handle the text size + QString originalConfig; // Starting config string + std::string gameId; + + QComboBox* gameComboBox; // Combo box for selecting game configurations + + void loadFile(QString game); // Function to load the config file + void saveFile(QString game); // Function to save the config file + void loadInstalledGames(); // Helper to populate gameComboBox + bool hasUnsavedChanges(); // Checks for unsaved changes + +private slots: + void onSaveClicked(); // Save button slot + void onCancelClicked(); // Slot for handling cancel button + void onHelpClicked(); // Slot for handling help button + void onResetToDefaultClicked(); + void onGameSelectionChanged(const QString& game); // Slot for game selection changes +}; diff --git a/src/qt_gui/kbm_help_dialog.cpp b/src/qt_gui/kbm_help_dialog.cpp new file mode 100644 index 000000000..44f75f6f8 --- /dev/null +++ b/src/qt_gui/kbm_help_dialog.cpp @@ -0,0 +1,112 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "kbm_help_dialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +ExpandableSection::ExpandableSection(const QString& title, const QString& content, + QWidget* parent = nullptr) + : QWidget(parent) { + QVBoxLayout* layout = new QVBoxLayout(this); + + // Button to toggle visibility of content + toggleButton = new QPushButton(title); + layout->addWidget(toggleButton); + + // QTextBrowser for content (initially hidden) + contentBrowser = new QTextBrowser(); + contentBrowser->setPlainText(content); + contentBrowser->setVisible(false); + + // Remove scrollbars from QTextBrowser + contentBrowser->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + contentBrowser->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + // Set size policy to allow vertical stretching only + contentBrowser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); + + // Calculate and set initial height based on content + updateContentHeight(); + + layout->addWidget(contentBrowser); + + // Connect button click to toggle visibility + connect(toggleButton, &QPushButton::clicked, [this]() { + contentBrowser->setVisible(!contentBrowser->isVisible()); + if (contentBrowser->isVisible()) { + updateContentHeight(); // Update height when expanding + } + emit expandedChanged(); // Notify for layout adjustments + }); + + // Connect to update height if content changes + connect(contentBrowser->document(), &QTextDocument::contentsChanged, this, + &ExpandableSection::updateContentHeight); + + // Minimal layout settings for spacing + layout->setSpacing(2); + layout->setContentsMargins(0, 0, 0, 0); +} + +void HelpDialog::closeEvent(QCloseEvent* event) { + *help_open_ptr = false; + close(); +} +void HelpDialog::reject() { + *help_open_ptr = false; + close(); +} + +HelpDialog::HelpDialog(bool* open_flag, QWidget* parent) : QDialog(parent) { + help_open_ptr = open_flag; + // Main layout for the help dialog + QVBoxLayout* mainLayout = new QVBoxLayout(this); + + // Container widget for the scroll area + QWidget* containerWidget = new QWidget; + QVBoxLayout* containerLayout = new QVBoxLayout(containerWidget); + + // Add expandable sections to container layout + auto* quickstartSection = new ExpandableSection("Quickstart", quickstart()); + auto* faqSection = new ExpandableSection("FAQ", faq()); + auto* syntaxSection = new ExpandableSection("Syntax", syntax()); + auto* specialSection = new ExpandableSection("Special Bindings", special()); + auto* bindingsSection = new ExpandableSection("Keybindings", bindings()); + + containerLayout->addWidget(quickstartSection); + containerLayout->addWidget(faqSection); + containerLayout->addWidget(syntaxSection); + containerLayout->addWidget(specialSection); + containerLayout->addWidget(bindingsSection); + containerLayout->addStretch(1); + + // Scroll area wrapping the container + QScrollArea* scrollArea = new QScrollArea; + scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + scrollArea->setWidgetResizable(true); + scrollArea->setWidget(containerWidget); + + // Add the scroll area to the main dialog layout + mainLayout->addWidget(scrollArea); + setLayout(mainLayout); + + // Minimum size for the dialog + setMinimumSize(500, 400); + + // Re-adjust dialog layout when any section expands/collapses + connect(quickstartSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize); + connect(faqSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize); + connect(syntaxSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize); + connect(specialSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize); + connect(bindingsSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize); +} \ No newline at end of file diff --git a/src/qt_gui/kbm_help_dialog.h b/src/qt_gui/kbm_help_dialog.h new file mode 100644 index 000000000..8d543b7e7 --- /dev/null +++ b/src/qt_gui/kbm_help_dialog.h @@ -0,0 +1,169 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include +#include +#include +#include + +class ExpandableSection : public QWidget { + Q_OBJECT +public: + explicit ExpandableSection(const QString& title, const QString& content, QWidget* parent); + +signals: + void expandedChanged(); // Signal to indicate layout size change + +private: + QPushButton* toggleButton; + QTextBrowser* contentBrowser; // Changed from QLabel to QTextBrowser + QPropertyAnimation* animation; + int contentHeight; + void updateContentHeight() { + int contentHeight = contentBrowser->document()->size().height(); + contentBrowser->setMinimumHeight(contentHeight + 5); + contentBrowser->setMaximumHeight(contentHeight + 50); + } +}; + +class HelpDialog : public QDialog { + Q_OBJECT +public: + explicit HelpDialog(bool* open_flag = nullptr, QWidget* parent = nullptr); + +protected: + void closeEvent(QCloseEvent* event) override; + void reject() override; + +private: + bool* help_open_ptr; + + QString quickstart() { + return + R"(The keyboard and controller remapping backend, GUI and documentation have been written by kalaposfos + +In this section, you will find information about the project, its features and help on setting up your ideal setup. +To view the config file's syntax, check out the Syntax tab, for keybind names, visit Normal Keybinds and Special Bindings, and if you are here to view emulator-wide keybinds, you can find it in the FAQ section. +This project started out because I didn't like the original unchangeable keybinds, but rather than waiting for someone else to do it, I implemented this myself. From the default keybinds, you can clearly tell this was a project built for Bloodborne, but ovbiously you can make adjustments however you like. +)"; + } + QString faq() { + return + R"(Q: What are the emulator-wide keybinds? +A: -F12: Triggers Renderdoc capture +-F11: Toggles fullscreen +-F10: Toggles FPS counter +-Ctrl F10: Open the debug menu +-F9: Pauses emultor, if the debug menu is open +-F8: Reparses the config file while in-game +-F7: Toggles mouse capture and mouse input + +Q: How do I change between mouse and controller joystick input, and why is it even required? +A: You can switch between them with F7, and it is required, because mouse input is done with polling, which means mouse movement is checked every frame, and if it didn't move, the code manually sets the emulator's virtual controller to 0 (back to the center), even if other input devices would update it. + +Q: What happens if I accidentally make a typo in the config? +A: The code recognises the line as wrong, and skip it, so the rest of the file will get parsed, but that line in question will be treated like a comment line. You can find these lines in the log, if you search for 'input_handler'. + +Q: I want to bind to , but your code doesn't support ! +A: Some keys are intentionally omitted, but if you read the bindings through, and you're sure it is not there and isn't one of the intentionally disabled ones, open an issue on https://github.com/shadps4-emu/shadPS4. +)"; + } + QString syntax() { + return + R"(This is the full list of currently supported mouse, keyboard and controller inputs, and how to use them. +Emulator-reserved keys: F1 through F12 + +Syntax (aka how a line can look like): +#Comment line + = , , ; + = , ; + = ; + +Examples: +#Interact +cross = e; +#Heavy attack (in BB) +r2 = leftbutton, lshift; +#Move forward +axis_left_y_minus = w; + +You can make a comment line by putting # as the first character. +Whitespace doesn't matter, =; is just as valid as = ; +';' at the ends of lines is also optional. +)"; + } + QString bindings() { + return + R"(The following names should be interpreted without the '' around them, and for inputs that have left and right versions, only the left one is shown, but the right can be inferred from that. +Example: 'lshift', 'rshift' + +Keyboard: +Alphabet: 'a', 'b', ..., 'z' +Numbers: '0', '1', ..., '9' +Keypad: 'kp0', kp1', ..., 'kp9', 'kpperiod', 'kpcomma', + 'kpdivide', 'kpmultiply', 'kpdivide', 'kpplus', 'kpminus', 'kpenter' +Punctuation and misc: + 'space', 'comma', 'period', 'question', 'semicolon', 'minus', 'plus', 'lparenthesis', 'lbracket', 'lbrace', 'backslash', 'dash', + 'enter', 'tab', backspace', 'escape' +Arrow keys: 'up', 'down', 'left', 'right' +Modifier keys: + 'lctrl', 'lshift', 'lalt', 'lwin' = 'lmeta' (same input, different names, so if you are not on Windows and don't like calling this the Windows key, there is an alternative) + +Mouse: + 'leftbutton', 'rightbutton', 'middlebutton', 'sidebuttonforward', 'sidebuttonback' + The following wheel inputs cannot be bound to axis input, only button: + 'mousewheelup', 'mousewheeldown', 'mousewheelleft', 'mousewheelright' + +Controller: + The touchpad currently can't be rebound to anything else, but you can bind buttons to it. + If you have a controller that has different names for buttons, it will still work, just look up what are the equivalent names for that controller + The same left-right rule still applies here. + Buttons: + 'triangle', 'circle', 'cross', 'square', 'l1', 'l3', + 'options', touchpad', 'up', 'down', 'left', 'right' + Axes if you bind them to a button input: + 'axis_left_x_plus', 'axis_left_x_minus', 'axis_left_y_plus', 'axis_left_y_minus', + 'axis_right_x_plus', ..., 'axis_right_y_minus', + 'l2' + Axes if you bind them to another axis input: + 'axis_left_x' 'axis_left_y' 'axis_right_x' 'axis_right_y', + 'l2' +)"; + } + QString special() { + return + R"(There are some extra bindings you can put into the config file, that don't correspond to a controller input, but rather something else. +You can find these here, with detailed comments, examples and suggestions for most of them. + +'leftjoystick_halfmode' and 'rightjoystick_halfmode' = ; + These are a pair of input modifiers, that change the way keyboard button bound axes work. By default, those push the joystick to the max in their respective direction, but if their respective joystick_halfmode modifier value is true, they only push it... halfway. With this, you can change from run to walk in games like Bloodborne. + +'mouse_to_joystick' = 'none', 'left' or 'right'; + This binds the mouse movement to either joystick. If it recieves a value that is not 'left' or 'right', it defaults to 'none'. + +'mouse_movement_params' = float, float, float; + (If you don't know what a float is, it is a data type that stores non-whole numbers.) + Default values: 0.5, 1, 0.125 + Let's break each parameter down: + 1st: mouse_deadzone_offset: this value should have a value between 0 and 1 (It gets clamped to that range anyway), with 0 being no offset and 1 being pushing the joystick to the max in the direction the mouse moved. + This controls the minimum distance the joystick gets moved, when moving the mouse. If set to 0, it will emulate raw mouse input, which doesn't work very well due to deadzones preventing input if the movement is not large enough. + 2nd: mouse_speed: It's just a standard multiplier to the mouse input speed. + If you input a negative number, the axis directions get reversed (Keep in mind that the offset can still push it back to positive, if it's big enough) + 3rd: mouse_speed_offset: This also should be in the 0 to 1 range, with 0 being no offset and 1 being offsetting to the max possible value. + This is best explained through an example: Let's set mouse_deadzone to 0.5, and this to 0: This means that if we move the mousevery slowly, it still inputs a half-strength joystick input, and if we increase the speed, it would stay that way until we move faster than half the max speed. If we instead set this to 0.25, we now only need to move the mouse faster than the 0.5-0.25=0.25=quarter of the max speed, to get an increase in joystick speed. If we set it to 0.5, then even moving the mouse at 1 pixel per frame will result in a faster-than-minimum speed. + +'key_toggle' = , ; + This assigns a key to another key, and if pressed, toggles that key's virtual value. If it's on, then it doesn't matter if the key is pressed or not, the input handler will treat it as if it's pressed. + You can make an input toggleable with this, for example: Let's say we want to be able to toggle l1 with t. You can then bind l1 to a key you won't use, like kpenter, then bind t to toggle that, so you will end up with this: + l1 = kpenter; + key_toggle = t, kpenter; +'analog_deadzone' = , ; + value goes from 1 to 127 (no deadzone to max deadzone) + devices: leftjoystick, rightjoystick, l2, r2 +)"; + } +}; \ No newline at end of file diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index aa02d1237..de3557992 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "about_dialog.h" @@ -21,6 +22,9 @@ #include "install_dir_select.h" #include "main_window.h" #include "settings_dialog.h" + +#include "kbm_config_dialog.h" + #include "video_core/renderer_vulkan/vk_instance.h" #ifdef ENABLE_DISCORD_RPC #include "common/discord_rpc_handler.h" @@ -291,6 +295,12 @@ void MainWindow::CreateConnects() { settingsDialog->exec(); }); + // this is the editor for kbm keybinds + connect(ui->controllerButton, &QPushButton::clicked, this, [this]() { + EditorDialog* editorWindow = new EditorDialog(this); + editorWindow->exec(); // Show the editor window modally + }); + #ifdef ENABLE_UPDATER connect(ui->updaterAct, &QAction::triggered, this, [this]() { auto checkUpdate = new CheckUpdate(true); diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index 9b7617925..6eaad62e5 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -1,24 +1,27 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include -#include -#include -#include -#include -#include - +#include "SDL3/SDL_events.h" +#include "SDL3/SDL_hints.h" +#include "SDL3/SDL_init.h" +#include "SDL3/SDL_properties.h" +#include "SDL3/SDL_timer.h" +#include "SDL3/SDL_video.h" #include "common/assert.h" #include "common/config.h" +#include "common/elf_info.h" +#include "common/version.h" #include "core/libraries/kernel/time.h" #include "core/libraries/pad/pad.h" #include "imgui/renderer/imgui_core.h" #include "input/controller.h" +#include "input/input_handler.h" +#include "input/input_mouse.h" #include "sdl_window.h" #include "video_core/renderdoc.h" #ifdef __APPLE__ -#include +#include "SDL3/SDL_metal.h" #endif namespace Input { @@ -290,6 +293,10 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_ window_info.type = WindowSystemType::Metal; window_info.render_surface = SDL_Metal_GetLayer(SDL_Metal_CreateView(window)); #endif + // input handler init-s + Input::ControllerOutput::SetControllerOutputController(controller); + Input::ControllerOutput::LinkJoystickAxes(); + Input::ParseInputConfig(std::string(Common::ElfInfo::Instance().GameSerial())); } WindowSDL::~WindowSDL() = default; @@ -317,18 +324,28 @@ void WindowSDL::WaitEvent() { is_shown = event.type == SDL_EVENT_WINDOW_EXPOSED; OnResize(); break; + case SDL_EVENT_MOUSE_BUTTON_DOWN: + case SDL_EVENT_MOUSE_BUTTON_UP: + case SDL_EVENT_MOUSE_WHEEL: + case SDL_EVENT_MOUSE_WHEEL_OFF: case SDL_EVENT_KEY_DOWN: case SDL_EVENT_KEY_UP: - OnKeyPress(&event); + OnKeyboardMouseInput(&event); + break; + case SDL_EVENT_GAMEPAD_ADDED: + case SDL_EVENT_GAMEPAD_REMOVED: + controller->SetEngine(std::make_unique()); + break; + case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN: + case SDL_EVENT_GAMEPAD_TOUCHPAD_UP: + case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION: + controller->SetTouchpadState(event.gtouchpad.finger, + event.type != SDL_EVENT_GAMEPAD_TOUCHPAD_UP, event.gtouchpad.x, + event.gtouchpad.y); break; case SDL_EVENT_GAMEPAD_BUTTON_DOWN: case SDL_EVENT_GAMEPAD_BUTTON_UP: case SDL_EVENT_GAMEPAD_AXIS_MOTION: - case SDL_EVENT_GAMEPAD_ADDED: - case SDL_EVENT_GAMEPAD_REMOVED: - case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN: - case SDL_EVENT_GAMEPAD_TOUCHPAD_UP: - case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION: OnGamepadEvent(&event); break; // i really would have appreciated ANY KIND OF DOCUMENTATION ON THIS @@ -355,6 +372,7 @@ void WindowSDL::WaitEvent() { void WindowSDL::InitTimers() { SDL_AddTimer(100, &PollController, controller); + SDL_AddTimer(33, Input::MousePolling, (void*)controller); } void WindowSDL::RequestKeyboard() { @@ -381,239 +399,87 @@ void WindowSDL::OnResize() { ImGui::Core::OnResize(); } -void WindowSDL::OnKeyPress(const SDL_Event* event) { - auto button = OrbisPadButtonDataOffset::None; - Input::Axis axis = Input::Axis::AxisMax; - int axisvalue = 0; - int ax = 0; - std::string backButtonBehavior = Config::getBackButtonBehavior(); - switch (event->key.key) { - case SDLK_UP: - button = OrbisPadButtonDataOffset::Up; - break; - case SDLK_DOWN: - button = OrbisPadButtonDataOffset::Down; - break; - case SDLK_LEFT: - button = OrbisPadButtonDataOffset::Left; - break; - case SDLK_RIGHT: - button = OrbisPadButtonDataOffset::Right; - break; - // Provide alternatives for face buttons for users without a numpad. - case SDLK_KP_8: - case SDLK_C: - button = OrbisPadButtonDataOffset::Triangle; - break; - case SDLK_KP_6: - case SDLK_B: - button = OrbisPadButtonDataOffset::Circle; - break; - case SDLK_KP_2: - case SDLK_N: - button = OrbisPadButtonDataOffset::Cross; - break; - case SDLK_KP_4: - case SDLK_V: - button = OrbisPadButtonDataOffset::Square; - break; - case SDLK_RETURN: - button = OrbisPadButtonDataOffset::Options; - break; - case SDLK_A: - axis = Input::Axis::LeftX; - if (event->type == SDL_EVENT_KEY_DOWN) { - axisvalue += -127; - } else { - axisvalue = 0; +Uint32 wheelOffCallback(void* og_event, Uint32 timer_id, Uint32 interval) { + SDL_Event off_event = *(SDL_Event*)og_event; + off_event.type = SDL_EVENT_MOUSE_WHEEL_OFF; + SDL_PushEvent(&off_event); + delete (SDL_Event*)og_event; + return 0; +} + +void WindowSDL::OnKeyboardMouseInput(const SDL_Event* event) { + using Libraries::Pad::OrbisPadButtonDataOffset; + + // get the event's id, if it's keyup or keydown + const bool input_down = event->type == SDL_EVENT_KEY_DOWN || + event->type == SDL_EVENT_MOUSE_BUTTON_DOWN || + event->type == SDL_EVENT_MOUSE_WHEEL; + Input::InputEvent input_event = Input::InputBinding::GetInputEventFromSDLEvent(*event); + + // Handle window controls outside of the input maps + if (event->type == SDL_EVENT_KEY_DOWN) { + u32 input_id = input_event.input.sdl_id; + // Reparse kbm inputs + if (input_id == SDLK_F8) { + Input::ParseInputConfig(std::string(Common::ElfInfo::Instance().GameSerial())); + return; } - ax = Input::GetAxis(-0x80, 0x80, axisvalue); - break; - case SDLK_D: - axis = Input::Axis::LeftX; - if (event->type == SDL_EVENT_KEY_DOWN) { - axisvalue += 127; - } else { - axisvalue = 0; + // Toggle mouse capture and movement input + else if (input_id == SDLK_F7) { + Input::ToggleMouseEnabled(); + SDL_SetWindowRelativeMouseMode(this->GetSDLWindow(), + !SDL_GetWindowRelativeMouseMode(this->GetSDLWindow())); + return; } - ax = Input::GetAxis(-0x80, 0x80, axisvalue); - break; - case SDLK_W: - axis = Input::Axis::LeftY; - if (event->type == SDL_EVENT_KEY_DOWN) { - axisvalue += -127; - } else { - axisvalue = 0; + // Toggle fullscreen + else if (input_id == SDLK_F11) { + SDL_WindowFlags flag = SDL_GetWindowFlags(window); + bool is_fullscreen = flag & SDL_WINDOW_FULLSCREEN; + SDL_SetWindowFullscreen(window, !is_fullscreen); + return; } - ax = Input::GetAxis(-0x80, 0x80, axisvalue); - break; - case SDLK_S: - axis = Input::Axis::LeftY; - if (event->type == SDL_EVENT_KEY_DOWN) { - axisvalue += 127; - } else { - axisvalue = 0; - } - ax = Input::GetAxis(-0x80, 0x80, axisvalue); - break; - case SDLK_J: - axis = Input::Axis::RightX; - if (event->type == SDL_EVENT_KEY_DOWN) { - axisvalue += -127; - } else { - axisvalue = 0; - } - ax = Input::GetAxis(-0x80, 0x80, axisvalue); - break; - case SDLK_L: - axis = Input::Axis::RightX; - if (event->type == SDL_EVENT_KEY_DOWN) { - axisvalue += 127; - } else { - axisvalue = 0; - } - ax = Input::GetAxis(-0x80, 0x80, axisvalue); - break; - case SDLK_I: - axis = Input::Axis::RightY; - if (event->type == SDL_EVENT_KEY_DOWN) { - axisvalue += -127; - } else { - axisvalue = 0; - } - ax = Input::GetAxis(-0x80, 0x80, axisvalue); - break; - case SDLK_K: - axis = Input::Axis::RightY; - if (event->type == SDL_EVENT_KEY_DOWN) { - axisvalue += 127; - } else { - axisvalue = 0; - } - ax = Input::GetAxis(-0x80, 0x80, axisvalue); - break; - case SDLK_X: - button = OrbisPadButtonDataOffset::L3; - break; - case SDLK_M: - button = OrbisPadButtonDataOffset::R3; - break; - case SDLK_Q: - button = OrbisPadButtonDataOffset::L1; - break; - case SDLK_U: - button = OrbisPadButtonDataOffset::R1; - break; - case SDLK_E: - button = OrbisPadButtonDataOffset::L2; - axis = Input::Axis::TriggerLeft; - if (event->type == SDL_EVENT_KEY_DOWN) { - axisvalue += 255; - } else { - axisvalue = 0; - } - ax = Input::GetAxis(0, 0x80, axisvalue); - break; - case SDLK_O: - button = OrbisPadButtonDataOffset::R2; - axis = Input::Axis::TriggerRight; - if (event->type == SDL_EVENT_KEY_DOWN) { - axisvalue += 255; - } else { - axisvalue = 0; - } - ax = Input::GetAxis(0, 0x80, axisvalue); - break; - case SDLK_SPACE: - if (backButtonBehavior != "none") { - float x = backButtonBehavior == "left" ? 0.25f - : (backButtonBehavior == "right" ? 0.75f : 0.5f); - // trigger a touchpad event so that the touchpad emulation for back button works - controller->SetTouchpadState(0, true, x, 0.5f); - button = OrbisPadButtonDataOffset::TouchPad; - } else { - button = {}; - } - break; - case SDLK_F11: - if (event->type == SDL_EVENT_KEY_DOWN) { - { - SDL_WindowFlags flag = SDL_GetWindowFlags(window); - bool is_fullscreen = flag & SDL_WINDOW_FULLSCREEN; - SDL_SetWindowFullscreen(window, !is_fullscreen); - } - } - break; - case SDLK_F12: - if (event->type == SDL_EVENT_KEY_DOWN) { - // Trigger rdoc capture + // Trigger rdoc capture + else if (input_id == SDLK_F12) { VideoCore::TriggerCapture(); + return; } - break; - default: - break; } - if (button != OrbisPadButtonDataOffset::None) { - controller->CheckButton(0, button, event->type == SDL_EVENT_KEY_DOWN); + + // if it's a wheel event, make a timer that turns it off after a set time + if (event->type == SDL_EVENT_MOUSE_WHEEL) { + const SDL_Event* copy = new SDL_Event(*event); + SDL_AddTimer(33, wheelOffCallback, (void*)copy); } - if (axis != Input::Axis::AxisMax) { - controller->Axis(0, axis, ax); + + // add/remove it from the list + bool inputs_changed = Input::UpdatePressedKeys(input_event); + + // update bindings + if (inputs_changed) { + Input::ActivateOutputsFromInputs(); } } void WindowSDL::OnGamepadEvent(const SDL_Event* event) { - auto button = OrbisPadButtonDataOffset::None; - Input::Axis axis = Input::Axis::AxisMax; - switch (event->type) { - case SDL_EVENT_GAMEPAD_ADDED: - case SDL_EVENT_GAMEPAD_REMOVED: - controller->SetEngine(std::make_unique()); - break; - case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN: - case SDL_EVENT_GAMEPAD_TOUCHPAD_UP: - case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION: - controller->SetTouchpadState(event->gtouchpad.finger, - event->type != SDL_EVENT_GAMEPAD_TOUCHPAD_UP, - event->gtouchpad.x, event->gtouchpad.y); - break; - case SDL_EVENT_GAMEPAD_BUTTON_DOWN: - case SDL_EVENT_GAMEPAD_BUTTON_UP: { - button = Input::SDLGamepadToOrbisButton(event->gbutton.button); - if (button == OrbisPadButtonDataOffset::None) { - break; - } - if (event->gbutton.button != SDL_GAMEPAD_BUTTON_BACK) { - controller->CheckButton(0, button, event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN); - break; - } - const auto backButtonBehavior = Config::getBackButtonBehavior(); - if (backButtonBehavior != "none") { - float x = backButtonBehavior == "left" ? 0.25f - : (backButtonBehavior == "right" ? 0.75f : 0.5f); - // trigger a touchpad event so that the touchpad emulation for back button works - controller->SetTouchpadState(0, true, x, 0.5f); - controller->CheckButton(0, button, event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN); - } - break; - } - case SDL_EVENT_GAMEPAD_AXIS_MOTION: - axis = event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFTX ? Input::Axis::LeftX - : event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFTY ? Input::Axis::LeftY - : event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHTX ? Input::Axis::RightX - : event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHTY ? Input::Axis::RightY - : event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFT_TRIGGER ? Input::Axis::TriggerLeft - : event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER ? Input::Axis::TriggerRight - : Input::Axis::AxisMax; - if (axis != Input::Axis::AxisMax) { - if (event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFT_TRIGGER || - event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER) { - controller->Axis(0, axis, Input::GetAxis(0, 0x8000, event->gaxis.value)); - } else { - controller->Axis(0, axis, Input::GetAxis(-0x8000, 0x8000, event->gaxis.value)); - } - } - break; + bool input_down = event->type == SDL_EVENT_GAMEPAD_AXIS_MOTION || + event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN; + Input::InputEvent input_event = Input::InputBinding::GetInputEventFromSDLEvent(*event); + + // the touchpad button shouldn't be rebound to anything else, + // as it would break the entire touchpad handling + // You can still bind other things to it though + if (event->gbutton.button == SDL_GAMEPAD_BUTTON_TOUCHPAD) { + controller->CheckButton(0, OrbisPadButtonDataOffset::TouchPad, input_down); + return; + } + + // add/remove it from the list + bool inputs_changed = Input::UpdatePressedKeys(input_event); + + // update bindings + if (inputs_changed) { + Input::ActivateOutputsFromInputs(); } } diff --git a/src/sdl_window.h b/src/sdl_window.h index 3ab3c3613..9acd2b16b 100644 --- a/src/sdl_window.h +++ b/src/sdl_window.h @@ -3,9 +3,10 @@ #pragma once -#include #include "common/types.h" +#include "core/libraries/pad/pad.h" #include "input/controller.h" +#include "string" struct SDL_Window; struct SDL_Gamepad; @@ -94,7 +95,7 @@ public: private: void OnResize(); - void OnKeyPress(const SDL_Event* event); + void OnKeyboardMouseInput(const SDL_Event* event); void OnGamepadEvent(const SDL_Event* event); private: From 9aa6c5b9514c9c9c3ce3469790613af987725ec5 Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Fri, 31 Jan 2025 17:41:11 +0100 Subject: [PATCH 67/72] Remapping: Documentation and defaults update + add option to use a unified config (#2302) * Add a toggle to use unified or per-game configs, and add a deadzone example to the default config * Add a checkbox to toggle config type * clang --- src/common/config.cpp | 16 +++++++++++++++- src/common/config.h | 2 ++ src/input/input_handler.cpp | 7 ++----- src/qt_gui/kbm_config_dialog.cpp | 11 +++++++++++ src/qt_gui/kbm_help_dialog.h | 6 ++++++ 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index e79a52796..fee0b4ed3 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -68,6 +68,7 @@ static bool vkGuestMarkers = false; static bool rdocEnable = false; static s16 cursorState = HideCursorState::Idle; static int cursorHideTimeout = 5; // 5 seconds (default) +static bool useUnifiedInputConfig = true; static bool separateupdatefolder = false; static bool compatibilityData = false; static bool checkCompatibilityOnStartup = false; @@ -98,6 +99,14 @@ std::string emulator_language = "en"; // Language u32 m_language = 1; // english +bool GetUseUnifiedInputConfig() { + return useUnifiedInputConfig; +} + +void SetUseUnifiedInputConfig(bool use) { + useUnifiedInputConfig = use; +} + std::string getTrophyKey() { return trophyKey; } @@ -657,6 +666,7 @@ void load(const std::filesystem::path& path) { useSpecialPad = toml::find_or(input, "useSpecialPad", false); specialPadClass = toml::find_or(input, "specialPadClass", 1); isMotionControlsEnabled = toml::find_or(input, "isMotionControlsEnabled", true); + useUnifiedInputConfig = toml::find_or(input, "useUnifiedInputConfig", true); } if (data.contains("GPU")) { @@ -779,6 +789,7 @@ void save(const std::filesystem::path& path) { data["Input"]["useSpecialPad"] = useSpecialPad; data["Input"]["specialPadClass"] = specialPadClass; data["Input"]["isMotionControlsEnabled"] = isMotionControlsEnabled; + data["Input"]["useUnifiedInputConfig"] = useUnifiedInputConfig; data["GPU"]["screenWidth"] = screenWidth; data["GPU"]["screenHeight"] = screenHeight; data["GPU"]["nullGpu"] = isNullGpu; @@ -969,9 +980,12 @@ touchpad = back axis_left_x = axis_left_x axis_left_y = axis_left_y - axis_right_x = axis_right_x axis_right_y = axis_right_y + +# Range of deadzones: 1 (almost none) to 127 (max) +analog_deadzone = leftjoystick, 2 +analog_deadzone = rightjoystick, 2 )"; } std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id) { diff --git a/src/common/config.h b/src/common/config.h index f726f840c..77ed69ece 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -43,6 +43,8 @@ std::string getBackButtonBehavior(); bool getUseSpecialPad(); int getSpecialPadClass(); bool getIsMotionControlsEnabled(); +bool GetUseUnifiedInputConfig(); +void SetUseUnifiedInputConfig(bool use); u32 getScreenWidth(); u32 getScreenHeight(); diff --git a/src/input/input_handler.cpp b/src/input/input_handler.cpp index a78a54131..5394e4818 100644 --- a/src/input/input_handler.cpp +++ b/src/input/input_handler.cpp @@ -198,11 +198,8 @@ InputBinding GetBindingFromString(std::string& line) { } void ParseInputConfig(const std::string game_id = "") { - const auto config_file = Config::GetFoolproofKbmConfigFile(game_id); - - if (game_id == "") { - return; - } + std::string config_type = Config::GetUseUnifiedInputConfig() ? "default" : game_id; + const auto config_file = Config::GetFoolproofKbmConfigFile(config_type); // we reset these here so in case the user fucks up or doesn't include some of these, // we can fall back to default diff --git a/src/qt_gui/kbm_config_dialog.cpp b/src/qt_gui/kbm_config_dialog.cpp index af198f79d..74a49034b 100644 --- a/src/qt_gui/kbm_config_dialog.cpp +++ b/src/qt_gui/kbm_config_dialog.cpp @@ -12,6 +12,7 @@ #include "game_info.h" #include "src/sdl_window.h" +#include #include #include #include @@ -50,7 +51,16 @@ EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) { // Load all installed games loadInstalledGames(); + QCheckBox* unifiedInputCheckBox = new QCheckBox("Use Per-Game configs", this); + unifiedInputCheckBox->setChecked(!Config::GetUseUnifiedInputConfig()); + + // Connect checkbox signal + connect(unifiedInputCheckBox, &QCheckBox::toggled, this, [](bool checked) { + Config::SetUseUnifiedInputConfig(!checked); + Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml"); + }); // Create Save, Cancel, and Help buttons + Config::SetUseUnifiedInputConfig(!Config::GetUseUnifiedInputConfig()); QPushButton* saveButton = new QPushButton("Save", this); QPushButton* cancelButton = new QPushButton("Cancel", this); QPushButton* helpButton = new QPushButton("Help", this); @@ -58,6 +68,7 @@ EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) { // Layout for the game selection and buttons QHBoxLayout* topLayout = new QHBoxLayout(); + topLayout->addWidget(unifiedInputCheckBox); topLayout->addWidget(gameComboBox); topLayout->addStretch(); topLayout->addWidget(saveButton); diff --git a/src/qt_gui/kbm_help_dialog.h b/src/qt_gui/kbm_help_dialog.h index 8d543b7e7..c482d2b5c 100644 --- a/src/qt_gui/kbm_help_dialog.h +++ b/src/qt_gui/kbm_help_dialog.h @@ -70,6 +70,12 @@ A: The code recognises the line as wrong, and skip it, so the rest of the file w Q: I want to bind to , but your code doesn't support ! A: Some keys are intentionally omitted, but if you read the bindings through, and you're sure it is not there and isn't one of the intentionally disabled ones, open an issue on https://github.com/shadps4-emu/shadPS4. + +Q: What does default.ini do? +A: If you're using per-game configs, it's the base from which all new games generate their config file. If you use the unified config, then this is used for every game directly instead. + +Q: What does the use Per-game Config checkbox do? +A: It controls whether the config is loaded from CUSAXXXXX.ini for a game, or from default.ini. This way, if you only want to manage one set of bindings, you can do so, but if you want to use a different setup for every game, that's possible as well. )"; } QString syntax() { From 259d5ef60b5cd0aa1474f6c3be757804203890a3 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sat, 1 Feb 2025 00:34:41 -0800 Subject: [PATCH 68/72] config: Restore previous keyboard mapping defaults. (#2313) --- README.md | 53 +++++++++++++++++++------------------- src/common/config.cpp | 60 +++++++++++++++++++++---------------------- 2 files changed, 57 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 0e5ba7e39..97e3ab383 100644 --- a/README.md +++ b/README.md @@ -92,33 +92,34 @@ F12 | Trigger RenderDoc Capture > [!NOTE] > Xbox and DualShock controllers work out of the box. -The default controls are inspired by the *Elden Ring* PC controls. Inputs support up to three keys per binding, mouse buttons, mouse movement mapped to joystick input, and more. +| Controller button | Keyboard equivalent | +|-------------|-------------| +LEFT AXIS UP | W | +LEFT AXIS DOWN | S | +LEFT AXIS LEFT | A | +LEFT AXIS RIGHT | D | +RIGHT AXIS UP | I | +RIGHT AXIS DOWN | K | +RIGHT AXIS LEFT | J | +RIGHT AXIS RIGHT | L | +TRIANGLE | Numpad 8 or C | +CIRCLE | Numpad 6 or B | +CROSS | Numpad 2 or N | +SQUARE | Numpad 4 or V | +PAD UP | UP | +PAD DOWN | DOWN | +PAD LEFT | LEFT | +PAD RIGHT | RIGHT | +OPTIONS | RETURN | +BACK BUTTON / TOUCH PAD | SPACE | +L1 | Q | +R1 | U | +L2 | E | +R2 | O | +L3 | X | +R3 | M | -| Action | Default Key(s) | -|-------------|-----------------------------| -| Triangle | F | -| Circle | Space | -| Cross | E | -| Square | R | -| Pad Up | W, LAlt / Mouse Wheel Up | -| Pad Down | S, LAlt / Mouse Wheel Down | -| Pad Left | A, LAlt / Mouse Wheel Left | -| Pad Right | D, LAlt / Mouse Wheel Right | -| L1 | Right Button, LShift | -| R1 | Left Button | -| L2 | Right Button | -| R2 | Left Button, LShift | -| L3 | X | -| R3 | Q / Middle Button | -| Options | Escape | -| Touchpad | G | - -| Joystick | Default Input | -|--------------------|----------------| -| Left Joystick | WASD | -| Right Joystick | Mouse movement | - -Keyboard and mouse inputs can be customized in the settings menu by clicking the Controller button, and further details and help on controls are also found there. Custom bindings are saved per-game. +Keyboard and mouse inputs can be customized in the settings menu by clicking the Controller button, and further details and help on controls are also found there. Custom bindings are saved per-game. Inputs support up to three keys per binding, mouse buttons, mouse movement mapped to joystick input, and more. # Main team diff --git a/src/common/config.cpp b/src/common/config.cpp index fee0b4ed3..2059da0b3 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -919,44 +919,44 @@ void setDefaultValues() { constexpr std::string_view GetDefaultKeyboardConfig() { return R"(#Feeling lost? Check out the Help section! -#Keyboard bindings +# Keyboard bindings -triangle = f -circle = space -cross = e -square = r +triangle = kp8 +circle = kp6 +cross = kp2 +square = kp4 +# Alternatives for users without a keypad +triangle = c +circle = b +cross = n +square = v -pad_up = w, lalt -pad_up = mousewheelup -pad_down = s, lalt -pad_down = mousewheeldown -pad_left = a, lalt -pad_left = mousewheelleft -pad_right = d, lalt -pad_right = mousewheelright - -l1 = rightbutton, lshift -r1 = leftbutton -l2 = rightbutton -r2 = leftbutton, lshift +l1 = q +r1 = u +l2 = e +r2 = o l3 = x -r3 = q -r3 = middlebutton +r3 = m -options = escape -touchpad = g +options = enter +touchpad = space -key_toggle = i, lalt -mouse_to_joystick = right -mouse_movement_params = 0.5, 1, 0.125 -leftjoystick_halfmode = lctrl +pad_up = up +pad_down = down +pad_left = left +pad_right = right axis_left_x_minus = a axis_left_x_plus = d axis_left_y_minus = w axis_left_y_plus = s -#Controller bindings +axis_right_x_minus = j +axis_right_x_plus = l +axis_right_y_minus = i +axis_right_y_plus = k + +# Controller bindings triangle = triangle cross = cross @@ -970,14 +970,14 @@ r1 = r1 r2 = r2 r3 = r3 +options = options +touchpad = back + pad_up = pad_up pad_down = pad_down pad_left = pad_left pad_right = pad_right -options = options -touchpad = back - axis_left_x = axis_left_x axis_left_y = axis_left_y axis_right_x = axis_right_x From e1550c9091e2389c09634c56befb6c589703d00c Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sat, 1 Feb 2025 00:52:40 -0800 Subject: [PATCH 69/72] audioout: Add error returns when not initialized. (#2309) --- src/core/libraries/audio/audioout.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core/libraries/audio/audioout.cpp b/src/core/libraries/audio/audioout.cpp index f0ad59c3b..dea8115e9 100644 --- a/src/core/libraries/audio/audioout.cpp +++ b/src/core/libraries/audio/audioout.cpp @@ -89,6 +89,9 @@ int PS4_SYSV_ABI sceAudioOutChangeAppModuleState() { int PS4_SYSV_ABI sceAudioOutClose(s32 handle) { LOG_INFO(Lib_AudioOut, "handle = {}", handle); + if (audio == nullptr) { + return ORBIS_AUDIO_OUT_ERROR_NOT_INIT; + } if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) { return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT; } @@ -171,6 +174,9 @@ int PS4_SYSV_ABI sceAudioOutGetLastOutputTime() { } int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* state) { + if (audio == nullptr) { + return ORBIS_AUDIO_OUT_ERROR_NOT_INIT; + } if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) { return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT; } @@ -305,6 +311,10 @@ s32 PS4_SYSV_ABI sceAudioOutOpen(UserService::OrbisUserServiceUserId user_id, user_id, magic_enum::enum_name(port_type), index, length, sample_rate, magic_enum::enum_name(param_type.data_format.Value()), magic_enum::enum_name(param_type.attributes.Value())); + if (audio == nullptr) { + LOG_ERROR(Lib_AudioOut, "Audio out not initialized"); + return ORBIS_AUDIO_OUT_ERROR_NOT_INIT; + } if ((port_type < OrbisAudioOutPort::Main || port_type > OrbisAudioOutPort::Padspk) && (port_type != OrbisAudioOutPort::Aux)) { LOG_ERROR(Lib_AudioOut, "Invalid port type"); @@ -368,6 +378,9 @@ int PS4_SYSV_ABI sceAudioOutOpenEx() { } s32 PS4_SYSV_ABI sceAudioOutOutput(s32 handle, void* ptr) { + if (audio == nullptr) { + return ORBIS_AUDIO_OUT_ERROR_NOT_INIT; + } if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) { return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT; } @@ -489,6 +502,9 @@ int PS4_SYSV_ABI sceAudioOutSetUsbVolume() { } s32 PS4_SYSV_ABI sceAudioOutSetVolume(s32 handle, s32 flag, s32* vol) { + if (audio == nullptr) { + return ORBIS_AUDIO_OUT_ERROR_NOT_INIT; + } if (handle < 1 || handle > SCE_AUDIO_OUT_NUM_PORTS) { return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT; } From 84c27eea2ae56807a7b178e31363f6ab1c27a9bb Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sat, 1 Feb 2025 01:54:40 -0800 Subject: [PATCH 70/72] texture_cache: Make sure left-overlapped mips get marked for rebind. (#2268) --- .../texture_cache/texture_cache.cpp | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/video_core/texture_cache/texture_cache.cpp b/src/video_core/texture_cache/texture_cache.cpp index e995b10b2..ecac78847 100644 --- a/src/video_core/texture_cache/texture_cache.cpp +++ b/src/video_core/texture_cache/texture_cache.cpp @@ -240,32 +240,32 @@ std::tuple TextureCache::ResolveOverlap(const ImageInfo& imag return {{}, -1, -1}; } else { // Left overlap, the image from cache is a possible subresource of the image requested - if (!merged_image_id) { - // We need to have a larger, already allocated image to copy this one into - return {{}, -1, -1}; - } - if (auto mip = tex_cache_image.info.IsMipOf(image_info); mip >= 0) { if (tex_cache_image.binding.is_target) { // We have a larger image created and a separate one, representing a subres of it, // bound as render target. In this case we need to rebind render target. tex_cache_image.binding.needs_rebind = 1u; - GetImage(merged_image_id).binding.is_target = 1u; + if (merged_image_id) { + GetImage(merged_image_id).binding.is_target = 1u; + } FreeImage(cache_image_id); return {merged_image_id, -1, -1}; } - tex_cache_image.Transit(vk::ImageLayout::eTransferSrcOptimal, - vk::AccessFlagBits2::eTransferRead, {}); + // We need to have a larger, already allocated image to copy this one into + if (merged_image_id) { + tex_cache_image.Transit(vk::ImageLayout::eTransferSrcOptimal, + vk::AccessFlagBits2::eTransferRead, {}); - const auto num_mips_to_copy = tex_cache_image.info.resources.levels; - ASSERT(num_mips_to_copy == 1); + const auto num_mips_to_copy = tex_cache_image.info.resources.levels; + ASSERT(num_mips_to_copy == 1); - auto& merged_image = slot_images[merged_image_id]; - merged_image.CopyMip(tex_cache_image, mip); + auto& merged_image = slot_images[merged_image_id]; + merged_image.CopyMip(tex_cache_image, mip); - FreeImage(cache_image_id); + FreeImage(cache_image_id); + } } } From 83671ebf763c9e94731b1a0b94626d02a4f1fb27 Mon Sep 17 00:00:00 2001 From: pdaloxd <31321612+pablodrake@users.noreply.github.com> Date: Sat, 1 Feb 2025 10:58:05 +0100 Subject: [PATCH 71/72] Translatable Compatibility Status (#2304) * qt_gui: Made compatibility status translatable * Translations: Added English and Spanish translation for compatibility status --- src/qt_gui/compatibility_info.cpp | 19 +++++++++++++++++++ src/qt_gui/compatibility_info.h | 8 +------- src/qt_gui/game_list_frame.cpp | 2 +- src/qt_gui/translations/en.ts | 27 +++++++++++++++++++++++++++ src/qt_gui/translations/es_ES.ts | 27 +++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 8 deletions(-) diff --git a/src/qt_gui/compatibility_info.cpp b/src/qt_gui/compatibility_info.cpp index 69fb3e377..884387061 100644 --- a/src/qt_gui/compatibility_info.cpp +++ b/src/qt_gui/compatibility_info.cpp @@ -260,3 +260,22 @@ void CompatibilityInfoClass::ExtractCompatibilityInfo(QByteArray response) { return; } + +const QString CompatibilityInfoClass::GetCompatStatusString(const CompatibilityStatus status) { + switch (status) { + case CompatibilityStatus::Unknown: + return tr("Unknown"); + case CompatibilityStatus::Nothing: + return tr("Nothing"); + case CompatibilityStatus::Boots: + return tr("Boots"); + case CompatibilityStatus::Menus: + return tr("Menus"); + case CompatibilityStatus::Ingame: + return tr("Ingame"); + case CompatibilityStatus::Playable: + return tr("Playable"); + default: + return tr("Unknown"); + } +} \ No newline at end of file diff --git a/src/qt_gui/compatibility_info.h b/src/qt_gui/compatibility_info.h index 0c47c27ff..511c106ce 100644 --- a/src/qt_gui/compatibility_info.h +++ b/src/qt_gui/compatibility_info.h @@ -69,13 +69,6 @@ public: {QStringLiteral("os-windows"), OSType::Win32}, }; - inline static const std::unordered_map CompatStatusToString = { - {CompatibilityStatus::Unknown, QStringLiteral("Unknown")}, - {CompatibilityStatus::Nothing, QStringLiteral("Nothing")}, - {CompatibilityStatus::Boots, QStringLiteral("Boots")}, - {CompatibilityStatus::Menus, QStringLiteral("Menus")}, - {CompatibilityStatus::Ingame, QStringLiteral("Ingame")}, - {CompatibilityStatus::Playable, QStringLiteral("Playable")}}; inline static const std::unordered_map OSTypeToString = { {OSType::Linux, QStringLiteral("os-linux")}, {OSType::macOS, QStringLiteral("os-macOS")}, @@ -87,6 +80,7 @@ public: void UpdateCompatibilityDatabase(QWidget* parent = nullptr, bool forced = false); bool LoadCompatibilityFile(); CompatibilityEntry GetCompatibilityInfo(const std::string& serial); + const QString GetCompatStatusString(const CompatibilityStatus status); void ExtractCompatibilityInfo(QByteArray response); static bool WaitForReply(QNetworkReply* reply); QNetworkReply* FetchPage(int page_num); diff --git a/src/qt_gui/game_list_frame.cpp b/src/qt_gui/game_list_frame.cpp index 8255c0daf..f2d08f578 100644 --- a/src/qt_gui/game_list_frame.cpp +++ b/src/qt_gui/game_list_frame.cpp @@ -289,7 +289,7 @@ void GameListFrame::SetCompatibilityItem(int row, int column, CompatibilityEntry QLabel* dotLabel = new QLabel("", widget); dotLabel->setPixmap(circle_pixmap); - QLabel* label = new QLabel(m_compat_info->CompatStatusToString.at(entry.status), widget); + QLabel* label = new QLabel(m_compat_info->GetCompatStatusString(entry.status), widget); label->setStyleSheet("color: white; font-size: 16px; font-weight: bold;"); diff --git a/src/qt_gui/translations/en.ts b/src/qt_gui/translations/en.ts index 7ad2f15c0..58d6e9aa8 100644 --- a/src/qt_gui/translations/en.ts +++ b/src/qt_gui/translations/en.ts @@ -1414,4 +1414,31 @@ TB + + CompatibilityInfoClass + + Unknown + Unknown + + + Nothing + Nothing + + + Boots + Boots + + + Menus + Menus + + + Ingame + Ingame + + + Playable + Playable + + diff --git a/src/qt_gui/translations/es_ES.ts b/src/qt_gui/translations/es_ES.ts index 8af34c042..d732e67ea 100644 --- a/src/qt_gui/translations/es_ES.ts +++ b/src/qt_gui/translations/es_ES.ts @@ -1405,4 +1405,31 @@ TB + + CompatibilityInfoClass + + Unknown + Desconocido + + + Nothing + Nada + + + Boots + Inicia + + + Menus + Menús + + + Ingame + En el juego + + + Playable + Jugable + + \ No newline at end of file From 1d8c607c1554e308a4f5e9fc5dc0ca7bf821ebff Mon Sep 17 00:00:00 2001 From: Vladislav Mikhalin Date: Sat, 1 Feb 2025 20:44:10 +0300 Subject: [PATCH 72/72] hotfix: stronger conditions for the vtx offset error message --- src/video_core/renderer_vulkan/vk_rasterizer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 1c90c6c27..7f2db3f8d 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -1172,7 +1172,8 @@ void Rasterizer::UpdateViewportScissorState(const GraphicsPipeline& pipeline) { const float reduce_z = regs.clipper_control.clip_space == AmdGpu::Liverpool::ClipSpace::MinusWToW ? 1.0f : 0.0f; - if (regs.polygon_control.enable_window_offset) { + if (regs.polygon_control.enable_window_offset && + (regs.window_offset.window_x_offset != 0 || regs.window_offset.window_y_offset != 0)) { LOG_ERROR(Render_Vulkan, "PA_SU_SC_MODE_CNTL.VTX_WINDOW_OFFSET_ENABLE support is not yet implemented."); }