splited DeviceAttribute::Refresh function.

This commit is contained in:
hyzboy 2021-12-15 19:54:07 +08:00
parent 75e25d16c7
commit d98acda22e
2 changed files with 56 additions and 41 deletions

View File

@ -55,7 +55,12 @@ public:
bool CheckMemoryType(uint32_t typeBits,VkMemoryPropertyFlags properties,uint32_t *typeIndex) const; bool CheckMemoryType(uint32_t typeBits,VkMemoryPropertyFlags properties,uint32_t *typeIndex) const;
void Refresh(); void RefreshSurfaceCaps();
private:
void RefreshSurface();
void RefreshQueueFamily();
public: public:

View File

@ -13,7 +13,9 @@ GPUDeviceAttribute::GPUDeviceAttribute(VulkanInstance *inst,const GPUPhysicalDev
physical_device=pd; physical_device=pd;
surface=s; surface=s;
Refresh(); RefreshSurfaceCaps();
RefreshSurface();
RefreshQueueFamily();
} }
GPUDeviceAttribute::~GPUDeviceAttribute() GPUDeviceAttribute::~GPUDeviceAttribute()
@ -42,11 +44,16 @@ bool GPUDeviceAttribute::CheckMemoryType(uint32_t typeBits,VkMemoryPropertyFlags
return physical_device->CheckMemoryType(typeBits,properties,typeIndex); return physical_device->CheckMemoryType(typeBits,properties,typeIndex);
} }
void GPUDeviceAttribute::Refresh() void GPUDeviceAttribute::RefreshSurfaceCaps()
{ {
VkPhysicalDevice pdevice = *physical_device; VkPhysicalDevice pdevice = *physical_device;
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(pdevice, surface, &surface_caps); vkGetPhysicalDeviceSurfaceCapabilitiesKHR(pdevice, surface, &surface_caps);
}
void GPUDeviceAttribute::RefreshSurface()
{
VkPhysicalDevice pdevice = *physical_device;
{ {
if (surface_caps.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) if (surface_caps.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR)
@ -116,8 +123,12 @@ void GPUDeviceAttribute::Refresh()
present_modes.Clear(); present_modes.Clear();
} }
} }
}
void GPUDeviceAttribute::RefreshQueueFamily()
{
VkPhysicalDevice pdevice = *physical_device;
{
uint32_t family_count; uint32_t family_count;
vkGetPhysicalDeviceQueueFamilyProperties(pdevice, &family_count, nullptr); vkGetPhysicalDeviceQueueFamilyProperties(pdevice, &family_count, nullptr);
family_properties.SetCount(family_count); family_properties.SetCount(family_count);
@ -169,6 +180,5 @@ void GPUDeviceAttribute::Refresh()
++sp; ++sp;
} }
} }
}
} }
VK_NAMESPACE_END VK_NAMESPACE_END