summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan/present
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2024-01-14 04:52:04 +0100
committerLiam <byteslice@airmail.cc>2024-01-31 17:27:20 +0100
commit9568b310befe19154511afe14709188f641e4951 (patch)
tree4ed2a065b68970747f2c8280de273d280a1cd985 /src/video_core/renderer_vulkan/present
parentrenderer_opengl: isolate core presentation code (diff)
downloadyuzu-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 '')
-rw-r--r--src/video_core/renderer_vulkan/present/anti_alias_pass.h27
-rw-r--r--src/video_core/renderer_vulkan/present/fsr.cpp (renamed from src/video_core/renderer_vulkan/vk_fsr.cpp)2
-rw-r--r--src/video_core/renderer_vulkan/present/fsr.h (renamed from src/video_core/renderer_vulkan/vk_fsr.h)0
-rw-r--r--src/video_core/renderer_vulkan/present/fxaa.cpp144
-rw-r--r--src/video_core/renderer_vulkan/present/fxaa.h63
-rw-r--r--src/video_core/renderer_vulkan/present/smaa.cpp270
-rw-r--r--src/video_core/renderer_vulkan/present/smaa.h (renamed from src/video_core/renderer_vulkan/vk_smaa.h)7
-rw-r--r--src/video_core/renderer_vulkan/present/util.cpp (renamed from src/video_core/renderer_vulkan/vk_smaa.cpp)282
-rw-r--r--src/video_core/renderer_vulkan/present/util.h46
9 files changed, 566 insertions, 275 deletions
diff --git a/src/video_core/renderer_vulkan/present/anti_alias_pass.h b/src/video_core/renderer_vulkan/present/anti_alias_pass.h
new file mode 100644
index 000000000..c1ec0b9a0
--- /dev/null
+++ b/src/video_core/renderer_vulkan/present/anti_alias_pass.h
@@ -0,0 +1,27 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "video_core/vulkan_common/vulkan_wrapper.h"
+
+namespace Vulkan {
+
+class Scheduler;
+
+class AntiAliasPass {
+public:
+ virtual ~AntiAliasPass() = default;
+ virtual VkImageView Draw(Scheduler& scheduler, size_t image_index, VkImage source_image,
+ VkImageView source_image_view) = 0;
+};
+
+class NoAA final : public AntiAliasPass {
+public:
+ virtual VkImageView Draw(Scheduler& scheduler, size_t image_index, VkImage source_image,
+ VkImageView source_image_view) {
+ return source_image_view;
+ }
+};
+
+} // namespace Vulkan
diff --git a/src/video_core/renderer_vulkan/vk_fsr.cpp b/src/video_core/renderer_vulkan/present/fsr.cpp
index f7a05fbc0..30a16a785 100644
--- a/src/video_core/renderer_vulkan/vk_fsr.cpp
+++ b/src/video_core/renderer_vulkan/present/fsr.cpp
@@ -10,7 +10,7 @@
#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/present/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"
diff --git a/src/video_core/renderer_vulkan/vk_fsr.h b/src/video_core/renderer_vulkan/present/fsr.h
index 3505c1416..3505c1416 100644
--- a/src/video_core/renderer_vulkan/vk_fsr.h
+++ b/src/video_core/renderer_vulkan/present/fsr.h
diff --git a/src/video_core/renderer_vulkan/present/fxaa.cpp b/src/video_core/renderer_vulkan/present/fxaa.cpp
new file mode 100644
index 000000000..6f87ddebb
--- /dev/null
+++ b/src/video_core/renderer_vulkan/present/fxaa.cpp
@@ -0,0 +1,144 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "common/common_types.h"
+
+#include "video_core/host_shaders/fxaa_frag_spv.h"
+#include "video_core/host_shaders/fxaa_vert_spv.h"
+#include "video_core/renderer_vulkan/present/fxaa.h"
+#include "video_core/renderer_vulkan/present/util.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"
+
+namespace Vulkan {
+
+FXAA::FXAA(const Device& device, MemoryAllocator& allocator, size_t image_count, VkExtent2D extent)
+ : m_device(device), m_allocator(allocator), m_extent(extent),
+ m_image_count(static_cast<u32>(image_count)) {
+ CreateImages();
+ CreateRenderPasses();
+ CreateSampler();
+ CreateShaders();
+ CreateDescriptorPool();
+ CreateDescriptorSetLayouts();
+ CreateDescriptorSets();
+ CreatePipelineLayouts();
+ CreatePipelines();
+}
+
+FXAA::~FXAA() = default;
+
+void FXAA::CreateImages() {
+ for (u32 i = 0; i < m_image_count; i++) {
+ Image& image = m_dynamic_images.emplace_back();
+
+ image.image = CreateWrappedImage(m_allocator, m_extent, VK_FORMAT_R16G16B16A16_SFLOAT);
+ image.image_view =
+ CreateWrappedImageView(m_device, image.image, VK_FORMAT_R16G16B16A16_SFLOAT);
+ }
+}
+
+void FXAA::CreateRenderPasses() {
+ m_renderpass = CreateWrappedRenderPass(m_device, VK_FORMAT_R16G16B16A16_SFLOAT);
+
+ for (auto& image : m_dynamic_images) {
+ image.framebuffer =
+ CreateWrappedFramebuffer(m_device, m_renderpass, image.image_view, m_extent);
+ }
+}
+
+void FXAA::CreateSampler() {
+ m_sampler = CreateWrappedSampler(m_device);
+}
+
+void FXAA::CreateShaders() {
+ m_vertex_shader = CreateWrappedShaderModule(m_device, FXAA_VERT_SPV);
+ m_fragment_shader = CreateWrappedShaderModule(m_device, FXAA_FRAG_SPV);
+}
+
+void FXAA::CreateDescriptorPool() {
+ // 2 descriptors, 1 descriptor set per image
+ m_descriptor_pool = CreateWrappedDescriptorPool(m_device, 2 * m_image_count, m_image_count);
+}
+
+void FXAA::CreateDescriptorSetLayouts() {
+ m_descriptor_set_layout = CreateWrappedDescriptorSetLayout(m_device, 2);
+}
+
+void FXAA::CreateDescriptorSets() {
+ VkDescriptorSetLayout layout = *m_descriptor_set_layout;
+
+ for (auto& images : m_dynamic_images) {
+ images.descriptor_sets = CreateWrappedDescriptorSets(m_descriptor_pool, {layout});
+ }
+}
+
+void FXAA::CreatePipelineLayouts() {
+ m_pipeline_layout = CreateWrappedPipelineLayout(m_device, m_descriptor_set_layout);
+}
+
+void FXAA::CreatePipelines() {
+ m_pipeline = CreateWrappedPipeline(m_device, m_renderpass, m_pipeline_layout,
+ std::tie(m_vertex_shader, m_fragment_shader));
+}
+
+void FXAA::UpdateDescriptorSets(VkImageView image_view, size_t image_index) {
+ Image& image = m_dynamic_images[image_index];
+ std::vector<VkDescriptorImageInfo> image_infos;
+ std::vector<VkWriteDescriptorSet> updates;
+ image_infos.reserve(2);
+
+ updates.push_back(
+ CreateWriteDescriptorSet(image_infos, *m_sampler, image_view, image.descriptor_sets[0], 0));
+ updates.push_back(
+ CreateWriteDescriptorSet(image_infos, *m_sampler, image_view, image.descriptor_sets[0], 1));
+
+ m_device.GetLogical().UpdateDescriptorSets(updates, {});
+}
+
+void FXAA::UploadImages(Scheduler& scheduler) {
+ if (m_images_ready) {
+ return;
+ }
+
+ scheduler.Record([&](vk::CommandBuffer cmdbuf) {
+ for (auto& image : m_dynamic_images) {
+ ClearColorImage(cmdbuf, *image.image);
+ }
+ });
+ scheduler.Finish();
+
+ m_images_ready = true;
+}
+
+VkImageView FXAA::Draw(Scheduler& scheduler, size_t image_index, VkImage source_image,
+ VkImageView source_image_view) {
+ const Image& image{m_dynamic_images[image_index]};
+ const VkImage output_image{*image.image};
+ const VkDescriptorSet descriptor_set{image.descriptor_sets[0]};
+ const VkFramebuffer framebuffer{*image.framebuffer};
+ const VkRenderPass renderpass{*m_renderpass};
+ const VkPipeline pipeline{*m_pipeline};
+ const VkPipelineLayout layout{*m_pipeline_layout};
+ const VkExtent2D extent{m_extent};
+
+ UploadImages(scheduler);
+ UpdateDescriptorSets(source_image_view, image_index);
+
+ scheduler.RequestOutsideRenderPassOperationContext();
+ scheduler.Record([=](vk::CommandBuffer cmdbuf) {
+ TransitionImageLayout(cmdbuf, source_image, VK_IMAGE_LAYOUT_GENERAL);
+ TransitionImageLayout(cmdbuf, output_image, VK_IMAGE_LAYOUT_GENERAL);
+ BeginRenderPass(cmdbuf, renderpass, framebuffer, extent);
+ cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
+ cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptor_set, {});
+ cmdbuf.Draw(4, 1, 0, 0);
+ cmdbuf.EndRenderPass();
+ TransitionImageLayout(cmdbuf, output_image, VK_IMAGE_LAYOUT_GENERAL);
+ });
+
+ return *image.image_view;
+}
+
+} // namespace Vulkan
diff --git a/src/video_core/renderer_vulkan/present/fxaa.h b/src/video_core/renderer_vulkan/present/fxaa.h
new file mode 100644
index 000000000..c083f3ff0
--- /dev/null
+++ b/src/video_core/renderer_vulkan/present/fxaa.h
@@ -0,0 +1,63 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#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 FXAA final : public AntiAliasPass {
+public:
+ explicit FXAA(const Device& device, MemoryAllocator& allocator, size_t image_count,
+ VkExtent2D extent);
+ ~FXAA() override;
+
+ VkImageView Draw(Scheduler& scheduler, size_t image_index, VkImage source_image,
+ VkImageView source_image_view) override;
+
+private:
+ 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::ShaderModule m_vertex_shader{};
+ vk::ShaderModule m_fragment_shader{};
+ vk::DescriptorPool m_descriptor_pool{};
+ vk::DescriptorSetLayout m_descriptor_set_layout{};
+ vk::PipelineLayout m_pipeline_layout{};
+ vk::Pipeline m_pipeline{};
+ vk::RenderPass m_renderpass{};
+
+ struct Image {
+ vk::DescriptorSets descriptor_sets{};
+ vk::Framebuffer framebuffer{};
+ vk::Image image{};
+ vk::ImageView image_view{};
+ };
+ std::vector<Image> m_dynamic_images{};
+ bool m_images_ready{};
+
+ vk::Sampler m_sampler{};
+};
+
+} // namespace Vulkan
diff --git a/src/video_core/renderer_vulkan/present/smaa.cpp b/src/video_core/renderer_vulkan/present/smaa.cpp
new file mode 100644
index 000000000..68cd22b08
--- /dev/null
+++ b/src/video_core/renderer_vulkan/present/smaa.cpp
@@ -0,0 +1,270 @@
+// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <list>
+
+#include "common/assert.h"
+#include "common/polyfill_ranges.h"
+
+#include "video_core/renderer_vulkan/present/smaa.h"
+#include "video_core/renderer_vulkan/present/util.h"
+#include "video_core/renderer_vulkan/vk_scheduler.h"
+#include "video_core/renderer_vulkan/vk_shader_util.h"
+#include "video_core/smaa_area_tex.h"
+#include "video_core/smaa_search_tex.h"
+#include "video_core/vulkan_common/vulkan_device.h"
+
+#include "video_core/host_shaders/smaa_blending_weight_calculation_frag_spv.h"
+#include "video_core/host_shaders/smaa_blending_weight_calculation_vert_spv.h"
+#include "video_core/host_shaders/smaa_edge_detection_frag_spv.h"
+#include "video_core/host_shaders/smaa_edge_detection_vert_spv.h"
+#include "video_core/host_shaders/smaa_neighborhood_blending_frag_spv.h"
+#include "video_core/host_shaders/smaa_neighborhood_blending_vert_spv.h"
+
+namespace Vulkan {
+
+SMAA::SMAA(const Device& device, MemoryAllocator& allocator, size_t image_count, VkExtent2D extent)
+ : m_device(device), m_allocator(allocator), m_extent(extent),
+ m_image_count(static_cast<u32>(image_count)) {
+ CreateImages();
+ CreateRenderPasses();
+ CreateSampler();
+ CreateShaders();
+ CreateDescriptorPool();
+ CreateDescriptorSetLayouts();
+ CreateDescriptorSets();
+ CreatePipelineLayouts();
+ CreatePipelines();
+}
+
+SMAA::~SMAA() = default;
+
+void SMAA::CreateImages() {
+ static constexpr VkExtent2D area_extent{AREATEX_WIDTH, AREATEX_HEIGHT};
+ static constexpr VkExtent2D search_extent{SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT};
+
+ m_static_images[Area] = CreateWrappedImage(m_allocator, area_extent, VK_FORMAT_R8G8_UNORM);
+ m_static_images[Search] = CreateWrappedImage(m_allocator, search_extent, VK_FORMAT_R8_UNORM);
+
+ m_static_image_views[Area] =
+ CreateWrappedImageView(m_device, m_static_images[Area], VK_FORMAT_R8G8_UNORM);
+ m_static_image_views[Search] =
+ CreateWrappedImageView(m_device, m_static_images[Search], VK_FORMAT_R8_UNORM);
+
+ for (u32 i = 0; i < m_image_count; i++) {
+ Images& images = m_dynamic_images.emplace_back();
+
+ images.images[Blend] =
+ CreateWrappedImage(m_allocator, m_extent, VK_FORMAT_R16G16B16A16_SFLOAT);
+ images.images[Edges] = CreateWrappedImage(m_allocator, m_extent, VK_FORMAT_R16G16_SFLOAT);
+ images.images[Output] =
+ CreateWrappedImage(m_allocator, m_extent, VK_FORMAT_R16G16B16A16_SFLOAT);
+
+ images.image_views[Blend] =
+ CreateWrappedImageView(m_device, images.images[Blend], VK_FORMAT_R16G16B16A16_SFLOAT);
+ images.image_views[Edges] =
+ CreateWrappedImageView(m_device, images.images[Edges], VK_FORMAT_R16G16_SFLOAT);
+ images.image_views[Output] =
+ CreateWrappedImageView(m_device, images.images[Output], VK_FORMAT_R16G16B16A16_SFLOAT);
+ }
+}
+
+void SMAA::CreateRenderPasses() {
+ m_renderpasses[EdgeDetection] = CreateWrappedRenderPass(m_device, VK_FORMAT_R16G16_SFLOAT);
+ m_renderpasses[BlendingWeightCalculation] =
+ CreateWrappedRenderPass(m_device, VK_FORMAT_R16G16B16A16_SFLOAT);
+ m_renderpasses[NeighborhoodBlending] =
+ CreateWrappedRenderPass(m_device, VK_FORMAT_R16G16B16A16_SFLOAT);
+
+ for (auto& images : m_dynamic_images) {
+ images.framebuffers[EdgeDetection] = CreateWrappedFramebuffer(
+ m_device, m_renderpasses[EdgeDetection], images.image_views[Edges], m_extent);
+
+ images.framebuffers[BlendingWeightCalculation] =
+ CreateWrappedFramebuffer(m_device, m_renderpasses[BlendingWeightCalculation],
+ images.image_views[Blend], m_extent);
+
+ images.framebuffers[NeighborhoodBlending] = CreateWrappedFramebuffer(
+ m_device, m_renderpasses[NeighborhoodBlending], images.image_views[Output], m_extent);
+ }
+}
+
+void SMAA::CreateSampler() {
+ m_sampler = CreateWrappedSampler(m_device);
+}
+
+void SMAA::CreateShaders() {
+ // These match the order of the SMAAStage enum
+ static constexpr std::array vert_shader_sources{
+ ARRAY_TO_SPAN(SMAA_EDGE_DETECTION_VERT_SPV),
+ ARRAY_TO_SPAN(SMAA_BLENDING_WEIGHT_CALCULATION_VERT_SPV),
+ ARRAY_TO_SPAN(SMAA_NEIGHBORHOOD_BLENDING_VERT_SPV),
+ };
+ static constexpr std::array frag_shader_sources{
+ ARRAY_TO_SPAN(SMAA_EDGE_DETECTION_FRAG_SPV),
+ ARRAY_TO_SPAN(SMAA_BLENDING_WEIGHT_CALCULATION_FRAG_SPV),
+ ARRAY_TO_SPAN(SMAA_NEIGHBORHOOD_BLENDING_FRAG_SPV),
+ };
+
+ for (size_t i = 0; i < MaxSMAAStage; i++) {
+ m_vertex_shaders[i] = CreateWrappedShaderModule(m_device, vert_shader_sources[i]);
+ m_fragment_shaders[i] = CreateWrappedShaderModule(m_device, frag_shader_sources[i]);
+ }
+}
+
+void SMAA::CreateDescriptorPool() {
+ // Edge detection: 1 descriptor
+ // Blending weight calculation: 3 descriptors
+ // Neighborhood blending: 2 descriptors
+
+ // 6 descriptors, 3 descriptor sets per image
+ m_descriptor_pool = CreateWrappedDescriptorPool(m_device, 6 * m_image_count, 3 * m_image_count);
+}
+
+void SMAA::CreateDescriptorSetLayouts() {
+ m_descriptor_set_layouts[EdgeDetection] = CreateWrappedDescriptorSetLayout(m_device, 1);
+ m_descriptor_set_layouts[BlendingWeightCalculation] =
+ CreateWrappedDescriptorSetLayout(m_device, 3);
+ m_descriptor_set_layouts[NeighborhoodBlending] = CreateWrappedDescriptorSetLayout(m_device, 2);
+}
+
+void SMAA::CreateDescriptorSets() {
+ std::vector<VkDescriptorSetLayout> layouts(m_descriptor_set_layouts.size());
+ std::ranges::transform(m_descriptor_set_layouts, layouts.begin(),
+ [](auto& layout) { return *layout; });
+
+ for (auto& images : m_dynamic_images) {
+ images.descriptor_sets = CreateWrappedDescriptorSets(m_descriptor_pool, layouts);
+ }
+}
+
+void SMAA::CreatePipelineLayouts() {
+ for (size_t i = 0; i < MaxSMAAStage; i++) {
+ m_pipeline_layouts[i] = CreateWrappedPipelineLayout(m_device, m_descriptor_set_layouts[i]);
+ }
+}
+
+void SMAA::CreatePipelines() {
+ for (size_t i = 0; i < MaxSMAAStage; i++) {
+ m_pipelines[i] =
+ CreateWrappedPipeline(m_device, m_renderpasses[i], m_pipeline_layouts[i],
+ std::tie(m_vertex_shaders[i], m_fragment_shaders[i]));
+ }
+}
+
+void SMAA::UpdateDescriptorSets(VkImageView image_view, size_t image_index) {
+ Images& images = m_dynamic_images[image_index];
+ std::vector<VkDescriptorImageInfo> image_infos;
+ std::vector<VkWriteDescriptorSet> updates;
+ image_infos.reserve(6);
+
+ updates.push_back(CreateWriteDescriptorSet(image_infos, *m_sampler, image_view,
+ images.descriptor_sets[EdgeDetection], 0));
+
+ updates.push_back(CreateWriteDescriptorSet(image_infos, *m_sampler, *images.image_views[Edges],
+ images.descriptor_sets[BlendingWeightCalculation],
+ 0));
+ updates.push_back(CreateWriteDescriptorSet(image_infos, *m_sampler, *m_static_image_views[Area],
+ images.descriptor_sets[BlendingWeightCalculation],
+ 1));
+ updates.push_back(
+ CreateWriteDescriptorSet(image_infos, *m_sampler, *m_static_image_views[Search],
+ images.descriptor_sets[BlendingWeightCalculation], 2));
+
+ updates.push_back(CreateWriteDescriptorSet(image_infos, *m_sampler, image_view,
+ images.descriptor_sets[NeighborhoodBlending], 0));
+ updates.push_back(CreateWriteDescriptorSet(image_infos, *m_sampler, *images.image_views[Blend],
+ images.descriptor_sets[NeighborhoodBlending], 1));
+
+ m_device.GetLogical().UpdateDescriptorSets(updates, {});
+}
+
+void SMAA::UploadImages(Scheduler& scheduler) {
+ if (m_images_ready) {
+ return;
+ }
+
+ static constexpr VkExtent2D area_extent{AREATEX_WIDTH, AREATEX_HEIGHT};
+ static constexpr VkExtent2D search_extent{SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT};
+
+ UploadImage(m_device, m_allocator, scheduler, m_static_images[Area], area_extent,
+ VK_FORMAT_R8G8_UNORM, ARRAY_TO_SPAN(areaTexBytes));
+ UploadImage(m_device, m_allocator, scheduler, m_static_images[Search], search_extent,
+ VK_FORMAT_R8_UNORM, ARRAY_TO_SPAN(searchTexBytes));
+
+ scheduler.Record([&](vk::CommandBuffer cmdbuf) {
+ for (auto& images : m_dynamic_images) {
+ for (size_t i = 0; i < MaxDynamicImage; i++) {
+ ClearColorImage(cmdbuf, *images.images[i]);
+ }
+ }
+ });
+ scheduler.Finish();
+
+ m_images_ready = true;
+}
+
+VkImageView SMAA::Draw(Scheduler& scheduler, size_t image_index, VkImage source_image,
+ VkImageView source_image_view) {
+ Images& images = m_dynamic_images[image_index];
+
+ VkImage output_image = *images.images[Output];
+ VkImage edges_image = *images.images[Edges];
+ VkImage blend_image = *images.images[Blend];
+
+ VkDescriptorSet edge_detection_descriptor_set = images.descriptor_sets[EdgeDetection];
+ VkDescriptorSet blending_weight_calculation_descriptor_set =
+ images.descriptor_sets[BlendingWeightCalculation];
+ VkDescriptorSet neighborhood_blending_descriptor_set =
+ images.descriptor_sets[NeighborhoodBlending];
+
+ VkFramebuffer edge_detection_framebuffer = *images.framebuffers[EdgeDetection];
+ VkFramebuffer blending_weight_calculation_framebuffer =
+ *images.framebuffers[BlendingWeightCalculation];
+ VkFramebuffer neighborhood_blending_framebuffer = *images.framebuffers[NeighborhoodBlending];
+
+ UploadImages(scheduler);
+ UpdateDescriptorSets(source_image_view, image_index);
+
+ scheduler.RequestOutsideRenderPassOperationContext();
+ scheduler.Record([=, this](vk::CommandBuffer cmdbuf) {
+ TransitionImageLayout(cmdbuf, source_image, VK_IMAGE_LAYOUT_GENERAL);
+ TransitionImageLayout(cmdbuf, edges_image, VK_IMAGE_LAYOUT_GENERAL);
+ BeginRenderPass(cmdbuf, *m_renderpasses[EdgeDetection], edge_detection_framebuffer,
+ m_extent);
+ cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelines[EdgeDetection]);
+ cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS,
+ *m_pipeline_layouts[EdgeDetection], 0,
+ edge_detection_descriptor_set, {});
+ cmdbuf.Draw(3, 1, 0, 0);
+ cmdbuf.EndRenderPass();
+
+ TransitionImageLayout(cmdbuf, edges_image, VK_IMAGE_LAYOUT_GENERAL);
+ TransitionImageLayout(cmdbuf, blend_image, VK_IMAGE_LAYOUT_GENERAL);
+ BeginRenderPass(cmdbuf, *m_renderpasses[BlendingWeightCalculation],
+ blending_weight_calculation_framebuffer, m_extent);
+ cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS,
+ *m_pipelines[BlendingWeightCalculation]);
+ cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS,
+ *m_pipeline_layouts[BlendingWeightCalculation], 0,
+ blending_weight_calculation_descriptor_set, {});
+ cmdbuf.Draw(3, 1, 0, 0);
+ cmdbuf.EndRenderPass();
+
+ TransitionImageLayout(cmdbuf, blend_image, VK_IMAGE_LAYOUT_GENERAL);
+ TransitionImageLayout(cmdbuf, output_image, VK_IMAGE_LAYOUT_GENERAL);
+ BeginRenderPass(cmdbuf, *m_renderpasses[NeighborhoodBlending],
+ neighborhood_blending_framebuffer, m_extent);
+ cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelines[NeighborhoodBlending]);
+ cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS,
+ *m_pipeline_layouts[NeighborhoodBlending], 0,
+ neighborhood_blending_descriptor_set, {});
+ cmdbuf.Draw(3, 1, 0, 0);
+ cmdbuf.EndRenderPass();
+ TransitionImageLayout(cmdbuf, output_image, VK_IMAGE_LAYOUT_GENERAL);
+ });
+
+ return *images.image_views[Output];
+}
+
+} // namespace Vulkan
diff --git a/src/video_core/renderer_vulkan/vk_smaa.h b/src/video_core/renderer_vulkan/present/smaa.h
index 0e214258a..3d6707d48 100644
--- a/src/video_core/renderer_vulkan/vk_smaa.h
+++ b/src/video_core/renderer_vulkan/present/smaa.h
@@ -4,6 +4,7 @@
#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"
@@ -13,12 +14,14 @@ class Device;
class Scheduler;
class StagingBufferPool;
-class SMAA {
+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);
+ VkImageView source_image_view) override;
private:
enum SMAAStage {
diff --git a/src/video_core/renderer_vulkan/vk_smaa.cpp b/src/video_core/renderer_vulkan/present/util.cpp
index 70644ea82..a445b213e 100644
--- a/src/video_core/renderer_vulkan/vk_smaa.cpp
+++ b/src/video_core/renderer_vulkan/present/util.cpp
@@ -1,29 +1,11 @@
-// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
-#include <list>
-
#include "common/assert.h"
#include "common/polyfill_ranges.h"
-
-#include "video_core/renderer_vulkan/vk_scheduler.h"
-#include "video_core/renderer_vulkan/vk_shader_util.h"
-#include "video_core/renderer_vulkan/vk_smaa.h"
-#include "video_core/smaa_area_tex.h"
-#include "video_core/smaa_search_tex.h"
-#include "video_core/vulkan_common/vulkan_device.h"
-
-#include "video_core/host_shaders/smaa_blending_weight_calculation_frag_spv.h"
-#include "video_core/host_shaders/smaa_blending_weight_calculation_vert_spv.h"
-#include "video_core/host_shaders/smaa_edge_detection_frag_spv.h"
-#include "video_core/host_shaders/smaa_edge_detection_vert_spv.h"
-#include "video_core/host_shaders/smaa_neighborhood_blending_frag_spv.h"
-#include "video_core/host_shaders/smaa_neighborhood_blending_vert_spv.h"
+#include "video_core/renderer_vulkan/present/util.h"
namespace Vulkan {
-namespace {
-
-#define ARRAY_TO_SPAN(a) std::span(a, (sizeof(a) / sizeof(a[0])))
vk::Image CreateWrappedImage(MemoryAllocator& allocator, VkExtent2D dimensions, VkFormat format) {
const VkImageCreateInfo image_ci{
@@ -48,7 +30,7 @@ vk::Image CreateWrappedImage(MemoryAllocator& allocator, VkExtent2D dimensions,
}
void TransitionImageLayout(vk::CommandBuffer& cmdbuf, VkImage image, VkImageLayout target_layout,
- VkImageLayout source_layout = VK_IMAGE_LAYOUT_GENERAL) {
+ VkImageLayout source_layout) {
constexpr VkFlags flags{VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT};
const VkImageMemoryBarrier barrier{
@@ -75,7 +57,7 @@ void TransitionImageLayout(vk::CommandBuffer& cmdbuf, VkImage image, VkImageLayo
void UploadImage(const Device& device, MemoryAllocator& allocator, Scheduler& scheduler,
vk::Image& image, VkExtent2D dimensions, VkFormat format,
- std::span<const u8> initial_contents = {}) {
+ std::span<const u8> initial_contents) {
const VkBufferCreateInfo upload_ci = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = nullptr,
@@ -200,13 +182,13 @@ vk::Framebuffer CreateWrappedFramebuffer(const Device& device, vk::RenderPass& r
});
}
-vk::Sampler CreateWrappedSampler(const Device& device) {
+vk::Sampler CreateWrappedSampler(const Device& device, VkFilter filter) {
return device.GetLogical().CreateSampler(VkSamplerCreateInfo{
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
.pNext = nullptr,
.flags = 0,
- .magFilter = VK_FILTER_LINEAR,
- .minFilter = VK_FILTER_LINEAR,
+ .magFilter = filter,
+ .minFilter = filter,
.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR,
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
@@ -471,12 +453,12 @@ void ClearColorImage(vk::CommandBuffer& cmdbuf, VkImage image) {
cmdbuf.ClearColorImage(image, VK_IMAGE_LAYOUT_GENERAL, {}, subresources);
}
-void BeginRenderPass(vk::CommandBuffer& cmdbuf, vk::RenderPass& render_pass,
- VkFramebuffer framebuffer, VkExtent2D extent) {
+void BeginRenderPass(vk::CommandBuffer& cmdbuf, VkRenderPass render_pass, VkFramebuffer framebuffer,
+ VkExtent2D extent) {
const VkRenderPassBeginInfo renderpass_bi{
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
.pNext = nullptr,
- .renderPass = *render_pass,
+ .renderPass = render_pass,
.framebuffer = framebuffer,
.renderArea{
.offset{},
@@ -503,248 +485,4 @@ void BeginRenderPass(vk::CommandBuffer& cmdbuf, vk::RenderPass& render_pass,
cmdbuf.SetScissor(0, scissor);
}
-} // Anonymous namespace
-
-SMAA::SMAA(const Device& device, MemoryAllocator& allocator, size_t image_count, VkExtent2D extent)
- : m_device(device), m_allocator(allocator), m_extent(extent),
- m_image_count(static_cast<u32>(image_count)) {
- CreateImages();
- CreateRenderPasses();
- CreateSampler();
- CreateShaders();
- CreateDescriptorPool();
- CreateDescriptorSetLayouts();
- CreateDescriptorSets();
- CreatePipelineLayouts();
- CreatePipelines();
-}
-
-void SMAA::CreateImages() {
- static constexpr VkExtent2D area_extent{AREATEX_WIDTH, AREATEX_HEIGHT};
- static constexpr VkExtent2D search_extent{SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT};
-
- m_static_images[Area] = CreateWrappedImage(m_allocator, area_extent, VK_FORMAT_R8G8_UNORM);
- m_static_images[Search] = CreateWrappedImage(m_allocator, search_extent, VK_FORMAT_R8_UNORM);
-
- m_static_image_views[Area] =
- CreateWrappedImageView(m_device, m_static_images[Area], VK_FORMAT_R8G8_UNORM);
- m_static_image_views[Search] =
- CreateWrappedImageView(m_device, m_static_images[Search], VK_FORMAT_R8_UNORM);
-
- for (u32 i = 0; i < m_image_count; i++) {
- Images& images = m_dynamic_images.emplace_back();
-
- images.images[Blend] =
- CreateWrappedImage(m_allocator, m_extent, VK_FORMAT_R16G16B16A16_SFLOAT);
- images.images[Edges] = CreateWrappedImage(m_allocator, m_extent, VK_FORMAT_R16G16_SFLOAT);
- images.images[Output] =
- CreateWrappedImage(m_allocator, m_extent, VK_FORMAT_R16G16B16A16_SFLOAT);
-
- images.image_views[Blend] =
- CreateWrappedImageView(m_device, images.images[Blend], VK_FORMAT_R16G16B16A16_SFLOAT);
- images.image_views[Edges] =
- CreateWrappedImageView(m_device, images.images[Edges], VK_FORMAT_R16G16_SFLOAT);
- images.image_views[Output] =
- CreateWrappedImageView(m_device, images.images[Output], VK_FORMAT_R16G16B16A16_SFLOAT);
- }
-}
-
-void SMAA::CreateRenderPasses() {
- m_renderpasses[EdgeDetection] = CreateWrappedRenderPass(m_device, VK_FORMAT_R16G16_SFLOAT);
- m_renderpasses[BlendingWeightCalculation] =
- CreateWrappedRenderPass(m_device, VK_FORMAT_R16G16B16A16_SFLOAT);
- m_renderpasses[NeighborhoodBlending] =
- CreateWrappedRenderPass(m_device, VK_FORMAT_R16G16B16A16_SFLOAT);
-
- for (auto& images : m_dynamic_images) {
- images.framebuffers[EdgeDetection] = CreateWrappedFramebuffer(
- m_device, m_renderpasses[EdgeDetection], images.image_views[Edges], m_extent);
-
- images.framebuffers[BlendingWeightCalculation] =
- CreateWrappedFramebuffer(m_device, m_renderpasses[BlendingWeightCalculation],
- images.image_views[Blend], m_extent);
-
- images.framebuffers[NeighborhoodBlending] = CreateWrappedFramebuffer(
- m_device, m_renderpasses[NeighborhoodBlending], images.image_views[Output], m_extent);
- }
-}
-
-void SMAA::CreateSampler() {
- m_sampler = CreateWrappedSampler(m_device);
-}
-
-void SMAA::CreateShaders() {
- // These match the order of the SMAAStage enum
- static constexpr std::array vert_shader_sources{
- ARRAY_TO_SPAN(SMAA_EDGE_DETECTION_VERT_SPV),
- ARRAY_TO_SPAN(SMAA_BLENDING_WEIGHT_CALCULATION_VERT_SPV),
- ARRAY_TO_SPAN(SMAA_NEIGHBORHOOD_BLENDING_VERT_SPV),
- };
- static constexpr std::array frag_shader_sources{
- ARRAY_TO_SPAN(SMAA_EDGE_DETECTION_FRAG_SPV),
- ARRAY_TO_SPAN(SMAA_BLENDING_WEIGHT_CALCULATION_FRAG_SPV),
- ARRAY_TO_SPAN(SMAA_NEIGHBORHOOD_BLENDING_FRAG_SPV),
- };
-
- for (size_t i = 0; i < MaxSMAAStage; i++) {
- m_vertex_shaders[i] = CreateWrappedShaderModule(m_device, vert_shader_sources[i]);
- m_fragment_shaders[i] = CreateWrappedShaderModule(m_device, frag_shader_sources[i]);
- }
-}
-
-void SMAA::CreateDescriptorPool() {
- // Edge detection: 1 descriptor
- // Blending weight calculation: 3 descriptors
- // Neighborhood blending: 2 descriptors
-
- // 6 descriptors, 3 descriptor sets per image
- m_descriptor_pool = CreateWrappedDescriptorPool(m_device, 6 * m_image_count, 3 * m_image_count);
-}
-
-void SMAA::CreateDescriptorSetLayouts() {
- m_descriptor_set_layouts[EdgeDetection] = CreateWrappedDescriptorSetLayout(m_device, 1);
- m_descriptor_set_layouts[BlendingWeightCalculation] =
- CreateWrappedDescriptorSetLayout(m_device, 3);
- m_descriptor_set_layouts[NeighborhoodBlending] = CreateWrappedDescriptorSetLayout(m_device, 2);
-}
-
-void SMAA::CreateDescriptorSets() {
- std::vector<VkDescriptorSetLayout> layouts(m_descriptor_set_layouts.size());
- std::ranges::transform(m_descriptor_set_layouts, layouts.begin(),
- [](auto& layout) { return *layout; });
-
- for (auto& images : m_dynamic_images) {
- images.descriptor_sets = CreateWrappedDescriptorSets(m_descriptor_pool, layouts);
- }
-}
-
-void SMAA::CreatePipelineLayouts() {
- for (size_t i = 0; i < MaxSMAAStage; i++) {
- m_pipeline_layouts[i] = CreateWrappedPipelineLayout(m_device, m_descriptor_set_layouts[i]);
- }
-}
-
-void SMAA::CreatePipelines() {
- for (size_t i = 0; i < MaxSMAAStage; i++) {
- m_pipelines[i] =
- CreateWrappedPipeline(m_device, m_renderpasses[i], m_pipeline_layouts[i],
- std::tie(m_vertex_shaders[i], m_fragment_shaders[i]));
- }
-}
-
-void SMAA::UpdateDescriptorSets(VkImageView image_view, size_t image_index) {
- Images& images = m_dynamic_images[image_index];
- std::vector<VkDescriptorImageInfo> image_infos;
- std::vector<VkWriteDescriptorSet> updates;
- image_infos.reserve(6);
-
- updates.push_back(CreateWriteDescriptorSet(image_infos, *m_sampler, image_view,
- images.descriptor_sets[EdgeDetection], 0));
-
- updates.push_back(CreateWriteDescriptorSet(image_infos, *m_sampler, *images.image_views[Edges],
- images.descriptor_sets[BlendingWeightCalculation],
- 0));
- updates.push_back(CreateWriteDescriptorSet(image_infos, *m_sampler, *m_static_image_views[Area],
- images.descriptor_sets[BlendingWeightCalculation],
- 1));
- updates.push_back(
- CreateWriteDescriptorSet(image_infos, *m_sampler, *m_static_image_views[Search],
- images.descriptor_sets[BlendingWeightCalculation], 2));
-
- updates.push_back(CreateWriteDescriptorSet(image_infos, *m_sampler, image_view,
- images.descriptor_sets[NeighborhoodBlending], 0));
- updates.push_back(CreateWriteDescriptorSet(image_infos, *m_sampler, *images.image_views[Blend],
- images.descriptor_sets[NeighborhoodBlending], 1));
-
- m_device.GetLogical().UpdateDescriptorSets(updates, {});
-}
-
-void SMAA::UploadImages(Scheduler& scheduler) {
- if (m_images_ready) {
- return;
- }
-
- static constexpr VkExtent2D area_extent{AREATEX_WIDTH, AREATEX_HEIGHT};
- static constexpr VkExtent2D search_extent{SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT};
-
- UploadImage(m_device, m_allocator, scheduler, m_static_images[Area], area_extent,
- VK_FORMAT_R8G8_UNORM, ARRAY_TO_SPAN(areaTexBytes));
- UploadImage(m_device, m_allocator, scheduler, m_static_images[Search], search_extent,
- VK_FORMAT_R8_UNORM, ARRAY_TO_SPAN(searchTexBytes));
-
- scheduler.Record([&](vk::CommandBuffer cmdbuf) {
- for (auto& images : m_dynamic_images) {
- for (size_t i = 0; i < MaxDynamicImage; i++) {
- ClearColorImage(cmdbuf, *images.images[i]);
- }
- }
- });
- scheduler.Finish();
-
- m_images_ready = true;
-}
-
-VkImageView SMAA::Draw(Scheduler& scheduler, size_t image_index, VkImage source_image,
- VkImageView source_image_view) {
- Images& images = m_dynamic_images[image_index];
-
- VkImage output_image = *images.images[Output];
- VkImage edges_image = *images.images[Edges];
- VkImage blend_image = *images.images[Blend];
-
- VkDescriptorSet edge_detection_descriptor_set = images.descriptor_sets[EdgeDetection];
- VkDescriptorSet blending_weight_calculation_descriptor_set =
- images.descriptor_sets[BlendingWeightCalculation];
- VkDescriptorSet neighborhood_blending_descriptor_set =
- images.descriptor_sets[NeighborhoodBlending];
-
- VkFramebuffer edge_detection_framebuffer = *images.framebuffers[EdgeDetection];
- VkFramebuffer blending_weight_calculation_framebuffer =
- *images.framebuffers[BlendingWeightCalculation];
- VkFramebuffer neighborhood_blending_framebuffer = *images.framebuffers[NeighborhoodBlending];
-
- UploadImages(scheduler);
- UpdateDescriptorSets(source_image_view, image_index);
-
- scheduler.RequestOutsideRenderPassOperationContext();
- scheduler.Record([=, this](vk::CommandBuffer cmdbuf) {
- TransitionImageLayout(cmdbuf, source_image, VK_IMAGE_LAYOUT_GENERAL);
- TransitionImageLayout(cmdbuf, edges_image, VK_IMAGE_LAYOUT_GENERAL);
- BeginRenderPass(cmdbuf, m_renderpasses[EdgeDetection], edge_detection_framebuffer,
- m_extent);
- cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelines[EdgeDetection]);
- cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS,
- *m_pipeline_layouts[EdgeDetection], 0,
- edge_detection_descriptor_set, {});
- cmdbuf.Draw(3, 1, 0, 0);
- cmdbuf.EndRenderPass();
-
- TransitionImageLayout(cmdbuf, edges_image, VK_IMAGE_LAYOUT_GENERAL);
- TransitionImageLayout(cmdbuf, blend_image, VK_IMAGE_LAYOUT_GENERAL);
- BeginRenderPass(cmdbuf, m_renderpasses[BlendingWeightCalculation],
- blending_weight_calculation_framebuffer, m_extent);
- cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS,
- *m_pipelines[BlendingWeightCalculation]);
- cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS,
- *m_pipeline_layouts[BlendingWeightCalculation], 0,
- blending_weight_calculation_descriptor_set, {});
- cmdbuf.Draw(3, 1, 0, 0);
- cmdbuf.EndRenderPass();
-
- TransitionImageLayout(cmdbuf, blend_image, VK_IMAGE_LAYOUT_GENERAL);
- TransitionImageLayout(cmdbuf, output_image, VK_IMAGE_LAYOUT_GENERAL);
- BeginRenderPass(cmdbuf, m_renderpasses[NeighborhoodBlending],
- neighborhood_blending_framebuffer, m_extent);
- cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelines[NeighborhoodBlending]);
- cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS,
- *m_pipeline_layouts[NeighborhoodBlending], 0,
- neighborhood_blending_descriptor_set, {});
- cmdbuf.Draw(3, 1, 0, 0);
- cmdbuf.EndRenderPass();
- TransitionImageLayout(cmdbuf, output_image, VK_IMAGE_LAYOUT_GENERAL);
- });
-
- return *images.image_views[Output];
-}
-
} // namespace Vulkan
diff --git a/src/video_core/renderer_vulkan/present/util.h b/src/video_core/renderer_vulkan/present/util.h
new file mode 100644
index 000000000..93cfdd16b
--- /dev/null
+++ b/src/video_core/renderer_vulkan/present/util.h
@@ -0,0 +1,46 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "video_core/renderer_vulkan/vk_scheduler.h"
+#include "video_core/vulkan_common/vulkan_memory_allocator.h"
+#include "video_core/vulkan_common/vulkan_wrapper.h"
+
+namespace Vulkan {
+
+#define ARRAY_TO_SPAN(a) std::span(a, (sizeof(a) / sizeof(a[0])))
+
+vk::Image CreateWrappedImage(MemoryAllocator& allocator, VkExtent2D dimensions, VkFormat format);
+void TransitionImageLayout(vk::CommandBuffer& cmdbuf, VkImage image, VkImageLayout target_layout,
+ VkImageLayout source_layout = VK_IMAGE_LAYOUT_GENERAL);
+void UploadImage(const Device& device, MemoryAllocator& allocator, Scheduler& scheduler,
+ vk::Image& image, VkExtent2D dimensions, VkFormat format,
+ std::span<const u8> initial_contents = {});
+void ClearColorImage(vk::CommandBuffer& cmdbuf, VkImage image);
+
+vk::ImageView CreateWrappedImageView(const Device& device, vk::Image& image, VkFormat format);
+vk::RenderPass CreateWrappedRenderPass(const Device& device, VkFormat format);
+vk::Framebuffer CreateWrappedFramebuffer(const Device& device, vk::RenderPass& render_pass,
+ vk::ImageView& dest_image, VkExtent2D extent);
+vk::Sampler CreateWrappedSampler(const Device& device, VkFilter filter = VK_FILTER_LINEAR);
+vk::ShaderModule CreateWrappedShaderModule(const Device& device, std::span<const u32> code);
+vk::DescriptorPool CreateWrappedDescriptorPool(const Device& device, u32 max_sampler_bindings,
+ u32 max_sets);
+vk::DescriptorSetLayout CreateWrappedDescriptorSetLayout(const Device& device,
+ u32 max_sampler_bindings);
+vk::DescriptorSets CreateWrappedDescriptorSets(vk::DescriptorPool& pool,
+ vk::Span<VkDescriptorSetLayout> layouts);
+vk::PipelineLayout CreateWrappedPipelineLayout(const Device& device,
+ vk::DescriptorSetLayout& layout);
+vk::Pipeline CreateWrappedPipeline(const Device& device, vk::RenderPass& renderpass,
+ vk::PipelineLayout& layout,
+ std::tuple<vk::ShaderModule&, vk::ShaderModule&> shaders);
+VkWriteDescriptorSet CreateWriteDescriptorSet(std::vector<VkDescriptorImageInfo>& images,
+ VkSampler sampler, VkImageView view,
+ VkDescriptorSet set, u32 binding);
+
+void BeginRenderPass(vk::CommandBuffer& cmdbuf, VkRenderPass render_pass, VkFramebuffer framebuffer,
+ VkExtent2D extent);
+
+} // namespace Vulkan