optimized CheckMemoryType function.
This commit is contained in:
parent
4602b9fb1f
commit
ebffc78fae
@ -53,7 +53,7 @@ public:
|
||||
GPUDeviceAttribute(VulkanInstance *inst,const GPUPhysicalDevice *pd,VkSurfaceKHR s);
|
||||
~GPUDeviceAttribute();
|
||||
|
||||
bool CheckMemoryType(uint32_t typeBits,VkMemoryPropertyFlags properties,uint32_t *typeIndex) const;
|
||||
int GetMemoryType(uint32_t typeBits,VkMemoryPropertyFlags properties) const;
|
||||
|
||||
void RefreshSurfaceCaps();
|
||||
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
operator VkPhysicalDevice(){return physical_device;}
|
||||
operator const VkPhysicalDevice()const{return physical_device;}
|
||||
|
||||
const bool CheckMemoryType(uint32_t,VkMemoryPropertyFlags,uint32_t *)const;
|
||||
const int GetMemoryType(uint32_t,VkMemoryPropertyFlags)const;
|
||||
|
||||
VkPhysicalDeviceType GetDeviceType()const{return properties.deviceType;}
|
||||
const char * GetDeviceName()const{return properties.deviceName;}
|
||||
|
@ -40,9 +40,9 @@ GPUDeviceAttribute::~GPUDeviceAttribute()
|
||||
instance->DestroySurface(surface);
|
||||
}
|
||||
|
||||
bool GPUDeviceAttribute::CheckMemoryType(uint32_t typeBits,VkMemoryPropertyFlags properties,uint32_t *typeIndex) const
|
||||
int GPUDeviceAttribute::GetMemoryType(uint32_t typeBits,VkMemoryPropertyFlags properties) const
|
||||
{
|
||||
return physical_device->CheckMemoryType(typeBits,properties,typeIndex);
|
||||
return physical_device->GetMemoryType(typeBits,properties);
|
||||
}
|
||||
|
||||
void GPUDeviceAttribute::RefreshSurfaceCaps()
|
||||
|
@ -246,7 +246,7 @@ bool GPUDevice::CommitTexture2D(Texture2D *tex,GPUBuffer *buf,const VkBufferImag
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
count,
|
||||
buffer_image_copy);
|
||||
|
||||
|
||||
if(destinationStage==VK_PIPELINE_STAGE_TRANSFER_BIT) //接下来还有,一般是给自动生成mipmaps
|
||||
{
|
||||
texture_cmd_buf->ImageMemoryBarrier(tex->GetImage(),
|
||||
|
@ -4,9 +4,9 @@
|
||||
VK_NAMESPACE_BEGIN
|
||||
GPUMemory *GPUDevice::CreateMemory(const VkMemoryRequirements &req,uint32_t properties)
|
||||
{
|
||||
uint32_t index;
|
||||
const int index=attr->physical_device->GetMemoryType(req.memoryTypeBits,properties);
|
||||
|
||||
if(!attr->physical_device->CheckMemoryType(req.memoryTypeBits,properties,&index))
|
||||
if(index<0)
|
||||
return(nullptr);
|
||||
|
||||
MemoryAllocateInfo alloc_info(index,req.size);
|
||||
|
@ -193,24 +193,20 @@ const bool GPUPhysicalDevice::CheckExtensionSupport(const AnsiString &name)const
|
||||
return(false);
|
||||
}
|
||||
|
||||
const bool GPUPhysicalDevice::CheckMemoryType(uint32_t typeBits,VkMemoryPropertyFlags properties,uint32_t *typeIndex)const
|
||||
const int GPUPhysicalDevice::GetMemoryType(uint32_t typeBits,VkMemoryPropertyFlags properties)const
|
||||
{
|
||||
// Search memtypes to find first index with those properties
|
||||
for(uint32_t i=0; i<memory_properties.memoryTypeCount; i++)
|
||||
for(int i=0; i<memory_properties.memoryTypeCount; i++)
|
||||
{
|
||||
if((typeBits&1)==1)
|
||||
{
|
||||
// Type is available, does it match user properties?
|
||||
if(typeBits&1) // Type is available, does it match user properties?
|
||||
if((memory_properties.memoryTypes[i].propertyFlags&properties)==properties)
|
||||
{
|
||||
*typeIndex=i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
|
||||
typeBits>>=1;
|
||||
}
|
||||
|
||||
// No memory types matched, return failure
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
VkFormat GPUPhysicalDevice::GetDepthFormat(bool lower_to_high)const
|
||||
|
Loading…
x
Reference in New Issue
Block a user