diff --git a/kraken/KRDevice.cpp b/kraken/KRDevice.cpp index 90901f4..aae7db8 100644 --- a/kraken/KRDevice.cpp +++ b/kraken/KRDevice.cpp @@ -475,7 +475,11 @@ void KRDevice::getQueueFamiliesForSharing(uint32_t* queueFamilyIndices, uint32_t } } -bool KRDevice::createImage(Vector2i dimensions, VkImageCreateFlags imageCreateFlags, VkMemoryPropertyFlags properties, VkImage* image, VmaAllocation* allocation) +bool KRDevice::createImage(Vector2i dimensions, VkImageCreateFlags imageCreateFlags, VkMemoryPropertyFlags properties, VkImage* image, VmaAllocation* allocation +#if KRENGINE_DEBUG_GPU_LABELS + , const char* debug_label +#endif +) { VkImageCreateInfo imageInfo{}; imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; @@ -506,6 +510,14 @@ bool KRDevice::createImage(Vector2i dimensions, VkImageCreateFlags imageCreateFl if (res != VK_SUCCESS) { return false; } +#if KRENGINE_DEBUG_GPU_LABELS + VkDebugUtilsObjectNameInfoEXT debugInfo{}; + debugInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT; + debugInfo.objectHandle = (uint64_t)*image; + debugInfo.objectType = VK_OBJECT_TYPE_IMAGE; + debugInfo.pObjectName = debug_label; + res = vkSetDebugUtilsObjectNameEXT(m_logicalDevice, &debugInfo); +#endif // KRENGINE_DEBUG_GPU_LABELS return true; } diff --git a/kraken/KRDevice.h b/kraken/KRDevice.h index 4862490..8a1fd86 100644 --- a/kraken/KRDevice.h +++ b/kraken/KRDevice.h @@ -55,7 +55,11 @@ public: #endif ); - bool createImage(Vector2i dimensions, VkImageCreateFlags imageCreateFlags, VkMemoryPropertyFlags properties, VkImage* image, VmaAllocation* allocation); + bool createImage(Vector2i dimensions, VkImageCreateFlags imageCreateFlags, VkMemoryPropertyFlags properties, VkImage* image, VmaAllocation* allocation +#if KRENGINE_DEBUG_GPU_LABELS + , const char* debug_label +#endif + ); KrResult selectSurfaceFormat(VkSurfaceKHR& surface, VkSurfaceFormatKHR& surfaceFormat); KrResult selectDepthFormat(VkFormat& selectedDepthFormat); diff --git a/kraken/KRTexture.cpp b/kraken/KRTexture.cpp index bdcdf23..9e08a77 100755 --- a/kraken/KRTexture.cpp +++ b/kraken/KRTexture.cpp @@ -118,7 +118,9 @@ void KRTexture::resize(int max_dim) getContext().getTextureManager()->memoryChanged(m_newTextureMemUsed); getContext().getTextureManager()->addMemoryTransferredThisFrame(m_newTextureMemUsed); - if(!createGPUTexture(target_dim)) { + if (createGPUTexture(target_dim)) { + m_new_lod_max_dim = target_dim; + } else { getContext().getTextureManager()->memoryChanged(-m_newTextureMemUsed); m_newTextureMemUsed = 0; assert(false); // Failed to create the texture @@ -131,7 +133,7 @@ void KRTexture::resize(int max_dim) } GLuint KRTexture::getHandle() { - assert(false); // TODO - Vulkan refactoring required + // assert(false); // TODO - Vulkan refactoring required resetPoolExpiry(0.0f, KRTexture::TEXTURE_USAGE_NONE); // TODO - Pass through getHandle() arguements to replace extraneous resetPoolExpiry calls? return 0; } diff --git a/kraken/KRTexture2D.cpp b/kraken/KRTexture2D.cpp index eb70173..1c2a5d7 100755 --- a/kraken/KRTexture2D.cpp +++ b/kraken/KRTexture2D.cpp @@ -61,7 +61,11 @@ bool KRTexture2D::createGPUTexture(int lod_max_dim) { texture.allocation = VK_NULL_HANDLE; texture.image = VK_NULL_HANDLE; - if (!device.createImage(getDimensions(), 0, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &texture.image, &texture.allocation)) { + if (!device.createImage(getDimensions(), 0, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &texture.image, &texture.allocation +#if KRENGINE_DEBUG_GPU_LABELS + , getName().c_str() +#endif + )) { success = false; break; } diff --git a/kraken/KRTextureCube.cpp b/kraken/KRTextureCube.cpp index 48673bf..9ee59df 100755 --- a/kraken/KRTextureCube.cpp +++ b/kraken/KRTextureCube.cpp @@ -102,7 +102,11 @@ bool KRTextureCube::createGPUTexture(int lod_max_dim) texture.allocation = VK_NULL_HANDLE; texture.image = VK_NULL_HANDLE; - if (!device.createImage(dimensions, VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &texture.image, &texture.allocation)) { + if (!device.createImage(dimensions, VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &texture.image, &texture.allocation +#if KRENGINE_DEBUG_GPU_LABELS + , getName().c_str() +#endif + )) { success = false; break; }