SpiecsEngine
 
Loading...
Searching...
No Matches

◆ GetThreadGraphicCommandPool()

VkCommandPool & Spices::VulkanCommandPool::GetThreadGraphicCommandPool ( )
static

Get Thread Graphic VkCommandPool by thread id.

Returns
Returns thread VkCommandPool.

Instanced a VkCommandPoolCreateInfo with default value.

Create commandpool and set it global.

Instanced a VkCommandPoolCreateInfo with default value.

Create commandpool and set it global.

Definition at line 83 of file VulkanCommandBuffer.cpp.

84 {
86
87 std::unique_lock<std::mutex> lock(m_GraphicCommandPoolMutex);
88
89 if (!m_IsPoolActive)
90 {
91 SPICES_CORE_ERROR("CommandPool is not active.")
92 }
93
94 if(VulkanCommandPoolThreadWrapper::GetInst().m_GraphicThreadId == -1)
95 {
96 for (int i = 0; i < m_ThreadGraphicCommandPool.size(); i++)
97 {
99 }
100
101 if (VulkanCommandPoolThreadWrapper::GetInst().m_GraphicThreadId == -1)
102 {
104 m_ThreadGraphicCommandPool.push_back(nullptr);
105 }
106 }
107
109 {
113 VkCommandPoolCreateInfo poolInfo{};
114 poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
115 poolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
116 poolInfo.queueFamilyIndex = VulkanRenderBackend::GetState().m_GraphicQueueFamily;
117
121 VkCommandPool pool;
122 VK_CHECK(vkCreateCommandPool(VulkanRenderBackend::GetState().m_Device, &poolInfo, nullptr, &pool))
123 DEBUGUTILS_SETOBJECTNAME(VK_OBJECT_TYPE_COMMAND_POOL, reinterpret_cast<uint64_t>(pool), VulkanRenderBackend::GetState().m_Device, "ThreadGraphicCommandPool")
124 m_ThreadGraphicCommandPool[VulkanCommandPoolThreadWrapper::GetInst().m_GraphicThreadId] = std::move(pool);
125 }
126
127 return m_ThreadGraphicCommandPool[VulkanCommandPoolThreadWrapper::GetInst().m_GraphicThreadId];
128 }
#define SPICES_PROFILE_ZONE
#define VK_CHECK(expr)
Vulkan Check macro. Verify Vulkan API Effectiveness.
Definition VulkanUtils.h:68
int m_GraphicThreadId
Thread Unique Graphic ThreadId.
static VulkanCommandPoolThreadWrapper & GetInst()
Get this instance.
static std::vector< VkCommandPool > m_ThreadGraphicCommandPool
Thread Graphic VkCommandPool map.
static bool m_IsPoolActive
True if this Pool is actived.
static std::mutex m_GraphicCommandPoolMutex
Mutex for GraphicCommandPool.
static VulkanState & GetState()
Get VulkanState in use.
STL namespace.
uint32_t m_GraphicQueueFamily

References Spices::VulkanCommandPoolThreadWrapper::GetInst(), Spices::VulkanCommandPoolThreadWrapper::m_GraphicThreadId, and m_IsPoolActive.