Move the ShaderStageBind to the PrimitiveCreate inside, and renamed to PrimitiveVertexBuffer
This commit is contained in:
parent
3523afc6c2
commit
233523231e
@ -8,28 +8,28 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
namespace graph
|
namespace graph
|
||||||
{
|
{
|
||||||
struct ShaderStageBind
|
|
||||||
{
|
|
||||||
AnsiString name;
|
|
||||||
uint binding;
|
|
||||||
VAD * data =nullptr;
|
|
||||||
VBO * vbo =nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
~ShaderStageBind()
|
|
||||||
{
|
|
||||||
SAFE_CLEAR(data);
|
|
||||||
}
|
|
||||||
};//struct ShaderStageBind
|
|
||||||
|
|
||||||
using ShaderStageBindMap=ObjectMap<AnsiString,ShaderStageBind>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可绘制图元创建器
|
* 可绘制图元创建器
|
||||||
*/
|
*/
|
||||||
class PrimitiveCreater
|
class PrimitiveCreater
|
||||||
{
|
{
|
||||||
|
struct PrimitiveVertexBuffer
|
||||||
|
{
|
||||||
|
AnsiString name;
|
||||||
|
uint binding;
|
||||||
|
VAD * data =nullptr;
|
||||||
|
VBO * vbo =nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
~PrimitiveVertexBuffer()
|
||||||
|
{
|
||||||
|
SAFE_CLEAR(data);
|
||||||
|
}
|
||||||
|
};//struct PrimitiveVertexBuffer
|
||||||
|
|
||||||
|
using PVBMap=ObjectMap<AnsiString,PrimitiveVertexBuffer>;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
RenderResource *db;
|
RenderResource *db;
|
||||||
@ -42,7 +42,7 @@ namespace hgl
|
|||||||
uint32 vertices_number;
|
uint32 vertices_number;
|
||||||
|
|
||||||
IndexBuffer * ibo;
|
IndexBuffer * ibo;
|
||||||
ShaderStageBindMap ssb_map;
|
PVBMap vbo_map;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -33,27 +33,27 @@ namespace hgl
|
|||||||
if(!vif)
|
if(!vif)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
ShaderStageBind *ssb;
|
PrimitiveVertexBuffer *pvb;
|
||||||
|
|
||||||
if(ssb_map.Get(name,ssb))
|
if(vbo_map.Get(name,pvb))
|
||||||
return ssb->data;
|
return pvb->data;
|
||||||
|
|
||||||
VAD *vad=hgl::graph::CreateVertexAttribData(vertices_number,vif);
|
VAD *vad=hgl::graph::CreateVertexAttribData(vertices_number,vif);
|
||||||
|
|
||||||
if(!vad)
|
if(!vad)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
ssb=new ShaderStageBind;
|
pvb=new PrimitiveVertexBuffer;
|
||||||
|
|
||||||
ssb->data =vad;
|
pvb->data =vad;
|
||||||
ssb->name =name;
|
pvb->name =name;
|
||||||
ssb->binding=vif->binding;
|
pvb->binding=vif->binding;
|
||||||
|
|
||||||
ssb->vbo =nullptr;
|
pvb->vbo =nullptr;
|
||||||
|
|
||||||
ssb_map.Add(name,ssb);
|
vbo_map.Add(name,pvb);
|
||||||
|
|
||||||
return ssb->data;
|
return pvb->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrimitiveCreater::WriteVAD(const AnsiString &name,const void *data,const uint32_t bytes)
|
bool PrimitiveCreater::WriteVAD(const AnsiString &name,const void *data,const uint32_t bytes)
|
||||||
@ -63,9 +63,9 @@ namespace hgl
|
|||||||
if(!data)return(false);
|
if(!data)return(false);
|
||||||
if(!bytes)return(false);
|
if(!bytes)return(false);
|
||||||
|
|
||||||
ShaderStageBind *ssb;
|
PrimitiveVertexBuffer *pvb;
|
||||||
|
|
||||||
if(ssb_map.Get(name,ssb))
|
if(vbo_map.Get(name,pvb))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const VertexInputFormat *vif=vil->GetConfig(name);
|
const VertexInputFormat *vif=vil->GetConfig(name);
|
||||||
@ -76,15 +76,15 @@ namespace hgl
|
|||||||
if(vif->stride*vertices_number!=bytes)
|
if(vif->stride*vertices_number!=bytes)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
ssb=new ShaderStageBind;
|
pvb=new PrimitiveVertexBuffer;
|
||||||
|
|
||||||
ssb->data =nullptr;
|
pvb->data =nullptr;
|
||||||
ssb->name =name;
|
pvb->name =name;
|
||||||
ssb->binding=vif->binding;
|
pvb->binding=vif->binding;
|
||||||
|
|
||||||
ssb->vbo =db->CreateVBO(vif->format,vertices_number,data);
|
pvb->vbo =db->CreateVBO(vif->format,vertices_number,data);
|
||||||
|
|
||||||
ssb_map.Add(name,ssb);
|
vbo_map.Add(name,pvb);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -109,12 +109,12 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
const uint si_count=vil->GetCount();
|
const uint si_count=vil->GetCount();
|
||||||
|
|
||||||
if(ssb_map.GetCount()!=si_count)
|
if(vbo_map.GetCount()!=si_count)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
Primitive *primitive=db->CreatePrimitive(vertices_number);
|
Primitive *primitive=db->CreatePrimitive(vertices_number);
|
||||||
|
|
||||||
const auto *sp=ssb_map.GetDataList();
|
const auto *sp=vbo_map.GetDataList();
|
||||||
for(uint i=0;i<si_count;i++)
|
for(uint i=0;i<si_count;i++)
|
||||||
{
|
{
|
||||||
if((*sp)->value->vbo)
|
if((*sp)->value->vbo)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user