added BindGlobalDescriptor at RenderResource
This commit is contained in:
parent
76f5dcb884
commit
f2c6c24ddf
@ -47,7 +47,8 @@ class RenderResource
|
|||||||
IDResManage<TextureID, Texture> rm_textures; ///<纹理合集
|
IDResManage<TextureID, Texture> rm_textures; ///<纹理合集
|
||||||
IDResManage<RenderableID, Renderable> rm_renderables; ///<渲染实例集合集
|
IDResManage<RenderableID, Renderable> rm_renderables; ///<渲染实例集合集
|
||||||
|
|
||||||
Map<AnsiString,DeviceBuffer *> global_buffer_map; ///<全局UBO
|
Map<AnsiString,DeviceBuffer *> global_buffer_map; ///<全局Buffer(UBO/SSBO)
|
||||||
|
Map<AnsiString,Texture *> global_texture_map; ///<全局Texture
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ public: //Add
|
|||||||
TextureID Add(Texture * t ){return rm_textures.Add(t);}
|
TextureID Add(Texture * t ){return rm_textures.Add(t);}
|
||||||
RenderableID Add(Renderable * r ){return rm_renderables.Add(r);}
|
RenderableID Add(Renderable * r ){return rm_renderables.Add(r);}
|
||||||
|
|
||||||
public: //全局属性
|
public: //全局属性(对应shader中的PerGlobal set合集)
|
||||||
|
|
||||||
void SetGlobal(const AnsiString &name,DeviceBuffer *buf);
|
void SetGlobal(const AnsiString &name,DeviceBuffer *buf);
|
||||||
|
|
||||||
@ -73,6 +74,8 @@ public: //全局属性
|
|||||||
|
|
||||||
void Free(DeviceBuffer *);
|
void Free(DeviceBuffer *);
|
||||||
|
|
||||||
|
void BindGlobalDescriptor(MaterialInstance *);
|
||||||
|
|
||||||
public: // VBO/VAO
|
public: // VBO/VAO
|
||||||
|
|
||||||
VBO *CreateVBO(VkFormat format,uint32_t count,const void *data,SharingMode sm=SharingMode::Exclusive);
|
VBO *CreateVBO(VkFormat format,uint32_t count,const void *data,SharingMode sm=SharingMode::Exclusive);
|
||||||
|
@ -32,6 +32,34 @@ void RenderResource::Free(DeviceBuffer *buf)
|
|||||||
global_buffer_map.DeleteByValue(buf);
|
global_buffer_map.DeleteByValue(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderResource::BindGlobalDescriptor(MaterialInstance *mi)
|
||||||
|
{
|
||||||
|
if(!mi)return;
|
||||||
|
|
||||||
|
const uint count=global_buffer_map.GetCount();
|
||||||
|
|
||||||
|
if(count<=0)return;
|
||||||
|
|
||||||
|
auto **gb_list=global_buffer_map.GetDataList();
|
||||||
|
|
||||||
|
auto *mp=mi->GetMP(DescriptorSetType::Global);
|
||||||
|
|
||||||
|
if(!mp)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(mp->GetDescriptorCount()<=0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(uint i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
mp->BindUBO((*gb_list)->left,(*gb_list)->right);
|
||||||
|
|
||||||
|
++gb_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
mp->Update();
|
||||||
|
}
|
||||||
|
|
||||||
VBO *RenderResource::CreateVBO(VkFormat format,uint32_t count,const void *data,SharingMode sharing_mode)
|
VBO *RenderResource::CreateVBO(VkFormat format,uint32_t count,const void *data,SharingMode sharing_mode)
|
||||||
{
|
{
|
||||||
VBO *vb=device->CreateVBO(format,count,data,sharing_mode);
|
VBO *vb=device->CreateVBO(format,count,data,sharing_mode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user