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