append codes that they can output queue family properties of physical device.
This commit is contained in:
parent
4a24a05360
commit
c9b50e35c7
@ -27,6 +27,18 @@ namespace hgl
|
||||
}//namespace hgl
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
/*
|
||||
* GPU设备创建信息
|
||||
*/
|
||||
struct GPUDeviceCreateInfo
|
||||
{
|
||||
VkPhysicalDeviceType device_type =VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM;
|
||||
|
||||
uint32_t swapchain_image_count =0;
|
||||
VkSurfaceFormatKHR color_format ={PF_A2BGR10UN,VK_COLOR_SPACE_SRGB_NONLINEAR_KHR};
|
||||
VkFormat depth_format =VK_FORMAT_UNDEFINED;
|
||||
};//struct GPUDeviceCreateInfo
|
||||
|
||||
class GPUDevice
|
||||
{
|
||||
GPUDeviceAttribute *attr;
|
||||
|
@ -59,8 +59,9 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void RefreshSurface();
|
||||
void RefreshQueueFamily();
|
||||
void GetSurfaceFormatList();
|
||||
void GetSurfacePresentMode();
|
||||
void GetQueueFamily();
|
||||
|
||||
public:
|
||||
|
||||
|
@ -15,6 +15,7 @@ class GPUPhysicalDevice
|
||||
VkPhysicalDeviceMemoryProperties memory_properties;
|
||||
List<VkLayerProperties> layer_properties;
|
||||
List<VkExtensionProperties> extension_properties;
|
||||
List<VkQueueFamilyProperties> queue_family_properties;
|
||||
|
||||
public:
|
||||
|
||||
@ -48,20 +49,6 @@ public:
|
||||
|
||||
const uint32_t GetConstantSize ()const{return properties.limits.maxPushConstantsSize;}
|
||||
|
||||
// support != open, so please don't direct use GetFeatures().
|
||||
// open any features in CreateDevice()&SetDeviceFeatures() functions.
|
||||
const bool IsSupportMDI ()const
|
||||
{
|
||||
// I found a few device support MDI, but its MaxDrawIndirectCount is 1.
|
||||
|
||||
return (features.multiDrawIndirect&&properties.limits.maxDrawIndirectCount>1);
|
||||
}
|
||||
|
||||
const uint32_t GetMaxMDICount ()const
|
||||
{
|
||||
return properties.limits.maxDrawIndirectCount;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -112,9 +99,23 @@ public:
|
||||
public:
|
||||
|
||||
const VkBool32 SupportGeometryShader ()const{return features.geometryShader;}
|
||||
const VkBool32 SupportMultiDrawIndirect ()const{return features.multiDrawIndirect;}
|
||||
const VkBool32 SupportCubeMapArray ()const{return features.imageCubeArray;}
|
||||
|
||||
|
||||
// support != open, so please don't direct use GetFeatures().
|
||||
// open any features in CreateDevice()&SetDeviceFeatures() functions.
|
||||
const bool SupportMDI ()const
|
||||
{
|
||||
// I found a few device support MDI, but its MaxDrawIndirectCount is 1.
|
||||
|
||||
return (features.multiDrawIndirect&&properties.limits.maxDrawIndirectCount>1);
|
||||
}
|
||||
|
||||
const uint32_t GetMaxMDICount ()const
|
||||
{
|
||||
return properties.limits.maxDrawIndirectCount;
|
||||
}
|
||||
|
||||
const uint32_t GetMaxImage1D ()const{return properties.limits.maxImageDimension1D;}
|
||||
const uint32_t GetMaxImage2D ()const{return properties.limits.maxImageDimension2D;}
|
||||
const uint32_t GetMaxImage3D ()const{return properties.limits.maxImageDimension3D;}
|
||||
|
@ -170,7 +170,7 @@ void RenderCmdBuffer::DrawIndirect( VkBuffer buffer,
|
||||
uint32_t drawCount,
|
||||
uint32_t stride)
|
||||
{
|
||||
if(this->dev_attr->physical_device->IsSupportMDI())
|
||||
if(this->dev_attr->physical_device->SupportMDI())
|
||||
vkCmdDrawIndirect(cmd_buf,buffer,offset,drawCount,stride);
|
||||
else
|
||||
for(uint32_t i=0;i<drawCount;i++)
|
||||
@ -182,7 +182,7 @@ void RenderCmdBuffer::DrawIndexedIndirect( VkBuffer buffer,
|
||||
uint32_t drawCount,
|
||||
uint32_t stride)
|
||||
{
|
||||
if(this->dev_attr->physical_device->IsSupportMDI())
|
||||
if(this->dev_attr->physical_device->SupportMDI())
|
||||
vkCmdDrawIndexedIndirect(cmd_buf,buffer,offset,drawCount,stride);
|
||||
else
|
||||
for(uint32_t i=0;i<drawCount;i++)
|
||||
|
@ -14,8 +14,9 @@ GPUDeviceAttribute::GPUDeviceAttribute(VulkanInstance *inst,const GPUPhysicalDev
|
||||
surface=s;
|
||||
|
||||
RefreshSurfaceCaps();
|
||||
RefreshSurface();
|
||||
RefreshQueueFamily();
|
||||
GetSurfaceFormatList();
|
||||
GetSurfacePresentMode();
|
||||
GetQueueFamily();
|
||||
}
|
||||
|
||||
GPUDeviceAttribute::~GPUDeviceAttribute()
|
||||
@ -49,11 +50,6 @@ void GPUDeviceAttribute::RefreshSurfaceCaps()
|
||||
VkPhysicalDevice pdevice = *physical_device;
|
||||
|
||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(pdevice, surface, &surface_caps);
|
||||
}
|
||||
|
||||
void GPUDeviceAttribute::RefreshSurface()
|
||||
{
|
||||
VkPhysicalDevice pdevice = *physical_device;
|
||||
|
||||
{
|
||||
if (surface_caps.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR)
|
||||
@ -63,10 +59,13 @@ void GPUDeviceAttribute::RefreshSurface()
|
||||
}
|
||||
|
||||
{
|
||||
constexpr VkCompositeAlphaFlagBitsKHR compositeAlphaFlags[4]={VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
|
||||
constexpr VkCompositeAlphaFlagBitsKHR compositeAlphaFlags[4]=
|
||||
{
|
||||
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
|
||||
VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR,
|
||||
VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR,
|
||||
VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR };
|
||||
VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR
|
||||
};
|
||||
|
||||
for(auto flags:compositeAlphaFlags)
|
||||
if (surface_caps.supportedCompositeAlpha & flags)
|
||||
@ -75,6 +74,11 @@ void GPUDeviceAttribute::RefreshSurface()
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GPUDeviceAttribute::GetSurfaceFormatList()
|
||||
{
|
||||
VkPhysicalDevice pdevice = *physical_device;
|
||||
|
||||
{
|
||||
uint32_t format_count;
|
||||
@ -113,19 +117,24 @@ void GPUDeviceAttribute::RefreshSurface()
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t mode_count;
|
||||
if (vkGetPhysicalDeviceSurfacePresentModesKHR(pdevice, surface, &mode_count, nullptr) == VK_SUCCESS)
|
||||
{
|
||||
present_modes.SetCount(mode_count);
|
||||
if (vkGetPhysicalDeviceSurfacePresentModesKHR(pdevice, surface, &mode_count, present_modes.GetData()) != VK_SUCCESS)
|
||||
present_modes.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GPUDeviceAttribute::RefreshQueueFamily()
|
||||
void GPUDeviceAttribute::GetSurfacePresentMode()
|
||||
{
|
||||
uint32_t mode_count;
|
||||
|
||||
VkPhysicalDevice pdevice = *physical_device;
|
||||
|
||||
if (!vkGetPhysicalDeviceSurfacePresentModesKHR(pdevice, surface, &mode_count, nullptr) == VK_SUCCESS)
|
||||
return;
|
||||
|
||||
present_modes.SetCount(mode_count);
|
||||
|
||||
if (vkGetPhysicalDeviceSurfacePresentModesKHR(pdevice, surface, &mode_count, present_modes.GetData()) != VK_SUCCESS)
|
||||
present_modes.Clear();
|
||||
}
|
||||
|
||||
void GPUDeviceAttribute::GetQueueFamily()
|
||||
{
|
||||
VkPhysicalDevice pdevice = *physical_device;
|
||||
|
||||
|
@ -49,9 +49,13 @@ namespace
|
||||
|
||||
FEATURE_COPY(geometryShader);
|
||||
FEATURE_COPY(multiDrawIndirect);
|
||||
// FEATURE_COPY(imageCubeArray);
|
||||
FEATURE_COPY(samplerAnisotropy);
|
||||
|
||||
// FEATURE_COPY(imageCubeArray);
|
||||
// FEATURE_COPY(fullDrawIndexUint32);
|
||||
// FEATURE_COPY(wideLines)
|
||||
// FEATURE_COPY(largePoints)
|
||||
|
||||
#undef FEATURE_COPY
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ VulkanInstance *CreateInstance(const AnsiString &app_name,VKDebugOut *out,Create
|
||||
VK_EXT_DEBUG_REPORT_EXTENSION_NAME,
|
||||
VK_EXT_DEBUG_UTILS_EXTENSION_NAME,
|
||||
#endif//_DEBUG
|
||||
VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME,
|
||||
};
|
||||
|
||||
for(const char *ext_name:require_ext_list)
|
||||
|
@ -2,11 +2,69 @@
|
||||
#include<hgl/graph/VKInstance.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
namespace
|
||||
{
|
||||
void debug_queue_family_properties_out(const char *front,const List<VkQueueFamilyProperties> &qfp_list)
|
||||
{
|
||||
constexpr char *queue_bit_name[]=
|
||||
{
|
||||
"Graphics",
|
||||
"Compute",
|
||||
"Transfer",
|
||||
"SparseBinding",
|
||||
"Protected",
|
||||
"VideoDecode",
|
||||
"VideoEncode"
|
||||
};
|
||||
|
||||
const int count=qfp_list.GetCount();
|
||||
|
||||
if(count<=0)return;
|
||||
|
||||
const VkQueueFamilyProperties *p=qfp_list.GetData();
|
||||
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
std::cout<<front<<" Queue Family ["<<i<<"] count: "<<p->queueCount
|
||||
<<", timestampValidBits: "<<p->timestampValidBits
|
||||
<<", minImageTransferGranularity [" <<p->minImageTransferGranularity.width<<","
|
||||
<<p->minImageTransferGranularity.height<<","
|
||||
<<p->minImageTransferGranularity.depth<<"], queueFlags[";
|
||||
|
||||
uint32_t bits=p->queueFlags;
|
||||
|
||||
for(uint i=0;i<7;i++)
|
||||
{
|
||||
if(bits&1)
|
||||
{
|
||||
std::cout<<queue_bit_name[i];
|
||||
bits>>=1;
|
||||
if(bits>0)std::cout<<",";
|
||||
}
|
||||
else
|
||||
{
|
||||
bits>>=1;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout<<"]"<<std::endl;
|
||||
|
||||
++p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GPUPhysicalDevice::GPUPhysicalDevice(VkInstance inst,VkPhysicalDevice pd)
|
||||
{
|
||||
instance=inst;
|
||||
physical_device=pd;
|
||||
|
||||
vkGetPhysicalDeviceFeatures(physical_device,&features);
|
||||
vkGetPhysicalDeviceMemoryProperties(physical_device,&memory_properties);
|
||||
vkGetPhysicalDeviceProperties(physical_device,&properties);
|
||||
|
||||
std::string debug_front="PhysicalDevice["+std::string(properties.deviceName)+"]";
|
||||
|
||||
{
|
||||
uint32_t property_count;
|
||||
|
||||
@ -15,7 +73,7 @@ GPUPhysicalDevice::GPUPhysicalDevice(VkInstance inst,VkPhysicalDevice pd)
|
||||
layer_properties.SetCount(property_count);
|
||||
vkEnumerateDeviceLayerProperties(physical_device,&property_count,layer_properties.GetData());
|
||||
|
||||
debug_out("PhysicalDevice",layer_properties);
|
||||
debug_out(debug_front.c_str(),layer_properties);
|
||||
}
|
||||
|
||||
{
|
||||
@ -26,12 +84,19 @@ GPUPhysicalDevice::GPUPhysicalDevice(VkInstance inst,VkPhysicalDevice pd)
|
||||
extension_properties.SetCount(exten_count);
|
||||
vkEnumerateDeviceExtensionProperties(physical_device,nullptr,&exten_count,extension_properties.GetData());
|
||||
|
||||
debug_out("PhysicalDevice",extension_properties);
|
||||
debug_out(debug_front.c_str(),extension_properties);
|
||||
}
|
||||
|
||||
vkGetPhysicalDeviceFeatures(physical_device,&features);
|
||||
vkGetPhysicalDeviceMemoryProperties(physical_device,&memory_properties);
|
||||
vkGetPhysicalDeviceProperties(physical_device,&properties);
|
||||
{
|
||||
uint32_t family_count;
|
||||
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,&family_count,nullptr);
|
||||
|
||||
queue_family_properties.SetCount(family_count);
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,&family_count,queue_family_properties.GetData());
|
||||
|
||||
debug_queue_family_properties_out(debug_front.c_str(),queue_family_properties);
|
||||
}
|
||||
}
|
||||
|
||||
const bool GPUPhysicalDevice::GetLayerVersion(const AnsiString &name,uint32_t &spec,uint32_t &impl)const
|
||||
|
Loading…
x
Reference in New Issue
Block a user