summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2021-08-17 00:12:52 +0200
committerGravatar Fernando Sahmkow2021-11-16 22:11:29 +0100
commita6b88e85bfb14c45345f6443b54d15a61e3975d5 (patch)
treee5908c9c61f3da27fc5f0c5e20d2a8e9809594f9 /src/video_core/renderer_vulkan
parentTexture Cache: fix scaling on upload and stop scaling on base resolution. (diff)
downloadyuzu-a6b88e85bfb14c45345f6443b54d15a61e3975d5.tar.gz
yuzu-a6b88e85bfb14c45345f6443b54d15a61e3975d5.tar.xz
yuzu-a6b88e85bfb14c45345f6443b54d15a61e3975d5.zip
Renderer: Implement Bicubic and ScaleForce filters.
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_blit_screen.cpp123
-rw-r--r--src/video_core/renderer_vulkan/vk_blit_screen.h8
2 files changed, 121 insertions, 10 deletions
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp
index 7051e6559..19d91ecfc 100644
--- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp
+++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp
@@ -12,11 +12,14 @@
12#include "common/assert.h" 12#include "common/assert.h"
13#include "common/common_types.h" 13#include "common/common_types.h"
14#include "common/math_util.h" 14#include "common/math_util.h"
15#include "common/settings.h"
15#include "core/core.h" 16#include "core/core.h"
16#include "core/frontend/emu_window.h" 17#include "core/frontend/emu_window.h"
17#include "core/memory.h" 18#include "core/memory.h"
18#include "video_core/gpu.h" 19#include "video_core/gpu.h"
20#include "video_core/host_shaders/vulkan_present_bicubic_frag_spv.h"
19#include "video_core/host_shaders/vulkan_present_frag_spv.h" 21#include "video_core/host_shaders/vulkan_present_frag_spv.h"
22#include "video_core/host_shaders/vulkan_present_scaleforce_frag_spv.h"
20#include "video_core/host_shaders/vulkan_present_vert_spv.h" 23#include "video_core/host_shaders/vulkan_present_vert_spv.h"
21#include "video_core/renderer_vulkan/renderer_vulkan.h" 24#include "video_core/renderer_vulkan/renderer_vulkan.h"
22#include "video_core/renderer_vulkan/vk_blit_screen.h" 25#include "video_core/renderer_vulkan/vk_blit_screen.h"
@@ -258,8 +261,22 @@ VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer,
258 .offset = {0, 0}, 261 .offset = {0, 0},
259 .extent = size, 262 .extent = size,
260 }; 263 };
264 const auto filter = Settings::values.scaling_filter.GetValue();
261 cmdbuf.BeginRenderPass(renderpass_bi, VK_SUBPASS_CONTENTS_INLINE); 265 cmdbuf.BeginRenderPass(renderpass_bi, VK_SUBPASS_CONTENTS_INLINE);
262 cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *pipeline); 266 switch (filter) {
267 case Settings::ScalingFilter::Bilinear:
268 cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *bilinear_pipeline);
269 break;
270 case Settings::ScalingFilter::Bicubic:
271 cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *bicubic_pipeline);
272 break;
273 case Settings::ScalingFilter::ScaleForce:
274 cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *scaleforce_pipeline);
275 break;
276 default:
277 cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *bilinear_pipeline);
278 break;
279 }
263 cmdbuf.SetViewport(0, viewport); 280 cmdbuf.SetViewport(0, viewport);
264 cmdbuf.SetScissor(0, scissor); 281 cmdbuf.SetScissor(0, scissor);
265 282
@@ -324,7 +341,9 @@ void VKBlitScreen::RefreshResources(const Tegra::FramebufferConfig& framebuffer)
324 341
325void VKBlitScreen::CreateShaders() { 342void VKBlitScreen::CreateShaders() {
326 vertex_shader = BuildShader(device, VULKAN_PRESENT_VERT_SPV); 343 vertex_shader = BuildShader(device, VULKAN_PRESENT_VERT_SPV);
327 fragment_shader = BuildShader(device, VULKAN_PRESENT_FRAG_SPV); 344 bilinear_fragment_shader = BuildShader(device, VULKAN_PRESENT_FRAG_SPV);
345 bicubic_fragment_shader = BuildShader(device, VULKAN_PRESENT_BICUBIC_FRAG_SPV);
346 scaleforce_fragment_shader = BuildShader(device, VULKAN_PRESENT_SCALEFORCE_FRAG_SPV);
328} 347}
329 348
330void VKBlitScreen::CreateSemaphores() { 349void VKBlitScreen::CreateSemaphores() {
@@ -468,7 +487,7 @@ void VKBlitScreen::CreatePipelineLayout() {
468} 487}
469 488
470void VKBlitScreen::CreateGraphicsPipeline() { 489void VKBlitScreen::CreateGraphicsPipeline() {
471 const std::array<VkPipelineShaderStageCreateInfo, 2> shader_stages{{ 490 const std::array<VkPipelineShaderStageCreateInfo, 2> bilinear_shader_stages{{
472 { 491 {
473 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, 492 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
474 .pNext = nullptr, 493 .pNext = nullptr,
@@ -483,7 +502,49 @@ void VKBlitScreen::CreateGraphicsPipeline() {
483 .pNext = nullptr, 502 .pNext = nullptr,
484 .flags = 0, 503 .flags = 0,
485 .stage = VK_SHADER_STAGE_FRAGMENT_BIT, 504 .stage = VK_SHADER_STAGE_FRAGMENT_BIT,
486 .module = *fragment_shader, 505 .module = *bilinear_fragment_shader,
506 .pName = "main",
507 .pSpecializationInfo = nullptr,
508 },
509 }};
510
511 const std::array<VkPipelineShaderStageCreateInfo, 2> bicubic_shader_stages{{
512 {
513 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
514 .pNext = nullptr,
515 .flags = 0,
516 .stage = VK_SHADER_STAGE_VERTEX_BIT,
517 .module = *vertex_shader,
518 .pName = "main",
519 .pSpecializationInfo = nullptr,
520 },
521 {
522 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
523 .pNext = nullptr,
524 .flags = 0,
525 .stage = VK_SHADER_STAGE_FRAGMENT_BIT,
526 .module = *bicubic_fragment_shader,
527 .pName = "main",
528 .pSpecializationInfo = nullptr,
529 },
530 }};
531
532 const std::array<VkPipelineShaderStageCreateInfo, 2> scaleforce_shader_stages{{
533 {
534 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
535 .pNext = nullptr,
536 .flags = 0,
537 .stage = VK_SHADER_STAGE_VERTEX_BIT,
538 .module = *vertex_shader,
539 .pName = "main",
540 .pSpecializationInfo = nullptr,
541 },
542 {
543 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
544 .pNext = nullptr,
545 .flags = 0,
546 .stage = VK_SHADER_STAGE_FRAGMENT_BIT,
547 .module = *scaleforce_fragment_shader,
487 .pName = "main", 548 .pName = "main",
488 .pSpecializationInfo = nullptr, 549 .pSpecializationInfo = nullptr,
489 }, 550 },
@@ -583,12 +644,56 @@ void VKBlitScreen::CreateGraphicsPipeline() {
583 .pDynamicStates = dynamic_states.data(), 644 .pDynamicStates = dynamic_states.data(),
584 }; 645 };
585 646
586 const VkGraphicsPipelineCreateInfo pipeline_ci{ 647 const VkGraphicsPipelineCreateInfo bilinear_pipeline_ci{
648 .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
649 .pNext = nullptr,
650 .flags = 0,
651 .stageCount = static_cast<u32>(bilinear_shader_stages.size()),
652 .pStages = bilinear_shader_stages.data(),
653 .pVertexInputState = &vertex_input_ci,
654 .pInputAssemblyState = &input_assembly_ci,
655 .pTessellationState = nullptr,
656 .pViewportState = &viewport_state_ci,
657 .pRasterizationState = &rasterization_ci,
658 .pMultisampleState = &multisampling_ci,
659 .pDepthStencilState = nullptr,
660 .pColorBlendState = &color_blend_ci,
661 .pDynamicState = &dynamic_state_ci,
662 .layout = *pipeline_layout,
663 .renderPass = *renderpass,
664 .subpass = 0,
665 .basePipelineHandle = 0,
666 .basePipelineIndex = 0,
667 };
668
669 const VkGraphicsPipelineCreateInfo bicubic_pipeline_ci{
670 .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
671 .pNext = nullptr,
672 .flags = 0,
673 .stageCount = static_cast<u32>(bicubic_shader_stages.size()),
674 .pStages = bicubic_shader_stages.data(),
675 .pVertexInputState = &vertex_input_ci,
676 .pInputAssemblyState = &input_assembly_ci,
677 .pTessellationState = nullptr,
678 .pViewportState = &viewport_state_ci,
679 .pRasterizationState = &rasterization_ci,
680 .pMultisampleState = &multisampling_ci,
681 .pDepthStencilState = nullptr,
682 .pColorBlendState = &color_blend_ci,
683 .pDynamicState = &dynamic_state_ci,
684 .layout = *pipeline_layout,
685 .renderPass = *renderpass,
686 .subpass = 0,
687 .basePipelineHandle = 0,
688 .basePipelineIndex = 0,
689 };
690
691 const VkGraphicsPipelineCreateInfo scaleforce_pipeline_ci{
587 .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, 692 .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
588 .pNext = nullptr, 693 .pNext = nullptr,
589 .flags = 0, 694 .flags = 0,
590 .stageCount = static_cast<u32>(shader_stages.size()), 695 .stageCount = static_cast<u32>(scaleforce_shader_stages.size()),
591 .pStages = shader_stages.data(), 696 .pStages = scaleforce_shader_stages.data(),
592 .pVertexInputState = &vertex_input_ci, 697 .pVertexInputState = &vertex_input_ci,
593 .pInputAssemblyState = &input_assembly_ci, 698 .pInputAssemblyState = &input_assembly_ci,
594 .pTessellationState = nullptr, 699 .pTessellationState = nullptr,
@@ -605,7 +710,9 @@ void VKBlitScreen::CreateGraphicsPipeline() {
605 .basePipelineIndex = 0, 710 .basePipelineIndex = 0,
606 }; 711 };
607 712
608 pipeline = device.GetLogical().CreateGraphicsPipeline(pipeline_ci); 713 bilinear_pipeline = device.GetLogical().CreateGraphicsPipeline(bilinear_pipeline_ci);
714 bicubic_pipeline = device.GetLogical().CreateGraphicsPipeline(bicubic_pipeline_ci);
715 scaleforce_pipeline = device.GetLogical().CreateGraphicsPipeline(scaleforce_pipeline_ci);
609} 716}
610 717
611void VKBlitScreen::CreateSampler() { 718void VKBlitScreen::CreateSampler() {
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.h b/src/video_core/renderer_vulkan/vk_blit_screen.h
index 430bcfbca..d3a16f0ba 100644
--- a/src/video_core/renderer_vulkan/vk_blit_screen.h
+++ b/src/video_core/renderer_vulkan/vk_blit_screen.h
@@ -107,11 +107,15 @@ private:
107 const VKScreenInfo& screen_info; 107 const VKScreenInfo& screen_info;
108 108
109 vk::ShaderModule vertex_shader; 109 vk::ShaderModule vertex_shader;
110 vk::ShaderModule fragment_shader; 110 vk::ShaderModule bilinear_fragment_shader;
111 vk::ShaderModule bicubic_fragment_shader;
112 vk::ShaderModule scaleforce_fragment_shader;
111 vk::DescriptorPool descriptor_pool; 113 vk::DescriptorPool descriptor_pool;
112 vk::DescriptorSetLayout descriptor_set_layout; 114 vk::DescriptorSetLayout descriptor_set_layout;
113 vk::PipelineLayout pipeline_layout; 115 vk::PipelineLayout pipeline_layout;
114 vk::Pipeline pipeline; 116 vk::Pipeline bilinear_pipeline;
117 vk::Pipeline bicubic_pipeline;
118 vk::Pipeline scaleforce_pipeline;
115 vk::RenderPass renderpass; 119 vk::RenderPass renderpass;
116 std::vector<vk::Framebuffer> framebuffers; 120 std::vector<vk::Framebuffer> framebuffers;
117 vk::DescriptorSets descriptor_sets; 121 vk::DescriptorSets descriptor_sets;