From 532a8e3b5611ea1c277702dcd05bc49c26429364 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Thu, 11 Jun 2020 18:25:08 +0800 Subject: [PATCH] update support VkVulkanSDK 1.2.141 --- CMSceneGraph | 2 +- inc/hgl/graph/shader/ShaderResource.h | 12 ++++++++++ inc/hgl/graph/vulkan/VKPipeline.h | 12 ++++++++++ inc/hgl/graph/vulkan/VKPrimivate.h | 6 ++--- .../Vulkan/POD/VKTextureLoader.cpp | 3 +-- src/RenderDevice/Vulkan/VKDeviceCreater.cpp | 24 +++++++++++++++++++ src/RenderDevice/Vulkan/VKDeviceImage.cpp | 2 +- src/RenderDevice/Vulkan/VKPipeline.cpp | 2 +- 8 files changed, 55 insertions(+), 8 deletions(-) diff --git a/CMSceneGraph b/CMSceneGraph index c879515d..89d5cb4f 160000 --- a/CMSceneGraph +++ b/CMSceneGraph @@ -1 +1 @@ -Subproject commit c879515d448d129ada207364e223c59694204b86 +Subproject commit 89d5cb4fd6e13f7017ac35aa2232d8851c4782ca diff --git a/inc/hgl/graph/shader/ShaderResource.h b/inc/hgl/graph/shader/ShaderResource.h index 6a658576..dcbb8bbd 100644 --- a/inc/hgl/graph/shader/ShaderResource.h +++ b/inc/hgl/graph/shader/ShaderResource.h @@ -21,6 +21,18 @@ VK_NAMESPACE_BEGIN ShaderBindingList binding_list; }; + #ifndef VK_DESCRIPTOR_TYPE_BEGIN_RANGE + constexpr size_t VK_DESCRIPTOR_TYPE_BEGIN_RANGE=VK_DESCRIPTOR_TYPE_SAMPLER; + #endif//VK_DESCRIPTOR_TYPE_BEGIN_RANGE + + #ifndef VK_DESCRIPTOR_TYPE_END_RANGE + constexpr size_t VK_DESCRIPTOR_TYPE_END_RANGE=VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; + #endif//VK_DESCRIPTOR_TYPE_END_RANGE + + #ifndef VK_DESCRIPTOR_TYPE_RANGE_SIZE + constexpr size_t VK_DESCRIPTOR_TYPE_RANGE_SIZE=VK_DESCRIPTOR_TYPE_END_RANGE-VK_DESCRIPTOR_TYPE_BEGIN_RANGE+1; + #endif//VK_DESCRIPTOR_TYPE_RANGE_SIZE + class ShaderResource { const void *data; diff --git a/inc/hgl/graph/vulkan/VKPipeline.h b/inc/hgl/graph/vulkan/VKPipeline.h index 4162e687..5880f3b3 100644 --- a/inc/hgl/graph/vulkan/VKPipeline.h +++ b/inc/hgl/graph/vulkan/VKPipeline.h @@ -27,6 +27,18 @@ public: constexpr size_t MAX_SAMPLE_MASK_COUNT=(VK_SAMPLE_COUNT_64_BIT+31)/32; +#ifndef VK_DYNAMIC_STATE_BEGIN_RANGE +constexpr size_t VK_DYNAMIC_STATE_BEGIN_RANGE=VK_DYNAMIC_STATE_VIEWPORT; +#endif//VK_DYNAMIC_STATE_BEGIN_RANGE + +#ifndef VK_DYNAMIC_STATE_END_RANGE +constexpr size_t VK_DYNAMIC_STATE_END_RANGE=VK_DYNAMIC_STATE_STENCIL_REFERENCE; +#endif//VK_DYNAMIC_STATE_END_RANGE + +#ifndef VK_DYNAMIC_STATE_RANGE_SIZE +constexpr size_t VK_DYNAMIC_STATE_RANGE_SIZE=VK_DYNAMIC_STATE_END_RANGE-VK_DYNAMIC_STATE_BEGIN_RANGE+1; +#endif//VK_DYNAMIC_STATE_RANGE_SIZE + class PipelineCreater { VkDevice device; diff --git a/inc/hgl/graph/vulkan/VKPrimivate.h b/inc/hgl/graph/vulkan/VKPrimivate.h index 13b52c77..efd6cece 100644 --- a/inc/hgl/graph/vulkan/VKPrimivate.h +++ b/inc/hgl/graph/vulkan/VKPrimivate.h @@ -15,8 +15,8 @@ #define PRIM_TRIANGLE_STRIP_ADJ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ///<4+2N个Vertices代表N个Primitive,其中1,3,5,7,9...代表原本的Triangle strip形成Triangle,而2,4,6,8,10...代表邻近提供信息的点.(由1起算) #define PRIM_PATCHS VK_PRIMITIVE_TOPOLOGY_PATCH_LIST #define PRIM_RECTANGLE 0x100 ///<矩形(并非原生支持。以画点形式在每个点的Position中传递Left,Top,Width,Height。在Geometry Shader中转换为2个三角形。用于2D游戏或UI) -#define PRIM_BEGIN VK_PRIMITIVE_TOPOLOGY_BEGIN_RANGE -#define PRIM_END VK_PRIMITIVE_TOPOLOGY_END_RANGE -#define PRIM_RANGE VK_PRIMITIVE_TOPOLOGY_RANGE_SIZE +#define PRIM_BEGIN VK_PRIMITIVE_TOPOLOGY_POINT_LIST +#define PRIM_END VK_PRIMITIVE_TOPOLOGY_PATCH_LIST +constexpr uint32_t PRIM_RANGE =PRIM_END-PRIM_BEGIN+1; #endif//HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE diff --git a/src/RenderDevice/Vulkan/POD/VKTextureLoader.cpp b/src/RenderDevice/Vulkan/POD/VKTextureLoader.cpp index 459d2556..84744247 100644 --- a/src/RenderDevice/Vulkan/POD/VKTextureLoader.cpp +++ b/src/RenderDevice/Vulkan/POD/VKTextureLoader.cpp @@ -131,8 +131,7 @@ Texture2D *CreateTextureFromFile(Device *device,const OSString &filename) const VkFormat format=file_header.vk_format(); - if(format<=VK_FORMAT_BEGIN_RANGE - ||format>=VK_FORMAT_END_RANGE) + if(!CheckVulkanFormat(format)) return(nullptr); const uint total_bytes=file_header.total_bytes(); diff --git a/src/RenderDevice/Vulkan/VKDeviceCreater.cpp b/src/RenderDevice/Vulkan/VKDeviceCreater.cpp index 401dd9af..a290e6b7 100644 --- a/src/RenderDevice/Vulkan/VKDeviceCreater.cpp +++ b/src/RenderDevice/Vulkan/VKDeviceCreater.cpp @@ -320,6 +320,18 @@ namespace #undef OUT_PHYSICAL_DEVICE_LIMIT_INTEGER } + #ifndef VK_PHYSICAL_DEVICE_TYPE_BEGIN_RANGE + #define VK_PHYSICAL_DEVICE_TYPE_BEGIN_RANGE VK_PHYSICAL_DEVICE_TYPE_OTHER + #endif//VK_PHYSICAL_DEVICE_TYPE_BEGIN_RANGE + + #ifndef VK_PHYSICAL_DEVICE_TYPE_END_RANGE + #define VK_PHYSICAL_DEVICE_TYPE_END_RANGE VK_PHYSICAL_DEVICE_TYPE_CPU + #endif//VK_PHYSICAL_DEVICE_TYPE_END_RANGE + + #ifndef VK_PHYSICAL_DEVICE_TYPE_RANGE_SIZE + constexpr size_t VK_PHYSICAL_DEVICE_TYPE_RANGE_SIZE=VK_PHYSICAL_DEVICE_TYPE_END_RANGE-VK_PHYSICAL_DEVICE_TYPE_BEGIN_RANGE+1; + #endif//VK_PHYSICAL_DEVICE_TYPE_RANGE_SIZE + void DebugOut(const VkPhysicalDeviceProperties &pdp) { constexpr char DeviceTypeString[VK_PHYSICAL_DEVICE_TYPE_RANGE_SIZE][16]= @@ -346,6 +358,18 @@ namespace } }//namespace +#ifndef VK_DRIVER_ID_BEGIN_RANGE +#define VK_DRIVER_ID_BEGIN_RANGE VK_DRIVER_ID_AMD_PROPRIETARY +#endif//VK_DRIVER_ID_BEGIN_RANGE + +#ifndef VK_DRIVER_ID_END_RANGE +#define VK_DRIVER_ID_END_RANGE VK_DRIVER_ID_MESA_LLVMPIPE +#endif//VK_DRIVER_ID_END_RANGE + +#ifndef VK_DRIVER_ID_RANGE_SIZE +constexpr size_t VK_DRIVER_ID_RANGE_SIZE=VK_DRIVER_ID_END_RANGE-VK_DRIVER_ID_BEGIN_RANGE+1; +#endif//VK_DRIVER_ID_RANGE_SIZE + Device *CreateRenderDevice(VkInstance inst,const PhysicalDevice *physical_device,VkSurfaceKHR surface,const VkExtent2D &extent) { #ifdef _DEBUG diff --git a/src/RenderDevice/Vulkan/VKDeviceImage.cpp b/src/RenderDevice/Vulkan/VKDeviceImage.cpp index 4578effd..5159bba1 100644 --- a/src/RenderDevice/Vulkan/VKDeviceImage.cpp +++ b/src/RenderDevice/Vulkan/VKDeviceImage.cpp @@ -3,7 +3,7 @@ VK_NAMESPACE_BEGIN VkImage Device::CreateImage(const VkFormat format,uint32_t width,uint32_t height,const uint usage,const VkImageTiling tiling) { - if(formatVK_FORMAT_END_RANGE)return(nullptr); + if(!CheckVulkanFormat(format))return(nullptr); if(width<1||height<1)return(nullptr); VkImageCreateInfo imageCreateInfo; diff --git a/src/RenderDevice/Vulkan/VKPipeline.cpp b/src/RenderDevice/Vulkan/VKPipeline.cpp index 0f53d0c6..7d8d7559 100644 --- a/src/RenderDevice/Vulkan/VKPipeline.cpp +++ b/src/RenderDevice/Vulkan/VKPipeline.cpp @@ -218,7 +218,7 @@ PipelineCreater::PipelineCreater(Device *dev,const Material *material,const Rend bool PipelineCreater::Set(const VkPrimitiveTopology topology,bool restart) { - if(topologyVK_PRIMITIVE_TOPOLOGY_END_RANGE) + if(topologyPRIM_END) if(topology!=PRIM_RECTANGLE)return(false); inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;