#include #include VK_NAMESPACE_BEGIN GPUPhysicalDevice::GPUPhysicalDevice(VkInstance inst,VkPhysicalDevice pd) { instance=inst; physical_device=pd; { uint32_t property_count; vkEnumerateDeviceLayerProperties(physical_device,&property_count,nullptr); layer_properties.SetCount(property_count); vkEnumerateDeviceLayerProperties(physical_device,&property_count,layer_properties.GetData()); debug_out("PhysicalDevice",layer_properties); } { uint32_t exten_count; vkEnumerateDeviceExtensionProperties(physical_device,nullptr,&exten_count,nullptr); extension_properties.SetCount(exten_count); vkEnumerateDeviceExtensionProperties(physical_device,nullptr,&exten_count,extension_properties.GetData()); debug_out("PhysicalDevice",extension_properties); } vkGetPhysicalDeviceFeatures(physical_device,&features); vkGetPhysicalDeviceMemoryProperties(physical_device,&memory_properties); vkGetPhysicalDeviceProperties(physical_device,&properties); } const bool GPUPhysicalDevice::GetLayerVersion(const AnsiString &name,uint32_t &spec,uint32_t &impl)const { for(const VkLayerProperties &lp:layer_properties) { if(name.Comp(lp.layerName)==0) { spec=lp.specVersion; impl=lp.implementationVersion; return(true); } } return(false); } const uint32_t GPUPhysicalDevice::GetExtensionVersion(const AnsiString &name)const { for(const VkExtensionProperties &ep:extension_properties) { if(name.Comp(ep.extensionName)==0) return ep.specVersion; } return 0; } const bool GPUPhysicalDevice::CheckMemoryType(uint32_t typeBits,VkMemoryPropertyFlags properties,uint32_t *typeIndex)const { // Search memtypes to find first index with those properties for(uint32_t i=0; i>=1; } // No memory types matched, return failure return false; } VkFormat GPUPhysicalDevice::GetDepthFormat(bool lower_to_high)const { constexpr VkFormat depthFormats[] = { PF_D16UN, PF_X8_D24UN, PF_D16UN_S8U, PF_D24UN_S8U, PF_D32F, PF_D32F_S8U }; VkFormat result=VK_FORMAT_UNDEFINED; for (auto& format : depthFormats) { if(IsDepthAttachmentOptimal(format)) { if(lower_to_high) return format; else result=format; } } return result; } VkFormat GPUPhysicalDevice::GetDepthStencilFormat(bool lower_to_high)const { constexpr VkFormat depthStencilFormats[] = { PF_D16UN_S8U, PF_D24UN_S8U, PF_D32F_S8U }; VkFormat result=VK_FORMAT_UNDEFINED; for (auto& format : depthStencilFormats) { if(IsDepthAttachmentOptimal(format)) { if(lower_to_high) return format; else result=format; } } return result; } VK_NAMESPACE_END