From b57607168ad2896fcfc89aff77b2fbd8a5a0b87b Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Fri, 18 Jun 2021 16:07:15 +0200 Subject: [PATCH] early-access version 1794 --- README.md | 2 +- src/common/settings.h | 2 +- src/core/hle/service/nvflinger/nvflinger.cpp | 2 +- src/video_core/textures/astc.cpp | 99 +++++++++++++++---- .../vulkan_common/vulkan_debug_callback.cpp | 8 ++ .../vulkan_common/vulkan_device.cpp | 8 +- src/yuzu/configuration/config.cpp | 8 +- src/yuzu/configuration/configure_debug.cpp | 2 - src/yuzu/configuration/configure_debug.ui | 18 ---- .../configure_graphics_advanced.cpp | 6 ++ .../configure_graphics_advanced.h | 1 + .../configure_graphics_advanced.ui | 20 +++- src/yuzu/main.cpp | 8 +- src/yuzu_cmd/config.cpp | 3 +- src/yuzu_cmd/default_ini.h | 2 +- 15 files changed, 133 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index fc7f0b558..637d5be75 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1793. +This is the source code for early-access 1794. ## Legal Notice diff --git a/src/common/settings.h b/src/common/settings.h index 265a2f12d..55cef40f8 100755 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -149,6 +149,7 @@ struct Values { Setting use_nvdec_emulation; Setting accelerate_astc; Setting use_vsync; + Setting disable_fps_limit; Setting use_assembly_shaders; Setting use_asynchronous_shaders; Setting use_fast_gpu_time; @@ -224,7 +225,6 @@ struct Values { bool reporting_services; bool quest_flag; bool disable_macro_jit; - bool unlimit_fps; bool extended_logging; bool use_debug_asserts; bool use_auto_stub; diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index f87627832..1d810562f 100755 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -307,7 +307,7 @@ void NVFlinger::Compose() { } s64 NVFlinger::GetNextTicks() const { - if (Settings::values.unlimit_fps) { + if (Settings::values.disable_fps_limit.GetValue()) { return 0; } constexpr s64 max_hertz = 120LL; diff --git a/src/video_core/textures/astc.cpp b/src/video_core/textures/astc.cpp index 9b2177ebd..541ba50b3 100755 --- a/src/video_core/textures/astc.cpp +++ b/src/video_core/textures/astc.cpp @@ -18,11 +18,15 @@ #include #include #include +#if __cpp_lib_parallel_algorithm +#include +#endif #include #include #include +#include "common/alignment.h" #include "common/common_types.h" #include "video_core/textures/astc.h" @@ -1548,30 +1552,87 @@ static void DecompressBlock(std::span inBuf, const u32 blockWidth, void Decompress(std::span data, uint32_t width, uint32_t height, uint32_t depth, uint32_t block_width, uint32_t block_height, std::span output) { - u32 block_index = 0; - std::size_t depth_offset = 0; - for (u32 z = 0; z < depth; z++) { - for (u32 y = 0; y < height; y += block_height) { - for (u32 x = 0; x < width; x += block_width) { - const std::span blockPtr{data.subspan(block_index * 16, 16)}; + struct ASTCStrideInfo { + u32 z{}; + u32 index{}; + }; - // Blocks can be at most 12x12 - std::array uncompData; - DecompressBlock(blockPtr, block_width, block_height, uncompData); + const u32 rows = Common::DivideUp(height, block_height); + const u32 cols = Common::DivideUp(width, block_width); - u32 decompWidth = std::min(block_width, width - x); - u32 decompHeight = std::min(block_height, height - y); + const u32 num_strides = depth * rows; + std::vector astc_strides(num_strides); - const std::span outRow = output.subspan(depth_offset + (y * width + x) * 4); - for (u32 jj = 0; jj < decompHeight; jj++) { - std::memcpy(outRow.data() + jj * width * 4, - uncompData.data() + jj * block_width, decompWidth * 4); - } - ++block_index; + for (u32 z = 0; z < depth; ++z) { + for (u32 index = 0; index < rows; ++index) { + astc_strides.emplace_back(ASTCStrideInfo{ + .z{z}, + .index{index}, + }); + } + } + + auto decompress_stride = [&](const ASTCStrideInfo& stride) { + const u32 y = stride.index * block_height; + const u32 depth_offset = stride.z * height * width * 4; + for (u32 x_index = 0; x_index < cols; ++x_index) { + const u32 block_index = stride.index * cols + x_index; + const u32 x = x_index * block_width; + + const std::span blockPtr{data.subspan(block_index * 16, 16)}; + + // Blocks can be at most 12x12 + std::array uncompData; + DecompressBlock(blockPtr, block_width, block_height, uncompData); + + const u32 decompWidth = std::min(block_width, width - x); + const u32 decompHeight = std::min(block_height, height - y); + + const std::span outRow = output.subspan(depth_offset + (y * width + x) * 4); + + for (u32 h = 0; h < decompHeight; ++h) { + std::memcpy(outRow.data() + h * width * 4, uncompData.data() + h * block_width, + decompWidth * 4); } } - depth_offset += height * width * 4; - } + }; + +#if __cpp_lib_parallel_algorithm + std::for_each(std::execution::par, astc_strides.cbegin(), astc_strides.cend(), + decompress_stride); +#else + std::for_each(astc_strides.cbegin(), astc_strides.cend(), decompress_stride); +#endif + + // const u32 rows = Common::DivideUp(height, block_height); + // const u32 cols = Common::DivideUp(width, block_width); + + // for (u32 z = 0; z < depth; ++z) { + // const u32 depth_offset = z * height * width * 4; + // for (u32 y_index = 0; y_index < rows; ++y_index) { + // const u32 y = y_index * block_height; + // for (u32 x_index = 0; x_index < cols; ++x_index) { + // const u32 block_index = y_index * cols + x_index; + // const u32 x = x_index * block_width; + + // const std::span blockPtr{data.subspan(block_index * 16, 16)}; + + // // Blocks can be at most 12x12 + // std::array uncompData; + // DecompressBlock(blockPtr, block_width, block_height, uncompData); + + // u32 decompWidth = std::min(block_width, width - x); + // u32 decompHeight = std::min(block_height, height - y); + + // const std::span outRow = output.subspan(depth_offset + (y * width + x) * 4); + // for (u32 h = 0; h < decompHeight; ++h) { + // std::memcpy(outRow.data() + h * width * 4, uncompData.data() + h * + // block_width, + // decompWidth * 4); + // } + // } + // } + // } } } // namespace Tegra::Texture::ASTC diff --git a/src/video_core/vulkan_common/vulkan_debug_callback.cpp b/src/video_core/vulkan_common/vulkan_debug_callback.cpp index 5c64c9bf7..0f60765bb 100755 --- a/src/video_core/vulkan_common/vulkan_debug_callback.cpp +++ b/src/video_core/vulkan_common/vulkan_debug_callback.cpp @@ -12,6 +12,14 @@ VkBool32 Callback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, VkDebugUtilsMessageTypeFlagsEXT type, const VkDebugUtilsMessengerCallbackDataEXT* data, [[maybe_unused]] void* user_data) { + // Skip logging known false-positive validation errors + switch (static_cast(data->messageIdNumber)) { + case 0x682a878au: // VUID-vkCmdBindVertexBuffers2EXT-pBuffers-parameter + case 0x99fb7dfdu: // UNASSIGNED-RequiredParameter (vkCmdBindVertexBuffers2EXT pBuffers[0]) + return VK_FALSE; + default: + break; + } const std::string_view message{data->pMessage}; if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) { LOG_CRITICAL(Render_Vulkan, "{}", message); diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 724a0141c..707a8b8fb 100755 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -821,13 +821,11 @@ void Device::CollectTelemetryParameters() { void Device::CollectPhysicalMemoryInfo() { const auto mem_properties = physical.GetMemoryProperties(); - const std::size_t num_properties = mem_properties.memoryTypeCount; + const std::size_t num_properties = mem_properties.memoryHeapCount; device_access_memory = 0; for (std::size_t element = 0; element < num_properties; element++) { - if ((mem_properties.memoryTypes[element].propertyFlags & - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) != 0) { - const std::size_t heap_index = mem_properties.memoryTypes[element].heapIndex; - device_access_memory += mem_properties.memoryHeaps[heap_index].size; + if ((mem_properties.memoryHeaps[element].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) != 0) { + device_access_memory += mem_properties.memoryHeaps[element].size; } } } diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 6b83695b2..be065f077 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -236,9 +236,9 @@ const std::array Config::default_hotkeys{{ {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}}, {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), Qt::WindowShortcut}}, {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}}, + {QStringLiteral("Toggle Framerate Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+U"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F9"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), Qt::ApplicationShortcut}}, - {QStringLiteral("Toggle Frame Limiter"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+U"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), Qt::WindowShortcut}}, }}; // clang-format on @@ -655,7 +655,6 @@ void Config::ReadDebuggingValues() { Settings::values.quest_flag = ReadSetting(QStringLiteral("quest_flag"), false).toBool(); Settings::values.disable_macro_jit = ReadSetting(QStringLiteral("disable_macro_jit"), false).toBool(); - Settings::values.unlimit_fps = ReadSetting(QStringLiteral("unlimit_fps"), false).toBool(); Settings::values.extended_logging = ReadSetting(QStringLiteral("extended_logging"), false).toBool(); Settings::values.use_debug_asserts = @@ -813,6 +812,8 @@ void Config::ReadRendererValues() { true); ReadSettingGlobal(Settings::values.accelerate_astc, QStringLiteral("accelerate_astc"), true); ReadSettingGlobal(Settings::values.use_vsync, QStringLiteral("use_vsync"), true); + ReadSettingGlobal(Settings::values.disable_fps_limit, QStringLiteral("disable_fps_limit"), + false); ReadSettingGlobal(Settings::values.use_assembly_shaders, QStringLiteral("use_assembly_shaders"), false); ReadSettingGlobal(Settings::values.use_asynchronous_shaders, @@ -1269,7 +1270,6 @@ void Config::SaveDebuggingValues() { WriteSetting(QStringLiteral("quest_flag"), Settings::values.quest_flag, false); WriteSetting(QStringLiteral("use_debug_asserts"), Settings::values.use_debug_asserts, false); WriteSetting(QStringLiteral("disable_macro_jit"), Settings::values.disable_macro_jit, false); - WriteSetting(QStringLiteral("unlimit_fps"), Settings::values.unlimit_fps, false); qt_config->endGroup(); } @@ -1399,6 +1399,8 @@ void Config::SaveRendererValues() { true); WriteSettingGlobal(QStringLiteral("accelerate_astc"), Settings::values.accelerate_astc, true); WriteSettingGlobal(QStringLiteral("use_vsync"), Settings::values.use_vsync, true); + WriteSettingGlobal(QStringLiteral("disable_fps_limit"), Settings::values.disable_fps_limit, + false); WriteSettingGlobal(QStringLiteral("use_assembly_shaders"), Settings::values.use_assembly_shaders, false); WriteSettingGlobal(QStringLiteral("use_asynchronous_shaders"), diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index a5472a89a..15d6a5ad7 100755 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -44,7 +44,6 @@ void ConfigureDebug::SetConfiguration() { ui->enable_graphics_debugging->setChecked(Settings::values.renderer_debug); ui->disable_macro_jit->setEnabled(runtime_lock); ui->disable_macro_jit->setChecked(Settings::values.disable_macro_jit); - ui->unlimit_fps->setChecked(Settings::values.unlimit_fps); ui->extended_logging->setChecked(Settings::values.extended_logging); } @@ -59,7 +58,6 @@ void ConfigureDebug::ApplyConfiguration() { Settings::values.use_auto_stub = ui->use_auto_stub->isChecked(); Settings::values.renderer_debug = ui->enable_graphics_debugging->isChecked(); Settings::values.disable_macro_jit = ui->disable_macro_jit->isChecked(); - Settings::values.unlimit_fps = ui->unlimit_fps->isChecked(); Settings::values.extended_logging = ui->extended_logging->isChecked(); Debugger::ToggleConsole(); Common::Log::Filter filter; diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui index a9a8fe942..c8087542f 100755 --- a/src/yuzu/configuration/configure_debug.ui +++ b/src/yuzu/configuration/configure_debug.ui @@ -138,24 +138,6 @@ - - - - true - - - - <html><head/><body> - <p>Presents guest frames as they become available, disabling the fps limit in most titles.</p> - <p>NOTE: Will cause instabilities.</p> - </body></html> - - - - Unlimit Framerate (Experimental) - - - diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index a9e611125..8d13c9857 100755 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -28,6 +28,7 @@ void ConfigureGraphicsAdvanced::SetConfiguration() { ui->anisotropic_filtering_combobox->setEnabled(runtime_lock); ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue()); + ui->disable_fps_limit->setChecked(Settings::values.disable_fps_limit.GetValue()); ui->use_assembly_shaders->setChecked(Settings::values.use_assembly_shaders.GetValue()); ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue()); ui->use_caches_gc->setChecked(Settings::values.use_caches_gc.GetValue()); @@ -58,6 +59,8 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() { ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy, ui->anisotropic_filtering_combobox); ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.disable_fps_limit, + ui->disable_fps_limit, disable_fps_limit); ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_assembly_shaders, ui->use_assembly_shaders, use_assembly_shaders); ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_shaders, @@ -100,6 +103,7 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { if (Settings::IsConfiguringGlobal()) { ui->gpu_accuracy->setEnabled(Settings::values.gpu_accuracy.UsingGlobal()); ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal()); + ui->disable_fps_limit->setEnabled(Settings::values.disable_fps_limit.UsingGlobal()); ui->use_assembly_shaders->setEnabled(Settings::values.use_assembly_shaders.UsingGlobal()); ui->use_asynchronous_shaders->setEnabled( Settings::values.use_asynchronous_shaders.UsingGlobal()); @@ -112,6 +116,8 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { } ConfigurationShared::SetColoredTristate(ui->use_vsync, Settings::values.use_vsync, use_vsync); + ConfigurationShared::SetColoredTristate(ui->disable_fps_limit, + Settings::values.disable_fps_limit, disable_fps_limit); ConfigurationShared::SetColoredTristate( ui->use_assembly_shaders, Settings::values.use_assembly_shaders, use_assembly_shaders); ConfigurationShared::SetColoredTristate(ui->use_asynchronous_shaders, diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h index 9148aacf2..6ac5f20ec 100755 --- a/src/yuzu/configuration/configure_graphics_advanced.h +++ b/src/yuzu/configuration/configure_graphics_advanced.h @@ -35,6 +35,7 @@ private: std::unique_ptr ui; ConfigurationShared::CheckState use_vsync; + ConfigurationShared::CheckState disable_fps_limit; ConfigurationShared::CheckState use_assembly_shaders; ConfigurationShared::CheckState use_asynchronous_shaders; ConfigurationShared::CheckState use_fast_gpu_time; diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui index eaf55c517..18c43629e 100755 --- a/src/yuzu/configuration/configure_graphics_advanced.ui +++ b/src/yuzu/configuration/configure_graphics_advanced.ui @@ -76,6 +76,24 @@ + + + + true + + + + <html><head/><body> + <p>Presents guest frames as they become available, disabling the FPS limit in most titles.</p> + <p>NOTE: Will cause instabilities.</p> + </body></html> + + + + Disable framerate limit (experimental) + + + @@ -109,7 +127,7 @@ Enables garbage collection for the GPU caches, this will try to keep VRAM within 3-4 GB by flushing the least used textures/buffers. May cause issues in a few games. - Enable GPU cache garbage collection (unsafe) + Enable GPU cache garbage collection (experimental) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index ab6ec1e5a..d4c7d2c0b 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1025,9 +1025,11 @@ void GMainWindow::InitializeHotkeys() { connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Mute Audio"), this), &QShortcut::activated, this, [] { Settings::values.audio_muted = !Settings::values.audio_muted; }); - connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Frame Limiter"), this), - &QShortcut::activated, this, - [] { Settings::values.unlimit_fps = !Settings::values.unlimit_fps; }); + connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Framerate Limit"), this), + &QShortcut::activated, this, [] { + Settings::values.disable_fps_limit.SetValue( + !Settings::values.disable_fps_limit.GetValue()); + }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Mouse Panning"), this), &QShortcut::activated, this, [&] { Settings::values.mouse_panning = !Settings::values.mouse_panning; diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 1b2df6cef..60bf66ec0 100755 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -443,6 +443,8 @@ void Config::ReadValues() { sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", true)); Settings::values.use_vsync.SetValue( static_cast(sdl2_config->GetInteger("Renderer", "use_vsync", 1))); + Settings::values.disable_fps_limit.SetValue( + sdl2_config->GetBoolean("Renderer", "disable_fps_limit", false)); Settings::values.use_assembly_shaders.SetValue( sdl2_config->GetBoolean("Renderer", "use_assembly_shaders", true)); Settings::values.use_asynchronous_shaders.SetValue( @@ -490,7 +492,6 @@ void Config::ReadValues() { Settings::values.disable_macro_jit = sdl2_config->GetBoolean("Debugging", "disable_macro_jit", false); - Settings::values.unlimit_fps = sdl2_config->GetBoolean("Debugging", "unlimit_fps", false); const auto title_list = sdl2_config->Get("AddOns", "title_ids", ""); std::stringstream ss(title_list); diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index a81b1594f..cc9850aad 100755 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -368,7 +368,7 @@ use_auto_stub = disable_macro_jit=false # Presents guest frames as they become available. Experimental. # false: Disabled (default), true: Enabled -unlimit_fps=false +disable_fps_limit=false [WebService] # Whether or not to enable telemetry