diff --git a/.reuse/dep5 b/.reuse/dep5 index b39bc42fb7..baf1354bf6 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -180,3 +180,7 @@ License: GPL-3.0-or-later Files: dist/icns_generator.sh Copyright: 2024 suyu Emulator Project License: GPL-3.0-or-later + +Files: img/* +Copyright: 2024 suyu Emulator Project +License: CC0-1.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 42e8615e57..9406dd64a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -396,7 +396,71 @@ function(set_suyu_qt_components) set(SUYU_QT_COMPONENTS ${SUYU_QT_COMPONENTS2} PARENT_SCOPE) endfunction(set_suyu_qt_components) +# find SDL2 exports a bunch of variables that are needed, so its easier to do this outside of the suyu_find_package +if (ENABLE_SDL2) + if (SUYU_USE_BUNDLED_SDL2) + # Detect toolchain and platform + if ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND ARCHITECTURE_x86_64) + set(SDL2_VER "SDL2-2.28.2") + else() + message(FATAL_ERROR "No bundled SDL2 binaries for your toolchain. Disable SUYU_USE_BUNDLED_SDL2 and provide your own.") + endif() + + if (DEFINED SDL2_VER) + download_bundled_external("sdl2/" ${SDL2_VER} SDL2_PREFIX) + endif() + + set(SDL2_FOUND YES) + set(SDL2_INCLUDE_DIR "${SDL2_PREFIX}/include" CACHE PATH "Path to SDL2 headers") + set(SDL2_LIBRARY "${SDL2_PREFIX}/lib/x64/SDL2.lib" CACHE PATH "Path to SDL2 library") + set(SDL2_DLL_DIR "${SDL2_PREFIX}/lib/x64/" CACHE PATH "Path to SDL2.dll") + + add_library(SDL2::SDL2 INTERFACE IMPORTED) + target_link_libraries(SDL2::SDL2 INTERFACE "${SDL2_LIBRARY}") + target_include_directories(SDL2::SDL2 INTERFACE "${SDL2_INCLUDE_DIR}") + elseif (SUYU_USE_EXTERNAL_SDL2) + message(STATUS "Using SDL2 from externals.") + else() + find_package(SDL2 2.26.4 REQUIRED) + endif() +endif() + +# List of all FFmpeg components required +set(FFmpeg_COMPONENTS + avcodec + avfilter + avutil + swscale) + +if (UNIX AND NOT APPLE AND NOT ANDROID) + find_package(PkgConfig REQUIRED) + pkg_check_modules(LIBVA libva) +endif() +if (NOT SUYU_USE_BUNDLED_FFMPEG) + # Use system installed FFmpeg + find_package(FFmpeg 4.3 REQUIRED QUIET COMPONENTS ${FFmpeg_COMPONENTS}) +endif() + +if (WIN32 AND SUYU_CRASH_DUMPS) + set(BREAKPAD_VER "breakpad-c89f9dd") + download_bundled_external("breakpad/" ${BREAKPAD_VER} BREAKPAD_PREFIX) + + set(BREAKPAD_CLIENT_INCLUDE_DIR "${BREAKPAD_PREFIX}/include") + set(BREAKPAD_CLIENT_LIBRARY "${BREAKPAD_PREFIX}/lib/libbreakpad_client.lib") + + add_library(libbreakpad_client INTERFACE IMPORTED) + target_link_libraries(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_LIBRARY}") + target_include_directories(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_INCLUDE_DIR}") +endif() + +# Prefer the -pthread flag on Linux. +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) + +add_subdirectory(externals) + # Qt5 requires that we find components, so it doesn't fit our pretty little find package function +# Qt6 sets Vulkan::Headers, so Qt search has to come after externals, so it doesn't get to do it. if(ENABLE_QT) set(QT_VERSION 5.15) # These are used to specify minimum versions @@ -535,67 +599,6 @@ if(ENABLE_QT) endif() -# find SDL2 exports a bunch of variables that are needed, so its easier to do this outside of the suyu_find_package -if (ENABLE_SDL2) - if (SUYU_USE_BUNDLED_SDL2) - # Detect toolchain and platform - if ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND ARCHITECTURE_x86_64) - set(SDL2_VER "SDL2-2.28.2") - else() - message(FATAL_ERROR "No bundled SDL2 binaries for your toolchain. Disable SUYU_USE_BUNDLED_SDL2 and provide your own.") - endif() - - if (DEFINED SDL2_VER) - download_bundled_external("sdl2/" ${SDL2_VER} SDL2_PREFIX) - endif() - - set(SDL2_FOUND YES) - set(SDL2_INCLUDE_DIR "${SDL2_PREFIX}/include" CACHE PATH "Path to SDL2 headers") - set(SDL2_LIBRARY "${SDL2_PREFIX}/lib/x64/SDL2.lib" CACHE PATH "Path to SDL2 library") - set(SDL2_DLL_DIR "${SDL2_PREFIX}/lib/x64/" CACHE PATH "Path to SDL2.dll") - - add_library(SDL2::SDL2 INTERFACE IMPORTED) - target_link_libraries(SDL2::SDL2 INTERFACE "${SDL2_LIBRARY}") - target_include_directories(SDL2::SDL2 INTERFACE "${SDL2_INCLUDE_DIR}") - elseif (SUYU_USE_EXTERNAL_SDL2) - message(STATUS "Using SDL2 from externals.") - else() - find_package(SDL2 2.26.4 REQUIRED) - endif() -endif() - -# List of all FFmpeg components required -set(FFmpeg_COMPONENTS - avcodec - avfilter - avutil - swscale) - -if (UNIX AND NOT APPLE AND NOT ANDROID) - find_package(PkgConfig REQUIRED) - pkg_check_modules(LIBVA libva) -endif() -if (NOT SUYU_USE_BUNDLED_FFMPEG) - # Use system installed FFmpeg - find_package(FFmpeg 4.3 REQUIRED QUIET COMPONENTS ${FFmpeg_COMPONENTS}) -endif() - -if (WIN32 AND SUYU_CRASH_DUMPS) - set(BREAKPAD_VER "breakpad-c89f9dd") - download_bundled_external("breakpad/" ${BREAKPAD_VER} BREAKPAD_PREFIX) - - set(BREAKPAD_CLIENT_INCLUDE_DIR "${BREAKPAD_PREFIX}/include") - set(BREAKPAD_CLIENT_LIBRARY "${BREAKPAD_PREFIX}/lib/libbreakpad_client.lib") - - add_library(libbreakpad_client INTERFACE IMPORTED) - target_link_libraries(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_LIBRARY}") - target_include_directories(libbreakpad_client INTERFACE "${BREAKPAD_CLIENT_INCLUDE_DIR}") -endif() - -# Prefer the -pthread flag on Linux. -set(THREADS_PREFER_PTHREAD_FLAG ON) -find_package(Threads REQUIRED) - # Platform-specific library requirements # ====================================== @@ -710,7 +713,6 @@ if (SUYU_USE_FASTER_LD AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() endif() -add_subdirectory(externals) add_subdirectory(src) # Set suyu project or suyu-cmd project as default StartUp Project in Visual Studio depending on whether QT is enabled or not diff --git a/README.md b/README.md index 6334f02b2c..3448576d3f 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,12 @@ It is written in C++ with portability in mind, and we're actively working on bui Pipelines

+## Hardware Requirements +[Click here to see the Hardware Requirements](https://git.suyu.dev/suyu/suyu/wiki/Hardware-Requirements) + ## Status -Although we're able to make builds, we don't have a version ready for distribution yet. But we can always use more help! You can make a merge request if you'd like to see something changed, or you can [chat with other developers to find out what needs work](https://discord.gg/suyu). +We currently have builds over at the [Releases](https://git.suyu.dev/suyu/suyu/releases) page. **Note**: We try to update this README whenever we can, but some links might be broken, and some information may be outdated or irrelevant. diff --git a/img/maximum-clocks.png b/img/maximum-clocks.png new file mode 100644 index 0000000000..0353c0bf83 Binary files /dev/null and b/img/maximum-clocks.png differ diff --git a/src/core/hle/service/am/process_creation.cpp b/src/core/hle/service/am/process_creation.cpp index 237151d061..e6e2fad2c6 100644 --- a/src/core/hle/service/am/process_creation.cpp +++ b/src/core/hle/service/am/process_creation.cpp @@ -106,6 +106,7 @@ std::unique_ptr CreateApplicationProcess(std::vector& out_control, out_control = nacp.GetRawBytes(); } else { out_control.resize(sizeof(FileSys::RawNACP)); + memset(out_control.data(), 0, sizeof(u8) * out_control.size()); } auto& storage = system.GetContentProviderUnion(); diff --git a/src/core/hle/service/am/service/library_applet_accessor.cpp b/src/core/hle/service/am/service/library_applet_accessor.cpp index cda8c3eb87..b7ea464ff2 100644 --- a/src/core/hle/service/am/service/library_applet_accessor.cpp +++ b/src/core/hle/service/am/service/library_applet_accessor.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "core/hle/service/am/applet_data_broker.h" @@ -101,6 +102,22 @@ Result ILibraryAppletAccessor::PushInData(SharedPointer storage) { Result ILibraryAppletAccessor::PopOutData(Out> out_storage) { LOG_DEBUG(Service_AM, "called"); + // suyu todo: move library applet fix to another function + // since this function is only called for applets that give a result, + // applets that don't (e.g. info applets in 1st party games) simply freeze + if (auto caller = m_applet->caller_applet.lock(); caller != nullptr) { + caller->SetInteractibleLocked(true); + + caller->lifecycle_manager.SetFocusState(FocusState::InFocus); + caller->lifecycle_manager.UpdateRequestedFocusState(); + + caller->lifecycle_manager.SetResumeNotificationEnabled(true); + caller->lifecycle_manager.RequestResumeNotification(); + caller->UpdateSuspensionStateLocked(true); + } else { + LOG_CRITICAL(Service_AM, "Caller applet pointer is invalid."); + LOG_CRITICAL(Service_AM, "The emulator will freeze!"); + } R_RETURN(m_broker->GetOutData().Pop(out_storage.Get())); } diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp index d4a6d7f9ad..480649cc82 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp @@ -1,4 +1,5 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project, 2024 sudachi Emulator Project +// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project +// SPDX-FileCopyrightText: 2024 sudachi Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp index 44ce3242a5..3c0c19961d 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp @@ -1,4 +1,5 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project, 2024 sudachi Emulator Project +// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project +// SPDX-FileCopyrightText: 2024 sudachi Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index adec9fa46f..5d428d2d68 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp @@ -1,4 +1,5 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project, 2024 sudachi Emulator Project +// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project +// SPDX-FileCopyrightText: 2024 sudachi Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include diff --git a/src/shader_recompiler/runtime_info.h b/src/shader_recompiler/runtime_info.h index f49c1bdda1..f9ac9fbb42 100644 --- a/src/shader_recompiler/runtime_info.h +++ b/src/shader_recompiler/runtime_info.h @@ -1,4 +1,5 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project, 2024 sudachi Emulator Project +// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project +// SPDX-FileCopyrightText: 2024 sudachi Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 8909c77af3..24853ebb9e 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -1406,7 +1406,7 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu if (runtime->device.HasDebuggingToolAttached()) { original_image.SetObjectNameEXT(VideoCommon::Name(*this).c_str()); } - current_image = *original_image; + current_image = &Image::original_image; storage_image_views.resize(info.resources.levels); if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported() && Settings::values.astc_recompression.GetValue() == @@ -1550,8 +1550,8 @@ VkImageView Image::StorageImageView(s32 level) noexcept { if (!view) { const auto format_info = MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format); - view = - MakeStorageView(runtime->device.GetLogical(), level, current_image, format_info.format); + view = MakeStorageView(runtime->device.GetLogical(), level, *(this->*current_image), + format_info.format); } return *view; } @@ -1582,7 +1582,7 @@ bool Image::ScaleUp(bool ignore) { runtime->ViewFormats(info.format)); ignore = false; } - current_image = *scaled_image; + current_image = &Image::scaled_image; if (ignore) { return true; } @@ -1607,7 +1607,7 @@ bool Image::ScaleDown(bool ignore) { } ASSERT(info.type != ImageType::Linear); flags &= ~ImageFlagBits::Rescaled; - current_image = *original_image; + current_image = &Image::original_image; if (ignore) { return true; } @@ -1726,7 +1726,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI const VkImageViewUsageCreateInfo image_view_usage{ .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO, .pNext = nullptr, - .usage = ImageUsageFlags(format_info, format), + .usage = image.UsageFlags(), }; const VkImageViewCreateInfo create_info{ .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, @@ -2087,4 +2087,4 @@ void TextureCacheRuntime::TransitionImageLayout(Image& image) { } } -} // namespace Vulkan \ No newline at end of file +} // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index 8501ec384b..4161d7ff92 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h @@ -24,7 +24,6 @@ using Common::SlotVector; using VideoCommon::ImageId; using VideoCommon::NUM_RT; using VideoCommon::Region2D; -using VideoCommon::RenderTargets; using VideoCore::Surface::PixelFormat; class BlitImageHelper; @@ -157,13 +156,17 @@ public: std::span copies); [[nodiscard]] VkImage Handle() const noexcept { - return current_image; + return *(this->*current_image); } [[nodiscard]] VkImageAspectFlags AspectMask() const noexcept { return aspect_mask; } + [[nodiscard]] VkImageUsageFlags UsageFlags() const noexcept { + return (this->*current_image).UsageFlags(); + } + /// Returns true when the image is already initialized and mark it as initialized [[nodiscard]] bool ExchangeInitialization() noexcept { return std::exchange(initialized, true); @@ -186,11 +189,15 @@ private: TextureCacheRuntime* runtime{}; vk::Image original_image; + vk::Image scaled_image; + + // Use a pointer to field because it is relative, so that the object can be + // moved without breaking the reference. + vk::Image Image::*current_image{}; + std::vector storage_image_views; VkImageAspectFlags aspect_mask = 0; bool initialized = false; - vk::Image scaled_image{}; - VkImage current_image{}; std::unique_ptr scale_framebuffer; std::unique_ptr scale_view; diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp index 8f4a57e3ca..54331688e3 100644 --- a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp +++ b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp @@ -247,7 +247,7 @@ vk::Image MemoryAllocator::CreateImage(const VkImageCreateInfo& ci) const { vk::Check(vmaCreateImage(allocator, &ci, &alloc_ci, &handle, &allocation, nullptr)); - return vk::Image(handle, *device.GetLogical(), allocator, allocation, + return vk::Image(handle, ci.usage, *device.GetLogical(), allocator, allocation, device.GetDispatchLoader()); } diff --git a/src/video_core/vulkan_common/vulkan_wrapper.h b/src/video_core/vulkan_common/vulkan_wrapper.h index 757f3c8afb..1bb8a47bdf 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.h +++ b/src/video_core/vulkan_common/vulkan_wrapper.h @@ -623,9 +623,10 @@ public: class Image { public: - explicit Image(VkImage handle_, VkDevice owner_, VmaAllocator allocator_, - VmaAllocation allocation_, const DeviceDispatch& dld_) noexcept - : handle{handle_}, owner{owner_}, allocator{allocator_}, + explicit Image(VkImage handle_, VkImageUsageFlags usage_, VkDevice owner_, + VmaAllocator allocator_, VmaAllocation allocation_, + const DeviceDispatch& dld_) noexcept + : handle{handle_}, usage{usage_}, owner{owner_}, allocator{allocator_}, allocation{allocation_}, dld{&dld_} {} Image() = default; @@ -633,12 +634,13 @@ public: Image& operator=(const Image&) = delete; Image(Image&& rhs) noexcept - : handle{std::exchange(rhs.handle, nullptr)}, owner{rhs.owner}, allocator{rhs.allocator}, - allocation{rhs.allocation}, dld{rhs.dld} {} + : handle{std::exchange(rhs.handle, nullptr)}, usage{rhs.usage}, owner{rhs.owner}, + allocator{rhs.allocator}, allocation{rhs.allocation}, dld{rhs.dld} {} Image& operator=(Image&& rhs) noexcept { Release(); handle = std::exchange(rhs.handle, nullptr); + usage = rhs.usage; owner = rhs.owner; allocator = rhs.allocator; allocation = rhs.allocation; @@ -665,10 +667,15 @@ public: void SetObjectNameEXT(const char* name) const; + [[nodiscard]] VkImageUsageFlags UsageFlags() const noexcept { + return usage; + } + private: void Release() const noexcept; VkImage handle = nullptr; + VkImageUsageFlags usage{}; VkDevice owner = nullptr; VmaAllocator allocator = nullptr; VmaAllocation allocation = nullptr;