2023-03-23 21:43:10 +08:00
|
|
|
|
#ifndef HGL_GRAPH_RENDER_NODE_2D_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_RENDER_NODE_2D_INCLUDE
|
|
|
|
|
|
2023-03-24 22:14:43 +08:00
|
|
|
|
#include<hgl/math/Math.h>
|
2023-04-25 18:08:26 +08:00
|
|
|
|
#include<hgl/type/Map.h>
|
2023-05-04 22:01:00 +08:00
|
|
|
|
#include<hgl/graph/VK.h>
|
2023-03-23 21:43:10 +08:00
|
|
|
|
namespace hgl
|
|
|
|
|
{
|
|
|
|
|
namespace graph
|
|
|
|
|
{
|
|
|
|
|
class Renderable;
|
2023-04-25 18:08:26 +08:00
|
|
|
|
class Material;
|
2023-05-04 22:01:00 +08:00
|
|
|
|
class GPUDevice;
|
2023-03-23 21:43:10 +08:00
|
|
|
|
|
|
|
|
|
struct RenderNode2D
|
|
|
|
|
{
|
2023-03-24 22:14:43 +08:00
|
|
|
|
Matrix3x4f local_to_world;
|
2023-03-23 21:43:10 +08:00
|
|
|
|
|
|
|
|
|
Renderable *ri;
|
|
|
|
|
};
|
|
|
|
|
|
2023-04-26 20:52:31 +08:00
|
|
|
|
using RenderNode2DList=List<RenderNode2D>;
|
2023-04-25 18:08:26 +08:00
|
|
|
|
|
2023-05-04 22:01:00 +08:00
|
|
|
|
struct RenderNode2DExtraBuffer;
|
|
|
|
|
|
2023-04-25 18:08:26 +08:00
|
|
|
|
/**
|
|
|
|
|
* 同一材质的对象渲染列表
|
|
|
|
|
*/
|
2023-04-26 20:52:31 +08:00
|
|
|
|
class MaterialRenderList2D
|
2023-04-25 18:08:26 +08:00
|
|
|
|
{
|
2023-05-04 22:01:00 +08:00
|
|
|
|
GPUDevice *device;
|
|
|
|
|
RenderCmdBuffer *cmd_buf;
|
|
|
|
|
|
2023-04-25 18:08:26 +08:00
|
|
|
|
Material *mtl;
|
|
|
|
|
|
|
|
|
|
RenderNode2DList rn_list;
|
2023-04-26 20:52:31 +08:00
|
|
|
|
|
2023-05-04 22:01:00 +08:00
|
|
|
|
RenderNode2DExtraBuffer *extra_buffer;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
uint32_t binding_count;
|
|
|
|
|
VkBuffer *buffer_list;
|
|
|
|
|
VkDeviceSize *buffer_offset;
|
|
|
|
|
|
|
|
|
|
MaterialInstance *last_mi;
|
|
|
|
|
Pipeline *last_pipeline;
|
|
|
|
|
Primitive *last_primitive;
|
|
|
|
|
uint first_index;
|
|
|
|
|
|
|
|
|
|
void Render(const uint index,Renderable *);
|
|
|
|
|
|
2023-04-26 20:52:31 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2023-05-04 22:01:00 +08:00
|
|
|
|
MaterialRenderList2D(GPUDevice *d,RenderCmdBuffer *,Material *m);
|
|
|
|
|
~MaterialRenderList2D();
|
2023-04-26 20:52:31 +08:00
|
|
|
|
|
|
|
|
|
void Add(Renderable *ri,const Matrix3x4f &mat);
|
|
|
|
|
|
|
|
|
|
void ClearData()
|
|
|
|
|
{
|
|
|
|
|
rn_list.ClearData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void End();
|
2023-05-04 22:01:00 +08:00
|
|
|
|
|
|
|
|
|
void Render();
|
2023-04-25 18:08:26 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MaterialRenderMap2D:public ObjectMap<Material *,MaterialRenderList2D>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
MaterialRenderMap2D()=default;
|
|
|
|
|
virtual ~MaterialRenderMap2D()=default;
|
|
|
|
|
|
2023-04-26 20:52:31 +08:00
|
|
|
|
void Begin()
|
|
|
|
|
{
|
|
|
|
|
for(auto *it:data_list)
|
|
|
|
|
it->value->ClearData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void End()
|
2023-04-25 18:08:26 +08:00
|
|
|
|
{
|
|
|
|
|
for(auto *it:data_list)
|
2023-04-26 20:52:31 +08:00
|
|
|
|
it->value->End();
|
2023-04-25 18:08:26 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2023-03-23 21:43:10 +08:00
|
|
|
|
}//namespace graph
|
|
|
|
|
}//namespace hgl
|
|
|
|
|
#endif//HGL_GRAPH_RENDER_NODE_2D_INCLUDE
|