From dc50f1e0d34b6cc93154e978deefebfc3a18e19e Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 13 Nov 2019 20:50:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B0=E7=9A=84CheckInstan?= =?UTF-8?q?ceLayer=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/graph/vulkan/VK.h | 2 ++ src/RenderDevice/Vulkan/VKInstance.cpp | 34 ++------------------ src/RenderDevice/Vulkan/VKProperties.cpp | 40 ++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/inc/hgl/graph/vulkan/VK.h b/inc/hgl/graph/vulkan/VK.h index 53803eea..204f4082 100644 --- a/inc/hgl/graph/vulkan/VK.h +++ b/inc/hgl/graph/vulkan/VK.h @@ -10,6 +10,8 @@ VK_NAMESPACE_BEGIN +using CharPointerList=hgl::List; + class Instance; class PhysicalDevice; class Device; diff --git a/src/RenderDevice/Vulkan/VKInstance.cpp b/src/RenderDevice/Vulkan/VKInstance.cpp index 9c6afa1a..f0082a3d 100644 --- a/src/RenderDevice/Vulkan/VKInstance.cpp +++ b/src/RenderDevice/Vulkan/VKInstance.cpp @@ -7,7 +7,7 @@ VK_NAMESPACE_BEGIN Device *CreateRenderDevice(VkInstance,const PhysicalDevice *,Window *); -using CharPointerList=hgl::List; +void CheckInstanceLayer(CharPointerList &layer_list,CreateInstanceLayerInfo *layer_info); Instance *CreateInstance(const UTF8String &app_name,VKDebugOut *out,CreateInstanceLayerInfo *layer_info) { @@ -33,37 +33,7 @@ Instance *CreateInstance(const UTF8String &app_name,VKDebugOut *out,CreateInstan #endif//_DEBUG if(layer_info) - { - #define VK_LAYER_LUNARG_ADD(name) if(layer_info->lunarg.name)layer_list.Add("VK_LAYER_LUNARG_" #name); - - VK_LAYER_LUNARG_ADD(api_dump) - VK_LAYER_LUNARG_ADD(device_simulation) - VK_LAYER_LUNARG_ADD(monitor) - VK_LAYER_LUNARG_ADD(screenshot) - VK_LAYER_LUNARG_ADD(standard_validation) - VK_LAYER_LUNARG_ADD(vktrace) - - #define VK_LAYER_KHRONOS_ADD(name) if(layer_info->khronos.name)layer_list.Add("VK_LAYER_KHRONOS_" #name); - - VK_LAYER_KHRONOS_ADD(validation) - - #define VK_LAYER_NV_ADD(name) if(layer_info->nv.name)layer_list.Add("VK_LAYER_NV_" #name); - - VK_LAYER_NV_ADD(optimus) - - #define VK_LAYER_VALVE_ADD(name) if(layer_info->valve.name)layer_list.Add("VK_LAYER_VALVE_" #name); - - VK_LAYER_VALVE_ADD(steam_overlay) - VK_LAYER_VALVE_ADD(steam_fossilize) - - #define VK_LAYER_RENDERDOC_ADD(name) if(layer_info->RenderDoc.name)layer_list.Add("VK_LAYER_RENDERDOC_" #name); - - VK_LAYER_RENDERDOC_ADD(Capture) - - #define VK_LAYER_BANDICAM_ADD(name) if(layer_info->bandicam.name)layer_list.Add("VK_LAYER_bandicam_" #name); - - VK_LAYER_BANDICAM_ADD(helper) - } + CheckInstanceLayer(layer_list,layer_info); inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; inst_info.pNext = nullptr; diff --git a/src/RenderDevice/Vulkan/VKProperties.cpp b/src/RenderDevice/Vulkan/VKProperties.cpp index d6d0dd7a..4c8f067a 100644 --- a/src/RenderDevice/Vulkan/VKProperties.cpp +++ b/src/RenderDevice/Vulkan/VKProperties.cpp @@ -1,4 +1,5 @@ #include +#include VK_NAMESPACE_BEGIN @@ -55,4 +56,43 @@ const bool CheckLayerSupport(const char *layer_name) return(false); } + +void CheckInstanceLayer(CharPointerList &layer_list,CreateInstanceLayerInfo *layer_info) +{ + #define VK_LAYER_CHECK(sname,lname,name) if(layer_info->sname.name) \ + { \ + if(CheckLayerSupport("VK_LAYER_" lname "_" #name)) \ + layer_list.Add("VK_LAYER_" lname "_" #name); \ + } + +#define VK_LAYER_LUNARG_ADD(name) VK_LAYER_CHECK(lunarg,"LUNARG",name) + + VK_LAYER_LUNARG_ADD(api_dump) + VK_LAYER_LUNARG_ADD(device_simulation) + VK_LAYER_LUNARG_ADD(monitor) + VK_LAYER_LUNARG_ADD(screenshot) + VK_LAYER_LUNARG_ADD(standard_validation) + VK_LAYER_LUNARG_ADD(vktrace) + +#define VK_LAYER_KHRONOS_ADD(name) VK_LAYER_CHECK(khronos,"KHRONOS",name) + + VK_LAYER_KHRONOS_ADD(validation) + +#define VK_LAYER_NV_ADD(name) VK_LAYER_CHECK(nv,"NV",name) + + VK_LAYER_NV_ADD(optimus) + +#define VK_LAYER_VALVE_ADD(name) VK_LAYER_CHECK(valve,"VALVE",name) + + VK_LAYER_VALVE_ADD(steam_overlay) + VK_LAYER_VALVE_ADD(steam_fossilize) + +#define VK_LAYER_RENDERDOC_ADD(name) VK_LAYER_CHECK(RenderDoc,"RENDERDOC",name) + + VK_LAYER_RENDERDOC_ADD(Capture) + +#define VK_LAYER_BANDICAM_ADD(name) VK_LAYER_CHECK(bandicam,"bandicam",name) + + VK_LAYER_BANDICAM_ADD(helper) +} VK_NAMESPACE_END