From 8657c4c5eb8e3a37e01d84c709f21eedc5c83193 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Fri, 30 Jun 2023 01:36:31 +0200 Subject: [PATCH] early-access version 3725 --- README.md | 2 +- src/android/gradle.properties | 3 + src/common/settings.h | 10 +-- src/input_common/drivers/mouse.cpp | 73 +++++++++---------- .../renderer_vulkan/vk_texture_cache.cpp | 46 ++++++++++-- .../renderer_vulkan/vk_texture_cache.h | 5 ++ src/video_core/texture_cache/texture_cache.h | 4 + src/video_core/texture_cache/types.h | 1 - src/video_core/texture_cache/util.cpp | 9 +-- src/video_core/vulkan_common/vulkan_device.h | 6 ++ src/yuzu/configuration/config.cpp | 6 +- .../configuration/configure_mouse_panning.cpp | 18 ++--- .../configuration/configure_mouse_panning.ui | 32 +------- 13 files changed, 112 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index cec3a9ce3..40159359d 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3720. +This is the source code for early-access 3725. ## Legal Notice diff --git a/src/android/gradle.properties b/src/android/gradle.properties index e2f278f33..4fca1b576 100755 --- a/src/android/gradle.properties +++ b/src/android/gradle.properties @@ -15,3 +15,6 @@ android.useAndroidX=true kotlin.code.style=official kotlin.parallel.tasks.in.project=true android.defaults.buildfeatures.buildconfig=true + +# Android Gradle plugin 8.0.2 +android.suppressUnsupportedCompileSdk=34 diff --git a/src/common/settings.h b/src/common/settings.h index a22d39cf2..e6b757b2a 100755 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -527,12 +527,10 @@ struct Values { Setting mouse_panning{false, "mouse_panning"}; Setting mouse_panning_x_sensitivity{50, 1, 100, "mouse_panning_x_sensitivity"}; Setting mouse_panning_y_sensitivity{50, 1, 100, "mouse_panning_y_sensitivity"}; - Setting mouse_panning_deadzone_x_counterweight{ - 0, 0, 100, "mouse_panning_deadzone_x_counterweight"}; - Setting mouse_panning_deadzone_y_counterweight{ - 0, 0, 100, "mouse_panning_deadzone_y_counterweight"}; - Setting mouse_panning_decay_strength{22, 0, 100, "mouse_panning_decay_strength"}; - Setting mouse_panning_min_decay{5, 0, 100, "mouse_panning_min_decay"}; + Setting mouse_panning_deadzone_counterweight{20, 0, 100, + "mouse_panning_deadzone_counterweight"}; + Setting mouse_panning_decay_strength{18, 0, 100, "mouse_panning_decay_strength"}; + Setting mouse_panning_min_decay{6, 0, 100, "mouse_panning_min_decay"}; Setting mouse_enabled{false, "mouse_enabled"}; Setting emulate_analog_keyboard{false, "emulate_analog_keyboard"}; diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index a522fdd1c..a95198fbb 100755 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp @@ -12,9 +12,13 @@ namespace InputCommon { constexpr int update_time = 10; -constexpr float default_stick_sensitivity = 0.0044f; -constexpr float default_motion_sensitivity = 0.0003f; +constexpr float default_panning_sensitivity = 0.0010f; +constexpr float default_stick_sensitivity = 0.0006f; +constexpr float default_deadzone_counterweight = 0.01f; +constexpr float default_motion_panning_sensitivity = 2.5f; +constexpr float default_motion_sensitivity = 0.416f; constexpr float maximum_rotation_speed = 2.0f; +constexpr float maximum_stick_range = 1.5f; constexpr int mouse_axis_x = 0; constexpr int mouse_axis_y = 1; constexpr int wheel_axis_x = 2; @@ -89,26 +93,13 @@ void Mouse::UpdateStickInput() { // Prevent input from exceeding the max range (1.0f) too much, // but allow some room to make it easier to sustain - if (length > 1.2f) { + if (length > maximum_stick_range) { last_mouse_change /= length; - last_mouse_change *= 1.2f; + last_mouse_change *= maximum_stick_range; } - auto mouse_change = last_mouse_change; - - // Bind the mouse change to [0 <= deadzone_counterweight <= 1,1] - if (length < 1.0f) { - const float deadzone_h_counterweight = - Settings::values.mouse_panning_deadzone_x_counterweight.GetValue(); - const float deadzone_v_counterweight = - Settings::values.mouse_panning_deadzone_y_counterweight.GetValue(); - mouse_change /= length; - mouse_change.x *= length + (1 - length) * deadzone_h_counterweight * 0.01f; - mouse_change.y *= length + (1 - length) * deadzone_v_counterweight * 0.01f; - } - - SetAxis(identifier, mouse_axis_x, mouse_change.x); - SetAxis(identifier, mouse_axis_y, -mouse_change.y); + SetAxis(identifier, mouse_axis_x, last_mouse_change.x); + SetAxis(identifier, mouse_axis_y, -last_mouse_change.y); // Decay input over time const float clamped_length = std::min(1.0f, length); @@ -120,14 +111,13 @@ void Mouse::UpdateStickInput() { } void Mouse::UpdateMotionInput() { - // This may need its own sensitivity instead of using the average - const float sensitivity = (Settings::values.mouse_panning_x_sensitivity.GetValue() + - Settings::values.mouse_panning_y_sensitivity.GetValue()) / - 2.0f * default_motion_sensitivity; + const float sensitivity = Settings::values.mouse_panning ? default_motion_panning_sensitivity + : default_motion_sensitivity; const float rotation_velocity = std::sqrt(last_motion_change.x * last_motion_change.x + last_motion_change.y * last_motion_change.y); + // Clamp rotation speed if (rotation_velocity > maximum_rotation_speed / sensitivity) { const float multiplier = maximum_rotation_speed / rotation_velocity / sensitivity; last_motion_change.x = last_motion_change.x * multiplier; @@ -158,29 +148,38 @@ void Mouse::Move(int x, int y, int center_x, int center_y) { const auto mouse_change = (Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast(); const float x_sensitivity = - Settings::values.mouse_panning_x_sensitivity.GetValue() * default_stick_sensitivity; + Settings::values.mouse_panning_x_sensitivity.GetValue() * default_panning_sensitivity; const float y_sensitivity = - Settings::values.mouse_panning_y_sensitivity.GetValue() * default_stick_sensitivity; + Settings::values.mouse_panning_y_sensitivity.GetValue() * default_panning_sensitivity; + const float deadzone_counterweight = + Settings::values.mouse_panning_deadzone_counterweight.GetValue() * + default_deadzone_counterweight; - last_motion_change += {-mouse_change.y, -mouse_change.x, 0}; - last_mouse_change.x += mouse_change.x * x_sensitivity * 0.09f; - last_mouse_change.y += mouse_change.y * y_sensitivity * 0.09f; + last_motion_change += {-mouse_change.y * x_sensitivity, -mouse_change.x * y_sensitivity, 0}; + last_mouse_change.x += mouse_change.x * x_sensitivity; + last_mouse_change.y += mouse_change.y * y_sensitivity; + + // Bind the mouse change to [0 <= deadzone_counterweight <= 1.0] + if (last_mouse_change.Length() < deadzone_counterweight) { + last_mouse_change /= last_mouse_change.Length(); + last_mouse_change *= deadzone_counterweight; + } return; } if (button_pressed) { const auto mouse_move = Common::MakeVec(x, y) - mouse_origin; - const float x_sensitivity = Settings::values.mouse_panning_x_sensitivity.GetValue(); - const float y_sensitivity = Settings::values.mouse_panning_y_sensitivity.GetValue(); - SetAxis(identifier, mouse_axis_x, - static_cast(mouse_move.x) * x_sensitivity * 0.0012f); - SetAxis(identifier, mouse_axis_y, - static_cast(-mouse_move.y) * y_sensitivity * 0.0012f); + const float x_sensitivity = + Settings::values.mouse_panning_x_sensitivity.GetValue() * default_stick_sensitivity; + const float y_sensitivity = + Settings::values.mouse_panning_y_sensitivity.GetValue() * default_stick_sensitivity; + SetAxis(identifier, mouse_axis_x, static_cast(mouse_move.x) * x_sensitivity); + SetAxis(identifier, mouse_axis_y, static_cast(-mouse_move.y) * y_sensitivity); last_motion_change = { - static_cast(-mouse_move.y) / 50.0f, - static_cast(-mouse_move.x) / 50.0f, + static_cast(-mouse_move.y) * x_sensitivity, + static_cast(-mouse_move.x) * y_sensitivity, last_motion_change.z, }; } @@ -234,7 +233,7 @@ void Mouse::ReleaseButton(MouseButton button) { void Mouse::MouseWheelChange(int x, int y) { wheel_position.x += x; wheel_position.y += y; - last_motion_change.z += static_cast(y) / 100.0f; + last_motion_change.z += static_cast(y); SetAxis(identifier, wheel_axis_x, static_cast(wheel_position.x)); SetAxis(identifier, wheel_axis_y, static_cast(wheel_position.y)); } diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 09f25b102..2476a6ef0 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -36,8 +36,10 @@ using VideoCommon::ImageFlagBits; using VideoCommon::ImageInfo; using VideoCommon::ImageType; using VideoCommon::SubresourceRange; +using VideoCore::Surface::BytesPerBlock; using VideoCore::Surface::IsPixelFormatASTC; using VideoCore::Surface::IsPixelFormatInteger; +using VideoCore::Surface::SurfaceType; namespace { constexpr VkBorderColor ConvertBorderColor(const std::array& color) { @@ -130,7 +132,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array& color) { [[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info) { const PixelFormat format = StorageFormat(info.format); const auto format_info = MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, format); - VkImageCreateFlags flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; + VkImageCreateFlags flags{}; if (info.type == ImageType::e2D && info.resources.layers >= 6 && info.size.width == info.size.height && !device.HasBrokenCubeImageCompability()) { flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; @@ -163,11 +165,24 @@ constexpr VkBorderColor ConvertBorderColor(const std::array& color) { } [[nodiscard]] vk::Image MakeImage(const Device& device, const MemoryAllocator& allocator, - const ImageInfo& info) { + const ImageInfo& info, std::span view_formats) { if (info.type == ImageType::Buffer) { return vk::Image{}; } - return allocator.CreateImage(MakeImageCreateInfo(device, info)); + VkImageCreateInfo image_ci = MakeImageCreateInfo(device, info); + const VkImageFormatListCreateInfo image_format_list = { + .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO, + .pNext = nullptr, + .viewFormatCount = static_cast(view_formats.size()), + .pViewFormats = view_formats.data(), + }; + if (view_formats.size() > 1) { + image_ci.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; + if (device.IsKhrImageFormatListSupported()) { + image_ci.pNext = &image_format_list; + } + } + return allocator.CreateImage(image_ci); } [[nodiscard]] VkImageAspectFlags ImageAspectMask(PixelFormat format) { @@ -806,6 +821,24 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched astc_decoder_pass.emplace(device, scheduler, descriptor_pool, staging_buffer_pool, compute_pass_descriptor_queue, memory_allocator); } + if (!device.IsKhrImageFormatListSupported()) { + return; + } + for (size_t index_a = 0; index_a < VideoCore::Surface::MaxPixelFormat; index_a++) { + const auto image_format = static_cast(index_a); + const auto type_a = VideoCore::Surface::GetFormatType(image_format); + if (type_a != SurfaceType::ColorTexture) { + continue; + } + for (size_t index_b = 0; index_b < VideoCore::Surface::MaxPixelFormat; index_b++) { + const auto view_format = static_cast(index_b); + if (VideoCore::Surface::IsViewCompatible(image_format, view_format, false, true)) { + const auto view_info = + MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, true, view_format); + view_formats[index_a].push_back(view_info.format); + } + } + } } void TextureCacheRuntime::Finish() { @@ -1265,8 +1298,8 @@ void TextureCacheRuntime::TickFrame() {} Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu_addr_, VAddr cpu_addr_) : VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), scheduler{&runtime_.scheduler}, - runtime{&runtime_}, - original_image(MakeImage(runtime_.device, runtime_.memory_allocator, info)), + runtime{&runtime_}, original_image(MakeImage(runtime_.device, runtime_.memory_allocator, info, + runtime->ViewFormats(info.format))), aspect_mask(ImageAspectMask(info.format)) { if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) { if (Settings::values.async_astc.GetValue()) { @@ -1471,7 +1504,8 @@ bool Image::ScaleUp(bool ignore) { auto scaled_info = info; scaled_info.size.width = scaled_width; scaled_info.size.height = scaled_height; - scaled_image = MakeImage(runtime->device, runtime->memory_allocator, scaled_info); + scaled_image = MakeImage(runtime->device, runtime->memory_allocator, scaled_info, + runtime->ViewFormats(info.format)); ignore = false; } current_image = *scaled_image; diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index 5013a532a..6089ffa83 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h @@ -103,6 +103,10 @@ public: [[nodiscard]] VkBuffer GetTemporaryBuffer(size_t needed_size); + std::span ViewFormats(PixelFormat format) { + return view_formats[static_cast(format)]; + } + void BarrierFeedbackLoop(); const Device& device; @@ -113,6 +117,7 @@ public: RenderPassCache& render_pass_cache; std::optional astc_decoder_pass; const Settings::ResolutionScalingInfo& resolution; + std::array, VideoCore::Surface::MaxPixelFormat> view_formats; static constexpr size_t indexing_slots = 8 * sizeof(size_t); std::array buffers{}; diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 0ba52e293..8628f97e1 100755 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -870,6 +870,10 @@ ImageId TextureCache

::DmaImageId(const Tegra::DMA::ImageOperand& operand, boo return NULL_IMAGE_ID; } auto& image = slot_images[image_id]; + if (image.info.type == ImageType::e3D) { + // Don't accelerate 3D images. + return NULL_IMAGE_ID; + } if (!is_upload && !image.info.dma_downloaded) { // Force a full sync. image.info.dma_downloaded = true; diff --git a/src/video_core/texture_cache/types.h b/src/video_core/texture_cache/types.h index 3810b3dae..837a87b9b 100755 --- a/src/video_core/texture_cache/types.h +++ b/src/video_core/texture_cache/types.h @@ -54,7 +54,6 @@ enum class RelaxedOptions : u32 { Format = 1 << 1, Samples = 1 << 2, ForceBrokenViews = 1 << 3, - FormatBpp = 1 << 4, }; DECLARE_ENUM_FLAG_OPERATORS(RelaxedOptions) diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp index 094973a42..d230a38a2 100755 --- a/src/video_core/texture_cache/util.cpp +++ b/src/video_core/texture_cache/util.cpp @@ -1201,8 +1201,7 @@ std::optional FindSubresource(const ImageInfo& candidate, const // Format checking is relaxed, but we still have to check for matching bytes per block. // This avoids creating a view for blits on UE4 titles where formats with different bytes // per block are aliased. - if (BytesPerBlock(existing.format) != BytesPerBlock(candidate.format) && - False(options & RelaxedOptions::FormatBpp)) { + if (BytesPerBlock(existing.format) != BytesPerBlock(candidate.format)) { return std::nullopt; } } else { @@ -1233,11 +1232,7 @@ std::optional FindSubresource(const ImageInfo& candidate, const } const bool strict_size = False(options & RelaxedOptions::Size); if (!IsBlockLinearSizeCompatible(existing, candidate, base->level, 0, strict_size)) { - if (False(options & RelaxedOptions::FormatBpp)) { - return std::nullopt; - } else if (!IsBlockLinearSizeCompatibleBPPRelaxed(existing, candidate, base->level, 0)) { - return std::nullopt; - } + return std::nullopt; } // TODO: compare block sizes return base; diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 66d1c3c31..37c999020 100755 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h @@ -77,6 +77,7 @@ VK_DEFINE_HANDLE(VmaAllocator) EXTENSION(KHR, SPIRV_1_4, spirv_1_4) \ EXTENSION(KHR, SWAPCHAIN, swapchain) \ EXTENSION(KHR, SWAPCHAIN_MUTABLE_FORMAT, swapchain_mutable_format) \ + EXTENSION(KHR, IMAGE_FORMAT_LIST, image_format_list) \ EXTENSION(NV, DEVICE_DIAGNOSTICS_CONFIG, device_diagnostics_config) \ EXTENSION(NV, GEOMETRY_SHADER_PASSTHROUGH, geometry_shader_passthrough) \ EXTENSION(NV, VIEWPORT_ARRAY2, viewport_array2) \ @@ -408,6 +409,11 @@ public: return extensions.workgroup_memory_explicit_layout; } + /// Returns true if the device supports VK_KHR_image_format_list. + bool IsKhrImageFormatListSupported() const { + return extensions.image_format_list || instance_version >= VK_API_VERSION_1_2; + } + /// Returns true if the device supports VK_EXT_primitive_topology_list_restart. bool IsTopologyListPrimitiveRestartSupported() const { return features.primitive_topology_list_restart.primitiveTopologyListRestart; diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index a667df3b0..8e1071724 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -503,8 +503,7 @@ void Config::ReadMousePanningValues() { ReadBasicSetting(Settings::values.mouse_panning); ReadBasicSetting(Settings::values.mouse_panning_x_sensitivity); ReadBasicSetting(Settings::values.mouse_panning_y_sensitivity); - ReadBasicSetting(Settings::values.mouse_panning_deadzone_x_counterweight); - ReadBasicSetting(Settings::values.mouse_panning_deadzone_y_counterweight); + ReadBasicSetting(Settings::values.mouse_panning_deadzone_counterweight); ReadBasicSetting(Settings::values.mouse_panning_decay_strength); ReadBasicSetting(Settings::values.mouse_panning_min_decay); } @@ -1122,8 +1121,7 @@ void Config::SaveMousePanningValues() { // Don't overwrite values.mouse_panning WriteBasicSetting(Settings::values.mouse_panning_x_sensitivity); WriteBasicSetting(Settings::values.mouse_panning_y_sensitivity); - WriteBasicSetting(Settings::values.mouse_panning_deadzone_x_counterweight); - WriteBasicSetting(Settings::values.mouse_panning_deadzone_y_counterweight); + WriteBasicSetting(Settings::values.mouse_panning_deadzone_counterweight); WriteBasicSetting(Settings::values.mouse_panning_decay_strength); WriteBasicSetting(Settings::values.mouse_panning_min_decay); } diff --git a/src/yuzu/configuration/configure_mouse_panning.cpp b/src/yuzu/configuration/configure_mouse_panning.cpp index f183d2740..b3386347e 100755 --- a/src/yuzu/configuration/configure_mouse_panning.cpp +++ b/src/yuzu/configuration/configure_mouse_panning.cpp @@ -27,10 +27,8 @@ void ConfigureMousePanning::SetConfiguration(float right_stick_deadzone, float r ui->enable->setChecked(Settings::values.mouse_panning.GetValue()); ui->x_sensitivity->setValue(Settings::values.mouse_panning_x_sensitivity.GetValue()); ui->y_sensitivity->setValue(Settings::values.mouse_panning_y_sensitivity.GetValue()); - ui->deadzone_x_counterweight->setValue( - Settings::values.mouse_panning_deadzone_x_counterweight.GetValue()); - ui->deadzone_y_counterweight->setValue( - Settings::values.mouse_panning_deadzone_y_counterweight.GetValue()); + ui->deadzone_counterweight->setValue( + Settings::values.mouse_panning_deadzone_counterweight.GetValue()); ui->decay_strength->setValue(Settings::values.mouse_panning_decay_strength.GetValue()); ui->min_decay->setValue(Settings::values.mouse_panning_min_decay.GetValue()); @@ -48,10 +46,8 @@ void ConfigureMousePanning::SetConfiguration(float right_stick_deadzone, float r void ConfigureMousePanning::SetDefaultConfiguration() { ui->x_sensitivity->setValue(Settings::values.mouse_panning_x_sensitivity.GetDefault()); ui->y_sensitivity->setValue(Settings::values.mouse_panning_y_sensitivity.GetDefault()); - ui->deadzone_x_counterweight->setValue( - Settings::values.mouse_panning_deadzone_x_counterweight.GetDefault()); - ui->deadzone_y_counterweight->setValue( - Settings::values.mouse_panning_deadzone_y_counterweight.GetDefault()); + ui->deadzone_counterweight->setValue( + Settings::values.mouse_panning_deadzone_counterweight.GetDefault()); ui->decay_strength->setValue(Settings::values.mouse_panning_decay_strength.GetDefault()); ui->min_decay->setValue(Settings::values.mouse_panning_min_decay.GetDefault()); } @@ -68,10 +64,8 @@ void ConfigureMousePanning::ApplyConfiguration() { Settings::values.mouse_panning = ui->enable->isChecked(); Settings::values.mouse_panning_x_sensitivity = static_cast(ui->x_sensitivity->value()); Settings::values.mouse_panning_y_sensitivity = static_cast(ui->y_sensitivity->value()); - Settings::values.mouse_panning_deadzone_x_counterweight = - static_cast(ui->deadzone_x_counterweight->value()); - Settings::values.mouse_panning_deadzone_y_counterweight = - static_cast(ui->deadzone_y_counterweight->value()); + Settings::values.mouse_panning_deadzone_counterweight = + static_cast(ui->deadzone_counterweight->value()); Settings::values.mouse_panning_decay_strength = static_cast(ui->decay_strength->value()); Settings::values.mouse_panning_min_decay = static_cast(ui->min_decay->value()); diff --git a/src/yuzu/configuration/configure_mouse_panning.ui b/src/yuzu/configuration/configure_mouse_panning.ui index 75795b727..33615be54 100755 --- a/src/yuzu/configuration/configure_mouse_panning.ui +++ b/src/yuzu/configuration/configure_mouse_panning.ui @@ -89,40 +89,14 @@ - + - Horizontal + Deadzone - - - Qt::AlignCenter - - - % - - - 0 - - - 100 - - - 0 - - - - - - - Vertical - - - - - + Qt::AlignCenter