VKPhysicalDevice由struct改为class

This commit is contained in:
hyzboy 2019-05-28 21:17:18 +08:00
parent 9bf934ed5c
commit e50adf12a2
3 changed files with 18 additions and 9 deletions

View File

@ -1,10 +1,10 @@
#pragma once #pragma once
#include<hgl/graph/vulkan/VK.h> #include<hgl/graph/vulkan/VK.h>
#include<hgl/type/BaseString.h> #include<hgl/type/BaseString.h>
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN
struct PhysicalDevice class PhysicalDevice
{ {
VkInstance instance=nullptr; VkInstance instance=nullptr;
VkPhysicalDevice physical_device=nullptr; VkPhysicalDevice physical_device=nullptr;
@ -20,6 +20,9 @@ public:
PhysicalDevice(VkInstance,VkPhysicalDevice); PhysicalDevice(VkInstance,VkPhysicalDevice);
~PhysicalDevice()=default; ~PhysicalDevice()=default;
operator VkPhysicalDevice(){return physical_device;}
operator const VkPhysicalDevice()const{return physical_device;}
const bool CheckMemoryType(uint32_t,VkFlags,uint32_t *)const; const bool CheckMemoryType(uint32_t,VkFlags,uint32_t *)const;
VkPhysicalDeviceType GetDeviceType()const{return properties.deviceType;} VkPhysicalDeviceType GetDeviceType()const{return properties.deviceType;}
@ -35,8 +38,14 @@ public:
const char * GetDriverName ()const{return driver_properties.driverName;} const char * GetDriverName ()const{return driver_properties.driverName;}
const char * GetDriverInfo ()const{return driver_properties.driverInfo;} const char * GetDriverInfo ()const{return driver_properties.driverInfo;}
public:
const uint32_t GetConstantSize()const{return properties.limits.maxPushConstantsSize;}
public:
/** /**
* *
*/ */
const bool isGPU()const const bool isGPU()const
{ {
@ -47,9 +56,9 @@ public:
return(false); return(false);
} }
const bool isDiscreteGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU);} ///<是否是独立显卡 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 isIntegratedGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU);} ///<是否是集成显卡
const bool isVirtualGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU);} ///<是否是虚拟显卡 const bool isVirtualGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU);} ///<是否是虚拟显卡
public: public:
@ -61,5 +70,5 @@ public:
return fp; return fp;
} }
};//struct PhysicalDevice };//class PhysicalDevice
VK_NAMESPACE_END VK_NAMESPACE_END

View File

@ -11,7 +11,7 @@ DeviceAttribute::DeviceAttribute(VkInstance inst,const PhysicalDevice *pd,VkSurf
physical_device=pd; physical_device=pd;
surface=s; surface=s;
VkPhysicalDevice pdevice=physical_device->physical_device; VkPhysicalDevice pdevice=*physical_device;
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(pdevice,surface,&surface_caps); vkGetPhysicalDeviceSurfaceCapabilitiesKHR(pdevice,surface,&surface_caps);

View File

@ -546,7 +546,7 @@ Device *CreateRenderDevice(VkInstance inst,const PhysicalDevice *physical_device
if(attr->graphics_family==ERROR_FAMILY_INDEX) if(attr->graphics_family==ERROR_FAMILY_INDEX)
return(nullptr); return(nullptr);
attr->device=CreateDevice(inst,physical_device->physical_device,attr->graphics_family); attr->device=CreateDevice(inst,*physical_device,attr->graphics_family);
if(!attr->device) if(!attr->device)
return(nullptr); return(nullptr);