1.used uvec2/ushort2 in AssignVBO
2.completed first step then merge MI buffer
This commit is contained in:
@@ -3,21 +3,22 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKMaterialInstance.h>
|
||||
#include<hgl/graph/RenderNode.h>
|
||||
#include<hgl/graph/VKRenderable.h>
|
||||
#include<hgl/graph/VKRenderAssign.h>
|
||||
#include<hgl/graph/mtl/UBOCommon.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
RenderAssignBuffer::RenderAssignBuffer(GPUDevice *dev,const uint mi_total_bytes)
|
||||
RenderAssignBuffer::RenderAssignBuffer(GPUDevice *dev,const uint mi_bytes)
|
||||
{
|
||||
hgl_zero(*this);
|
||||
|
||||
device=dev;
|
||||
|
||||
if(mi_total_bytes>0)
|
||||
ubo_mi=device->CreateUBO(mi_total_bytes);
|
||||
else
|
||||
ubo_mi=nullptr;
|
||||
mi_data_bytes=mi_bytes;
|
||||
|
||||
ubo_mi=nullptr;
|
||||
mi_count=0;
|
||||
}
|
||||
|
||||
VkBuffer RenderAssignBuffer::GetAssignVBO()const
|
||||
@@ -44,6 +45,7 @@ void RenderAssignBuffer::Clear()
|
||||
SAFE_CLEAR(vbo_assigns);
|
||||
|
||||
node_count=0;
|
||||
mi_count=0;
|
||||
}
|
||||
|
||||
void RenderAssignBuffer::Alloc(const uint nc,const uint mc)
|
||||
@@ -51,21 +53,21 @@ void RenderAssignBuffer::Alloc(const uint nc,const uint mc)
|
||||
Clear();
|
||||
|
||||
{
|
||||
node_count=power_to_2(nc);
|
||||
node_count=nc;
|
||||
|
||||
ubo_l2w=device->CreateUBO(node_count*sizeof(Matrix4f));
|
||||
}
|
||||
|
||||
if(mi_data_bytes>0&&mc>0)
|
||||
{
|
||||
mi_count=mc;
|
||||
|
||||
ubo_mi=device->CreateUBO(mi_data_bytes*mi_count);
|
||||
}
|
||||
|
||||
vbo_assigns=device->CreateVBO(ASSIGN_VBO_FMT,node_count);
|
||||
}
|
||||
|
||||
bool RenderAssignBuffer::WriteMIData(void *mi_data,const uint bytes)
|
||||
{
|
||||
if(!mi_data||!bytes||!ubo_mi)return(false);
|
||||
|
||||
return ubo_mi->Write(mi_data,bytes);
|
||||
}
|
||||
|
||||
void RenderAssignBuffer::WriteNode(RenderNode *render_node,const uint count,const MaterialInstanceSets &mi_set)
|
||||
{
|
||||
RenderNode *rn;
|
||||
@@ -78,7 +80,7 @@ void RenderAssignBuffer::WriteNode(RenderNode *render_node,const uint count,cons
|
||||
|
||||
for(MaterialInstance *mi:mi_set)
|
||||
{
|
||||
// memcpy(mip,mi->GetData(),mi_data_bytes);
|
||||
memcpy(mip,mi->GetMIData(),mi_data_bytes);
|
||||
mip+=mi_data_bytes;
|
||||
}
|
||||
|
||||
@@ -100,8 +102,8 @@ void RenderAssignBuffer::WriteNode(RenderNode *render_node,const uint count,cons
|
||||
*idp=i;
|
||||
++idp;
|
||||
|
||||
//*idp=mi_set.Find(rn->ri->GetMaterialInstance());
|
||||
//++idp;
|
||||
*idp=mi_set.Find(rn->ri->GetMaterialInstance());
|
||||
++idp;
|
||||
|
||||
++rn;
|
||||
}
|
||||
|
Reference in New Issue
Block a user