SpiecsEngine
 
Loading...
Searching...
No Matches

◆ GetThreadComputeCommandPool()

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

Get Thread Compute 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 130 of file VulkanCommandBuffer.cpp.

131 {
133
134 std::unique_lock<std::mutex> lock(m_ComputeCommandPoolMutex);
135
136 if (!m_IsPoolActive)
137 {
138 SPICES_CORE_ERROR("CommandPool is not active.")
139 }
140
141 if (VulkanCommandPoolThreadWrapper::GetInst().m_ComputeThreadId == -1)
142 {
143 for (int i = 0; i < m_ThreadComputeCommandPool.size(); i++)
144 {
146 }
147
148 if (VulkanCommandPoolThreadWrapper::GetInst().m_ComputeThreadId == -1)
149 {
151 m_ThreadComputeCommandPool.push_back(nullptr);
152 }
153 }
154
156 {
160 VkCommandPoolCreateInfo poolInfo{};
161 poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
162 poolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
163 poolInfo.queueFamilyIndex = VulkanRenderBackend::GetState().m_ComputeQueueFamily;
164
168 VkCommandPool pool;
169 VK_CHECK(vkCreateCommandPool(VulkanRenderBackend::GetState().m_Device, &poolInfo, nullptr, &pool))
170 DEBUGUTILS_SETOBJECTNAME(VK_OBJECT_TYPE_COMMAND_POOL, reinterpret_cast<uint64_t>(pool), VulkanRenderBackend::GetState().m_Device, "ThreadComputeCommandPool")
171 m_ThreadComputeCommandPool[VulkanCommandPoolThreadWrapper::GetInst().m_ComputeThreadId] = std::move(pool);
172 }
173
174 return m_ThreadComputeCommandPool[VulkanCommandPoolThreadWrapper::GetInst().m_ComputeThreadId];
175 }
#define SPICES_PROFILE_ZONE
#define VK_CHECK(expr)
Vulkan Check macro. Verify Vulkan API Effectiveness.
Definition VulkanUtils.h:68
int m_ComputeThreadId
Thread Unique Compute ThreadId.
static VulkanCommandPoolThreadWrapper & GetInst()
Get this instance.
static bool m_IsPoolActive
True if this Pool is actived.
static std::mutex m_ComputeCommandPoolMutex
Mutex for GraphicCommandPool.
static std::vector< VkCommandPool > m_ThreadComputeCommandPool
Thread Compute VkCommandPool map.
static VulkanState & GetState()
Get VulkanState in use.
STL namespace.
uint32_t m_ComputeQueueFamily

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