1.1 KiB
1.1 KiB
OpenGLDescriptorPool::AllocateSet
RHIDescriptorSet* AllocateSet(const DescriptorSetLayoutDesc& layout) override;
作用
创建一个新的 OpenGLDescriptorSet。
当前实现行为
- 如果
m_allocatedSets.size() >= m_maxSets,返回nullptr - 创建新的
OpenGLDescriptorSet - 调用
newSet->Initialize(m_textureUnitAllocator, layout.bindingCount, layout) - 失败时删除新对象并返回
nullptr - 成功时把它加入
m_allocatedSets
与 allocator 的关系
如果 layout 中包含 SRV、Sampler 或 UAV,OpenGLDescriptorSet::Initialize(...) 会尝试从 OpenGLTextureUnitAllocator 申请 texture unit。也就是说,pool 只是创建入口,真正的 unit 分配发生在 set 初始化内部。
当前限制
- 没有更细粒度容量控制
- layout 合法性基本依赖
OpenGLDescriptorSet - 如果外部绕过 FreeSet 直接 delete set,pool 内部跟踪会失真