[Fix] (MG_State/Buffer): pass PingPong test

This commit is contained in:
2025-07-19 22:00:01 +08:00
parent 6f455bc26a
commit 16697b8c2b
5 changed files with 20 additions and 13 deletions
@@ -15,7 +15,8 @@ namespace MobileGL {
AtomicCounter,
DispatchIndirect,
DrawIndirect,
ShaderStorage
ShaderStorage,
BufferTargetCount
};
enum class BufferUsage {
@@ -18,7 +18,7 @@ namespace MobileGL {
// m_size = data.size;
memcpy(m_data.data() + atOffset, data.data, data.size);
// m_dirtyRange = MakeUnique<Range1D>(0, m_size);
m_dirtyRange.UnionUpdate(atOffset, atOffset + data.size - 1);
m_dirtyRange.UnionUpdate(atOffset, atOffset + data.size);
}
void* BufferObject::AcquireMemory(Bool markMapped, Bool read, Bool write) {
@@ -78,13 +78,7 @@ namespace MobileGL {
}
BindingSlot<BufferObject>& BufferState::GetBindingSlot(BufferTarget target) {
for (auto& slot : m_bindingSlots) {
if (slot.GetTarget() == target) {
return slot;
}
}
m_bindingSlots.emplace_back(target);
return m_bindingSlots.back();
return m_bindingSlots[(SizeT)target];
}
}
}
@@ -5,6 +5,12 @@ namespace MobileGL {
namespace GLState {
class BufferState {
public:
BufferState() {
for (SizeT i = 0; i < (SizeT)BufferTarget::BufferTargetCount; ++i) {
m_bindingSlots[i] = BindingSlot<BufferObject>((BufferTarget)i);
}
}
SharedPtr<BufferObject> GetBufferObject(Uint index);
Vector<Uint> GenerateNames(Uint number);
SharedPtr<BufferObject> CreateBufferObject(Uint index);
@@ -13,7 +19,7 @@ namespace MobileGL {
private:
UnorderedMap<Uint, SharedPtr<BufferObject>> m_bufferObjects;
IndexGenerator<Uint> m_indexGenerator;
Vector<BindingSlot<BufferObject>> m_bindingSlots;
Array<BindingSlot<BufferObject>, (SizeT)BufferTarget::BufferTargetCount> m_bindingSlots;
};
}
}