将memory_type_from_properties转移位置
This commit is contained in:
parent
2e1f624090
commit
fef0addac7
@ -166,4 +166,24 @@ RenderSurfaceAttribute::~RenderSurfaceAttribute()
|
|||||||
if(surface)
|
if(surface)
|
||||||
vkDestroySurfaceKHR(instance,surface,nullptr);
|
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<memory_properties.memoryTypeCount; i++)
|
||||||
|
{
|
||||||
|
if((typeBits&1)==1)
|
||||||
|
{
|
||||||
|
// Type is available, does it match user properties?
|
||||||
|
if((memory_properties.memoryTypes[i].propertyFlags&requirements_mask)==requirements_mask)
|
||||||
|
{
|
||||||
|
*typeIndex=i;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
typeBits>>=1;
|
||||||
|
}
|
||||||
|
// No memory types matched, return failure
|
||||||
|
return false;
|
||||||
|
}
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -51,5 +51,7 @@ public:
|
|||||||
|
|
||||||
RenderSurfaceAttribute(VkInstance inst,VkPhysicalDevice pd,VkSurfaceKHR s);
|
RenderSurfaceAttribute(VkInstance inst,VkPhysicalDevice pd,VkSurfaceKHR s);
|
||||||
~RenderSurfaceAttribute();
|
~RenderSurfaceAttribute();
|
||||||
|
|
||||||
|
bool CheckMemoryType(uint32_t,VkFlags,uint32_t *);
|
||||||
};//class RenderSurfaceAttribute
|
};//class RenderSurfaceAttribute
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -172,26 +172,6 @@ namespace
|
|||||||
return(true);
|
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<memory_properties.memoryTypeCount; i++)
|
|
||||||
{
|
|
||||||
if((typeBits&1)==1)
|
|
||||||
{
|
|
||||||
// Type is available, does it match user properties?
|
|
||||||
if((memory_properties.memoryTypes[i].propertyFlags&requirements_mask)==requirements_mask)
|
|
||||||
{
|
|
||||||
*typeIndex=i;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
typeBits>>=1;
|
|
||||||
}
|
|
||||||
// No memory types matched, return failure
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CreateDepthBuffer(RenderSurfaceAttribute *rsa)
|
bool CreateDepthBuffer(RenderSurfaceAttribute *rsa)
|
||||||
{
|
{
|
||||||
VkImageCreateInfo image_info={};
|
VkImageCreateInfo image_info={};
|
||||||
@ -258,7 +238,8 @@ namespace
|
|||||||
mem_alloc.memoryTypeIndex=0;
|
mem_alloc.memoryTypeIndex=0;
|
||||||
mem_alloc.allocationSize=mem_reqs.size;
|
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)
|
if(vkAllocateMemory(rsa->device,&mem_alloc,nullptr,&rsa->depth.mem)!=VK_SUCCESS)
|
||||||
return(false);
|
return(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user