2022-06-24 21:06:38 +08:00
|
|
|
|
#ifndef HGL_GRAPH_RENDERABLE_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_RENDERABLE_INCLUDE
|
2020-09-21 19:05:25 +08:00
|
|
|
|
|
2022-06-24 17:51:05 +08:00
|
|
|
|
#include<hgl/graph/VKPrimitive.h>
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VKPipeline.h>
|
2023-02-13 11:50:55 +08:00
|
|
|
|
#include<hgl/graph/VKDescriptorSet.h>
|
2021-06-16 20:29:25 +08:00
|
|
|
|
#include<hgl/graph/VKMaterial.h>
|
2021-06-16 11:43:19 +08:00
|
|
|
|
#include<hgl/graph/VKMaterialParameters.h>
|
2021-06-16 20:29:25 +08:00
|
|
|
|
#include<hgl/graph/VKMaterialInstance.h>
|
2023-05-04 19:11:18 +08:00
|
|
|
|
#include<hgl/graph/VertexAttrib.h>
|
2020-09-21 19:05:25 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
2024-05-27 01:42:10 +08:00
|
|
|
|
struct PrimitiveRenderBuffer
|
2023-04-28 11:09:22 +08:00
|
|
|
|
{
|
2024-05-27 01:42:10 +08:00
|
|
|
|
uint32_t vab_count;
|
|
|
|
|
VkBuffer * vab_list;
|
|
|
|
|
IndexBuffer * ibo;
|
2023-04-28 11:09:22 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2024-05-27 01:42:10 +08:00
|
|
|
|
PrimitiveRenderBuffer(const uint32_t,const uint32_t,const IBAccess *iba);
|
|
|
|
|
~PrimitiveRenderBuffer();
|
2023-05-05 21:11:39 +08:00
|
|
|
|
|
2024-05-27 01:42:10 +08:00
|
|
|
|
const bool Comp(const PrimitiveRenderBuffer *prb)const;
|
|
|
|
|
};//struct PrimitiveRenderBuffer
|
2023-05-06 19:30:08 +08:00
|
|
|
|
|
2024-05-27 01:42:10 +08:00
|
|
|
|
struct PrimitiveRenderData
|
2024-05-25 22:08:01 +08:00
|
|
|
|
{
|
|
|
|
|
uint vab_count;
|
|
|
|
|
VkDeviceSize * vab_offset;
|
2024-05-27 01:42:10 +08:00
|
|
|
|
uint32_t vertex_count;
|
2023-05-05 21:11:39 +08:00
|
|
|
|
|
2024-05-27 01:42:10 +08:00
|
|
|
|
uint32_t index_start;
|
|
|
|
|
uint32_t index_count;
|
2023-05-05 21:11:39 +08:00
|
|
|
|
|
2024-05-25 22:08:01 +08:00
|
|
|
|
public:
|
2023-05-05 21:11:39 +08:00
|
|
|
|
|
2024-05-27 01:42:10 +08:00
|
|
|
|
PrimitiveRenderData(const uint32_t bc,const uint32_t vc,const IBAccess *iba);
|
|
|
|
|
~PrimitiveRenderData();
|
2023-05-05 21:11:39 +08:00
|
|
|
|
|
2024-05-27 01:42:10 +08:00
|
|
|
|
const bool Comp(const PrimitiveRenderData *)const;
|
2024-05-25 22:08:01 +08:00
|
|
|
|
};
|
2023-04-28 11:09:22 +08:00
|
|
|
|
|
2020-09-21 19:05:25 +08:00
|
|
|
|
/**
|
2022-06-24 21:06:38 +08:00
|
|
|
|
* 可渲染对象<br>
|
2020-09-21 19:05:25 +08:00
|
|
|
|
*/
|
2022-06-24 21:06:38 +08:00
|
|
|
|
class Renderable ///可渲染对象实例
|
2020-09-21 19:05:25 +08:00
|
|
|
|
{
|
2020-12-09 21:33:29 +08:00
|
|
|
|
Pipeline * pipeline;
|
2021-06-16 20:29:25 +08:00
|
|
|
|
MaterialInstance * mat_inst;
|
2022-06-24 18:00:22 +08:00
|
|
|
|
Primitive * primitive;
|
2020-09-21 19:05:25 +08:00
|
|
|
|
|
2024-05-27 01:42:10 +08:00
|
|
|
|
PrimitiveRenderBuffer * primitive_render_buffer;
|
|
|
|
|
PrimitiveRenderData * primitive_render_data;
|
2021-06-10 18:54:53 +08:00
|
|
|
|
|
2020-09-21 19:05:25 +08:00
|
|
|
|
private:
|
|
|
|
|
|
2022-06-24 21:06:38 +08:00
|
|
|
|
friend Renderable *CreateRenderable(Primitive *,MaterialInstance *,Pipeline *);
|
2020-09-21 19:05:25 +08:00
|
|
|
|
|
2024-05-27 01:42:10 +08:00
|
|
|
|
Renderable(Primitive *,MaterialInstance *,Pipeline *,PrimitiveRenderBuffer *,PrimitiveRenderData *);
|
2020-09-21 19:05:25 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2024-05-25 22:08:01 +08:00
|
|
|
|
virtual ~Renderable()
|
|
|
|
|
{
|
|
|
|
|
//需要在这里添加删除pipeline/desc_sets/primitive引用计数的代码
|
|
|
|
|
|
2024-05-27 01:42:10 +08:00
|
|
|
|
SAFE_CLEAR(primitive_render_buffer);
|
|
|
|
|
SAFE_CLEAR(primitive_render_data);
|
2024-05-25 22:08:01 +08:00
|
|
|
|
}
|
2020-09-21 19:05:25 +08:00
|
|
|
|
|
2021-06-20 02:15:17 +08:00
|
|
|
|
void UpdatePipeline (Pipeline *p){pipeline=p;}
|
|
|
|
|
|
2020-12-09 21:33:29 +08:00
|
|
|
|
Pipeline * GetPipeline (){return pipeline;}
|
2021-06-16 20:29:25 +08:00
|
|
|
|
VkPipelineLayout GetPipelineLayout (){return mat_inst->GetMaterial()->GetPipelineLayout();}
|
2021-06-16 21:03:52 +08:00
|
|
|
|
Material * GetMaterial (){return mat_inst->GetMaterial();}
|
2021-06-16 20:29:25 +08:00
|
|
|
|
MaterialInstance * GetMaterialInstance (){return mat_inst;}
|
2022-06-24 18:00:22 +08:00
|
|
|
|
Primitive * GetPrimitive (){return primitive;}
|
|
|
|
|
const AABB & GetBoundingBox ()const{return primitive->GetBoundingBox();}
|
2020-09-21 19:05:25 +08:00
|
|
|
|
|
2024-05-27 01:42:10 +08:00
|
|
|
|
const PrimitiveRenderBuffer * GetRenderBuffer ()const{return primitive_render_buffer;}
|
|
|
|
|
const PrimitiveRenderData * GetRenderData ()const{return primitive_render_data;}
|
2022-06-24 21:06:38 +08:00
|
|
|
|
};//class Renderable
|
2020-09-21 19:05:25 +08:00
|
|
|
|
|
2022-06-24 21:06:38 +08:00
|
|
|
|
Renderable *CreateRenderable(Primitive *,MaterialInstance *,Pipeline *);
|
2020-09-21 19:05:25 +08:00
|
|
|
|
VK_NAMESPACE_END
|
2022-06-24 21:06:38 +08:00
|
|
|
|
#endif//HGL_GRAPH_RENDERABLE_INCLUDE
|