diff options
author | Liam <byteslice@airmail.cc> | 2024-01-14 04:52:04 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2024-01-31 17:27:20 +0100 |
commit | 9568b310befe19154511afe14709188f641e4951 (patch) | |
tree | 4ed2a065b68970747f2c8280de273d280a1cd985 /src/video_core/renderer_vulkan/present/smaa.h | |
parent | renderer_opengl: isolate core presentation code (diff) | |
download | yuzu-9568b310befe19154511afe14709188f641e4951.tar yuzu-9568b310befe19154511afe14709188f641e4951.tar.gz yuzu-9568b310befe19154511afe14709188f641e4951.tar.bz2 yuzu-9568b310befe19154511afe14709188f641e4951.tar.lz yuzu-9568b310befe19154511afe14709188f641e4951.tar.xz yuzu-9568b310befe19154511afe14709188f641e4951.tar.zst yuzu-9568b310befe19154511afe14709188f641e4951.zip |
Diffstat (limited to 'src/video_core/renderer_vulkan/present/smaa.h')
-rw-r--r-- | src/video_core/renderer_vulkan/present/smaa.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/present/smaa.h b/src/video_core/renderer_vulkan/present/smaa.h new file mode 100644 index 000000000..3d6707d48 --- /dev/null +++ b/src/video_core/renderer_vulkan/present/smaa.h @@ -0,0 +1,87 @@ +// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <array> +#include "video_core/renderer_vulkan/present/anti_alias_pass.h" +#include "video_core/vulkan_common/vulkan_memory_allocator.h" +#include "video_core/vulkan_common/vulkan_wrapper.h" + +namespace Vulkan { + +class Device; +class Scheduler; +class StagingBufferPool; + +class SMAA final : public AntiAliasPass { +public: + explicit SMAA(const Device& device, MemoryAllocator& allocator, size_t image_count, + VkExtent2D extent); + ~SMAA() override; + + VkImageView Draw(Scheduler& scheduler, size_t image_index, VkImage source_image, + VkImageView source_image_view) override; + +private: + enum SMAAStage { + EdgeDetection = 0, + BlendingWeightCalculation = 1, + NeighborhoodBlending = 2, + MaxSMAAStage = 3, + }; + + enum StaticImageType { + Area = 0, + Search = 1, + MaxStaticImage = 2, + }; + + enum DynamicImageType { + Blend = 0, + Edges = 1, + Output = 2, + MaxDynamicImage = 3, + }; + + void CreateImages(); + void CreateRenderPasses(); + void CreateSampler(); + void CreateShaders(); + void CreateDescriptorPool(); + void CreateDescriptorSetLayouts(); + void CreateDescriptorSets(); + void CreatePipelineLayouts(); + void CreatePipelines(); + void UpdateDescriptorSets(VkImageView image_view, size_t image_index); + void UploadImages(Scheduler& scheduler); + + const Device& m_device; + MemoryAllocator& m_allocator; + const VkExtent2D m_extent; + const u32 m_image_count; + + vk::DescriptorPool m_descriptor_pool{}; + std::array<vk::DescriptorSetLayout, MaxSMAAStage> m_descriptor_set_layouts{}; + std::array<vk::PipelineLayout, MaxSMAAStage> m_pipeline_layouts{}; + std::array<vk::ShaderModule, MaxSMAAStage> m_vertex_shaders{}; + std::array<vk::ShaderModule, MaxSMAAStage> m_fragment_shaders{}; + std::array<vk::Pipeline, MaxSMAAStage> m_pipelines{}; + std::array<vk::RenderPass, MaxSMAAStage> m_renderpasses{}; + + std::array<vk::Image, MaxStaticImage> m_static_images{}; + std::array<vk::ImageView, MaxStaticImage> m_static_image_views{}; + + struct Images { + vk::DescriptorSets descriptor_sets{}; + std::array<vk::Image, MaxDynamicImage> images{}; + std::array<vk::ImageView, MaxDynamicImage> image_views{}; + std::array<vk::Framebuffer, MaxSMAAStage> framebuffers{}; + }; + std::vector<Images> m_dynamic_images{}; + bool m_images_ready{}; + + vk::Sampler m_sampler{}; +}; + +} // namespace Vulkan |