aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan/present
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2025-07-22 20:49:00 +0200
committercrueter <crueter@eden-emu.dev>2025-07-22 20:49:00 +0200
commitb66adfe04c2a0bae57d829553aa329a445d8aee0 (patch)
treea1bae885703dbf435d30ce8ed8082d94ae2f7e6b /src/video_core/renderer_vulkan/present
parent8d86b615d54525ffc8602264085a9f7faf532309 (diff)
[vulkan] add native cubic filtering (#88)
Co-authored-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/88 This implements the use of VK_FILTER_CUBIC_EXT as a replacement for the software-based bicubic window adapting filter, used primarily for texture sampling in upscaled or downscaled surfaces such as UI, transparency effects, and screen-space elements in Unreal Engine 4 titles. The Vulkan cubic filter is now conditionally enabled if the following are satisfied: The device supports VK_EXT_filter_cubic The format used supports VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT This change improves visual quality while reducing GPU workload by offloading cubic filtering to the driver instead of running custom sampling code in shaders. On supported hardware (e.g. desktop GPUs or high-end Adreno/AMD devices), it results in smoother transitions, improved transparency sampling, and better fidelity with lower shader complexity. Fallback to the original software bicubic logic remains in place for devices lacking the extension or format capability. Tested on several UE4 titles and confirmed to preserve or enhance visual output, especially in alpha-blended and UI-heavy scenes. Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src/video_core/renderer_vulkan/present')
-rw-r--r--src/video_core/renderer_vulkan/present/filters.cpp6
-rw-r--r--src/video_core/renderer_vulkan/present/util.cpp28
-rw-r--r--src/video_core/renderer_vulkan/present/util.h4
3 files changed, 37 insertions, 1 deletions
diff --git a/src/video_core/renderer_vulkan/present/filters.cpp b/src/video_core/renderer_vulkan/present/filters.cpp
index e5365acde9..7843f38d2c 100644
--- a/src/video_core/renderer_vulkan/present/filters.cpp
+++ b/src/video_core/renderer_vulkan/present/filters.cpp
@@ -46,8 +46,12 @@ std::unique_ptr<WindowAdaptPass> MakeBilinear(const Device& device, VkFormat fra
}
std::unique_ptr<WindowAdaptPass> MakeBicubic(const Device& device, VkFormat frame_format) {
+ // No need for handrolled shader -- if the VK impl can do it for us ;)
+ if (device.IsExtFilterCubicSupported())
+ return std::make_unique<WindowAdaptPass>(device, frame_format, CreateCubicSampler(device),
+ BuildShader(device, VULKAN_PRESENT_FRAG_SPV));
return std::make_unique<WindowAdaptPass>(device, frame_format, CreateBilinearSampler(device),
- BuildShader(device, PRESENT_BICUBIC_FRAG_SPV));
+ BuildShader(device, PRESENT_BICUBIC_FRAG_SPV));
}
std::unique_ptr<WindowAdaptPass> MakeGaussian(const Device& device, VkFormat frame_format) {
diff --git a/src/video_core/renderer_vulkan/present/util.cpp b/src/video_core/renderer_vulkan/present/util.cpp
index 7f27c7c1b5..6874bbae99 100644
--- a/src/video_core/renderer_vulkan/present/util.cpp
+++ b/src/video_core/renderer_vulkan/present/util.cpp
@@ -1,3 +1,6 @@
+// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -621,6 +624,31 @@ vk::Sampler CreateNearestNeighborSampler(const Device& device) {
return device.GetLogical().CreateSampler(ci_nn);
}
+vk::Sampler CreateCubicSampler(const Device& device) {
+ const VkSamplerCreateInfo ci_nn{
+ .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
+ .pNext = nullptr,
+ .flags = 0,
+ .magFilter = VK_FILTER_CUBIC_EXT,
+ .minFilter = VK_FILTER_CUBIC_EXT,
+ .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST,
+ .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
+ .addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
+ .addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
+ .mipLodBias = 0.0f,
+ .anisotropyEnable = VK_FALSE,
+ .maxAnisotropy = 0.0f,
+ .compareEnable = VK_FALSE,
+ .compareOp = VK_COMPARE_OP_NEVER,
+ .minLod = 0.0f,
+ .maxLod = 0.0f,
+ .borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK,
+ .unnormalizedCoordinates = VK_FALSE,
+ };
+
+ return device.GetLogical().CreateSampler(ci_nn);
+}
+
void ClearColorImage(vk::CommandBuffer& cmdbuf, VkImage image) {
static constexpr std::array<VkImageSubresourceRange, 1> subresources{{{
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
diff --git a/src/video_core/renderer_vulkan/present/util.h b/src/video_core/renderer_vulkan/present/util.h
index 5b22f0fa82..11810352df 100644
--- a/src/video_core/renderer_vulkan/present/util.h
+++ b/src/video_core/renderer_vulkan/present/util.h
@@ -1,3 +1,6 @@
+// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -54,6 +57,7 @@ VkWriteDescriptorSet CreateWriteDescriptorSet(std::vector<VkDescriptorImageInfo>
VkDescriptorSet set, u32 binding);
vk::Sampler CreateBilinearSampler(const Device& device);
vk::Sampler CreateNearestNeighborSampler(const Device& device);
+vk::Sampler CreateCubicSampler(const Device& device);
void BeginRenderPass(vk::CommandBuffer& cmdbuf, VkRenderPass render_pass, VkFramebuffer framebuffer,
VkExtent2D extent);