From e61f8aa7d1526d5774c6c10f60a19d9a2ad1724c Mon Sep 17 00:00:00 2001 From: kearwood Date: Sat, 16 Jul 2022 00:03:15 -0700 Subject: [PATCH] Added VkMemoryPropertyFlags argument to KRDevice::createImage --- kraken/KRDevice.cpp | 9 ++++++--- kraken/KRDevice.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/kraken/KRDevice.cpp b/kraken/KRDevice.cpp index 865a0e2..d9ba92d 100644 --- a/kraken/KRDevice.cpp +++ b/kraken/KRDevice.cpp @@ -430,7 +430,7 @@ VmaAllocator KRDevice::getAllocator() return m_allocator; } -bool KRDevice::createImage(Vector2i dimensions, VkImage* image, VmaAllocation* allocation) +bool KRDevice::createImage(Vector2i dimensions, VkMemoryPropertyFlags properties, VkImage* image, VmaAllocation* allocation) { // TODO - Break block into own function to be shared with createBuffer int familyCount = 1; @@ -441,7 +441,6 @@ bool KRDevice::createImage(Vector2i dimensions, VkImage* image, VmaAllocation* a familyCount++; } - VmaAllocationCreateInfo allocationInfo{}; VkImageCreateInfo imageInfo{}; imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; imageInfo.imageType = VK_IMAGE_TYPE_2D; @@ -460,7 +459,11 @@ bool KRDevice::createImage(Vector2i dimensions, VkImage* image, VmaAllocation* a imageInfo.pQueueFamilyIndices = queueFamilyIndices; imageInfo.queueFamilyIndexCount = familyCount; - VkResult res = vmaCreateImage(m_allocator, &imageInfo, &allocationInfo, image, allocation, nullptr); + VmaAllocationCreateInfo allocInfo = {}; + allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; + allocInfo.requiredFlags = properties; + + VkResult res = vmaCreateImage(m_allocator, &imageInfo, &allocInfo, image, allocation, nullptr); if (res != VK_SUCCESS) { return false; } diff --git a/kraken/KRDevice.h b/kraken/KRDevice.h index 01918fc..ce55557 100644 --- a/kraken/KRDevice.h +++ b/kraken/KRDevice.h @@ -55,7 +55,7 @@ public: #endif ); - bool createImage(Vector2i dimensions, VkImage* image, VmaAllocation* allocation); + bool createImage(Vector2i dimensions, VkMemoryPropertyFlags properties, VkImage* image, VmaAllocation* allocation); KrResult selectSurfaceFormat(VkSurfaceKHR& surface, VkSurfaceFormatKHR& surfaceFormat); KrResult selectDepthFormat(VkFormat& selectedDepthFormat);