summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-11-29 18:22:52 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-11-29 18:22:52 +0000
commitc13e13a5fe6848a462c9c05e5b4e1724eec62323 (patch)
tree7685dd40855872fe4114c518013179dc1537363d /Graphics/GraphicsEngineVulkan
parentFixed few vector initialization issues (diff)
downloadDiligentCore-c13e13a5fe6848a462c9c05e5b4e1724eec62323.tar.gz
DiligentCore-c13e13a5fe6848a462c9c05e5b4e1724eec62323.zip
Vulkan backend: fixed 32-bit build
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/CMakeLists.txt7
-rw-r--r--Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h24
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h75
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h6
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp6
-rw-r--r--Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp63
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp45
10 files changed, 139 insertions, 93 deletions
diff --git a/Graphics/GraphicsEngineVulkan/CMakeLists.txt b/Graphics/GraphicsEngineVulkan/CMakeLists.txt
index 85c93332..afa73a10 100644
--- a/Graphics/GraphicsEngineVulkan/CMakeLists.txt
+++ b/Graphics/GraphicsEngineVulkan/CMakeLists.txt
@@ -177,7 +177,12 @@ set(PRIVATE_DEPENDENCIES
)
if(PLATFORM_WIN32)
- find_library(Vulkan_LIBRARY NAMES vulkan-1 vulkan PATHS "../../ThirdParty/vulkan/libs/windows")
+ if(${ARCH} EQUAL 64)
+ set(VULKAN_LIB_FOLDER x64)
+ else()
+ set(VULKAN_LIB_FOLDER x86)
+ endif()
+ find_library(Vulkan_LIBRARY NAMES vulkan-1 vulkan PATHS "../../ThirdParty/vulkan/libs/windows/${VULKAN_LIB_FOLDER}")
elseif(PLATFORM_MACOS)
find_library(Vulkan_LIBRARY NAMES vulkan.1 vulkan PATHS "../../ThirdParty/vulkan/libs/macOS")
elseif(PLATFORM_IOS)
diff --git a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h
index 9462b423..cf8923f3 100644
--- a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h
@@ -94,7 +94,7 @@ public:
virtual void* GetNativeHandle() override final
{
auto vkBuffer = GetVkBuffer();
- return vkBuffer;
+ return reinterpret_cast<void*>(vkBuffer);
}
/// Implementation of IBufferVk::SetAccessFlags().
diff --git a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h
index 4a75bdc1..51f98427 100644
--- a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h
@@ -73,7 +73,7 @@ public:
virtual void* GetNativeHandle() override final
{
auto vkImage = GetVkImage();
- return vkImage;
+ return reinterpret_cast<void*>(vkImage);
}
/// Implementation of ITextureVk::SetLayout().
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h
index 60ba5410..35f8826b 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h
@@ -92,26 +92,10 @@ void SetSemaphoreName (VkDevice device, VkSemaphore semaphor
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);
+enum class VulkanHandleTypeId : uint32_t;
+
+template<typename VulkanObjectType, VulkanHandleTypeId>
+void SetVulkanObjectName(VkDevice device, VulkanObjectType vkObject, const char * name);
const char* VkResultToString (VkResult errorCode);
const char* VkAccessFlagBitToString(VkAccessFlagBits Bit);
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
index 11a8b951..6ff00801 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
@@ -29,25 +29,53 @@
namespace VulkanUtilities
{
-template <typename VulkanObjectType>
+// In 32-bit version, all Vulkan handles are typedefed as uint64_t, so we have to
+// use VulkanHandleTypeId to distinguish objects.
+enum class VulkanHandleTypeId : uint32_t
+{
+ CommandPool,
+ CommandBuffer,
+ Buffer,
+ BufferView,
+ Image,
+ ImageView,
+ DeviceMemory,
+ Fence,
+ RenderPass,
+ Pipeline,
+ ShaderModule,
+ PipelineLayout,
+ Sampler,
+ Framebuffer,
+ DescriptorPool,
+ DescriptorSetLayout,
+ DescriptorSet,
+ Semaphore,
+ Queue,
+ Event
+};
+
+template <typename VulkanObjectType, VulkanHandleTypeId>
class VulkanObjectWrapper;
-using CommandPoolWrapper = VulkanObjectWrapper<VkCommandPool>;
-using BufferWrapper = VulkanObjectWrapper<VkBuffer>;
-using BufferViewWrapper = VulkanObjectWrapper<VkBufferView>;
-using ImageWrapper = VulkanObjectWrapper<VkImage>;
-using ImageViewWrapper = VulkanObjectWrapper<VkImageView>;
-using DeviceMemoryWrapper = VulkanObjectWrapper<VkDeviceMemory>;
-using FenceWrapper = VulkanObjectWrapper<VkFence>;
-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>;
-using SemaphoreWrapper = VulkanObjectWrapper<VkSemaphore>;
+#define DEFINE_VULKAN_OBJECT_WRAPPER(Type) VulkanObjectWrapper<Vk##Type, VulkanHandleTypeId::Type>
+using CommandPoolWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(CommandPool);
+using BufferWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(Buffer);
+using BufferViewWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(BufferView);
+using ImageWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(Image);
+using ImageViewWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(ImageView);
+using DeviceMemoryWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(DeviceMemory);
+using FenceWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(Fence);
+using RenderPassWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(RenderPass);
+using PipelineWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(Pipeline);
+using ShaderModuleWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(ShaderModule);
+using PipelineLayoutWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(PipelineLayout);
+using SamplerWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(Sampler);
+using FramebufferWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(Framebuffer);
+using DescriptorPoolWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(DescriptorPool);
+using DescriptorSetLayoutWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(DescriptorSetLayout);
+using SemaphoreWrapper = DEFINE_VULKAN_OBJECT_WRAPPER(Semaphore);
+#undef DEFINE_VULKAN_OBJECT_WRAPPER
class VulkanLogicalDevice : public std::enable_shared_from_this<VulkanLogicalDevice>
{
@@ -166,11 +194,14 @@ private:
const VkDeviceCreateInfo& DeviceCI,
const VkAllocationCallbacks* vkAllocator);
- template <typename VkObjectType, typename VkCreateObjectFuncType, typename VkObjectCreateInfoType>
- VulkanObjectWrapper<VkObjectType> CreateVulkanObject(VkCreateObjectFuncType VkCreateObject,
- const VkObjectCreateInfoType& CreateInfo,
- const char* DebugName,
- const char* ObjectType) const;
+ template <typename VkObjectType,
+ VulkanHandleTypeId VkTypeId,
+ typename VkCreateObjectFuncType,
+ typename VkObjectCreateInfoType>
+ VulkanObjectWrapper<VkObjectType, VkTypeId> 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 aac72c03..5e44a63d 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h
@@ -29,7 +29,11 @@
namespace VulkanUtilities
{
-template <typename VulkanObjectType>
+// In 32-bit version, all Vulkan handles are typedefed as uint64_t, so we have to
+// use another way to distinguish objects.
+enum class VulkanHandleTypeId : uint32_t;
+
+template <typename VulkanObjectType, VulkanHandleTypeId>
class VulkanObjectWrapper
{
public:
diff --git a/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp b/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp
index b2bf3680..9ef6cb9d 100644
--- a/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DescriptorPoolManager.cpp
@@ -32,7 +32,7 @@ void DescriptorSetAllocation::Release()
{
if (Set != VK_NULL_HANDLE)
{
- VERIFY_EXPR(DescrSetAllocator != nullptr && Pool != nullptr);
+ VERIFY_EXPR(DescrSetAllocator != nullptr && Pool != VK_NULL_HANDLE);
DescrSetAllocator->FreeDescriptorSet(Set, Pool, CmdQueueMask);
Reset();
@@ -219,8 +219,8 @@ void DescriptorSetAllocator::FreeDescriptorSet(VkDescriptorSet Set, VkDescriptor
Pool {rhs.Pool }
{
rhs.Allocator = nullptr;
- rhs.Set = nullptr;
- rhs.Pool = nullptr;
+ rhs.Set = VK_NULL_HANDLE;
+ rhs.Pool = VK_NULL_HANDLE;
}
// clang-format on
diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
index 665fa5d8..35f2b1ad 100644
--- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
@@ -146,7 +146,7 @@ RenderDeviceVkImpl::RenderDeviceVkImpl(IReferenceCounters*
m_DeviceCaps.MinorVersion = 0;
m_DeviceCaps.bSeparableProgramSupported = True;
m_DeviceCaps.bMultithreadedResourceCreationSupported = True;
- for (int fmt = 1; fmt < m_TextureFormatsInfo.size(); ++fmt)
+ for (Uint32 fmt = 1; fmt < m_TextureFormatsInfo.size(); ++fmt)
m_TextureFormatsInfo[fmt].Supported = true; // We will test every format on a specific hardware device
m_DeviceCaps.bGeometryShadersSupported = EngineCI.EnabledFeatures.geometryShader;
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp
index c4781196..776135d1 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDebug.cpp
@@ -12,6 +12,7 @@
#include <cstring>
#include "VulkanUtilities/VulkanDebug.h"
+#include "VulkanUtilities/VulkanLogicalDevice.h"
#include "Errors.h"
#include "DebugUtilities.h"
@@ -395,104 +396,122 @@ void SetEventName(VkDevice device, VkEvent _event, const char* name)
}
-
-
-void SetVulkanObjectName(VkDevice device, VkCommandPool cmdPool, const char* name)
+template <>
+void SetVulkanObjectName<VkCommandPool, VulkanHandleTypeId::CommandPool>(VkDevice device, VkCommandPool cmdPool, const char* name)
{
SetCommandPoolName(device, cmdPool, name);
}
-void SetVulkanObjectName(VkDevice device, VkCommandBuffer cmdBuffer, const char* name)
+template <>
+void SetVulkanObjectName<VkCommandBuffer, VulkanHandleTypeId::CommandBuffer>(VkDevice device, VkCommandBuffer cmdBuffer, const char* name)
{
SetCommandBufferName(device, cmdBuffer, name);
}
-void SetVulkanObjectName(VkDevice device, VkQueue queue, const char* name)
+template <>
+void SetVulkanObjectName<VkQueue, VulkanHandleTypeId::Queue>(VkDevice device, VkQueue queue, const char* name)
{
SetQueueName(device, queue, name);
}
-void SetVulkanObjectName(VkDevice device, VkImage image, const char* name)
+template <>
+void SetVulkanObjectName<VkImage, VulkanHandleTypeId::Image>(VkDevice device, VkImage image, const char* name)
{
SetImageName(device, image, name);
}
-void SetVulkanObjectName(VkDevice device, VkImageView imageView, const char* name)
+template <>
+void SetVulkanObjectName<VkImageView, VulkanHandleTypeId::ImageView>(VkDevice device, VkImageView imageView, const char* name)
{
SetImageViewName(device, imageView, name);
}
-void SetVulkanObjectName(VkDevice device, VkSampler sampler, const char* name)
+template <>
+void SetVulkanObjectName<VkSampler, VulkanHandleTypeId::Sampler>(VkDevice device, VkSampler sampler, const char* name)
{
SetSamplerName(device, sampler, name);
}
-void SetVulkanObjectName(VkDevice device, VkBuffer buffer, const char* name)
+template <>
+void SetVulkanObjectName<VkBuffer, VulkanHandleTypeId::Buffer>(VkDevice device, VkBuffer buffer, const char* name)
{
SetBufferName(device, buffer, name);
}
-void SetVulkanObjectName(VkDevice device, VkBufferView bufferView, const char* name)
+template <>
+void SetVulkanObjectName<VkBufferView, VulkanHandleTypeId::BufferView>(VkDevice device, VkBufferView bufferView, const char* name)
{
SetBufferViewName(device, bufferView, name);
}
-void SetVulkanObjectName(VkDevice device, VkDeviceMemory memory, const char* name)
+template <>
+void SetVulkanObjectName<VkDeviceMemory, VulkanHandleTypeId::DeviceMemory>(VkDevice device, VkDeviceMemory memory, const char* name)
{
SetDeviceMemoryName(device, memory, name);
}
-void SetVulkanObjectName(VkDevice device, VkShaderModule shaderModule, const char* name)
+template <>
+void SetVulkanObjectName<VkShaderModule, VulkanHandleTypeId::ShaderModule>(VkDevice device, VkShaderModule shaderModule, const char* name)
{
SetShaderModuleName(device, shaderModule, name);
}
-void SetVulkanObjectName(VkDevice device, VkPipeline pipeline, const char* name)
+template <>
+void SetVulkanObjectName<VkPipeline, VulkanHandleTypeId::Pipeline>(VkDevice device, VkPipeline pipeline, const char* name)
{
SetPipelineName(device, pipeline, name);
}
-void SetVulkanObjectName(VkDevice device, VkPipelineLayout pipelineLayout, const char* name)
+template <>
+void SetVulkanObjectName<VkPipelineLayout, VulkanHandleTypeId::PipelineLayout>(VkDevice device, VkPipelineLayout pipelineLayout, const char* name)
{
SetPipelineLayoutName(device, pipelineLayout, name);
}
-void SetVulkanObjectName(VkDevice device, VkRenderPass renderPass, const char* name)
+template <>
+void SetVulkanObjectName<VkRenderPass, VulkanHandleTypeId::RenderPass>(VkDevice device, VkRenderPass renderPass, const char* name)
{
SetRenderPassName(device, renderPass, name);
}
-void SetVulkanObjectName(VkDevice device, VkFramebuffer framebuffer, const char* name)
+template <>
+void SetVulkanObjectName<VkFramebuffer, VulkanHandleTypeId::Framebuffer>(VkDevice device, VkFramebuffer framebuffer, const char* name)
{
SetFramebufferName(device, framebuffer, name);
}
-void SetVulkanObjectName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char* name)
+template <>
+void SetVulkanObjectName<VkDescriptorSetLayout, VulkanHandleTypeId::DescriptorSetLayout>(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char* name)
{
SetDescriptorSetLayoutName(device, descriptorSetLayout, name);
}
-void SetVulkanObjectName(VkDevice device, VkDescriptorSet descriptorSet, const char* name)
+template <>
+void SetVulkanObjectName<VkDescriptorSet, VulkanHandleTypeId::DescriptorSet>(VkDevice device, VkDescriptorSet descriptorSet, const char* name)
{
SetDescriptorSetName(device, descriptorSet, name);
}
-void SetVulkanObjectName(VkDevice device, VkDescriptorPool descriptorPool, const char* name)
+template <>
+void SetVulkanObjectName<VkDescriptorPool, VulkanHandleTypeId::DescriptorPool>(VkDevice device, VkDescriptorPool descriptorPool, const char* name)
{
SetDescriptorPoolName(device, descriptorPool, name);
}
-void SetVulkanObjectName(VkDevice device, VkSemaphore semaphore, const char* name)
+template <>
+void SetVulkanObjectName<VkSemaphore, VulkanHandleTypeId::Semaphore>(VkDevice device, VkSemaphore semaphore, const char* name)
{
SetSemaphoreName(device, semaphore, name);
}
-void SetVulkanObjectName(VkDevice device, VkFence fence, const char* name)
+template <>
+void SetVulkanObjectName<VkFence, VulkanHandleTypeId::Fence>(VkDevice device, VkFence fence, const char* name)
{
SetFenceName(device, fence, name);
}
-void SetVulkanObjectName(VkDevice device, VkEvent _event, const char* name)
+template <>
+void SetVulkanObjectName<VkEvent, VulkanHandleTypeId::Event>(VkDevice device, VkEvent _event, const char* name)
{
SetEventName(device, _event, name);
}
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
index d43ac776..0b7a6e19 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
@@ -76,11 +76,14 @@ void VulkanLogicalDevice::WaitIdle() const
(void)err;
}
-template <typename VkObjectType, typename VkCreateObjectFuncType, typename VkObjectCreateInfoType>
-VulkanObjectWrapper<VkObjectType> VulkanLogicalDevice::CreateVulkanObject(VkCreateObjectFuncType VkCreateObject,
- const VkObjectCreateInfoType& CreateInfo,
- const char* DebugName,
- const char* ObjectType) const
+template <typename VkObjectType,
+ VulkanHandleTypeId VkTypeId,
+ typename VkCreateObjectFuncType,
+ typename VkObjectCreateInfoType>
+VulkanObjectWrapper<VkObjectType, VkTypeId> VulkanLogicalDevice::CreateVulkanObject(VkCreateObjectFuncType VkCreateObject,
+ const VkObjectCreateInfoType& CreateInfo,
+ const char* DebugName,
+ const char* ObjectType) const
{
if (DebugName == nullptr)
DebugName = "";
@@ -91,62 +94,62 @@ VulkanObjectWrapper<VkObjectType> VulkanLogicalDevice::CreateVulkanObject(VkCrea
CHECK_VK_ERROR_AND_THROW(err, "Failed to create Vulkan ", ObjectType, " '", DebugName, '\'');
if (DebugName != nullptr && *DebugName != 0)
- SetVulkanObjectName(m_VkDevice, VkObject, DebugName);
+ SetVulkanObjectName<VkObjectType, VkTypeId>(m_VkDevice, VkObject, DebugName);
- return VulkanObjectWrapper<VkObjectType>{GetSharedPtr(), std::move(VkObject)};
+ return VulkanObjectWrapper<VkObjectType, VkTypeId>{GetSharedPtr(), std::move(VkObject)};
}
CommandPoolWrapper VulkanLogicalDevice::CreateCommandPool(const VkCommandPoolCreateInfo& CmdPoolCI,
const char* DebugName) const
{
VERIFY_EXPR(CmdPoolCI.sType == VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO);
- return CreateVulkanObject<VkCommandPool>(vkCreateCommandPool, CmdPoolCI, DebugName, "command pool");
+ return CreateVulkanObject<VkCommandPool, VulkanHandleTypeId::CommandPool>(vkCreateCommandPool, CmdPoolCI, DebugName, "command pool");
}
BufferWrapper VulkanLogicalDevice::CreateBuffer(const VkBufferCreateInfo& BufferCI,
const char* DebugName) const
{
VERIFY_EXPR(BufferCI.sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
- return CreateVulkanObject<VkBuffer>(vkCreateBuffer, BufferCI, DebugName, "buffer");
+ return CreateVulkanObject<VkBuffer, VulkanHandleTypeId::Buffer>(vkCreateBuffer, BufferCI, DebugName, "buffer");
}
BufferViewWrapper VulkanLogicalDevice::CreateBufferView(const VkBufferViewCreateInfo& BuffViewCI,
const char* DebugName) const
{
VERIFY_EXPR(BuffViewCI.sType == VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO);
- return CreateVulkanObject<VkBufferView>(vkCreateBufferView, BuffViewCI, DebugName, "buffer view");
+ return CreateVulkanObject<VkBufferView, VulkanHandleTypeId::BufferView>(vkCreateBufferView, BuffViewCI, DebugName, "buffer view");
}
ImageWrapper VulkanLogicalDevice::CreateImage(const VkImageCreateInfo& ImageCI,
const char* DebugName) const
{
VERIFY_EXPR(ImageCI.sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO);
- return CreateVulkanObject<VkImage>(vkCreateImage, ImageCI, DebugName, "image");
+ return CreateVulkanObject<VkImage, VulkanHandleTypeId::Image>(vkCreateImage, ImageCI, DebugName, "image");
}
ImageViewWrapper VulkanLogicalDevice::CreateImageView(const VkImageViewCreateInfo& ImageViewCI,
const char* DebugName) const
{
VERIFY_EXPR(ImageViewCI.sType == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO);
- return CreateVulkanObject<VkImageView>(vkCreateImageView, ImageViewCI, DebugName, "image view");
+ return CreateVulkanObject<VkImageView, VulkanHandleTypeId::ImageView>(vkCreateImageView, ImageViewCI, DebugName, "image view");
}
SamplerWrapper VulkanLogicalDevice::CreateSampler(const VkSamplerCreateInfo& SamplerCI, const char* DebugName) const
{
VERIFY_EXPR(SamplerCI.sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
- return CreateVulkanObject<VkSampler>(vkCreateSampler, SamplerCI, DebugName, "sampler");
+ return CreateVulkanObject<VkSampler, VulkanHandleTypeId::Sampler>(vkCreateSampler, SamplerCI, DebugName, "sampler");
}
FenceWrapper VulkanLogicalDevice::CreateFence(const VkFenceCreateInfo& FenceCI, const char* DebugName) const
{
VERIFY_EXPR(FenceCI.sType == VK_STRUCTURE_TYPE_FENCE_CREATE_INFO);
- return CreateVulkanObject<VkFence>(vkCreateFence, FenceCI, DebugName, "fence");
+ return CreateVulkanObject<VkFence, VulkanHandleTypeId::Fence>(vkCreateFence, FenceCI, DebugName, "fence");
}
RenderPassWrapper VulkanLogicalDevice::CreateRenderPass(const VkRenderPassCreateInfo& RenderPassCI, const char* DebugName) const
{
VERIFY_EXPR(RenderPassCI.sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO);
- return CreateVulkanObject<VkRenderPass>(vkCreateRenderPass, RenderPassCI, DebugName, "render pass");
+ return CreateVulkanObject<VkRenderPass, VulkanHandleTypeId::RenderPass>(vkCreateRenderPass, RenderPassCI, DebugName, "render pass");
}
DeviceMemoryWrapper VulkanLogicalDevice::AllocateDeviceMemory(const VkMemoryAllocateInfo& AllocInfo,
@@ -211,37 +214,37 @@ PipelineWrapper VulkanLogicalDevice::CreateGraphicsPipeline(const VkGraphicsPipe
ShaderModuleWrapper VulkanLogicalDevice::CreateShaderModule(const VkShaderModuleCreateInfo& ShaderModuleCI, const char* DebugName) const
{
VERIFY_EXPR(ShaderModuleCI.sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO);
- return CreateVulkanObject<VkShaderModule>(vkCreateShaderModule, ShaderModuleCI, DebugName, "shader module");
+ return CreateVulkanObject<VkShaderModule, VulkanHandleTypeId::ShaderModule>(vkCreateShaderModule, ShaderModuleCI, DebugName, "shader module");
}
PipelineLayoutWrapper VulkanLogicalDevice::CreatePipelineLayout(const VkPipelineLayoutCreateInfo& PipelineLayoutCI, const char* DebugName) const
{
VERIFY_EXPR(PipelineLayoutCI.sType == VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO);
- return CreateVulkanObject<VkPipelineLayout>(vkCreatePipelineLayout, PipelineLayoutCI, DebugName, "pipeline layout");
+ return CreateVulkanObject<VkPipelineLayout, VulkanHandleTypeId::PipelineLayout>(vkCreatePipelineLayout, PipelineLayoutCI, DebugName, "pipeline layout");
}
FramebufferWrapper VulkanLogicalDevice::CreateFramebuffer(const VkFramebufferCreateInfo& FramebufferCI, const char* DebugName) const
{
VERIFY_EXPR(FramebufferCI.sType == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO);
- return CreateVulkanObject<VkFramebuffer>(vkCreateFramebuffer, FramebufferCI, DebugName, "framebuffer");
+ return CreateVulkanObject<VkFramebuffer, VulkanHandleTypeId::Framebuffer>(vkCreateFramebuffer, FramebufferCI, DebugName, "framebuffer");
}
DescriptorPoolWrapper VulkanLogicalDevice::CreateDescriptorPool(const VkDescriptorPoolCreateInfo& DescrPoolCI, const char* DebugName) const
{
VERIFY_EXPR(DescrPoolCI.sType == VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO);
- return CreateVulkanObject<VkDescriptorPool>(vkCreateDescriptorPool, DescrPoolCI, DebugName, "descriptor pool");
+ return CreateVulkanObject<VkDescriptorPool, VulkanHandleTypeId::DescriptorPool>(vkCreateDescriptorPool, DescrPoolCI, DebugName, "descriptor pool");
}
DescriptorSetLayoutWrapper VulkanLogicalDevice::CreateDescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo& LayoutCI, const char* DebugName) const
{
VERIFY_EXPR(LayoutCI.sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO);
- return CreateVulkanObject<VkDescriptorSetLayout>(vkCreateDescriptorSetLayout, LayoutCI, DebugName, "descriptor set layout");
+ return CreateVulkanObject<VkDescriptorSetLayout, VulkanHandleTypeId::DescriptorSetLayout>(vkCreateDescriptorSetLayout, LayoutCI, DebugName, "descriptor set layout");
}
SemaphoreWrapper VulkanLogicalDevice::CreateSemaphore(const VkSemaphoreCreateInfo& SemaphoreCI, const char* DebugName) const
{
VERIFY_EXPR(SemaphoreCI.sType == VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO);
- return CreateVulkanObject<VkSemaphore>(vkCreateSemaphore, SemaphoreCI, DebugName, "semaphore");
+ return CreateVulkanObject<VkSemaphore, VulkanHandleTypeId::Semaphore>(vkCreateSemaphore, SemaphoreCI, DebugName, "semaphore");
}
VkCommandBuffer VulkanLogicalDevice::AllocateVkCommandBuffer(const VkCommandBufferAllocateInfo& AllocInfo, const char* DebugName) const