(WIP) renamed a few values, new SceneTreeToRenderList
This commit is contained in:
parent
45284e1a32
commit
015a4d0b8e
@ -27,7 +27,7 @@ namespace hgl
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
Camera * camera;
|
Camera * camera;
|
||||||
CameraInfo * camera_matrix;
|
CameraInfo * camera_info;
|
||||||
Frustum frustum;
|
Frustum frustum;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -56,7 +56,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
device=d;
|
device=d;
|
||||||
camera=nullptr;
|
camera=nullptr;
|
||||||
camera_matrix=nullptr;
|
camera_info=nullptr;
|
||||||
|
|
||||||
scene_node_list=nullptr;
|
scene_node_list=nullptr;
|
||||||
render_list=nullptr;
|
render_list=nullptr;
|
||||||
|
@ -31,10 +31,10 @@ namespace hgl
|
|||||||
|
|
||||||
{
|
{
|
||||||
uint32_t unit_size=sizeof(T);
|
uint32_t unit_size=sizeof(T);
|
||||||
VKMemoryAllocator *ma=new VKMemoryAllocator(device,buffer_usage_flags);
|
VKMemoryAllocator *ma=new VKMemoryAllocator(device,buffer_usage_flags); // construct function is going to set AllocUnitSize by minUniformOffsetAlignment
|
||||||
MemoryBlock *mb=new MemoryBlock(ma);
|
MemoryBlock *mb=new MemoryBlock(ma);
|
||||||
|
|
||||||
uint32_t align_size=ma->GetAllocUnitSize()-1; ///< this value is "min UBO Offset alignment"
|
const uint32_t align_size=ma->GetAllocUnitSize()-1; // this value is "min UBO Offset alignment"
|
||||||
|
|
||||||
unit_size=(unit_size+align_size)&(~align_size);
|
unit_size=(unit_size+align_size)&(~align_size);
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ namespace hgl
|
|||||||
|
|
||||||
T *Map(const uint32 start,const uint32 count)
|
T *Map(const uint32 start,const uint32 count)
|
||||||
{
|
{
|
||||||
return coll->Map(start,count);
|
return (T *)(coll->Map(start,count));
|
||||||
}
|
}
|
||||||
};//class GPUArrayBuffer
|
};//class GPUArrayBuffer
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
|
@ -9,7 +9,7 @@ class GPUBuffer;
|
|||||||
class DescriptorSets
|
class DescriptorSets
|
||||||
{
|
{
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
int count;
|
int layout_binding_count;
|
||||||
VkDescriptorSet desc_set;
|
VkDescriptorSet desc_set;
|
||||||
const BindingMapping *index_by_binding;
|
const BindingMapping *index_by_binding;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ private:
|
|||||||
DescriptorSets(VkDevice dev,const int c,VkPipelineLayout pl,VkDescriptorSet ds,const BindingMapping *bi):index_by_binding(bi)
|
DescriptorSets(VkDevice dev,const int c,VkPipelineLayout pl,VkDescriptorSet ds,const BindingMapping *bi):index_by_binding(bi)
|
||||||
{
|
{
|
||||||
device=dev;
|
device=dev;
|
||||||
count=c;
|
layout_binding_count=c;
|
||||||
desc_set=ds;
|
desc_set=ds;
|
||||||
pipeline_layout=pl;
|
pipeline_layout=pl;
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ public:
|
|||||||
|
|
||||||
~DescriptorSets()=default;
|
~DescriptorSets()=default;
|
||||||
|
|
||||||
const uint32_t GetCount ()const{return count;}
|
const uint32_t GetCount ()const{return layout_binding_count;}
|
||||||
const VkDescriptorSet * GetDescriptorSets ()const{return &desc_set;}
|
const VkDescriptorSet * GetDescriptorSets ()const{return &desc_set;}
|
||||||
const VkPipelineLayout GetPipelineLayout ()const{return pipeline_layout;}
|
const VkPipelineLayout GetPipelineLayout ()const{return pipeline_layout;}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
constexpr size_t MVPMatrixBytes=sizeof(MVPMatrix);
|
constexpr size_t MVPMatrixBytes=sizeof(MVPMatrix);
|
||||||
|
|
||||||
|
|
||||||
//bool FrustumClipFilter(const SceneNode *node,void *fc)
|
//bool FrustumClipFilter(const SceneNode *node,void *fc)
|
||||||
//{
|
//{
|
||||||
// if(!node||!fc)return(false);
|
// if(!node||!fc)return(false);
|
||||||
@ -57,7 +56,7 @@ namespace hgl
|
|||||||
scene_node_list.Add(node);
|
scene_node_list.Add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderList::End(CameraInfo *camera_matrix)
|
void RenderList::End(CameraInfo *camera_info)
|
||||||
{
|
{
|
||||||
//清0计数器
|
//清0计数器
|
||||||
uint32_t mvp_count=0; //local to world矩阵总数量
|
uint32_t mvp_count=0; //local to world矩阵总数量
|
||||||
@ -80,7 +79,7 @@ namespace hgl
|
|||||||
|
|
||||||
if(!l2w.IsIdentity())
|
if(!l2w.IsIdentity())
|
||||||
{
|
{
|
||||||
mp->Set(l2w,camera_matrix->vp);
|
mp->Set(l2w,camera_info->vp);
|
||||||
++mp;
|
++mp;
|
||||||
|
|
||||||
*op=mvp_count*MVPMatrixBytes;
|
*op=mvp_count*MVPMatrixBytes;
|
||||||
|
@ -17,69 +17,68 @@ namespace hgl
|
|||||||
return( length_squared(obj_one->GetCenter(),camera->pos)-
|
return( length_squared(obj_one->GetCenter(),camera->pos)-
|
||||||
length_squared(obj_two->GetCenter(),camera->pos));
|
length_squared(obj_two->GetCenter(),camera->pos));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool SceneTreeToRenderList::InFrustum(const SceneNode *,void *)
|
//bool SceneTreeToRenderList::InFrustum(const SceneNode *,void *)
|
||||||
{
|
//{
|
||||||
return(true);
|
// return(true);
|
||||||
}
|
//}
|
||||||
|
|
||||||
bool SceneTreeToRenderList::Begin()
|
//bool SceneTreeToRenderList::Begin()
|
||||||
{
|
//{
|
||||||
if(!scene_node_list)
|
// if(!scene_node_list)
|
||||||
scene_node_list=new SceneNodeList;
|
// scene_node_list=new SceneNodeList;
|
||||||
|
|
||||||
scene_node_list->ClearData();
|
// scene_node_list->ClearData();
|
||||||
|
|
||||||
pipeline_sets.ClearData();
|
// pipeline_sets.ClearData();
|
||||||
material_sets.ClearData();
|
// material_sets.ClearData();
|
||||||
mat_instance_sets.ClearData();
|
// mat_instance_sets.ClearData();
|
||||||
|
|
||||||
return(true);
|
// return(true);
|
||||||
}
|
//}
|
||||||
|
|
||||||
/**
|
///**
|
||||||
* 理论上讲,我们需要按以下顺序排序
|
//* 理论上讲,我们需要按以下顺序排序
|
||||||
*
|
//*
|
||||||
* for(material)
|
//* for(material)
|
||||||
* for(pipeline)
|
//* for(pipeline)
|
||||||
* for(material_instance)
|
//* for(material_instance)
|
||||||
* for(vbo)
|
//* for(vbo)
|
||||||
*/
|
//*/
|
||||||
|
|
||||||
bool SceneTreeToRenderList::End()
|
//bool SceneTreeToRenderList::End()
|
||||||
{
|
//{
|
||||||
}
|
//}
|
||||||
|
|
||||||
bool SceneTreeToRenderList::Expend(SceneNode *sn)
|
//bool SceneTreeToRenderList::Expend(SceneNode *sn)
|
||||||
{
|
//{
|
||||||
if(!sn)return(false);
|
// if(!sn)return(false);
|
||||||
|
|
||||||
if(sn->renderable_instances)
|
// if(sn->renderable_instances)
|
||||||
scene_node_list->Add(sn);
|
// scene_node_list->Add(sn);
|
||||||
|
|
||||||
for(SceneNode *sub:sn->SubNode)
|
// for(SceneNode *sub:sn->SubNode)
|
||||||
Expend(sub);
|
// Expend(sub);
|
||||||
|
|
||||||
return(true);
|
// return(true);
|
||||||
}
|
//}
|
||||||
|
|
||||||
bool SceneTreeToRenderList::Expend(RenderList *rl,Camera *c,SceneNode *sn)
|
//bool SceneTreeToRenderList::Expend(RenderList *rl,Camera *c,SceneNode *sn)
|
||||||
{
|
//{
|
||||||
if(!device)return(false);
|
// if(!device)return(false);
|
||||||
if(!rl||!c||sn)return(false);
|
// if(!rl||!c||sn)return(false);
|
||||||
|
|
||||||
camera=c;
|
// camera=c;
|
||||||
camera->Refresh();
|
// camera->Refresh();
|
||||||
camera_matrix=&(camera->matrix);
|
// camera_info=&(camera->matrix);
|
||||||
|
|
||||||
//Frustum f;
|
// //Frustum f;
|
||||||
|
|
||||||
render_list=rl;
|
// render_list=rl;
|
||||||
|
|
||||||
Begin();
|
// Begin();
|
||||||
Expend(sn);
|
// Expend(sn);
|
||||||
End();
|
// End();
|
||||||
}
|
//}
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
@ -201,13 +201,11 @@ bool VKDebugOut::Init(VkInstance i)
|
|||||||
create_info.pNext =nullptr;
|
create_info.pNext =nullptr;
|
||||||
create_info.flags =0;
|
create_info.flags =0;
|
||||||
|
|
||||||
create_info.messageSeverity =VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT
|
create_info.messageSeverity =VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT
|
||||||
|VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
|
|VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
|
||||||
|VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
|VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
||||||
|
|
||||||
create_info.messageType =VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT
|
create_info.messageType =VK_DEBUG_UTILS_MESSAGE_TYPE_FLAG_BITS_MAX_ENUM_EXT;
|
||||||
|VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT
|
|
||||||
|VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
|
||||||
|
|
||||||
create_info.pfnUserCallback =vulkan_debug_utils_callback;
|
create_info.pfnUserCallback =vulkan_debug_utils_callback;
|
||||||
create_info.pUserData =this;
|
create_info.pUserData =this;
|
||||||
|
@ -38,19 +38,19 @@ void DescriptorSetLayoutCreater::Bind(const uint32_t binding,VkDescriptorType de
|
|||||||
index_by_binding.Add(binding,index);
|
index_by_binding.Add(binding,index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSetLayoutCreater::Bind(const uint32_t *binding,const uint32_t count,VkDescriptorType desc_type,VkShaderStageFlagBits stageFlags)
|
void DescriptorSetLayoutCreater::Bind(const uint32_t *binding,const uint32_t binding_count,VkDescriptorType desc_type,VkShaderStageFlagBits stageFlags)
|
||||||
{
|
{
|
||||||
if(!binding||count<=0)return;
|
if(!binding||binding_count<=0)return;
|
||||||
|
|
||||||
const uint old_count=layout_binding_list.GetCount();
|
const uint old_count=layout_binding_list.GetCount();
|
||||||
|
|
||||||
layout_binding_list.PreMalloc(old_count+count);
|
layout_binding_list.PreMalloc(old_count+binding_count);
|
||||||
|
|
||||||
VkDescriptorSetLayoutBinding *p=layout_binding_list.GetData()+old_count;
|
VkDescriptorSetLayoutBinding *p=layout_binding_list.GetData()+old_count;
|
||||||
|
|
||||||
uint fin_count=0;
|
uint fin_count=0;
|
||||||
|
|
||||||
for(uint i=old_count;i<old_count+count;i++)
|
for(uint i=old_count;i<old_count+binding_count;i++)
|
||||||
{
|
{
|
||||||
if(!index_by_binding.KeyExist(*binding))
|
if(!index_by_binding.KeyExist(*binding))
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include<hgl/graph/VKDevice.h>
|
#include<hgl/graph/VKDevice.h>
|
||||||
#include<hgl/graph/VKRenderableInstance.h>
|
#include<hgl/graph/VKRenderableInstance.h>
|
||||||
#include<hgl/graph/VKInlinePipeline.h>
|
#include<hgl/graph/VKInlinePipeline.h>
|
||||||
|
#include<hgl/graph/VKVertexAttribBuffer.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
VAB *RenderResource::CreateVAB(VkFormat format,uint32_t count,const void *data,SharingMode sharing_mode)
|
VAB *RenderResource::CreateVAB(VkFormat format,uint32_t count,const void *data,SharingMode sharing_mode)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include<hgl/graph/VKRenderableInstance.h>
|
#include<hgl/graph/VKRenderableInstance.h>
|
||||||
#include<hgl/graph/VKMaterialInstance.h>
|
#include<hgl/graph/VKMaterialInstance.h>
|
||||||
#include<hgl/graph/VKMaterial.h>
|
#include<hgl/graph/VKMaterial.h>
|
||||||
|
#include<hgl/graph/VKVertexAttribBuffer.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
RenderableInstance::RenderableInstance(Renderable *r,MaterialInstance *mi,Pipeline *p,const uint32_t count,VkBuffer *bl,VkDeviceSize *bs)
|
RenderableInstance::RenderableInstance(Renderable *r,MaterialInstance *mi,Pipeline *p,const uint32_t count,VkBuffer *bl,VkDeviceSize *bs)
|
||||||
@ -35,7 +36,11 @@ RenderableInstance *CreateRenderableInstance(Renderable *r,MaterialInstance *mi,
|
|||||||
const int input_count=ssl.GetCount();
|
const int input_count=ssl.GetCount();
|
||||||
|
|
||||||
if(r->GetBufferCount()<input_count) //小于材质要求的数量?那自然是不行的
|
if(r->GetBufferCount()<input_count) //小于材质要求的数量?那自然是不行的
|
||||||
|
{
|
||||||
|
LOG_ERROR("[FATAL ERROR] input buffer count of Renderable lesser than Material, Material name: "+mtl->GetName());
|
||||||
|
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
AutoDeleteArray<VkBuffer> buffer_list(input_count);
|
AutoDeleteArray<VkBuffer> buffer_list(input_count);
|
||||||
AutoDeleteArray<VkDeviceSize> buffer_size(input_count);
|
AutoDeleteArray<VkDeviceSize> buffer_size(input_count);
|
||||||
@ -53,10 +58,31 @@ RenderableInstance *CreateRenderableInstance(Renderable *r,MaterialInstance *mi,
|
|||||||
|
|
||||||
vab=r->GetVAB((*ss)->name,buffer_size+i);
|
vab=r->GetVAB((*ss)->name,buffer_size+i);
|
||||||
|
|
||||||
if(!vab)return(nullptr);
|
if(!vab)
|
||||||
|
{
|
||||||
|
LOG_ERROR("[FATAL ERROR] can't find VAB \""+(*ss)->name+"\" in Material: "+mtl->GetName());
|
||||||
|
return(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
if(vab->GetFormat()!=attr->format)return(nullptr);
|
if(vab->GetFormat()!=attr->format)
|
||||||
if(vab->GetStride()!=desc->stride)return(nullptr);
|
{
|
||||||
|
LOG_ERROR( "[FATAL ERROR] VAB \""+(*ss)->name+
|
||||||
|
UTF8String("\" format can't match Renderable, Material(")+mtl->GetName()+
|
||||||
|
UTF8String(") Format(")+GetVulkanFormatName(attr->format)+
|
||||||
|
UTF8String("), VAB Format(")+GetVulkanFormatName(vab->GetFormat())+
|
||||||
|
")");
|
||||||
|
return(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vab->GetStride()!=desc->stride)
|
||||||
|
{
|
||||||
|
LOG_ERROR( "[FATAL ERROR] VAB \""+(*ss)->name+
|
||||||
|
UTF8String("\" stride can't match Renderable, Material(")+mtl->GetName()+
|
||||||
|
UTF8String(") stride(")+UTF8String::valueOf(desc->stride)+
|
||||||
|
UTF8String("), VAB stride(")+UTF8String::valueOf(vab->GetStride())+
|
||||||
|
")");
|
||||||
|
return(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
buffer_list[i]=vab->GetBuffer();
|
buffer_list[i]=vab->GetBuffer();
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include<hgl/graph/font/TextRenderable.h>
|
#include<hgl/graph/font/TextRenderable.h>
|
||||||
#include<hgl/graph/VKDevice.h>
|
#include<hgl/graph/VKDevice.h>
|
||||||
#include<hgl/graph/VKMaterial.h>
|
#include<hgl/graph/VKMaterial.h>
|
||||||
|
#include<hgl/graph/VKVertexAttribBuffer.h>
|
||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user