PhysicalDevice增加驱动ID获取支持
This commit is contained in:
parent
19714f8942
commit
a988f36b92
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/vulkan/VK.h>
|
||||
#include<hgl/type/BaseString.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct PhysicalDevice
|
||||
@ -9,6 +10,7 @@ struct PhysicalDevice
|
||||
VkPhysicalDevice physical_device=nullptr;
|
||||
VkPhysicalDeviceFeatures features;
|
||||
VkPhysicalDeviceProperties properties;
|
||||
VkPhysicalDeviceDriverPropertiesKHR driver_properties;
|
||||
VkPhysicalDeviceMemoryProperties memory_properties;
|
||||
List<VkLayerProperties> layer_properties;
|
||||
List<VkExtensionProperties> extension_properties;
|
||||
@ -21,8 +23,13 @@ public:
|
||||
const bool CheckMemoryType(uint32_t,VkFlags,uint32_t *)const;
|
||||
|
||||
VkPhysicalDeviceType GetDeviceType()const{return properties.deviceType;}
|
||||
const char * GetDeviceName()const{return properties.deviceName;}
|
||||
|
||||
const char *GetDeviceName()const{return properties.deviceName;}
|
||||
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;}
|
||||
|
||||
/**
|
||||
* »ñÈ¡¸ÃÉ豸ÊÇ·ñÊÇÏÔ¿¨
|
||||
|
@ -3,6 +3,10 @@
|
||||
#include<hgl/graph/vulkan/VKPhysicalDevice.h>
|
||||
#include<hgl/graph/vulkan/VKFramebuffer.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include<iostream>
|
||||
#endif//_DEBUG
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
namespace
|
||||
{
|
||||
@ -300,6 +304,24 @@ namespace
|
||||
|
||||
Device *CreateRenderDevice(VkInstance inst,const PhysicalDevice *physical_device,VkSurfaceKHR surface,uint width,uint height)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
const VkDriverIdKHR driver_id=physical_device->GetDriverId();
|
||||
|
||||
if(driver_id>=VK_DRIVER_ID_BEGIN_RANGE_KHR
|
||||
&&driver_id<=VK_DRIVER_ID_END_RANGE_KHR)
|
||||
{
|
||||
std::cout<<"DriverID: "<<physical_device->GetDriverId()<<std::endl;
|
||||
std::cout<<"DriverName: "<<physical_device->GetDriverName()<<std::endl;
|
||||
std::cout<<"DriverInfo: "<<physical_device->GetDriverInfo()<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Unknow VideoCard Driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
#endif//_DEBUG
|
||||
|
||||
DeviceAttribute *attr=new DeviceAttribute(inst,physical_device,surface);
|
||||
|
||||
AutoDelete<DeviceAttribute> auto_delete(attr);
|
||||
|
@ -6,10 +6,6 @@ PhysicalDevice::PhysicalDevice(VkInstance inst,VkPhysicalDevice pd)
|
||||
instance=inst;
|
||||
physical_device=pd;
|
||||
|
||||
vkGetPhysicalDeviceFeatures(physical_device,&features);
|
||||
vkGetPhysicalDeviceProperties(physical_device,&properties);
|
||||
vkGetPhysicalDeviceMemoryProperties(physical_device,&memory_properties);
|
||||
|
||||
{
|
||||
uint32_t property_count;
|
||||
|
||||
@ -31,6 +27,49 @@ PhysicalDevice::PhysicalDevice(VkInstance inst,VkPhysicalDevice pd)
|
||||
|
||||
debug_out(extension_properties);
|
||||
}
|
||||
|
||||
vkGetPhysicalDeviceFeatures(physical_device,&features);
|
||||
vkGetPhysicalDeviceMemoryProperties(physical_device,&memory_properties);
|
||||
|
||||
PFN_vkGetPhysicalDeviceProperties2 GetPhysicalDeviceProperties2=nullptr;
|
||||
|
||||
if(GetExtensionSpecVersion(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME))
|
||||
GetPhysicalDeviceProperties2=(PFN_vkGetPhysicalDeviceProperties2KHR)vkGetInstanceProcAddr(instance,"vkGetPhysicalDeviceProperties2KHR");
|
||||
|
||||
if(!GetPhysicalDeviceProperties2)
|
||||
if(GetExtensionSpecVersion(VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME))
|
||||
GetPhysicalDeviceProperties2=(PFN_vkGetPhysicalDeviceProperties2)vkGetInstanceProcAddr(instance,"vkGetPhysicalDeviceProperties2");
|
||||
|
||||
if(GetPhysicalDeviceProperties2)
|
||||
{
|
||||
VkPhysicalDeviceProperties2KHR properties2;
|
||||
GetPhysicalDeviceProperties2(physical_device,&properties2);
|
||||
|
||||
hgl_cpy(properties,properties2.properties);
|
||||
|
||||
if(properties2.pNext)
|
||||
memcpy(&driver_properties,properties2.pNext,sizeof(VkPhysicalDeviceDriverPropertiesKHR));
|
||||
}
|
||||
else
|
||||
{
|
||||
vkGetPhysicalDeviceProperties(physical_device,&properties);
|
||||
|
||||
hgl_zero(driver_properties);
|
||||
}
|
||||
}
|
||||
|
||||
const uint32_t PhysicalDevice::GetExtensionSpecVersion(const UTF8String &name)const
|
||||
{
|
||||
const uint count=extension_properties.GetCount();
|
||||
const VkExtensionProperties *ep=extension_properties.GetData();
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
if(name.Comp(ep->extensionName)==0)
|
||||
return ep->specVersion;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const bool PhysicalDevice::CheckMemoryType(uint32_t typeBits,VkFlags requirements_mask,uint32_t *typeIndex)const
|
||||
|
Loading…
x
Reference in New Issue
Block a user