supported material group at MaterialRenderList::Bind
This commit is contained in:
parent
c8cbf020eb
commit
5718b1795f
@ -1,4 +1,4 @@
|
|||||||
#include<hgl/graph/RenderNode2D.h>
|
#include<hgl/graph/RenderNode.h>
|
||||||
#include<hgl/graph/VKRenderable.h>
|
#include<hgl/graph/VKRenderable.h>
|
||||||
#include<hgl/graph/VKDevice.h>
|
#include<hgl/graph/VKDevice.h>
|
||||||
#include<hgl/graph/VKVertexAttribBuffer.h>
|
#include<hgl/graph/VKVertexAttribBuffer.h>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
int Comparator<hgl::graph::RenderNode2D>::compare(const hgl::graph::RenderNode2D &obj_one,const hgl::graph::RenderNode2D &obj_two) const
|
int Comparator<hgl::graph::RenderNode>::compare(const hgl::graph::RenderNode &obj_one,const hgl::graph::RenderNode &obj_two) const
|
||||||
{
|
{
|
||||||
int off;
|
int off;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ namespace hgl
|
|||||||
/*
|
/*
|
||||||
* 2D渲染节点额外提供的VBO数据
|
* 2D渲染节点额外提供的VBO数据
|
||||||
*/
|
*/
|
||||||
struct RenderNode2DExtraBuffer
|
struct RenderNodeExtraBuffer
|
||||||
{
|
{
|
||||||
uint count;
|
uint count;
|
||||||
|
|
||||||
@ -70,12 +70,12 @@ namespace hgl
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RenderNode2DExtraBuffer()
|
RenderNodeExtraBuffer()
|
||||||
{
|
{
|
||||||
hgl_zero(*this);
|
hgl_zero(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
~RenderNode2DExtraBuffer()
|
~RenderNodeExtraBuffer()
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
@ -101,9 +101,9 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteData(RenderNode2D *render_node,const uint count)
|
void WriteData(RenderNode *render_node,const uint count)
|
||||||
{
|
{
|
||||||
RenderNode2D *rn;
|
RenderNode *rn;
|
||||||
glm::vec4 *tp;
|
glm::vec4 *tp;
|
||||||
|
|
||||||
for(uint col=0;col<4;col++)
|
for(uint col=0;col<4;col++)
|
||||||
@ -122,9 +122,9 @@ namespace hgl
|
|||||||
l2w_vbo[col]->Unmap();
|
l2w_vbo[col]->Unmap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};//struct RenderNode2DExtraBuffer
|
};//struct RenderNodeExtraBuffer
|
||||||
|
|
||||||
MaterialRenderList2D::MaterialRenderList2D(GPUDevice *d,Material *m)
|
MaterialRenderList::MaterialRenderList(GPUDevice *d,Material *m)
|
||||||
{
|
{
|
||||||
device=d;
|
device=d;
|
||||||
cmd_buf=nullptr;
|
cmd_buf=nullptr;
|
||||||
@ -138,7 +138,7 @@ namespace hgl
|
|||||||
buffer_offset=new VkDeviceSize[binding_count];
|
buffer_offset=new VkDeviceSize[binding_count];
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialRenderList2D::~MaterialRenderList2D()
|
MaterialRenderList::~MaterialRenderList()
|
||||||
{
|
{
|
||||||
delete[] buffer_offset;
|
delete[] buffer_offset;
|
||||||
delete[] buffer_list;
|
delete[] buffer_list;
|
||||||
@ -146,9 +146,9 @@ namespace hgl
|
|||||||
SAFE_CLEAR(extra_buffer)
|
SAFE_CLEAR(extra_buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialRenderList2D::Add(Renderable *ri,const Matrix4f &mat)
|
void MaterialRenderList::Add(Renderable *ri,const Matrix4f &mat)
|
||||||
{
|
{
|
||||||
RenderNode2D rn;
|
RenderNode rn;
|
||||||
|
|
||||||
rn.local_to_world=mat;
|
rn.local_to_world=mat;
|
||||||
rn.ri=ri;
|
rn.ri=ri;
|
||||||
@ -156,11 +156,11 @@ namespace hgl
|
|||||||
rn_list.Add(rn);
|
rn_list.Add(rn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialRenderList2D::End()
|
void MaterialRenderList::End()
|
||||||
{
|
{
|
||||||
//排序
|
//排序
|
||||||
{
|
{
|
||||||
Comparator<hgl::graph::RenderNode2D> rnc;
|
Comparator<hgl::graph::RenderNode> rnc;
|
||||||
|
|
||||||
Sort(rn_list,&rnc);
|
Sort(rn_list,&rnc);
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ namespace hgl
|
|||||||
if(count<=0)return;
|
if(count<=0)return;
|
||||||
|
|
||||||
if(!extra_buffer)
|
if(!extra_buffer)
|
||||||
extra_buffer=new RenderNode2DExtraBuffer;
|
extra_buffer=new RenderNodeExtraBuffer;
|
||||||
|
|
||||||
if(extra_buffer->count<count)
|
if(extra_buffer->count<count)
|
||||||
extra_buffer->Alloc(device,count);
|
extra_buffer->Alloc(device,count);
|
||||||
@ -182,17 +182,17 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialRenderList2D::RenderItem::Set(Renderable *ri)
|
void MaterialRenderList::RenderItem::Set(Renderable *ri)
|
||||||
{
|
{
|
||||||
pipeline =ri->GetPipeline();
|
pipeline =ri->GetPipeline();
|
||||||
mi =ri->GetMaterialInstance();
|
mi =ri->GetMaterialInstance();
|
||||||
vid =ri->GetVertexInputData();
|
vid =ri->GetVertexInputData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialRenderList2D::Stat()
|
void MaterialRenderList::Stat()
|
||||||
{
|
{
|
||||||
const uint count=rn_list.GetCount();
|
const uint count=rn_list.GetCount();
|
||||||
RenderNode2D *rn=rn_list.GetData();
|
RenderNode *rn=rn_list.GetData();
|
||||||
|
|
||||||
ri_list.ClearData();
|
ri_list.ClearData();
|
||||||
ri_list.PreMalloc(count);
|
ri_list.PreMalloc(count);
|
||||||
@ -237,11 +237,11 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialRenderList2D::Bind(MaterialInstance *mi)
|
void MaterialRenderList::Bind(MaterialInstance *mi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MaterialRenderList2D::Bind(const VertexInputData *vid,const uint first)
|
bool MaterialRenderList::Bind(const VertexInputData *vid,const uint first)
|
||||||
{
|
{
|
||||||
//binding号都是在VertexInput::CreateVIL时连续紧密排列生成的,所以bind时first_binding写0就行了。
|
//binding号都是在VertexInput::CreateVIL时连续紧密排列生成的,所以bind时first_binding写0就行了。
|
||||||
|
|
||||||
@ -260,6 +260,19 @@ namespace hgl
|
|||||||
count=vid->binding_count;
|
count=vid->binding_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(count<binding_count) //材质组
|
||||||
|
{
|
||||||
|
const uint mtl_binding_count=vil->GetCount(VertexInputGroup::Material);
|
||||||
|
|
||||||
|
if(mtl_binding_count>0)
|
||||||
|
{
|
||||||
|
if(mtl_binding_count!=1) //只有MaterialID
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
count+=mtl_binding_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(count<binding_count) //Bone组,暂未支持
|
if(count<binding_count) //Bone组,暂未支持
|
||||||
{
|
{
|
||||||
const uint bone_binding_count=vil->GetCount(VertexInputGroup::Bone);
|
const uint bone_binding_count=vil->GetCount(VertexInputGroup::Bone);
|
||||||
@ -303,7 +316,7 @@ namespace hgl
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialRenderList2D::Render(RenderItem *ri)
|
void MaterialRenderList::Render(RenderItem *ri)
|
||||||
{
|
{
|
||||||
if(last_pipeline!=ri->pipeline)
|
if(last_pipeline!=ri->pipeline)
|
||||||
{
|
{
|
||||||
@ -344,7 +357,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialRenderList2D::Render(RenderCmdBuffer *rcb)
|
void MaterialRenderList::Render(RenderCmdBuffer *rcb)
|
||||||
{
|
{
|
||||||
if(!rcb)return;
|
if(!rcb)return;
|
||||||
const uint count=rn_list.GetCount();
|
const uint count=rn_list.GetCount();
|
Loading…
x
Reference in New Issue
Block a user