Presentation: Only use FP16 in scaling shaders on supported devices in Vulkan
This commit is contained in:
parent
a39e867c73
commit
dcc5b4f6b0
15 changed files with 199 additions and 115 deletions
|
@ -21,8 +21,9 @@
|
|||
#include "video_core/host_shaders/fxaa_vert_spv.h"
|
||||
#include "video_core/host_shaders/present_bicubic_frag_spv.h"
|
||||
#include "video_core/host_shaders/present_gaussian_frag_spv.h"
|
||||
#include "video_core/host_shaders/present_scaleforce_frag_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_present_frag_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_present_scaleforce_fp16_frag_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_present_scaleforce_fp32_frag_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_present_vert_spv.h"
|
||||
#include "video_core/renderer_vulkan/renderer_vulkan.h"
|
||||
#include "video_core/renderer_vulkan/vk_blit_screen.h"
|
||||
|
@ -328,7 +329,7 @@ VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer,
|
|||
blit_read_barrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
blit_read_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
||||
|
||||
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT ,
|
||||
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, blit_read_barrier);
|
||||
}
|
||||
});
|
||||
|
@ -344,8 +345,12 @@ VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer,
|
|||
crop_rect.bottom = framebuffer.height;
|
||||
}
|
||||
crop_rect = crop_rect.Scale(Settings::values.resolution_info.up_factor);
|
||||
VkExtent2D fsr_input_size{
|
||||
.width = Settings::values.resolution_info.ScaleUp(framebuffer.width),
|
||||
.height = Settings::values.resolution_info.ScaleUp(framebuffer.height),
|
||||
};
|
||||
VkImageView fsr_image_view =
|
||||
fsr->Draw(scheduler, image_index, source_image_view, crop_rect);
|
||||
fsr->Draw(scheduler, image_index, source_image_view, fsr_input_size, crop_rect);
|
||||
UpdateDescriptorSet(image_index, fsr_image_view, true);
|
||||
} else {
|
||||
const bool is_nn =
|
||||
|
@ -500,7 +505,11 @@ void VKBlitScreen::CreateShaders() {
|
|||
bilinear_fragment_shader = BuildShader(device, VULKAN_PRESENT_FRAG_SPV);
|
||||
bicubic_fragment_shader = BuildShader(device, PRESENT_BICUBIC_FRAG_SPV);
|
||||
gaussian_fragment_shader = BuildShader(device, PRESENT_GAUSSIAN_FRAG_SPV);
|
||||
scaleforce_fragment_shader = BuildShader(device, PRESENT_SCALEFORCE_FRAG_SPV);
|
||||
if (device.IsFloat16Supported()) {
|
||||
scaleforce_fragment_shader = BuildShader(device, VULKAN_PRESENT_SCALEFORCE_FP16_FRAG_SPV);
|
||||
} else {
|
||||
scaleforce_fragment_shader = BuildShader(device, VULKAN_PRESENT_SCALEFORCE_FP32_FRAG_SPV);
|
||||
}
|
||||
}
|
||||
|
||||
void VKBlitScreen::CreateSemaphores() {
|
||||
|
|
|
@ -4,13 +4,19 @@
|
|||
|
||||
#include "common/common_types.h"
|
||||
#include "common/div_ceil.h"
|
||||
#include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_comp_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_comp_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16_comp_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32_comp_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16_comp_spv.h"
|
||||
#include "video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp32_comp_spv.h"
|
||||
#include "video_core/renderer_vulkan/vk_fsr.h"
|
||||
#include "video_core/renderer_vulkan/vk_scheduler.h"
|
||||
#include "video_core/renderer_vulkan/vk_shader_util.h"
|
||||
#include "video_core/vulkan_common/vulkan_device.h"
|
||||
|
||||
#define A_CPU
|
||||
#include <ffx_a.h>
|
||||
#include <ffx_fsr1.h>
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
FSR::FSR(const Device& device_, MemoryAllocator& memory_allocator_, size_t image_count_,
|
||||
|
@ -29,11 +35,11 @@ FSR::FSR(const Device& device_, MemoryAllocator& memory_allocator_, size_t image
|
|||
}
|
||||
|
||||
VkImageView FSR::Draw(VKScheduler& scheduler, size_t image_index, VkImageView image_view,
|
||||
const Common::Rectangle<int>& crop_rect) {
|
||||
VkExtent2D input_image_extent, const Common::Rectangle<int>& crop_rect) {
|
||||
|
||||
UpdateDescriptorSet(image_index, image_view);
|
||||
|
||||
scheduler.Record([this, image_index, crop_rect](vk::CommandBuffer cmdbuf) {
|
||||
scheduler.Record([this, image_index, input_image_extent, crop_rect](vk::CommandBuffer cmdbuf) {
|
||||
const VkImageMemoryBarrier base_barrier{
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
.pNext = nullptr,
|
||||
|
@ -54,13 +60,18 @@ VkImageView FSR::Draw(VKScheduler& scheduler, size_t image_index, VkImageView im
|
|||
},
|
||||
};
|
||||
|
||||
// TODO: Support clear color
|
||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE, *easu_pipeline);
|
||||
cmdbuf.PushConstants(*pipeline_layout, VK_SHADER_STAGE_COMPUTE_BIT,
|
||||
VkExtent2D{
|
||||
.width = static_cast<u32>(crop_rect.GetWidth()),
|
||||
.height = static_cast<u32>(crop_rect.GetHeight()),
|
||||
});
|
||||
|
||||
std::array<AU1, 4 * 4> push_constants;
|
||||
FsrEasuConOffset(
|
||||
push_constants.data() + 0, push_constants.data() + 4, push_constants.data() + 8,
|
||||
push_constants.data() + 12,
|
||||
|
||||
static_cast<AF1>(crop_rect.GetWidth()), static_cast<AF1>(crop_rect.GetHeight()),
|
||||
static_cast<AF1>(input_image_extent.width), static_cast<AF1>(input_image_extent.height),
|
||||
static_cast<AF1>(output_size.width), static_cast<AF1>(output_size.height),
|
||||
static_cast<AF1>(crop_rect.left), static_cast<AF1>(crop_rect.top));
|
||||
cmdbuf.PushConstants(*pipeline_layout, VK_SHADER_STAGE_COMPUTE_BIT, push_constants);
|
||||
|
||||
{
|
||||
VkImageMemoryBarrier fsr_write_barrier = base_barrier;
|
||||
|
@ -77,7 +88,9 @@ VkImageView FSR::Draw(VKScheduler& scheduler, size_t image_index, VkImageView im
|
|||
Common::DivCeil(output_size.height, 16u), 1);
|
||||
|
||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE, *rcas_pipeline);
|
||||
cmdbuf.PushConstants(*pipeline_layout, VK_SHADER_STAGE_COMPUTE_BIT, output_size);
|
||||
|
||||
FsrRcasCon(push_constants.data(), 0.25f);
|
||||
cmdbuf.PushConstants(*pipeline_layout, VK_SHADER_STAGE_COMPUTE_BIT, push_constants);
|
||||
|
||||
{
|
||||
std::array<VkImageMemoryBarrier, 2> barriers;
|
||||
|
@ -247,7 +260,7 @@ void FSR::CreatePipelineLayout() {
|
|||
VkPushConstantRange push_const{
|
||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||
.offset = 0,
|
||||
.size = sizeof(std::array<u32, 2>),
|
||||
.size = sizeof(std::array<u32, 4 * 4>),
|
||||
};
|
||||
VkPipelineLayoutCreateInfo ci{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
|
@ -344,8 +357,13 @@ void FSR::CreateSampler() {
|
|||
}
|
||||
|
||||
void FSR::CreateShaders() {
|
||||
easu_shader = BuildShader(device, VULKAN_FIDELITYFX_FSR_EASU_COMP_SPV);
|
||||
rcas_shader = BuildShader(device, VULKAN_FIDELITYFX_FSR_RCAS_COMP_SPV);
|
||||
if (device.IsFloat16Supported()) {
|
||||
easu_shader = BuildShader(device, VULKAN_FIDELITYFX_FSR_EASU_FP16_COMP_SPV);
|
||||
rcas_shader = BuildShader(device, VULKAN_FIDELITYFX_FSR_RCAS_FP16_COMP_SPV);
|
||||
} else {
|
||||
easu_shader = BuildShader(device, VULKAN_FIDELITYFX_FSR_EASU_FP32_COMP_SPV);
|
||||
rcas_shader = BuildShader(device, VULKAN_FIDELITYFX_FSR_RCAS_FP32_COMP_SPV);
|
||||
}
|
||||
}
|
||||
|
||||
void FSR::CreatePipeline() {
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
explicit FSR(const Device& device, MemoryAllocator& memory_allocator, size_t image_count,
|
||||
VkExtent2D output_size);
|
||||
VkImageView Draw(VKScheduler& scheduler, size_t image_index, VkImageView image_view,
|
||||
const Common::Rectangle<int>& crop_rect);
|
||||
VkExtent2D input_image_extent, const Common::Rectangle<int>& crop_rect);
|
||||
|
||||
private:
|
||||
void CreateDescriptorPool();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue