diff --git a/inc/hgl/graph/SceneDB.h b/inc/hgl/graph/SceneDB.h index 630fa4fb..143b1cd2 100644 --- a/inc/hgl/graph/SceneDB.h +++ b/inc/hgl/graph/SceneDB.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include namespace hgl @@ -26,7 +26,7 @@ namespace hgl using SamplerID =int; using TextureID =int; - class VertexAttribBufferCreater; + class VertexAttribData; /** * 场景DB,用于管理场景内所需的所有数据 @@ -66,7 +66,7 @@ namespace hgl vulkan::VertexAttribBuffer *CreateVAB(VkFormat format,uint32_t count,const void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); vulkan::VertexAttribBuffer *CreateVAB(VkFormat format,uint32_t count,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(format,count,nullptr,sharing_mode);} - vulkan::VertexAttribBuffer *CreateVAB(const VertexAttribBufferCreater *vbc,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(vbc->GetDataType(),vbc->GetCount(),vbc->GetData(),sharing_mode);} + vulkan::VertexAttribBuffer *CreateVAB(const VertexAttribData *vbc,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(vbc->GetDataType(),vbc->GetCount(),vbc->GetData(),sharing_mode);} #define SCENE_DB_CREATE_FUNC(name) vulkan::Buffer *Create##name(VkDeviceSize size,void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); \ vulkan::Buffer *Create##name(VkDeviceSize size,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); diff --git a/inc/hgl/graph/VertexAttribBuffer.h b/inc/hgl/graph/VertexAttribBuffer.h index 71c684a7..190c4e1a 100644 --- a/inc/hgl/graph/VertexAttribBuffer.h +++ b/inc/hgl/graph/VertexAttribBuffer.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace hgl { @@ -14,7 +14,7 @@ namespace hgl /** * 顶点属性数据实际模板 */ - template class VertexAttribBufferBase:public VertexAttribBufferCreater + template class VertexAttribBufferBase:public VertexAttribData { protected: @@ -25,7 +25,7 @@ namespace hgl public: - VertexAttribBufferBase(uint32_t _size,const T *_data=nullptr):VertexAttribBufferCreater(_size,C,sizeof(T)) + VertexAttribBufferBase(uint32_t _size,const T *_data=nullptr):VertexAttribData(_size,C,sizeof(T)) { mem_type=(T *)GetData(); access=0; @@ -1135,7 +1135,7 @@ namespace hgl * @param vecsize vec数量 * @param vertex_count 顶点数量 */ - VertexAttribBufferCreater *CreateVABCreater(const uint32_t base_type,const uint32_t vecsize,const uint32_t vertex_count); + VertexAttribData *CreateVABCreater(const uint32_t base_type,const uint32_t vecsize,const uint32_t vertex_count); }//namespace graph }//namespace hgl #endif//HGL_GRAPH_VERTEX_ATTRIB_BUFFER_INCLUDE diff --git a/inc/hgl/graph/VertexAttribBufferCreater.h b/inc/hgl/graph/VertexAttribData.h similarity index 92% rename from inc/hgl/graph/VertexAttribBufferCreater.h rename to inc/hgl/graph/VertexAttribData.h index b54624e1..753c9bf0 100644 --- a/inc/hgl/graph/VertexAttribBufferCreater.h +++ b/inc/hgl/graph/VertexAttribData.h @@ -1,5 +1,5 @@ -#ifndef HGL_GRAPH_VERTEX_ATTRIB_BUFFER_CREATER_INCLUDE -#define HGL_GRAPH_VERTEX_ATTRIB_BUFFER_CREATER_INCLUDE +#ifndef HGL_GRAPH_VERTEX_ATTRIB_DATA_INCLUDE +#define HGL_GRAPH_VERTEX_ATTRIB_DATA_INCLUDE #include namespace hgl @@ -7,7 +7,7 @@ namespace hgl namespace graph { /** - * 顶点属性缓冲区创建者 + * 顶点属性数据 */ class VertexAttribData ///顶点属性缓冲区创建者 { @@ -50,4 +50,4 @@ namespace hgl using VAD=VertexAttribData; }//namespace graph }//namespace hgl -#endif//HGL_GRAPH_VERTEX_ATTRIB_BUFFER_CREATER_INCLUDE +#endif//HGL_GRAPH_VERTEX_ATTRIB_DATA_INCLUDE diff --git a/inc/hgl/graph/vulkan/VKDevice.h b/inc/hgl/graph/vulkan/VKDevice.h index 25e03057..13436886 100644 --- a/inc/hgl/graph/vulkan/VKDevice.h +++ b/inc/hgl/graph/vulkan/VKDevice.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace hgl { @@ -89,7 +89,7 @@ public: //Buffer相关 VertexAttribBuffer * CreateVAB(VkFormat format,uint32_t count,const void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE); VertexAttribBuffer * CreateVAB(VkFormat format,uint32_t count,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(format,count,nullptr,sharing_mode);} - VertexAttribBuffer * CreateVAB(const VertexAttribBufferCreater *vbc,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(vbc->GetDataType(),vbc->GetCount(),vbc->GetData(),sharing_mode);} + VertexAttribBuffer * CreateVAB(const VertexAttribData *vbc,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVAB(vbc->GetDataType(),vbc->GetCount(),vbc->GetData(),sharing_mode);} 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);} diff --git a/src/RenderDevice/Vulkan/VKBuffer.cpp b/src/RenderDevice/Vulkan/VKBuffer.cpp index 5529f15f..22cdfde5 100644 --- a/src/RenderDevice/Vulkan/VKBuffer.cpp +++ b/src/RenderDevice/Vulkan/VKBuffer.cpp @@ -9,7 +9,7 @@ Buffer::~Buffer() vkDestroyBuffer(device,buf.buffer,nullptr); } -VertexAttribBufferCreater *CreateVABCreater(const uint32_t base_type,const uint32_t vecsize,const uint32_t vertex_count) +VertexAttribData *CreateVABCreater(const uint32_t base_type,const uint32_t vecsize,const uint32_t vertex_count) { if(base_type==spirv_cross::SPIRType::SByte) { diff --git a/src/SceneGraph/CMakeLists.txt b/src/SceneGraph/CMakeLists.txt index 8e50e28a..8ed03a5d 100644 --- a/src/SceneGraph/CMakeLists.txt +++ b/src/SceneGraph/CMakeLists.txt @@ -12,10 +12,10 @@ SOURCE_GROUP("Material" FILES ${SG_MATERIAL_HEADER} SOURCE_GROUP("Material\\Shader" FILES ${SHADER_RESOURCE_FILES}) -SET(SG_VERTEX_SOURCE ${ROOT_INCLUDE_PATH}/hgl/graph/VertexAttribBufferCreater.h +SET(SG_VAB_SOURCE ${ROOT_INCLUDE_PATH}/hgl/graph/VertexAttribData.h ${ROOT_INCLUDE_PATH}/hgl/graph/VertexAttribBuffer.h) -SOURCE_GROUP("VertexBuffer" FILES ${SG_VERTEX_SOURCE}) +SOURCE_GROUP("VertexAttribBuffer" FILES ${SG_VAB_SOURCE}) SET(SCENE_GRAPH_HEADER ${ROOT_INCLUDE_PATH}/hgl/graph/Light.h ${ROOT_INCLUDE_PATH}/hgl/graph/SceneDB.h @@ -78,7 +78,7 @@ add_cm_library(ULRE.SceneGraph "ULRE" ${SCENE_GRAPH_HEADER} ${SG_MATERIAL_HEADER} ${SG_MATERIAL_SOURCE} - ${SG_VERTEX_SOURCE} + ${SG_VAB_SOURCE} ${RENDERABLE_FILES} diff --git a/src/SceneGraph/InlineGeometry.cpp b/src/SceneGraph/InlineGeometry.cpp index 9ddbda68..1c71eb09 100644 --- a/src/SceneGraph/InlineGeometry.cpp +++ b/src/SceneGraph/InlineGeometry.cpp @@ -6,11 +6,13 @@ #include #include #include +#include + namespace hgl { namespace graph { - namespace +/* namespace { template struct GeometryCreater @@ -103,7 +105,7 @@ namespace hgl private: - void Finish(int binding,VertexAttribBufferCreater *vb) + void Finish(int binding,VertexAttribData *vb) { render_obj->Set(binding,db->CreateVAB(vb)); delete vb; @@ -141,15 +143,18 @@ namespace hgl using GeometryCreater3D=GeometryCreater; using GeometryCreater2D=GeometryCreater; }//namespace - + */ vulkan::Renderable *CreateRenderableRectangle(SceneDB *db,vulkan::Material *mtl,const RectangleCreateInfo *rci) { - GeometryCreater2D gc(db,mtl); + RenderableCreater rc(db,mtl); - if(!gc.Init(4)) + if(!rc.Init(4)) return(nullptr); - VB2f *vertex=gc.GetVertex(); + VAD *vertex=rc.CreateVAB(VAN::Vertex); + + if(vertex->GetComponent()!=2) + return(nullptr); vertex->WriteRectFan(rci->scope); diff --git a/src/SceneGraph/RenderableCreater.cpp b/src/SceneGraph/RenderableCreater.cpp index f5037c7a..faa9e76e 100644 --- a/src/SceneGraph/RenderableCreater.cpp +++ b/src/SceneGraph/RenderableCreater.cpp @@ -24,7 +24,7 @@ namespace hgl return(true); } - VertexAttribBufferCreater *RenderableCreater::CreateVAB(const AnsiString &name) + VertexAttribData *RenderableCreater::CreateVAB(const AnsiString &name) { if(!vsm)return(false);