create DrawData that it split from VertexInputData
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
#include<hgl/graph/VKVBOList.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class RenderL2WBuffer;
|
||||
class RenderAssignBuffer;
|
||||
|
||||
|
||||
/**
|
||||
* 同一材质的对象渲染列表
|
||||
*/
|
||||
@@ -30,6 +30,7 @@ private:
|
||||
Pipeline * pipeline;
|
||||
MaterialInstance * mi;
|
||||
const VertexInputData * vid;
|
||||
const DrawData * dd;
|
||||
|
||||
public:
|
||||
|
||||
@@ -47,9 +48,10 @@ protected:
|
||||
|
||||
Pipeline * last_pipeline;
|
||||
const VertexInputData * last_vid;
|
||||
const DrawData * last_dd;
|
||||
uint last_index;
|
||||
|
||||
bool Bind(const VertexInputData *,const uint);
|
||||
bool BindVAB(const VertexInputData *,const DrawData *,const uint);
|
||||
|
||||
void Render(RenderItem *);
|
||||
|
||||
|
@@ -55,6 +55,7 @@ class DeviceBuffer;
|
||||
struct DeviceBufferData;
|
||||
|
||||
struct VertexInputData;
|
||||
struct DrawData;
|
||||
|
||||
class VertexAttribBuffer;
|
||||
using VAB=VertexAttribBuffer;
|
||||
|
@@ -165,12 +165,12 @@ public:
|
||||
|
||||
if(!vbo_list->IsFull())return(false);
|
||||
|
||||
vkCmdBindVertexBuffers(cmd_buf,0,vbo_list->binding_count,vbo_list->buffer_list,vbo_list->buffer_offset);
|
||||
vkCmdBindVertexBuffers(cmd_buf,0,vbo_list->vab_count,vbo_list->vab_list,vbo_list->vab_offset);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
// void BindIBO(const IBAccess *);
|
||||
void BindIBO(IndexBuffer *ibo,VkDeviceSize offset); ///<绑定IBO,注意offset意为索引偏移量,不是字节
|
||||
|
||||
bool BindVBO(Renderable *);
|
||||
|
||||
@@ -200,8 +200,8 @@ public: //draw
|
||||
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 Draw (const VertexInputData *vid);
|
||||
void DrawIndexed (const IBAccess *iba,const uint32_t instance_count);
|
||||
void Draw (const VertexInputData *vid,const DrawData *dd);
|
||||
// void DrawIndexed (const IBAccess *iba,const uint32_t instance_count);
|
||||
|
||||
public: //dynamic state
|
||||
};//class RenderCmdBuffer:public GPUCmdBuffer
|
||||
|
@@ -11,12 +11,12 @@ class DeviceBuffer;
|
||||
class DescriptorSet
|
||||
{
|
||||
VkDevice device;
|
||||
int binding_count;
|
||||
int vab_count;
|
||||
VkDescriptorSet desc_set;
|
||||
|
||||
VkPipelineLayout pipeline_layout;
|
||||
|
||||
ObjectList<VkDescriptorBufferInfo> buffer_list;
|
||||
ObjectList<VkDescriptorBufferInfo> vab_list;
|
||||
ObjectList<VkDescriptorImageInfo> image_list;
|
||||
List<VkWriteDescriptorSet> wds_list;
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
DescriptorSet(VkDevice dev,const int bc,VkPipelineLayout pl,VkDescriptorSet ds)
|
||||
{
|
||||
device =dev;
|
||||
binding_count =bc;
|
||||
vab_count =bc;
|
||||
desc_set =ds;
|
||||
pipeline_layout =pl;
|
||||
|
||||
@@ -38,11 +38,11 @@ public:
|
||||
|
||||
~DescriptorSet()=default;
|
||||
|
||||
const uint32_t GetCount ()const{return binding_count;}
|
||||
const uint32_t GetCount ()const{return vab_count;}
|
||||
const VkDescriptorSet GetDescriptorSet ()const{return desc_set;}
|
||||
const VkPipelineLayout GetPipelineLayout ()const{return pipeline_layout;}
|
||||
|
||||
const bool IsReady ()const{return wds_list.GetCount()==binding_count;}
|
||||
const bool IsReady ()const{return wds_list.GetCount()==vab_count;}
|
||||
|
||||
void Clear();
|
||||
|
||||
|
@@ -22,7 +22,7 @@ class Material
|
||||
{
|
||||
AnsiString name;
|
||||
|
||||
VertexInput *vertex_input;
|
||||
VertexInput *vertex_input_data;
|
||||
|
||||
ShaderModuleMap *shader_maps;
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
const AnsiString & GetName ()const{return name;}
|
||||
|
||||
const VertexInput * GetVertexInput ()const{return vertex_input;}
|
||||
const VertexInput * GetVertexInput ()const{return vertex_input_data;}
|
||||
|
||||
const ShaderStageCreateInfoList & GetStageList ()const{return shader_stage_list;}
|
||||
|
||||
|
@@ -40,10 +40,13 @@ public:
|
||||
public:
|
||||
|
||||
const AnsiString & GetName ()const{ return prim_name; }
|
||||
|
||||
const VkDeviceSize GetVertexCount ()const;
|
||||
const int GetVABCount ()const;
|
||||
VABAccess * GetVABAccess (const AnsiString &);
|
||||
|
||||
IBAccess * GetIBAccess ();
|
||||
IndexBuffer * GetIBO ();
|
||||
|
||||
const AABB & GetBoundingBox ()const{return BoundingBox;}
|
||||
};//class Primitive
|
||||
|
@@ -11,39 +11,35 @@
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct VertexInputData
|
||||
{
|
||||
uint32_t binding_count;
|
||||
VkBuffer *buffer_list;
|
||||
VkDeviceSize *buffer_offset;
|
||||
|
||||
uint32_t vertex_count;
|
||||
|
||||
const IBAccess *ib_access;
|
||||
uint32_t vab_count;
|
||||
VkBuffer *vab_list;
|
||||
IndexBuffer *ibo;
|
||||
|
||||
public:
|
||||
|
||||
VertexInputData(const uint32_t,const uint32_t,const IBAccess *);
|
||||
VertexInputData(const uint32_t,const uint32_t,const IBAccess *iba);
|
||||
~VertexInputData();
|
||||
|
||||
const bool Comp(const VertexInputData *vid)const
|
||||
{
|
||||
if(!vid)return(false);
|
||||
|
||||
if(binding_count!=vid->binding_count)return(false);
|
||||
|
||||
for(uint32_t i=0;i<binding_count;i++)
|
||||
{
|
||||
if(buffer_list[i]!=vid->buffer_list[i])return(false);
|
||||
if(buffer_offset[i]!=vid->buffer_offset[i])return(false);
|
||||
}
|
||||
|
||||
if(vertex_count!=vid->vertex_count)return(false);
|
||||
|
||||
if(ib_access!=vid->ib_access)return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
const bool Comp(const VertexInputData *vid)const;
|
||||
};//struct VertexInputData
|
||||
|
||||
struct DrawData
|
||||
{
|
||||
uint vab_count;
|
||||
VkDeviceSize * vab_offset;
|
||||
VkDeviceSize vertex_count;
|
||||
|
||||
VkDeviceSize index_start;
|
||||
VkDeviceSize index_count;
|
||||
|
||||
public:
|
||||
|
||||
DrawData(const uint32_t bc,const VkDeviceSize vc,const IBAccess *iba);
|
||||
~DrawData();
|
||||
|
||||
const bool Comp(const DrawData *)const;
|
||||
};
|
||||
|
||||
/**
|
||||
* 可渲染对象<br>
|
||||
*/
|
||||
@@ -53,17 +49,24 @@ class Renderable
|
||||
MaterialInstance * mat_inst;
|
||||
Primitive * primitive;
|
||||
|
||||
VertexInputData * vertex_input;
|
||||
VertexInputData * vertex_input_data;
|
||||
DrawData * draw_data;
|
||||
|
||||
private:
|
||||
|
||||
friend Renderable *CreateRenderable(Primitive *,MaterialInstance *,Pipeline *);
|
||||
|
||||
Renderable(Primitive *,MaterialInstance *,Pipeline *,VertexInputData *);
|
||||
Renderable(Primitive *,MaterialInstance *,Pipeline *,VertexInputData *,DrawData *);
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Renderable();
|
||||
virtual ~Renderable()
|
||||
{
|
||||
//需要在这里添加删除pipeline/desc_sets/primitive引用计数的代码
|
||||
|
||||
SAFE_CLEAR(vertex_input_data);
|
||||
SAFE_CLEAR(draw_data);
|
||||
}
|
||||
|
||||
void UpdatePipeline (Pipeline *p){pipeline=p;}
|
||||
|
||||
@@ -74,7 +77,8 @@ public:
|
||||
Primitive * GetPrimitive (){return primitive;}
|
||||
const AABB & GetBoundingBox ()const{return primitive->GetBoundingBox();}
|
||||
|
||||
const VertexInputData * GetVertexInputData ()const{return vertex_input;}
|
||||
const VertexInputData * GetVertexInputData ()const{return vertex_input_data;}
|
||||
const DrawData * GetDrawData ()const{return draw_data;}
|
||||
};//class Renderable
|
||||
|
||||
Renderable *CreateRenderable(Primitive *,MaterialInstance *,Pipeline *);
|
||||
|
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class VBOList
|
||||
{
|
||||
uint32_t binding_count;
|
||||
VkBuffer *buffer_list;
|
||||
VkDeviceSize *buffer_offset;
|
||||
uint32_t vab_count;
|
||||
VkBuffer *vab_list;
|
||||
VkDeviceSize *vab_offset;
|
||||
|
||||
uint32_t write_count;
|
||||
|
||||
@@ -15,17 +15,17 @@ public:
|
||||
|
||||
VBOList(const uint32 bc)
|
||||
{
|
||||
binding_count=bc;
|
||||
buffer_list=new VkBuffer[binding_count];
|
||||
buffer_offset=new VkDeviceSize[binding_count];
|
||||
vab_count=bc;
|
||||
vab_list=new VkBuffer[vab_count];
|
||||
vab_offset=new VkDeviceSize[vab_count];
|
||||
|
||||
write_count=0;
|
||||
}
|
||||
|
||||
~VBOList()
|
||||
{
|
||||
delete[] buffer_offset;
|
||||
delete[] buffer_list;
|
||||
delete[] vab_offset;
|
||||
delete[] vab_list;
|
||||
}
|
||||
|
||||
void Restart()
|
||||
@@ -35,21 +35,21 @@ public:
|
||||
|
||||
const bool IsFull()const
|
||||
{
|
||||
return write_count>=binding_count;
|
||||
return write_count>=vab_count;
|
||||
}
|
||||
|
||||
void Add(const VkBuffer buf,const VkDeviceSize offset)
|
||||
{
|
||||
buffer_list[write_count]=buf;
|
||||
buffer_offset[write_count]=offset;
|
||||
vab_list[write_count]=buf;
|
||||
vab_offset[write_count]=offset;
|
||||
|
||||
++write_count;
|
||||
}
|
||||
|
||||
void Add(const VkBuffer *buf,const VkDeviceSize *offset,const uint32_t count)
|
||||
{
|
||||
hgl_cpy(buffer_list +write_count,buf, count);
|
||||
hgl_cpy(buffer_offset+write_count,offset,count);
|
||||
hgl_cpy(vab_list +write_count,buf, count);
|
||||
hgl_cpy(vab_offset+write_count,offset,count);
|
||||
|
||||
write_count+=count;
|
||||
}
|
||||
|
Reference in New Issue
Block a user