2019-04-09 00:22:26 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_INSTANCE_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_VULKAN_INSTANCE_INCLUDE
|
|
|
|
|
|
2020-09-05 17:54:21 +08:00
|
|
|
|
#include<hgl/type/String.h>
|
2023-07-28 20:17:46 +08:00
|
|
|
|
#include<hgl/type/ObjectList.h>
|
2019-04-30 16:42:59 +08:00
|
|
|
|
#include<hgl/platform/Window.h>
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VKPhysicalDevice.h>
|
|
|
|
|
#include<hgl/graph/VKDebugOut.h>
|
2019-04-09 00:22:26 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_BEGIN
|
2019-11-13 19:55:13 +08:00
|
|
|
|
#define VK_BOOL1BIT(name) bool name:1;
|
|
|
|
|
struct CreateInstanceLayerInfo
|
|
|
|
|
{
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
VK_BOOL1BIT(api_dump)
|
|
|
|
|
VK_BOOL1BIT(device_simulation)
|
|
|
|
|
VK_BOOL1BIT(monitor)
|
|
|
|
|
VK_BOOL1BIT(screenshot)
|
|
|
|
|
VK_BOOL1BIT(standard_validation)
|
|
|
|
|
VK_BOOL1BIT(vktrace)
|
|
|
|
|
}lunarg;
|
|
|
|
|
|
|
|
|
|
struct
|
|
|
|
|
{
|
2023-05-31 17:18:14 +08:00
|
|
|
|
VK_BOOL1BIT(synchronization2)
|
2019-11-13 19:55:13 +08:00
|
|
|
|
VK_BOOL1BIT(validation)
|
2023-05-31 17:18:14 +08:00
|
|
|
|
VK_BOOL1BIT(profiles)
|
2019-11-13 19:55:13 +08:00
|
|
|
|
}khronos;
|
|
|
|
|
|
2023-12-05 02:07:25 +08:00
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
VK_BOOL1BIT(switchable_graphics)
|
|
|
|
|
}amd;
|
|
|
|
|
|
2019-11-13 19:55:13 +08:00
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
VK_BOOL1BIT(optimus)
|
|
|
|
|
}nv;
|
|
|
|
|
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
VK_BOOL1BIT(steam_overlay)
|
|
|
|
|
VK_BOOL1BIT(steam_fossilize)
|
|
|
|
|
}valve;
|
|
|
|
|
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
VK_BOOL1BIT(Capture)
|
|
|
|
|
}RenderDoc;
|
|
|
|
|
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
VK_BOOL1BIT(helper);
|
|
|
|
|
}bandicam;
|
|
|
|
|
};
|
|
|
|
|
#undef VK_BOOL1BIT
|
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
class VulkanInstance
|
2019-04-09 00:22:26 +08:00
|
|
|
|
{
|
|
|
|
|
VkInstance inst;
|
|
|
|
|
|
2019-11-06 20:52:09 +08:00
|
|
|
|
VKDebugOut *debug_out;
|
2019-04-12 22:14:40 +08:00
|
|
|
|
|
2025-05-17 20:26:36 +08:00
|
|
|
|
ObjectList<VulkanPhyDevice> physical_devices;
|
2019-04-09 02:02:43 +08:00
|
|
|
|
|
2021-09-23 22:13:57 +08:00
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
|
|
|
|
|
|
2019-04-09 00:22:26 +08:00
|
|
|
|
private:
|
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
friend VulkanInstance *CreateInstance(const AnsiString &app_name,VKDebugOut *out=nullptr,CreateInstanceLayerInfo *cili=nullptr);
|
2019-04-11 02:29:21 +08:00
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
VulkanInstance(VkInstance,VKDebugOut *);
|
2019-04-09 00:22:26 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
virtual ~VulkanInstance();
|
2019-04-09 00:22:26 +08:00
|
|
|
|
|
2019-05-07 12:46:25 +08:00
|
|
|
|
operator VkInstance (){return inst;}
|
2019-04-09 02:02:43 +08:00
|
|
|
|
|
2025-05-17 20:26:36 +08:00
|
|
|
|
const ObjectList<VulkanPhyDevice> &GetDeviceList ()const {return physical_devices;}
|
|
|
|
|
const VulkanPhyDevice * GetDevice (VkPhysicalDeviceType)const;
|
2020-10-28 17:28:07 +08:00
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
T *GetInstanceProc(const char *name)
|
|
|
|
|
{
|
|
|
|
|
return reinterpret_cast<T>(vkGetInstanceProcAddr(inst,name));
|
|
|
|
|
}
|
2021-09-23 22:13:57 +08:00
|
|
|
|
|
|
|
|
|
template<typename T>
|
2024-07-26 03:25:09 +08:00
|
|
|
|
T *GetDeviceProc(VkDevice *dev,const char *name)
|
2021-09-23 22:13:57 +08:00
|
|
|
|
{
|
|
|
|
|
if(!GetDeviceProcAddr)return(nullptr);
|
|
|
|
|
|
2024-07-26 03:25:09 +08:00
|
|
|
|
return reinterpret_cast<T>(GetDeviceProcAddr(dev,name));
|
2021-09-23 22:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DestroySurface(VkSurfaceKHR);
|
2020-10-21 12:39:22 +08:00
|
|
|
|
};//class VulkanInstance
|
2019-11-13 19:55:13 +08:00
|
|
|
|
|
2020-10-28 17:28:07 +08:00
|
|
|
|
void InitVulkanInstanceProperties();
|
2025-04-23 00:27:43 +08:00
|
|
|
|
const ArrayList<VkLayerProperties> & GetInstanceLayerProperties();
|
|
|
|
|
const ArrayList<VkExtensionProperties> & GetInstanceExtensionProperties();
|
2020-10-28 17:28:07 +08:00
|
|
|
|
const bool CheckInstanceLayerSupport(const AnsiString &);
|
|
|
|
|
const bool GetInstanceLayerVersion(const AnsiString &,uint32_t &spec,uint32_t &impl);
|
|
|
|
|
const bool CheckInstanceExtensionSupport(const AnsiString &);
|
2019-04-11 02:29:21 +08:00
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
VulkanInstance *CreateInstance(const AnsiString &,VKDebugOut *,CreateInstanceLayerInfo *); ///<创建一个Vulkan实例
|
2019-04-09 00:22:26 +08:00
|
|
|
|
VK_NAMESPACE_END
|
|
|
|
|
#endif//HGL_GRAPH_VULKAN_INSTANCE_INCLUDE
|