Moved debug label functionality to KRDevice::createBuffer
This commit is contained in:
@@ -235,7 +235,12 @@ VmaAllocator KRDevice::getAllocator()
|
|||||||
return m_allocator;
|
return m_allocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRDevice::createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer* buffer, VmaAllocation* allocation)
|
|
||||||
|
void KRDevice::createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer* buffer, VmaAllocation* allocation
|
||||||
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
|
, const char* debug_label
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
VkBufferCreateInfo bufferInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
VkBufferCreateInfo bufferInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||||
bufferInfo.size = size;
|
bufferInfo.size = size;
|
||||||
@@ -247,6 +252,15 @@ void KRDevice::createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemor
|
|||||||
|
|
||||||
VkResult res = vmaCreateBuffer(m_allocator, &bufferInfo, &allocInfo, buffer, allocation, nullptr);
|
VkResult res = vmaCreateBuffer(m_allocator, &bufferInfo, &allocInfo, buffer, allocation, nullptr);
|
||||||
// TODO - Error Handling...
|
// TODO - Error Handling...
|
||||||
|
|
||||||
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
|
VkDebugUtilsObjectNameInfoEXT debugInfo{};
|
||||||
|
debugInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
||||||
|
debugInfo.objectHandle = (uint64_t)*buffer;
|
||||||
|
debugInfo.objectType = VK_OBJECT_TYPE_BUFFER;
|
||||||
|
debugInfo.pObjectName = debug_label;
|
||||||
|
res = vkSetDebugUtilsObjectNameEXT(m_logicalDevice, &debugInfo);
|
||||||
|
#endif // KRENGINE_DEBUG_GPU_LABELS
|
||||||
}
|
}
|
||||||
|
|
||||||
KrResult KRDevice::selectSurfaceFormat(VkSurfaceKHR& surface, VkSurfaceFormatKHR& selectedFormat)
|
KrResult KRDevice::selectSurfaceFormat(VkSurfaceKHR& surface, VkSurfaceFormatKHR& selectedFormat)
|
||||||
|
|||||||
@@ -47,7 +47,11 @@ public:
|
|||||||
bool initialize(const std::vector<const char*>& deviceExtensions);
|
bool initialize(const std::vector<const char*>& deviceExtensions);
|
||||||
|
|
||||||
VmaAllocator getAllocator();
|
VmaAllocator getAllocator();
|
||||||
void createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer* buffer, VmaAllocation* allocation);
|
void createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer* buffer, VmaAllocation* allocation
|
||||||
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
|
, const char* debug_label
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
KrResult selectSurfaceFormat(VkSurfaceKHR& surface, VkSurfaceFormatKHR& surfaceFormat);
|
KrResult selectSurfaceFormat(VkSurfaceKHR& surface, VkSurfaceFormatKHR& surfaceFormat);
|
||||||
KrResult selectDepthFormat(VkFormat& selectedDepthFormat);
|
KrResult selectDepthFormat(VkFormat& selectedDepthFormat);
|
||||||
|
|||||||
@@ -545,16 +545,6 @@ void KRMeshManager::KRVBOData::load()
|
|||||||
AllocationInfo& allocation = m_allocations[iAllocation];
|
AllocationInfo& allocation = m_allocations[iAllocation];
|
||||||
allocation.device = deviceHandle;
|
allocation.device = deviceHandle;
|
||||||
|
|
||||||
device.createBuffer(
|
|
||||||
m_data->getSize(),
|
|
||||||
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
|
||||||
&allocation.vertex_buffer,
|
|
||||||
&allocation.vertex_allocation
|
|
||||||
);
|
|
||||||
|
|
||||||
// TODO - Use staging buffers
|
|
||||||
|
|
||||||
#if KRENGINE_DEBUG_GPU_LABELS
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
char debug_label[KRENGINE_DEBUG_GPU_LABEL_MAX_LEN];
|
char debug_label[KRENGINE_DEBUG_GPU_LABEL_MAX_LEN];
|
||||||
|
|
||||||
@@ -575,15 +565,21 @@ void KRMeshManager::KRVBOData::load()
|
|||||||
}
|
}
|
||||||
|
|
||||||
snprintf(debug_label, KRENGINE_DEBUG_GPU_LABEL_MAX_LEN, "%s Vertices: %s", type_label, m_debugLabel);
|
snprintf(debug_label, KRENGINE_DEBUG_GPU_LABEL_MAX_LEN, "%s Vertices: %s", type_label, m_debugLabel);
|
||||||
|
|
||||||
VkDebugUtilsObjectNameInfoEXT debugInfo{};
|
|
||||||
debugInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
|
||||||
debugInfo.objectHandle = (uint64_t)allocation.vertex_buffer;
|
|
||||||
debugInfo.objectType = VK_OBJECT_TYPE_BUFFER;
|
|
||||||
debugInfo.pObjectName = debug_label;
|
|
||||||
VkResult res = vkSetDebugUtilsObjectNameEXT(device.m_logicalDevice, &debugInfo);
|
|
||||||
#endif // KRENGINE_DEBUG_GPU_LABELS
|
#endif // KRENGINE_DEBUG_GPU_LABELS
|
||||||
|
|
||||||
|
device.createBuffer(
|
||||||
|
m_data->getSize(),
|
||||||
|
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
||||||
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
||||||
|
&allocation.vertex_buffer,
|
||||||
|
&allocation.vertex_allocation
|
||||||
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
|
, debug_label
|
||||||
|
#endif // KRENGINE_DEBUG_GPU_LABELS
|
||||||
|
);
|
||||||
|
|
||||||
|
// TODO - Use staging buffers
|
||||||
|
|
||||||
void* mappedData = nullptr;
|
void* mappedData = nullptr;
|
||||||
m_data->lock();
|
m_data->lock();
|
||||||
vmaMapMemory(allocator, allocation.vertex_allocation, &mappedData);
|
vmaMapMemory(allocator, allocation.vertex_allocation, &mappedData);
|
||||||
@@ -592,24 +588,20 @@ void KRMeshManager::KRVBOData::load()
|
|||||||
m_data->unlock();
|
m_data->unlock();
|
||||||
|
|
||||||
if (m_index_data->getSize() > 0) {
|
if (m_index_data->getSize() > 0) {
|
||||||
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
|
snprintf(debug_label, KRENGINE_DEBUG_GPU_LABEL_MAX_LEN, "%s Indexes: %s", type_label, m_debugLabel);
|
||||||
|
#endif // KRENGINE_DEBUG_GPU_LABELS
|
||||||
device.createBuffer(
|
device.createBuffer(
|
||||||
m_index_data->getSize(),
|
m_index_data->getSize(),
|
||||||
VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
||||||
&allocation.index_buffer,
|
&allocation.index_buffer,
|
||||||
&allocation.index_allocation
|
&allocation.index_allocation
|
||||||
|
#if KRENGINE_DEBUG_GPU_LABELS
|
||||||
|
, debug_label
|
||||||
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
#if KRENGINE_DEBUG_GPU_LABELS
|
|
||||||
snprintf(debug_label, KRENGINE_DEBUG_GPU_LABEL_MAX_LEN, "%s Indexes: %s", type_label, m_debugLabel);
|
|
||||||
|
|
||||||
VkDebugUtilsObjectNameInfoEXT debugInfo{};
|
|
||||||
debugInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
|
||||||
debugInfo.objectHandle = (uint64_t)allocation.index_buffer;
|
|
||||||
debugInfo.objectType = VK_OBJECT_TYPE_BUFFER;
|
|
||||||
debugInfo.pObjectName = debug_label;
|
|
||||||
res = vkSetDebugUtilsObjectNameEXT(device.m_logicalDevice, &debugInfo);
|
|
||||||
#endif // KRENGINE_DEBUG_GPU_LABELS
|
|
||||||
mappedData = nullptr;
|
mappedData = nullptr;
|
||||||
m_index_data->lock();
|
m_index_data->lock();
|
||||||
vmaMapMemory(allocator, allocation.index_allocation, &mappedData);
|
vmaMapMemory(allocator, allocation.index_allocation, &mappedData);
|
||||||
|
|||||||
Reference in New Issue
Block a user