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 first_binding;
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct VertexInputDataGroup
|
|
|
|
|
{
|
|
|
|
|
const VIL *vil;
|
|
|
|
|
|
|
|
|
|
VertexInputData vid[size_t(VertexInputGroup::RANGE_SIZE)];
|
2023-04-28 11:09:22 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2023-05-04 19:11:18 +08:00
|
|
|
|
VertexInputDataGroup(const VIL *);
|
|
|
|
|
~VertexInputDataGroup();
|
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-04 19:11:18 +08:00
|
|
|
|
VertexInputDataGroup *vid_group;
|
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-04 19:11:18 +08:00
|
|
|
|
Renderable(Primitive *,MaterialInstance *,Pipeline *,VertexInputDataGroup *);
|
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-04 19:11:18 +08:00
|
|
|
|
const VertexInputData * GetVertexInputData (const VertexInputGroup &vig)const
|
|
|
|
|
{
|
|
|
|
|
RANGE_CHECK_RETURN_NULLPTR(vig)
|
|
|
|
|
|
|
|
|
|
return vid_group->vid+size_t(vig);
|
|
|
|
|
}
|
2023-04-28 11:09:22 +08:00
|
|
|
|
|
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
|
|
|
|
|
2023-02-22 21:53:51 +08:00
|
|
|
|
MaterialParameters *GetMP (const DescriptorSetType &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
|