summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-04-15 17:39:57 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-04-15 17:39:57 +0000
commit6b9021245de386e5390bdb68c1ab09bcb3d89b80 (patch)
tree21a0fca76c7baa3e50094735405068e3f689964d /Graphics/GraphicsEngineVulkan
parentFixed build errors (diff)
downloadDiligentCore-6b9021245de386e5390bdb68c1ab09bcb3d89b80.tar.gz
DiligentCore-6b9021245de386e5390bdb68c1ab09bcb3d89b80.zip
Reworked vulkan object wrapper creation by logical device
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h60
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h20
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h5
-rw-r--r--Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp5
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp110
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp171
6 files changed, 263 insertions, 108 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h
index 6d088f00..50b1a0a8 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h
@@ -61,25 +61,47 @@ namespace VulkanUtilities
//void EndRegion(VkCommandBuffer cmdBuffer);
// Object specific naming functions
- void SetCommandPoolName(VkDevice device, VkCommandPool cmdPool, const char * name);
- void SetCommandBufferName(VkDevice device, VkCommandBuffer cmdBuffer, const char * name);
- void SetQueueName(VkDevice device, VkQueue queue, const char * name);
- void SetImageName(VkDevice device, VkImage image, const char * name);
- void SetImageViewName(VkDevice device, VkImageView imageView, const char * name);
- void SetSamplerName(VkDevice device, VkSampler sampler, const char * name);
- void SetBufferName(VkDevice device, VkBuffer buffer, const char * name);
- void SetBufferViewName(VkDevice device, VkBufferView bufferView, const char * name);
- void SetDeviceMemoryName(VkDevice device, VkDeviceMemory memory, const char * name);
- void SetShaderModuleName(VkDevice device, VkShaderModule shaderModule, const char * name);
- void SetPipelineName(VkDevice device, VkPipeline pipeline, const char * name);
- void SetPipelineLayoutName(VkDevice device, VkPipelineLayout pipelineLayout, const char * name);
- void SetRenderPassName(VkDevice device, VkRenderPass renderPass, const char * name);
- void SetFramebufferName(VkDevice device, VkFramebuffer framebuffer, const char * name);
- void SetDescriptorSetLayoutName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name);
- void SetDescriptorSetName(VkDevice device, VkDescriptorSet descriptorSet, const char * name);
- void SetSemaphoreName(VkDevice device, VkSemaphore semaphore, const char * name);
- void SetFenceName(VkDevice device, VkFence fence, const char * name);
- void SetEventName(VkDevice device, VkEvent _event, const char * name);
+ void SetCommandPoolName (VkDevice device, VkCommandPool cmdPool, const char * name);
+ void SetCommandBufferName (VkDevice device, VkCommandBuffer cmdBuffer, const char * name);
+ void SetQueueName (VkDevice device, VkQueue queue, const char * name);
+ void SetImageName (VkDevice device, VkImage image, const char * name);
+ void SetImageViewName (VkDevice device, VkImageView imageView, const char * name);
+ void SetSamplerName (VkDevice device, VkSampler sampler, const char * name);
+ void SetBufferName (VkDevice device, VkBuffer buffer, const char * name);
+ void SetBufferViewName (VkDevice device, VkBufferView bufferView, const char * name);
+ void SetDeviceMemoryName (VkDevice device, VkDeviceMemory memory, const char * name);
+ void SetShaderModuleName (VkDevice device, VkShaderModule shaderModule, const char * name);
+ void SetPipelineName (VkDevice device, VkPipeline pipeline, const char * name);
+ void SetPipelineLayoutName (VkDevice device, VkPipelineLayout pipelineLayout, const char * name);
+ void SetRenderPassName (VkDevice device, VkRenderPass renderPass, const char * name);
+ void SetFramebufferName (VkDevice device, VkFramebuffer framebuffer, const char * name);
+ void SetDescriptorSetLayoutName (VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name);
+ void SetDescriptorSetName (VkDevice device, VkDescriptorSet descriptorSet, const char * name);
+ void SetDescriptorPoolName (VkDevice device, VkDescriptorPool descriptorPool, const char * name);
+ void SetSemaphoreName (VkDevice device, VkSemaphore semaphore, const char * name);
+ void SetFenceName (VkDevice device, VkFence fence, const char * name);
+ void SetEventName (VkDevice device, VkEvent _event, const char * name);
+
+ void SetVulkanObjectName(VkDevice device, VkCommandPool cmdPool, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkCommandBuffer cmdBuffer, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkQueue queue, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkImage image, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkImageView imageView, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkSampler sampler, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkBuffer buffer, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkBufferView bufferView, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkDeviceMemory memory, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkShaderModule shaderModule, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkPipeline pipeline, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkPipelineLayout pipelineLayout, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkRenderPass renderPass, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkFramebuffer framebuffer, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkDescriptorSet descriptorSet, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkDescriptorPool descriptorPool, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkSemaphore semaphore, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkFence fence, const char * name);
+ void SetVulkanObjectName(VkDevice device, VkEvent _event, const char * name);
const char* VkResultToString(VkResult errorCode);
}
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
index 8dba0dd7..bafe0bea 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
@@ -67,13 +67,18 @@ namespace VulkanUtilities
BufferViewWrapper CreateBufferView (const VkBufferViewCreateInfo &BuffViewCI, const char *DebugName = "")const;
ImageWrapper CreateImage (const VkImageCreateInfo &ImageCI, const char *DebugName = "")const;
ImageViewWrapper CreateImageView (const VkImageViewCreateInfo &ImageViewCI, const char *DebugName = "")const;
+ SamplerWrapper CreateSampler (const VkSamplerCreateInfo &SamplerCI, const char *DebugName = "")const;
FenceWrapper CreateFence (const VkFenceCreateInfo &FenceCI, const char *DebugName = "")const;
RenderPassWrapper CreateRenderPass (const VkRenderPassCreateInfo &RenderPassCI,const char *DebugName = "")const;
DeviceMemoryWrapper AllocateDeviceMemory(const VkMemoryAllocateInfo &AllocInfo, const char *DebugName = "")const;
PipelineWrapper CreateComputePipeline (const VkComputePipelineCreateInfo &PipelineCI, VkPipelineCache cache, const char *DebugName = "")const;
PipelineWrapper CreateGraphicsPipeline(const VkGraphicsPipelineCreateInfo &PipelineCI, VkPipelineCache cache, const char *DebugName = "")const;
- ShaderModuleWrapper CreateShaderModule (const VkShaderModuleCreateInfo &ShaderModuleCI, const char *DebugName = "")const;
-
+ ShaderModuleWrapper CreateShaderModule (const VkShaderModuleCreateInfo &ShaderModuleCI, const char *DebugName = "")const;
+ PipelineLayoutWrapper CreatePipelineLayout(const VkPipelineLayoutCreateInfo &LayoutCI, const char *DebugName = "")const;
+ FramebufferWrapper CreateFramebuffer (const VkFramebufferCreateInfo &FramebufferCI, const char *DebugName = "")const;
+ DescriptorPoolWrapper CreateDescriptorPool(const VkDescriptorPoolCreateInfo &DescrPoolCI, const char *DebugName = "")const;
+ DescriptorSetLayoutWrapper CreateDescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo &LayoutCI, const char *DebugName = "")const;
+
VkCommandBuffer AllocateVkCommandBuffer(const VkCommandBufferAllocateInfo &AllocInfo, const char *DebugName = "")const;
void ReleaseVulkanObject(CommandPoolWrapper&& CmdPool)const;
@@ -81,11 +86,16 @@ namespace VulkanUtilities
void ReleaseVulkanObject(BufferViewWrapper&& BufferView)const;
void ReleaseVulkanObject(ImageWrapper&& Image)const;
void ReleaseVulkanObject(ImageViewWrapper&& ImageView)const;
+ void ReleaseVulkanObject(SamplerWrapper&& Sampler)const;
void ReleaseVulkanObject(FenceWrapper&& Fence)const;
void ReleaseVulkanObject(RenderPassWrapper&& RenderPass)const;
void ReleaseVulkanObject(DeviceMemoryWrapper&& Memory)const;
void ReleaseVulkanObject(PipelineWrapper&& Pipeline)const;
void ReleaseVulkanObject(ShaderModuleWrapper&& ShaderModule)const;
+ void ReleaseVulkanObject(PipelineLayoutWrapper&& PipelineLayout)const;
+ void ReleaseVulkanObject(FramebufferWrapper&& Framebuffer)const;
+ void ReleaseVulkanObject(DescriptorPoolWrapper&& DescriptorPool)const;
+ void ReleaseVulkanObject(DescriptorSetLayoutWrapper&& DescriptorSetLayout)const;
VkMemoryRequirements GetBufferMemoryRequirements(VkBuffer vkBuffer)const;
VkMemoryRequirements GetImageMemoryRequirements (VkImage vkImage )const;
@@ -105,6 +115,12 @@ namespace VulkanUtilities
const VkAllocationCallbacks* vkAllocator,
bool EnableDebugMarkers);
+ template<typename VkObjectType, typename VkCreateObjectFuncType, typename VkObjectCreateInfoType>
+ VulkanObjectWrapper<VkObjectType> CreateVulkanObject(VkCreateObjectFuncType VkCreateObject,
+ const VkObjectCreateInfoType& CreateInfo,
+ const char *DebugName,
+ const char *ObjectType)const;
+
VkDevice m_VkDevice = VK_NULL_HANDLE;
const VkAllocationCallbacks* const m_VkAllocator;
};
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h
index 7e749a70..59d757cb 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h
@@ -100,4 +100,9 @@ namespace VulkanUtilities
using RenderPassWrapper = VulkanObjectWrapper<VkRenderPass>;
using PipelineWrapper = VulkanObjectWrapper<VkPipeline>;
using ShaderModuleWrapper = VulkanObjectWrapper<VkShaderModule>;
+ using PipelineLayoutWrapper = VulkanObjectWrapper<VkPipelineLayout>;
+ using SamplerWrapper = VulkanObjectWrapper<VkSampler>;
+ using FramebufferWrapper = VulkanObjectWrapper<VkFramebuffer>;
+ using DescriptorPoolWrapper = VulkanObjectWrapper<VkDescriptorPool>;
+ using DescriptorSetLayoutWrapper = VulkanObjectWrapper<VkDescriptorSetLayout>;
}
diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
index e18186ff..cb90a89d 100644
--- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
@@ -409,10 +409,15 @@ template void RenderDeviceVkImpl::SafeReleaseVkObject<VkBuffer> (VulkanUti
template void RenderDeviceVkImpl::SafeReleaseVkObject<VkBufferView> (VulkanUtilities::BufferViewWrapper &&Object);
template void RenderDeviceVkImpl::SafeReleaseVkObject<VkImage> (VulkanUtilities::ImageWrapper &&Object);
template void RenderDeviceVkImpl::SafeReleaseVkObject<VkImageView> (VulkanUtilities::ImageViewWrapper &&Object);
+template void RenderDeviceVkImpl::SafeReleaseVkObject<VkSampler> (VulkanUtilities::SamplerWrapper &&Object);
template void RenderDeviceVkImpl::SafeReleaseVkObject<VkDeviceMemory> (VulkanUtilities::DeviceMemoryWrapper &&Object);
template void RenderDeviceVkImpl::SafeReleaseVkObject<VkRenderPass> (VulkanUtilities::RenderPassWrapper &&Object);
template void RenderDeviceVkImpl::SafeReleaseVkObject<VkPipeline> (VulkanUtilities::PipelineWrapper &&Object);
template void RenderDeviceVkImpl::SafeReleaseVkObject<VkShaderModule> (VulkanUtilities::ShaderModuleWrapper &&Object);
+template void RenderDeviceVkImpl::SafeReleaseVkObject<VkPipelineLayout>(VulkanUtilities::PipelineLayoutWrapper &&Object);
+template void RenderDeviceVkImpl::SafeReleaseVkObject<VkFramebuffer> (VulkanUtilities::FramebufferWrapper &&Object);
+template void RenderDeviceVkImpl::SafeReleaseVkObject<VkDescriptorPool> (VulkanUtilities::DescriptorPoolWrapper &&Object);
+template void RenderDeviceVkImpl::SafeReleaseVkObject<VkDescriptorSetLayout>(VulkanUtilities::DescriptorSetLayoutWrapper &&Object);
void RenderDeviceVkImpl::DiscardStaleVkObjects(Uint64 CmdListNumber, Uint64 FenceValue)
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp
index 9e80f530..587d988d 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp
@@ -266,6 +266,11 @@ namespace VulkanUtilities
SetObjectName(device, (uint64_t)descriptorSet, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, name);
}
+ void SetDescriptorPoolName(VkDevice device, VkDescriptorPool descriptorPool, const char * name)
+ {
+ SetObjectName(device, (uint64_t)descriptorPool, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, name);
+ }
+
void SetSemaphoreName(VkDevice device, VkSemaphore semaphore, const char * name)
{
SetObjectName(device, (uint64_t)semaphore, VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, name);
@@ -281,6 +286,111 @@ namespace VulkanUtilities
SetObjectName(device, (uint64_t)_event, VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT, name);
}
+
+
+
+ void SetVulkanObjectName(VkDevice device, VkCommandPool cmdPool, const char * name)
+ {
+ SetCommandPoolName(device, cmdPool, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkCommandBuffer cmdBuffer, const char * name)
+ {
+ SetCommandBufferName(device, cmdBuffer, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkQueue queue, const char * name)
+ {
+ SetQueueName(device, queue, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkImage image, const char * name)
+ {
+ SetImageName(device, image, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkImageView imageView, const char * name)
+ {
+ SetImageViewName(device, imageView, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkSampler sampler, const char * name)
+ {
+ SetSamplerName(device, sampler, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkBuffer buffer, const char * name)
+ {
+ SetBufferName(device, buffer, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkBufferView bufferView, const char * name)
+ {
+ SetBufferViewName(device, bufferView, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkDeviceMemory memory, const char * name)
+ {
+ SetDeviceMemoryName(device, memory, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkShaderModule shaderModule, const char * name)
+ {
+ SetShaderModuleName(device, shaderModule, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkPipeline pipeline, const char * name)
+ {
+ SetPipelineName(device, pipeline, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkPipelineLayout pipelineLayout, const char * name)
+ {
+ SetPipelineLayoutName(device, pipelineLayout, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkRenderPass renderPass, const char * name)
+ {
+ SetRenderPassName(device, renderPass, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkFramebuffer framebuffer, const char * name)
+ {
+ SetFramebufferName(device, framebuffer, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name)
+ {
+ SetDescriptorSetLayoutName(device, descriptorSetLayout, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkDescriptorSet descriptorSet, const char * name)
+ {
+ SetDescriptorSetName(device, descriptorSet, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkDescriptorPool descriptorPool, const char * name)
+ {
+ SetDescriptorPoolName(device, descriptorPool, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkSemaphore semaphore, const char * name)
+ {
+ SetSemaphoreName(device, semaphore, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkFence fence, const char * name)
+ {
+ SetFenceName(device, fence, name);
+ }
+
+ void SetVulkanObjectName(VkDevice device, VkEvent _event, const char * name)
+ {
+ SetEventName(device, _event, name);
+ }
+
+
+
const char* VkResultToString(VkResult errorCode)
{
switch (errorCode)
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
index c178d3d2..3dff7a73 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
@@ -53,7 +53,7 @@ namespace VulkanUtilities
if (EnableDebugMarkers)
{
- VulkanUtilities::SetupDebugMarkers(m_VkDevice);
+ SetupDebugMarkers(m_VkDevice);
}
}
@@ -74,114 +74,68 @@ namespace VulkanUtilities
VERIFY_EXPR(err == VK_SUCCESS);
}
- CommandPoolWrapper VulkanLogicalDevice::CreateCommandPool(const VkCommandPoolCreateInfo &CmdPoolCI,
- const char *DebugName) const
+ template<typename VkObjectType, typename VkCreateObjectFuncType, typename VkObjectCreateInfoType>
+ VulkanObjectWrapper<VkObjectType> VulkanLogicalDevice::CreateVulkanObject(VkCreateObjectFuncType VkCreateObject,
+ const VkObjectCreateInfoType& CreateInfo,
+ const char *DebugName,
+ const char *ObjectType)const
{
- if(DebugName == nullptr)
+ if (DebugName == nullptr)
DebugName = "";
- VkCommandPool CmdPool = VK_NULL_HANDLE;
- auto err = vkCreateCommandPool(m_VkDevice, &CmdPoolCI, m_VkAllocator, &CmdPool);
- CHECK_VK_ERROR_AND_THROW(err, "Failed to create Vulkan command pool '", DebugName, '\'');
+ VkObjectType VkObject = VK_NULL_HANDLE;
+ auto err = VkCreateObject(m_VkDevice, &CreateInfo, m_VkAllocator, &VkObject);
+ CHECK_VK_ERROR_AND_THROW(err, "Failed to create Vulkan ", ObjectType, " '", DebugName, '\'');
+
+ if (DebugName != nullptr && *DebugName != 0)
+ SetVulkanObjectName(m_VkDevice, VkObject, DebugName);
- if(DebugName != nullptr && *DebugName != 0)
- VulkanUtilities::SetCommandPoolName(m_VkDevice, CmdPool, DebugName);
+ return VulkanObjectWrapper<VkObjectType>{ GetSharedPtr(), std::move(VkObject) };
+ }
- return CommandPoolWrapper{ GetSharedPtr(), std::move(CmdPool)};
+ CommandPoolWrapper VulkanLogicalDevice::CreateCommandPool(const VkCommandPoolCreateInfo &CmdPoolCI,
+ const char *DebugName) const
+ {
+ return CreateVulkanObject<VkCommandPool>(vkCreateCommandPool, CmdPoolCI, DebugName, "command pool");
}
BufferWrapper VulkanLogicalDevice::CreateBuffer(const VkBufferCreateInfo &BufferCI,
const char *DebugName)const
{
- if (DebugName == nullptr)
- DebugName = "";
-
- VkBuffer vkBuffer = VK_NULL_HANDLE;
- auto err = vkCreateBuffer(m_VkDevice, &BufferCI, m_VkAllocator, &vkBuffer);
- CHECK_VK_ERROR_AND_THROW(err, "Failed to create Vulkan buffer '", DebugName, '\'');
-
- if (DebugName != nullptr && *DebugName != 0)
- VulkanUtilities::SetBufferName(m_VkDevice, vkBuffer, DebugName);
-
- return BufferWrapper{ GetSharedPtr(), std::move(vkBuffer) };
+ return CreateVulkanObject<VkBuffer>(vkCreateBuffer, BufferCI, DebugName, "buffer");
}
BufferViewWrapper VulkanLogicalDevice::CreateBufferView(const VkBufferViewCreateInfo &BuffViewCI,
const char *DebugName)const
{
- if (DebugName == nullptr)
- DebugName = "";
-
- VkBufferView vkBufferView = VK_NULL_HANDLE;
- auto err = vkCreateBufferView(m_VkDevice, &BuffViewCI, m_VkAllocator, &vkBufferView);
- CHECK_VK_ERROR_AND_THROW(err, "Failed to create Vulkan buffer view '", DebugName, '\'');
-
- if (DebugName != nullptr && *DebugName != 0)
- VulkanUtilities::SetBufferViewName(m_VkDevice, vkBufferView, DebugName);
-
- return BufferViewWrapper{ GetSharedPtr(), std::move(vkBufferView) };
+ return CreateVulkanObject<VkBufferView>(vkCreateBufferView, BuffViewCI, DebugName, "buffer view");
}
ImageWrapper VulkanLogicalDevice::CreateImage(const VkImageCreateInfo &ImageCI,
const char *DebugName)const
{
- if (DebugName == nullptr)
- DebugName = "";
-
- VkImage vkImage = VK_NULL_HANDLE;
- auto err = vkCreateImage(m_VkDevice, &ImageCI, m_VkAllocator, &vkImage);
- CHECK_VK_ERROR_AND_THROW(err, "Failed to create Vulkan image '", DebugName, '\'');
-
- if (DebugName != nullptr && *DebugName != 0)
- VulkanUtilities::SetImageName(m_VkDevice, vkImage, DebugName);
-
- return ImageWrapper{ GetSharedPtr(), std::move(vkImage) };
+ return CreateVulkanObject<VkImage>(vkCreateImage, ImageCI, DebugName, "image");
}
ImageViewWrapper VulkanLogicalDevice::CreateImageView(const VkImageViewCreateInfo &ImageViewCI,
const char *DebugName)const
{
- if (DebugName == nullptr)
- DebugName = "";
-
- VkImageView vkImageView = VK_NULL_HANDLE;
- auto err = vkCreateImageView(m_VkDevice, &ImageViewCI, m_VkAllocator, &vkImageView);
- CHECK_VK_ERROR_AND_THROW(err, "Failed to create Vulkan image view '", DebugName, '\'');
-
- if (DebugName != nullptr && *DebugName != 0)
- VulkanUtilities::SetImageViewName(m_VkDevice, vkImageView, DebugName);
+ return CreateVulkanObject<VkImageView>(vkCreateImageView, ImageViewCI, DebugName, "image view");
+ }
- return ImageViewWrapper{ GetSharedPtr(), std::move(vkImageView) };
+ SamplerWrapper VulkanLogicalDevice::CreateSampler(const VkSamplerCreateInfo &SamplerCI, const char *DebugName)const
+ {
+ return CreateVulkanObject<VkSampler>(vkCreateSampler, SamplerCI, DebugName, "sampler");
}
FenceWrapper VulkanLogicalDevice::CreateFence(const VkFenceCreateInfo &FenceCI, const char *DebugName)const
{
- if (DebugName == nullptr)
- DebugName = "";
-
- VkFence vkFence = VK_NULL_HANDLE;
- auto err = vkCreateFence(m_VkDevice, &FenceCI, m_VkAllocator, &vkFence);
- CHECK_VK_ERROR_AND_THROW(err, "Failed to create fence '", DebugName, '\'');
-
- if (DebugName != nullptr && *DebugName != 0)
- VulkanUtilities::SetFenceName(m_VkDevice, vkFence, DebugName);
-
- return FenceWrapper{ GetSharedPtr(), std::move(vkFence) };
+ return CreateVulkanObject<VkFence>(vkCreateFence, FenceCI, DebugName, "fence");
}
RenderPassWrapper VulkanLogicalDevice::CreateRenderPass(const VkRenderPassCreateInfo &RenderPassCI, const char *DebugName)const
{
- if (DebugName == nullptr)
- DebugName = "";
-
- VkRenderPass vkRenderPass = VK_NULL_HANDLE;
- auto err = vkCreateRenderPass(m_VkDevice, &RenderPassCI, m_VkAllocator, &vkRenderPass);
- CHECK_VK_ERROR_AND_THROW(err, "Failed to create Render Pass '", DebugName, '\'');
-
- if (DebugName != nullptr && *DebugName != 0)
- VulkanUtilities::SetRenderPassName(m_VkDevice, vkRenderPass, DebugName);
-
- return RenderPassWrapper{ GetSharedPtr(), std::move(vkRenderPass) };
+ return CreateVulkanObject<VkRenderPass>(vkCreateRenderPass, RenderPassCI, DebugName, "render pass");
}
DeviceMemoryWrapper VulkanLogicalDevice::AllocateDeviceMemory(const VkMemoryAllocateInfo &AllocInfo,
@@ -196,7 +150,7 @@ namespace VulkanUtilities
CHECK_VK_ERROR_AND_THROW(err, "Failed to allocate device memory '", DebugName, '\'');
if (DebugName != nullptr && *DebugName != 0)
- VulkanUtilities::SetDeviceMemoryName(m_VkDevice, vkDeviceMem, DebugName);
+ SetDeviceMemoryName(m_VkDevice, vkDeviceMem, DebugName);
return DeviceMemoryWrapper{ GetSharedPtr(), std::move(vkDeviceMem) };
}
@@ -213,7 +167,7 @@ namespace VulkanUtilities
CHECK_VK_ERROR_AND_THROW(err, "Failed to create compute pipeline '", DebugName, '\'');
if (DebugName != nullptr && *DebugName != 0)
- VulkanUtilities::SetPipelineName(m_VkDevice, vkPipeline, DebugName);
+ SetPipelineName(m_VkDevice, vkPipeline, DebugName);
return PipelineWrapper{ GetSharedPtr(), std::move(vkPipeline) };
}
@@ -227,29 +181,38 @@ namespace VulkanUtilities
VkPipeline vkPipeline = VK_NULL_HANDLE;
auto err = vkCreateGraphicsPipelines(m_VkDevice, cache, 1, &PipelineCI, m_VkAllocator, &vkPipeline);
- CHECK_VK_ERROR_AND_THROW(err, "Failed to create Graphics pipeline '", DebugName, '\'');
+ CHECK_VK_ERROR_AND_THROW(err, "Failed to create graphics pipeline '", DebugName, '\'');
if (DebugName != nullptr && *DebugName != 0)
- VulkanUtilities::SetPipelineName(m_VkDevice, vkPipeline, DebugName);
+ SetPipelineName(m_VkDevice, vkPipeline, DebugName);
return PipelineWrapper{ GetSharedPtr(), std::move(vkPipeline) };
}
ShaderModuleWrapper VulkanLogicalDevice::CreateShaderModule(const VkShaderModuleCreateInfo &ShaderModuleCI, const char *DebugName)const
{
- if (DebugName == nullptr)
- DebugName = "";
+ return CreateVulkanObject<VkShaderModule>(vkCreateShaderModule, ShaderModuleCI, DebugName, "shader module");
+ }
- VkShaderModule vkShaderModule = VK_NULL_HANDLE;
- auto err = vkCreateShaderModule(m_VkDevice, &ShaderModuleCI, m_VkAllocator, &vkShaderModule);
- CHECK_VK_ERROR_AND_THROW(err, "Failed to create Render Pass '", DebugName, '\'');
+ PipelineLayoutWrapper VulkanLogicalDevice::CreatePipelineLayout(const VkPipelineLayoutCreateInfo &PipelineLayoutCI, const char *DebugName)const
+ {
+ return CreateVulkanObject<VkPipelineLayout>(vkCreatePipelineLayout, PipelineLayoutCI, DebugName, "pipeline layout");
+ }
- if (DebugName != nullptr && *DebugName != 0)
- VulkanUtilities::SetShaderModuleName(m_VkDevice, vkShaderModule, DebugName);
+ FramebufferWrapper VulkanLogicalDevice::CreateFramebuffer(const VkFramebufferCreateInfo &FramebufferCI, const char *DebugName)const
+ {
+ return CreateVulkanObject<VkFramebuffer>(vkCreateFramebuffer, FramebufferCI, DebugName, "framebuffer");
+ }
- return ShaderModuleWrapper{ GetSharedPtr(), std::move(vkShaderModule) };
+ DescriptorPoolWrapper VulkanLogicalDevice::CreateDescriptorPool(const VkDescriptorPoolCreateInfo &DescrPoolCI, const char *DebugName)const
+ {
+ return CreateVulkanObject<VkDescriptorPool>(vkCreateDescriptorPool, DescrPoolCI, DebugName, "descriptor pool");
}
+ DescriptorSetLayoutWrapper VulkanLogicalDevice::CreateDescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo &LayoutCI, const char *DebugName)const
+ {
+ return CreateVulkanObject<VkDescriptorSetLayout>(vkCreateDescriptorSetLayout, LayoutCI, DebugName, "descriptor set layout");
+ }
VkCommandBuffer VulkanLogicalDevice::AllocateVkCommandBuffer(const VkCommandBufferAllocateInfo &AllocInfo, const char *DebugName)const
{
@@ -296,6 +259,12 @@ namespace VulkanUtilities
ImageView.m_VkObject = VK_NULL_HANDLE;
}
+ void VulkanLogicalDevice::ReleaseVulkanObject(SamplerWrapper&& Sampler)const
+ {
+ vkDestroySampler(m_VkDevice, Sampler.m_VkObject, m_VkAllocator);
+ Sampler.m_VkObject = VK_NULL_HANDLE;
+ }
+
void VulkanLogicalDevice::ReleaseVulkanObject(FenceWrapper&& Fence)const
{
vkDestroyFence(m_VkDevice, Fence.m_VkObject, m_VkAllocator);
@@ -326,6 +295,34 @@ namespace VulkanUtilities
ShaderModule.m_VkObject = VK_NULL_HANDLE;
}
+ void VulkanLogicalDevice::ReleaseVulkanObject(PipelineLayoutWrapper&& PipelineLayout)const
+ {
+ vkDestroyPipelineLayout(m_VkDevice, PipelineLayout.m_VkObject, m_VkAllocator);
+ PipelineLayout.m_VkObject = VK_NULL_HANDLE;
+ }
+
+ void VulkanLogicalDevice::ReleaseVulkanObject(FramebufferWrapper&& Framebuffer)const
+ {
+ vkDestroyFramebuffer(m_VkDevice, Framebuffer.m_VkObject, m_VkAllocator);
+ Framebuffer.m_VkObject = VK_NULL_HANDLE;
+ }
+
+ void VulkanLogicalDevice::ReleaseVulkanObject(DescriptorPoolWrapper&& DescriptorPool)const
+ {
+ vkDestroyDescriptorPool(m_VkDevice, DescriptorPool.m_VkObject, m_VkAllocator);
+ DescriptorPool.m_VkObject = VK_NULL_HANDLE;
+ }
+
+ void VulkanLogicalDevice::ReleaseVulkanObject(DescriptorSetLayoutWrapper&& DescriptorSetLayout)const
+ {
+ vkDestroyDescriptorSetLayout(m_VkDevice, DescriptorSetLayout.m_VkObject, m_VkAllocator);
+ DescriptorSetLayout.m_VkObject = VK_NULL_HANDLE;
+ }
+
+
+
+
+
VkMemoryRequirements VulkanLogicalDevice::GetBufferMemoryRequirements(VkBuffer vkBuffer)const
{
VkMemoryRequirements MemReqs = {};