diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 58ce8a5f..1551be2a 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -1293,6 +1293,24 @@ VkBool32 VulkanExampleBase::getMemoryType(uint32_t typeBits, VkFlags properties, return false; } +uint32_t VulkanExampleBase::getMemoryType(uint32_t typeBits, VkFlags properties) +{ + for (uint32_t i = 0; i < 32; i++) + { + if ((typeBits & 1) == 1) + { + if ((deviceMemoryProperties.memoryTypes[i].propertyFlags & properties) == properties) + { + return i; + } + } + typeBits >>= 1; + } + + // todo : throw error + return 0; +} + void VulkanExampleBase::createCommandPool() { VkCommandPoolCreateInfo cmdPoolInfo = {}; diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index a506f031..d2488e98 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -229,6 +229,7 @@ public: // Get memory type for a given memory allocation (flags and bits) VkBool32 getMemoryType(uint32_t typeBits, VkFlags properties, uint32_t *typeIndex); + uint32_t getMemoryType(uint32_t typeBits, VkFlags properties); // Creates a new (graphics) command pool object storing command buffers void createCommandPool();