2020-12-30 06:25:23 +01:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "video_core/engines/fermi_2d.h"
|
|
|
|
#include "video_core/renderer_vulkan/vk_descriptor_pool.h"
|
|
|
|
#include "video_core/texture_cache/types.h"
|
2020-12-25 01:30:11 +01:00
|
|
|
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
2020-12-30 06:25:23 +01:00
|
|
|
|
|
|
|
namespace Vulkan {
|
|
|
|
|
2021-05-08 04:14:21 +02:00
|
|
|
using VideoCommon::Region2D;
|
2020-12-30 06:25:23 +01:00
|
|
|
|
2020-12-26 05:10:53 +01:00
|
|
|
class Device;
|
2020-12-30 06:25:23 +01:00
|
|
|
class Framebuffer;
|
|
|
|
class ImageView;
|
2020-12-26 05:10:53 +01:00
|
|
|
class StateTracker;
|
|
|
|
class VKScheduler;
|
2020-12-30 06:25:23 +01:00
|
|
|
|
|
|
|
struct BlitImagePipelineKey {
|
|
|
|
constexpr auto operator<=>(const BlitImagePipelineKey&) const noexcept = default;
|
|
|
|
|
|
|
|
VkRenderPass renderpass;
|
|
|
|
Tegra::Engines::Fermi2D::Operation operation;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BlitImageHelper {
|
|
|
|
public:
|
2020-12-26 05:10:53 +01:00
|
|
|
explicit BlitImageHelper(const Device& device, VKScheduler& scheduler,
|
2021-04-25 05:15:32 +02:00
|
|
|
StateTracker& state_tracker, DescriptorPool& descriptor_pool);
|
2020-12-30 06:25:23 +01:00
|
|
|
~BlitImageHelper();
|
|
|
|
|
2021-10-14 05:53:59 +02:00
|
|
|
void BlitColor(const Framebuffer* dst_framebuffer, VkImageView src_image_view,
|
2021-05-08 04:14:21 +02:00
|
|
|
const Region2D& dst_region, const Region2D& src_region,
|
2020-12-30 06:25:23 +01:00
|
|
|
Tegra::Engines::Fermi2D::Filter filter,
|
|
|
|
Tegra::Engines::Fermi2D::Operation operation);
|
|
|
|
|
|
|
|
void BlitDepthStencil(const Framebuffer* dst_framebuffer, VkImageView src_depth_view,
|
2021-05-08 04:14:21 +02:00
|
|
|
VkImageView src_stencil_view, const Region2D& dst_region,
|
|
|
|
const Region2D& src_region, Tegra::Engines::Fermi2D::Filter filter,
|
2020-12-30 06:25:23 +01:00
|
|
|
Tegra::Engines::Fermi2D::Operation operation);
|
|
|
|
|
2021-11-21 07:53:16 +01:00
|
|
|
void ConvertD32ToR32(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
2020-12-30 06:25:23 +01:00
|
|
|
|
2021-11-21 07:53:16 +01:00
|
|
|
void ConvertR32ToD32(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
2020-12-30 06:25:23 +01:00
|
|
|
|
2021-11-21 07:53:16 +01:00
|
|
|
void ConvertD16ToR16(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
2020-12-30 06:25:23 +01:00
|
|
|
|
2021-11-21 07:53:16 +01:00
|
|
|
void ConvertR16ToD16(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
2020-12-30 06:25:23 +01:00
|
|
|
|
2021-11-21 07:53:16 +01:00
|
|
|
void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);
|
2021-11-19 03:17:02 +01:00
|
|
|
|
2021-11-21 07:53:16 +01:00
|
|
|
void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view);
|
2021-11-19 03:17:02 +01:00
|
|
|
|
2022-03-15 23:38:53 +01:00
|
|
|
void ConvertS8D24ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view);
|
|
|
|
|
2020-12-30 06:25:23 +01:00
|
|
|
private:
|
|
|
|
void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
|
2021-11-21 07:53:16 +01:00
|
|
|
const ImageView& src_image_view);
|
2020-12-30 06:25:23 +01:00
|
|
|
|
2021-11-19 03:17:02 +01:00
|
|
|
void ConvertDepthStencil(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
|
2021-11-21 07:53:16 +01:00
|
|
|
ImageView& src_image_view);
|
2021-11-19 03:17:02 +01:00
|
|
|
|
2021-10-17 20:08:39 +02:00
|
|
|
[[nodiscard]] VkPipeline FindOrEmplaceColorPipeline(const BlitImagePipelineKey& key);
|
2020-12-30 06:25:23 +01:00
|
|
|
|
2021-10-17 20:08:39 +02:00
|
|
|
[[nodiscard]] VkPipeline FindOrEmplaceDepthStencilPipeline(const BlitImagePipelineKey& key);
|
2020-12-30 06:25:23 +01:00
|
|
|
|
2021-11-21 06:57:04 +01:00
|
|
|
void ConvertPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass, bool is_target_depth);
|
|
|
|
|
2020-12-30 06:25:23 +01:00
|
|
|
void ConvertDepthToColorPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass);
|
|
|
|
|
|
|
|
void ConvertColorToDepthPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass);
|
|
|
|
|
2021-11-21 06:50:46 +01:00
|
|
|
void ConvertPipelineEx(vk::Pipeline& pipeline, VkRenderPass renderpass,
|
|
|
|
vk::ShaderModule& module, bool single_texture, bool is_target_depth);
|
|
|
|
|
2021-11-19 23:22:44 +01:00
|
|
|
void ConvertPipelineColorTargetEx(vk::Pipeline& pipeline, VkRenderPass renderpass,
|
2021-11-21 06:50:46 +01:00
|
|
|
vk::ShaderModule& module);
|
2021-11-19 23:22:44 +01:00
|
|
|
|
|
|
|
void ConvertPipelineDepthTargetEx(vk::Pipeline& pipeline, VkRenderPass renderpass,
|
2021-11-21 06:50:46 +01:00
|
|
|
vk::ShaderModule& module);
|
2021-11-19 03:17:02 +01:00
|
|
|
|
2020-12-26 05:10:53 +01:00
|
|
|
const Device& device;
|
2020-12-30 06:25:23 +01:00
|
|
|
VKScheduler& scheduler;
|
|
|
|
StateTracker& state_tracker;
|
|
|
|
|
|
|
|
vk::DescriptorSetLayout one_texture_set_layout;
|
|
|
|
vk::DescriptorSetLayout two_textures_set_layout;
|
|
|
|
DescriptorAllocator one_texture_descriptor_allocator;
|
|
|
|
DescriptorAllocator two_textures_descriptor_allocator;
|
|
|
|
vk::PipelineLayout one_texture_pipeline_layout;
|
|
|
|
vk::PipelineLayout two_textures_pipeline_layout;
|
|
|
|
vk::ShaderModule full_screen_vert;
|
|
|
|
vk::ShaderModule blit_color_to_color_frag;
|
|
|
|
vk::ShaderModule blit_depth_stencil_frag;
|
|
|
|
vk::ShaderModule convert_depth_to_float_frag;
|
|
|
|
vk::ShaderModule convert_float_to_depth_frag;
|
2021-11-19 03:17:02 +01:00
|
|
|
vk::ShaderModule convert_abgr8_to_d24s8_frag;
|
|
|
|
vk::ShaderModule convert_d24s8_to_abgr8_frag;
|
2022-03-15 23:38:53 +01:00
|
|
|
vk::ShaderModule convert_s8d24_to_abgr8_frag;
|
2020-12-30 06:25:23 +01:00
|
|
|
vk::Sampler linear_sampler;
|
|
|
|
vk::Sampler nearest_sampler;
|
|
|
|
|
|
|
|
std::vector<BlitImagePipelineKey> blit_color_keys;
|
|
|
|
std::vector<vk::Pipeline> blit_color_pipelines;
|
2021-10-17 20:08:39 +02:00
|
|
|
std::vector<BlitImagePipelineKey> blit_depth_stencil_keys;
|
|
|
|
std::vector<vk::Pipeline> blit_depth_stencil_pipelines;
|
2020-12-30 06:25:23 +01:00
|
|
|
vk::Pipeline convert_d32_to_r32_pipeline;
|
|
|
|
vk::Pipeline convert_r32_to_d32_pipeline;
|
|
|
|
vk::Pipeline convert_d16_to_r16_pipeline;
|
|
|
|
vk::Pipeline convert_r16_to_d16_pipeline;
|
2021-11-19 03:17:02 +01:00
|
|
|
vk::Pipeline convert_abgr8_to_d24s8_pipeline;
|
|
|
|
vk::Pipeline convert_d24s8_to_abgr8_pipeline;
|
2022-03-15 23:38:53 +01:00
|
|
|
vk::Pipeline convert_s8d24_to_abgr8_pipeline;
|
2020-12-30 06:25:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Vulkan
|