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-07-02 21:39:24 +08:00
|
|
|
|
#include<hgl/type/Set.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;
|
|
|
|
|
|
2019-07-02 21:52:27 +08:00
|
|
|
|
VkFormatProperties format_properties[VK_FORMAT_RANGE_SIZE];
|
2019-07-02 21:39:24 +08:00
|
|
|
|
|
|
|
|
|
void InitFormatSupport();
|
|
|
|
|
|
2019-04-13 21:44:26 +08:00
|
|
|
|
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-06-25 22:26:09 +08:00
|
|
|
|
const bool CheckMemoryType(uint32_t,VkMemoryPropertyFlags,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-07-02 21:52:27 +08:00
|
|
|
|
|
2019-07-02 21:59:27 +08:00
|
|
|
|
bool OptimalSupport (const VkFormat format,const VkFormatFeatureFlags flag)const{return((format<VK_FORMAT_BEGIN_RANGE||format>VK_FORMAT_END_RANGE)?false:(format_properties[format].optimalTilingFeatures&flag));}
|
|
|
|
|
bool LinearSupport (const VkFormat format,const VkFormatFeatureFlags flag)const{return((format<VK_FORMAT_BEGIN_RANGE||format>VK_FORMAT_END_RANGE)?false:(format_properties[format].linearTilingFeatures&flag));}
|
|
|
|
|
bool BufferSupport (const VkFormat format,const VkFormatFeatureFlags flag)const{return((format<VK_FORMAT_BEGIN_RANGE||format>VK_FORMAT_END_RANGE)?false:(format_properties[format].bufferFeatures&flag));}
|
2019-06-19 16:54:41 +08:00
|
|
|
|
|
2019-07-02 21:59:27 +08:00
|
|
|
|
bool IsColorAttachmentOptimal(const VkFormat format)const{return OptimalSupport(format,VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);}
|
|
|
|
|
bool IsDepthAttachmentOptimal(const VkFormat format)const{return OptimalSupport(format,VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT);}
|
2019-07-05 19:56:15 +08:00
|
|
|
|
|
|
|
|
|
bool IsColorAttachmentLinear(const VkFormat format)const{return LinearSupport(format,VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);}
|
|
|
|
|
bool IsDepthAttachmentLinear(const VkFormat format)const{return LinearSupport(format,VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT);}
|
|
|
|
|
|
|
|
|
|
bool IsColorAttachmentBuffer(const VkFormat format)const{return BufferSupport(format,VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);}
|
|
|
|
|
bool IsDepthAttachmentBuffer(const VkFormat format)const{return BufferSupport(format,VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT);}
|
2019-07-02 21:39:24 +08:00
|
|
|
|
|
2019-06-19 16:54:41 +08:00
|
|
|
|
VkFormat GetDepthFormat(bool lower_to_high=true)const;
|
|
|
|
|
VkFormat GetDepthStencilFormat(bool lower_to_high=true)const;
|
2019-05-28 21:17:18 +08:00
|
|
|
|
};//class PhysicalDevice
|
2019-07-02 21:59:27 +08:00
|
|
|
|
VK_NAMESPACE_END
|