use "VertexAttribData" instead "VertexAttribBufferCreater"

This commit is contained in:
hyzboy 2020-07-16 17:02:24 +08:00
parent 9999ff26c8
commit 1ebaedb350
6 changed files with 50 additions and 27 deletions

View File

@ -32,10 +32,17 @@ namespace hgl
{
AnsiString name;
uint binding;
VABCreater *vabc;
VAD *vabc =nullptr;
public:
~ShaderStageBind()
{
SAFE_CLEAR(vabc);
}
};//struct ShaderStageBind
using VABCreaterMaps=MapObject<AnsiString,VABCreater>;
using VABCreaterMaps=MapObject<AnsiString,ShaderStageBind>;
/**
*
@ -61,12 +68,12 @@ namespace hgl
RenderableCreater(SceneDB *sdb,vulkan::Material *m);
virtual ~RenderableCreater()=default;
virtual bool Init(const uint32 count);
virtual bool Init(const uint32 count); ///<初始化,参数为顶点数量
virtual VABCreater * CreateVAB(const AnsiString &name);
virtual VAD * CreateVAB(const AnsiString &name); ///<创建一个顶点属性缓冲区创建器
uint16 * CreateIBO16(uint count,const uint16 *data=nullptr);
uint32 * CreateIBO32(uint count,const uint32 *data=nullptr);
uint16 * CreateIBO16(uint count,const uint16 *data=nullptr); ///<创建16位的索引缓冲区
uint32 * CreateIBO32(uint count,const uint32 *data=nullptr); ///<创建32位的索引缓冲区
virtual vulkan::Renderable * Finish();
};//class RenderableCreater

View File

@ -9,7 +9,7 @@ namespace hgl
/**
*
*/
class VertexAttribBufferCreater ///顶点属性缓冲区创建者
class VertexAttribData ///顶点属性缓冲区创建者
{
void *mem_data; ///<内存中的数据
@ -26,13 +26,13 @@ namespace hgl
public:
VertexAttribBufferCreater(uint32_t c,uint32_t dc,uint32_t cs):count(c),dc_num(dc),comp_stride(cs),stride(dc*cs),total_bytes(dc*cs*c)
VertexAttribData(uint32_t c,uint32_t dc,uint32_t cs):count(c),dc_num(dc),comp_stride(cs),stride(dc*cs),total_bytes(dc*cs*c)
{
mem_data = hgl_malloc(total_bytes); //在很多情况下hgl_malloc分配的内存是对齐的这样有效率上的提升
mem_end = ((char *)mem_data) + total_bytes;
}
virtual ~VertexAttribBufferCreater()
virtual ~VertexAttribData()
{
if(mem_data)
hgl_free(mem_data);
@ -45,9 +45,9 @@ namespace hgl
const uint32_t GetStride ()const{return stride;} ///<取得每一组数据字节数
void * GetData ()const{return mem_data;} ///<取得数据指针
const uint32_t GetTotalBytes ()const{return total_bytes; } ///<取得数据字节数
};//class VertexAttribBufferCreater
};//class VertexAttribData
using VABCreater=VertexAttribBufferCreater;
using VAD=VertexAttribData;
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_VERTEX_ATTRIB_BUFFER_CREATER_INCLUDE

2
res

@ -1 +1 @@
Subproject commit 3c8d4ba212c743feba2271743e560d32e9cb2e74
Subproject commit 394fe76188845b306575e0f68fe587a286ab1d14

View File

@ -80,7 +80,7 @@ add_cm_library(ULRE.SceneGraph "ULRE" ${SCENE_GRAPH_HEADER}
${SG_VERTEX_SOURCE}
#${RENDERABLE_FILES}
${RENDERABLE_FILES}
${FONT_HEADER}
${FONT_SOURCE})

View File

@ -12,7 +12,6 @@ namespace hgl
vsm =mtl->GetVertexShaderModule();
vertices_number =0;
vabc_vertex =nullptr;
ibo =nullptr;
}
@ -29,21 +28,26 @@ namespace hgl
{
if(!vsm)return(false);
VertexAttribBufferCreater *vabc;
ShaderStageBind *ssb;
if(vabc_maps.Get(name,vabc))
return vabc;
if(vabc_maps.Get(name,ssb))
return ssb->vabc;
const vulkan::ShaderStage *ss=vsm->GetStageInput(name);
if(!ss)
return(nullptr);
vabc=hgl::graph::CreateVABCreater(ss->base_type,ss->component,vertices_number);
ssb=new ShaderStageBind;
vabc_maps.Add(name,vabc);
ssb->vabc=hgl::graph::CreateVABCreater(ss->base_type,ss->component,vertices_number);
return vabc;
ssb->name=name;
ssb->binding=ss->binding;
vabc_maps.Add(name,ssb);
return ssb->vabc;
}
uint16 *RenderableCreater::CreateIBO16(uint count,const uint16 *data)
@ -74,8 +78,20 @@ namespace hgl
const auto *sp=vabc_maps.GetDataList();
for(uint i=0;i<si_count;i++)
{
render_obj->Set((*sp)->right->binding,db->CreateVAB((*sp)->right->vabc));
++sp;
}
if(ibo)
{
ibo->Unmap();
render_obj->Set(ibo);
}
db->Add(render_obj);
return render_obj;
}
}//namespace graph
}//namespace hgl