(WIP) renamed a few values, new SceneTreeToRenderList
This commit is contained in:
parent
45284e1a32
commit
015a4d0b8e
@ -27,7 +27,7 @@ namespace hgl
|
||||
protected:
|
||||
|
||||
Camera * camera;
|
||||
CameraInfo * camera_matrix;
|
||||
CameraInfo * camera_info;
|
||||
Frustum frustum;
|
||||
|
||||
protected:
|
||||
@ -56,7 +56,7 @@ namespace hgl
|
||||
{
|
||||
device=d;
|
||||
camera=nullptr;
|
||||
camera_matrix=nullptr;
|
||||
camera_info=nullptr;
|
||||
|
||||
scene_node_list=nullptr;
|
||||
render_list=nullptr;
|
||||
|
@ -31,10 +31,10 @@ namespace hgl
|
||||
|
||||
{
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
@ -62,7 +62,7 @@ namespace hgl
|
||||
|
||||
T *Map(const uint32 start,const uint32 count)
|
||||
{
|
||||
return coll->Map(start,count);
|
||||
return (T *)(coll->Map(start,count));
|
||||
}
|
||||
};//class GPUArrayBuffer
|
||||
}//namespace graph
|
||||
|
@ -9,7 +9,7 @@ class GPUBuffer;
|
||||
class DescriptorSets
|
||||
{
|
||||
VkDevice device;
|
||||
int count;
|
||||
int layout_binding_count;
|
||||
VkDescriptorSet desc_set;
|
||||
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)
|
||||
{
|
||||
device=dev;
|
||||
count=c;
|
||||
layout_binding_count=c;
|
||||
desc_set=ds;
|
||||
pipeline_layout=pl;
|
||||
}
|
||||
@ -35,7 +35,7 @@ public:
|
||||
|
||||
~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 VkPipelineLayout GetPipelineLayout ()const{return pipeline_layout;}
|
||||
|
||||
|
@ -14,7 +14,7 @@ namespace hgl
|
||||
GPUDevice * device;
|
||||
Material * mtl;
|
||||
|
||||
uint max_count; ///<缓冲区最大容量
|
||||
uint max_count; ///<缓冲区最大容量
|
||||
|
||||
VAB * vab_position;
|
||||
VAB * vab_tex_coord;
|
||||
|
@ -15,7 +15,6 @@ namespace hgl
|
||||
{
|
||||
constexpr size_t MVPMatrixBytes=sizeof(MVPMatrix);
|
||||
|
||||
|
||||
//bool FrustumClipFilter(const SceneNode *node,void *fc)
|
||||
//{
|
||||
// if(!node||!fc)return(false);
|
||||
@ -57,7 +56,7 @@ namespace hgl
|
||||
scene_node_list.Add(node);
|
||||
}
|
||||
|
||||
void RenderList::End(CameraInfo *camera_matrix)
|
||||
void RenderList::End(CameraInfo *camera_info)
|
||||
{
|
||||
//清0计数器
|
||||
uint32_t mvp_count=0; //local to world矩阵总数量
|
||||
@ -80,7 +79,7 @@ namespace hgl
|
||||
|
||||
if(!l2w.IsIdentity())
|
||||
{
|
||||
mp->Set(l2w,camera_matrix->vp);
|
||||
mp->Set(l2w,camera_info->vp);
|
||||
++mp;
|
||||
|
||||
*op=mvp_count*MVPMatrixBytes;
|
||||
|
@ -17,69 +17,68 @@ namespace hgl
|
||||
return( length_squared(obj_one->GetCenter(),camera->pos)-
|
||||
length_squared(obj_two->GetCenter(),camera->pos));
|
||||
}
|
||||
}
|
||||
|
||||
bool SceneTreeToRenderList::InFrustum(const SceneNode *,void *)
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
//bool SceneTreeToRenderList::InFrustum(const SceneNode *,void *)
|
||||
//{
|
||||
// return(true);
|
||||
//}
|
||||
|
||||
bool SceneTreeToRenderList::Begin()
|
||||
{
|
||||
if(!scene_node_list)
|
||||
scene_node_list=new SceneNodeList;
|
||||
//bool SceneTreeToRenderList::Begin()
|
||||
//{
|
||||
// if(!scene_node_list)
|
||||
// scene_node_list=new SceneNodeList;
|
||||
|
||||
scene_node_list->ClearData();
|
||||
// scene_node_list->ClearData();
|
||||
|
||||
pipeline_sets.ClearData();
|
||||
material_sets.ClearData();
|
||||
mat_instance_sets.ClearData();
|
||||
// pipeline_sets.ClearData();
|
||||
// material_sets.ClearData();
|
||||
// mat_instance_sets.ClearData();
|
||||
|
||||
return(true);
|
||||
}
|
||||
// return(true);
|
||||
//}
|
||||
|
||||
/**
|
||||
* 理论上讲,我们需要按以下顺序排序
|
||||
*
|
||||
* for(material)
|
||||
* for(pipeline)
|
||||
* for(material_instance)
|
||||
* for(vbo)
|
||||
*/
|
||||
///**
|
||||
//* 理论上讲,我们需要按以下顺序排序
|
||||
//*
|
||||
//* for(material)
|
||||
//* for(pipeline)
|
||||
//* for(material_instance)
|
||||
//* for(vbo)
|
||||
//*/
|
||||
|
||||
bool SceneTreeToRenderList::End()
|
||||
{
|
||||
}
|
||||
//bool SceneTreeToRenderList::End()
|
||||
//{
|
||||
//}
|
||||
|
||||
bool SceneTreeToRenderList::Expend(SceneNode *sn)
|
||||
{
|
||||
if(!sn)return(false);
|
||||
//bool SceneTreeToRenderList::Expend(SceneNode *sn)
|
||||
//{
|
||||
// if(!sn)return(false);
|
||||
|
||||
if(sn->renderable_instances)
|
||||
scene_node_list->Add(sn);
|
||||
// if(sn->renderable_instances)
|
||||
// scene_node_list->Add(sn);
|
||||
|
||||
for(SceneNode *sub:sn->SubNode)
|
||||
Expend(sub);
|
||||
// for(SceneNode *sub:sn->SubNode)
|
||||
// Expend(sub);
|
||||
|
||||
return(true);
|
||||
}
|
||||
// return(true);
|
||||
//}
|
||||
|
||||
bool SceneTreeToRenderList::Expend(RenderList *rl,Camera *c,SceneNode *sn)
|
||||
{
|
||||
if(!device)return(false);
|
||||
if(!rl||!c||sn)return(false);
|
||||
//bool SceneTreeToRenderList::Expend(RenderList *rl,Camera *c,SceneNode *sn)
|
||||
//{
|
||||
// if(!device)return(false);
|
||||
// if(!rl||!c||sn)return(false);
|
||||
|
||||
camera=c;
|
||||
camera->Refresh();
|
||||
camera_matrix=&(camera->matrix);
|
||||
// camera=c;
|
||||
// camera->Refresh();
|
||||
// camera_info=&(camera->matrix);
|
||||
|
||||
//Frustum f;
|
||||
// //Frustum f;
|
||||
|
||||
render_list=rl;
|
||||
// render_list=rl;
|
||||
|
||||
Begin();
|
||||
Expend(sn);
|
||||
End();
|
||||
}
|
||||
// Begin();
|
||||
// Expend(sn);
|
||||
// End();
|
||||
//}
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@ -201,13 +201,11 @@ bool VKDebugOut::Init(VkInstance i)
|
||||
create_info.pNext =nullptr;
|
||||
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_ERROR_BIT_EXT;
|
||||
|
||||
create_info.messageType =VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT
|
||||
|VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT
|
||||
|VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
||||
create_info.messageType =VK_DEBUG_UTILS_MESSAGE_TYPE_FLAG_BITS_MAX_ENUM_EXT;
|
||||
|
||||
create_info.pfnUserCallback =vulkan_debug_utils_callback;
|
||||
create_info.pUserData =this;
|
||||
|
@ -38,19 +38,19 @@ void DescriptorSetLayoutCreater::Bind(const uint32_t binding,VkDescriptorType de
|
||||
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();
|
||||
|
||||
layout_binding_list.PreMalloc(old_count+count);
|
||||
layout_binding_list.PreMalloc(old_count+binding_count);
|
||||
|
||||
VkDescriptorSetLayoutBinding *p=layout_binding_list.GetData()+old_count;
|
||||
|
||||
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))
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKRenderableInstance.h>
|
||||
#include<hgl/graph/VKInlinePipeline.h>
|
||||
#include<hgl/graph/VKVertexAttribBuffer.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
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/VKMaterialInstance.h>
|
||||
#include<hgl/graph/VKMaterial.h>
|
||||
#include<hgl/graph/VKVertexAttribBuffer.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
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();
|
||||
|
||||
if(r->GetBufferCount()<input_count) //小于材质要求的数量?那自然是不行的
|
||||
{
|
||||
LOG_ERROR("[FATAL ERROR] input buffer count of Renderable lesser than Material, Material name: "+mtl->GetName());
|
||||
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
AutoDeleteArray<VkBuffer> buffer_list(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);
|
||||
|
||||
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->GetStride()!=desc->stride)return(nullptr);
|
||||
if(vab->GetFormat()!=attr->format)
|
||||
{
|
||||
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();
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include<hgl/graph/font/TextRenderable.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKMaterial.h>
|
||||
#include<hgl/graph/VKVertexAttribBuffer.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user