finished to stat render list,maked buffer list....next step to bind buffer.

This commit is contained in:
2023-05-05 21:12:53 +08:00
parent 2eac17ac61
commit 21201b1695
4 changed files with 207 additions and 57 deletions

View File

@@ -11,6 +11,8 @@ namespace hgl
class Renderable;
class Material;
class GPUDevice;
struct VertexInputData;
struct IndexBufferData;
struct RenderNode2D
{
@@ -35,20 +37,44 @@ namespace hgl
RenderNode2DList rn_list;
private:
RenderNode2DExtraBuffer *extra_buffer;
struct RenderItem
{
uint32_t first;
uint32_t count;
Pipeline * pipeline;
MaterialInstance * mi;
const VertexInputData * vid;
public:
void Set(Renderable *);
};
List<RenderItem> ri_list;
uint ri_count;
void Stat();
protected:
uint32_t binding_count;
VkBuffer *buffer_list;
VkDeviceSize *buffer_offset;
MaterialInstance *last_mi;
Pipeline *last_pipeline;
Primitive *last_primitive;
uint first_index;
MaterialInstance * last_mi;
Pipeline * last_pipeline;
const VertexInputData * last_vid;
uint last_index;
void Render(const uint index,Renderable *);
void Bind(MaterialInstance *);
bool Bind(const VertexInputData *,const uint);
void Render(RenderItem *);
public:

View File

@@ -7,6 +7,12 @@
#include<hgl/math/Math.h>
#include<hgl/graph/AABB.h>
VK_NAMESPACE_BEGIN
struct IndexBufferData
{
IndexBuffer *buffer;
VkDeviceSize offset;
};
/**
* 单一图元数据
*/
@@ -26,10 +32,9 @@ class Primitive
protected:
uint32_t draw_count;
uint32_t vertex_count;
IndexBuffer *indices_buffer=nullptr;
VkDeviceSize indices_offset=0;
IndexBufferData index_buffer_data;
protected:
@@ -46,42 +51,34 @@ protected:
public:
Primitive(const uint32_t dc=0):draw_count(dc){}
Primitive(const uint32_t vc=0):vertex_count(vc){}
virtual ~Primitive()=default;
const uint GetRefCount()const{return ref_count;}
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
const AABB & GetBoundingBox()const {return BoundingBox;}
bool Set(const AnsiString &name,VBO *vb,VkDeviceSize offset=0);
bool Set(const AnsiString &name,VBO *vb,VkDeviceSize offset=0);
bool Set(IndexBuffer *ib,VkDeviceSize offset=0)
bool Set(IndexBuffer *ib,VkDeviceSize offset=0)
{
if(!ib)return(false);
indices_buffer=ib;
indices_offset=offset;
index_buffer_data.buffer=ib;
index_buffer_data.offset=offset;
return(true);
}
public:
void SetDrawCount(const uint32_t dc){draw_count=dc;} ///<设置当前对象绘制需要多少个顶点
virtual const uint32_t GetDrawCount()const ///<取得当前对象绘制需要多少个顶点
{
if(indices_buffer)
return indices_buffer->GetCount();
const uint32_t GetVertexCount ()const {return vertex_count;}
return draw_count;
}
VBO * GetVBO (const AnsiString &,VkDeviceSize *);
VkBuffer GetBuffer (const AnsiString &,VkDeviceSize *);
const int GetBufferCount ()const {return buffer_list.GetCount();}
VBO * GetVBO (const AnsiString &,VkDeviceSize *);
VkBuffer GetBuffer (const AnsiString &,VkDeviceSize *);
const int GetBufferCount ()const {return buffer_list.GetCount();}
IndexBuffer * GetIndexBuffer () {return indices_buffer;}
const VkDeviceSize GetIndexBufferOffset()const {return indices_offset;}
const IndexBufferData * GetIndexBuffer ()const {return &index_buffer_data;}
};//class Primitive
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE