[Feat] (MG_State/Program, DirectGLES): plumb ubo to backend

This commit is contained in:
2025-11-05 15:37:10 +08:00
parent c39c03d866
commit ef1924d7f9
7 changed files with 82 additions and 14 deletions
@@ -25,6 +25,11 @@ namespace MobileGL {
BindingSlot<BufferObject>& GetBindingSlot(BufferTarget target);
// For glBindBufferBase / glBindBufferRange
BindingSlotRange1D<BufferObject>& GetBindingPoint(BufferTarget target, Uint index);
constexpr SizeT GetBindingPointCount(const BufferTarget target) const {
auto it = std::find(BufferBindPointTargets.begin(), BufferBindPointTargets.end(), target);
auto index = std::distance(BufferBindPointTargets.begin(), it);
return m_bufferBindPointTargets[index].size();
}
void MarkBufferObjectForDeletion(Uint index);
Bool ValidateName(Uint index) const;
Bool ValidateBufferObject(Uint index) const;
@@ -35,7 +40,7 @@ namespace MobileGL {
Array<BindingSlot<BufferObject>, GlobalBufferTargets.size()> m_bindingSlots;
// TODO: query the count somewhere globally?
// For glBindBufferBase / glBindBufferRange
Array<Array<BindingSlotRange1D<BufferObject>, 14>, BufferBindPointTargets.size()> m_bufferBindPointTargets;
Array<Array<BindingSlotRange1D<BufferObject>, 16>, BufferBindPointTargets.size()> m_bufferBindPointTargets;
};
} // namespace GLState
} // namespace MG_State
+3
View File
@@ -33,6 +33,9 @@ namespace MobileGL {
SharedPtr<BufferObject> GetBufferObject(Uint index);
BindingSlot<BufferObject>& GetBufferBindingSlot(BufferTarget target);
BindingSlotRange1D<BufferObject>& GetBufferBindingPoint(BufferTarget target, Uint index);
constexpr SizeT GetBufferBindingPointCount(BufferTarget target) const {
return m_bufferState.GetBindingPointCount(target);
}
SharedPtr<BufferObject> CreateBufferObject(Uint index);
void MarkBufferObjectForDeletion(Uint index);
Bool ValidateBufferName(Uint index) const;
@@ -208,6 +208,9 @@ namespace MobileGL {
auto& ubo = m_program->getUniformBlock(i);
m_uniformBlockNameMaxLength = std::max(m_uniformBlockNameMaxLength, (Int)ubo.name.length());
m_uniformBlockIndexByName[ubo.name] = i;
// if there's binding defined in shader as layout(binding = ...),
// retrieve it here
m_uniformBlockBinding[i] = ubo.getBinding();
}
}
@@ -103,6 +103,10 @@ namespace MobileGL {
m_uniformBlockBinding[index] = binding;
}
Uint GetUniformBlockBinding(Uint index) const {
return m_uniformBlockBinding[index];
}
Vector<Vector<unsigned>>& GetGeneratedSpirv() { return m_generatedSpirv; }
Uint GetExternalIndex() const { return m_externalIndex; }