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
|
2023-04-28 11:09:22 +08:00
|
|
|
|
struct VertexInputData
|
|
|
|
|
{
|
2023-05-04 19:11:18 +08:00
|
|
|
|
uint32_t binding_count;
|
2023-04-28 11:09:22 +08:00
|
|
|
|
VkBuffer *buffer_list;
|
|
|
|
|
VkDeviceSize *buffer_offset;
|
2023-05-04 19:11:18 +08:00
|
|
|
|
|
2023-05-05 21:11:39 +08:00
|
|
|
|
uint32_t vertex_count;
|
2023-05-04 19:11:18 +08:00
|
|
|
|
|
2023-05-05 21:11:39 +08:00
|
|
|
|
const IndexBufferData *index_buffer;
|
2023-04-28 11:09:22 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2023-05-05 21:11:39 +08:00
|
|
|
|
VertexInputData(const uint32_t,const uint32_t,const IndexBufferData *);
|
|
|
|
|
~VertexInputData();
|
|
|
|
|
|
|
|
|
|
const bool Comp(const VertexInputData *vid)const
|
|
|
|
|
{
|
2023-05-06 19:30:08 +08:00
|
|
|
|
if(!vid)return(false);
|
|
|
|
|
|
2023-05-05 21:11:39 +08:00
|
|
|
|
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(index_buffer!=vid->index_buffer)return(false);
|
|
|
|
|
|
|
|
|
|
return(true);
|
|
|
|
|
}
|
|
|
|
|
};//struct VertexInputData
|
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
|
|
|
|
|
2023-05-05 21:11:39 +08:00
|
|
|
|
VertexInputData * vertex_input;
|
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
|
|
|
|
|
2023-05-05 21:11:39 +08:00
|
|
|
|
Renderable(Primitive *,MaterialInstance *,Pipeline *,VertexInputData *);
|
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
|
|
|
|
|
2023-05-05 21:11:39 +08:00
|
|
|
|
const VertexInputData * GetVertexInputData ()const{return vertex_input;}
|
2020-09-21 19:05:25 +08:00
|
|
|
|
|
2023-02-22 21:53:51 +08:00
|
|
|
|
MaterialParameters *GetMP (const DescriptorSetType &type){return mat_inst->GetMP(type);}
|
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
|