Plasma Engine  2.0
Loading...
Searching...
No Matches
ImageCopyVulkan.h
1#pragma once
2
3#include <RendererVulkan/RendererVulkanDLL.h>
4
5#include <RendererFoundation/Shader/ShaderUtils.h>
6#include <RendererVulkan/Cache/ResourceCacheVulkan.h>
7
8#include <vulkan/vulkan.hpp>
9
17
18
20class PL_RENDERERVULKAN_DLL plImageCopyVulkan
21{
22public:
23 plImageCopyVulkan(plGALDeviceVulkan& GALDeviceVulkan);
25 void Init(const plGALTextureVulkan* pSource, const plGALTextureVulkan* pTarget, plShaderUtils::plBuiltinShaderType type);
26
27 void Copy(const plVec3U32& sourceOffset, const vk::ImageSubresourceLayers& sourceLayers, const plVec3U32& targetOffset, const vk::ImageSubresourceLayers& targetLayers, const plVec3U32& extends);
28
29 static void Initialize(plGALDeviceVulkan& GALDeviceVulkan);
30 static void DeInitialize(plGALDeviceVulkan& GALDeviceVulkan);
31
33 {
34 PL_DECLARE_POD_TYPE();
35
36 vk::Format targetFormat;
37 vk::SampleCountFlagBits targetSamples;
38 };
39
41 {
42 PL_DECLARE_POD_TYPE();
43
44 vk::RenderPass m_renderpass;
45 vk::ImageView m_targetView;
46 plVec3U32 m_extends;
47 uint32_t m_layerCount;
48 };
49
51 {
52 PL_DECLARE_POD_TYPE();
53
54 vk::Image m_image;
55 vk::ImageSubresourceLayers m_subresourceLayers;
56 };
57
59 {
60 PL_DECLARE_POD_TYPE();
61
62 vk::ImageSubresourceLayers m_subresourceLayers;
63 vk::ImageView m_imageView;
64 };
65
66private:
67 void RenderInternal(const plVec3U32& sourceOffset, const vk::ImageSubresourceLayers& sourceLayers, const plVec3U32& targetOffset, const vk::ImageSubresourceLayers& targetLayers, const plVec3U32& extends);
68
69 static void OnBeforeImageDestroyed(plGALDeviceVulkan::OnBeforeImageDestroyedData data);
70
71
72private:
73 plGALDeviceVulkan& m_GALDeviceVulkan;
74
75 // Init input
76 const plGALTextureVulkan* m_pSource = nullptr;
77 const plGALTextureVulkan* m_pTarget = nullptr;
78 plShaderUtils::plBuiltinShaderType m_type = plShaderUtils::plBuiltinShaderType::CopyImage;
79
80 // Init derived Vulkan objects
81 vk::RenderPass m_renderPass;
83 plGALVertexDeclarationHandle m_hVertexDecl;
86 vk::Pipeline m_pipeline;
87
88 // Cache to keep important resources alive
89 // This avoids recreating them every frame
90 struct Cache
91 {
92 Cache(plAllocator* pAllocator);
93 ~Cache();
94
98 plHashTable<vk::Image, ImageViewCacheValue> m_imageToSourceImageViewCacheKey;
100 plHashTable<vk::Image, ImageViewCacheValue> m_imageToTargetImageViewCacheKey;
103
104 plEventSubscriptionID m_onBeforeImageDeletedSubscription;
105 };
106
107 static plUniquePtr<Cache> s_cache;
108};
Base class for all memory allocators.
Definition Allocator.h:23
Definition ResourceViewVulkan.h:33
Definition UnorderedAccessViewVulkan.h:34
Definition BufferVulkan.h:11
The Vulkan device implementation of the graphics abstraction layer.
Definition DeviceVulkan.h:58
Definition RenderTargetViewVulkan.h:11
Definition ResourceViewVulkan.h:12
Definition UnorderedAccessViewVulkan.h:11
Definition TextureVulkan.h:11
Definition RendererFoundationDLL.h:488
Definition HashTable.h:333
Definition ImageCopyVulkan.h:21
A Unique ptr manages an object and destroys that object when it goes out of scope....
Definition UniquePtr.h:10
Definition ImageCopyVulkan.h:41
Definition ImageCopyVulkan.h:51
Definition ImageCopyVulkan.h:59
Definition ImageCopyVulkan.h:33
Definition ResourceCacheVulkan.h:40
Definition ResourceCacheVulkan.h:34
Definition ShaderUtils.h:54