diff options
| author | 2021-10-17 17:22:16 +0200 | |
|---|---|---|
| committer | 2021-11-16 22:11:31 +0100 | |
| commit | b60966041c5b1dccd9c5c5ca00fb02353c2151bb (patch) | |
| tree | a4c8e34aadb27e64989a69b3b3b32584e193fab1 /src/video_core/renderer_vulkan | |
| parent | externals: Add only included ffx-fsr headers (diff) | |
| download | yuzu-b60966041c5b1dccd9c5c5ca00fb02353c2151bb.tar.gz yuzu-b60966041c5b1dccd9c5c5ca00fb02353c2151bb.tar.xz yuzu-b60966041c5b1dccd9c5c5ca00fb02353c2151bb.zip | |
Presentation: add Nearest Neighbor filter.
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_blit_screen.cpp | 41 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_blit_screen.h | 4 |
2 files changed, 37 insertions, 8 deletions
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp index 8ce60e874..334eeb92e 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp +++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp | |||
| @@ -152,7 +152,9 @@ VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer, | |||
| 152 | use_accelerated ? screen_info.image_view : *raw_image_views[image_index]; | 152 | use_accelerated ? screen_info.image_view : *raw_image_views[image_index]; |
| 153 | 153 | ||
| 154 | if (!fsr) { | 154 | if (!fsr) { |
| 155 | UpdateDescriptorSet(image_index, source_image_view); | 155 | const bool is_nn = |
| 156 | Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::NearestNeighbor; | ||
| 157 | UpdateDescriptorSet(image_index, source_image_view, is_nn); | ||
| 156 | } | 158 | } |
| 157 | 159 | ||
| 158 | BufferData data; | 160 | BufferData data; |
| @@ -247,7 +249,7 @@ VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer, | |||
| 247 | crop_rect = crop_rect.Scale(Settings::values.resolution_info.up_factor); | 249 | crop_rect = crop_rect.Scale(Settings::values.resolution_info.up_factor); |
| 248 | VkImageView fsr_image_view = | 250 | VkImageView fsr_image_view = |
| 249 | fsr->Draw(scheduler, image_index, source_image_view, crop_rect); | 251 | fsr->Draw(scheduler, image_index, source_image_view, crop_rect); |
| 250 | UpdateDescriptorSet(image_index, fsr_image_view); | 252 | UpdateDescriptorSet(image_index, fsr_image_view, true); |
| 251 | } | 253 | } |
| 252 | 254 | ||
| 253 | scheduler.Record( | 255 | scheduler.Record( |
| @@ -286,6 +288,9 @@ VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer, | |||
| 286 | const auto filter = Settings::values.scaling_filter.GetValue(); | 288 | const auto filter = Settings::values.scaling_filter.GetValue(); |
| 287 | cmdbuf.BeginRenderPass(renderpass_bi, VK_SUBPASS_CONTENTS_INLINE); | 289 | cmdbuf.BeginRenderPass(renderpass_bi, VK_SUBPASS_CONTENTS_INLINE); |
| 288 | switch (filter) { | 290 | switch (filter) { |
| 291 | case Settings::ScalingFilter::NearestNeighbor: | ||
| 292 | cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *bilinear_pipeline); | ||
| 293 | break; | ||
| 289 | case Settings::ScalingFilter::Bilinear: | 294 | case Settings::ScalingFilter::Bilinear: |
| 290 | cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *bilinear_pipeline); | 295 | cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *bilinear_pipeline); |
| 291 | break; | 296 | break; |
| @@ -745,13 +750,33 @@ void VKBlitScreen::CreateGraphicsPipeline() { | |||
| 745 | } | 750 | } |
| 746 | 751 | ||
| 747 | void VKBlitScreen::CreateSampler() { | 752 | void VKBlitScreen::CreateSampler() { |
| 748 | bool linear = Settings::values.scaling_filter.GetValue() != Settings::ScalingFilter::Fsr; | ||
| 749 | const VkSamplerCreateInfo ci{ | 753 | const VkSamplerCreateInfo ci{ |
| 750 | .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, | 754 | .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, |
| 751 | .pNext = nullptr, | 755 | .pNext = nullptr, |
| 752 | .flags = 0, | 756 | .flags = 0, |
| 753 | .magFilter = linear ? VK_FILTER_LINEAR : VK_FILTER_NEAREST, | 757 | .magFilter = VK_FILTER_LINEAR, |
| 754 | .minFilter = linear ? VK_FILTER_LINEAR : VK_FILTER_NEAREST, | 758 | .minFilter = VK_FILTER_LINEAR, |
| 759 | .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST, | ||
| 760 | .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, | ||
| 761 | .addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, | ||
| 762 | .addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, | ||
| 763 | .mipLodBias = 0.0f, | ||
| 764 | .anisotropyEnable = VK_FALSE, | ||
| 765 | .maxAnisotropy = 0.0f, | ||
| 766 | .compareEnable = VK_FALSE, | ||
| 767 | .compareOp = VK_COMPARE_OP_NEVER, | ||
| 768 | .minLod = 0.0f, | ||
| 769 | .maxLod = 0.0f, | ||
| 770 | .borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK, | ||
| 771 | .unnormalizedCoordinates = VK_FALSE, | ||
| 772 | }; | ||
| 773 | |||
| 774 | const VkSamplerCreateInfo ci_nn{ | ||
| 775 | .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, | ||
| 776 | .pNext = nullptr, | ||
| 777 | .flags = 0, | ||
| 778 | .magFilter = VK_FILTER_NEAREST, | ||
| 779 | .minFilter = VK_FILTER_NEAREST, | ||
| 755 | .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST, | 780 | .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST, |
| 756 | .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, | 781 | .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, |
| 757 | .addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, | 782 | .addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, |
| @@ -768,6 +793,7 @@ void VKBlitScreen::CreateSampler() { | |||
| 768 | }; | 793 | }; |
| 769 | 794 | ||
| 770 | sampler = device.GetLogical().CreateSampler(ci); | 795 | sampler = device.GetLogical().CreateSampler(ci); |
| 796 | nn_sampler = device.GetLogical().CreateSampler(ci_nn); | ||
| 771 | } | 797 | } |
| 772 | 798 | ||
| 773 | void VKBlitScreen::CreateFramebuffers() { | 799 | void VKBlitScreen::CreateFramebuffers() { |
| @@ -862,7 +888,8 @@ void VKBlitScreen::CreateRawImages(const Tegra::FramebufferConfig& framebuffer) | |||
| 862 | } | 888 | } |
| 863 | } | 889 | } |
| 864 | 890 | ||
| 865 | void VKBlitScreen::UpdateDescriptorSet(std::size_t image_index, VkImageView image_view) const { | 891 | void VKBlitScreen::UpdateDescriptorSet(std::size_t image_index, VkImageView image_view, |
| 892 | bool nn) const { | ||
| 866 | const VkDescriptorBufferInfo buffer_info{ | 893 | const VkDescriptorBufferInfo buffer_info{ |
| 867 | .buffer = *buffer, | 894 | .buffer = *buffer, |
| 868 | .offset = offsetof(BufferData, uniform), | 895 | .offset = offsetof(BufferData, uniform), |
| @@ -883,7 +910,7 @@ void VKBlitScreen::UpdateDescriptorSet(std::size_t image_index, VkImageView imag | |||
| 883 | }; | 910 | }; |
| 884 | 911 | ||
| 885 | const VkDescriptorImageInfo image_info{ | 912 | const VkDescriptorImageInfo image_info{ |
| 886 | .sampler = *sampler, | 913 | .sampler = nn ? *nn_sampler : *sampler, |
| 887 | .imageView = image_view, | 914 | .imageView = image_view, |
| 888 | .imageLayout = VK_IMAGE_LAYOUT_GENERAL, | 915 | .imageLayout = VK_IMAGE_LAYOUT_GENERAL, |
| 889 | }; | 916 | }; |
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.h b/src/video_core/renderer_vulkan/vk_blit_screen.h index 337931468..448a2fbe6 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.h +++ b/src/video_core/renderer_vulkan/vk_blit_screen.h | |||
| @@ -90,7 +90,7 @@ private: | |||
| 90 | void CreateStagingBuffer(const Tegra::FramebufferConfig& framebuffer); | 90 | void CreateStagingBuffer(const Tegra::FramebufferConfig& framebuffer); |
| 91 | void CreateRawImages(const Tegra::FramebufferConfig& framebuffer); | 91 | void CreateRawImages(const Tegra::FramebufferConfig& framebuffer); |
| 92 | 92 | ||
| 93 | void UpdateDescriptorSet(std::size_t image_index, VkImageView image_view) const; | 93 | void UpdateDescriptorSet(std::size_t image_index, VkImageView image_view, bool nn) const; |
| 94 | void SetUniformData(BufferData& data, const Layout::FramebufferLayout layout) const; | 94 | void SetUniformData(BufferData& data, const Layout::FramebufferLayout layout) const; |
| 95 | void SetVertexData(BufferData& data, const Tegra::FramebufferConfig& framebuffer, | 95 | void SetVertexData(BufferData& data, const Tegra::FramebufferConfig& framebuffer, |
| 96 | const Layout::FramebufferLayout layout) const; | 96 | const Layout::FramebufferLayout layout) const; |
| @@ -115,12 +115,14 @@ private: | |||
| 115 | vk::DescriptorPool descriptor_pool; | 115 | vk::DescriptorPool descriptor_pool; |
| 116 | vk::DescriptorSetLayout descriptor_set_layout; | 116 | vk::DescriptorSetLayout descriptor_set_layout; |
| 117 | vk::PipelineLayout pipeline_layout; | 117 | vk::PipelineLayout pipeline_layout; |
| 118 | vk::Pipeline nearest_neightbor_pipeline; | ||
| 118 | vk::Pipeline bilinear_pipeline; | 119 | vk::Pipeline bilinear_pipeline; |
| 119 | vk::Pipeline bicubic_pipeline; | 120 | vk::Pipeline bicubic_pipeline; |
| 120 | vk::Pipeline scaleforce_pipeline; | 121 | vk::Pipeline scaleforce_pipeline; |
| 121 | vk::RenderPass renderpass; | 122 | vk::RenderPass renderpass; |
| 122 | std::vector<vk::Framebuffer> framebuffers; | 123 | std::vector<vk::Framebuffer> framebuffers; |
| 123 | vk::DescriptorSets descriptor_sets; | 124 | vk::DescriptorSets descriptor_sets; |
| 125 | vk::Sampler nn_sampler; | ||
| 124 | vk::Sampler sampler; | 126 | vk::Sampler sampler; |
| 125 | 127 | ||
| 126 | vk::Buffer buffer; | 128 | vk::Buffer buffer; |