update RenderAssignBuffer,but can't run.

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-09-19 22:04:34 +08:00
parent 4208e47534
commit 00d2677066
4 changed files with 29 additions and 20 deletions

View File

@ -76,8 +76,9 @@ public:
public:
const uint32_t GetMIDataBytes ()const{return mi_data_bytes;}
const uint32_t GetMIMaxCount ()const{return mi_max_count;}
const bool HasMI ()const{return !mi_data_bytes;}
const uint32_t GetMIDataBytes ()const{return mi_data_bytes;}
const uint32_t GetMIMaxCount ()const{return mi_max_count;}
void ReleaseMI(int); ///<释放材质实例
void *GetMIData(int); ///<取得指定ID号的材质实例数据访问指针

View File

@ -91,7 +91,9 @@ void MaterialRenderList::End()
if(node_count<=0)return;
StatMI();
if(mtl->HasMI())
StatMI();
Stat();
//写入LocalToWorld数据
@ -116,6 +118,8 @@ void MaterialRenderList::StatMI()
{
//超出最大数量了怎么办???
}
}
void MaterialRenderList::Stat()

View File

@ -8,6 +8,18 @@
VK_NAMESPACE_BEGIN
RenderAssignBuffer::RenderAssignBuffer(GPUDevice *dev,const uint mi_total_bytes)
{
hgl_zero(*this);
device=dev;
if(mi_total_bytes>0)
ubo_mi=device->CreateUBO(mi_total_bytes);
else
ubo_mi=nullptr;
}
VkBuffer RenderAssignBuffer::GetAssignVBO()const
{
return vbo_assigns->GetBuffer();
@ -44,15 +56,16 @@ void RenderAssignBuffer::Alloc(const uint nc,const uint mc)
ubo_l2w=device->CreateUBO(node_count*sizeof(Matrix4f));
}
{
mi_count=power_to_2(mc);
ubo_mi=device->CreateUBO(mi_count*mi_data_bytes);
}
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;

View File

@ -37,8 +37,6 @@ private:
uint node_count; ///<渲染节点数量
DeviceBuffer *ubo_l2w; ///<Local2World数据
uint mi_count; ///<材质实例数量
uint mi_data_bytes; ///<单个材质实例数据字节数
DeviceBuffer *ubo_mi; ///<材质实例数据
//Assign VBO
@ -58,17 +56,10 @@ public:
public:
RenderAssignBuffer(GPUDevice *dev,const uint mi_bytes)
{
hgl_zero(*this);
device=dev;
mi_data_bytes=mi_bytes;
}
RenderAssignBuffer(GPUDevice *dev,const uint mi_total_bytes);
~RenderAssignBuffer(){Clear();}
bool WriteMIData(void *,const uint);
void WriteNode(RenderNode *render_node,const uint count,const MaterialInstanceSets &mi_set);
};//struct RenderAssignBuffer