From 54e5531fc4aa8ec6da4ff13cec7ffbf5e0dd1e2b Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sun, 23 Aug 2020 19:43:50 +0800 Subject: [PATCH] support .shader file(version 1) --- example/Vulkan/DrawText.cpp | 2 +- example/Vulkan/LoadStaticMesh.cpp | 2 +- inc/hgl/graph/shader/ShaderResource.h | 12 +++++++----- inc/hgl/graph/vulkan/VKDevice.h | 2 +- .../Vulkan/VKDescriptorSetLayoutCreater.h | 6 +++--- src/SceneGraph/shader/ShaderResource.cpp | 7 +++++-- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/example/Vulkan/DrawText.cpp b/example/Vulkan/DrawText.cpp index 7a3ad9ab..81de9223 100644 --- a/example/Vulkan/DrawText.cpp +++ b/example/Vulkan/DrawText.cpp @@ -151,7 +151,7 @@ private: return tl_engine.Init(); } - + bool InitTextRenderable() { UTF16String str; diff --git a/example/Vulkan/LoadStaticMesh.cpp b/example/Vulkan/LoadStaticMesh.cpp index aa894be7..d3f1143f 100644 --- a/example/Vulkan/LoadStaticMesh.cpp +++ b/example/Vulkan/LoadStaticMesh.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include diff --git a/inc/hgl/graph/shader/ShaderResource.h b/inc/hgl/graph/shader/ShaderResource.h index a9df38ba..57a88cc6 100644 --- a/inc/hgl/graph/shader/ShaderResource.h +++ b/inc/hgl/graph/shader/ShaderResource.h @@ -20,13 +20,15 @@ VK_NAMESPACE_BEGIN uint binding; };//struct ShaderStage - using ShaderStageList =ObjectList; - using ShaderBindingList =List; + using ShaderStageList =ObjectList; + using DescriptorSetList =List; + using DescriptorBindingList =List; struct ShaderDescriptorList { - AnsiStringList name_list; - ShaderBindingList binding_list; + AnsiStringList name_list; + DescriptorSetList set_list; + DescriptorBindingList binding_list; }; #ifndef VK_DESCRIPTOR_TYPE_BEGIN_RANGE @@ -88,7 +90,7 @@ VK_NAMESPACE_BEGIN ShaderDescriptorList &GetSampler(){return descriptor_list[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER];} const int GetBinding (VkDescriptorType desc_type,const AnsiString &name)const; - const ShaderBindingList * GetBindingList (VkDescriptorType desc_type)const + const DescriptorBindingList * GetBindingList (VkDescriptorType desc_type)const { if(desc_typeVK_DESCRIPTOR_TYPE_END_RANGE)return nullptr; diff --git a/inc/hgl/graph/vulkan/VKDevice.h b/inc/hgl/graph/vulkan/VKDevice.h index 21a1446b..020ad646 100644 --- a/inc/hgl/graph/vulkan/VKDevice.h +++ b/inc/hgl/graph/vulkan/VKDevice.h @@ -97,7 +97,7 @@ public: //Buffer相关 VAB * CreateVAB (VkFormat format,uint32_t count, VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(format,count,nullptr,sharing_mode);} VAB * CreateVAB (const VAD *vad, VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(vad->GetVulkanFormat(),vad->GetCount(),vad->GetData(),sharing_mode);} - IndexBuffer * CreateIBO (VkIndexType index_type,uint32_t count,const void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); + IndexBuffer * CreateIBO (VkIndexType index_type,uint32_t count,const void * data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); IndexBuffer * CreateIBO16 ( uint32_t count,const uint16 *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateIBO(VK_INDEX_TYPE_UINT16,count,(void *)data,sharing_mode);} IndexBuffer * CreateIBO32 ( uint32_t count,const uint32 *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateIBO(VK_INDEX_TYPE_UINT32,count,(void *)data,sharing_mode);} diff --git a/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.h b/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.h index 652d2b39..af65f88d 100644 --- a/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.h +++ b/src/RenderDevice/Vulkan/VKDescriptorSetLayoutCreater.h @@ -26,10 +26,10 @@ public: void Bind(const uint32_t binding,VkDescriptorType,VkShaderStageFlagBits); void Bind(const uint32_t *binding,const uint32_t count,VkDescriptorType type,VkShaderStageFlagBits stage); - void Bind(const ShaderBindingList &sbl,VkDescriptorType type,VkShaderStageFlagBits stage) + void Bind(const DescriptorBindingList &dbl,VkDescriptorType type,VkShaderStageFlagBits stage) { - if(sbl.GetCount()>0) - Bind(sbl.GetData(),sbl.GetCount(),type,stage); + if(dbl.GetCount()>0) + Bind(dbl.GetData(),dbl.GetCount(),type,stage); } void Bind(const ShaderDescriptorList *sdl,VkShaderStageFlagBits stage) diff --git a/src/SceneGraph/shader/ShaderResource.cpp b/src/SceneGraph/shader/ShaderResource.cpp index a5bb7ae9..c7cdc615 100644 --- a/src/SceneGraph/shader/ShaderResource.cpp +++ b/src/SceneGraph/shader/ShaderResource.cpp @@ -53,7 +53,7 @@ VK_NAMESPACE_BEGIN return data; } - const uint8 *LoadShaderDescriptor(ShaderDescriptorList *sd_list,const uint8 *data) + const uint8 *LoadShaderDescriptor(const uint8_t version,ShaderDescriptorList *sd_list,const uint8 *data) { const uint32 total_bytes=AccessByPointer(data,uint32); @@ -63,6 +63,9 @@ VK_NAMESPACE_BEGIN for(uint i=0;i=1) + sd_list->set_list.Add(*data++); + sd_list->binding_list.Add(*data++); str_len=*data++; sd_list->name_list.Add(AnsiString((char *)data,str_len)); @@ -174,7 +177,7 @@ VK_NAMESPACE_BEGIN { desc_type=AccessByPointer(filedata,uint32); - filedata=LoadShaderDescriptor(sr->GetDescriptorList((VkDescriptorType)desc_type),filedata); + filedata=LoadShaderDescriptor(version,sr->GetDescriptorList((VkDescriptorType)desc_type),filedata); } return sr;