From ef99adf450e01a86425fb2ad3a5c7023001b3701 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Fri, 25 Nov 2022 11:21:50 +0100 Subject: [PATCH] early-access version 3150 --- CMakeLists.txt | 4 +- README.md | 2 +- externals/CMakeLists.txt | 12 +- src/common/polyfill_thread.h | 2 +- src/video_core/buffer_cache/buffer_cache.h | 4 +- src/video_core/engines/engine_upload.cpp | 8 +- src/video_core/engines/maxwell_3d.cpp | 8 +- src/video_core/engines/puller.cpp | 4 +- src/video_core/engines/sw_blitter/blitter.cpp | 16 +-- .../engines/sw_blitter/converter.cpp | 6 + .../engines/sw_blitter/generate_converters.py | 136 ++++++++++++++++++ .../renderer_vulkan/maxwell_to_vk.cpp | 6 +- src/yuzu/configuration/config.cpp | 11 +- src/yuzu/configuration/configure_graphics.cpp | 9 ++ src/yuzu/configuration/configure_graphics.h | 2 + src/yuzu/configuration/configure_graphics.ui | 51 ++++++- 16 files changed, 240 insertions(+), 41 deletions(-) create mode 100755 src/video_core/engines/sw_blitter/generate_converters.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 14357fe1d..8af47571f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,7 @@ if(ENABLE_QT) # Check that the system GLIBCXX version is compatible find_program(OBJDUMP objdump) - if ("${OBJDUMP}" STREQUAL "OBJDUMP-NOTFOUND") + if (NOT OBJDUMP) message(FATAL_ERROR "Required program `objdump` not found.") endif() find_library(LIBSTDCXX libstdc++.so.6) @@ -333,7 +333,7 @@ if(ENABLE_QT) set(UNRESOLVED_QT_DEPS "") foreach (REQUIREMENT ${BUNDLED_QT_REQUIREMENTS}) find_library(BUNDLED_QT_${REQUIREMENT} ${REQUIREMENT}) - if ("${BUNDLED_QT_${REQUIREMENT}}" STREQUAL "BUNDLED_QT_${REQUIREMENT}-NOTFOUND") + if (NOT BUNDLED_QT_${REQUIREMENT}) set(UNRESOLVED_QT_DEPS ${UNRESOLVED_QT_DEPS} ${REQUIREMENT}) endif() unset(BUNDLED_QT_${REQUIREMENT}) diff --git a/README.md b/README.md index 6c023e629..bee59633a 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3144. +This is the source code for early-access 3150. ## Legal Notice diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 9af4c611a..11110a755 100755 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -95,10 +95,14 @@ endif() add_subdirectory(sirit) if (ENABLE_WEB_SERVICE) - find_package(OpenSSL 1.1) - if (OPENSSL_FOUND) - set(OPENSSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto) - else() + if (NOT WIN32) + find_package(OpenSSL 1.1) + if (OPENSSL_FOUND) + set(OPENSSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto) + endif() + endif() + + if (WIN32 OR NOT OPENSSL_FOUND) # LibreSSL set(LIBRESSL_SKIP_INSTALL ON CACHE BOOL "") set(OPENSSLDIR "/etc/ssl/") diff --git a/src/common/polyfill_thread.h b/src/common/polyfill_thread.h index d495d51d5..5a8d1ce08 100755 --- a/src/common/polyfill_thread.h +++ b/src/common/polyfill_thread.h @@ -147,7 +147,7 @@ private: class stop_source { public: - stop_source() = default; + stop_source() : m_stop_state(make_shared()) {} explicit stop_source(nostopstate_t) noexcept {} stop_source(const stop_source&) noexcept = default; diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index febb98619..336c722b8 100755 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -1743,12 +1743,12 @@ bool BufferCache

::InlineMemory(VAddr dest_address, size_t copy_size, SynchronizeBuffer(buffer, dest_address, static_cast(copy_size)); if constexpr (USE_MEMORY_MAPS) { + auto upload_staging = runtime.UploadStagingBuffer(copy_size); std::array copies{BufferCopy{ - .src_offset = 0, + .src_offset = upload_staging.offset, .dst_offset = buffer.Offset(dest_address), .size = copy_size, }}; - auto upload_staging = runtime.UploadStagingBuffer(copy_size); u8* const src_pointer = upload_staging.mapped_span.data(); std::memcpy(src_pointer, inlined_buffer.data(), copy_size); runtime.CopyBuffer(buffer, upload_staging.buffer, copies); diff --git a/src/video_core/engines/engine_upload.cpp b/src/video_core/engines/engine_upload.cpp index d05d1f6e7..cf87e3fbb 100755 --- a/src/video_core/engines/engine_upload.cpp +++ b/src/video_core/engines/engine_upload.cpp @@ -51,11 +51,11 @@ void State::ProcessData(std::span read_buffer) { } else { for (u32 line = 0; line < regs.line_count; ++line) { const GPUVAddr dest_line = address + static_cast(line) * regs.dest.pitch; - memory_manager.WriteBlockUnsafe( - dest_line, read_buffer.data() + static_cast(line) * regs.line_length_in, - regs.line_length_in); + std::span buffer(read_buffer.data() + + static_cast(line) * regs.line_length_in, + regs.line_length_in); + rasterizer->AccelerateInlineToMemory(dest_line, regs.line_length_in, buffer); } - memory_manager.InvalidateRegion(address, regs.dest.pitch * regs.line_count); } } else { u32 width = regs.dest.width; diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index e882f0514..6fe957b9a 100755 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -250,9 +250,6 @@ void Maxwell3D::ProcessMethodCall(u32 method, u32 argument, u32 nonshadow_argume return; case MAXWELL3D_REG_INDEX(fragment_barrier): return rasterizer->FragmentBarrier(); - case MAXWELL3D_REG_INDEX(invalidate_texture_data_cache): - rasterizer->InvalidateGPUCache(); - return rasterizer->WaitForIdle(); case MAXWELL3D_REG_INDEX(tiled_cache_barrier): return rasterizer->TiledCacheBarrier(); } @@ -539,10 +536,7 @@ void Maxwell3D::ProcessCounterReset() { void Maxwell3D::ProcessSyncPoint() { const u32 sync_point = regs.sync_info.sync_point.Value(); - const u32 cache_flush = regs.sync_info.clean_l2.Value(); - if (cache_flush != 0) { - rasterizer->InvalidateGPUCache(); - } + [[maybe_unused]] const u32 cache_flush = regs.sync_info.clean_l2.Value(); rasterizer->SignalSyncPoint(sync_point); } diff --git a/src/video_core/engines/puller.cpp b/src/video_core/engines/puller.cpp index 1dc23188f..89bf47272 100755 --- a/src/video_core/engines/puller.cpp +++ b/src/video_core/engines/puller.cpp @@ -118,7 +118,7 @@ void Puller::ProcessSemaphoreRelease() { std::function operation([this, sequence_address, payload] { memory_manager.Write(sequence_address, payload); }); - rasterizer->SyncOperation(std::move(operation)); + rasterizer->SignalFence(std::move(operation)); } void Puller::ProcessSemaphoreAcquire() { @@ -151,8 +151,8 @@ void Puller::CallPullerMethod(const MethodCall& method_call) { case BufferMethods::SemaphoreAddressLow: case BufferMethods::SemaphoreSequencePayload: case BufferMethods::SyncpointPayload: - break; case BufferMethods::WrcacheFlush: + break; case BufferMethods::RefCnt: rasterizer->SignalReference(); break; diff --git a/src/video_core/engines/sw_blitter/blitter.cpp b/src/video_core/engines/sw_blitter/blitter.cpp index c923a80e9..2f1ea4626 100755 --- a/src/video_core/engines/sw_blitter/blitter.cpp +++ b/src/video_core/engines/sw_blitter/blitter.cpp @@ -26,8 +26,8 @@ namespace { constexpr size_t ir_components = 4; -void NeighrestNeighbor(std::span input, std::span output, u32 src_width, - u32 src_height, u32 dst_width, u32 dst_height, size_t bpp) { +void NearestNeighbor(std::span input, std::span output, u32 src_width, u32 src_height, + u32 dst_width, u32 dst_height, size_t bpp) { const size_t dx_du = std::llround((static_cast(src_width) / dst_width) * (1ULL << 32)); const size_t dy_dv = std::llround((static_cast(src_height) / dst_height) * (1ULL << 32)); size_t src_y = 0; @@ -44,8 +44,8 @@ void NeighrestNeighbor(std::span input, std::span output, u32 src_ } } -void NeighrestNeighborFast(std::span input, std::span output, u32 src_width, - u32 src_height, u32 dst_width, u32 dst_height) { +void NearestNeighborFast(std::span input, std::span output, u32 src_width, + u32 src_height, u32 dst_width, u32 dst_height) { const size_t dx_du = std::llround((static_cast(src_width) / dst_width) * (1ULL << 32)); const size_t dy_dv = std::llround((static_cast(src_height) / dst_height) * (1ULL << 32)); size_t src_y = 0; @@ -171,8 +171,8 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst, src.format != dst.format || src_extent_x != dst_extent_x || src_extent_y != dst_extent_y; const auto convertion_phase_same_format = [&]() { - NeighrestNeighbor(impl->src_buffer, impl->dst_buffer, src_extent_x, src_extent_y, - dst_extent_x, dst_extent_y, dst_bytes_per_pixel); + NearestNeighbor(impl->src_buffer, impl->dst_buffer, src_extent_x, src_extent_y, + dst_extent_x, dst_extent_y, dst_bytes_per_pixel); }; const auto convertion_phase_ir = [&]() { @@ -182,8 +182,8 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst, input_converter->ConvertTo(impl->src_buffer, impl->intermediate_src); if (config.filter != Fermi2D::Filter::Bilinear) { - NeighrestNeighborFast(impl->intermediate_src, impl->intermediate_dst, src_extent_x, - src_extent_y, dst_extent_x, dst_extent_y); + NearestNeighborFast(impl->intermediate_src, impl->intermediate_dst, src_extent_x, + src_extent_y, dst_extent_x, dst_extent_y); } else { Bilinear(impl->intermediate_src, impl->intermediate_dst, src_extent_x, src_extent_y, dst_extent_x, dst_extent_y); diff --git a/src/video_core/engines/sw_blitter/converter.cpp b/src/video_core/engines/sw_blitter/converter.cpp index 37c5eff69..cd46dfd4f 100755 --- a/src/video_core/engines/sw_blitter/converter.cpp +++ b/src/video_core/engines/sw_blitter/converter.cpp @@ -41,6 +41,12 @@ enum class ComponentType : u32 { namespace { +/* + * Note: Use generate_converters.py to generate the structs and searches for new render target + * formats and copy paste them to this file in order to update. just call "python + * generate_converters.py" and get the code from the output. modify the file to add new formats. + */ + constexpr std::array SRGB_TO_RGB_LUT = { 0.000000e+00f, 3.035270e-04f, 6.070540e-04f, 9.105810e-04f, 1.214108e-03f, 1.517635e-03f, 1.821162e-03f, 2.124689e-03f, 2.428216e-03f, 2.731743e-03f, 3.035270e-03f, 3.346536e-03f, diff --git a/src/video_core/engines/sw_blitter/generate_converters.py b/src/video_core/engines/sw_blitter/generate_converters.py new file mode 100755 index 000000000..f641564f7 --- /dev/null +++ b/src/video_core/engines/sw_blitter/generate_converters.py @@ -0,0 +1,136 @@ +# SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + +import re + +class Format: + def __init__(self, string_value): + self.name = string_value + tmp = string_value.split('_') + self.component_type = tmp[1] + component_data = re.findall(r"\w\d+", tmp[0]) + self.num_components = len(component_data) + sizes = [] + swizzle = [] + for data in component_data: + swizzle.append(data[0]) + sizes.append(int(data[1:])) + self.sizes = sizes + self.swizzle = swizzle + + def build_component_type_array(self): + result = "{ " + b = False + for i in range(0, self.num_components): + if b: + result += ", " + b = True + result += "ComponentType::" + self.component_type + result += " }" + return result + + def build_component_sizes_array(self): + result = "{ " + b = False + for i in range(0, self.num_components): + if b: + result += ", " + b = True + result += str(self.sizes[i]) + result += " }" + return result + + def build_component_swizzle_array(self): + result = "{ " + b = False + for i in range(0, self.num_components): + if b: + result += ", " + b = True + swizzle = self.swizzle[i] + if swizzle == "X": + swizzle = "None" + result += "Swizzle::" + swizzle + result += " }" + return result + + def print_declaration(self): + print("struct " + self.name + "Traits {") + print(" static constexpr size_t num_components = " + str(self.num_components) + ";") + print(" static constexpr std::array component_types = " + self.build_component_type_array() + ";") + print(" static constexpr std::array component_sizes = " + self.build_component_sizes_array() + ";") + print(" static constexpr std::array component_swizzle = " + self.build_component_swizzle_array() + ";") + print("};\n") + + def print_case(self): + print("case RenderTargetFormat::" + self.name + ":") + print(" return impl->converters_cache") + print(" .emplace(format, std::make_unique>())") + print(" .first->second.get();") + print(" break;") + +txt = """ +R32G32B32A32_FLOAT +R32G32B32A32_SINT +R32G32B32A32_UINT +R32G32B32X32_FLOAT +R32G32B32X32_SINT +R32G32B32X32_UINT +R16G16B16A16_UNORM +R16G16B16A16_SNORM +R16G16B16A16_SINT +R16G16B16A16_UINT +R16G16B16A16_FLOAT +R32G32_FLOAT +R32G32_SINT +R32G32_UINT +R16G16B16X16_FLOAT +A8R8G8B8_UNORM +A8R8G8B8_SRGB +A2B10G10R10_UNORM +A2B10G10R10_UINT +A2R10G10B10_UNORM +A8B8G8R8_UNORM +A8B8G8R8_SRGB +A8B8G8R8_SNORM +A8B8G8R8_SINT +A8B8G8R8_UINT +R16G16_UNORM +R16G16_SNORM +R16G16_SINT +R16G16_UINT +R16G16_FLOAT +B10G11R11_FLOAT +R32_SINT +R32_UINT +R32_FLOAT +X8R8G8B8_UNORM +X8R8G8B8_SRGB +R5G6B5_UNORM +A1R5G5B5_UNORM +R8G8_UNORM +R8G8_SNORM +R8G8_SINT +R8G8_UINT +R16_UNORM +R16_SNORM +R16_SINT +R16_UINT +R16_FLOAT +R8_UNORM +R8_SNORM +R8_SINT +R8_UINT +X1R5G5B5_UNORM +X8B8G8R8_UNORM +X8B8G8R8_SRGB +""" + +x = txt.split() +y = list(map(lambda a: Format(a), x)) +formats = list(y) +for format in formats: + format.print_declaration() + +for format in formats: + format.print_case() diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp index ed9476082..6999c38a6 100755 --- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp +++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp @@ -150,7 +150,7 @@ struct FormatTuple { {VK_FORMAT_BC6H_UFLOAT_BLOCK}, // BC6H_UFLOAT {VK_FORMAT_BC6H_SFLOAT_BLOCK}, // BC6H_SFLOAT {VK_FORMAT_ASTC_4x4_UNORM_BLOCK}, // ASTC_2D_4X4_UNORM - {VK_FORMAT_B8G8R8A8_UNORM, Attachable}, // B8G8R8A8_UNORM + {VK_FORMAT_B8G8R8A8_UNORM, Attachable | Storage}, // B8G8R8A8_UNORM {VK_FORMAT_R32G32B32A32_SFLOAT, Attachable | Storage}, // R32G32B32A32_FLOAT {VK_FORMAT_R32G32B32A32_SINT, Attachable | Storage}, // R32G32B32A32_SINT {VK_FORMAT_R32G32_SFLOAT, Attachable | Storage}, // R32G32_FLOAT @@ -160,7 +160,7 @@ struct FormatTuple { {VK_FORMAT_R16_UNORM, Attachable | Storage}, // R16_UNORM {VK_FORMAT_R16_SNORM, Attachable | Storage}, // R16_SNORM {VK_FORMAT_R16_UINT, Attachable | Storage}, // R16_UINT - {VK_FORMAT_UNDEFINED}, // R16_SINT + {VK_FORMAT_R16_SINT, Attachable | Storage}, // R16_SINT {VK_FORMAT_R16G16_UNORM, Attachable | Storage}, // R16G16_UNORM {VK_FORMAT_R16G16_SFLOAT, Attachable | Storage}, // R16G16_FLOAT {VK_FORMAT_R16G16_UINT, Attachable | Storage}, // R16G16_UINT @@ -184,7 +184,7 @@ struct FormatTuple { {VK_FORMAT_BC2_SRGB_BLOCK}, // BC2_SRGB {VK_FORMAT_BC3_SRGB_BLOCK}, // BC3_SRGB {VK_FORMAT_BC7_SRGB_BLOCK}, // BC7_SRGB - {VK_FORMAT_R4G4B4A4_UNORM_PACK16, Attachable}, // A4B4G4R4_UNORM + {VK_FORMAT_R4G4B4A4_UNORM_PACK16}, // A4B4G4R4_UNORM {VK_FORMAT_R4G4_UNORM_PACK8}, // G4R4_UNORM {VK_FORMAT_ASTC_4x4_SRGB_BLOCK}, // ASTC_2D_4X4_SRGB {VK_FORMAT_ASTC_8x8_SRGB_BLOCK}, // ASTC_2D_8X8_SRGB diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index b816731dd..907897c27 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -408,12 +408,12 @@ void Config::ReadControlValues() { for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { ReadPlayerValue(p); } - Settings::values.use_docked_mode.SetGlobal(!IsCustomConfig()); ReadGlobalSetting(Settings::values.use_docked_mode); // Disable docked mode if handheld is selected const auto controller_type = Settings::values.players.GetValue()[0].controller_type; if (controller_type == Settings::ControllerType::Handheld) { + Settings::values.use_docked_mode.SetGlobal(!IsCustomConfig()); Settings::values.use_docked_mode.SetValue(false); } @@ -1124,11 +1124,6 @@ void Config::SaveControlValues() { for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { SavePlayerValue(p); } - Settings::values.use_docked_mode.SetGlobal(!IsCustomConfig()); - WriteGlobalSetting(Settings::values.use_docked_mode); - WriteGlobalSetting(Settings::values.vibration_enabled); - WriteGlobalSetting(Settings::values.enable_accurate_vibrations); - WriteGlobalSetting(Settings::values.motion_enabled); if (IsCustomConfig()) { qt_config->endGroup(); return; @@ -1140,6 +1135,10 @@ void Config::SaveControlValues() { SaveHidbusValues(); SaveIrCameraValues(); + WriteGlobalSetting(Settings::values.use_docked_mode); + WriteGlobalSetting(Settings::values.vibration_enabled); + WriteGlobalSetting(Settings::values.enable_accurate_vibrations); + WriteGlobalSetting(Settings::values.motion_enabled); WriteBasicSetting(Settings::values.enable_raw_input); WriteBasicSetting(Settings::values.keyboard_enabled); WriteBasicSetting(Settings::values.emulate_analog_keyboard); diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index ff8a30c4e..309d47365 100755 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -63,6 +63,9 @@ ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* paren ui->api_widget->isEnabled()); ui->bg_label->setVisible(Settings::IsConfiguringGlobal()); ui->bg_combobox->setVisible(!Settings::IsConfiguringGlobal()); + + connect(ui->fsr_sharpening_slider, &QSlider::valueChanged, this, + &ConfigureGraphics::SetFSRIndicatorText); } void ConfigureGraphics::UpdateDeviceSelection(int device) { @@ -156,6 +159,12 @@ void ConfigureGraphics::SetConfiguration() { Settings::values.bg_green.GetValue(), Settings::values.bg_blue.GetValue())); UpdateAPILayout(); + SetFSRIndicatorText(ui->fsr_sharpening_slider->sliderPosition()); +} + +void ConfigureGraphics::SetFSRIndicatorText(int percentage) { + ui->fsr_sharpening_value->setText( + tr("%1%", "FSR sharpening percentage (e.g. 50%)").arg(100 - (percentage / 2))); } void ConfigureGraphics::ApplyConfiguration() { diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h index 32456729b..4e0f7128a 100755 --- a/src/yuzu/configuration/configure_graphics.h +++ b/src/yuzu/configuration/configure_graphics.h @@ -42,6 +42,8 @@ private: void RetrieveVulkanDevices(); + void SetFSRIndicatorText(int percentage); + void SetupPerGameUI(); Settings::RendererBackend GetCurrentGraphicsBackend() const; diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index 7c7f79d50..04b09358d 100755 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui @@ -152,6 +152,12 @@ + + + 16777215 + 16777215 + + Graphics Settings @@ -486,6 +492,12 @@ true + + + 0 + 0 + + 6 @@ -507,6 +519,12 @@ + + + 0 + 0 + + FSR Sharpening: @@ -515,11 +533,17 @@ - + 0 0 + + + 0 + 0 + + 200 @@ -534,7 +558,32 @@ + + + + + 0 + 0 + + + + + 32 + 0 + + + + 100% + + + Qt::AlignCenter + + + + fsr_sharpening_value + fsr_sharpening_label + fsr_sharpening_slider