diff --git a/example/Vulkan/RenderSurfaceAttribute.cpp b/example/Vulkan/RenderSurfaceAttribute.cpp index 551779b1..e9b2c87e 100644 --- a/example/Vulkan/RenderSurfaceAttribute.cpp +++ b/example/Vulkan/RenderSurfaceAttribute.cpp @@ -166,4 +166,24 @@ RenderSurfaceAttribute::~RenderSurfaceAttribute() if(surface) vkDestroySurfaceKHR(instance,surface,nullptr); } + +bool RenderSurfaceAttribute::CheckMemoryType(uint32_t typeBits,VkFlags requirements_mask,uint32_t *typeIndex) +{ + // Search memtypes to find first index with those properties + for(uint32_t i=0; i>=1; + } + // No memory types matched, return failure + return false; +} VK_NAMESPACE_END diff --git a/example/Vulkan/RenderSurfaceAttribute.h b/example/Vulkan/RenderSurfaceAttribute.h index 7730173a..5e7783ec 100644 --- a/example/Vulkan/RenderSurfaceAttribute.h +++ b/example/Vulkan/RenderSurfaceAttribute.h @@ -51,5 +51,7 @@ public: RenderSurfaceAttribute(VkInstance inst,VkPhysicalDevice pd,VkSurfaceKHR s); ~RenderSurfaceAttribute(); + + bool CheckMemoryType(uint32_t,VkFlags,uint32_t *); };//class RenderSurfaceAttribute VK_NAMESPACE_END diff --git a/example/Vulkan/RenderSurfaceCreater.cpp b/example/Vulkan/RenderSurfaceCreater.cpp index 85fa7a60..a0a619fc 100644 --- a/example/Vulkan/RenderSurfaceCreater.cpp +++ b/example/Vulkan/RenderSurfaceCreater.cpp @@ -171,27 +171,7 @@ namespace return(true); } - - bool memory_type_from_properties(VkPhysicalDeviceMemoryProperties memory_properties,uint32_t typeBits,VkFlags requirements_mask,uint32_t *typeIndex) - { - // Search memtypes to find first index with those properties - for(uint32_t i=0; i>=1; - } - // No memory types matched, return failure - return false; - } - + bool CreateDepthBuffer(RenderSurfaceAttribute *rsa) { VkImageCreateInfo image_info={}; @@ -258,7 +238,8 @@ namespace mem_alloc.memoryTypeIndex=0; mem_alloc.allocationSize=mem_reqs.size; - bool pass=memory_type_from_properties(rsa->memory_properties,mem_reqs.memoryTypeBits,VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,&mem_alloc.memoryTypeIndex); + if(!rsa->CheckMemoryType(mem_reqs.memoryTypeBits,VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,&mem_alloc.memoryTypeIndex)) + return(false); if(vkAllocateMemory(rsa->device,&mem_alloc,nullptr,&rsa->depth.mem)!=VK_SUCCESS) return(false);