2019-05-28 21:17:18 +08:00
|
|
|
|
#pragma once
|
2019-04-13 21:44:26 +08:00
|
|
|
|
|
2019-05-07 12:46:25 +08:00
|
|
|
|
#include<hgl/graph/vulkan/VK.h>
|
2019-05-23 13:24:21 +08:00
|
|
|
|
#include<hgl/type/BaseString.h>
|
2019-04-13 21:44:26 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_BEGIN
|
2019-05-28 21:17:18 +08:00
|
|
|
|
class PhysicalDevice
|
2019-04-13 21:44:26 +08:00
|
|
|
|
{
|
|
|
|
|
VkInstance instance=nullptr;
|
|
|
|
|
VkPhysicalDevice physical_device=nullptr;
|
|
|
|
|
VkPhysicalDeviceFeatures features;
|
|
|
|
|
VkPhysicalDeviceProperties properties;
|
2019-05-23 13:24:21 +08:00
|
|
|
|
VkPhysicalDeviceDriverPropertiesKHR driver_properties;
|
2019-04-13 21:44:26 +08:00
|
|
|
|
VkPhysicalDeviceMemoryProperties memory_properties;
|
|
|
|
|
List<VkLayerProperties> layer_properties;
|
|
|
|
|
List<VkExtensionProperties> extension_properties;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
PhysicalDevice(VkInstance,VkPhysicalDevice);
|
|
|
|
|
~PhysicalDevice()=default;
|
|
|
|
|
|
2019-05-28 21:17:18 +08:00
|
|
|
|
operator VkPhysicalDevice(){return physical_device;}
|
|
|
|
|
operator const VkPhysicalDevice()const{return physical_device;}
|
|
|
|
|
|
2019-05-23 13:24:21 +08:00
|
|
|
|
const bool CheckMemoryType(uint32_t,VkFlags,uint32_t *)const;
|
2019-04-13 21:44:26 +08:00
|
|
|
|
|
2019-05-23 13:24:21 +08:00
|
|
|
|
VkPhysicalDeviceType GetDeviceType()const{return properties.deviceType;}
|
|
|
|
|
const char * GetDeviceName()const{return properties.deviceName;}
|
2019-04-13 21:44:26 +08:00
|
|
|
|
|
2019-05-28 14:25:58 +08:00
|
|
|
|
const VkPhysicalDeviceFeatures & GetFeatures ()const{return features;}
|
|
|
|
|
const VkPhysicalDeviceProperties & GetProperties ()const{return properties;}
|
|
|
|
|
const VkPhysicalDeviceMemoryProperties &GetMemoryProperties ()const{return memory_properties;}
|
|
|
|
|
|
2019-05-23 13:24:21 +08:00
|
|
|
|
const uint32_t GetExtensionSpecVersion(const UTF8String &name)const;
|
|
|
|
|
|
|
|
|
|
const VkDriverIdKHR GetDriverId ()const{return driver_properties.driverID;}
|
|
|
|
|
const char * GetDriverName ()const{return driver_properties.driverName;}
|
|
|
|
|
const char * GetDriverInfo ()const{return driver_properties.driverInfo;}
|
2019-04-13 21:44:26 +08:00
|
|
|
|
|
2019-05-28 21:17:18 +08:00
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
const uint32_t GetConstantSize()const{return properties.limits.maxPushConstantsSize;}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2019-04-13 21:44:26 +08:00
|
|
|
|
/**
|
2019-05-28 21:17:18 +08:00
|
|
|
|
* 获取该设备是否是显卡
|
2019-04-13 21:44:26 +08:00
|
|
|
|
*/
|
|
|
|
|
const bool isGPU()const
|
|
|
|
|
{
|
|
|
|
|
if(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)return(true);
|
|
|
|
|
if(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU)return(true);
|
|
|
|
|
if(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU)return(true);
|
|
|
|
|
|
|
|
|
|
return(false);
|
|
|
|
|
}
|
2019-05-05 14:22:58 +08:00
|
|
|
|
|
2019-05-28 21:17:18 +08:00
|
|
|
|
const bool isDiscreteGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU);} ///<是否是独立显卡
|
|
|
|
|
const bool isIntegratedGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU);} ///<是否是集成显卡
|
|
|
|
|
const bool isVirtualGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU);} ///<是否是虚拟显卡
|
2019-05-18 15:41:49 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
VkFormatProperties GetFormatProperties(const VkFormat format)const
|
|
|
|
|
{
|
|
|
|
|
VkFormatProperties fp;
|
|
|
|
|
|
|
|
|
|
vkGetPhysicalDeviceFormatProperties(physical_device,format,&fp);
|
|
|
|
|
|
|
|
|
|
return fp;
|
|
|
|
|
}
|
2019-05-28 21:17:18 +08:00
|
|
|
|
};//class PhysicalDevice
|
2019-04-13 21:44:26 +08:00
|
|
|
|
VK_NAMESPACE_END
|