renamed many values and function's name.
This commit is contained in:
parent
bbf94767fe
commit
ad330f3a42
@ -89,24 +89,6 @@ namespace hgl
|
||||
return(true);
|
||||
}
|
||||
|
||||
//template<typename T,IndexType IT>
|
||||
//T * CreateIBO(const uint count,const T *data=nullptr) ///<创建索引缓冲区
|
||||
//{
|
||||
// if(ibo)
|
||||
// return(nullptr);
|
||||
//
|
||||
// ibo=db->CreateIBO(IT,count,data);
|
||||
|
||||
// if(!ibo)
|
||||
// return(nullptr);
|
||||
|
||||
// return (T *)ibo->Map();
|
||||
//}
|
||||
|
||||
//uint8 * CreateIBO8 (uint count,const uint8 *data=nullptr){return CreateIBO<uint8 ,IndexType::U8 >(count,data);} ///<创建8位的索引缓冲区
|
||||
//uint16 * CreateIBO16(uint count,const uint16 *data=nullptr){return CreateIBO<uint16,IndexType::U16>(count,data);} ///<创建16位的索引缓冲区
|
||||
//uint32 * CreateIBO32(uint count,const uint32 *data=nullptr){return CreateIBO<uint32,IndexType::U32>(count,data);} ///<创建32位的索引缓冲区
|
||||
|
||||
virtual Primitive * Finish(const AnsiString &); ///<结束并创建可渲染对象
|
||||
};//class PrimitiveCreater
|
||||
}//namespace graph
|
||||
|
@ -64,7 +64,8 @@ class IndexBuffer;
|
||||
struct IndexBufferAccess
|
||||
{
|
||||
IndexBuffer *buffer=nullptr;
|
||||
VkDeviceSize offset=0;
|
||||
VkDeviceSize start=0;
|
||||
VkDeviceSize count=0;
|
||||
};
|
||||
|
||||
using IBAccess=IndexBufferAccess;
|
||||
|
@ -170,7 +170,7 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
void BindIBO(const IBAccess *);
|
||||
// void BindIBO(const IBAccess *);
|
||||
|
||||
bool BindVBO(Renderable *);
|
||||
|
||||
@ -192,8 +192,8 @@ public: //draw
|
||||
void Draw (const uint32_t vertex_count,const uint32_t instance_count) {vkCmdDraw(cmd_buf,vertex_count,instance_count,0,0);}
|
||||
void DrawIndexed (const uint32_t index_count ,const uint32_t instance_count) {vkCmdDrawIndexed(cmd_buf,index_count,instance_count,0,0,0);}
|
||||
|
||||
template<typename ...ARGS> void Draw (ARGS...args) {vkCmdDraw(cmd_buf,args...);}
|
||||
template<typename ...ARGS> void DrawIndexed (ARGS...args) {vkCmdDrawIndexed(cmd_buf,args...);}
|
||||
// template<typename ...ARGS> void Draw (ARGS...args) {vkCmdDraw(cmd_buf,args...);}
|
||||
// template<typename ...ARGS> void DrawIndexed (ARGS...args) {vkCmdDrawIndexed(cmd_buf,args...);}
|
||||
|
||||
void DrawIndirect (VkBuffer,VkDeviceSize, uint32_t drawCount,uint32_t stride=sizeof(VkDrawIndirectCommand ));
|
||||
void DrawIndexedIndirect(VkBuffer,VkDeviceSize, uint32_t drawCount,uint32_t stride=sizeof(VkDrawIndexedIndirectCommand ));
|
||||
@ -201,6 +201,7 @@ public: //draw
|
||||
void DrawIndexedIndirect(VkBuffer buf, uint32_t drawCount,uint32_t stride=sizeof(VkDrawIndexedIndirectCommand )){return DrawIndexedIndirect( buf,0,drawCount,stride);}
|
||||
|
||||
void Draw (const VertexInputData *vid);
|
||||
void DrawIndexed (const IBAccess *iba,const uint32_t instance_count);
|
||||
|
||||
public: //dynamic state
|
||||
};//class RenderCmdBuffer:public GPUCmdBuffer
|
||||
|
@ -16,7 +16,7 @@ class Primitive
|
||||
|
||||
protected:
|
||||
|
||||
uint32_t vertex_count;
|
||||
VkDeviceSize vertex_count;
|
||||
|
||||
VABAccessMap buffer_list;
|
||||
|
||||
@ -30,7 +30,7 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
Primitive(GPUDevice *dev,const AnsiString &n,const uint32_t vc=0)
|
||||
Primitive(GPUDevice *dev,const AnsiString &n,const VkDeviceSize vc=0)
|
||||
{
|
||||
device=dev;
|
||||
prim_name=n;
|
||||
@ -42,13 +42,13 @@ public:
|
||||
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
|
||||
const AABB & GetBoundingBox()const {return BoundingBox;}
|
||||
|
||||
bool Set(const AnsiString &name,VAB *vb,VkDeviceSize offset=0);
|
||||
bool SetVAB(const AnsiString &name,VAB *vb,VkDeviceSize start=0);
|
||||
|
||||
bool Set(IndexBuffer *ib,VkDeviceSize offset=0);
|
||||
bool SetIndex(IndexBuffer *ib,VkDeviceSize start,const VkDeviceSize index_count);
|
||||
|
||||
public:
|
||||
|
||||
const uint32_t GetVertexCount ()const {return vertex_count;}
|
||||
const VkDeviceSize GetVertexCount ()const {return vertex_count;}
|
||||
|
||||
bool GetVABAccess (const AnsiString &,VABAccess *);
|
||||
const int GetBufferCount ()const {return buffer_list.GetCount();}
|
||||
|
@ -8,7 +8,7 @@ VK_NAMESPACE_BEGIN
|
||||
|
||||
struct PrimitiveData
|
||||
{
|
||||
uint32_t vertex_count;
|
||||
VkDeviceSize vertex_count;
|
||||
|
||||
uint32_t va_count;
|
||||
|
||||
|
@ -11,13 +11,13 @@ class RenderablePrimitiveCreater
|
||||
{
|
||||
RenderResource *rr;
|
||||
|
||||
uint32_t vertex_count;
|
||||
VkDeviceSize vertex_count;
|
||||
|
||||
Primitive *prim;
|
||||
|
||||
public:
|
||||
|
||||
RenderablePrimitiveCreater(RenderResource *_rr,const AnsiString &name,uint32_t vc)
|
||||
RenderablePrimitiveCreater(RenderResource *_rr,const AnsiString &name,VkDeviceSize vc)
|
||||
{
|
||||
rr=_rr;
|
||||
vertex_count=vc;
|
||||
@ -32,18 +32,18 @@ public:
|
||||
if(!vab)
|
||||
return(nullptr);
|
||||
|
||||
prim->Set(name,vab);
|
||||
prim->SetVAB(name,vab);
|
||||
return(vab);
|
||||
}
|
||||
|
||||
IndexBuffer *SetIBO(const IndexType &it,const void *buf,const uint32_t index_count)
|
||||
IndexBuffer *SetIndex(const IndexType &it,const void *buf,const VkDeviceSize index_count)
|
||||
{
|
||||
IndexBuffer *ibo=rr->CreateIBO(it,index_count,buf);
|
||||
|
||||
if(!ibo)
|
||||
return(nullptr);
|
||||
|
||||
prim->Set(ibo);
|
||||
prim->SetIndex(ibo,0,index_count);
|
||||
return(ibo);
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,7 @@ namespace hgl
|
||||
struct VABAccess
|
||||
{
|
||||
VAB *vab;
|
||||
VkDeviceSize offset;
|
||||
VkDeviceSize size;
|
||||
VkDeviceSize start;
|
||||
|
||||
void *map_ptr;
|
||||
|
||||
|
@ -51,14 +51,14 @@ namespace hgl
|
||||
|
||||
/**
|
||||
* 取得数据区地址
|
||||
* @param offset 从第几个数据开始访问
|
||||
* @param start 从第几个数据开始访问
|
||||
* @return 访问地址
|
||||
*/
|
||||
T *Get(uint32_t offset=0)
|
||||
{
|
||||
if(!data||offset>=count)
|
||||
{
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess::Get() out,offset:")+OSString::numberOf(offset));
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess::Get() out,start:")+OSString::numberOf(offset));
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
@ -67,14 +67,14 @@ namespace hgl
|
||||
|
||||
/**
|
||||
* 开始访问数据区
|
||||
* @param offset 从第几个数据开始访问
|
||||
* @param start 从第几个数据开始访问
|
||||
* @return 访问地址
|
||||
*/
|
||||
T *Begin(uint32_t offset=0)
|
||||
{
|
||||
if(access)
|
||||
{
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess::Begin() access!=0,offset:")+OSString::numberOf(offset));
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess::Begin() access!=0,start:")+OSString::numberOf(offset));
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
|
@ -260,9 +260,7 @@ void MaterialRenderList::Render(RenderItem *ri)
|
||||
|
||||
if(iba->buffer)
|
||||
{
|
||||
cmd_buf->BindIBO(iba);
|
||||
|
||||
cmd_buf->DrawIndexed(iba->buffer->GetCount(),ri->count);
|
||||
cmd_buf->DrawIndexed(iba,ri->count);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -173,7 +173,7 @@ namespace hgl
|
||||
if((*sp)->value.map_ptr)
|
||||
(*sp)->value.vab->Unmap();
|
||||
|
||||
primitive->Set((*sp)->key,(*sp)->value.vab);
|
||||
primitive->SetVAB((*sp)->key,(*sp)->value.vab);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -187,7 +187,7 @@ namespace hgl
|
||||
if(ibo)
|
||||
{
|
||||
ibo->Unmap();
|
||||
primitive->Set(ibo);
|
||||
primitive->SetIndex(ibo,0,index_number);
|
||||
|
||||
db->Add(ibo);
|
||||
ibo=nullptr; //避免释构函数删除
|
||||
|
@ -129,13 +129,13 @@ bool RenderCmdBuffer::BindDescriptorSets(Material *mtl)
|
||||
return(true);
|
||||
}
|
||||
|
||||
void RenderCmdBuffer::BindIBO(const IBAccess *iba)
|
||||
{
|
||||
vkCmdBindIndexBuffer( cmd_buf,
|
||||
iba->buffer->GetBuffer(),
|
||||
iba->offset,
|
||||
VkIndexType(iba->buffer->GetType()));
|
||||
}
|
||||
//void RenderCmdBuffer::BindIBO(const IBAccess *iba)
|
||||
//{
|
||||
// vkCmdBindIndexBuffer( cmd_buf,
|
||||
// iba->buffer->GetBuffer(),
|
||||
// iba->start,
|
||||
// VkIndexType(iba->buffer->GetType()));
|
||||
//}
|
||||
|
||||
bool RenderCmdBuffer::BindVBO(Renderable *ri)
|
||||
{
|
||||
@ -154,7 +154,7 @@ bool RenderCmdBuffer::BindVBO(Renderable *ri)
|
||||
if(indices_buffer)
|
||||
vkCmdBindIndexBuffer(cmd_buf,
|
||||
indices_buffer->GetBuffer(),
|
||||
vid->ib_access->offset,
|
||||
vid->ib_access->start,
|
||||
VkIndexType(indices_buffer->GetType()));
|
||||
|
||||
return(true);
|
||||
@ -187,8 +187,20 @@ void RenderCmdBuffer::DrawIndexedIndirect( VkBuffer buffer,
|
||||
void RenderCmdBuffer::Draw(const VertexInputData *vid)
|
||||
{
|
||||
if (vid->ib_access->buffer)
|
||||
DrawIndexed(vid->ib_access->buffer->GetCount());
|
||||
DrawIndexed(vid->ib_access->count);
|
||||
else
|
||||
Draw(vid->vertex_count);
|
||||
}
|
||||
|
||||
void RenderCmdBuffer::DrawIndexed(const IBAccess *iba,const uint32_t instance_count)
|
||||
{
|
||||
if(!iba||instance_count<=0)return;
|
||||
|
||||
vkCmdBindIndexBuffer(cmd_buf,
|
||||
iba->buffer->GetBuffer(),
|
||||
iba->start,
|
||||
VkIndexType(iba->buffer->GetType()));
|
||||
|
||||
vkCmdDrawIndexed(cmd_buf,iba->count,instance_count,0,0,0);
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@ -27,7 +27,7 @@ VK_NAMESPACE_BEGIN
|
||||
// return(true);
|
||||
//}
|
||||
|
||||
bool Primitive::Set(const AnsiString &name,VAB *vab,VkDeviceSize offset)
|
||||
bool Primitive::SetVAB(const AnsiString &name,VAB *vab,VkDeviceSize start)
|
||||
{
|
||||
if(!vab)return(false);
|
||||
if(buffer_list.KeyExist(name))return(false);
|
||||
@ -35,8 +35,7 @@ bool Primitive::Set(const AnsiString &name,VAB *vab,VkDeviceSize offset)
|
||||
VABAccess vad;
|
||||
|
||||
vad.vab=vab;
|
||||
vad.offset=offset;
|
||||
vad.size=vab->GetBytes();
|
||||
vad.start=start;
|
||||
|
||||
buffer_list.Add(name,vad);
|
||||
|
||||
@ -61,12 +60,13 @@ bool Primitive::GetVABAccess(const AnsiString &name,VABAccess *vad)
|
||||
return buffer_list.Get(name,*vad);
|
||||
}
|
||||
|
||||
bool Primitive::Set(IndexBuffer *ib,VkDeviceSize offset)
|
||||
bool Primitive::SetIndex(IndexBuffer *ib,VkDeviceSize start,const VkDeviceSize index_count)
|
||||
{
|
||||
if(!ib)return(false);
|
||||
|
||||
ib_access.buffer=ib;
|
||||
ib_access.offset=offset;
|
||||
ib_access.start=start;
|
||||
ib_access.count=index_count;
|
||||
|
||||
#ifdef _DEBUG
|
||||
DebugUtils *du=device->GetDebugUtils();
|
||||
|
@ -95,7 +95,7 @@ Renderable *CreateRenderable(Primitive *prim,MaterialInstance *mi,Pipeline *p)
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
vid->buffer_offset[i]=vad.offset;
|
||||
vid->buffer_offset[i]=vad.start;
|
||||
vid->buffer_list[i]=vab->GetBuffer();
|
||||
++vif;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user