renamed to MeshDataBuffer from PrimitiveDataBuffer,
renamed to MeshRenderData from PrimitiveRenderData
This commit is contained in:
parent
014fce2c8e
commit
4b2f344c5c
@ -68,8 +68,8 @@ private:
|
|||||||
|
|
||||||
MaterialInstance * mi;
|
MaterialInstance * mi;
|
||||||
|
|
||||||
const PrimitiveDataBuffer * pdb;
|
const MeshDataBuffer * pdb;
|
||||||
const PrimitiveRenderData * prd;
|
const MeshRenderData * prd;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -92,14 +92,14 @@ protected:
|
|||||||
|
|
||||||
VABList * vab_list;
|
VABList * vab_list;
|
||||||
|
|
||||||
const PrimitiveDataBuffer * last_data_buffer;
|
const MeshDataBuffer * last_data_buffer;
|
||||||
const VDM * last_vdm;
|
const VDM * last_vdm;
|
||||||
const PrimitiveRenderData * last_render_data;
|
const MeshRenderData * last_render_data;
|
||||||
|
|
||||||
int first_indirect_draw_index=-1;
|
int first_indirect_draw_index=-1;
|
||||||
uint indirect_draw_count=0;
|
uint indirect_draw_count=0;
|
||||||
|
|
||||||
bool BindVAB(const PrimitiveDataBuffer *,const uint);
|
bool BindVAB(const MeshDataBuffer *,const uint);
|
||||||
|
|
||||||
void ProcIndirectRender();
|
void ProcIndirectRender();
|
||||||
void Render(RenderItem *);
|
void Render(RenderItem *);
|
||||||
|
@ -73,8 +73,8 @@ class DeviceBuffer;
|
|||||||
struct DeviceBufferData;
|
struct DeviceBufferData;
|
||||||
template<typename T> class DeviceBufferMap;
|
template<typename T> class DeviceBufferMap;
|
||||||
|
|
||||||
struct PrimitiveDataBuffer;
|
struct MeshDataBuffer;
|
||||||
struct PrimitiveRenderData;
|
struct MeshRenderData;
|
||||||
|
|
||||||
class VertexAttribBuffer;
|
class VertexAttribBuffer;
|
||||||
using VAB=VertexAttribBuffer;
|
using VAB=VertexAttribBuffer;
|
||||||
|
@ -202,7 +202,7 @@ public:
|
|||||||
|
|
||||||
void BindIBO(IndexBuffer *,const VkDeviceSize byte_offset=0);
|
void BindIBO(IndexBuffer *,const VkDeviceSize byte_offset=0);
|
||||||
|
|
||||||
bool BindDataBuffer(const PrimitiveDataBuffer *);
|
bool BindDataBuffer(const MeshDataBuffer *);
|
||||||
|
|
||||||
void SetViewport (uint32_t first,uint32_t count,const VkViewport *vp) {vkCmdSetViewport(cmd_buf,first,count,vp);}
|
void SetViewport (uint32_t first,uint32_t count,const VkViewport *vp) {vkCmdSetViewport(cmd_buf,first,count,vp);}
|
||||||
void SetScissor (uint32_t first,uint32_t count,const VkRect2D *sci) {vkCmdSetScissor(cmd_buf,first,count,sci);}
|
void SetScissor (uint32_t first,uint32_t count,const VkRect2D *sci) {vkCmdSetScissor(cmd_buf,first,count,sci);}
|
||||||
@ -239,7 +239,7 @@ public: //draw
|
|||||||
void DrawIndirect (VkBuffer buf, uint32_t drawCount,uint32_t stride=sizeof(VkDrawIndirectCommand )){return DrawIndirect( buf,0,drawCount,stride);}
|
void DrawIndirect (VkBuffer buf, uint32_t drawCount,uint32_t stride=sizeof(VkDrawIndirectCommand )){return DrawIndirect( buf,0,drawCount,stride);}
|
||||||
void DrawIndexedIndirect(VkBuffer buf, uint32_t drawCount,uint32_t stride=sizeof(VkDrawIndexedIndirectCommand )){return DrawIndexedIndirect( buf,0,drawCount,stride);}
|
void DrawIndexedIndirect(VkBuffer buf, uint32_t drawCount,uint32_t stride=sizeof(VkDrawIndexedIndirectCommand )){return DrawIndexedIndirect( buf,0,drawCount,stride);}
|
||||||
|
|
||||||
void Draw (const PrimitiveDataBuffer *prb,const PrimitiveRenderData *prd,const uint32_t instance_count=1,const uint32_t first_instance=0);
|
void Draw (const MeshDataBuffer *prb,const MeshRenderData *prd,const uint32_t instance_count=1,const uint32_t first_instance=0);
|
||||||
|
|
||||||
public: //dynamic state
|
public: //dynamic state
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ VK_NAMESPACE_BEGIN
|
|||||||
* 原始图元数据缓冲区<Br>
|
* 原始图元数据缓冲区<Br>
|
||||||
* 提供在渲染之前的数据绑定信息
|
* 提供在渲染之前的数据绑定信息
|
||||||
*/
|
*/
|
||||||
struct PrimitiveDataBuffer:public Comparator<PrimitiveDataBuffer>
|
struct MeshDataBuffer:public Comparator<MeshDataBuffer>
|
||||||
{
|
{
|
||||||
uint32_t vab_count;
|
uint32_t vab_count;
|
||||||
VkBuffer * vab_list;
|
VkBuffer * vab_list;
|
||||||
@ -29,17 +29,17 @@ struct PrimitiveDataBuffer:public Comparator<PrimitiveDataBuffer>
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PrimitiveDataBuffer(const uint32_t,IndexBuffer *,VertexDataManager *_v=nullptr);
|
MeshDataBuffer(const uint32_t,IndexBuffer *,VertexDataManager *_v=nullptr);
|
||||||
~PrimitiveDataBuffer();
|
~MeshDataBuffer();
|
||||||
|
|
||||||
const int compare(const PrimitiveDataBuffer &pdb)const override;
|
const int compare(const MeshDataBuffer &pdb)const override;
|
||||||
};//struct PrimitiveDataBuffer
|
};//struct MeshDataBuffer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 原始图元渲染数据<Br>
|
* 原始图元渲染数据<Br>
|
||||||
* 提供在渲染时的数据
|
* 提供在渲染时的数据
|
||||||
*/
|
*/
|
||||||
struct PrimitiveRenderData:public ComparatorData<PrimitiveRenderData>
|
struct MeshRenderData:public ComparatorData<MeshRenderData>
|
||||||
{
|
{
|
||||||
//因为要VAB是流式访问,所以我们这个结构会被用做排序依据
|
//因为要VAB是流式访问,所以我们这个结构会被用做排序依据
|
||||||
//也因此,把vertex_offset放在最前面
|
//也因此,把vertex_offset放在最前面
|
||||||
@ -52,7 +52,7 @@ struct PrimitiveRenderData:public ComparatorData<PrimitiveRenderData>
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PrimitiveRenderData(const uint32_t vc,const uint32_t ic,const int32_t vo=0,const uint32_t fi=0)
|
MeshRenderData(const uint32_t vc,const uint32_t ic,const int32_t vo=0,const uint32_t fi=0)
|
||||||
{
|
{
|
||||||
vertex_count =vc;
|
vertex_count =vc;
|
||||||
index_count =ic;
|
index_count =ic;
|
||||||
@ -70,14 +70,14 @@ class Mesh
|
|||||||
MaterialInstance * mat_inst;
|
MaterialInstance * mat_inst;
|
||||||
Primitive * primitive;
|
Primitive * primitive;
|
||||||
|
|
||||||
PrimitiveDataBuffer * primitive_data_buffer;
|
MeshDataBuffer * data_buffer;
|
||||||
PrimitiveRenderData * primitive_render_data;
|
MeshRenderData * render_data;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend Mesh *CreateRenderable(Primitive *,MaterialInstance *,Pipeline *);
|
friend Mesh *CreateRenderable(Primitive *,MaterialInstance *,Pipeline *);
|
||||||
|
|
||||||
Mesh(Primitive *,MaterialInstance *,Pipeline *,PrimitiveDataBuffer *,PrimitiveRenderData *);
|
Mesh(Primitive *,MaterialInstance *,Pipeline *,MeshDataBuffer *,MeshRenderData *);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -85,8 +85,8 @@ public:
|
|||||||
{
|
{
|
||||||
//需要在这里添加删除pipeline/desc_sets/primitive引用计数的代码
|
//需要在这里添加删除pipeline/desc_sets/primitive引用计数的代码
|
||||||
|
|
||||||
SAFE_CLEAR(primitive_data_buffer);
|
SAFE_CLEAR(data_buffer);
|
||||||
SAFE_CLEAR(primitive_render_data);
|
SAFE_CLEAR(render_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatePipeline (Pipeline *p){pipeline=p;}
|
void UpdatePipeline (Pipeline *p){pipeline=p;}
|
||||||
@ -98,8 +98,8 @@ public:
|
|||||||
Primitive * GetPrimitive (){return primitive;}
|
Primitive * GetPrimitive (){return primitive;}
|
||||||
const AABB & GetBoundingBox ()const{return primitive->GetBoundingBox();}
|
const AABB & GetBoundingBox ()const{return primitive->GetBoundingBox();}
|
||||||
|
|
||||||
const PrimitiveDataBuffer *GetDataBuffer ()const{return primitive_data_buffer;}
|
const MeshDataBuffer * GetDataBuffer ()const{return data_buffer;}
|
||||||
const PrimitiveRenderData *GetRenderData ()const{return primitive_render_data;}
|
const MeshRenderData * GetRenderData ()const{return render_data;}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ void RenderCmdBuffer::BindIBO(IndexBuffer *ibo,const VkDeviceSize byte_offset)
|
|||||||
VkIndexType(ibo->GetType()));
|
VkIndexType(ibo->GetType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderCmdBuffer::BindDataBuffer(const PrimitiveDataBuffer *pdb)
|
bool RenderCmdBuffer::BindDataBuffer(const MeshDataBuffer *pdb)
|
||||||
{
|
{
|
||||||
if(!pdb)
|
if(!pdb)
|
||||||
return(false);
|
return(false);
|
||||||
@ -178,7 +178,7 @@ void RenderCmdBuffer::DrawIndexedIndirect( VkBuffer buffer,
|
|||||||
vkCmdDrawIndexedIndirect(cmd_buf,buffer,offset+i*stride,1,stride);
|
vkCmdDrawIndexedIndirect(cmd_buf,buffer,offset+i*stride,1,stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderCmdBuffer::Draw(const PrimitiveDataBuffer *pdb,const PrimitiveRenderData *prd,const uint32_t instance_count,const uint32_t first_instance)
|
void RenderCmdBuffer::Draw(const MeshDataBuffer *pdb,const MeshRenderData *prd,const uint32_t instance_count,const uint32_t first_instance)
|
||||||
{
|
{
|
||||||
if(!pdb||!prd)
|
if(!pdb||!prd)
|
||||||
return;
|
return;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include<hgl/log/LogInfo.h>
|
#include<hgl/log/LogInfo.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
PrimitiveDataBuffer::PrimitiveDataBuffer(const uint32_t c,IndexBuffer *ib,VertexDataManager *_vdm)
|
MeshDataBuffer::MeshDataBuffer(const uint32_t c,IndexBuffer *ib,VertexDataManager *_vdm)
|
||||||
{
|
{
|
||||||
vab_count=c;
|
vab_count=c;
|
||||||
|
|
||||||
@ -18,13 +18,13 @@ PrimitiveDataBuffer::PrimitiveDataBuffer(const uint32_t c,IndexBuffer *ib,Vertex
|
|||||||
vdm=_vdm;
|
vdm=_vdm;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimitiveDataBuffer::~PrimitiveDataBuffer()
|
MeshDataBuffer::~MeshDataBuffer()
|
||||||
{
|
{
|
||||||
delete[] vab_offset;
|
delete[] vab_offset;
|
||||||
delete[] vab_list;
|
delete[] vab_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int PrimitiveDataBuffer::compare(const PrimitiveDataBuffer &pdb)const
|
const int MeshDataBuffer::compare(const MeshDataBuffer &pdb)const
|
||||||
{
|
{
|
||||||
ptrdiff_t off;
|
ptrdiff_t off;
|
||||||
|
|
||||||
@ -52,14 +52,14 @@ const int PrimitiveDataBuffer::compare(const PrimitiveDataBuffer &pdb)const
|
|||||||
return off;
|
return off;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mesh::Mesh(Primitive *r,MaterialInstance *mi,Pipeline *p,PrimitiveDataBuffer *pdb,PrimitiveRenderData *prd)
|
Mesh::Mesh(Primitive *r,MaterialInstance *mi,Pipeline *p,MeshDataBuffer *pdb,MeshRenderData *prd)
|
||||||
{
|
{
|
||||||
primitive=r;
|
primitive=r;
|
||||||
pipeline=p;
|
pipeline=p;
|
||||||
mat_inst=mi;
|
mat_inst=mi;
|
||||||
|
|
||||||
primitive_data_buffer=pdb;
|
data_buffer=pdb;
|
||||||
primitive_render_data=prd;
|
render_data=prd;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mesh *CreateRenderable(Primitive *prim,MaterialInstance *mi,Pipeline *p)
|
Mesh *CreateRenderable(Primitive *prim,MaterialInstance *mi,Pipeline *p)
|
||||||
@ -81,8 +81,8 @@ Mesh *CreateRenderable(Primitive *prim,MaterialInstance *mi,Pipeline *p)
|
|||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimitiveDataBuffer *pdb=new PrimitiveDataBuffer(input_count,prim->GetIBO(),prim->GetVDM());
|
MeshDataBuffer *pdb=new MeshDataBuffer(input_count,prim->GetIBO(),prim->GetVDM());
|
||||||
PrimitiveRenderData *prd=new PrimitiveRenderData(prim->GetVertexCount(),prim->GetIndexCount(),prim->GetVertexOffset(),prim->GetFirstIndex());
|
MeshRenderData *prd=new MeshRenderData(prim->GetVertexCount(),prim->GetIndexCount(),prim->GetVertexOffset(),prim->GetFirstIndex());
|
||||||
|
|
||||||
const VertexInputFormat *vif=vil->GetVIFList(VertexInputGroup::Basic);
|
const VertexInputFormat *vif=vil->GetVIFList(VertexInputGroup::Basic);
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ void MaterialRenderList::Stat()
|
|||||||
icb_draw_indexed->Unmap();
|
icb_draw_indexed->Unmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MaterialRenderList::BindVAB(const PrimitiveDataBuffer *pdb,const uint ri_index)
|
bool MaterialRenderList::BindVAB(const MeshDataBuffer *pdb,const uint ri_index)
|
||||||
{
|
{
|
||||||
//binding号都是在VertexInput::CreateVIL时连续紧密排列生成的,所以bind时first_binding写0就行了。
|
//binding号都是在VertexInput::CreateVIL时连续紧密排列生成的,所以bind时first_binding写0就行了。
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user