[Refactor] (MG_Impl/GLImpl): replace Flywheel dispatch sync hack with MOBILEGL_COHERENT_AS_FLUSH

This commit is contained in:
2026-07-15 21:51:20 -04:00
parent f80f6f4a62
commit 3e4ce5caa7
28 changed files with 295 additions and 62 deletions
@@ -7,7 +7,6 @@
// End of Source File Header
#include "BufferObject.h"
#include <algorithm>
namespace MobileGL::MG_State::GLState {
namespace {
@@ -167,23 +166,6 @@ namespace MobileGL::MG_State::GLState {
NotifySubData(m_mappedRange.start, m_mappedRange.end - m_mappedRange.start);
}
void BufferObject::SyncMappedRangeForGpuRead(Range1D range) {
if (!m_isMapped) return;
// GPU-resident maps already alias GPU-visible memory; nothing to push.
if (m_resource.IsGpuResident()) return;
if (!(m_mappingAccess & BufferMappingAccessBit::Persistent)) return;
if (!(m_mappingAccess & BufferMappingAccessBit::Write)) return;
// Non-FLUSH_EXPLICIT persistent maps are already covered wholesale by
// SyncPersistentMappedRange.
if (!(m_mappingAccess & BufferMappingAccessBit::FlushExplicit)) return;
const SizeT start = std::max(range.start, m_mappedRange.start);
const SizeT end = std::min({range.end, m_mappedRange.end, m_size});
if (start >= end) return;
NotifySubData(start, end - start);
}
void BufferObject::WritebackFromBackend(DataPtr data, SizeT atOffset) {
MOBILEGL_ASSERT(atOffset + data.size <= m_size,
"WritebackFromBackend out of bounds: atOffset (%zu) + data.size (%zu) > m_size (%zu)", atOffset,
@@ -139,12 +139,6 @@ namespace MobileGL {
// Pushes the persistently-mapped write range to the backend; called by
// backends at draw time (persistent maps mutate the shadow without API calls).
void SyncPersistentMappedRange();
// App-compat for FLUSH_EXPLICIT persistent maps: engines like Flywheel
// write copy descriptors into the mapping and bind that range as an SSBO
// without ever flushing it. Undefined per spec, but works on drivers whose
// persistent maps alias GPU-visible memory. Ours alias the CPU shadow, so
// callers push the GPU-read range down right before it is consumed.
void SyncMappedRangeForGpuRead(Range1D range);
// Shadow-only write used when the backend copies GPU results (e.g. ReadPixels
// into a pixel-pack buffer) back into the frontend mirror. Does not issue a
// backend op: the backend storage already holds these bytes.