diff --git a/CMSceneGraph b/CMSceneGraph index 62363619..509273e4 160000 --- a/CMSceneGraph +++ b/CMSceneGraph @@ -1 +1 @@ -Subproject commit 6236361903f2a94f7ae8400294ff048263ff3725 +Subproject commit 509273e44937426ecc51116f5094564b96ea8b87 diff --git a/example/2dVector/line.cpp b/example/2dVector/line.cpp index b466f6f7..6cdb0f85 100644 --- a/example/2dVector/line.cpp +++ b/example/2dVector/line.cpp @@ -116,7 +116,7 @@ private: Primitive *primitive=db->CreatePrimitive(VERTEX_COUNT); if(!primitive)return(false); - if(!primitive->Set(VAN::Position, db->CreateVBO(VF_V2F,VERTEX_COUNT,position_data)))return(false); + if(!primitive->Set(VAN::Position, db->CreateVAB(VF_V2F,VERTEX_COUNT,position_data)))return(false); render_obj=db->CreateRenderable(primitive,material_instance,pipeline); return(true); diff --git a/example/2dVector/roundbox.cpp b/example/2dVector/roundbox.cpp index df838a4f..7ab04200 100644 --- a/example/2dVector/roundbox.cpp +++ b/example/2dVector/roundbox.cpp @@ -138,7 +138,7 @@ private: Primitive *primitive=db->CreatePrimitive(VERTEX_COUNT); if(!primitive)return(false); - if(!primitive->Set(VAN::Position, db->CreateVBO(VF_V4I16,VERTEX_COUNT,position_data)))return(false); + if(!primitive->Set(VAN::Position, db->CreateVAB(VF_V4I16,VERTEX_COUNT,position_data)))return(false); render_obj=db->CreateRenderable(primitive,material_instance,pipeline); return(true); diff --git a/example/Gizmo/Gizmo3DMove.cpp b/example/Gizmo/Gizmo3DMove.cpp index a975dd45..5a1864ec 100644 --- a/example/Gizmo/Gizmo3DMove.cpp +++ b/example/Gizmo/Gizmo3DMove.cpp @@ -180,8 +180,8 @@ private: for(Color4f &c:color_data[1])c=Color4f(0,1,0,1); for(Color4f &c:color_data[2])c=Color4f(0,0,1,1); - if(!ro_line->Set(VAN::Position, db->CreateVBO(VF_V3F,AXIS_MAX_VERTICES,position_data)))return(false); - if(!ro_line->Set(VAN::Color, db->CreateVBO(VF_V4F,AXIS_MAX_VERTICES,color_data )))return(false); + if(!ro_line->Set(VAN::Position, db->CreateVAB(VF_V3F,AXIS_MAX_VERTICES,position_data)))return(false); + if(!ro_line->Set(VAN::Color, db->CreateVAB(VF_V4F,AXIS_MAX_VERTICES,color_data )))return(false); } return(true); diff --git a/example/Gizmo/RayPicking.cpp b/example/Gizmo/RayPicking.cpp index 75208547..cd4ea7e6 100644 --- a/example/Gizmo/RayPicking.cpp +++ b/example/Gizmo/RayPicking.cpp @@ -106,8 +106,8 @@ private: ro_line=db->CreatePrimitive("Line",2); if(!ro_line)return(false); - if(!ro_line->Set(VAN::Position, vbo_pos= db->CreateVBO(VF_V3F,2,position_data )))return(false); - if(!ro_line->Set(VAN::Luminance, db->CreateVBO(VF_V1F,2,lumiance_data )))return(false); + if(!ro_line->Set(VAN::Position, vbo_pos= db->CreateVAB(VF_V3F,2,position_data )))return(false); + if(!ro_line->Set(VAN::Luminance, db->CreateVAB(VF_V1F,2,lumiance_data )))return(false); } return(true); diff --git a/inc/hgl/graph/PrimitiveCreater.h b/inc/hgl/graph/PrimitiveCreater.h index 73b5d325..48883e5c 100644 --- a/inc/hgl/graph/PrimitiveCreater.h +++ b/inc/hgl/graph/PrimitiveCreater.h @@ -32,11 +32,11 @@ namespace hgl IndexBuffer * ibo; void * ibo_map; - VBOAccessMap vbo_map; + VABAccessMap vbo_map; protected: - bool AcquirePVB(VBOAccessData *,const AnsiString &,const void *data); ///<请求一个顶点属性数据区 + bool AcquirePVB(VABAccess *,const AnsiString &,const void *data); ///<请求一个顶点属性数据区 void ClearAllData(); @@ -49,14 +49,14 @@ namespace hgl virtual bool Init(const uint32 vertices_count,const uint32 index_count,IndexType it=IndexType::AUTO); ///<初始化,参数为顶点数量 template - T * AccessVBO(const AnsiString &name) ///<创建一个顶点属性数据缓冲区以及访问器 + T * AccessVAB(const AnsiString &name) ///<创建一个顶点属性数据缓冲区以及访问器 { const VkFormat format=vil->GetVulkanFormat(name); if(format!=T::GetVulkanFormat()) return(nullptr); - VBOAccessData vad; + VABAccess vad; if(!this->AcquirePVB(&vad,name,nullptr)) return(nullptr); @@ -67,9 +67,10 @@ namespace hgl return access; } - bool WriteVBO(const AnsiString &name,const void *data,const uint32_t bytes); ///<直接写入顶点属性数据 + bool WriteVAB(const AnsiString &name,const void *data,const uint32_t bytes); ///<直接写入顶点属性数据 const IndexType GetIndexType()const{return ibo?ibo->GetType():IndexType::ERR;} ///<取得索引数据类型 + template T *AccessIBO() { if(!ibo)return(nullptr); diff --git a/inc/hgl/graph/VK.h b/inc/hgl/graph/VK.h index b6e5d7b6..c77673da 100644 --- a/inc/hgl/graph/VK.h +++ b/inc/hgl/graph/VK.h @@ -55,7 +55,7 @@ class DeviceBuffer; struct DeviceBufferData; class VertexAttribBuffer; -using VBO=VertexAttribBuffer; +using VAB=VertexAttribBuffer; class IndexBuffer; diff --git a/inc/hgl/graph/VKCommandBuffer.h b/inc/hgl/graph/VKCommandBuffer.h index b33c461d..4cd346e8 100644 --- a/inc/hgl/graph/VKCommandBuffer.h +++ b/inc/hgl/graph/VKCommandBuffer.h @@ -154,9 +154,9 @@ public: void PushConstants(const void *data,const uint32_t size) {vkCmdPushConstants(cmd_buf,pipeline_layout,VK_SHADER_STAGE_VERTEX_BIT,0, size,data);} void PushConstants(const void *data,const uint32_t offset,const uint32_t size) {vkCmdPushConstants(cmd_buf,pipeline_layout,VK_SHADER_STAGE_VERTEX_BIT,offset, size,data);} - void BindVBO(const uint32_t first,const uint32_t count,const VkBuffer *vbo,const VkDeviceSize *offsets) + void BindVBO(const uint32_t first,const uint32_t count,const VkBuffer *vab,const VkDeviceSize *offsets) { - vkCmdBindVertexBuffers(cmd_buf,first,count,vbo,offsets); + vkCmdBindVertexBuffers(cmd_buf,first,count,vab,offsets); } bool BindVBO(VBOList *vbo_list) diff --git a/inc/hgl/graph/VKDevice.h b/inc/hgl/graph/VKDevice.h index 55aed076..d5811aba 100644 --- a/inc/hgl/graph/VKDevice.h +++ b/inc/hgl/graph/VKDevice.h @@ -114,8 +114,8 @@ public: //Buffer相关 DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,data,sm);} DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,nullptr,sm);} - VBO * CreateVBO (VkFormat format, uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive); - VBO * CreateVBO (VkFormat format, uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVBO(format,count,nullptr,sm);} + VAB * CreateVAB (VkFormat format, uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive); + VAB * CreateVAB (VkFormat format, uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVAB(format,count,nullptr,sm);} const IndexType ChooseIndexType (const VkDeviceSize &vertex_count)const; ///<求一个合适的索引类型 const bool CheckIndexType (const IndexType,const VkDeviceSize &vertex_count)const; ///<检测一个索引类型是否合适 diff --git a/inc/hgl/graph/VKDeviceCreater.h b/inc/hgl/graph/VKDeviceCreater.h index 607543e0..60c381ff 100644 --- a/inc/hgl/graph/VKDeviceCreater.h +++ b/inc/hgl/graph/VKDeviceCreater.h @@ -58,7 +58,7 @@ struct VulkanHardwareRequirement // primitive topology // viewport // scissor - // bind vbo + // bind vab // depth test // depth write // depth compare op diff --git a/inc/hgl/graph/VKPrimitive.h b/inc/hgl/graph/VKPrimitive.h index 6d72fda8..8f6bf1c9 100644 --- a/inc/hgl/graph/VKPrimitive.h +++ b/inc/hgl/graph/VKPrimitive.h @@ -8,6 +8,22 @@ #include #include VK_NAMESPACE_BEGIN + +struct PrimitiveData +{ + uint32_t vertex_count; + + uint32_t va_count; + + + + VABAccess *vab_list; + + IndexBufferData index_buffer_data; + + AABB BoundingBox; +}; + /** * 单一图元数据 */ @@ -16,15 +32,13 @@ class Primitive GPUDevice *device; AnsiString prim_name; - VBOAccessMap buffer_list; - protected: uint32_t vertex_count; - IndexBufferData index_buffer_data; + VABAccessMap buffer_list; -protected: + IndexBufferData index_buffer_data; AABB BoundingBox; @@ -53,7 +67,7 @@ public: void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;} const AABB & GetBoundingBox()const {return BoundingBox;} - bool Set(const AnsiString &name,VBO *vb,VkDeviceSize offset=0); + bool Set(const AnsiString &name,VAB *vb,VkDeviceSize offset=0); bool Set(IndexBuffer *ib,VkDeviceSize offset=0); @@ -61,7 +75,7 @@ public: const uint32_t GetVertexCount ()const {return vertex_count;} - bool GetVBOAccessData (const AnsiString &,VBOAccessData *); + bool GetVBOAccessData (const AnsiString &,VABAccess *); const int GetBufferCount ()const {return buffer_list.GetCount();} const IndexBufferData * GetIndexBufferData ()const {return &index_buffer_data;} diff --git a/inc/hgl/graph/VKRenderResource.h b/inc/hgl/graph/VKRenderResource.h index bf86aa87..5cd4a90b 100644 --- a/inc/hgl/graph/VKRenderResource.h +++ b/inc/hgl/graph/VKRenderResource.h @@ -105,8 +105,8 @@ public: //Add public: // VBO/VAO - VBO *CreateVBO(VkFormat format,uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive); - VBO *CreateVBO(VkFormat format,uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVBO(format, count, nullptr, sm);} + VAB *CreateVAB(VkFormat format,uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive); + VAB *CreateVAB(VkFormat format,uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVAB(format, count, nullptr, sm);} #define SCENE_DB_CREATE_FUNC(name) DeviceBuffer *Create##name(const AnsiString &buf_name,VkDeviceSize size,void *data,SharingMode sm=SharingMode::Exclusive); \ DeviceBuffer *Create##name(const AnsiString &buf_name,VkDeviceSize size,SharingMode sm=SharingMode::Exclusive){return Create##name(buf_name,size,nullptr,sm);} diff --git a/inc/hgl/graph/VKRenderablePrimitiveCreater.h b/inc/hgl/graph/VKRenderablePrimitiveCreater.h index 69f3240e..2cff5485 100644 --- a/inc/hgl/graph/VKRenderablePrimitiveCreater.h +++ b/inc/hgl/graph/VKRenderablePrimitiveCreater.h @@ -24,13 +24,13 @@ public: VBO *SetVBO(const AnsiString &name,const VkFormat &fmt,const void *buf) { - VBO *vbo=rr->CreateVBO(fmt,vertex_count,buf); + VBO *vab=rr->CreateVAB(fmt,vertex_count,buf); - if(!vbo) + if(!vab) return(nullptr); - prim->Set(name,vbo); - return(vbo); + prim->Set(name,vab); + return(vab); } IndexBuffer *SetIBO(const IndexType &it,const void *buf,const uint32_t index_count) diff --git a/inc/hgl/graph/VKVertexAttribBuffer.h b/inc/hgl/graph/VKVertexAttribBuffer.h index e57bddc3..96e683cc 100644 --- a/inc/hgl/graph/VKVertexAttribBuffer.h +++ b/inc/hgl/graph/VKVertexAttribBuffer.h @@ -35,11 +35,11 @@ namespace hgl const VkDeviceSize GetBytes()const { return stride*count; } };//class VertexAttribBuffer:public DeviceBuffer - using VBO=VertexAttribBuffer; + using VAB=VertexAttribBuffer; - struct VBOAccessData + struct VABAccess { - VBO *vbo; + VAB *vab; VkDeviceSize offset; VkDeviceSize size; @@ -47,10 +47,10 @@ namespace hgl public: - CompOperatorMemcmp(const VBOAccessData &); - };//class VBOAccessData + CompOperatorMemcmp(const VABAccess &); + };//class VABAccess - using VBOAccessMap=Map; + using VABAccessMap=Map; }//namespace graph }//namespace hgl #endif//HGL_GRAPH_VULKAN_VERTEX_ATTRIB_BUFFER_INCLUDE diff --git a/inc/hgl/graph/VertexDataManager.h b/inc/hgl/graph/VertexDataManager.h index bd4f42d4..8e28809e 100644 --- a/inc/hgl/graph/VertexDataManager.h +++ b/inc/hgl/graph/VertexDataManager.h @@ -18,9 +18,9 @@ namespace hgl uint vi_count; ///<顶点输入流数量 const VIF * vif_list; ///<顶点输入格式列表 - VkDeviceSize vbo_max_size; ///<顶点缓冲区分配空间大小 - VkDeviceSize vbo_cur_size; ///<顶点缓冲区当前使用大小 - VBO ** vbo; ///<顶点缓冲区列表 + VkDeviceSize vab_max_size; ///<顶点缓冲区分配空间大小 + VkDeviceSize vab_cur_size; ///<顶点缓冲区当前使用大小 + VAB ** vab; ///<顶点缓冲区列表 VkDeviceSize ibo_cur_size; ///<索引缓冲区当前使用大小 IndexBuffer * ibo; ///<索引缓冲区 @@ -39,8 +39,8 @@ namespace hgl const VIL * GetVIL ()const{return vil;} ///<取得顶点输入格式列表 - const VkDeviceSize GetVBOMaxCount ()const{return vbo_max_size;} ///<取得顶点缓冲区分配的空间最大数量 - const VkDeviceSize GetVBOCurCount ()const{return vbo_cur_size;} ///<取得顶点缓冲区当前数量 + const VkDeviceSize GetVABMaxCount ()const{return vab_max_size;} ///<取得顶点属性缓冲区分配的空间最大数量 + const VkDeviceSize GetVABCurCount ()const{return vab_cur_size;} ///<取得顶点属性缓冲区当前数量 const IndexType GetIBOType ()const{return ibo?ibo->GetType():IndexType::ERR;} ///<取得索引缓冲区类型 const VkDeviceSize GetIBOMaxCount ()const{return ibo?ibo->GetCount():-1;} ///<取得索引缓冲区分配的空间最大数量 diff --git a/inc/hgl/graph/font/TextPrimitive.h b/inc/hgl/graph/font/TextPrimitive.h index 1498abf3..7bad2791 100644 --- a/inc/hgl/graph/font/TextPrimitive.h +++ b/inc/hgl/graph/font/TextPrimitive.h @@ -16,8 +16,8 @@ namespace hgl uint max_count; ///<缓冲区最大容量 - VBO * vbo_position; - VBO * vbo_tex_coord; + VAB * vab_position; + VAB * vab_tex_coord; protected: diff --git a/src/SceneGraph/InlineGeometry.cpp b/src/SceneGraph/InlineGeometry.cpp index cb55e2e9..e59c82c9 100644 --- a/src/SceneGraph/InlineGeometry.cpp +++ b/src/SceneGraph/InlineGeometry.cpp @@ -21,7 +21,7 @@ namespace hgl if(!rc.Init(4,0)) return(nullptr); - AutoDelete vertex=rc.AccessVBO(VAN::Position); + AutoDelete vertex=rc.AccessVAB(VAN::Position); if(!vertex) return(nullptr); @@ -49,7 +49,7 @@ namespace hgl if(!rc.Init(4,0)) return(nullptr); - AutoDelete vertex=rc.AccessVBO(VAN::Position); + AutoDelete vertex=rc.AccessVAB(VAN::Position); vertex->WriteRectFan(rci->scope); } @@ -63,7 +63,7 @@ namespace hgl if(!rc.Init(rci->round_per*4,8)) return(nullptr); - AutoDelete vertex=rc.AccessVBO(VAN::Position); + AutoDelete vertex=rc.AccessVAB(VAN::Position); Vector2f *coord=new Vector2f[rci->round_per]; @@ -131,8 +131,8 @@ namespace hgl if(!rc.Init(cci->field_count,0))return(nullptr); } - AutoDelete vertex=rc.AccessVBO(VAN::Position); - AutoDelete color=rc.AccessVBO(VAN::Color); + AutoDelete vertex=rc.AccessVAB(VAN::Position); + AutoDelete color=rc.AccessVAB(VAN::Color); if(!vertex) return(nullptr); @@ -169,7 +169,7 @@ namespace hgl if(!rc.Init(((pgci->grid_size.Width()+1)+(pgci->grid_size.Height()+1))*2,0)) return(nullptr); - AutoDelete vertex=rc.AccessVBO(VAN::Position); + AutoDelete vertex=rc.AccessVAB(VAN::Position); const float right=float(pgci->grid_size.Width())/2.0f; const float left =-right; @@ -189,7 +189,7 @@ namespace hgl Vector3f(left+col,bottom,0)); } - AutoDelete lum=rc.AccessVBO(VAN::Luminance); + AutoDelete lum=rc.AccessVAB(VAN::Luminance); if(lum) { for(uint row=0;row<=pgci->grid_size.Height();row++) @@ -224,22 +224,22 @@ namespace hgl if(!rc.Init(4,8)) return(nullptr); - rc.WriteVBO(VAN::Position,xy_vertices,sizeof(xy_vertices)); + rc.WriteVAB(VAN::Position,xy_vertices,sizeof(xy_vertices)); { - AutoDelete normal=rc.AccessVBO(VAN::Normal); + AutoDelete normal=rc.AccessVAB(VAN::Normal); if(normal)normal->RepeatWrite(xy_normal,4); } { - AutoDelete tangent=rc.AccessVBO(VAN::Tangent); + AutoDelete tangent=rc.AccessVAB(VAN::Tangent); if(tangent)tangent->RepeatWrite(xy_tangent,4); } { - AutoDelete tex_coord=rc.AccessVBO(VAN::TexCoord); + AutoDelete tex_coord=rc.AccessVAB(VAN::TexCoord); if(tex_coord) tex_coord->Write(xy_tex_coord,4); @@ -306,22 +306,22 @@ namespace hgl if(!rc.Init(24,6*2*3,IndexType::U16)) return(nullptr); - rc.WriteVBO(VAN::Position,positions,sizeof(positions)); + rc.WriteVAB(VAN::Position,positions,sizeof(positions)); if(cci->normal) - rc.WriteVBO(VAN::Normal,normals,sizeof(normals)); + rc.WriteVAB(VAN::Normal,normals,sizeof(normals)); if(cci->tangent) - rc.WriteVBO(VAN::Tangent,tangents,sizeof(tangents)); + rc.WriteVAB(VAN::Tangent,tangents,sizeof(tangents)); if(cci->tex_coord) - rc.WriteVBO(VAN::TexCoord,tex_coords,sizeof(tex_coords)); + rc.WriteVAB(VAN::TexCoord,tex_coords,sizeof(tex_coords)); if(cci->color_type!=CubeCreateInfo::ColorType::NoColor) { RANGE_CHECK_RETURN_NULLPTR(cci->color_type); - AutoDelete color=rc.AccessVBO(VAN::Color); + AutoDelete color=rc.AccessVAB(VAN::Color); if(color) { @@ -460,10 +460,10 @@ namespace hgl if(!rc.Init(numberVertices,numberIndices)) return(nullptr); - AutoDelete vertex=rc.AccessVBO(VAN::Position); - AutoDelete normal=rc.AccessVBO(VAN::Normal); - AutoDelete tangent=rc.AccessVBO(VAN::Tangent); - AutoDelete tex_coord=rc.AccessVBO(VAN::TexCoord); + AutoDelete vertex=rc.AccessVAB(VAN::Position); + AutoDelete normal=rc.AccessVAB(VAN::Normal); + AutoDelete tangent=rc.AccessVAB(VAN::Tangent); + AutoDelete tex_coord=rc.AccessVAB(VAN::TexCoord); float *vp=vertex->Get(); float *np=normal?normal->Get():nullptr; @@ -546,10 +546,10 @@ namespace hgl if(!rc.Init(numberVertices,numberIndices)) return(nullptr); - AutoDelete vertex=rc.AccessVBO(VAN::Position); - AutoDelete normal=rc.AccessVBO(VAN::Normal); - AutoDelete tangent=rc.AccessVBO(VAN::Tangent); - AutoDelete tex_coord=rc.AccessVBO(VAN::TexCoord); + AutoDelete vertex=rc.AccessVAB(VAN::Position); + AutoDelete normal=rc.AccessVAB(VAN::Normal); + AutoDelete tangent=rc.AccessVAB(VAN::Tangent); + AutoDelete tex_coord=rc.AccessVAB(VAN::TexCoord); float *vp=vertex->Get(); float *np=normal?normal->Get():nullptr; @@ -688,10 +688,10 @@ namespace hgl if(!rc.Init(numberVertices,numberIndices)) return(nullptr); - AutoDelete vertex=rc.AccessVBO(VAN::Position); - AutoDelete normal=rc.AccessVBO(VAN::Normal); - AutoDelete tangent=rc.AccessVBO(VAN::Tangent); - AutoDelete tex_coord=rc.AccessVBO(VAN::TexCoord); + AutoDelete vertex=rc.AccessVAB(VAN::Position); + AutoDelete normal=rc.AccessVAB(VAN::Normal); + AutoDelete tangent=rc.AccessVAB(VAN::Tangent); + AutoDelete tex_coord=rc.AccessVAB(VAN::TexCoord); float *vp=vertex->Get(); float *np=normal?normal->Get():nullptr; @@ -827,10 +827,10 @@ namespace hgl if (cci->numberSlices < 3 || numberVertices > GLUS_MAX_VERTICES || numberIndices > GLUS_MAX_INDICES) return nullptr; - AutoDelete vertex=rc.AccessVBO(VAN::Position); - AutoDelete normal=rc.AccessVBO(VAN::Normal); - AutoDelete tangent=rc.AccessVBO(VAN::Tangent); - AutoDelete tex_coord=rc.AccessVBO(VAN::TexCoord); + AutoDelete vertex=rc.AccessVAB(VAN::Position); + AutoDelete normal=rc.AccessVAB(VAN::Normal); + AutoDelete tangent=rc.AccessVAB(VAN::Tangent); + AutoDelete tex_coord=rc.AccessVAB(VAN::TexCoord); float *vp=vertex->Get(); float *np=normal?normal->Get():nullptr; @@ -1053,10 +1053,10 @@ namespace hgl if (cci->numberSlices < 3 || cci->numberStacks < 1 || numberVertices > GLUS_MAX_VERTICES || numberIndices > GLUS_MAX_INDICES) return nullptr; - AutoDelete vertex=rc.AccessVBO(VAN::Position); - AutoDelete normal=rc.AccessVBO(VAN::Normal); - AutoDelete tangent=rc.AccessVBO(VAN::Tangent); - AutoDelete tex_coord=rc.AccessVBO(VAN::TexCoord); + AutoDelete vertex=rc.AccessVAB(VAN::Position); + AutoDelete normal=rc.AccessVAB(VAN::Normal); + AutoDelete tangent=rc.AccessVAB(VAN::Tangent); + AutoDelete tex_coord=rc.AccessVAB(VAN::TexCoord); float *vp=vertex->Get(); float *np=normal?normal->Get():nullptr; @@ -1172,8 +1172,8 @@ namespace hgl if(!rc.Init(6,0)) return(nullptr); - AutoDelete vertex=rc.AccessVBO(VAN::Position); - AutoDelete color=rc.AccessVBO(VAN::Color); + AutoDelete vertex=rc.AccessVAB(VAN::Position); + AutoDelete color=rc.AccessVAB(VAN::Color); if(!vertex||!color) return(nullptr); @@ -1217,17 +1217,17 @@ namespace hgl if(!rc.Init(8,24,IndexType::U16)) return(nullptr); - AutoDelete vertex=rc.AccessVBO(VAN::Position); + AutoDelete vertex=rc.AccessVAB(VAN::Position); if(!vertex)return(nullptr); - rc.WriteVBO(VAN::Position,points,sizeof(points)); + rc.WriteVAB(VAN::Position,points,sizeof(points)); if(cci->color_type!=BoundingBoxCreateInfo::ColorType::NoColor) { RANGE_CHECK_RETURN_NULLPTR(cci->color_type); - AutoDelete color=rc.AccessVBO(VAN::Color); + AutoDelete color=rc.AccessVAB(VAN::Color); if(color) { diff --git a/src/SceneGraph/MaterialRenderList.cpp b/src/SceneGraph/MaterialRenderList.cpp index 9d347a9d..3736483e 100644 --- a/src/SceneGraph/MaterialRenderList.cpp +++ b/src/SceneGraph/MaterialRenderList.cpp @@ -14,7 +14,7 @@ * for(material) * for(pipeline) * for(material_instance) -* for(vbo) +* for(vab) */ template<> @@ -196,7 +196,7 @@ bool MaterialRenderList::Bind(const VertexInputData *vid,const uint ri_index) } if(mi_buffer) //材质实例组 - vbo_list->Add(mi_buffer->GetVBO(),MI_VBO_STRIDE_BYTES*ri_index); + vbo_list->Add(mi_buffer->GetVBO(),MI_VAB_STRIDE_BYTES*ri_index); //if(!vbo_list.IsFull()) //Joint组,暂未支持 //{ diff --git a/src/SceneGraph/PrimitiveCreater.cpp b/src/SceneGraph/PrimitiveCreater.cpp index 12bd6617..208545ba 100644 --- a/src/SceneGraph/PrimitiveCreater.cpp +++ b/src/SceneGraph/PrimitiveCreater.cpp @@ -85,7 +85,7 @@ namespace hgl return(true); } - bool PrimitiveCreater::AcquirePVB(VBOAccessData *vad,const AnsiString &name,const void *data) + bool PrimitiveCreater::AcquirePVB(VABAccess *vad,const AnsiString &name,const void *data) { if(!vad)return(false); if(!vil)return(false); @@ -99,10 +99,10 @@ namespace hgl if(vbo_map.Get(name,*vad)) return true; - vad->vbo =db->CreateVBO(vif->format,vertices_number,data); + vad->vab =db->CreateVAB(vif->format,vertices_number,data); if(!data) - vad->map_ptr=vad->vbo->Map(); + vad->map_ptr=vad->vab->Map(); else vad->map_ptr=nullptr; @@ -111,7 +111,7 @@ namespace hgl return true; } - bool PrimitiveCreater::WriteVBO(const AnsiString &name,const void *data,const uint32_t bytes) + bool PrimitiveCreater::WriteVAB(const AnsiString &name,const void *data,const uint32_t bytes) { if(!vil)return(false); if(name.IsEmpty())return(false); @@ -126,7 +126,7 @@ namespace hgl if(vif->stride*vertices_number!=bytes) return(false); - VBOAccessData vad; + VABAccess vad; return AcquirePVB(&vad,name,data); } @@ -138,10 +138,10 @@ namespace hgl const auto *sp=vbo_map.GetDataList(); for(uint i=0;ivalue.vbo) + if((*sp)->value.vab) { - (*sp)->value.vbo->Unmap(); - delete (*sp)->value.vbo; + (*sp)->value.vab->Unmap(); + delete (*sp)->value.vab; } ++sp; @@ -168,12 +168,12 @@ namespace hgl const auto *sp=vbo_map.GetDataList(); for(uint i=0;ivalue.vbo) + if((*sp)->value.vab) { if((*sp)->value.map_ptr) - (*sp)->value.vbo->Unmap(); + (*sp)->value.vab->Unmap(); - primitive->Set((*sp)->key,(*sp)->value.vbo); + primitive->Set((*sp)->key,(*sp)->value.vab); } else { diff --git a/src/SceneGraph/RenderAssignBuffer.cpp b/src/SceneGraph/RenderAssignBuffer.cpp index 332d1b01..41d800cd 100644 --- a/src/SceneGraph/RenderAssignBuffer.cpp +++ b/src/SceneGraph/RenderAssignBuffer.cpp @@ -30,18 +30,18 @@ namespace { constexpr const char *l2w_buffer_name[]= { - "VBO:Buffer:LocalToWorld:0", - "VBO:Buffer:LocalToWorld:1", - "VBO:Buffer:LocalToWorld:2", - "VBO:Buffer:LocalToWorld:3" + "VAB:Buffer:LocalToWorld:0", + "VAB:Buffer:LocalToWorld:1", + "VAB:Buffer:LocalToWorld:2", + "VAB:Buffer:LocalToWorld:3" }; constexpr const char *l2w_memory_name[]= { - "VBO:Memory:LocalToWorld:0", - "VBO:Memory:LocalToWorld:1", - "VBO:Memory:LocalToWorld:2", - "VBO:Memory:LocalToWorld:3" + "VAB:Memory:LocalToWorld:0", + "VAB:Memory:LocalToWorld:1", + "VAB:Memory:LocalToWorld:2", + "VAB:Memory:LocalToWorld:3" }; } #endif//_DEBUG @@ -55,7 +55,7 @@ void RenderL2WBuffer::Alloc(const uint nc) for(uint i=0;i<4;i++) { - l2w_vbo[i]=device->CreateVBO(VF_V4F,node_count); + l2w_vbo[i]=device->CreateVAB(VF_V4F,node_count); l2w_buffer[i]=l2w_vbo[i]->GetBuffer(); } } @@ -114,13 +114,13 @@ void RenderMIBuffer::Bind(Material *mtl)const { if(!mtl)return; - mtl->BindUBO(DescriptorSetType::PerMaterial,mtl::SBS_MaterialInstance.name,ubo_mi); + mtl->BindUBO(DescriptorSetType::PerMaterial,mtl::SBS_MaterialInstance.name,mi_data_buffer); } void RenderMIBuffer::Clear() { - SAFE_CLEAR(ubo_mi); - SAFE_CLEAR(vbo_mi); + SAFE_CLEAR(mi_data_buffer); + SAFE_CLEAR(mi_vab); mi_count=0; node_count=0; @@ -136,22 +136,22 @@ void RenderMIBuffer::Alloc(const uint nc,const uint mc) { mi_count=mc; - ubo_mi=device->CreateUBO(mi_data_bytes*mi_count); + mi_data_buffer=device->CreateUBO(mi_data_bytes*mi_count); } - vbo_mi=device->CreateVBO(MI_VBO_FMT,node_count); - mi_buffer=vbo_mi->GetBuffer(); + mi_vab=device->CreateVAB(MI_VAB_FMT,node_count); + mi_buffer=mi_vab->GetBuffer(); #ifdef _DEBUG DebugUtils *du=device->GetDebugUtils(); if(du) { - du->SetBuffer(ubo_mi->GetBuffer(),"UBO:Buffer:MaterialInstance"); - du->SetDeviceMemory(ubo_mi->GetVkMemory(),"UBO:Memory:MaterialInstance"); + du->SetBuffer(mi_data_buffer->GetBuffer(),"UBO:Buffer:MaterialInstance"); + du->SetDeviceMemory(mi_data_buffer->GetVkMemory(),"UBO:Memory:MaterialInstance"); - du->SetBuffer(vbo_mi->GetBuffer(),"VBO:Buffer:MaterialInstanceID"); - du->SetDeviceMemory(vbo_mi->GetVkMemory(),"VBO:Memory:MaterialInstanceID"); + du->SetBuffer(mi_vab->GetBuffer(),"VAB:Buffer:MaterialInstanceID"); + du->SetDeviceMemory(mi_vab->GetVkMemory(),"VAB:Memory:MaterialInstanceID"); } #endif//_DEBUG } @@ -162,7 +162,7 @@ void RenderMIBuffer::WriteNode(RenderNode *render_node,const uint count,const Ma Alloc(count,mi_set.GetCount()); - uint8 *mip=(uint8 *)(ubo_mi->Map()); + uint8 *mip=(uint8 *)(mi_data_buffer->Map()); for(MaterialInstance *mi:mi_set) { @@ -170,9 +170,9 @@ void RenderMIBuffer::WriteNode(RenderNode *render_node,const uint count,const Ma mip+=mi_data_bytes; } - ubo_mi->Unmap(); + mi_data_buffer->Unmap(); - uint16 *idp=(uint16 *)(vbo_mi->Map()); + uint16 *idp=(uint16 *)(mi_vab->Map()); { rn=render_node; @@ -186,6 +186,6 @@ void RenderMIBuffer::WriteNode(RenderNode *render_node,const uint count,const Ma } } - vbo_mi->Unmap(); + mi_vab->Unmap(); } VK_NAMESPACE_END diff --git a/src/SceneGraph/RenderAssignBuffer.h b/src/SceneGraph/RenderAssignBuffer.h index a4a45695..731f068a 100644 --- a/src/SceneGraph/RenderAssignBuffer.h +++ b/src/SceneGraph/RenderAssignBuffer.h @@ -31,7 +31,7 @@ class RenderL2WBuffer uint node_count; ///<渲染节点数量 - VBO *l2w_vbo[4]; + VAB *l2w_vbo[4]; VkBuffer l2w_buffer[4]; private: @@ -65,9 +65,9 @@ private: uint32_t mi_data_bytes; ///<材质实例数据字节数 uint32_t mi_count; ///<材质实例数量 - DeviceBuffer *ubo_mi; ///<材质实例数据 + DeviceBuffer *mi_data_buffer; ///<材质实例数据(UBO/SSBO) - VBO *vbo_mi; ///<材质实例ID(R16UI格式) + VAB *mi_vab; ///<材质实例ID(R16UI格式) VkBuffer mi_buffer; private: diff --git a/src/SceneGraph/VertexDataManager.cpp b/src/SceneGraph/VertexDataManager.cpp index d09a6ba1..f695b20b 100644 --- a/src/SceneGraph/VertexDataManager.cpp +++ b/src/SceneGraph/VertexDataManager.cpp @@ -16,9 +16,9 @@ namespace hgl vi_count=_vil->GetCount(); vif_list=_vil->GetVIFList(); //来自于Material,不会被释放,所以指针有效 - vbo_max_size=0; - vbo_cur_size=0; - vbo=hgl_zero_new(vi_count); + vab_max_size=0; + vab_cur_size=0; + vab=hgl_zero_new(vi_count); ibo_cur_size=0; ibo=nullptr; @@ -26,7 +26,7 @@ namespace hgl VertexDataManager::~VertexDataManager() { - SAFE_CLEAR_OBJECT_ARRAY(vbo,vi_count); + SAFE_CLEAR_OBJECT_ARRAY(vab,vi_count); SAFE_CLEAR(ibo); } @@ -38,26 +38,26 @@ namespace hgl */ bool VertexDataManager::Init(const VkDeviceSize vbo_size,const VkDeviceSize ibo_size,const IndexType index_type) { - if(vbo[0]||ibo) //已经初始化过了 + if(vab[0]||ibo) //已经初始化过了 return(false); if(vbo_size<=0) return(false); - vbo_max_size=vbo_size; + vab_max_size=vbo_size; ibo_cur_size=ibo_size; - vbo_cur_size=0; + vab_cur_size=0; ibo_cur_size=0; for(uint i=0;iCreateVBO(vif_list[i].format,vbo_max_size); - if(!vbo[i]) + vab[i]=device->CreateVAB(vif_list[i].format,vab_max_size); + if(!vab[i]) return(false); } - vbo_data_chain.Init(vbo_max_size); + vbo_data_chain.Init(vab_max_size); if(ibo_size>0) { diff --git a/src/SceneGraph/Vulkan/VKDeviceBuffer.cpp b/src/SceneGraph/Vulkan/VKDeviceBuffer.cpp index 6c8c3c61..40c8e1c2 100644 --- a/src/SceneGraph/Vulkan/VKDeviceBuffer.cpp +++ b/src/SceneGraph/Vulkan/VKDeviceBuffer.cpp @@ -55,7 +55,7 @@ bool GPUDevice::CreateBuffer(DeviceBufferData *buf,VkBufferUsageFlags buf_usage, return(false); } -VBO *GPUDevice::CreateVBO(VkFormat format,uint32_t count,const void *data,SharingMode sharing_mode) +VAB *GPUDevice::CreateVAB(VkFormat format,uint32_t count,const void *data,SharingMode sharing_mode) { if(count==0)return(nullptr); diff --git a/src/SceneGraph/Vulkan/VKPrimitive.cpp b/src/SceneGraph/Vulkan/VKPrimitive.cpp index 0b58aad8..81e84e9f 100644 --- a/src/SceneGraph/Vulkan/VKPrimitive.cpp +++ b/src/SceneGraph/Vulkan/VKPrimitive.cpp @@ -27,16 +27,16 @@ VK_NAMESPACE_BEGIN // return(true); //} -bool Primitive::Set(const AnsiString &name,VBO *vbo,VkDeviceSize offset) +bool Primitive::Set(const AnsiString &name,VAB *vab,VkDeviceSize offset) { - if(!vbo)return(false); + if(!vab)return(false); if(buffer_list.KeyExist(name))return(false); - VBOAccessData vad; + VABAccess vad; - vad.vbo=vbo; + vad.vab=vab; vad.offset=offset; - vad.size=vbo->GetBytes(); + vad.size=vab->GetBytes(); buffer_list.Add(name,vad); @@ -45,15 +45,15 @@ bool Primitive::Set(const AnsiString &name,VBO *vbo,VkDeviceSize offset) if(du) { - du->SetBuffer(vbo->GetBuffer(),prim_name+":VBO:Buffer:"+name); - du->SetDeviceMemory(vbo->GetVkMemory(),prim_name+":VBO:Memory:"+name); + du->SetBuffer(vab->GetBuffer(),prim_name+":VBO:Buffer:"+name); + du->SetDeviceMemory(vab->GetVkMemory(),prim_name+":VBO:Memory:"+name); } #endif//_DEBUG return(true); } -bool Primitive::GetVBOAccessData(const AnsiString &name,VBOAccessData *vad) +bool Primitive::GetVBOAccessData(const AnsiString &name,VABAccess *vad) { if(name.IsEmpty())return(false); if(!vad)return(false); diff --git a/src/SceneGraph/Vulkan/VKRenderResource.cpp b/src/SceneGraph/Vulkan/VKRenderResource.cpp index d63a59d5..af09cb4e 100644 --- a/src/SceneGraph/Vulkan/VKRenderResource.cpp +++ b/src/SceneGraph/Vulkan/VKRenderResource.cpp @@ -5,9 +5,9 @@ #include VK_NAMESPACE_BEGIN -VBO *RenderResource::CreateVBO(VkFormat format,uint32_t count,const void *data,SharingMode sharing_mode) +VAB *RenderResource::CreateVAB(VkFormat format,uint32_t count,const void *data,SharingMode sharing_mode) { - VBO *vb=device->CreateVBO(format,count,data,sharing_mode); + VAB *vb=device->CreateVAB(format,count,data,sharing_mode); if(!vb) return(nullptr); diff --git a/src/SceneGraph/Vulkan/VKRenderable.cpp b/src/SceneGraph/Vulkan/VKRenderable.cpp index ed0630db..a51bccd5 100644 --- a/src/SceneGraph/Vulkan/VKRenderable.cpp +++ b/src/SceneGraph/Vulkan/VKRenderable.cpp @@ -55,12 +55,12 @@ Renderable *CreateRenderable(Primitive *prim,MaterialInstance *mi,Pipeline *p) return(nullptr); } - VBO *vbo; + VAB *vab; VertexInputData *vid=new VertexInputData(input_count,prim->GetVertexCount(),prim->GetIndexBufferData()); const VertexInputFormat *vif=vil->GetVIFList(VertexInputGroup::Basic); - VBOAccessData vad; + VABAccess vad; for(uint i=0;iGetFormat()!=vif->format) + if(vab->GetFormat()!=vif->format) { LOG_ERROR( "[FATAL ERROR] VBO \""+UTF8String(vif->name)+ UTF8String("\" format can't match Renderable, Material(")+mtl_name+ UTF8String(") Format(")+GetVulkanFormatName(vif->format)+ - UTF8String("), VBO Format(")+GetVulkanFormatName(vbo->GetFormat())+ + UTF8String("), VBO Format(")+GetVulkanFormatName(vab->GetFormat())+ ")"); return(nullptr); } - if(vbo->GetStride()!=vif->stride) + if(vab->GetStride()!=vif->stride) { LOG_ERROR( "[FATAL ERROR] VBO \""+UTF8String(vif->name)+ UTF8String("\" stride can't match Renderable, Material(")+mtl_name+ UTF8String(") stride(")+UTF8String::numberOf(vif->stride)+ - UTF8String("), VBO stride(")+UTF8String::numberOf(vbo->GetStride())+ + UTF8String("), VBO stride(")+UTF8String::numberOf(vab->GetStride())+ ")"); return(nullptr); } vid->buffer_offset[i]=vad.offset; - vid->buffer_list[i]=vbo->GetBuffer(); + vid->buffer_list[i]=vab->GetBuffer(); ++vif; }