mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-13 06:38:31 +09:00
[Perf] (MG_State, MG_Backend/DirectGLES): skip never-touched buffer bind points via high-water mark; SyncNeccessaryBuffers 15.7% -> 4.2%
This commit is contained in:
@@ -13,6 +13,9 @@ namespace MobileGL::MG_State::GLState {
|
||||
for (SizeT i = 0; i < m_bindingSlots.size(); ++i) {
|
||||
m_bindingSlots[i] = BindingSlot<BufferObject>(GlobalBufferTargets[i]);
|
||||
}
|
||||
for (SizeT i = 0; i < m_touchedBindPointCount.size(); ++i) {
|
||||
m_touchedBindPointCount[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const SharedPtr<BufferObject>& BufferState::GetBufferObject(Uint index) {
|
||||
|
||||
@@ -36,6 +36,20 @@ namespace MobileGL::MG_State::GLState {
|
||||
auto index = std::distance(BufferBindPointTargets.begin(), it);
|
||||
return m_bufferBindPointTargets[index].size();
|
||||
}
|
||||
// High-water mark of app-touched binding points per target (highest index + 1, 0 if none).
|
||||
// Lets the backend skip syncing the never-touched tail of the fixed 36-point array each draw.
|
||||
void TouchBindPoint(const BufferTarget target, Uint index) {
|
||||
auto it = std::find(BufferBindPointTargets.begin(), BufferBindPointTargets.end(), target);
|
||||
if (it == BufferBindPointTargets.end()) return;
|
||||
auto slot = std::distance(BufferBindPointTargets.begin(), it);
|
||||
if (static_cast<SizeT>(index) + 1 > m_touchedBindPointCount[slot])
|
||||
m_touchedBindPointCount[slot] = static_cast<SizeT>(index) + 1;
|
||||
}
|
||||
SizeT GetTouchedBindPointCount(const BufferTarget target) const {
|
||||
auto it = std::find(BufferBindPointTargets.begin(), BufferBindPointTargets.end(), target);
|
||||
if (it == BufferBindPointTargets.end()) return 0;
|
||||
return m_touchedBindPointCount[std::distance(BufferBindPointTargets.begin(), it)];
|
||||
}
|
||||
void MarkBufferObjectForDeletion(Uint index);
|
||||
Bool ValidateName(Uint index) const;
|
||||
Bool ValidateBufferObject(Uint index) const;
|
||||
@@ -48,5 +62,6 @@ namespace MobileGL::MG_State::GLState {
|
||||
// For glBindBufferBase / glBindBufferRange
|
||||
Array<Array<BindingSlotRange1D<BufferObject>, BufferBindingPointCount>, BufferBindPointTargets.size()>
|
||||
m_bufferBindPointTargets;
|
||||
Array<SizeT, BufferBindPointTargets.size()> m_touchedBindPointCount;
|
||||
};
|
||||
} // namespace MobileGL::MG_State::GLState
|
||||
|
||||
@@ -67,6 +67,12 @@ namespace MobileGL {
|
||||
constexpr SizeT GetBufferBindingPointCount(BufferTarget target) const {
|
||||
return m_bufferState.GetBindingPointCount(target);
|
||||
}
|
||||
void TouchBufferBindingPoint(BufferTarget target, Uint index) {
|
||||
m_bufferState.TouchBindPoint(target, index);
|
||||
}
|
||||
SizeT GetTouchedBufferBindingPointCount(BufferTarget target) const {
|
||||
return m_bufferState.GetTouchedBindPointCount(target);
|
||||
}
|
||||
const SharedPtr<BufferObject>& CreateBufferObject(Uint index);
|
||||
void MarkBufferObjectForDeletion(Uint index);
|
||||
Bool ValidateBufferName(Uint index) const;
|
||||
|
||||
Reference in New Issue
Block a user