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>
|
|
|
|
|
#include<hgl/graph/VKDescriptorSets.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>
|
2020-09-21 19:05:25 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
|
|
|
|
/**
|
2022-06-24 21:06:38 +08:00
|
|
|
|
* 可渲染对象<br>
|
2020-12-18 16:51:53 +08:00
|
|
|
|
* RenderList会统一管理Shader中的LocalToWorld数据,使用DynamicUBO/DynamicSSBO实现。
|
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
|
|
|
|
|
2020-12-09 21:33:29 +08:00
|
|
|
|
uint32_t buffer_count;
|
|
|
|
|
VkBuffer * buffer_list;
|
|
|
|
|
VkDeviceSize * buffer_size;
|
2020-09-21 19:05:25 +08:00
|
|
|
|
|
2021-06-10 18:54:53 +08:00
|
|
|
|
uint32_t buffer_hash;
|
|
|
|
|
|
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
|
|
|
|
|
2022-06-24 21:06:38 +08:00
|
|
|
|
Renderable(Primitive *,MaterialInstance *,Pipeline *,const uint32_t,VkBuffer *,VkDeviceSize *);
|
2020-09-21 19:05:25 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2022-06-24 21:06:38 +08:00
|
|
|
|
virtual ~Renderable();
|
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
|
|
|
|
|
2020-12-09 21:33:29 +08:00
|
|
|
|
const uint32_t GetBufferCount ()const{return buffer_count;}
|
|
|
|
|
VkBuffer * GetBuffer ()const{return buffer_list;}
|
|
|
|
|
VkDeviceSize * GetBufferSize ()const{return buffer_size;}
|
2022-06-24 18:00:22 +08:00
|
|
|
|
IndexBuffer * GetIndexBuffer ()const{return primitive->GetIndexBuffer();}
|
|
|
|
|
const uint32_t GetIndexBufferOffset()const{return primitive->GetIndexBufferOffset();}
|
|
|
|
|
const uint32_t GetDrawCount ()const{return primitive->GetDrawCount();}
|
2020-09-21 19:05:25 +08:00
|
|
|
|
|
2021-06-10 18:54:53 +08:00
|
|
|
|
const uint32_t GetBufferHash ()const{return buffer_hash;}
|
|
|
|
|
|
2021-09-27 21:20:22 +08:00
|
|
|
|
MaterialParameters *GetMP (const DescriptorSetsType &type){return mat_inst->GetMP(type);}
|
2022-06-24 16:28:22 +08:00
|
|
|
|
|
|
|
|
|
public: //instance support
|
|
|
|
|
|
|
|
|
|
virtual const uint32_t GetInstanceCount ()const{return 1;}
|
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
|