From c1602b1bb82ee45fc2db838172edfd46e5217f1c Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Tue, 19 Sep 2023 17:30:09 +0200 Subject: [PATCH] early-access version 3880 --- CMakeLists.txt | 1 + CMakeModules/FindRenderDoc.cmake | 19 +++++++ README.md | 2 +- externals/CMakeLists.txt | 7 ++- src/android/.gitignore | 3 ++ .../yuzu_emu/activities/EmulationActivity.kt | 8 ++- .../yuzu_emu/fragments/EmulationFragment.kt | 26 +++------- .../src/main/jni/emu_window/emu_window.cpp | 14 ++--- src/core/CMakeLists.txt | 2 +- src/core/hle/service/aoc/aoc_u.cpp | 20 ++++++- src/core/hle/service/mii/mii.cpp | 2 +- .../hle/service/mii/mii_database_manager.cpp | 2 + .../hle/service/mii/mii_database_manager.h | 1 - src/core/tools/renderdoc.cpp | 2 +- .../renderer_vulkan/vk_texture_cache.cpp | 16 +++++- .../vulkan_common/vulkan_device.cpp | 8 +-- src/video_core/vulkan_common/vulkan_device.h | 52 +++++++++++-------- 17 files changed, 119 insertions(+), 66 deletions(-) create mode 100755 CMakeModules/FindRenderDoc.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d53f5c29..1a5313225 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -333,6 +333,7 @@ find_package(LLVM 17 MODULE COMPONENTS Demangle) find_package(lz4 REQUIRED) find_package(nlohmann_json 3.8 REQUIRED) find_package(Opus 1.3 MODULE) +find_package(RenderDoc MODULE) find_package(VulkanMemoryAllocator CONFIG) find_package(ZLIB 1.2 REQUIRED) find_package(zstd 1.5 REQUIRED) diff --git a/CMakeModules/FindRenderDoc.cmake b/CMakeModules/FindRenderDoc.cmake new file mode 100755 index 000000000..2678b936b --- /dev/null +++ b/CMakeModules/FindRenderDoc.cmake @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2023 Alexandre Bouvier +# +# SPDX-License-Identifier: GPL-3.0-or-later + +find_path(RenderDoc_INCLUDE_DIR renderdoc_app.h) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(RenderDoc + REQUIRED_VARS RenderDoc_INCLUDE_DIR +) + +if (RenderDoc_FOUND AND NOT TARGET RenderDoc::API) + add_library(RenderDoc::API INTERFACE IMPORTED) + set_target_properties(RenderDoc::API PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${RenderDoc_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced(RenderDoc_INCLUDE_DIR) diff --git a/README.md b/README.md index 3b7b6dec7..7e8893298 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3879. +This is the source code for early-access 3880. ## Legal Notice diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 3eb4ac00e..6d5f44c67 100755 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -174,8 +174,11 @@ target_include_directories(stb PUBLIC ./stb) add_library(bc_decoder bc_decoder/bc_decoder.cpp) target_include_directories(bc_decoder PUBLIC ./bc_decoder) -add_library(renderdoc INTERFACE) -target_include_directories(renderdoc SYSTEM INTERFACE ./renderdoc) +if (NOT TARGET RenderDoc::API) + add_library(renderdoc INTERFACE) + target_include_directories(renderdoc SYSTEM INTERFACE ./renderdoc) + add_library(RenderDoc::API ALIAS renderdoc) +endif() if (ANDROID) if (ARCHITECTURE_arm64) diff --git a/src/android/.gitignore b/src/android/.gitignore index 121cc8484..ff7121acd 100755 --- a/src/android/.gitignore +++ b/src/android/.gitignore @@ -63,3 +63,6 @@ fastlane/Preview.html fastlane/screenshots fastlane/test_output fastlane/readme.md + +# Autogenerated library for vulkan validation layers +libVkLayer_khronos_validation.so diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt index d4ae39661..e96a2059b 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt @@ -3,6 +3,7 @@ package org.yuzu.yuzu_emu.activities +import android.annotation.SuppressLint import android.app.Activity import android.app.PendingIntent import android.app.PictureInPictureParams @@ -397,6 +398,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { } } + @SuppressLint("UnspecifiedRegisterReceiverFlag") override fun onPictureInPictureModeChanged( isInPictureInPictureMode: Boolean, newConfig: Configuration @@ -409,7 +411,11 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { addAction(actionMute) addAction(actionUnmute) }.also { - registerReceiver(pictureInPictureReceiver, it) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + registerReceiver(pictureInPictureReceiver, it, RECEIVER_EXPORTED) + } else { + registerReceiver(pictureInPictureReceiver, it) + } } } else { try { diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 3e6c157c7..750638bc9 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt @@ -15,7 +15,6 @@ import android.net.Uri import android.os.Bundle import android.os.Handler import android.os.Looper -import android.util.Rational import android.view.* import android.widget.TextView import androidx.activity.OnBackPressedCallback @@ -287,13 +286,14 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) + updateScreenLayout() if (emulationActivity?.isInPictureInPictureMode == true) { if (binding.drawerLayout.isOpen) { binding.drawerLayout.close() } if (EmulationMenuSettings.showOverlay) { binding.surfaceInputOverlay.post { - binding.surfaceInputOverlay.visibility = View.VISIBLE + binding.surfaceInputOverlay.visibility = View.INVISIBLE } } } else { @@ -328,7 +328,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { } override fun onPause() { - if (emulationState.isRunning) { + if (emulationState.isRunning && emulationActivity?.isInPictureInPictureMode != true) { emulationState.pause() } super.onPause() @@ -394,16 +394,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { } private fun updateScreenLayout() { - binding.surfaceEmulation.setAspectRatio( - when (IntSetting.RENDERER_ASPECT_RATIO.int) { - 0 -> Rational(16, 9) - 1 -> Rational(4, 3) - 2 -> Rational(21, 9) - 3 -> Rational(16, 10) - 4 -> null // Stretch - else -> Rational(16, 9) - } - ) + binding.surfaceEmulation.setAspectRatio(null) emulationActivity?.buildPictureInPictureParams() updateOrientation() } @@ -693,7 +684,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { private class EmulationState(private val gamePath: String) { private var state: State private var surface: Surface? = null - private var runWhenSurfaceIsValid = false init { // Starting state is stopped. @@ -751,8 +741,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { // If the surface is set, run now. Otherwise, wait for it to get set. if (surface != null) { runWithValidSurface() - } else { - runWhenSurfaceIsValid = true } } @@ -760,7 +748,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { @Synchronized fun newSurface(surface: Surface?) { this.surface = surface - if (runWhenSurfaceIsValid) { + if (this.surface != null) { runWithValidSurface() } } @@ -788,10 +776,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { } private fun runWithValidSurface() { - runWhenSurfaceIsValid = false + NativeLibrary.surfaceChanged(surface) when (state) { State.STOPPED -> { - NativeLibrary.surfaceChanged(surface) val emulationThread = Thread({ Log.debug("[EmulationFragment] Starting emulation thread.") NativeLibrary.run(gamePath) @@ -801,7 +788,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { State.PAUSED -> { Log.debug("[EmulationFragment] Resuming emulation.") - NativeLibrary.surfaceChanged(surface) NativeLibrary.unpauseEmulation() } diff --git a/src/android/app/src/main/jni/emu_window/emu_window.cpp b/src/android/app/src/main/jni/emu_window/emu_window.cpp index a890c6604..a7e414b81 100755 --- a/src/android/app/src/main/jni/emu_window/emu_window.cpp +++ b/src/android/app/src/main/jni/emu_window/emu_window.cpp @@ -11,6 +11,12 @@ #include "jni/emu_window/emu_window.h" void EmuWindow_Android::OnSurfaceChanged(ANativeWindow* surface) { + m_window_width = ANativeWindow_getWidth(surface); + m_window_height = ANativeWindow_getHeight(surface); + + // Ensures that we emulate with the correct aspect ratio. + UpdateCurrentFramebufferLayout(m_window_width, m_window_height); + window_info.render_surface = reinterpret_cast(surface); } @@ -62,14 +68,8 @@ EmuWindow_Android::EmuWindow_Android(InputCommon::InputSubsystem* input_subsyste return; } - m_window_width = ANativeWindow_getWidth(surface); - m_window_height = ANativeWindow_getHeight(surface); - - // Ensures that we emulate with the correct aspect ratio. - UpdateCurrentFramebufferLayout(m_window_width, m_window_height); - + OnSurfaceChanged(surface); window_info.type = Core::Frontend::WindowSystemType::Android; - window_info.render_surface = reinterpret_cast(surface); m_input_subsystem->Initialize(); } diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 510e2f5ac..d91c6d0ec 100755 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -894,7 +894,7 @@ endif() create_target_directory_groups(core) target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core nx_tzdb) -target_link_libraries(core PUBLIC Boost::headers PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls renderdoc) +target_link_libraries(core PUBLIC Boost::headers PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls RenderDoc::API) if (MINGW) target_link_libraries(core PRIVATE ${MSWSOCK_LIBRARY}) endif() diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 34703e52b..d78f52e9b 100755 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -22,6 +22,8 @@ namespace Service::AOC { +constexpr Result ResultNoPurchasedProductInfoAvailable{ErrorModule::NIMShop, 400}; + static bool CheckAOCTitleIDMatchesBase(u64 title_id, u64 base) { return FileSys::GetBaseTitleID(title_id) == base; } @@ -54,8 +56,8 @@ public: {0, &IPurchaseEventManager::SetDefaultDeliveryTarget, "SetDefaultDeliveryTarget"}, {1, &IPurchaseEventManager::SetDeliveryTarget, "SetDeliveryTarget"}, {2, &IPurchaseEventManager::GetPurchasedEventReadableHandle, "GetPurchasedEventReadableHandle"}, - {3, nullptr, "PopPurchasedProductInfo"}, - {4, nullptr, "PopPurchasedProductInfoWithUid"}, + {3, &IPurchaseEventManager::PopPurchasedProductInfo, "PopPurchasedProductInfo"}, + {4, &IPurchaseEventManager::PopPurchasedProductInfoWithUid, "PopPurchasedProductInfoWithUid"}, }; // clang-format on @@ -101,6 +103,20 @@ private: rb.PushCopyObjects(purchased_event->GetReadableEvent()); } + void PopPurchasedProductInfo(HLERequestContext& ctx) { + LOG_DEBUG(Service_AOC, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultNoPurchasedProductInfoAvailable); + } + + void PopPurchasedProductInfoWithUid(HLERequestContext& ctx) { + LOG_DEBUG(Service_AOC, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultNoPurchasedProductInfoAvailable); + } + KernelHelpers::ServiceContext service_context; Kernel::KEvent* purchased_event; diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index f7152500b..fcf23b179 100755 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp @@ -546,7 +546,7 @@ private: rb.Push(ResultSuccess); rb.PushIpcInterface(system, is_system); - LOG_CRITICAL(Service_Mii, "called"); + LOG_DEBUG(Service_Mii, "called"); } bool is_system{}; diff --git a/src/core/hle/service/mii/mii_database_manager.cpp b/src/core/hle/service/mii/mii_database_manager.cpp index 06c7ce40f..c39898594 100755 --- a/src/core/hle/service/mii/mii_database_manager.cpp +++ b/src/core/hle/service/mii/mii_database_manager.cpp @@ -15,6 +15,8 @@ #include "core/hle/service/mii/types/store_data.h" namespace Service::Mii { +const char* DbFileName = "MiiDatabase.dat"; + DatabaseManager::DatabaseManager() {} Result DatabaseManager::MountSaveData() { diff --git a/src/core/hle/service/mii/mii_database_manager.h b/src/core/hle/service/mii/mii_database_manager.h index 78a555a9d..52c32be82 100755 --- a/src/core/hle/service/mii/mii_database_manager.h +++ b/src/core/hle/service/mii/mii_database_manager.h @@ -53,7 +53,6 @@ private: NintendoFigurineDatabase database{}; std::filesystem::path system_save_dir{}; - const std::string DbFileName = "MiiDatabase.dat"; }; }; // namespace Service::Mii diff --git a/src/core/tools/renderdoc.cpp b/src/core/tools/renderdoc.cpp index 44d24822a..947fa6cb3 100755 --- a/src/core/tools/renderdoc.cpp +++ b/src/core/tools/renderdoc.cpp @@ -7,7 +7,7 @@ #include "common/dynamic_library.h" #include "core/tools/renderdoc.h" -#ifdef WIN32 +#ifdef _WIN32 #include #else #include diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 7ac73d41b..257848d90 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -1044,15 +1044,27 @@ void TextureCacheRuntime::BlitImage(Framebuffer* dst_framebuffer, ImageView& dst dst_region, src_region, filter, operation); return; } + ASSERT(src.format == dst.format); if (aspect_mask == (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { - if (!device.IsBlitDepthStencilSupported()) { + const auto format = src.format; + const auto can_blit_depth_stencil = [this, format] { + switch (format) { + case VideoCore::Surface::PixelFormat::D24_UNORM_S8_UINT: + case VideoCore::Surface::PixelFormat::S8_UINT_D24_UNORM: + return device.IsBlitDepth24Stencil8Supported(); + case VideoCore::Surface::PixelFormat::D32_FLOAT_S8_UINT: + return device.IsBlitDepth32Stencil8Supported(); + default: + UNREACHABLE(); + } + }(); + if (!can_blit_depth_stencil) { UNIMPLEMENTED_IF(is_src_msaa || is_dst_msaa); blit_image_helper.BlitDepthStencil(dst_framebuffer, src.DepthView(), src.StencilView(), dst_region, src_region, filter, operation); return; } } - ASSERT(src.format == dst.format); ASSERT(!(is_dst_msaa && !is_src_msaa)); ASSERT(operation == Fermi2D::Operation::SrcCopy); diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index c20c0cb02..eca8a0c42 100755 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -420,7 +420,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR first_next = &diagnostics_nv; } - is_blit_depth_stencil_supported = TestDepthStencilBlits(); + is_blit_depth24_stencil8_supported = TestDepthStencilBlits(VK_FORMAT_D24_UNORM_S8_UINT); + is_blit_depth32_stencil8_supported = TestDepthStencilBlits(VK_FORMAT_D32_SFLOAT_S8_UINT); is_optimal_astc_supported = ComputeIsOptimalAstcSupported(); is_warp_potentially_bigger = !extensions.subgroup_size_control || properties.subgroup_size_control.maxSubgroupSize > GuestWarpSize; @@ -774,14 +775,13 @@ bool Device::ComputeIsOptimalAstcSupported() const { return true; } -bool Device::TestDepthStencilBlits() const { +bool Device::TestDepthStencilBlits(VkFormat format) const { static constexpr VkFormatFeatureFlags required_features = VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT; const auto test_features = [](VkFormatProperties props) { return (props.optimalTilingFeatures & required_features) == required_features; }; - return test_features(format_properties.at(VK_FORMAT_D32_SFLOAT_S8_UINT)) && - test_features(format_properties.at(VK_FORMAT_D24_UNORM_S8_UINT)); + return test_features(format_properties.at(format)); } bool Device::IsFormatSupported(VkFormat wanted_format, VkFormatFeatureFlags wanted_usage, diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index e1aaa75b1..9b0ef35a9 100755 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h @@ -366,9 +366,14 @@ public: return features.features.depthBounds; } - /// Returns true when blitting from and to depth stencil images is supported. - bool IsBlitDepthStencilSupported() const { - return is_blit_depth_stencil_supported; + /// Returns true when blitting from and to D24S8 images is supported. + bool IsBlitDepth24Stencil8Supported() const { + return is_blit_depth24_stencil8_supported; + } + + /// Returns true when blitting from and to D32S8 images is supported. + bool IsBlitDepth32Stencil8Supported() const { + return is_blit_depth32_stencil8_supported; } /// Returns true if the device supports VK_NV_viewport_swizzle. @@ -686,7 +691,7 @@ private: bool ComputeIsOptimalAstcSupported() const; /// Returns true if the device natively supports blitting depth stencil images. - bool TestDepthStencilBlits() const; + bool TestDepthStencilBlits(VkFormat format) const; private: VkInstance instance; ///< Vulkan instance. @@ -750,25 +755,26 @@ private: VkPhysicalDeviceProperties2 properties2{}; // Misc features - bool is_optimal_astc_supported{}; ///< Support for all guest ASTC formats. - bool is_blit_depth_stencil_supported{}; ///< Support for blitting from and to depth stencil. - bool is_warp_potentially_bigger{}; ///< Host warp size can be bigger than guest. - bool is_integrated{}; ///< Is GPU an iGPU. - bool is_virtual{}; ///< Is GPU a virtual GPU. - bool is_non_gpu{}; ///< Is SoftwareRasterizer, FPGA, non-GPU device. - bool has_broken_compute{}; ///< Compute shaders can cause crashes - bool has_broken_cube_compatibility{}; ///< Has broken cube compatibility bit - bool has_renderdoc{}; ///< Has RenderDoc attached - bool has_nsight_graphics{}; ///< Has Nsight Graphics attached - bool supports_d24_depth{}; ///< Supports D24 depth buffers. - bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting. - bool must_emulate_scaled_formats{}; ///< Requires scaled vertex format emulation - bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format. - bool dynamic_state3_blending{}; ///< Has all blending features of dynamic_state3. - bool dynamic_state3_enables{}; ///< Has all enables features of dynamic_state3. - bool supports_conditional_barriers{}; ///< Allows barriers in conditional control flow. - u64 device_access_memory{}; ///< Total size of device local memory in bytes. - u32 sets_per_pool{}; ///< Sets per Description Pool + bool is_optimal_astc_supported{}; ///< Support for all guest ASTC formats. + bool is_blit_depth24_stencil8_supported{}; ///< Support for blitting from and to D24S8. + bool is_blit_depth32_stencil8_supported{}; ///< Support for blitting from and to D32S8. + bool is_warp_potentially_bigger{}; ///< Host warp size can be bigger than guest. + bool is_integrated{}; ///< Is GPU an iGPU. + bool is_virtual{}; ///< Is GPU a virtual GPU. + bool is_non_gpu{}; ///< Is SoftwareRasterizer, FPGA, non-GPU device. + bool has_broken_compute{}; ///< Compute shaders can cause crashes + bool has_broken_cube_compatibility{}; ///< Has broken cube compatibility bit + bool has_renderdoc{}; ///< Has RenderDoc attached + bool has_nsight_graphics{}; ///< Has Nsight Graphics attached + bool supports_d24_depth{}; ///< Supports D24 depth buffers. + bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting. + bool must_emulate_scaled_formats{}; ///< Requires scaled vertex format emulation + bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format. + bool dynamic_state3_blending{}; ///< Has all blending features of dynamic_state3. + bool dynamic_state3_enables{}; ///< Has all enables features of dynamic_state3. + bool supports_conditional_barriers{}; ///< Allows barriers in conditional control flow. + u64 device_access_memory{}; ///< Total size of device local memory in bytes. + u32 sets_per_pool{}; ///< Sets per Description Pool // Telemetry parameters std::set> supported_extensions; ///< Reported Vulkan extensions.