Compare commits

...
Author SHA1 Message Date
swung0x48 bbd555fda9 Tests: TrackerShareGroup takes the context slot with Take() now that it is a pointer slot. 2026-10-10 05:25:51 -04:00
swung0x48 eb08b0b112 Docs (P15): pwab device A/B of present-wait levers and pmflush. 2026-10-10 04:14:57 -04:00
swung0x48 b52b9ef61a Docs: present-wait levers A and B handoff and device plan. 2026-10-10 04:14:56 -04:00
swung0x48 046e4a512c Magma: MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES asks for swapchain images beyond the surface minimum. 2026-10-10 04:14:42 -04:00
swung0x48 d6c702e628 Tests: WindowPassGateScenario covers frames split around the window pass. 2026-10-10 04:14:41 -04:00
swung0x48 1c206f306c Espryt: flush once per frame ahead of the window buffer's first use. 2026-10-10 04:14:41 -04:00
swung0x48 d439fdde1b Magma: submit a frame's off-screen work ahead of the swapchain acquire wait. 2026-10-10 04:14:40 -04:00
swung0x48 ff184f24d3 Espryt: drain a partial write to a small store as a whole-store orphan-map instead of an upload-ring copy job. 2026-10-10 04:14:25 -04:00
swung0x48 5ce2a0af6a Docs: hot-path TLS cut device A/B and handoff notes. 2026-10-10 04:14:24 -04:00
swung0x48 78c12e6ded TLS: the context owner drops its reference before it clears the slot at thread exit. 2026-10-10 04:14:14 -04:00
swung0x48 fb0502886b TLS: Espryt's bound context serial and per-context lookup cache share one thread_local block. 2026-10-10 04:14:13 -04:00
swung0x48 892f4609be TLS: the Magma session read and built-slot lookup inline into SessionLocal accesses. 2026-10-10 04:14:12 -04:00
swung0x48 fe868f6f78 TLS: the applier lookup cache is one thread_local block. 2026-10-10 04:14:10 -04:00
swung0x48 fd60f9a720 TLS: pGLContext and gPipeInputs become constant-initialized pointer slots. 2026-10-10 04:14:09 -04:00
swung0x48 c9de510a1a Docs (P15): queue the pwait latency trace and write-up. 2026-10-10 04:14:08 -04:00
swung0x48 de1d112725 Pipe: share-group clocks fire dirty bits 11-14 when a sibling context changes a shared texture, renderbuffer or sampler. 2026-10-10 04:14:07 -04:00
swung0x48 d0d808fc80 Docs (P15): present-wait timeline; the display release gates the frame, not the GPU. 2026-10-10 04:14:02 -04:00
62 changed files with 2496 additions and 474 deletions
+7
View File
@@ -175,6 +175,13 @@ namespace MobileGL::MG_Config {
// ahead of the server, is derived from it: max(1, N - 2), so the default 3 keeps the
// shipped credit of 1 and N = 4 is credit 2 (one more frame of latency).
Uint32 FramesInFlight = 3;
// MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES: swapchain images Magma asks for beyond the
// surface's minimum (the frames-in-flight count still raises the request when it is
// larger), clamped to the surface's maximum. With more images, the one the display has
// just released is reused later, by when its release has usually signaled, so fewer
// frames start their window pass behind it. Each image costs a full-size colour buffer
// plus the default framebuffer's depth/stencil buffer of the same size.
Uint32 MagmaExtraSwapchainImages = 0;
// MOBILEGL_MAGMA_MAX_DRAWS_PER_COMMAND_BUFFER: GL draws and dispatches Magma records into
// one command buffer before it submits it and continues on a fresh one. 0 = unbounded.
// Drivers back a command buffer with GPU memory that is only returned when the buffer is
+1
View File
@@ -386,6 +386,7 @@ namespace MobileGL::MG_ConfigLoader {
if (acceptedEnvVariablesMap->count("MOBILEGL_MAGMA_FRAMESINFLIGHT") != 0)
MGLOG_W("Config: MOBILEGL_MAGMA_FRAMESINFLIGHT is deprecated; use MOBILEGL_FRAMES_IN_FLIGHT");
}
features.MagmaExtraSwapchainImages = QueryEnvUint32("MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES", 0, 0, 16);
features.MagmaMaxDrawsPerCommandBuffer =
QueryEnvUint32("MOBILEGL_MAGMA_MAX_DRAWS_PER_COMMAND_BUFFER", 16384, 0, 1u << 24);
features.MagmaDescriptorTrimFrames = QueryEnvUint32("MOBILEGL_MAGMA_DESCRIPTOR_TRIM_FRAMES", 120, 0, 1u << 20);
+85 -48
View File
@@ -115,7 +115,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
// addresses again - the cached pointers cannot go stale. Invalidation is
// exactly the pointer compare below.
using FbBindingSlot =
std::remove_reference_t<decltype(MG_Pipe::gPipeInputs.GetFramebufferBindingSlot(FramebufferTarget::Draw))>;
std::remove_reference_t<decltype(MG_Pipe::gPipeInputs->GetFramebufferBindingSlot(FramebufferTarget::Draw))>;
// P2 step e4. On the {slot, gen} arm this is an ORDINARY read of pushed state and the cache
// above is not consulted, which closes the P1 accessor bypass: the cached raw pointer ran
// the checked accessor once per context change and then handed out the pointee forever, so
@@ -132,10 +132,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
// frontend getter still linear-scans, so the cache is exactly the code it was.
static inline FbBindingSlot& GetFramebufferBindingSlotChecked(FramebufferTarget target) {
if (EsprytSlotTablesEnabled()) {
return MG_Pipe::gPipeInputs.GetFramebufferBindingSlot(target);
return MG_Pipe::gPipeInputs->GetFramebufferBindingSlot(target);
}
// No legacy arm compiled: EsprytSlotTablesEnabled() is unconditionally true above.
return MG_Pipe::gPipeInputs.GetFramebufferBindingSlot(target);
return MG_Pipe::gPipeInputs->GetFramebufferBindingSlot(target);
}
// A4, TAKEN AT THE VERIFICATION ROUND, AND THE FOUR TEMPORARY LATCHES ARE GONE WITH IT.
@@ -181,7 +181,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
[[noreturn]] static void RefuseFramebufferBindingSlotRead() {
MG_Pipe::MGPipeInputPoisonFatalForVerb(MG_Pipe::MGPipeInputField::GetFramebufferBindingSlot,
MG_Pipe::gPipeInputs.CurrentVerb());
MG_Pipe::gPipeInputs->CurrentVerb());
}
static Bool IsDualSourceBlendFactor(BlendFactor v) {
@@ -1146,7 +1146,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
const SizeT packedStride = program->GetTransformFeedbackPackedStride();
const SizeT modelledVertices =
static_cast<SizeT>(MG_Pipe::gPipeInputs.GetTransformFeedbackCapturedVertices());
static_cast<SizeT>(MG_Pipe::gPipeInputs->GetTransformFeedbackCapturedVertices());
const SizeT vertices = std::min<SizeT>(modelledVertices, xfb.scatterCapacityVertices);
if (packedStride == 0 || vertices == 0) {
// The scatter path redirected the DRIVER's capture into the scratch buffer,
@@ -1669,7 +1669,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
}
auto* twin = ResolveVaoTwin(MG_Pipe::MGPipeApplier().BoundVertexElements);
if (twin == nullptr) return;
const auto& currentVAO = MG_Pipe::gPipeInputs.GetBoundVertexArray();
const auto& currentVAO = MG_Pipe::gPipeInputs->GetBoundVertexArray();
if (!currentVAO) return;
twin->SyncClientSideAttributesForDrawArrays(currentVAO, first, count);
return;
@@ -1766,7 +1766,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
for (Uint32 remaining = memo.pendingMask; remaining != 0; remaining &= remaining - 1) {
const Uint32 location = static_cast<Uint32>(std::countr_zero(remaining));
const auto& currentValue = MG_Pipe::gPipeInputs.GetCurrentVertexAttribute(location);
const auto& currentValue = MG_Pipe::gPipeInputs->GetCurrentVertexAttribute(location);
const auto typeInfo = MG_State::GLState::ClassifyVertexAttribType(program->GetAttribType(location));
switch (typeInfo.baseType) {
case MG_State::GLState::VertexAttribBaseType::Float:
@@ -1909,7 +1909,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
// below rather than reading past the end.
const GLenum attribType =
location < link.attribTypes.size() ? link.attribTypes[location] : 0;
const auto& currentValue = MG_Pipe::gPipeInputs.GetCurrentVertexAttribute(location);
const auto& currentValue = MG_Pipe::gPipeInputs->GetCurrentVertexAttribute(location);
const auto typeInfo = MG_State::GLState::ClassifyVertexAttribType(attribType);
switch (typeInfo.baseType) {
case MG_State::GLState::VertexAttribBaseType::Float:
@@ -1986,7 +1986,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
static void CaptureUnitBindings(Int maxTouchedUnit, Vector<UnitBindingsSnapshot>& out) {
out.resize(static_cast<SizeT>(maxTouchedUnit + 1));
for (Int unit = 0; unit <= maxTouchedUnit; ++unit) {
auto& textureUnit = MG_Pipe::gPipeInputs.GetTextureUnitObject(unit);
auto& textureUnit = MG_Pipe::gPipeInputs->GetTextureUnitObject(unit);
auto& snapshot = out[static_cast<SizeT>(unit)];
const auto& slots = textureUnit.GetAllBindingSlots();
for (SizeT i = 0; i < slots.size(); ++i) {
@@ -1999,7 +1999,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
static Bool UnitBindingsUnchanged(Int maxTouchedUnit, const Vector<UnitBindingsSnapshot>& snapshots) {
if (snapshots.size() != static_cast<SizeT>(maxTouchedUnit + 1)) return false;
for (Int unit = 0; unit <= maxTouchedUnit; ++unit) {
auto& textureUnit = MG_Pipe::gPipeInputs.GetTextureUnitObject(unit);
auto& textureUnit = MG_Pipe::gPipeInputs->GetTextureUnitObject(unit);
const auto& snapshot = snapshots[static_cast<SizeT>(unit)];
const auto& slots = textureUnit.GetAllBindingSlots();
for (SizeT i = 0; i < slots.size(); ++i) {
@@ -2146,8 +2146,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
MG_Util::PipeStats::CountGate(MG_Util::PipeStats::Gate::EsprytUnitBindingsEpoch,
/*hit=*/false);
}
const Uint64 contextId = MG_Pipe::gPipeInputs.GetTextureContextId();
const Uint64 bindGeneration = MG_Pipe::gPipeInputs.GetTextureBindGeneration();
const Uint64 contextId = MG_Pipe::gPipeInputs->GetTextureContextId();
const Uint64 bindGeneration = MG_Pipe::gPipeInputs->GetTextureBindGeneration();
if (MG_Util::PipeStats::Enabled()) {
// Two accessor calls whichever way the shutter goes; only the unit WALK is
// gated, and that walk reads no GLContext accessor of its own.
@@ -2366,7 +2366,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
DrawTextureSyncKeys CaptureDrawTextureSyncKeys() {
DrawTextureSyncKeys keys;
keys.contextId = MG_Pipe::gPipeInputs.GetTextureContextId();
keys.contextId = MG_Pipe::gPipeInputs->GetTextureContextId();
// Units past the frontend's high-water mark have provably-empty slots.
//
// P4a e2 DELIBERATELY DOES NOT take this off the sampler-view window's Count, and
@@ -2379,8 +2379,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
// CLIENT as the count argument and says nothing about re-deriving it server-side.
// It is one accessor read per draw; the integrator can move it in one line once a
// tree exists where the two can be compared.
keys.maxTouchedUnit = MG_Pipe::gPipeInputs.GetMaxTouchedTextureUnit();
keys.samplingGeneration = MG_Pipe::gPipeInputs.GetSamplingResolutionGeneration();
keys.maxTouchedUnit = MG_Pipe::gPipeInputs->GetMaxTouchedTextureUnit();
keys.samplingGeneration = MG_Pipe::gPipeInputs->GetSamplingResolutionGeneration();
keys.unitBindingsEpoch = CurrentUnitBindingsEpoch(keys.maxTouchedUnit);
if (MG_Util::PipeStats::Enabled()) {
// The three reads above; CurrentUnitBindingsEpoch counts its own two when it
@@ -3455,7 +3455,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
#ifdef TRACY_ENABLE
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
#endif
Uint16 currentRenderStateVersion = MG_Pipe::gPipeInputs.GetRenderStateParametersVersion();
Uint16 currentRenderStateVersion = MG_Pipe::gPipeInputs->GetRenderStateParametersVersion();
const Bool forceFullPush = g_forceFullRenderStateResync;
g_forceFullRenderStateResync = false;
// The alpha discipline for widened colour attachments (see the header comment on
@@ -3483,7 +3483,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::AccessorCalls, 3);
}
const auto& parameters = MG_Pipe::gPipeInputs.GetRenderStateParameters();
const auto& parameters = MG_Pipe::gPipeInputs->GetRenderStateParameters();
// The frontend has ONE version for the whole parameter block, so a per-draw blend
// toggle used to re-diff all ~40 pieces of state field by field on every draw
@@ -3512,7 +3512,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
!g_hasSyncedRenderState || std::memcmp(currentBytes + kBlendSpanEnd, syncedBytes + kBlendSpanEnd,
sizeof(RenderStateParameters) - kBlendSpanEnd) != 0;
IntVec4 backendViewport = MG_Pipe::gPipeInputs.GetViewport();
IntVec4 backendViewport = MG_Pipe::gPipeInputs->GetViewport();
if (backendViewport.z() <= 0 || backendViewport.w() <= 0) {
Int surfaceWidth = 0;
Int surfaceHeight = 0;
@@ -3595,7 +3595,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
// never turns it on, so the driver has to be told to write raw. Without this a render
// into an sRGB colour buffer comes back encoded once too often (the shader's own
// decode on the next fetch then leaves the value one conversion short).
const Bool srgbWrites = MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::FramebufferSrgb);
const Bool srgbWrites = MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::FramebufferSrgb);
if (g_GLESCapabilities.SupportsSrgbWriteControl &&
(forceFullPush || srgbWrites != g_syncedSrgbFramebufferWrites)) {
srgbWrites ? g_GLESFuncs.glEnable(GL_FRAMEBUFFER_SRGB)
@@ -4505,11 +4505,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
!twin->ImageUnitFormatsStillMatch() ||
(twin->GetPassthroughTessControlPatchVertices() >= 0 &&
(twin->GetPassthroughTessControlPatchVertices() !=
static_cast<Int>(MG_Pipe::gPipeInputs.GetPatchVertices()) ||
static_cast<Int>(MG_Pipe::gPipeInputs->GetPatchVertices()) ||
!BitwiseEqual(twin->GetPassthroughTessControlOuterLevel(),
MG_Pipe::gPipeInputs.GetPatchDefaultOuterLevel()) ||
MG_Pipe::gPipeInputs->GetPatchDefaultOuterLevel()) ||
!BitwiseEqual(twin->GetPassthroughTessControlInnerLevel(),
MG_Pipe::gPipeInputs.GetPatchDefaultInnerLevel())))) {
MG_Pipe::gPipeInputs->GetPatchDefaultInnerLevel())))) {
twin->SyncToBackendByHandle(cso);
}
g_currentDrawProgramHandle = cso;
@@ -4517,6 +4517,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
}
} // namespace PrgramImpl
// Defined with the surface registry, below.
static void FlushAheadOfWindowBufferUse();
void BindCurrentFBO(FramebufferTarget target) {
#ifdef TRACY_ENABLE
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
@@ -4560,6 +4563,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
} else {
MGLOG_D("Binding default framebuffer as %s FBO",
(target == FramebufferTarget::Read ? "READ" : "DRAW"));
if (FramebufferImpl::CurrentFramebufferBinding(target) != 0) FlushAheadOfWindowBufferUse();
// Through the shadow: a raw bind here would leave the shadow claiming
// the previous user FBO, false-skipping its next re-bind.
FramebufferImpl::BindFramebufferId(
@@ -4596,6 +4600,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
FramebufferImpl::g_alphaWidenedDrawBufferMask = 0;
FramebufferImpl::g_integerColorDrawBufferMask = 0;
}
if (FramebufferImpl::CurrentFramebufferBinding(target) != 0) FlushAheadOfWindowBufferUse();
FramebufferImpl::BindFramebufferId(
target == FramebufferTarget::Draw ? GL_DRAW_FRAMEBUFFER : GL_READ_FRAMEBUFFER, 0);
return;
@@ -5846,12 +5851,12 @@ namespace MobileGL::MG_Backend::DirectGLES {
// times; rasterizer discard means there are no fragments to gate at all, so replaying
// would be pure cost with nothing to show for it. Both fall back to a single pass with an
// open gate, i.e. to the pre-emulation behaviour, rather than to wrong data.
if (MG_Pipe::gPipeInputs.IsTransformFeedbackActive() ||
MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::RasterizerDiscard)) {
if (MG_Pipe::gPipeInputs->IsTransformFeedbackActive() ||
MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::RasterizerDiscard)) {
return 1;
}
const auto& parameters = MG_Pipe::gPipeInputs.GetRenderStateParameters();
const auto& parameters = MG_Pipe::gPipeInputs->GetRenderStateParameters();
Int surfaceWidth = 0;
Int surfaceHeight = 0;
if (!QueryCurrentSurfaceSize(surfaceWidth, surfaceHeight)) {
@@ -6228,7 +6233,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
// color must go through glClearBufferfv, which GLES does not clamp.
GLbitfield remainingMask = mask;
if ((mask & GL_COLOR_BUFFER_BIT) != 0) {
const FloatVec4& cc = MG_Pipe::gPipeInputs.GetRenderStateParameters().ClearColor;
const FloatVec4& cc = MG_Pipe::gPipeInputs->GetRenderStateParameters().ClearColor;
const Bool outOfRange = cc.x() < 0.f || cc.x() > 1.f || cc.y() < 0.f || cc.y() > 1.f || cc.z() < 0.f ||
cc.z() > 1.f || cc.w() < 0.f || cc.w() > 1.f;
// A widened attachment's stored alpha has to end up 1.0, and glClear applies ONE
@@ -6456,13 +6461,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
} // namespace
RestartSubstitutionKind ResolveRestartSubstitution(GLenum indexType) {
if (!MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::PrimitiveRestart) ||
MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::PrimitiveRestartFixedIndex)) {
if (!MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::PrimitiveRestart) ||
MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::PrimitiveRestartFixedIndex)) {
return RestartSubstitutionKind::None;
}
const Uint32 fixedMax = MG_Util::FixedRestartIndexForGLType(indexType);
if (fixedMax == 0) return RestartSubstitutionKind::None;
const Uint32 restartIndex = MG_Pipe::gPipeInputs.GetPrimitiveRestartIndex();
const Uint32 restartIndex = MG_Pipe::gPipeInputs->GetPrimitiveRestartIndex();
if (restartIndex == fixedMax) return RestartSubstitutionKind::None;
// Strictly greater, never truncated. GL 4.6 core 10.3.6 compares the fetched index
// zero-extended against the full 32-bit state, so an index this type cannot hold matches
@@ -6502,7 +6507,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
}
const SizeT sourceIndexSize = MG_Util::GetGLTypeSize(indexType);
const Uint32 fixedMax = MG_Util::FixedRestartIndexForGLType(indexType);
const Uint32 applicationRestartIndex = MG_Pipe::gPipeInputs.GetPrimitiveRestartIndex();
const Uint32 applicationRestartIndex = MG_Pipe::gPipeInputs->GetPrimitiveRestartIndex();
const Uint8* source = nullptr;
SizeT indexCount = 0;
@@ -7395,8 +7400,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
// restore. Drop the flag so it is not misattributed to the emulation's own work.
DrainBlitErrors();
if (MG_Pipe::gPipeInputs.IsTransformFeedbackActive() &&
!MG_Pipe::gPipeInputs.IsTransformFeedbackPaused() && g_GLESFuncs.glPauseTransformFeedback) {
if (MG_Pipe::gPipeInputs->IsTransformFeedbackActive() &&
!MG_Pipe::gPipeInputs->IsTransformFeedbackPaused() && g_GLESFuncs.glPauseTransformFeedback) {
g_GLESFuncs.glPauseTransformFeedback();
m_pausedTransformFeedback = true;
DrainBlitErrors();
@@ -8618,7 +8623,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
#ifdef TRACY_ENABLE
ZoneScopedNC(__func__, TRACY_ZONECOLOR_BACKEND);
#endif
auto unit = MG_Pipe::gPipeInputs.GetActiveTextureUnit();
auto unit = MG_Pipe::gPipeInputs->GetActiveTextureUnit();
auto textureTarget = MG_Util::ConvertGLEnumToTextureTarget(target);
if (!TextureImpl::IsSupportedTextureTarget(textureTarget)) {
@@ -8695,7 +8700,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
// The frontend's current PACK parameters, for readbacks the ES driver serves
// directly with the client's layout.
static PixelStoreImpl::PackState PackStateFromContext() {
const auto packParams = MG_Pipe::gPipeInputs.GetPixelStoreParameters(false);
const auto packParams = MG_Pipe::gPipeInputs->GetPixelStoreParameters(false);
return {static_cast<GLint>(packParams.Alignment), static_cast<GLint>(packParams.RowLength),
static_cast<GLint>(packParams.SkipRows), static_cast<GLint>(packParams.SkipPixels)};
}
@@ -8891,7 +8896,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
MG_Util::ConvertGLEnumToString(err).c_str(),
MG_Util::ConvertGLEnumToString(target).c_str(),
MG_Util::ConvertTextureInternalFormatToString(format).c_str());
MG_Pipe::gPipeInputs.RecordError(
MG_Pipe::gPipeInputs->RecordError(
ConvertGLESErrorToErrorCode(err),
MakeUnique<GenericErrorInfo>("DirectGLES", operation,
MG_Util::ConvertGLEnumToString(err)));
@@ -9407,7 +9412,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
// Bind necessary FBO and texture
BindCurrentFBO(FramebufferTarget::Read);
Uint activeTextureUnit = MG_Pipe::gPipeInputs.GetActiveTextureUnit();
Uint activeTextureUnit = MG_Pipe::gPipeInputs->GetActiveTextureUnit();
TextureImpl::BackendTextureObject* dstBackendTexture = nullptr;
TextureInternalFormat mgInternalFormat{};
// P5c (hd, CONTRACT-P5C §3.4): with an active transport the destination resolves from
@@ -9516,7 +9521,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
// Bind necessary FBO and texture
BindCurrentFBO(FramebufferTarget::Read);
auto activeTextureUnit = MG_Pipe::gPipeInputs.GetActiveTextureUnit();
auto activeTextureUnit = MG_Pipe::gPipeInputs->GetActiveTextureUnit();
TextureImpl::BackendTextureObject* dstBackendTexture = nullptr;
// P5c (hd, CONTRACT-P5C §3.4): see CopyTexImage2D - the record's Dst handle, never the
// client's unit binding slot or the client allocator (T2/T4).
@@ -10347,7 +10352,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
template <typename FillRow>
static Bool StoreReadbackRowsToClient(GLsizei width, GLsizei height, SizeT dstPixelBytes, void* pixels,
const char* what, FillRow&& fillRow) {
const auto packParams = MG_Pipe::gPipeInputs.GetPixelStoreParameters(false);
const auto packParams = MG_Pipe::gPipeInputs->GetPixelStoreParameters(false);
const SizeT rowPixels = static_cast<SizeT>(packParams.RowLength > 0 ? packParams.RowLength : width);
const SizeT dstRowStride = AlignPixelRow(rowPixels * dstPixelBytes, packParams.Alignment);
const SizeT dstOffset = static_cast<SizeT>(std::max(packParams.SkipRows, 0)) * dstRowStride +
@@ -11811,7 +11816,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
// and legacy GL_RED reads) goes through the wide-format conversion, which picks a wide type
// the driver accepts for the current attachment. GL_PACK_SWAP_BYTES has no ES equivalent, so
// it always takes the conversion path (which swaps on the CPU).
const Bool packSwapBytes = MG_Pipe::gPipeInputs.GetPixelStoreParameters(false).SwapBytes;
const Bool packSwapBytes = MG_Pipe::gPipeInputs->GetPixelStoreParameters(false).SwapBytes;
// The read buffer is what glReadPixels reads, so the frontend's READ binding is exactly
// the right thing to ask here.
const Bool forceOpaqueAlpha = FramebufferImpl::IsAlphaWidenedFallbackReadAttachment();
@@ -12039,7 +12044,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
Uint64 activeToken = 0;
EGLContext boundContext = EGL_NO_CONTEXT;
EGLSurface boundDraw = EGL_NO_SURFACE;
Uint64 boundSerial = 0;
// QueryCurrentSurfaceSize's memo (P15): the last answer, good while the session, the
// registry epoch and the surface-size epoch all hold.
Bool sizeMemoValid = false;
@@ -12105,7 +12109,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
// surface (one client context drawing to several windows) is a real switch.
// (t_native.boundDraw)
// ...and that context's lifetime serial, the key of its container objects.
// (t_native.boundSerial)
// (t_nativeContextThread.BoundSerial, DirectGLES.h)
std::atomic<Uint64> g_nativeContextSerials{0};
std::mutex& PerNativeContextRegistryMutex() {
@@ -12118,7 +12122,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
}
} // namespace
Uint64 CurrentNativeContextSerial() { return t_native.boundSerial; }
namespace {
std::atomic<Uint64> g_perNativeContextEpoch{1};
@@ -12126,12 +12129,19 @@ namespace MobileGL::MG_Backend::DirectGLES {
Uint64 PerNativeContextEpoch() { return g_perNativeContextEpoch.load(std::memory_order_acquire); }
void BumpPerNativeContextEpoch() { g_perNativeContextEpoch.fetch_add(1, std::memory_order_acq_rel); }
PerNativeContextBase::PerNativeContextBase() {
namespace {
std::atomic<Uint32> g_perNativeContextCacheSlots{0};
}
PerNativeContextBase::PerNativeContextBase()
: m_cacheSlot(g_perNativeContextCacheSlots.fetch_add(1, std::memory_order_relaxed) %
NativeContextThreadState::kCacheEntries) {
const std::lock_guard<std::mutex> lock(PerNativeContextRegistryMutex());
PerNativeContextRegistry().push_back(this);
}
PerNativeContextBase::~PerNativeContextBase() {
BumpPerNativeContextEpoch();
const std::lock_guard<std::mutex> lock(PerNativeContextRegistryMutex());
auto& registry = PerNativeContextRegistry();
registry.erase(std::remove(registry.begin(), registry.end(), this), registry.end());
@@ -12872,7 +12882,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
if (t_native.boundContext == tuple->Context) {
t_native.boundContext = EGL_NO_CONTEXT;
t_native.boundDraw = EGL_NO_SURFACE;
t_native.boundSerial = 0;
t_nativeContextThread.BoundSerial = 0;
}
ForgetNativeContextObjects(tuple->Serial);
tuple->Serial = 0;
@@ -12980,6 +12990,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
// session's apply) thread; the present ends the frame.
thread_local EGLSurface t_ageAskedSurface = EGL_NO_SURFACE;
// Whether the frame being drawn on this thread has had its flush ahead of the window
// buffer (FlushAheadOfWindowBufferUse); the present ends the frame.
thread_local Bool t_windowBufferFlushIssued = false;
// A WINDOW SURFACE'S BUFFER AGE, on unless MOBILEGL_ESPRYT_WINDOW_AGE=0 (or, on Android, the
// property debug.mobilegl.espryt_window_age=0); off, a window answers 0 and its client
// repaints whole frames. It was opt-in while a window repainted by age sometimes showed a
@@ -13010,6 +13024,28 @@ namespace MobileGL::MG_Backend::DirectGLES {
}
} // namespace
// THE OFF-SCREEN PART OF A FRAME DOES NOT WAIT FOR THE WINDOW BUFFER. A window surface takes
// its next buffer when the frame first uses the default framebuffer, and about every other
// frame that is the buffer the display has only just released: its release fence is still
// pending. Whatever the driver has not yet submitted then goes out at the swap, in one batch
// behind that fence - the frame's off-screen passes included - so the GPU starts the whole
// frame only after the display's next commit. A flush just before the first use lets the
// off-screen work start now; only the window pass waits. Once per frame, on window surfaces
// only (a pbuffer has no buffer to wait for), and a flush is not a wait.
static void FlushAheadOfWindowBufferUse() {
if (t_windowBufferFlushIssued) return;
t_windowBufferFlushIssued = true;
NativeSessionState& session = ActiveNativeSession();
const EGLSurface surface = session.Draw;
if (surface == EGL_NO_SURFACE) return;
{
const std::lock_guard<std::mutex> lock(g_nativeRegistryMutex);
const auto* entry = FindSessionSurfaceLocked(session, surface);
if (entry == nullptr || entry->Window == static_cast<NativeWindowType>(0)) return;
}
if (g_GLESFuncs.glFlush) g_GLESFuncs.glFlush();
}
Int32 CurrentDrawBufferAge(Bool damageRegionFollows) {
NativeSessionState& session = ActiveNativeSession();
const EGLSurface surface = session.Draw;
@@ -13476,7 +13512,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
InvalidateEglVerifiedStamp();
t_native.boundContext = tuple.Context;
t_native.boundDraw = session.Draw;
t_native.boundSerial = tuple.Serial;
t_nativeContextThread.BoundSerial = tuple.Serial;
g_backendContextOwnerThread.store(std::this_thread::get_id(), std::memory_order_release);
// The ops table may have been unregistered when a previous ES context was
// destroyed (e.g. a probe context); re-register now that GL is usable.
@@ -13522,7 +13558,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
InvalidateEglVerifiedStamp();
t_native.boundContext = EGL_NO_CONTEXT;
t_native.boundDraw = EGL_NO_SURFACE;
t_native.boundSerial = 0;
t_nativeContextThread.BoundSerial = 0;
g_backendContextOwnerThread.store(std::thread::id{}, std::memory_order_release);
return true;
}
@@ -14131,8 +14167,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
const std::lock_guard<std::mutex> lock(g_nativeRegistryMutex);
if (auto* entry = FindSessionSurfaceLocked(session, drawSurface)) ++entry->Presents;
}
// A frame boundary: the next frame's age is asked anew.
// A frame boundary: the next frame's age is asked anew, and its window buffer use flushed.
t_ageAskedSurface = EGL_NO_SURFACE;
t_windowBufferFlushIssued = false;
// P15: MOBILEGL_FRAMES_IN_FLIGHT, Espryt's half. Magma bounds the frames the GPU has
// queued with its frame contexts (frame S+1 reuses the context of frame S+1-N); this is
@@ -14248,7 +14285,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
}
t_native.boundContext = EGL_NO_CONTEXT;
t_native.boundDraw = EGL_NO_SURFACE;
t_native.boundSerial = 0;
t_nativeContextThread.BoundSerial = 0;
for (auto* tuple : NativeContexts()) {
if (tuple->SessionKey != sessionKey || tuple->Context == EGL_NO_CONTEXT) continue;
ForgetNativeContextObjects(tuple->Serial);
+28 -11
View File
@@ -327,7 +327,24 @@ namespace MobileGL::MG_Backend::DirectGLES {
// The calling thread's current native context as a lifetime serial: assigned when the context
// is created and never reused (a recycled EGLContext address is a new serial). 0 when none was
// made current through MakeCurrent.
Uint64 CurrentNativeContextSerial();
//
// P15: it lives in one constant-initialized thread_local with the PerNativeContext lookup
// cache below, so the draw path's "this context's entry" question is one TLS address
// computation, not two calls each paying their own.
struct NativeContextThreadState {
struct CacheEntry {
const void* Owner = nullptr;
Uint64 Serial = 0;
Uint64 Epoch = 0;
void* Entry = nullptr;
};
static constexpr Uint32 kCacheEntries = 8;
Uint64 BoundSerial = 0;
// One entry per PerNativeContext instance slot (instances sharing a slot evict each other).
CacheEntry Cache[kCacheEntries]{};
};
inline constinit thread_local NativeContextThreadState t_nativeContextThread;
inline Uint64 CurrentNativeContextSerial() { return t_nativeContextThread.BoundSerial; }
class PerNativeContextBase {
public:
@@ -340,6 +357,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
protected:
~PerNativeContextBase();
// This instance's entry in NativeContextThreadState::Cache.
const Uint32 m_cacheSlot;
};
// Called where a native context is destroyed.
@@ -354,12 +373,16 @@ namespace MobileGL::MG_Backend::DirectGLES {
class PerNativeContext final : public PerNativeContextBase {
public:
T& Current() {
const Uint64 serial = CurrentNativeContextSerial();
NativeContextThreadState& thread = t_nativeContextThread;
const Uint64 serial = thread.BoundSerial;
// The draw path asks for the same entry over and over from one thread: a one-entry
// thread-local cache, invalidated by any drop anywhere (rare).
thread_local CurrentCache cache;
// thread-local cache per instance, invalidated by any drop anywhere (rare) and by an
// instance's destruction (so a later instance at the same address cannot hit).
NativeContextThreadState::CacheEntry& cache = thread.Cache[m_cacheSlot];
const Uint64 epoch = PerNativeContextEpoch();
if (cache.Owner == this && cache.Serial == serial && cache.Epoch == epoch) return *cache.Entry;
if (cache.Owner == this && cache.Serial == serial && cache.Epoch == epoch) {
return *static_cast<T*>(cache.Entry);
}
const std::lock_guard<std::mutex> lock(m_mutex);
T& entry = m_bySerial[serial]; // node-based: the reference survives other contexts' inserts
cache = {this, serial, epoch, &entry};
@@ -382,12 +405,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
}
private:
struct CurrentCache {
const PerNativeContext* Owner = nullptr;
Uint64 Serial = 0;
Uint64 Epoch = 0;
T* Entry = nullptr;
};
std::mutex m_mutex;
std::unordered_map<Uint64, T> m_bySerial;
};
+49 -19
View File
@@ -1511,6 +1511,35 @@ namespace MobileGL::MG_Backend::DirectGLES {
// this one against a sha pinned at 3e298c9a. Neither ladder may drift, and neither
// may drift AWAY FROM THE OTHER without the gate saying so.
// P15: the small-store write rename (WholeStoreRenameApplies, Managers.h), applied to the
// queue BEFORE the drain takes it. The ladder above is pinned and is not touched: it is
// handed one whole-store range, which its own tier 1 already answers with the
// whole-buffer orphan-map. Draw path only - the readback drains keep their exact ranges.
void RenameSmallStoreForDrain(GLESBufferResource& resource, const Uint8* hostBase, SizeT frontendSize) {
const SizeT store = resource.storageSize;
const Bool mapUsable = !MG_Config::Features.EsprytDisableInvalidateFlush &&
g_GLESFuncs.glMapBufferRange && g_GLESFuncs.glUnmapBuffer;
const Bool foreignBytes = resource.serverGpuWritten || resource.persistentMapped ||
resource.immutableStorage || resource.externalAhb != nullptr;
// The size gate first, with the whole store as the queue: it answers every refusal
// that does not depend on the queue before any lock is taken.
if (!WholeStoreRenameApplies(store, frontendSize, store, hostBase != nullptr, foreignBytes, mapUsable))
return;
// Under split the host bytes are the server's staged copy, which only holds what the
// content records delivered; monolith's base is the frontend shadow, the whole store.
if (ServerStaged().CopiesIntoServerStorage() && !ServerStaged().IsCovered(&resource, 0, store)) return;
const std::lock_guard<std::mutex> lock(resource.pendingMutex);
if (resource.pendingRanges.empty() || !resource.pendingResidentWrites.empty()) return;
SizeT queuedBytes = 0;
for (const auto& range : resource.pendingRanges) {
const SizeT end = std::min(range.end, store);
queuedBytes += end - std::min(range.start, end);
}
if (!WholeStoreRenameApplies(store, frontendSize, queuedBytes, true, false, true)) return;
resource.pendingRanges.clear();
resource.pendingRanges.Add({0, store});
}
// Land the app bytes queued for an ADOPTED store on the GPU timeline: staged
// into the upload ring and delivered by glCopyBufferSubData. The destination
// is the IMMUTABLE persistent store, which the driver can neither rename nor
@@ -3555,6 +3584,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
} else if (!resource->pendingRanges.empty()) {
// Same rule as Ops_H_Readback's, at the draw-time drain: with no frontend object
// `hostBase` is the server shadow and every queued range must be staged.
RenameSmallStoreForDrain(*resource, hostBase, size);
MGL_SERVER_STAGED_REQUIRE_PENDING(*resource, hostBase, size, "ensure_flush_pending");
FlushPendingRangesFrom(*resource, hostBase, size);
resource->syncedChangeSerial = serial;
@@ -7198,9 +7228,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
// that needs no work costs the same nothing per draw that any other synced texture does.
void BackendTextureObject::StampViewSyncKeys(
const SharedPtr<MG_State::GLState::ITextureObject>& stateTextureObject) {
if (MG_Pipe::gPipeInputs.IsLive()) {
m_syncedShapeContextId = MG_Pipe::gPipeInputs.GetTextureContextId();
m_syncedShapeGeneration = MG_Pipe::gPipeInputs.GetSamplingResolutionGeneration();
if (MG_Pipe::gPipeInputs->IsLive()) {
m_syncedShapeContextId = MG_Pipe::gPipeInputs->GetTextureContextId();
m_syncedShapeGeneration = MG_Pipe::gPipeInputs->GetSamplingResolutionGeneration();
m_syncedShapeParamsVersion = stateTextureObject->GetTextureParamsVersion();
}
m_syncedContentVersion = stateTextureObject->GetContentVersion();
@@ -7349,9 +7379,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
// LEGACY ARM ONLY from P4a on: the memos it reads are the pre-handle ones and the
// record above answers the same question in one compare.
if (pushedStorage == nullptr)
if (m_isInitialized && m_syncedShapeContextId != 0 && MG_Pipe::gPipeInputs.IsLive() &&
m_syncedShapeContextId == MG_Pipe::gPipeInputs.GetTextureContextId() &&
m_syncedShapeGeneration == MG_Pipe::gPipeInputs.GetSamplingResolutionGeneration() &&
if (m_isInitialized && m_syncedShapeContextId != 0 && MG_Pipe::gPipeInputs->IsLive() &&
m_syncedShapeContextId == MG_Pipe::gPipeInputs->GetTextureContextId() &&
m_syncedShapeGeneration == MG_Pipe::gPipeInputs->GetSamplingResolutionGeneration() &&
m_syncedContentVersion == stateTextureObject->GetContentVersion() &&
m_syncedShapeParamsVersion == stateTextureObject->GetTextureParamsVersion() &&
stateTextureObject->GetStorageType() == TextureStorageType::Mipmap) {
@@ -7467,9 +7497,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
// The probe just proved "fully synced" from the real state, so the cheap
// gate may be (re)stamped here: the coarse generation only ever goes stale
// from OTHER textures' churn, and this draw re-validated this one.
if (MG_Pipe::gPipeInputs.IsLive()) {
m_syncedShapeContextId = MG_Pipe::gPipeInputs.GetTextureContextId();
m_syncedShapeGeneration = MG_Pipe::gPipeInputs.GetSamplingResolutionGeneration();
if (MG_Pipe::gPipeInputs->IsLive()) {
m_syncedShapeContextId = MG_Pipe::gPipeInputs->GetTextureContextId();
m_syncedShapeGeneration = MG_Pipe::gPipeInputs->GetSamplingResolutionGeneration();
m_syncedShapeParamsVersion = stateTextureObject->GetTextureParamsVersion();
}
return;
@@ -8764,9 +8794,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
// Same instant, so the cheap gate's keys describe exactly this synced state.
// Only Mipmap storage may arm it - the gate refuses other storage types anyway,
// but a stale trio must not linger on an object that later switches type.
if (MG_Pipe::gPipeInputs.IsLive() && stateTextureObject->GetStorageType() == TextureStorageType::Mipmap) {
m_syncedShapeContextId = MG_Pipe::gPipeInputs.GetTextureContextId();
m_syncedShapeGeneration = MG_Pipe::gPipeInputs.GetSamplingResolutionGeneration();
if (MG_Pipe::gPipeInputs->IsLive() && stateTextureObject->GetStorageType() == TextureStorageType::Mipmap) {
m_syncedShapeContextId = MG_Pipe::gPipeInputs->GetTextureContextId();
m_syncedShapeGeneration = MG_Pipe::gPipeInputs->GetSamplingResolutionGeneration();
m_syncedShapeParamsVersion = stateTextureObject->GetTextureParamsVersion();
} else {
m_syncedShapeContextId = 0;
@@ -9905,7 +9935,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
return record && record->ReadSurface.Kind != MG_Pipe::kMGPipeSurfaceKindNone &&
IsSnormFormat(static_cast<TextureInternalFormat>(record->ReadSurface.InternalFormat));
const auto& readFBO =
MG_Pipe::gPipeInputs.GetFramebufferBindingSlot(FramebufferTarget::Read).GetBoundObject();
MG_Pipe::gPipeInputs->GetFramebufferBindingSlot(FramebufferTarget::Read).GetBoundObject();
if (!readFBO) {
return false;
}
@@ -11980,19 +12010,19 @@ namespace MobileGL::MG_Backend::DirectGLES {
// patch size - so a program built for one value is stale for another. Recorded here
// and compared on the draw path (SyncCurrentProgram), the same shape as the
// storage-block and image-format signatures next to it.
const Uint patchVertices = MG_Pipe::gPipeInputs.IsLive()
? MG_Pipe::gPipeInputs.GetPatchVertices()
const Uint patchVertices = MG_Pipe::gPipeInputs->IsLive()
? MG_Pipe::gPipeInputs->GetPatchVertices()
: 3u;
m_passthroughTessControlPatchVertices = static_cast<Int>(patchVertices);
// PATCH_DEFAULT_{OUTER,INNER}_LEVEL are the same kind of dynamic state and are baked
// into the same stage (ES has no such state and no entry point to forward them to), so
// they are recorded and compared alongside the patch size - the two move together, as
// BuildPassthroughTessControlEssl's contract says.
m_passthroughTessControlOuterLevel = MG_Pipe::gPipeInputs.IsLive()
? MG_Pipe::gPipeInputs.GetPatchDefaultOuterLevel()
m_passthroughTessControlOuterLevel = MG_Pipe::gPipeInputs->IsLive()
? MG_Pipe::gPipeInputs->GetPatchDefaultOuterLevel()
: FloatVec4(1.0f, 1.0f, 1.0f, 1.0f);
m_passthroughTessControlInnerLevel = MG_Pipe::gPipeInputs.IsLive()
? MG_Pipe::gPipeInputs.GetPatchDefaultInnerLevel()
m_passthroughTessControlInnerLevel = MG_Pipe::gPipeInputs->IsLive()
? MG_Pipe::gPipeInputs->GetPatchDefaultInnerLevel()
: FloatVec2(1.0f, 1.0f);
if (tessEvalShaderIndex < 0 ||
+40
View File
@@ -984,6 +984,46 @@ namespace MobileGL::MG_Backend::DirectGLES {
(wholeBuffer ? GL_MAP_INVALIDATE_BUFFER_BIT : GL_MAP_INVALIDATE_RANGE_BIT);
}
// P15: WRITE RENAMING FOR A SMALL STORE. The draw-time drain sends a partial range below
// the tier-1 threshold through the upload ring, and every such range is one
// glCopyBufferSubData: a GPU copy job the driver builds on the render thread (FCL MC 1.21.5
// monolith on Adreno 830: 0.08 of the drain's 0.105 ms/frame) and then runs on the GPU
// timeline. Minecraft's immediate-mode batches rewrite a small per-format vertex buffer from
// offset 0 before each draw, so these ranges are partial writes of tiny stores (the
// 1.21.5 in-world trace: ~122 a frame, 81 of them into 288-byte stores). For such a store
// the drain rewrites the WHOLE store from the host bytes instead, which is tier 1's
// whole-buffer orphan-map: draws already recorded keep the old storage, draws after read the
// new one, and no copy job is recorded - the rename Magma's RenameBusyWireStore makes under
// the same 64 KiB bound.
//
// The bytes the rename moves that the queue did not ask for are bounded by
// kEsprytWholeStoreRenameMaxExtraBytes: a 128-byte write into a 53 KiB index store stays a
// ring copy rather than becoming a 53 KiB memcpy. On that trace the bound keeps 108 of the
// 122 renames for 101 KiB of extra host copying a frame; renaming every store up to 64 KiB
// would copy 811 KiB.
//
// Widening a map past the queued range is the edge that already drew blood (the note on
// InvalidateFlushAccessFor): it is only exact when the host bytes ARE the store, byte for
// byte, outside the queued ranges too. So every way the store can hold bytes the host
// copy does not is a refusal, and the caller passes them in as one flag: a shader write
// since the last whole readback (serverGpuWritten), queued resident writes, a coherent or
// imported store, immutable storage. `hostBytesCoverStore` is the host copy's own extent:
// the frontend shadow on monolith, the staged coverage under split. `mapUsable` is tier 1's
// own gate - without the map the whole range would just be a bigger ring copy.
//
// `queuedBytes` is the sum of the queued ranges clamped to the store (VecRange1D keeps them
// disjoint).
inline constexpr SizeT kEsprytWholeStoreRenameMaxBytes = 64u * 1024u;
inline constexpr SizeT kEsprytWholeStoreRenameMaxExtraBytes = 8u * 1024u;
constexpr Bool WholeStoreRenameApplies(SizeT storageSize, SizeT frontendSize, SizeT queuedBytes,
Bool hostBytesCoverStore, Bool storeHoldsBytesTheHostDoesNot,
Bool mapUsable) {
if (!mapUsable || !hostBytesCoverStore || storeHoldsBytesTheHostDoesNot) return false;
if (storageSize == 0 || storageSize > kEsprytWholeStoreRenameMaxBytes) return false;
if (frontendSize != storageSize || queuedBytes == 0 || queuedBytes > storageSize) return false;
return storageSize - queuedBytes <= kEsprytWholeStoreRenameMaxExtraBytes;
}
// The handle arms of the two draw-path entry points below. IsBufferDrawCleanByHandle
// asks the applier the same five questions IsBufferDrawClean asks the frontend object,
// with identical semantics (D-A4); EnsureBufferResourceForHandle is the ensure path
+3 -3
View File
@@ -44,14 +44,14 @@ namespace MobileGL::MG_Backend::DirectGLES::MultiDrawImpl {
// verbatim is already "this batch restarts nowhere".
Uint32 RestartSentinelFor(GLenum type) {
if (ResolveRestartSubstitution(type) != RestartSubstitutionKind::None) {
return MG_Pipe::gPipeInputs.GetPrimitiveRestartIndex();
return MG_Pipe::gPipeInputs->GetPrimitiveRestartIndex();
}
return MG_Util::FixedRestartIndexForGLType(type);
}
Bool RestartActive() {
return MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::PrimitiveRestart) ||
MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::PrimitiveRestartFixedIndex);
return MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::PrimitiveRestart) ||
MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::PrimitiveRestartFixedIndex);
}
// Vertices per primitive for the modes whose sub-draws may be concatenated into a
+1 -1
View File
@@ -2338,7 +2338,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
// Destination layout is computed from the client-side PACK parameters; only the actual pixel
// rows are written so skip regions of the destination stay untouched.
const auto packParams = MG_Pipe::gPipeInputs.GetPixelStoreParameters(false);
const auto packParams = MG_Pipe::gPipeInputs->GetPixelStoreParameters(false);
const SizeT rowPixels = static_cast<SizeT>(packParams.RowLength > 0 ? packParams.RowLength : width);
const SizeT dstRowStride = AlignReadbackRow(rowPixels * dstPixelBytes, packParams.Alignment);
const SizeT imageRows =
@@ -291,25 +291,25 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::ClearBufferfi called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::ClearBufferfi called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::ClearBufferfi called with null GL context");
pVulkanRenderer->ClearBufferfi(buffer, drawbuffer, depth, stencil);
}
void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::ClearBufferfv called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::ClearBufferfv called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::ClearBufferfv called with null GL context");
pVulkanRenderer->ClearBufferfv(buffer, drawbuffer, value);
}
void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::ClearBufferuiv called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::ClearBufferuiv called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::ClearBufferuiv called with null GL context");
pVulkanRenderer->ClearBufferuiv(buffer, drawbuffer, value);
}
void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::ClearBufferiv called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::ClearBufferiv called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::ClearBufferiv called with null GL context");
pVulkanRenderer->ClearBufferiv(buffer, drawbuffer, value);
}
@@ -345,7 +345,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void DrawElementsInstancedBaseVertexBaseInstance(GLenum mode, GLsizei count, GLenum type, const void* indices,
GLsizei instancecount, GLint basevertex, GLuint baseinstance) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::DrawElementsInstancedBaseVertexBaseInstance called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::DrawElementsInstancedBaseVertexBaseInstance called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::DrawElementsInstancedBaseVertexBaseInstance called with null GL context");
DrawIndexedCmd payload{};
payload.mode = mode;
@@ -377,7 +377,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void DrawArraysInstancedBaseInstance(GLenum mode, GLint first, GLsizei count, GLsizei instancecount,
GLuint baseinstance) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::DrawArraysInstancedBaseInstance called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::DrawArraysInstancedBaseInstance called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::DrawArraysInstancedBaseInstance called with null GL context");
DrawCmd payload{};
payload.mode = mode;
@@ -397,13 +397,13 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
GLsizei height, GLint border) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::CopyTexImage2D called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::CopyTexImage2D called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::CopyTexImage2D called with null GL context");
pVulkanRenderer->CopyTexSubImage2D(target, level, 0, 0, x, y, width, height);
}
void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
GLsizei height) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::CopyTexSubImage2D called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::CopyTexSubImage2D called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::CopyTexSubImage2D called with null GL context");
pVulkanRenderer->CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
}
void CopyImageSubData(const CopyImageEndpoint& src,
@@ -412,20 +412,20 @@ namespace MobileGL::MG_Backend::DirectVulkan {
GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ,
GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::CopyImageSubData called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::CopyImageSubData called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::CopyImageSubData called with null GL context");
pVulkanRenderer->CopyImageSubData(src, srcTarget, srcLevel, srcX, srcY, srcZ,
dst, dstTarget, dstLevel, dstX, dstY, dstZ,
srcWidth, srcHeight, srcDepth);
}
void GenerateMipmap(GLenum target) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::GenerateMipmap called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::GenerateMipmap called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::GenerateMipmap called with null GL context");
pVulkanRenderer->GenerateMipmap(target);
}
void DispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::DispatchCompute called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::DispatchCompute called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::DispatchCompute called with null GL context");
pVulkanRenderer->DispatchCompute(numGroupsX, numGroupsY, numGroupsZ);
}
@@ -440,7 +440,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void MemoryBarrier(GLbitfield barriers) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::MemoryBarrier called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::MemoryBarrier called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::MemoryBarrier called with null GL context");
pVulkanRenderer->MemoryBarrier(barriers);
}
@@ -530,12 +530,12 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::ReadPixels called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::ReadPixels called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::ReadPixels called with null GL context");
pVulkanRenderer->ReadPixels(x, y, width, height, format, type, pixels);
}
void Clear(GLbitfield mask) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::Clear called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::Clear called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::Clear called with null GL context");
pVulkanRenderer->Clear(mask);
}
@@ -582,7 +582,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void DrawArrays(GLenum mode, GLint first, GLsizei count) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::DrawArrays called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::DrawArrays called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::DrawArrays called with null GL context");
if (mode == GL_LINE_LOOP) {
if (count < 2) {
@@ -607,7 +607,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::DrawElements called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::DrawElements called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::DrawElements called with null GL context");
if (mode == GL_LINE_LOOP) {
Vector<Uint32> closedIndices;
@@ -637,7 +637,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void MultiDrawArrays(GLenum mode, const GLint* first, const GLsizei* count, GLsizei drawcount) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::MultiDrawArrays called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::MultiDrawArrays called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::MultiDrawArrays called with null GL context");
if (drawcount <= 0) {
return;
}
@@ -743,7 +743,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLint basevertex) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::DrawElementsBaseVertex called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::DrawElementsBaseVertex called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::DrawElementsBaseVertex called with null GL context");
if (mode == GL_LINE_LOOP) {
Vector<Uint32> closedIndices;
if (BuildClosedLineLoopIndices(count, type, indices, closedIndices)) {
@@ -767,14 +767,14 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void MultiDrawElementsBaseVertex(GLenum mode, const GLsizei* count, GLenum type, const GLvoid* const* indices,
GLsizei drawcount, const GLint* basevertex) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::MultiDrawElementsBaseVertex called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::MultiDrawElementsBaseVertex called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::MultiDrawElementsBaseVertex called with null GL context");
MultiDrawElementsImpl(mode, count, type, indices, drawcount, basevertex);
}
void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1,
GLint dstY1, GLbitfield mask, GLenum filter) {
MOBILEGL_ASSERT(pVulkanRenderer, "DirectVulkan::BlitFramebuffer called with null VulkanRenderer");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "DirectVulkan::BlitFramebuffer called with null GL context");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "DirectVulkan::BlitFramebuffer called with null GL context");
pVulkanRenderer->BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
}
@@ -1018,8 +1018,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
#if MOBILEGL_BUILD_DISAGGREGATED
MG_Config::Transport == MG_Config::TransportMode::Monolith &&
#endif
MG_Pipe::gPipeInputs.IsLive()) {
primitives += MG_Pipe::gPipeInputs.GetTransformFeedbackPausedPrimitiveCounter() -
MG_Pipe::gPipeInputs->IsLive()) {
primitives += MG_Pipe::gPipeInputs->GetTransformFeedbackPausedPrimitiveCounter() -
query->pausedPrimitiveSnapshot;
}
*outNanoseconds = primitives;
@@ -1069,7 +1069,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
#if MOBILEGL_BUILD_DISAGGREGATED
MG_Config::Transport == MG_Config::TransportMode::Monolith &&
#endif
MG_Pipe::gPipeInputs.IsLive() ? MG_Pipe::gPipeInputs.GetTransformFeedbackPausedPrimitiveCounter() : 0;
MG_Pipe::gPipeInputs->IsLive() ? MG_Pipe::gPipeInputs->GetTransformFeedbackPausedPrimitiveCounter() : 0;
// Read AFTER StartXfbQueryCapture, which is where a failed reroute-pool creation
// disarms: the answer is then what this span will actually do for every draw.
query->pausedPrimitivesCountedByGpu = generated && pVulkanRenderer->ArePausedDrawsGpuCounted();
@@ -26,11 +26,9 @@ namespace MobileGL::MG_Backend::DirectVulkan {
std::atomic<Uint64> g_nextSessionId{1};
thread_local MagmaSession* t_boundSession = nullptr;
// Leak-at-exit, like the renderer it holds (GlobalObjects.cpp): nothing may tear the
// monolith's renderer down from a static destructor after the driver is gone.
MagmaSession& ProcessSession() {
MagmaSession& ProcessSessionInstance() {
static auto* session = new MagmaSession();
return *session;
}
@@ -42,12 +40,9 @@ namespace MobileGL::MG_Backend::DirectVulkan {
return static_cast<Uint32>(registry.size() - 1);
}
MagmaSession& Detail::CurrentMagmaSession() {
MagmaSession* bound = t_boundSession;
return bound != nullptr ? *bound : ProcessSession();
}
MagmaSession& Detail::ProcessMagmaSession() { return ProcessSessionInstance(); }
void* Detail::SessionLocalSlot(MagmaSession& session, Uint32 index) {
void* Detail::SessionLocalSlotSlow(MagmaSession& session, Uint32 index) {
if (index >= session.m_slots.size()) session.m_slots.resize(Registry().size(), nullptr);
void*& slot = session.m_slots[index];
if (slot == nullptr) slot = Registry()[index].construct();
@@ -63,25 +58,25 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
MagmaSession::~MagmaSession() {
MagmaSession* const previous = t_boundSession;
t_boundSession = this;
MagmaSession* const previous = Detail::t_boundMagmaSession;
Detail::t_boundMagmaSession = this;
const auto& registry = Registry();
for (SizeT i = m_slots.size(); i-- > 0;) {
if (m_slots[i] != nullptr) registry[i].destroy(m_slots[i]);
m_slots[i] = nullptr;
}
// Never back to this session: it is gone.
t_boundSession = previous == this ? nullptr : previous;
Detail::t_boundMagmaSession = previous == this ? nullptr : previous;
}
MagmaSessionScope::MagmaSessionScope(MagmaSession* session) : m_previous(t_boundSession) {
t_boundSession = session;
MagmaSessionScope::MagmaSessionScope(MagmaSession* session) : m_previous(Detail::t_boundMagmaSession) {
Detail::t_boundMagmaSession = session;
}
MagmaSessionScope::~MagmaSessionScope() { t_boundSession = m_previous; }
MagmaSessionScope::~MagmaSessionScope() { Detail::t_boundMagmaSession = m_previous; }
void BindMagmaSessionToThisThread(MagmaSession* session) { t_boundSession = session; }
void BindMagmaSessionToThisThread(MagmaSession* session) { Detail::t_boundMagmaSession = session; }
MagmaSession* BoundMagmaSession() { return t_boundSession; }
MagmaSession* BoundMagmaSession() { return Detail::t_boundMagmaSession; }
} // namespace MobileGL::MG_Backend::DirectVulkan
@@ -34,9 +34,19 @@ namespace MobileGL::MG_Backend::DirectVulkan {
using SessionLocalDestroy = void (*)(void*);
// Registers one SessionLocal<T> and returns its slot. Called from static initialization.
Uint32 RegisterSessionLocal(SessionLocalConstruct construct, SessionLocalDestroy destroy);
// The calling thread's bound session (MagmaSessionScope, BindMagmaSessionToThisThread), null
// when it has none. P15: visible here, and constant-initialized, so the read inlines into
// every SessionLocal access and one function's accesses can share a single TLS address
// computation instead of paying one out-of-line call each.
inline constinit thread_local MagmaSession* t_boundMagmaSession = nullptr;
MagmaSession& ProcessMagmaSession();
// The calling thread's session, or the process-wide default.
MagmaSession& CurrentMagmaSession();
void* SessionLocalSlot(MagmaSession& session, Uint32 index);
inline MagmaSession& CurrentMagmaSession() {
MagmaSession* const bound = t_boundMagmaSession;
return bound != nullptr ? *bound : ProcessMagmaSession();
}
inline void* SessionLocalSlot(MagmaSession& session, Uint32 index);
void* SessionLocalSlotSlow(MagmaSession& session, Uint32 index);
} // namespace Detail
// One served session's copy of every SessionLocal. Slots are built lazily on first use and
@@ -55,12 +65,21 @@ namespace MobileGL::MG_Backend::DirectVulkan {
private:
friend void* Detail::SessionLocalSlot(MagmaSession& session, Uint32 index);
friend void* Detail::SessionLocalSlotSlow(MagmaSession& session, Uint32 index);
Vector<void*> m_slots;
Uint64 m_id = 0;
};
// Makes `session` the calling thread's Magma session for the scope's lifetime, restoring the
// previous binding (usually none) afterwards.
// A built slot is returned in line; a missing one is built out of line.
inline void* Detail::SessionLocalSlot(MagmaSession& session, Uint32 index) {
if (index < session.m_slots.size()) {
if (void* const slot = session.m_slots[index]) return slot;
}
return SessionLocalSlotSlow(session, index);
}
class MagmaSessionScope {
public:
explicit MagmaSessionScope(MagmaSession* session);
@@ -302,7 +302,10 @@ namespace MobileGL::MG_Backend::DirectVulkan {
auto& frame = GetCurrent();
const VkResult result = vkAcquireNextImageKHR(device, swapchain, UINT64_MAX, frame.imageAvailableSemaphore,
VK_NULL_HANDLE, &outImageIndex);
if (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR) frame.imageAvailableSemaphoreConsumed = false;
if (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR) {
frame.imageAvailableSemaphoreConsumed = false;
frame.acquiredImageReferenced = false;
}
return result;
}
@@ -333,6 +336,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
frame.imageAvailableSemaphoreConsumed = false;
frame.acquiredImageReferenced = false;
const VkResult resetResult = vkResetFences(device, 1, &frame.imageInFlightFence);
// Hand the acquire's own code back so the caller can schedule a rebuild.
return resetResult == VK_SUCCESS ? result : resetResult;
@@ -476,6 +480,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
frame.hasCommandBufferRecorded = false;
frame.isCommandRecording = false;
frame.imageAvailableSemaphoreConsumed = false;
frame.acquiredImageReferenced = false;
return VK_SUCCESS;
}
@@ -494,5 +499,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
frame.isCommandRecording = false;
frame.hasCommandBufferRecorded = false;
frame.imageAvailableSemaphoreConsumed = false;
frame.acquiredImageReferenced = false;
}
} // namespace MobileGL::MG_Backend::DirectVulkan
@@ -25,8 +25,16 @@ namespace MobileGL::MG_Backend::DirectVulkan {
virtual void OnFrameCommandRecordingBegan(VkCommandBuffer commandBuffer) = 0;
};
// The stages the acquire wait blocks. Every first access of an acquired swapchain image is
// a layout transition out of PRESENT_SRC_KHR or UNDEFINED whose source scope includes these
// stages (TransitionWireImage, TransitionToPresent), and that chain is what orders the
// access after the presentation engine's release. Work at other stages, in this and later
// submissions, does not wait for the release.
static constexpr VkPipelineStageFlags kAcquireWaitStages =
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT;
struct SubmitInfoPacket {
VkPipelineStageFlags waitDstStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
VkPipelineStageFlags waitDstStageMask = kAcquireWaitStages;
VkSemaphore waitSemaphore = VK_NULL_HANDLE;
VkSemaphore signalSemaphore = VK_NULL_HANDLE;
// [0] = pre-pass command buffer (when recorded), then the frame
@@ -67,6 +75,11 @@ namespace MobileGL::MG_Backend::DirectVulkan {
Bool isPreCommandRecording = false;
Bool hasPreCommandBufferRecorded = false;
Bool imageAvailableSemaphoreConsumed = false;
// The open recording references the acquired swapchain image. Only a submission that
// does (or the present's) waits on imageAvailableSemaphore: the frame's work recorded
// before its first use of the image goes to the queue without the wait, so it never
// queues behind the release of an image the display still scans out.
Bool acquiredImageReferenced = false;
// Command buffers submitted mid-frame (FlushPendingCommands),
// appended in submit order; freed once their submission is known
// complete (fence wait or completion poll).
@@ -173,7 +173,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void SwapchainObject::Create(VkDevice device, VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
Uint32 graphicsQueueFamily, Uint32 presentQueueFamily, Uint32 minImageCountHint,
VkExtent2D desiredExtent, Optional<Int> swapInterval) {
Uint32 extraImageCount, VkExtent2D desiredExtent, Optional<Int> swapInterval) {
const auto swapchainCapabilities = GetSwapchainCapabilities(physicalDevice, surface);
MOBILEGL_ASSERT(swapchainCapabilities.IsComplete(),
"SwapchainObject::Create failed: incomplete swapchain capabilities");
@@ -198,11 +198,15 @@ namespace MobileGL::MG_Backend::DirectVulkan {
m_supportedPresentModes = swapchainCapabilities.presentModes;
const auto& swapchainCaps = swapchainCapabilities.capabilities;
Uint32 targetImageCount = std::max<Uint32>(minImageCountHint, swapchainCaps.minImageCount);
// The extra images count from the surface's own minimum: that is how many the platform
// keeps for itself and the application, so only images beyond it delay a buffer's reuse.
Uint32 targetImageCount =
std::max<Uint32>(minImageCountHint, swapchainCaps.minImageCount + extraImageCount);
if (swapchainCaps.maxImageCount != 0) {
targetImageCount = std::min(targetImageCount, swapchainCaps.maxImageCount);
}
MGLOG_I("Set minImageCount = %u", targetImageCount);
MGLOG_I("Set minImageCount = %u (surface min %u, max %u, extra %u)", targetImageCount,
swapchainCaps.minImageCount, swapchainCaps.maxImageCount, extraImageCount);
MGLOG_I("Swapchain currentTransform = %s",
string_VkSurfaceTransformFlagBitsKHR(swapchainCaps.currentTransform));
@@ -36,8 +36,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
static const char* GetPresentModeName(VkPresentModeKHR presentMode);
void Create(VkDevice device, VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, Uint32 graphicsQueueFamily,
Uint32 presentQueueFamily, Uint32 minImageCountHint, VkExtent2D desiredExtent,
Optional<Int> swapInterval);
Uint32 presentQueueFamily, Uint32 minImageCountHint, Uint32 extraImageCount,
VkExtent2D desiredExtent, Optional<Int> swapInterval);
void Shutdown(VkDevice device);
// Tells the frontend (or, under a transport, the client) the default framebuffer's size
// and formats. Create does this; a renderer switching between surfaces repeats it.
@@ -858,7 +858,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
VkDescriptorBufferInfo& outBufferInfo) const {
outBufferInfo = {};
MOBILEGL_ASSERT(m_bufferManager != nullptr, "ResolveStorageBufferDescriptor: buffer manager is null");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "ResolveStorageBufferDescriptor: GL context is null");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "ResolveStorageBufferDescriptor: GL context is null");
MOBILEGL_ASSERT(binding < programObj.storageBlockIndexByBinding.size(),
"ResolveStorageBufferDescriptor: binding %u out of range", binding);
if ((binding >= programObj.storageBlockIndexByBinding.size() ||
@@ -1155,7 +1155,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
const void* outData = nullptr;
VkDeviceSize outSize = 0;
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs.IsLive(), "ResolveUniformBufferPayload: GL context is null");
MOBILEGL_ASSERT(MG_Pipe::gPipeInputs->IsLive(), "ResolveUniformBufferPayload: GL context is null");
MOBILEGL_ASSERT(binding < programObj.bindingKinds.size(),
"ResolveUniformBufferPayload: binding %u out of range", binding);
MOBILEGL_ASSERT(programObj.bindingKinds[binding] == ProgramFactory::DescriptorBindingKind::UniformBufferDynamic,
@@ -55,7 +55,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
if (payload.colorEncoding != ClearColorEncoding::Float) return;
// With GL_FRAMEBUFFER_SRGB enabled GL performs the encoding itself, so the driver doing it
// is exactly right and there is nothing to undo.
if (MG_Pipe::gPipeInputs.IsCapabilityEnabled(MobileGL::CapabilityInput::FramebufferSrgb)) return;
if (MG_Pipe::gPipeInputs->IsCapabilityEnabled(MobileGL::CapabilityInput::FramebufferSrgb)) return;
if (ResolveSrgbAttachmentWriteFormat(destinationFormat, false) == destinationFormat) return;
// sRGB -> linear (GL 4.6 core 8.24), applied to the colour channels only: alpha is stored
@@ -526,12 +526,12 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// round trip), which is why the honest-but-lossy path was kept over widening every
// default-framebuffer Y-flip/pre-transform helper to floats. See the KNOWN INFIDELITY
// note in MG_IntegrationTest/Scenarios/AdvertisedLimitsScenario.cpp.
const FloatVec4& stored = MG_Pipe::gPipeInputs.GetViewportIndexed(index);
const FloatVec4& stored = MG_Pipe::gPipeInputs->GetViewportIndexed(index);
const IntVec4 viewportState(static_cast<Int>(std::lround(stored.x())),
static_cast<Int>(std::lround(stored.y())),
static_cast<Int>(std::lround(stored.z())),
static_cast<Int>(std::lround(stored.w())));
const FloatVec2& depthRange = MG_Pipe::gPipeInputs.GetDepthRangeIndexed(index);
const FloatVec2& depthRange = MG_Pipe::gPipeInputs->GetDepthRangeIndexed(index);
const IntVec2 logicalExtent = isDefaultFramebuffer
? ResolveDefaultFramebufferLogicalExtent(preTransform, framebufferExtent)
: framebufferExtent;
@@ -586,7 +586,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
static void ApplyBlendConstants(VkCommandBuffer commandBuffer) {
const FloatVec4& blendColor = MG_Pipe::gPipeInputs.GetBlendColor();
const FloatVec4& blendColor = MG_Pipe::gPipeInputs->GetBlendColor();
const float blendConstants[4] = {
blendColor.x(),
blendColor.y(),
@@ -619,8 +619,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
static void ApplyPolygonOffsetState(VkCommandBuffer commandBuffer) {
const Float constantFactor = MG_Pipe::gPipeInputs.GetPolygonOffsetUnits();
const Float slopeFactor = MG_Pipe::gPipeInputs.GetPolygonOffsetFactor();
const Float constantFactor = MG_Pipe::gPipeInputs->GetPolygonOffsetUnits();
const Float slopeFactor = MG_Pipe::gPipeInputs->GetPolygonOffsetFactor();
auto& shadow = *g_dynamicStateShadow;
if (shadow.depthBiasValid && shadow.depthBiasConstantFactor == constantFactor &&
shadow.depthBiasSlopeFactor == slopeFactor) {
@@ -633,7 +633,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
static void ApplyLineWidthState(VkCommandBuffer commandBuffer) {
Float lineWidth = MG_Pipe::gPipeInputs.GetLineWidth();
Float lineWidth = MG_Pipe::gPipeInputs->GetLineWidth();
#if MOBILEGL_BUILD_DISAGGREGATED
// P5c (hd, CONTRACT-P5C §3.7): with an active transport the dynamic parameters are the
// SERVER's own backend's - the client caps mirror is client memory (rule E). Monolith
@@ -677,7 +677,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// reader of the box asks this first. The resolution matches the viewport's (ComputeGLViewport
// resolves a never-written viewport to the current framebuffer's extent).
static Bool GLScissorTestClips(Uint32 index = 0) {
const RenderStateParameters& parameters = MG_Pipe::gPipeInputs.GetRenderStateParameters();
const RenderStateParameters& parameters = MG_Pipe::gPipeInputs->GetRenderStateParameters();
const Uint32 bit = 1u << index;
return (parameters.ScissorTestEnabledMask & bit) != 0 && (parameters.ScissorBoxWrittenMask & bit) != 0;
}
@@ -748,8 +748,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
static void ApplyStencilState(VkCommandBuffer commandBuffer) {
const StencilFaceState& frontStencil = MG_Pipe::gPipeInputs.GetStencilState(StencilFace::Front);
const StencilFaceState& backStencil = MG_Pipe::gPipeInputs.GetStencilState(StencilFace::Back);
const StencilFaceState& frontStencil = MG_Pipe::gPipeInputs->GetStencilState(StencilFace::Front);
const StencilFaceState& backStencil = MG_Pipe::gPipeInputs->GetStencilState(StencilFace::Back);
const Uint32 frontReference = static_cast<Uint32>(std::max(frontStencil.Ref, 0));
const Uint32 backReference = static_cast<Uint32>(std::max(backStencil.Ref, 0));
@@ -1116,7 +1116,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
static void RecordTextureCopyError(const char* func, ErrorCode code, const char* message) {
MG_Pipe::gPipeInputs.RecordError(code, MakeUnique<GenericErrorInfo>("DirectVulkan", func, message));
MG_Pipe::gPipeInputs->RecordError(code, MakeUnique<GenericErrorInfo>("DirectVulkan", func, message));
}
namespace {
@@ -1894,7 +1894,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// glReadPixels final conversion: GL_CLAMP_READ_COLOR defaults to GL_FIXED_ONLY,
// clamping fixed-point (normalized) buffers to [0,1] - visible for SNORM reads.
if (applyReadColorClamp && wideType == GL_FLOAT) {
const GLenum clampMode = MG_Pipe::gPipeInputs.GetClampReadColor();
const GLenum clampMode = MG_Pipe::gPipeInputs->GetClampReadColor();
const Bool clamp = clampMode == GL_TRUE ||
(clampMode == GL_FIXED_ONLY && !IsFloatingPointReadbackFormat(srcFormat));
if (clamp) {
@@ -2699,9 +2699,9 @@ namespace MobileGL::MG_Backend::DirectVulkan {
Uint32 VulkanRenderer::ResolveEffectiveSampleMask(VkSampleCountFlagBits rasterizationSamples) const {
constexpr Uint32 kFullCoverage = 0xffffffffu;
if (rasterizationSamples == VK_SAMPLE_COUNT_1_BIT) return kFullCoverage;
if (!MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::Multisample)) return kFullCoverage;
if (!MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::SampleMask)) return kFullCoverage;
return MG_Pipe::gPipeInputs.GetRenderStateParameters().SampleMaskValue;
if (!MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::Multisample)) return kFullCoverage;
if (!MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::SampleMask)) return kFullCoverage;
return MG_Pipe::gPipeInputs->GetRenderStateParameters().SampleMaskValue;
}
@@ -2716,7 +2716,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
//
// Only reached with no render-state CSO bound, and only in a build with no pre-handle
// arm to fall back to instead.
return MG_Pipe::MGPipeComputePipelineSubsetHash(MG_Pipe::gPipeInputs.GetRenderStateParameters());
return MG_Pipe::MGPipeComputePipelineSubsetHash(MG_Pipe::gPipeInputs->GetRenderStateParameters());
}
// A program that runs a geometry shader AND captures transform feedback. Both halves are
@@ -2748,7 +2748,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
if (!(aspects & DrawSetupAspect::IndexBuffer) || pIndexBufferView == nullptr) {
return false;
}
const RenderStateParameters& rsp = MG_Pipe::gPipeInputs.GetRenderStateParameters();
const RenderStateParameters& rsp = MG_Pipe::gPipeInputs->GetRenderStateParameters();
if (rsp.PrimitiveRestartFixedIndexEnabled) {
return true;
}
@@ -2803,7 +2803,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// the VALUE hash of that subset, never the version itself: the version is monotonic, so
// per-draw state flips (GL_BLEND toggles) would otherwise miss entries the memo holds.
// The version only guards recomputing the hash - unchanged version, unchanged bytes.
const Uint renderStateVersion = MG_Pipe::gPipeInputs.GetPipelineStateVersion();
const Uint renderStateVersion = MG_Pipe::gPipeInputs->GetPipelineStateVersion();
// P2 D12.1. Non-null means the client's render-state CSO handle is this draw's state
// key and the hash below is not computed at all; null means the pre-handle arm. The
// two arms' entries can never match each other: the handle arm stores hash 0 and a
@@ -2996,16 +2996,16 @@ namespace MobileGL::MG_Backend::DirectVulkan {
syntheticVertexInputState.pNext = vis.state.pNext;
pipelineVertexInputState = &syntheticVertexInputState;
}
auto cullFaceEnabled = MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::CullFace);
auto depthTestEnabled = MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::DepthTest);
auto cullFaceEnabled = MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::CullFace);
auto depthTestEnabled = MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::DepthTest);
auto polygonOffsetFillEnabled =
MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::PolygonOffsetFill) &&
MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::PolygonOffsetFill) &&
DrawModeUsesPolygonFill(mode);
auto rasterizerDiscardEnabled =
MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::RasterizerDiscard);
MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::RasterizerDiscard);
auto colorLogicOpEnabled =
MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::ColorLogicOp) && m_logicOpFeatureEnabled;
auto stencilTestEnabled = MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::StencilTest);
MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::ColorLogicOp) && m_logicOpFeatureEnabled;
auto stencilTestEnabled = MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::StencilTest);
// A framebuffer without a depth (stencil) attachment behaves as if the depth
// (stencil) test always passes and nothing is written - even when the bound
// image is a packed depth-stencil texture attached through only one half.
@@ -3016,10 +3016,10 @@ namespace MobileGL::MG_Backend::DirectVulkan {
if (fbo->Stencil.Kind == MG_Pipe::kMGPipeSurfaceKindNone) stencilTestEnabled = false;
}
}
const StencilFaceState& frontStencil = MG_Pipe::gPipeInputs.GetStencilState(StencilFace::Front);
const StencilFaceState& backStencil = MG_Pipe::gPipeInputs.GetStencilState(StencilFace::Back);
const StencilFaceState& frontStencil = MG_Pipe::gPipeInputs->GetStencilState(StencilFace::Front);
const StencilFaceState& backStencil = MG_Pipe::gPipeInputs->GetStencilState(StencilFace::Back);
const VkPolygonMode requestedPolygonMode =
MG_Util::ConvertPolygonModeToVkEnum(MG_Pipe::gPipeInputs.GetPolygonModeFront());
MG_Util::ConvertPolygonModeToVkEnum(MG_Pipe::gPipeInputs->GetPolygonModeFront());
// VK_POLYGON_MODE_LINE/_POINT require the fillModeNonSolid device feature; fall back to
// VK_POLYGON_MODE_FILL when the device lacks it.
const VkPolygonMode effectivePolygonMode =
@@ -3105,18 +3105,18 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// driver's own rate. Both halves move the render state's PIPELINE version, so a cached
// pipeline built at the old rate cannot be handed back for the new one.
.sampleShadingEnable = m_sampleRateShadingFeatureEnabled &&
MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::SampleShading),
.minSampleShading = MG_Pipe::gPipeInputs.GetMinSampleShadingValue(),
MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::SampleShading),
.minSampleShading = MG_Pipe::gPipeInputs->GetMinSampleShadingValue(),
// Word 1 keeps its all-ones initialiser: GL has no state for samples 32..63.
.sampleMask = {ResolveEffectiveSampleMask(renderPassEntry.sampleCount), 0xffffffffu},
.subpass = 0,
.topology = vkTopology,
.primitiveRestartEnable = primitiveRestartEnabled,
.patchControlPoints = static_cast<Uint32>(MG_Pipe::gPipeInputs.GetPatchVertices()),
.patchControlPoints = static_cast<Uint32>(MG_Pipe::gPipeInputs->GetPatchVertices()),
.viewportCount = ResolveDrawViewportCount(programObj.writesViewportIndexBuiltin),
.polygonMode = effectivePolygonMode,
.cullMode = cullFaceEnabled
? MG_Util::ConvertCullFaceModeToVkEnum(MG_Pipe::gPipeInputs.GetCullFaceMode(), invertClockwise)
? MG_Util::ConvertCullFaceModeToVkEnum(MG_Pipe::gPipeInputs->GetCullFaceMode(), invertClockwise)
: VK_CULL_MODE_NONE,
.frontFace = VK_FRONT_FACE_CLOCKWISE,
// Read the geometry stage off the program's own shader list rather than
@@ -3130,13 +3130,13 @@ namespace MobileGL::MG_Backend::DirectVulkan {
.provokingVertexMode = SelectProvokingVertexMode(
vkTopology, ProgramCapturesXfbFromGeometryStage(program)),
.depthTestEnable = depthTestEnabled,
.depthWriteEnable = depthTestEnabled && MG_Pipe::gPipeInputs.GetDepthMask(),
.depthWriteEnable = depthTestEnabled && MG_Pipe::gPipeInputs->GetDepthMask(),
.depthBiasEnable = polygonOffsetFillEnabled,
.rasterizerDiscardEnable = rasterizerDiscardEnabled,
.logicOpEnable = colorLogicOpEnabled,
.stencilTestEnable = stencilTestEnabled,
.depthCompareOp = MG_Util::ConvertDepthTestFuncToVkEnum(MG_Pipe::gPipeInputs.GetDepthFunc()),
.logicOp = MG_Util::ConvertLogicOperationToVkEnum(MG_Pipe::gPipeInputs.GetLogicOp()),
.depthCompareOp = MG_Util::ConvertDepthTestFuncToVkEnum(MG_Pipe::gPipeInputs->GetDepthFunc()),
.logicOp = MG_Util::ConvertLogicOperationToVkEnum(MG_Pipe::gPipeInputs->GetLogicOp()),
.frontStencilFailOp = MG_Util::ConvertStencilOperationToVkEnum(frontStencil.FailOp),
.frontStencilPassOp = MG_Util::ConvertStencilOperationToVkEnum(frontStencil.PassDepthPassOp),
.frontStencilDepthFailOp = MG_Util::ConvertStencilOperationToVkEnum(frontStencil.PassDepthFailOp),
@@ -3172,8 +3172,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// handed back after the application changed them.
if (programObj.needsPassthroughTessControl && programObj.passthroughTessControlEmulatable &&
vkTopology == VK_PRIMITIVE_TOPOLOGY_PATCH_LIST) {
const FloatVec4& defaultOuterLevel = MG_Pipe::gPipeInputs.GetPatchDefaultOuterLevel();
const FloatVec2& defaultInnerLevel = MG_Pipe::gPipeInputs.GetPatchDefaultInnerLevel();
const FloatVec4& defaultOuterLevel = MG_Pipe::gPipeInputs->GetPatchDefaultOuterLevel();
const FloatVec2& defaultInnerLevel = MG_Pipe::gPipeInputs->GetPatchDefaultInnerLevel();
payload.passthroughTessControlKey = ProgramFactory::ComputePassthroughTessControlKey(
payload.patchControlPoints, defaultOuterLevel, defaultInnerLevel,
programObj.passthroughPerVertexMembers);
@@ -3243,14 +3243,14 @@ namespace MobileGL::MG_Backend::DirectVulkan {
BlendFactor dstAlpha = BlendFactor::Zero;
BlendEquation colorEquation = BlendEquation::Add;
BlendEquation alphaEquation = BlendEquation::Add;
MG_Pipe::gPipeInputs.GetBlendFuncIndexed(i, srcRGB, dstRGB, srcAlpha, dstAlpha);
MG_Pipe::gPipeInputs.GetBlendEquationIndexed(i, colorEquation, alphaEquation);
const Bool blendEnabled = MG_Pipe::gPipeInputs.IsCapabilityEnabledIndexed(CapabilityInput::Blend, i);
MG_Pipe::gPipeInputs->GetBlendFuncIndexed(i, srcRGB, dstRGB, srcAlpha, dstAlpha);
MG_Pipe::gPipeInputs->GetBlendEquationIndexed(i, colorEquation, alphaEquation);
const Bool blendEnabled = MG_Pipe::gPipeInputs->IsCapabilityEnabledIndexed(CapabilityInput::Blend, i);
// Per-draw-buffer color write mask (glColorMaski). Divergent per-attachment masks require
// the independentBlend device feature; when it is absent, fall back to draw buffer 0's
// mask for every attachment (matching the non-indexed glColorMask broadcast).
const BoolVec4 bufferMask =
MG_Pipe::gPipeInputs.GetColorMaskIndexed(m_independentBlendFeatureEnabled ? i : 0);
MG_Pipe::gPipeInputs->GetColorMaskIndexed(m_independentBlendFeatureEnabled ? i : 0);
VkColorComponentFlags attachmentColorWriteMask = static_cast<VkColorComponentFlags>(
(bufferMask.r() ? VK_COLOR_COMPONENT_R_BIT : 0u) |
(bufferMask.g() ? VK_COLOR_COMPONENT_G_BIT : 0u) |
@@ -3404,7 +3404,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
VkRect2D VulkanRenderer::ComputeGLScissorRect(Uint32 index, const IntVec2& extent,
VkSurfaceTransformFlagBitsKHR preTransform,
Bool isDefaultFbo) const {
const auto& parameters = MG_Pipe::gPipeInputs.GetRenderStateParameters();
const auto& parameters = MG_Pipe::gPipeInputs->GetRenderStateParameters();
if (!GLScissorTestClips(index)) {
VkRect2D full{};
full.offset = {0, 0};
@@ -3480,7 +3480,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// counter still would make Espryt skip re-syncing the blend state it just changed.
// The second-level DynamicTailKey compare below is therefore what actually absorbs a
// pipeline-only change, exactly as it did before P2: one key build, no vkCmd*.
const Uint paramsVersion = MG_Pipe::gPipeInputs.GetRenderStateParametersVersion();
const Uint paramsVersion = MG_Pipe::gPipeInputs->GetRenderStateParametersVersion();
if (shadow.dynamicTailValid && shadow.dynamicTailParamsVersion == paramsVersion &&
shadow.dynamicTailExtentX == extent.x() && shadow.dynamicTailExtentY == extent.y() &&
shadow.dynamicTailIsDefaultFbo == isDefaultFbo) {
@@ -3504,7 +3504,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// re-derive the value its shadow already holds.
DynamicStateShadow::DynamicTailKey key;
{
const RenderStateParameters& p = MG_Pipe::gPipeInputs.GetRenderStateParameters();
const RenderStateParameters& p = MG_Pipe::gPipeInputs->GetRenderStateParameters();
// Viewport 0 and its depth range: ApplyGLViewportState reads exactly those two
// (per-index state for indices > 0 is keyed separately, see multiViewportKey below).
key.viewport[0] = p.Viewports[0].x();
@@ -3601,6 +3601,11 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// split server records every draw its client sends into the same frame command buffer, so
// the same loading frame grows it the same way there.
SplitOversizedRecording();
// A draw into the window: the frame's work so far goes out now, ahead of the acquire wait,
// while nothing of this draw is recorded yet (its descriptor binds must land in the
// recording the draw does). ResolveWireImage would split later, mid-setup.
if (const auto* fbo = MG_Pipe::MGPipeApplier().DrawFramebuffer(); fbo != nullptr && fbo->IsDefault)
SubmitAheadOfAcquiredImage();
if (!RewindWireDescriptorSetsIfDue()) return false;
// The wire route returns before the monolith branch's draw-gated
// sweep. Dead wire texture/renderbuffer records otherwise live
@@ -3763,9 +3768,9 @@ namespace MobileGL::MG_Backend::DirectVulkan {
if (!fbo) MagmaWireFatal("clear-framebuffer-record");
ClearAttachmentPayload payload{};
payload.mask = mask;
payload.color = MG_Pipe::gPipeInputs.GetClearColor();
payload.depth = MG_Pipe::gPipeInputs.GetClearDepth();
payload.stencil = MG_Pipe::gPipeInputs.GetClearStencil();
payload.color = MG_Pipe::gPipeInputs->GetClearColor();
payload.depth = MG_Pipe::gPipeInputs->GetClearDepth();
payload.stencil = MG_Pipe::gPipeInputs->GetClearStencil();
ClearWireFramebuffer(*fbo, payload);
return;
}
@@ -4846,7 +4851,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
const SharedPtr<MG_State::GLState::BufferObject> wireReplyHasNoPackBuffer;
const auto& pixelPackBufferObject =
wireReplyHasNoPackBuffer;
const auto packParams = MG_Pipe::gPipeInputs.GetPixelStoreParameters(false);
const auto packParams = MG_Pipe::gPipeInputs->GetPixelStoreParameters(false);
const SizeT rowPixels = static_cast<SizeT>(packParams.RowLength > 0 ? packParams.RowLength : width);
const SizeT packAlignment = packParams.Alignment > 0 ? static_cast<SizeT>(packParams.Alignment) : 1;
const SizeT dstRowStride = ((rowPixels * dstPixelBytes) + packAlignment - 1) / packAlignment * packAlignment;
@@ -4894,7 +4899,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// resets its counter state, because those bytes describe the previous owner's span.
Uint32 VulkanRenderer::CurrentXfbCounterSlot() {
constexpr Uint32 kNoSlot = static_cast<Uint32>(kXfbCounterObjectSlots);
const Uint64 identity = MG_Pipe::gPipeInputs.GetBoundTransformFeedbackLifetimeId();
const Uint64 identity = MG_Pipe::gPipeInputs->GetBoundTransformFeedbackLifetimeId();
MOBILEGL_ASSERT(identity != 0,
"transform feedback object reported the free-slot sentinel (0) as its identity - "
"every slot would then read as 'mine' without ever being claimed");
@@ -4943,14 +4948,14 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
Bool VulkanRenderer::BeginXfbCaptureForDraw(FrameContext::FrameData& frame) {
if (!m_transformFeedbackFeatureEnabled || !MG_Pipe::gPipeInputs.IsLive() ||
!MG_Pipe::gPipeInputs.IsTransformFeedbackActive()) {
if (!m_transformFeedbackFeatureEnabled || !MG_Pipe::gPipeInputs->IsLive() ||
!MG_Pipe::gPipeInputs->IsTransformFeedbackActive()) {
return false;
}
// A paused span captures nothing, and the counter buffers keep their values, so the
// next resumed draw appends exactly where the last captured one stopped - which is
// what pause/resume means (ARB_transform_feedback2).
if (MG_Pipe::gPipeInputs.IsTransformFeedbackPaused()) {
if (MG_Pipe::gPipeInputs->IsTransformFeedbackPaused()) {
return false;
}
// The bound pipeline's last pre-rasterization stage has to have been declared with Xfb
@@ -4993,7 +4998,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
const Uint32 counterSlot = CurrentXfbCounterSlot();
const Uint64 generation = MG_Pipe::gPipeInputs.GetTransformFeedbackGeneration();
const Uint64 generation = MG_Pipe::gPipeInputs->GetTransformFeedbackGeneration();
const Bool resume = m_xfbCountersValid[counterSlot] && m_xfbLastSeenGeneration[counterSlot] == generation;
m_xfbLastSeenGeneration[counterSlot] = generation;
@@ -5667,7 +5672,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
default: break;
}
if (mergeGranularity != 0) {
const RenderStateParameters& rsp = MG_Pipe::gPipeInputs.GetRenderStateParameters();
const RenderStateParameters& rsp = MG_Pipe::gPipeInputs->GetRenderStateParameters();
if (rsp.PrimitiveRestartEnabled || rsp.PrimitiveRestartFixedIndexEnabled) {
mergeGranularity = 0;
}
@@ -6116,7 +6121,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
m_completedSubmitCounter = m_submitCounter;
}
Bool VulkanRenderer::SubmitPendingCommandBuffer(FrameContext::FrameData& frame, VkFence fence, Bool pooledFence) {
Bool VulkanRenderer::SubmitPendingCommandBuffer(FrameContext::FrameData& frame, VkFence fence, Bool pooledFence,
Bool waitAcquire) {
RetireWireDrawPass();
// Batched texture uploads must reach the queue before the frame's
// commands: the recording being submitted may sample images whose
@@ -6124,10 +6130,15 @@ namespace MobileGL::MG_Backend::DirectVulkan {
if (m_textureManager) {
m_textureManager->FlushPendingUploads();
}
VkPipelineStageFlags waitDstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
VkPipelineStageFlags waitDstStageMask = FrameContext::kAcquireWaitStages;
VkSemaphore waitSemaphore = frame.imageAvailableSemaphore;
VkSubmitInfo submitInfo{VK_STRUCTURE_TYPE_SUBMIT_INFO};
if (!frame.imageAvailableSemaphoreConsumed) {
// A recording that never touched the acquired image does not wait for its release: on a
// queue that runs submissions in order, that wait would hold this work, and everything
// after it, until the display lets go of the image (SubmitAheadOfAcquiredImage).
const Bool waitsAcquire =
!frame.imageAvailableSemaphoreConsumed && (frame.acquiredImageReferenced || waitAcquire);
if (waitsAcquire) {
submitInfo.waitSemaphoreCount = 1;
submitInfo.pWaitSemaphores = &waitSemaphore;
submitInfo.pWaitDstStageMask = &waitDstStageMask;
@@ -6161,7 +6172,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
MGLOG_E_ONCE("SubmitPendingCommandBuffer: vkQueueSubmit returned %d", result);
return false;
}
frame.imageAvailableSemaphoreConsumed = true;
if (waitsAcquire) frame.imageAvailableSemaphoreConsumed = true;
frame.hasCommandBufferRecorded = false;
frame.hasPreCommandBufferRecorded = false;
RegisterSubmit(fence, pooledFence);
@@ -6239,6 +6250,25 @@ namespace MobileGL::MG_Backend::DirectVulkan {
return true;
}
void VulkanRenderer::SubmitAheadOfAcquiredImage() {
if (m_frameContext.GetFrameCount() == 0) return;
auto& frame = m_frameContext.GetCurrent();
if (frame.imageAvailableSemaphoreConsumed || frame.acquiredImageReferenced) return;
if (m_swapchainObject.GetHandle() == VK_NULL_HANDLE || m_presentSuspended) return;
// The frame's work so far renders off screen. Submitted together with the window pass it
// would wait behind the acquire semaphore, which signals only when the display releases
// the image - about every other frame that is the image it has just stopped scanning out,
// so the whole frame's GPU work started after the next display commit. Submitted now it
// runs while the display still holds the image. A failed flush leaves the work recorded,
// and it goes out later with the wait, as before. Inside a draw's preparation nothing is
// submitted (the draw may already hold state of the open recording); the image is only
// marked, so the submission that carries the use still waits.
if (m_wirePreparationDepth == 0 && HasPendingRecordedWork() && FlushPendingCommands())
MGLOG_I_ONCE("DirectVulkan: a frame's off-screen work goes to the queue ahead of its window pass; only "
"the submission that uses the swapchain image waits for its acquire");
frame.acquiredImageReferenced = true;
}
void VulkanRenderer::NoteDeviceLoss(VkResult result, const char* where) {
if (result != VK_ERROR_DEVICE_LOST || m_deviceLost) return;
m_deviceLost = true;
@@ -6428,8 +6458,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
if (!m_provokingVertexModePerPipeline) {
return VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT;
}
return (MG_Pipe::gPipeInputs.IsLive() &&
MG_Pipe::gPipeInputs.GetProvokingVertexMode() == ProvokingVertexMode::FirstVertex)
return (MG_Pipe::gPipeInputs->IsLive() &&
MG_Pipe::gPipeInputs->GetProvokingVertexMode() == ProvokingVertexMode::FirstVertex)
? VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT
: VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT;
}
@@ -6555,6 +6585,9 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
MOBILEGL_ASSERT(m_imageIndexAcquired < m_swapchainObject.GetImageCount(),
"Present, acquired image index out of range");
// A frame that never drew into the window still presents its image: what it recorded
// goes out first, unwaited, and the present's own submission waits for the release.
SubmitAheadOfAcquiredImage();
// A real presented frame is the canonical aging cadence; mid-frame drains
// count against this and only age when presents stop coming.
m_drainsSinceLastPresent = 0;
@@ -8477,7 +8510,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
m_swapchainObject.Create(m_device, m_physicalDevice.handle, m_surface,
static_cast<Uint32>(m_physicalDevice.queueFamilies.graphicsFamily),
static_cast<Uint32>(m_physicalDevice.queueFamilies.presentFamily),
m_config.MaxFramesInFlight, desiredExtent, m_config.SwapInterval);
m_config.MaxFramesInFlight, MG_Config::Features.MagmaExtraSwapchainImages,
desiredExtent, m_config.SwapInterval);
if (m_config.SwapInterval && m_config.SwapInterval != m_swapchainSwapInterval) {
MGLOG_D("DirectVulkan: swap interval %d -> %s", *m_config.SwapInterval,
SwapchainObject::GetPresentModeName(m_swapchainObject.GetPresentMode()));
@@ -9020,7 +9054,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
if (m_swapchainObject.GetHandle() != VK_NULL_HANDLE && !m_presentSuspended &&
!frame.imageAvailableSemaphoreConsumed) {
const VkFence fence = AcquirePooledSubmitFence();
if (fence == VK_NULL_HANDLE || !SubmitPendingCommandBuffer(frame, fence, /*pooledFence=*/true)) {
if (fence == VK_NULL_HANDLE ||
!SubmitPendingCommandBuffer(frame, fence, /*pooledFence=*/true, /*waitAcquire=*/true)) {
MGLOG_E("DirectVulkan: a parked surface's pending acquire could not be waited out");
}
}
@@ -976,12 +976,18 @@ namespace MobileGL::MG_Backend::DirectVulkan {
// vkWaitForFences inline before returning.
void RegisterSubmit(VkFence fence, Bool pooledFence);
// Builds the submit packet for the frame's pending command buffer
// (consuming the acquire semaphore on the slot's first submission),
// (consuming the acquire semaphore on the first submission that
// references the acquired image, or on any when `waitAcquire`),
// submits it with `fence`, and registers the submission. On failure
// the frame state is left untouched. Shared by the mid-frame flush
// and the readback path so the semaphore-consumption invariant lives
// in one place.
Bool SubmitPendingCommandBuffer(FrameContext::FrameData& frame, VkFence fence, Bool pooledFence);
Bool SubmitPendingCommandBuffer(FrameContext::FrameData& frame, VkFence fence, Bool pooledFence,
Bool waitAcquire = false);
// Called before the frame first references the acquired swapchain image: submits what is
// recorded so far WITHOUT the acquire wait, then marks the recording as referencing the
// image, so only the window pass waits for the presentation engine's release.
void SubmitAheadOfAcquiredImage();
// Polls in-flight submission fences (prefix order) and advances the
// completed counter past every fence observed signaled.
void RefreshCompletedSubmits();
@@ -238,7 +238,7 @@
// Mip generation samples and writes the texture's own color space;
// GL_FRAMEBUFFER_SRGB only controls framebuffer operations.
if (!mipmap) destination.format = ResolveSrgbAttachmentWriteFormat(destination.format,
MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::FramebufferSrgb));
MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::FramebufferSrgb));
VkFormatProperties destinationProperties{};
vkGetPhysicalDeviceFormatProperties(m_physicalDevice.handle, destination.format, &destinationProperties);
if (!(destinationProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) return false;
@@ -248,7 +248,7 @@
!(memo.drawFramebuffer == st.BoundFramebuffer[SizeT(MG_Pipe::MGPipeFramebufferTarget::Draw)]) ||
memo.textureImageEpoch != m_textureManager->GetTextureImageEpoch() ||
memo.resourceEraseEpoch != m_textureManager->GetResourceEraseEpoch() ||
memo.framebufferSrgb != MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::FramebufferSrgb))
memo.framebufferSrgb != MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::FramebufferSrgb))
return false;
// The resources are good while the erase epoch holds. Each must still be what the walk
// left: in GENERAL and synced to its record's serial with nothing pending.
@@ -300,7 +300,7 @@
auto& passKey = scratch.passKey;
passKey.ResetKeepingCapacity();
passKey.isDefault = fbo.IsDefault;
passKey.framebufferSrgb = MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::FramebufferSrgb);
passKey.framebufferSrgb = MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::FramebufferSrgb);
if (fbo.IsDefault) {
passKey.swapchain = m_swapchainObject.GetHandle();
// A drawing pass on the default framebuffer is what makes the freshly acquired
@@ -326,7 +326,7 @@
{image.resource, image.storage, surface.Kind == MG_Pipe::kMGPipeSurfaceKindRenderbuffer});
if (aspect == VK_IMAGE_ASPECT_COLOR_BIT)
image.format = ResolveSrgbAttachmentWriteFormat(image.format,
MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::FramebufferSrgb));
MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::FramebufferSrgb));
const VkImageLayout layout = aspect == VK_IMAGE_ASPECT_COLOR_BIT ?
VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_GENERAL;
// Already in its attachment layout: its barrier (which closes any open pass) waits until
@@ -470,7 +470,7 @@
memo.drawFramebuffer = st.BoundFramebuffer[SizeT(MG_Pipe::MGPipeFramebufferTarget::Draw)];
memo.textureImageEpoch = m_textureManager->GetTextureImageEpoch();
memo.resourceEraseEpoch = m_textureManager->GetResourceEraseEpoch();
memo.framebufferSrgb = MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::FramebufferSrgb);
memo.framebufferSrgb = MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::FramebufferSrgb);
memo.passHash = m_wireDrawPass->hash;
memo.marks.assign(scratch.gpuWriteMarks.begin(), scratch.gpuWriteMarks.end());
}
@@ -522,7 +522,7 @@
ProgramFactory::CompileOptionFlags flags =
ProgramFactory::CompileOptionFlags(GetBaseTransformFlagsRaw(fbo->IsDefault));
if (m_transformFeedbackFeatureEnabled && MG_Pipe::gPipeInputs.IsTransformFeedbackActive() &&
if (m_transformFeedbackFeatureEnabled && MG_Pipe::gPipeInputs->IsTransformFeedbackActive() &&
program.GetTransformFeedbackVaryingCount() > 0)
flags |= ProgramFactory::CompileOptionBit::XfbCapture;
const auto* programObject = &m_programFactory->GetOrCreateProgram(program, flags);
@@ -727,7 +727,7 @@
return false;
}
indexType = width == 4 ? VK_INDEX_TYPE_UINT32 : width == 2 ? VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT8;
const auto& restart = MG_Pipe::gPipeInputs.GetRenderStateParameters();
const auto& restart = MG_Pipe::gPipeInputs->GetRenderStateParameters();
const Uint32 fixed = MG_Util::FixedRestartIndexForGLType(indices->indexType);
const Bool replaceRestart = restart.PrimitiveRestartEnabled && !restart.PrimitiveRestartFixedIndexEnabled &&
restart.PrimitiveRestartIndex < fixed;
@@ -864,7 +864,7 @@
VkFormat format = VK_FORMAT_UNDEFINED;
const void* data = nullptr;
VkDeviceSize size = 0;
if (!TryGetCurrentVertexAttributeUploadPayload(MG_Pipe::gPipeInputs.GetCurrentVertexAttribute(location),
if (!TryGetCurrentVertexAttributeUploadPayload(MG_Pipe::gPipeInputs->GetCurrentVertexAttribute(location),
programObj.vertexInputTypes[location], format, data, size)) {
MGL_WIRE_DECLINE_AT(CurrentAttributePayload, "a disabled array's current attribute value has no upload payload");
return false;
@@ -987,7 +987,7 @@
const Int32 attachment = fbo.DrawBuffers[i];
if (attachment < 0 || attachment >= static_cast<Int32>(MG_Pipe::kMGPipeMaxColorAttachments)) continue;
if (!fbo.IsDefault && fbo.Color[attachment].Kind == MG_Pipe::kMGPipeSurfaceKindNone) continue;
const auto mask = MG_Pipe::gPipeInputs.GetColorMaskIndexed(i);
const auto mask = MG_Pipe::gPipeInputs->GetColorMaskIndexed(i);
if (!mask.r() && !mask.g() && !mask.b() && !mask.a()) continue;
if (!mask.r() || !mask.g() || !mask.b() || !mask.a()) { all = false; break; }
if (i >= key.colorReferences.size() || key.colorReferences[i] == VK_ATTACHMENT_UNUSED ||
@@ -1007,7 +1007,7 @@
: nullptr;
VkImageAspectFlags depthStencilAspects = 0;
if (remaining & GL_DEPTH_BUFFER_BIT) {
if (!MG_Pipe::gPipeInputs.GetDepthMask()) {
if (!MG_Pipe::gPipeInputs->GetDepthMask()) {
handled |= GL_DEPTH_BUFFER_BIT; // nothing to write, as on the standalone path
} else if (!fbo.IsDefault && fbo.Depth.Kind == MG_Pipe::kMGPipeSurfaceKindNone) {
handled |= GL_DEPTH_BUFFER_BIT; // no depth surface: nothing to clear
@@ -1018,7 +1018,7 @@
}
}
if (remaining & GL_STENCIL_BUFFER_BIT) {
const Uint32 mask = MG_Pipe::gPipeInputs.GetStencilState(StencilFace::Front).WriteMask & 255u;
const Uint32 mask = MG_Pipe::gPipeInputs->GetStencilState(StencilFace::Front).WriteMask & 255u;
if (mask == 0) {
handled |= GL_STENCIL_BUFFER_BIT;
} else if (!fbo.IsDefault && fbo.Stencil.Kind == MG_Pipe::kMGPipeSurfaceKindNone) {
@@ -1047,7 +1047,7 @@
VkRect2D area{{0, 0}, {key.width, key.height}};
if (GLScissorTestClips()) {
const auto& box = MG_Pipe::gPipeInputs.GetScissorBox();
const auto& box = MG_Pipe::gPipeInputs->GetScissorBox();
const Int32 x0 = std::max(box.x(), 0), y0 = std::max(box.y(), 0);
const Int32 x1 = std::min(box.x() + box.z(), static_cast<Int32>(key.width));
const Int32 y1 = std::min(box.y() + box.w(), static_cast<Int32>(key.height));
@@ -133,6 +133,9 @@
out.swapchainImageIndex = isWriteTarget ? DefaultFramebufferWriteIndex(true)
: DefaultFramebufferReadIndex(true);
if (aspect == VK_IMAGE_ASPECT_COLOR_BIT) {
// Every use of the acquired image is reached through here, ahead of its commands:
// the work recorded before it goes out without the acquire wait.
if (out.swapchainImageIndex == m_imageIndexAcquired) SubmitAheadOfAcquiredImage();
out.image = m_swapchainObject.GetImage(out.swapchainImageIndex);
out.format = m_swapchainObject.GetSurfaceFormat().format;
out.layout = m_swapchainObject.GetImageLayout(out.swapchainImageIndex);
@@ -201,6 +204,12 @@
VkPipelineStageFlags stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
VkAccessFlags access = 0;
GetImageTransitionSourceState(image.layout, stage, access);
// A swapchain image leaves PRESENT_SRC_KHR (or UNDEFINED, new) only after it was acquired:
// the transition is ordered after the presentation engine's release through the stages
// the acquire wait blocks, which an empty (TOP_OF_PIPE) source scope would not chain to.
if (image.isDefault && image.aspect == VK_IMAGE_ASPECT_COLOR_BIT &&
(image.layout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR || image.layout == VK_IMAGE_LAYOUT_UNDEFINED))
stage |= FrameContext::kAcquireWaitStages;
// One tracked layout per image: move the complete mip chain, never just the surface.
VkImageAspectFlags barrierAspect = image.aspect;
// Every packed format, D16_UNORM_S8_UINT included (g5-msrbo review round): the layout is
@@ -370,7 +379,7 @@
const Uint64 passHash = active->hash;
VkRect2D area{{0, 0}, {key.width, key.height}};
if (GLScissorTestClips()) {
const auto& box = MG_Pipe::gPipeInputs.GetScissorBox();
const auto& box = MG_Pipe::gPipeInputs->GetScissorBox();
const Int32 x0 = std::max(box.x(), 0), y0 = std::max(box.y(), 0);
const Int32 x1 = std::min(box.x() + box.z(), static_cast<Int32>(key.width));
const Int32 y1 = std::min(box.y() + box.w(), static_cast<Int32>(key.height));
@@ -394,7 +403,7 @@
const Int32 slot = fbo.DrawBuffers[i];
if (slot < 0 || slot >= static_cast<Int32>(MG_Pipe::kMGPipeMaxColorAttachments)) continue;
if (fbo.Color[slot].Kind == MG_Pipe::kMGPipeSurfaceKindNone) continue;
const auto mask = MG_Pipe::gPipeInputs.GetColorMaskIndexed(i);
const auto mask = MG_Pipe::gPipeInputs->GetColorMaskIndexed(i);
if (!mask.r() && !mask.g() && !mask.b() && !mask.a()) continue;
if (!mask.r() || !mask.g() || !mask.b() || !mask.a() || payload.colorEncoding != ClearColorEncoding::Float) {
all = false;
@@ -429,7 +438,7 @@
(key.attachments[key.depthReference].aspect & aspect) != 0;
};
if (remaining & GL_DEPTH_BUFFER_BIT) {
if (!MG_Pipe::gPipeInputs.GetDepthMask() || fbo.Depth.Kind == MG_Pipe::kMGPipeSurfaceKindNone) {
if (!MG_Pipe::gPipeInputs->GetDepthMask() || fbo.Depth.Kind == MG_Pipe::kMGPipeSurfaceKindNone) {
handled |= GL_DEPTH_BUFFER_BIT;
} else if (depthStencilHeld(fbo.Depth, VK_IMAGE_ASPECT_DEPTH_BIT)) {
depthStencilAspects |= VK_IMAGE_ASPECT_DEPTH_BIT;
@@ -437,7 +446,7 @@
}
}
if (remaining & GL_STENCIL_BUFFER_BIT) {
const Uint32 mask = MG_Pipe::gPipeInputs.GetStencilState(StencilFace::Front).WriteMask & 255u;
const Uint32 mask = MG_Pipe::gPipeInputs->GetStencilState(StencilFace::Front).WriteMask & 255u;
if (mask == 0 || fbo.Stencil.Kind == MG_Pipe::kMGPipeSurfaceKindNone) {
handled |= GL_STENCIL_BUFFER_BIT;
} else if (mask == 255u && depthStencilHeld(fbo.Stencil, VK_IMAGE_ASPECT_STENCIL_BIT)) {
@@ -472,7 +481,7 @@
const Bool scissor = GLScissorTestClips();
const auto wholeImage = [&](const WireImage& image) {
if (!scissor) return true;
const auto& box = MG_Pipe::gPipeInputs.GetScissorBox();
const auto& box = MG_Pipe::gPipeInputs->GetScissorBox();
return box.x() <= 0 && box.y() <= 0 && box.x() + box.z() >= static_cast<Int32>(image.extent.width) &&
box.y() + box.w() >= static_cast<Int32>(image.extent.height);
};
@@ -498,7 +507,7 @@
if (slot < 0 || slot >= static_cast<Int32>(MG_Pipe::kMGPipeMaxColorAttachments)) continue;
const auto& surface = fbo.Color[slot];
if (surface.Kind == MG_Pipe::kMGPipeSurfaceKindNone) continue;
const auto mask = MG_Pipe::gPipeInputs.GetColorMaskIndexed(i);
const auto mask = MG_Pipe::gPipeInputs->GetColorMaskIndexed(i);
if (!mask.r() && !mask.g() && !mask.b() && !mask.a()) continue;
if (!mask.r() || !mask.g() || !mask.b() || !mask.a()) {
all = false;
@@ -538,13 +547,13 @@
return true;
};
if (remaining & GL_DEPTH_BUFFER_BIT) {
if (!MG_Pipe::gPipeInputs.GetDepthMask() || fbo.Depth.Kind == MG_Pipe::kMGPipeSurfaceKindNone)
if (!MG_Pipe::gPipeInputs->GetDepthMask() || fbo.Depth.Kind == MG_Pipe::kMGPipeSurfaceKindNone)
handled |= GL_DEPTH_BUFFER_BIT;
else if (depthStencil(fbo.Depth, VK_IMAGE_ASPECT_DEPTH_BIT))
handled |= GL_DEPTH_BUFFER_BIT;
}
if (remaining & GL_STENCIL_BUFFER_BIT) {
const Uint32 mask = MG_Pipe::gPipeInputs.GetStencilState(StencilFace::Front).WriteMask & 255u;
const Uint32 mask = MG_Pipe::gPipeInputs->GetStencilState(StencilFace::Front).WriteMask & 255u;
if (mask == 0 || fbo.Stencil.Kind == MG_Pipe::kMGPipeSurfaceKindNone)
handled |= GL_STENCIL_BUFFER_BIT;
else if (mask == 255u && depthStencil(fbo.Stencil, VK_IMAGE_ASPECT_STENCIL_BIT))
@@ -564,7 +573,10 @@
void VulkanRenderer::ClearWireFramebuffer(const MG_Pipe::MGPFramebufferState& fbo,
const ClearAttachmentPayload& clearRequest, GLint drawbuffer) {
if (MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::RasterizerDiscard)) return;
if (MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::RasterizerDiscard)) return;
// A clear of the window: the frame's work so far goes out ahead of the acquire wait, before
// any of the clear's paths (in-pass, deferred, standalone) records or resolves anything.
if (fbo.IsDefault) SubmitAheadOfAcquiredImage();
// P15 S0: what the draw pass can take is cleared inside it (ClearWireFramebufferInPass,
// WireDraw.inc); only the buffers it hands back take the standalone pass below.
// P15: in the open pass when it is this framebuffer's (the in-pass clear) or merely holds
@@ -586,12 +598,12 @@
if (m_wireRetiredObjects.size() >= kRetiredObjectsBeforeSubmit && m_wirePreparationDepth == 0 &&
HasPendingRecordedWork())
(void)FlushPendingCommands();
if (MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::RasterizerDiscard)) return;
if (MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::RasterizerDiscard)) return;
const auto clearSurface = [&](const MG_Pipe::MGPSurface& surface, VkImageAspectFlags aspect,
Uint32 colorIndex) {
if (!fbo.IsDefault && surface.Kind == MG_Pipe::kMGPipeSurfaceKindNone) return;
if (aspect == VK_IMAGE_ASPECT_COLOR_BIT) {
const auto mask = MG_Pipe::gPipeInputs.GetColorMaskIndexed(colorIndex);
const auto mask = MG_Pipe::gPipeInputs->GetColorMaskIndexed(colorIndex);
if (!mask.r() && !mask.g() && !mask.b() && !mask.a()) return;
if (!mask.r() || !mask.g() || !mask.b() || !mask.a()) {
MGLOG_W_ONCE("DirectVulkan: glClear with a partial color mask is not supported");
@@ -599,10 +611,10 @@
}
}
if (aspect & VK_IMAGE_ASPECT_DEPTH_BIT) {
if (!MG_Pipe::gPipeInputs.GetDepthMask()) aspect &= ~VK_IMAGE_ASPECT_DEPTH_BIT;
if (!MG_Pipe::gPipeInputs->GetDepthMask()) aspect &= ~VK_IMAGE_ASPECT_DEPTH_BIT;
}
if (aspect & VK_IMAGE_ASPECT_STENCIL_BIT) {
const Uint32 mask = MG_Pipe::gPipeInputs.GetStencilState(StencilFace::Front).WriteMask & 255u;
const Uint32 mask = MG_Pipe::gPipeInputs->GetStencilState(StencilFace::Front).WriteMask & 255u;
if (!mask) aspect &= ~VK_IMAGE_ASPECT_STENCIL_BIT;
else if (mask != 255u) {
MGLOG_W_ONCE("DirectVulkan: glClear with a partial stencil write mask is not supported");
@@ -615,7 +627,7 @@
m_textureManager->FlushPendingUploads();
VkRect2D area{{0, 0}, image.extent};
if (GLScissorTestClips()) {
const auto& box = MG_Pipe::gPipeInputs.GetScissorBox();
const auto& box = MG_Pipe::gPipeInputs->GetScissorBox();
const Int32 x0 = std::max(box.x(), 0), y0 = std::max(box.y(), 0);
const Int32 x1 = std::min(box.x() + box.z(), static_cast<Int32>(image.extent.width));
const Int32 y1 = std::min(box.y() + box.w(), static_cast<Int32>(image.extent.height));
@@ -1264,7 +1276,7 @@
// The scissor test clips blit writes: intersect the destination rectangle with
// the scissor box and shrink the source proportionally.
if (GLScissorTestClips()) {
const IntVec4& scissor = MG_Pipe::gPipeInputs.GetScissorBox();
const IntVec4& scissor = MG_Pipe::gPipeInputs->GetScissorBox();
const auto clipAxis = [](GLint& d0, GLint& d1, GLint& s0, GLint& s1, GLint clipLo, GLint clipHi) -> Bool {
const Bool dstFlipped = d1 < d0;
GLint lo = dstFlipped ? d1 : d0;
+4 -4
View File
@@ -442,7 +442,7 @@ namespace MobileGL::MG_Pipe {
// D10: THE WIDER PREDICATE, and the narrow one was a latent crash rather than a missing
// optimisation. Gated on the REHEARSAL, this early-returned for the whole life of a
// spawn server - because that knob is off by default and nothing in the spawn shape
// turns it on - so the server's gPipeInputs.ContextIdentity() stayed nullptr forever.
// turns it on - so the server's gPipeInputs->ContextIdentity() stayed nullptr forever.
// DirectGLES' fb-slot memo compares that identity FIRST and with no generation, so a
// nullptr against its own nullptr initialiser reads as a CACHE HIT and hands out a slot
// that was never filled. `st` lands the named Fatal at that site; this is the gate that
@@ -596,12 +596,12 @@ namespace MobileGL::MG_Pipe {
// The seven carry no MGP_INPUT_CHECK at all (the declared exception argued at
// PipeInputs.h's F-class block), so freshness can never reach them and neither can the
// stamp's withdrawal. This is the only thing that puts them in `rsp`.
if (!gPipeInputs.ServerStampedVerb()) return;
if (!gPipeInputs->ServerStampedVerb()) return;
const auto ownership = MGPipeFieldOwnershipOf(field);
if (ownership == MGPipeFieldOwnership::kFatal)
MGPipeInputPoisonFatalForVerb(field, gPipeInputs.CurrentVerb());
MGPipeInputPoisonFatalForVerb(field, gPipeInputs->CurrentVerb());
if (ownership == MGPipeFieldOwnership::kBarrierPulled)
CountBarrierPull(field, gPipeInputs.CurrentVerb());
CountBarrierPull(field, gPipeInputs->CurrentVerb());
}
#endif // MOBILEGL_BUILD_RECORD_ARM && MOBILEGL_PIPE_POISON
+33 -7
View File
@@ -832,12 +832,18 @@ namespace MobileGL::MG_Pipe {
// have. Nothing about the block's contents changed; what changed is that the name resolves to
// the SESSION'S block on a thread that belongs to one.
//
// WHY A THREAD-LOCAL REFERENCE, AND NOT SOMETHING CLEVERER. gPipeInputs is spelled at ~380
// sites in MG_Backend/MG_Impl (they read `MG_Pipe::gPipeInputs.` directly since P13 retired the
// pull/push switch macro); a reference whose TARGET varies with the calling thread is the
// only shape that keeps all of them compiling and all of them correct. The cost is one TLS
// address computation per access site - not one per field, and with no guard: the reference is
// bound once per thread on its first use.
// WHY A THREAD-LOCAL SLOT, AND NOT SOMETHING CLEVERER. gPipeInputs is spelled at ~380
// sites in MG_Backend/MG_Impl (they read `MG_Pipe::gPipeInputs->` directly since P13 retired the
// pull/push switch macro); a name whose TARGET varies with the calling thread is the only
// shape that keeps all of them compiling and all of them correct.
//
// P15: A POINTER SLOT, NOT A REFERENCE. It used to be a `thread_local PipeInputs&` bound by a
// dynamic initializer, and a thread_local with a dynamic initializer is reached through its
// TLS init function, which tests two more thread_local guards on every read: three TLS
// address calls per access in a dlopen'ed library, at every API level. The slot below is
// constant-initialized and trivially destructible, so an access is one TLS address
// computation, a load and a null test; the binding itself is unchanged - once per thread, at
// its first use, through the same resolver.
//
// THE RESOLVER IS A HOOK because this header may not know about sessions (MG_Remote/Server
// owns them and includes THIS header, not the other way round). It is installed once by the
@@ -860,7 +866,27 @@ namespace MobileGL::MG_Pipe {
return gPipeInputsDefault;
}
inline thread_local PipeInputs& gPipeInputs = MGPipeServerInputsForCallingThread();
class PipeInputsThreadSlot {
public:
constexpr PipeInputsThreadSlot() = default;
PipeInputsThreadSlot(const PipeInputsThreadSlot&) = delete;
PipeInputsThreadSlot& operator=(const PipeInputsThreadSlot&) = delete;
// The block's address is `&*gPipeInputs`; the slot's own address names nothing.
void operator&() const = delete;
PipeInputs& Get() {
PipeInputs* bound = m_bound;
if (bound == nullptr) [[unlikely]] bound = m_bound = &MGPipeServerInputsForCallingThread();
return *bound;
}
PipeInputs* operator->() { return &Get(); }
PipeInputs& operator*() { return Get(); }
operator PipeInputs&() { return Get(); }
private:
PipeInputs* m_bound = nullptr;
};
inline constinit thread_local PipeInputsThreadSlot gPipeInputs;
#if MOBILEGL_BUILD_DISAGGREGATED
// ============================================================================
@@ -275,11 +275,11 @@ namespace MobileGL::MG_Record {
// Save the server-visible pack state, force neutral for the read, restore. Both go through
// the applier's own set_pixel_pack_state entry point (MGPipeApplySetPixelPackState writes
// gPipeInputs.m_pixelStore[0], which the backend's ReadPixels reads via
// gPipeInputs->m_pixelStore[0], which the backend's ReadPixels reads via
// gPipeInputs->GetPixelStoreParameters); the read is synchronous on this thread, so the window
// in which the pack state is neutral does not outlive the call.
const MG_Pipe::PixelStoreParameters savedPack =
MG_Pipe::gPipeInputs.GetPixelStoreParameters(/*isUnpack=*/false);
MG_Pipe::gPipeInputs->GetPixelStoreParameters(/*isUnpack=*/false);
// MG_Pipe owns the constant (MGPipeTypes.h): in a verify build the compare-at-read hook's
// oracle for the pack half inside this window is the same value, and a second hand-typed
// copy would drift without a build break.
@@ -566,7 +566,7 @@ namespace MobileGL::MG_Record {
// session child (false = latched, the verb declines); unarmed they still die.
Bool CheckUnitWindows(const MG_Pipe::MGPipeApplierState& st, const char* verb) {
if (st.SamplerViewCount == 0 && st.SamplerStateCount == 0) return true;
const Int maxTouched = MG_Pipe::gPipeInputs.GetMaxTouchedTextureUnit();
const Int maxTouched = MG_Pipe::gPipeInputs->GetMaxTouchedTextureUnit();
if (maxTouched < 0) return true;
const Uint32 required = static_cast<Uint32>(maxTouched) + 1u;
if (st.SamplerViewStart != 0 || st.SamplerViewCount < required) {
+3 -3
View File
@@ -671,7 +671,7 @@ namespace MobileGL::MG_Pipe {
}
void MGPipeVerifyReadHook(const PipeInputs& self, MGPipeInputField field, Uint index0, Uint index1) {
if (&self != &gPipeInputs || !g_verify.Enabled) return;
if (&self != &*gPipeInputs || !g_verify.Enabled) return;
const auto index = static_cast<SizeT>(field);
if (kMGPipeInputFieldSticky[index]) return;
// P13 W5: the monolith verb port applies records without a server stamp, and its readback
@@ -2256,7 +2256,7 @@ namespace MobileGL::MG_Pipe {
// static initialisation, by the translation unit that owns the forward.
const Bool kCompileEnvHookRegistered = [] {
MGPipeSetCompileEnvChangedHook([] {
if (gPipeInputs.IsLive()) gPipeInputs.InvalidateCompileEnv();
if (gPipeInputs->IsLive()) gPipeInputs->InvalidateCompileEnv();
});
return true;
}();
@@ -3134,7 +3134,7 @@ namespace MobileGL::MG_Pipe {
// GLContext's m_currentVertexAttributes hold exactly those, so the diff below is
// EMPTY on the one walk that must publish everything. The server's mirror is not
// default: MGPipeApplierReset() clears the CSO store and the residual block and
// leaves gPipeInputs.m_currentVertexAttribute holding the PREVIOUS context's
// leaves gPipeInputs->m_currentVertexAttribute holding the PREVIOUS context's
// defaults. So the InvalidateAll() a fresh context does to the set-hash
// suppressor would have been cancelled two lines later by this diff, and the one
// call P2 fully owns would publish nothing across a context change - exactly the
+45
View File
@@ -554,6 +554,8 @@ namespace MobileGL::MG_Pipe {
// F-2
// shutter: content x params x bind generation x programImages
// (lifetime id x link version x image unit version)
// bits 11-14 ALSO fire on the share group's twins of the aggregates they read, for
// a setter called through a sibling context (C8, after the dirty loop)
// ===========================================================================
// ---- the object-class bits 9..17 ----
@@ -752,6 +754,40 @@ namespace MobileGL::MG_Pipe {
}
m_lastMaxTextureUnit = maxTextureUnit;
// ---- bits 11..14 across contexts: the share clocks (C8) ----
// The aggregates bits 11-14 read are this context's, and a texture, renderbuffer or
// sampler changed through a SIBLING context bumps only the sibling's - so with nothing
// done here A's walk after B's glTexParameteri / glTexImage2D / glRenderbufferStorage
// fired none of the four and A recorded the stale framebuffer, view and sampler sets.
// The group keeps a twin of each aggregate, and each bit fires here on exactly the
// twins of what its own shutter reads above. An exact compare rather than one more
// MGPipeMixShutter for vaoChanged's reason: the four are small neighbouring counters.
// A single-context group skips the clocks behind one relaxed load; the first walk
// after a second context joins may fire the four once, which is the safe direction.
// The program bits need nothing of this: a program is a group object too, but its
// versions are read off the object itself, which every context sees move.
const auto& group = *ctx.GetShareGroup();
if (group.HasSeveralContexts()) {
using SharedClock = MG_State::GLState::ShareGroupState::SharedClock;
const SharedClocks clocks{group.ReadSharedClock(SharedClock::FramebufferAttachment),
group.ReadSharedClock(SharedClock::TextureContent),
group.ReadSharedClock(SharedClock::TextureParams),
group.ReadSharedClock(SharedClock::SamplingResolution)};
const Bool content = clocks.TextureContent != m_lastSharedClocks.TextureContent;
const Bool params = clocks.TextureParams != m_lastSharedClocks.TextureParams;
if (clocks.FramebufferAttachment != m_lastSharedClocks.FramebufferAttachment) {
dirty |= MGPipeDirtyBit(MGPipeDirty::NewFramebuffer);
}
if (content || params) {
dirty |= MGPipeDirtyBit(MGPipeDirty::NewSamplerViews) |
MGPipeDirtyBit(MGPipeDirty::NewShaderImages);
}
if (params || clocks.SamplingResolution != m_lastSharedClocks.SamplingResolution) {
dirty |= MGPipeDirtyBit(MGPipeDirty::NewSamplers);
}
m_lastSharedClocks = clocks;
}
// ---- bit 2: the PACK half of the pixel store, BitwiseEqual ----
const PixelStoreParameters pack = ctx.GetPixelStoreParameters(false);
if (!m_primed || std::memcmp(&pack, &m_pack, sizeof(pack)) != 0) {
@@ -806,6 +842,7 @@ namespace MobileGL::MG_Pipe {
m_lastVaoLifetime = 0;
m_lastVaoConfig = 0;
m_lastMaxTextureUnit = -1;
m_lastSharedClocks = SharedClocks{};
m_renderStateVersion.Reset();
m_pipelineStateVersion.Reset();
m_framebufferBind.Reset();
@@ -893,11 +930,19 @@ namespace MobileGL::MG_Pipe {
Float Outer[4];
Float Inner[2];
};
// The share group's four clocks as of this context's last walk (C8).
struct SharedClocks {
Uint64 FramebufferAttachment;
Uint64 TextureContent;
Uint64 TextureParams;
Uint64 SamplingResolution;
};
Uint64 m_lastPushed[kMGPipeDirtyCount]{};
Uint64 m_lastVaoLifetime = 0;
Uint32 m_lastVaoConfig = 0;
Int m_lastMaxTextureUnit = -1;
SharedClocks m_lastSharedClocks{};
MGPipeWidenedCounter m_renderStateVersion;
MGPipeWidenedCounter m_pipelineStateVersion;
// The draw framebuffer BINDING slot version, widened for the same reason: a Uint16
@@ -183,6 +183,8 @@ add_executable(MobileGLIntegrationTest
Scenarios/TextureParamsWithoutASamplerViewScenario.cpp
# P13 W3b: the GL-level successor of the borrowed-slot unit-memo probe.
Scenarios/DsaUpdateKeepsTheBoundUnitScenario.cpp
# C8: a shared object changed through a sibling context reaches the other's next draw.
Scenarios/SharedContextChangeScenario.cpp
Scenarios/TextureUploadShapeScenario.cpp
Scenarios/ObjectSubsystemControlScenario.cpp
Scenarios/P4aSeamAuditScenario.cpp
@@ -193,6 +195,8 @@ add_executable(MobileGLIntegrationTest
Scenarios/TriangleScenario.cpp
Scenarios/PersistentCoherentMapScenario.cpp
Scenarios/DefaultFramebufferAcrossSwapScenario.cpp
# P15 present wait: a frame's off-screen work is submitted ahead of its window pass.
Scenarios/WindowPassGateScenario.cpp
Scenarios/ScenarioIsolationScenario.cpp
Scenarios/UploadOrderScenario.cpp
Scenarios/PassOrderScenario.cpp
@@ -770,6 +774,10 @@ mgl_itest_join_environment(MGL_ITEST_VULKAN_PRIMGEN_REROUTE_ENVIRONMENT
${MGL_ITEST_VULKAN_ENV})
# The command-buffer draw budget pinned far below one frame's draws, with the log path for the
# split's latched MGLOG_I - the same arming reasoning as the two entries above.
mgl_itest_join_environment(MGL_ITEST_VULKAN_WINDOW_PASS_GATE_ENVIRONMENT
"MOBILEGL_BACKEND_TYPE=DirectVulkan" "MGITEST_WINDOW_PASS_GATE_LANE=1"
"MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/window-pass-gate.log"
${MGL_ITEST_VULKAN_ENV})
mgl_itest_join_environment(MGL_ITEST_VULKAN_SPLIT_RECORDING_ENVIRONMENT
"MOBILEGL_BACKEND_TYPE=DirectVulkan" "MOBILEGL_MAGMA_MAX_DRAWS_PER_COMMAND_BUFFER=64"
"MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/oversized-recording-split.log"
@@ -1116,6 +1124,22 @@ gtest_discover_tests(MobileGLIntegrationTest
ENVIRONMENT "${MGL_ITEST_VULKAN_SPLIT_RECORDING_ENVIRONMENT}"
)
# P15 present wait: WindowPassGateScenario with its arming assertion on. The ambient entries run
# its cases for the pixels; this one also reads the renderer's latched MGLOG_I back, which a
# renderer that submits each frame as one batch behind the acquire wait never writes. DirectVulkan
# only: Espryt's flush ahead of the window buffer needs a window surface, which this harness does
# not have. RESOURCE_LOCK for SplitRecording's reason: every case reads the lane's one log back.
gtest_discover_tests(MobileGLIntegrationTest
TEST_PREFIX "DirectVulkan.WindowPassGate."
TEST_FILTER "WindowPassGateScenario.*"
DISCOVERY_TIMEOUT 30
PROPERTIES
LABELS integration-gpu
TIMEOUT ${MGL_ITEST_TIMEOUT}
RESOURCE_LOCK window-pass-gate.log
ENVIRONMENT "${MGL_ITEST_VULKAN_WINDOW_PASS_GATE_ENVIRONMENT}"
)
# The packed16 copy scenarios again, with the 8-bit storage widening PINNED ON. The ambient
# registrations above cover the narrow storage - on every CI driver the widening's POST
# probe finds no field-order mirror, so Auto keeps the native 16-bit path - which means the
@@ -2994,6 +3018,9 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
# hand below (`DirectVulkan.<arm>.Oversized.`, `.SplitRecording64.`, `DirectVulkan.Split.DescPool.`),
# where the gated flavour and the per-arm exceptions live.
mgl_itest_register_split_arms("OversizedRecordingSplitScenario.*" "")
# P15 present wait: plain GL, pixel checks on every backend and arm (the frame shapes that
# split around the window pass); the arming assertion stays in DirectVulkan.WindowPassGate.
mgl_itest_register_split_arms("WindowPassGateScenario.*" "")
mgl_itest_register_split_arms("DescriptorPoolGrowthScenario.*" "")
# ---- P5b t2: the transform-feedback spans, the XFB object bind, the patch parameter -------
@@ -32,10 +32,10 @@ namespace MGITest {
out->peekAvailable = true;
out->roleSplitActive = MGP::MGPipeRoleSplitRehearsalActive();
MGP::PipeInputs& client = MGP::MGPipeClientInputs();
out->blocksDistinct = &client != &MGP::gPipeInputs;
out->blocksDistinct = &client != &*MGP::gPipeInputs;
out->clientSerial = client.FilledState().CurrentVerbSerial;
out->serverSerial = MGP::gPipeInputs.FilledState().CurrentVerbSerial;
out->serverIdentity = MGP::gPipeInputs.ContextIdentity();
out->serverSerial = MGP::gPipeInputs->FilledState().CurrentVerbSerial;
out->serverIdentity = MGP::gPipeInputs->ContextIdentity();
return true;
}
@@ -39,7 +39,7 @@ namespace MGITest {
// verb boundaries; the server block's moves only on a server verb stamp.
unsigned long long clientSerial = 0;
unsigned long long serverSerial = 0;
// gPipeInputs.ContextIdentity(): non-null once the server has stamped a verb boundary
// gPipeInputs->ContextIdentity(): non-null once the server has stamped a verb boundary
// under the rehearsal (CONTRACT-P5E §3.2's server-owned identity).
const void* serverIdentity = nullptr;
};
@@ -158,6 +158,7 @@ namespace MGITest {
void* display = nullptr;
void* surface = nullptr;
void* context = nullptr;
void* config = nullptr;
std::string renderer;
};
@@ -301,6 +302,7 @@ namespace MGITest {
out.display = display;
out.surface = surface;
out.context = context;
out.config = config;
out.renderer = reinterpret_cast<const char*>(renderer);
outReason.clear();
return 0;
@@ -605,6 +607,7 @@ namespace MGITest {
m_display = brought.display;
m_surface = brought.surface;
m_context = brought.context;
m_config = brought.config;
m_width = kSurfaceWidth;
m_height = kSurfaceHeight;
m_renderer = std::move(brought.renderer);
@@ -617,6 +620,27 @@ namespace MGITest {
++m_frameIndex;
}
void* HeadlessGL::CreateSharingContext() {
if (!m_usable) return nullptr;
const EGLint contextAttribs[] = {EGL_CONTEXT_MAJOR_VERSION, 3, EGL_CONTEXT_MINOR_VERSION, 3, EGL_NONE};
EGLContext context = eglCreateContext(static_cast<EGLDisplay>(m_display), static_cast<EGLConfig>(m_config),
static_cast<EGLContext>(m_context), contextAttribs);
return context == EGL_NO_CONTEXT ? nullptr : context;
}
bool HeadlessGL::MakeContextCurrent(void* context) {
if (!m_usable) return false;
EGLSurface surface = static_cast<EGLSurface>(m_surface);
return eglMakeCurrent(static_cast<EGLDisplay>(m_display), surface, surface,
static_cast<EGLContext>(context != nullptr ? context : m_context)) == EGL_TRUE;
}
void HeadlessGL::DestroySharingContext(void* context) {
if (!m_usable || context == nullptr) return;
MakeContextCurrent(nullptr);
eglDestroyContext(static_cast<EGLDisplay>(m_display), static_cast<EGLContext>(context));
}
void HeadlessGL::ShutDown() {
if (!m_usable) return;
EGLDisplay display = static_cast<EGLDisplay>(m_display);
@@ -139,6 +139,15 @@ namespace MGITest {
// destructor with no driver left underneath.
void ShutDown();
// A second context in the harness context's share group, for the scenarios that change a
// shared object through one context and draw with it through the other. It is made current
// on the harness surface; nullptr where EGL refuses one.
void* CreateSharingContext();
// nullptr makes the harness context current again.
bool MakeContextCurrent(void* context);
// Makes the harness context current, then destroys `context`.
void DestroySharingContext(void* context);
private:
HeadlessGL();
HeadlessGL(const HeadlessGL&) = delete;
@@ -156,6 +165,7 @@ namespace MGITest {
void* m_display = nullptr;
void* m_surface = nullptr;
void* m_context = nullptr;
void* m_config = nullptr;
};
// ---- the scenario vocabulary -------------------------------------------
@@ -100,6 +100,7 @@ set(MGL_P8A_AMBIENT_CASES
ResidentIndexScenario.*
SampleMaskScopeScenario.*
SampleVariablesScenario.*
SharedContextChangeScenario.*
SnormAttachmentScenario.*
SpirvShaderBinaryScenario.SpecializedModulesLinkAndRenderWithTheirConstantsApplied
SsboArrayDynamicIndexScenario.*
@@ -264,4 +264,38 @@ void main() {
<< "range untouched";
}
// The same partial SubData, but drained by the NEXT DISPATCH rather than by a readback: the
// counter buffer is ensured as a binding, which is the draw-time drain. DirectGLES renames a
// small store there - the whole store is rewritten from the host copy instead of the queued
// range being copied - and a store a shader wrote is exactly the one whose host copy is stale
// outside the range: offset 4 still holds the seed on the CPU side and the first dispatch's
// increments on the GPU. Renaming it would put the seed back and the second dispatch would
// count from there.
TEST_F(AtomicCounterScenario, APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour) {
if (!Ready() || IsSkipped()) return;
const GLuint zero = MakeCounterBuffer(0, {0u, 0u});
MakeCounterBuffer(1, {0u});
ASSERT_EQ(FirstGLError(), 0u);
Dispatch();
const unsigned int reseed = 4242u;
glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, zero);
glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(reseed), &reseed);
glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, 0);
ASSERT_EQ(FirstGLError(), 0u) << "re-seeding offset 0 raised a GL error";
Dispatch();
const std::vector<unsigned int> values = ReadCounters(zero, 2);
EXPECT_EQ(FirstGLError(), 0u);
EXPECT_EQ(values[0], reseed + kInvocations)
<< "offset 0 read back " << values[0] << "; the SubData did not reach the second dispatch";
EXPECT_EQ(values[1], 4 * kInvocations)
<< "offset 4 read back " << values[1] << "; " << 2 * kInvocations
<< " means the drain before the second dispatch rewrote the shader-written neighbour from the "
<< "stale host copy";
}
} // namespace MGITest
@@ -497,6 +497,63 @@ void main() {
// ---- a self-test of the assertions, not of MobileGL ------------------
//
// Inside ONE frame: draw, overwrite PART of the vertex buffer, draw again. This is the
// immediate-mode streaming shape (Minecraft rewrites a small per-format vertex buffer from
// offset 0 before every batch), and the first draw is still queued when the write lands -
// it must keep the bytes it was issued with. DirectGLES drains this partial range of a
// small store by renaming the whole store rather than copying the range, so this pins that
// the rename is an orphan the first draw survives and that it carries the bytes OUTSIDE
// the written range (the right quad's vertices) into the new storage.
TEST_F(CrossFrameBufferScenario, APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes) {
ASSERT_NO_FATAL_FAILURE(BuildScene(/*immutable=*/false));
for (int frame = 0; frame < kWarmupFrames; ++frame) {
BeginFrame();
DrawScene();
Gl().EndFrame();
}
// The left quad's four vertices moved onto the right half and turned blue: 80 of the
// buffer's 160 bytes.
std::vector<Vertex> moved = SceneVertices(/*leftQuadIsGreen=*/false);
for (int i = 0; i < kLeftQuadVertexCount; ++i) {
moved[i].x += 1.0f;
moved[i].r = 0.0f;
moved[i].g = 0.0f;
moved[i].b = 1.0f;
}
const GLsizeiptr leftQuadBytes = GLsizeiptr(kLeftQuadVertexCount * sizeof(Vertex));
ASSERT_LT(leftQuadBytes, m_vertexBytes) << "the write must be a partial range of the store";
BeginFrame();
DrawScene();
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
glBufferSubData(GL_ARRAY_BUFFER, 0, leftQuadBytes, moved.data());
glBindBuffer(GL_ARRAY_BUFFER, 0);
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "the partial SubData raised a GL error";
DrawScene();
const Image frame = ReadFrame();
Gl().EndFrame();
ExpectHalves(frame, "red", "blue",
"a draw queued before a partial SubData must keep its bytes, and the draw after it "
"must see the new ones");
// The next frame draws only from the rewritten store: the right quad's vertices
// (outside the written range) must have come along with the rename, so the second
// index set still reaches them.
BeginFrame();
glBindVertexArray(m_vao);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, m_indexBytes, kIndicesRightQuad);
glBindVertexArray(0);
DrawScene();
const Image next = ReadFrame();
Gl().EndFrame();
ExpectHalves(next, "black", "green",
"the bytes outside the partial write were lost when the store was rewritten");
EXPECT_EQ(FirstGLError(), GLenum(GL_NO_ERROR));
}
// Every case above leans on ExpectHalves. ExpectHalves used to sample the
// centre pixel of each half - two pixels for a 12288-pixel readback - and
// that is measurably too weak to stand behind a claim about buffer
@@ -0,0 +1,216 @@
// MobileGL - MobileGL/MG_IntegrationTest/Scenarios/SharedContextChangeScenario.cpp
// Copyright (c) 2026 MobileGL-Dev
// Licensed under the GNU Lesser General Public License v3.0:
// https://www.gnu.org/licenses/gpl-3.0.txt
// https://www.gnu.org/licenses/lgpl-3.0.txt
// SPDX-License-Identifier: LGPL-3.0-only
// End of Source File Header
//
// Scenario - A SHARED OBJECT CHANGED THROUGH ONE CONTEXT IS WHAT THE OTHER CONTEXT DRAWS WITH.
//
// Textures and renderbuffers belong to the share group (GL 4.6 core 5.1), so a change made
// through context B is the object context A sees, once B has finished and A has re-bound it
// (5.3.3's rule 4). The dirty walk's framebuffer and unit-set bits (11-14) used to shutter only on
// aggregates the change bumps on the context it is made THROUGH: B's glTexParameteri or
// glRenderbufferStorage moved nothing A's walk reads, A's re-bind of the same object is redundant
// and moves nothing either, and A went on recording the view set and framebuffer state from before
// the change. The share group's clocks (C8) are what A's walk now reads beside its own.
//
// Neither context draws between the change and the switch back, so the monolith's one tracker is
// still latched on A when A draws again - the shape where no context switch can rescue it.
#include <cstddef>
#include <string>
#include <vector>
#include "../Harness/HeadlessGL.h"
#include "../Harness/ScenarioFixture.h"
#ifdef GLAPI
#undef GLAPI
#endif
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glcorearb.h>
#undef GL_GLEXT_PROTOTYPES
namespace MGITest {
namespace {
constexpr int kFboSize = 32;
constexpr int kTexSize = 8;
constexpr int kSmallRenderbuffer = 8;
constexpr const char* kQuadVertexSource = R"(#version 330 core
void main() {
vec2 corner = vec2((gl_VertexID & 1) == 0 ? -1.0 : 1.0,
(gl_VertexID & 2) == 0 ? -1.0 : 1.0);
gl_Position = vec4(corner, 0.0, 1.0);
}
)";
// texelFetch: the point is WHETHER the texture is sampled, not how it is filtered.
constexpr const char* kSampleFragmentSource = R"(#version 330 core
uniform sampler2D u_tex;
out vec4 o_color;
void main() {
o_color = texelFetch(u_tex, ivec2(0, 0), 0);
}
)";
constexpr const char* kGreenFragmentSource = R"(#version 330 core
out vec4 o_color;
void main() {
o_color = vec4(0.0, 1.0, 0.0, 1.0);
}
)";
class SharedContextChangeScenario : public ScenarioTest {
protected:
void SetUp() override {
ScenarioTest::SetUp();
if (!Ready()) return;
glGenVertexArrays(1, &m_vao);
ASSERT_EQ(FirstGLError(), 0u) << "the scene setup raised a GL error";
}
void TearDown() override {
if (!Ready()) return;
if (m_sibling != nullptr) Gl().DestroySharingContext(m_sibling);
glBindVertexArray(0);
glUseProgram(0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
if (m_vao != 0) glDeleteVertexArrays(1, &m_vao);
ScenarioTest::TearDown();
}
// B, made current on the harness surface. Skips the case where EGL refuses one.
bool SwitchToSibling() {
if (m_sibling == nullptr) m_sibling = Gl().CreateSharingContext();
if (m_sibling == nullptr) return false;
return Gl().MakeContextCurrent(m_sibling);
}
static bool SwitchBack() { return Gl().MakeContextCurrent(nullptr); }
void DrawQuad(GLuint program) {
glBindVertexArray(m_vao);
glUseProgram(program);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
EXPECT_EQ(FirstGLError(), 0u) << "the draw raised a GL error";
}
GLuint m_vao = 0;
void* m_sibling = nullptr;
};
} // namespace
// Bit 12: the view of an incomplete texture is null, and B's filter write completes it.
TEST_F(SharedContextChangeScenario, ATextureCompletedThroughASharingContextIsSampledByTheOther) {
if (!Ready() || IsSkipped()) return;
std::string error;
const unsigned int program = CompileProgram(kQuadVertexSource, kSampleFragmentSource, &error);
ASSERT_NE(program, 0u) << error;
ColorFbo target = MakeColorFbo(kFboSize, kFboSize);
ASSERT_NE(target.fbo, 0u) << "could not create the render target";
// ONE level and no glTexParameteri, so MIN_FILTER keeps GL_NEAREST_MIPMAP_LINEAR and the
// texture is mipmap-incomplete: sampling it reads (0,0,0,1).
GLuint texture = 0;
glGenTextures(1, &texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
std::vector<unsigned char> green(static_cast<std::size_t>(kTexSize * kTexSize * 4), 0);
for (std::size_t i = 0; i < green.size(); i += 4) {
green[i + 1] = 255;
green[i + 3] = 255;
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, kTexSize, kTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, green.data());
glUseProgram(program);
glUniform1i(glGetUniformLocation(program, "u_tex"), 0);
ASSERT_EQ(FirstGLError(), 0u) << "defining the sampled texture raised a GL error";
BindFbo(target);
ClearTo(0.0f, 0.0f, 1.0f, 1.0f);
DrawQuad(program);
const Image incomplete = ReadPixels(kFboSize, kFboSize);
ASSERT_TRUE(RegionIsMostly(incomplete, 0, kFboSize - 1, 0, kFboSize - 1, "black", 0.0,
"an incomplete texture sampled through A"));
// B completes the texture and finishes, and draws nothing.
if (!SwitchToSibling()) GTEST_SKIP() << "EGL did not make a sharing context current";
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFinish();
ASSERT_EQ(FirstGLError(), 0u) << "completing the texture through B raised a GL error";
// A re-binds it (rule 4), which is the same binding and moves nothing on A.
ASSERT_TRUE(SwitchBack());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
BindFbo(target);
ClearTo(0.0f, 0.0f, 1.0f, 1.0f);
DrawQuad(program);
const Image complete = ReadPixels(kFboSize, kFboSize);
EXPECT_TRUE(RegionIsMostly(complete, 0, kFboSize - 1, 0, kFboSize - 1, "green", 0.0,
"the same texture through A after B completed it"))
<< "black means A still recorded the null view of the incomplete texture";
glBindTexture(GL_TEXTURE_2D, 0);
glDeleteTextures(1, &texture);
glDeleteProgram(program);
DestroyColorFbo(target);
}
// Bit 11: set_framebuffer_state inlines the attachment's extent, and B resizes it.
TEST_F(SharedContextChangeScenario, ARenderbufferResizedThroughASharingContextIsDrawnWhole) {
if (!Ready() || IsSkipped()) return;
std::string error;
const unsigned int program = CompileProgram(kQuadVertexSource, kGreenFragmentSource, &error);
ASSERT_NE(program, 0u) << error;
GLuint renderbuffer = 0;
glGenRenderbuffers(1, &renderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, kSmallRenderbuffer, kSmallRenderbuffer);
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer);
ASSERT_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE));
glViewport(0, 0, kSmallRenderbuffer, kSmallRenderbuffer);
ClearTo(0.0f, 0.0f, 1.0f, 1.0f);
const Image small = ReadPixels(kSmallRenderbuffer, kSmallRenderbuffer);
ASSERT_TRUE(RegionIsMostly(small, 0, kSmallRenderbuffer - 1, 0, kSmallRenderbuffer - 1, "blue", 0.0,
"the small renderbuffer through A"));
// B redefines the attached renderbuffer at four times the size, and draws nothing.
if (!SwitchToSibling()) GTEST_SKIP() << "EGL did not make a sharing context current";
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, kFboSize, kFboSize);
glFinish();
ASSERT_EQ(FirstGLError(), 0u) << "resizing the renderbuffer through B raised a GL error";
ASSERT_TRUE(SwitchBack());
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
ASSERT_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE));
glViewport(0, 0, kFboSize, kFboSize);
ClearTo(0.0f, 0.0f, 1.0f, 1.0f);
DrawQuad(program);
const Image whole = ReadPixels(kFboSize, kFboSize);
EXPECT_TRUE(RegionIsMostly(whole, 0, kFboSize - 1, 0, kFboSize - 1, "green", 0.0,
"the resized renderbuffer through A"))
<< "a corner left uncovered means A still recorded the renderbuffer's old extent";
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &fbo);
glDeleteRenderbuffers(1, &renderbuffer);
glDeleteProgram(program);
}
} // namespace MGITest
@@ -0,0 +1,303 @@
// MobileGL - MobileGL/MG_IntegrationTest/Scenarios/WindowPassGateScenario.cpp
// Copyright (c) 2025-2026 MobileGL-Dev
// Licensed under the GNU Lesser General Public License v3.0:
// https://www.gnu.org/licenses/gpl-3.0.txt
// https://www.gnu.org/licenses/lgpl-3.0.txt
// SPDX-License-Identifier: LGPL-3.0-only
// End of Source File Header
//
// Scenario - A FRAME'S OFF-SCREEN WORK GOES TO THE GPU AHEAD OF ITS WINDOW PASS, AND LOSES NOTHING.
//
// About every other frame on Android renders into the window buffer the display has only just
// released, whose release fence is still pending. A frame submitted as one batch put ALL of its
// GPU work behind that fence, so the frame's off-screen passes started only after the display's
// next commit (the P15 present-wait timeline). Now only the window pass waits:
//
// * DirectVulkan submits what a frame recorded before its first use of the acquired swapchain
// image WITHOUT the acquire semaphore, and the submission that uses the image (or the
// present's own) carries the wait (VulkanRenderer::SubmitAheadOfAcquiredImage);
// * DirectGLES flushes once per frame just before the first default-framebuffer use of a
// window surface (FlushAheadOfWindowBufferUse); the headless pbuffer here has no window
// buffer, so on DirectGLES these cases are the pixel control.
//
// The cases put the frame shapes that split around the window pass: off-screen work then a blit
// into the window, off-screen work then a draw that samples it into the window (Minecraft's
// shape), frames that never touch the window at all, and a readback of the window inside the
// frame. Every frame changes what it draws, so a window pass that ran ahead of the off-screen
// work it reads, or a frame that lost its off-screen half, shows up as the previous frame's
// colours. The DirectVulkan.WindowPassGate. entry also asserts the renderer's latched MGLOG_I:
// on a renderer that submits the frame in one piece it is the assertion that goes red.
#include <string>
#include "../Harness/HeadlessGL.h"
#include "../Harness/PipeStatsWindow.h"
#include "../Harness/ScenarioFixture.h"
#ifdef GLAPI
#undef GLAPI
#endif
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glcorearb.h>
#undef GL_GLEXT_PROTOTYPES
namespace MGITest {
namespace {
constexpr const char* kColorVS = R"(#version 330 core
in vec2 aPos;
in vec4 aColor;
out vec4 vColor;
void main() {
vColor = aColor;
gl_Position = vec4(aPos, 0.0, 1.0);
}
)";
constexpr const char* kColorFS = R"(#version 330 core
in vec4 vColor;
out vec4 o_color;
void main() { o_color = vColor; }
)";
// The window pass of Minecraft's frame: a full-screen draw that samples the off-screen target.
constexpr const char* kSampleVS = R"(#version 330 core
in vec2 aPos;
out vec2 vUv;
void main() {
vUv = aPos * 0.5 + 0.5;
gl_Position = vec4(aPos, 0.0, 1.0);
}
)";
constexpr const char* kSampleFS = R"(#version 330 core
uniform sampler2D uTex;
in vec2 vUv;
out vec4 o_color;
void main() { o_color = texture(uTex, vUv); }
)";
struct NamedColor {
float r, g, b;
const char* name;
};
// Saturated colours only: ColorName() names them exactly whatever the rounding.
constexpr NamedColor kCycle[] = {
{1.0f, 0.0f, 0.0f, "red"}, {0.0f, 1.0f, 0.0f, "green"}, {0.0f, 0.0f, 1.0f, "blue"},
{1.0f, 1.0f, 0.0f, "yellow"}, {1.0f, 1.0f, 1.0f, "white"},
};
constexpr int kCycleLength = static_cast<int>(sizeof(kCycle) / sizeof(kCycle[0]));
constexpr int kFrames = 7;
const NamedColor& Background(int frame) { return kCycle[frame % kCycleLength]; }
const NamedColor& Foreground(int frame) { return kCycle[(frame + 2) % kCycleLength]; }
// The NDC rectangle [x0, x1] x [y0, y1] in one colour; aPos at 0, aColor at 1.
void DrawRect(unsigned int program, float x0, float y0, float x1, float y1, const NamedColor& c) {
const float vertices[] = {
x0, y0, c.r, c.g, c.b, 1.0f, x1, y0, c.r, c.g, c.b, 1.0f,
x0, y1, c.r, c.g, c.b, 1.0f, x1, y1, c.r, c.g, c.b, 1.0f,
};
GLuint vao = 0, vbo = 0;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 6 * sizeof(float), nullptr);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 6 * sizeof(float), reinterpret_cast<void*>(2 * sizeof(float)));
glUseProgram(program);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glDeleteBuffers(1, &vbo);
glDeleteVertexArrays(1, &vao);
}
void DrawSampledFullScreen(unsigned int program, unsigned int texture) {
const float vertices[] = {-1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f};
GLuint vao = 0, vbo = 0;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), nullptr);
glUseProgram(program);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glUniform1i(glGetUniformLocation(program, "uTex"), 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindTexture(GL_TEXTURE_2D, 0);
glBindVertexArray(0);
glDeleteBuffers(1, &vbo);
glDeleteVertexArrays(1, &vao);
}
enum class WindowPass { Blit, SampledDraw };
class WindowPassGateScenario : public ScenarioTest {
protected:
void SetUp() override {
ScenarioTest::SetUp();
if (!Ready()) return;
// Before the case draws anything, so the arming line can only be this case's; ctest
// gives every case a process of its own and the renderer latches the line once.
m_logBefore = PipeStatsWindow::MarkLaneLog();
m_width = Gl().Width();
m_height = Gl().Height();
std::string error;
m_colorProgram = CompileProgram(kColorVS, kColorFS, &error);
ASSERT_NE(m_colorProgram, 0u) << error;
m_sampleProgram = CompileProgram(kSampleVS, kSampleFS, &error);
ASSERT_NE(m_sampleProgram, 0u) << error;
m_target = MakeColorFbo(m_width, m_height);
ASSERT_NE(m_target.fbo, 0u);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
}
void TearDown() override {
if (Ready()) {
glUseProgram(0);
BindDefaultFramebuffer();
if (m_colorProgram != 0) glDeleteProgram(m_colorProgram);
if (m_sampleProgram != 0) glDeleteProgram(m_sampleProgram);
if (m_target.fbo != 0) DestroyColorFbo(m_target);
}
ScenarioTest::TearDown();
}
// The off-screen half of frame `frame`: its background, and its foreground on the left half.
void RenderOffscreen(int frame) {
BindFbo(m_target);
const NamedColor& background = Background(frame);
ClearTo(background.r, background.g, background.b, 1.0f);
DrawRect(m_colorProgram, -1.0f, -1.0f, 0.0f, 1.0f, Foreground(frame));
}
void RenderWindowPass(WindowPass pass) {
if (pass == WindowPass::Blit) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_target.fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBlitFramebuffer(0, 0, m_width, m_height, 0, 0, m_width, m_height, GL_COLOR_BUFFER_BIT,
GL_NEAREST);
BindDefaultFramebuffer();
} else {
BindDefaultFramebuffer();
DrawSampledFullScreen(m_sampleProgram, m_target.texture);
}
}
// Frame `frame`'s picture in the bound READ framebuffer: its foreground on the left half,
// its background on the right. Two pixels in from the seam, which is where the halves meet.
::testing::AssertionResult HoldsFrame(const Image& image, int frame, const std::string& what) {
const int seam = m_width / 2;
auto left = RegionIsMostly(image, 0, seam - 3, 0, m_height - 1, Foreground(frame).name, 0.0,
what + ", left half (frame " + std::to_string(frame) + "'s foreground)");
if (!left) return left;
return RegionIsMostly(image, seam + 2, m_width - 1, 0, m_height - 1, Background(frame).name, 0.0,
what + ", right half (frame " + std::to_string(frame) + "'s background)");
}
// kFrames presented frames of the shape, then one more read back before its swap (a
// readback after the swap would touch an image already handed to the presentation engine).
void RunFramesThroughTheWindow(WindowPass pass) {
for (int frame = 0; frame < kFrames; ++frame) {
RenderOffscreen(frame);
RenderWindowPass(pass);
ASSERT_EQ(FirstGLError(), 0u) << "frame " << frame;
Gl().EndFrame();
}
RenderOffscreen(kFrames);
RenderWindowPass(pass);
EXPECT_TRUE(HoldsFrame(ReadPixels(m_width, m_height), kFrames, "the window after the presented frames"))
<< "the window pass did not show the off-screen work recorded ahead of it in the same frame";
EXPECT_EQ(FirstGLError(), 0u);
Gl().EndFrame();
}
// In the DirectVulkan.WindowPassGate. entry (DirectVulkan, a log of its own), a frame's
// off-screen work must have gone to the queue ahead of its window pass during this case.
void ExpectTheWindowPassWasGatedAlone() {
const bool armed = std::getenv("MGITEST_WINDOW_PASS_GATE_LANE") != nullptr &&
Gl().BackendName() == std::string("DirectVulkan") &&
!PipeStatsWindow::LibraryLogPath().empty();
RecordProperty("arming_checked", armed ? "yes" : "no");
if (!armed) return;
const std::string appended = PipeStatsWindow::ReadLaneLogSince(m_logBefore);
EXPECT_NE(appended.find("off-screen work goes to the queue ahead of its window pass"), std::string::npos)
<< "this case recorded off-screen work ahead of every window pass, but DirectVulkan never "
"reported submitting it ahead of the acquire wait: the whole frame still queues behind "
"the swapchain image's release (VulkanRenderer::SubmitAheadOfAcquiredImage). Log appended "
"by this case:\n"
<< appended;
}
PipeStatsWindow::LogMark m_logBefore{};
int m_width = 0;
int m_height = 0;
unsigned int m_colorProgram = 0;
unsigned int m_sampleProgram = 0;
ColorFbo m_target{};
};
} // namespace
TEST_F(WindowPassGateScenario, OffscreenWorkThenABlitIntoTheWindowEveryFrame) {
if (!Ready()) return;
RunFramesThroughTheWindow(WindowPass::Blit);
ExpectTheWindowPassWasGatedAlone();
}
TEST_F(WindowPassGateScenario, OffscreenWorkThenASampledDrawIntoTheWindowEveryFrame) {
if (!Ready()) return;
RunFramesThroughTheWindow(WindowPass::SampledDraw);
ExpectTheWindowPassWasGatedAlone();
}
// The present submits the whole frame's work on frames that never use the window, and its own
// submission then carries nothing but the wait. The window keeps working afterwards.
TEST_F(WindowPassGateScenario, FramesThatNeverTouchTheWindowStillPresent) {
if (!Ready()) return;
for (int frame = 0; frame < kFrames; ++frame) {
RenderOffscreen(frame);
ASSERT_EQ(FirstGLError(), 0u) << "frame " << frame;
Gl().EndFrame();
}
BindFbo(m_target);
EXPECT_TRUE(HoldsFrame(ReadPixels(m_width, m_height), kFrames - 1, "the off-screen target after the swaps"))
<< "off-screen work of a frame that never used the window did not execute";
RenderOffscreen(kFrames);
RenderWindowPass(WindowPass::SampledDraw);
EXPECT_TRUE(HoldsFrame(ReadPixels(m_width, m_height), kFrames, "the window in the frame after them"));
EXPECT_EQ(FirstGLError(), 0u);
Gl().EndFrame();
ExpectTheWindowPassWasGatedAlone();
}
// A readback of the window inside the frame: its submission uses the acquired image, so it waits
// for the acquire; the window pass's later work and the present must not wait for it again.
TEST_F(WindowPassGateScenario, AReadbackOfTheWindowInsideTheFrame) {
if (!Ready()) return;
for (int frame = 0; frame < kFrames; ++frame) {
RenderOffscreen(frame);
RenderWindowPass(frame % 2 == 0 ? WindowPass::Blit : WindowPass::SampledDraw);
EXPECT_TRUE(HoldsFrame(ReadPixels(m_width, m_height), frame, "the window read back inside its frame"));
// More window work after the readback, in a later submission of the same frame.
DrawRect(m_colorProgram, 0.0f, -1.0f, 1.0f, 1.0f, Foreground(frame));
EXPECT_TRUE(RegionIsMostly(ReadPixels(m_width, m_height), 0, m_width - 1, 0, m_height - 1,
Foreground(frame).name, 0.0, "the window painted over after its readback"));
ASSERT_EQ(FirstGLError(), 0u) << "frame " << frame;
Gl().EndFrame();
}
ExpectTheWindowPassWasGatedAlone();
}
} // namespace MGITest
+15 -13
View File
@@ -769,10 +769,14 @@ namespace MobileGL::MG_Pipe {
return groups;
}
thread_local MGPipeApplierState* t_applierCached = nullptr;
thread_local Uint64 t_applierCachedSession = 0;
thread_local Uint64 t_applierCachedContext = 0;
thread_local Uint64 t_applierCachedGeneration = 0;
// One block, so a hit is one TLS address computation rather than four (P15).
struct ApplierCache {
MGPipeApplierState* Applier = nullptr;
Uint64 Session = 0;
Uint64 Context = 0;
Uint64 Generation = 0;
};
constinit thread_local ApplierCache t_applierCache;
} // namespace
Uint64 MGPipeNextApplierSerialBase() {
@@ -804,19 +808,17 @@ namespace MobileGL::MG_Pipe {
MGPipeApplierKey key;
if (!resolve(&key)) return g_defaultApplier;
// THE FAST PATH, and the reason this is a cache rather than a lookup: this function is
// called from the backend per state read. A hit is three TLS loads, one atomic load and
// two compares; a miss is the registry, which only moves when a context is created,
// called from the backend per state read. A hit is one TLS block, one atomic load and
// the compares; a miss is the registry, which only moves when a context is created,
// destroyed or made current.
const Uint64 generation = g_applierRegistryGeneration.load(std::memory_order_acquire);
if (t_applierCached != nullptr && t_applierCachedGeneration == generation &&
t_applierCachedSession == key.SessionKey && t_applierCachedContext == key.ContextToken) {
return *t_applierCached;
ApplierCache& cache = t_applierCache;
if (cache.Applier != nullptr && cache.Generation == generation && cache.Session == key.SessionKey &&
cache.Context == key.ContextToken) {
return *cache.Applier;
}
MGPipeApplierState* const applier = FindApplierForKey(key);
t_applierCached = applier;
t_applierCachedSession = key.SessionKey;
t_applierCachedContext = key.ContextToken;
t_applierCachedGeneration = generation;
cache = {applier, key.SessionKey, key.ContextToken, generation};
return *applier;
}
+39 -2
View File
@@ -1377,6 +1377,8 @@ namespace MobileGL::MG_State {
GLContext::GLContext(SharedPtr<ShareGroupState> shareGroup)
: m_shareGroup(shareGroup ? Move(shareGroup) : MakeShared<ShareGroupState>()) {
// A second context in the group makes the dirty walk read the share clocks.
m_shareGroup->NoteContextAttached();
// The default transform feedback object (name 0) exists from the start of the context
// (GL 4.6 core 13.2.1), but nothing binds it, so nothing else would materialise it.
// Materialising it here is what lets GetBoundTransformFeedbackLifetimeId() be a plain
@@ -1653,8 +1655,43 @@ namespace MobileGL::MG_State {
} // namespace GLState
// Leak-at-exit storage; see GlobalObjects.cpp.
thread_local SharedPtr<GLState::GLContext> pGLContext;
constinit thread_local CurrentGLContextSlot pGLContext;
// The reference that keeps the calling thread's pGLContext alive (Core.h). Registered for
// destruction on the thread's first assignment. At thread exit it drops the reference first,
// with the slot still naming the context - what destroying the SharedPtr this used to be did
// - and then clears the slot, so no pointer outlives the context.
struct CurrentGLContextOwner {
SharedPtr<GLState::GLContext> context;
~CurrentGLContextOwner() {
context.reset();
pGLContext.m_context = nullptr;
}
};
namespace {
thread_local CurrentGLContextOwner tCurrentGLContextOwner;
}
const SharedPtr<GLState::GLContext>& CurrentGLContextSlot::Shared() const {
return tCurrentGLContextOwner.context;
}
SharedPtr<GLState::GLContext> CurrentGLContextSlot::Take() {
m_context = nullptr;
return Move(tCurrentGLContextOwner.context);
}
CurrentGLContextSlot& CurrentGLContextSlot::operator=(SharedPtr<GLState::GLContext> context) {
auto& owner = tCurrentGLContextOwner;
m_context = context.get();
// The old context's last reference may run destructors that read pGLContext: the slot
// already names the new one, as it did when this was a SharedPtr assignment.
SharedPtr<GLState::GLContext> previous = Move(owner.context);
owner.context = Move(context);
return *this;
}
#if MOBILEGL_BUILD_DISAGGREGATED
thread_local Bool tThreadReleasedLostContext = false;
constinit thread_local Bool tThreadReleasedLostContext = false;
#endif
} // namespace MobileGL::MG_State
+68 -6
View File
@@ -202,7 +202,10 @@ namespace MobileGL {
Uint64 GetSamplingResolutionGeneration() const {
return m_textureState.GetSamplingResolutionGeneration();
}
void BumpSamplingResolutionGeneration() { m_textureState.BumpSamplingResolutionGeneration(); }
void BumpSamplingResolutionGeneration() {
m_textureState.BumpSamplingResolutionGeneration();
m_shareGroup->BumpSharedClock(ShareGroupState::SharedClock::SamplingResolution);
}
// Never-reused id of this context, for backend memos keyed on the two counters
// above: both restart at 0 in a new context, and a recreated context can land on
// the old heap address. See TextureState::GetContextId.
@@ -276,15 +279,28 @@ namespace MobileGL {
Uint64 GetAnyVaoAttributeGeneration() const {
return m_vertexArrayState.GetAnyAttributeGeneration();
}
void NoteFramebufferAttachmentChanged() { m_framebufferState.NoteAttachmentChanged(); }
// The framebuffer and the two texture aggregates (and the sampling resolution
// generation above) also bump the share group's twin: the objects behind them are
// the group's, and a sibling context's walk has to see the change too
// (ShareGroupState's share clocks, C8).
void NoteFramebufferAttachmentChanged() {
m_framebufferState.NoteAttachmentChanged();
m_shareGroup->BumpSharedClock(ShareGroupState::SharedClock::FramebufferAttachment);
}
Uint64 GetAnyFramebufferAttachmentGeneration() const {
return m_framebufferState.GetAnyAttachmentGeneration();
}
void NoteTextureContentChanged() { m_textureState.NoteTextureContentChanged(); }
void NoteTextureContentChanged() {
m_textureState.NoteTextureContentChanged();
m_shareGroup->BumpSharedClock(ShareGroupState::SharedClock::TextureContent);
}
Uint64 GetAnyTextureContentGeneration() const {
return m_textureState.GetAnyTextureContentGeneration();
}
void NoteTextureParamsChanged() { m_textureState.NoteTextureParamsChanged(); }
void NoteTextureParamsChanged() {
m_textureState.NoteTextureParamsChanged();
m_shareGroup->BumpSharedClock(ShareGroupState::SharedClock::TextureParams);
}
Uint64 GetAnyTextureParamsGeneration() const {
return m_textureState.GetAnyTextureParamsGeneration();
}
@@ -766,7 +782,53 @@ namespace MobileGL {
// thread that never crossed an eglMakeCurrent keeps the process default MG_State::Init()
// gave it. NULL on a thread for which neither has happened, the same answer a process
// that never reached MG_State::Init() (the spawn server image) has always given.
extern thread_local SharedPtr<GLState::GLContext> pGLContext;
//
// P15: A PLAIN POINTER IN TLS, WITH THE OWNING REFERENCE KEPT BESIDE IT. Every GL entry
// point reads this, often several times. A thread_local with a destructor (the SharedPtr
// it used to be) is reached through its TLS init function, which tests a second
// thread_local guard first: two TLS address calls per read in a dlopen'ed library, at
// every API level. This object is trivially destructible and constant-initialized, so a
// read is one TLS address computation and a load. The SharedPtr that keeps the context
// alive lives in a separate thread_local in Core.cpp, written only by the assignments
// below (eglMakeCurrent and the release edge, MG_State::Init(), tests); at thread exit its
// destructor drops the reference and then clears this pointer, so no dangling pointer is
// left behind.
//
// Assignment, reset() and the SharedPtr conversions touch the owner and belong to the
// CALLING THREAD only: never assign through a reference to another thread's slot.
class CurrentGLContextSlot {
public:
constexpr CurrentGLContextSlot() = default;
CurrentGLContextSlot(const CurrentGLContextSlot&) = delete;
CurrentGLContextSlot& operator=(const CurrentGLContextSlot&) = delete;
GLState::GLContext* get() const { return m_context; }
GLState::GLContext* operator->() const { return m_context; }
GLState::GLContext& operator*() const { return *m_context; }
explicit operator bool() const { return m_context != nullptr; }
// The owning reference (cold: a second TLS read).
const SharedPtr<GLState::GLContext>& Shared() const;
operator const SharedPtr<GLState::GLContext>&() const& { return Shared(); }
// A move out of the slot is spelled Take(): std::move of the slot does not compile.
operator const SharedPtr<GLState::GLContext>&() const&& = delete;
SharedPtr<GLState::GLContext> Take();
CurrentGLContextSlot& operator=(SharedPtr<GLState::GLContext> context);
void reset() { *this = nullptr; }
friend Bool operator==(const CurrentGLContextSlot& slot, std::nullptr_t) {
return slot.m_context == nullptr;
}
friend Bool operator==(const CurrentGLContextSlot& slot, const SharedPtr<GLState::GLContext>& other) {
return slot.m_context == other.get();
}
private:
friend struct CurrentGLContextOwner;
GLState::GLContext* m_context = nullptr;
};
extern constinit thread_local CurrentGLContextSlot pGLContext;
#if MOBILEGL_BUILD_DISAGGREGATED
// True on a thread whose last EGL release let go of a context lost with an ended server
// session, until it makes a context current again. The release hands such a thread the
@@ -774,7 +836,7 @@ namespace MobileGL {
// TLS that state's last owner), so this is what keeps the thread answering as lost: an
// application that releases its context before asking glGetGraphicsResetStatus - Qt's
// render threads do - still learns that the context is gone and rebuilds it.
extern thread_local Bool tThreadReleasedLostContext;
extern constinit thread_local Bool tThreadReleasedLostContext;
#endif
// The fallback pGLContext starts at and an EGL release edge restores to: the process's
@@ -8,6 +8,7 @@
#pragma once
#include <Includes.h>
#include <atomic>
#include <mutex>
#include <MG_Util/Miscellany/IndexGenerator.h>
#include "BufferState/BufferObject.h"
@@ -74,7 +75,42 @@ namespace MobileGL::MG_State::GLState {
UniquePtr<BufferObject> TakeClientArrayBuffer();
void ReturnClientArrayBuffer(UniquePtr<BufferObject> buffer);
// ---- the share clocks (C8) ----
//
// The dirty walk's framebuffer and texture shutters (bits 11-14) read per-CONTEXT
// aggregates, and a mutation bumps them on the context it is made through. Textures,
// renderbuffers and samplers live here, though, so a change made through context B moved
// nothing context A's walk reads and A went on recording the stale framebuffer, view and
// sampler sets. These are the same four aggregates kept once per group: the GLContext
// funnel that bumps a context's own counter bumps its twin here too, and the walk
// compares the twins beside its own.
//
// Release on the bump, which runs after the object write; acquire on the read, so a walk
// that sees the new value also sees the object it describes.
enum class SharedClock : Uint8 {
FramebufferAttachment,
TextureContent,
TextureParams,
SamplingResolution,
Count,
};
void BumpSharedClock(SharedClock clock) {
m_sharedClocks[static_cast<SizeT>(clock)].fetch_add(1, std::memory_order_release);
}
Uint64 ReadSharedClock(SharedClock clock) const {
return m_sharedClocks[static_cast<SizeT>(clock)].load(std::memory_order_acquire);
}
// One relaxed load is the single-context walk's whole cost: with one context there is no
// other reader, and the clocks are not read at all. Sticky, never decremented, so no walk
// has to reason about a sibling that is mid-teardown. The BUMP is not skipped while the
// group has one context: the mutating thread may read a stale count, and a skipped bump
// is lost for good, where an unread clock costs nothing.
void NoteContextAttached() { m_attachedContexts.fetch_add(1, std::memory_order_relaxed); }
Bool HasSeveralContexts() const { return m_attachedContexts.load(std::memory_order_relaxed) > 1; }
private:
std::atomic<Uint64> m_sharedClocks[static_cast<SizeT>(SharedClock::Count)] = {};
std::atomic<Uint32> m_attachedContexts{0};
Uint64 m_token = 0;
UnorderedMap<Uint, SharedPtr<BufferObject>> m_bufferObjects;
IndexGenerator<Uint> m_bufferNames{1024, 1};
@@ -147,17 +147,17 @@ TEST(ContextEpochTest, SameXfbNameInTwoServedContextsDoesNotAliasThePausedSpan)
TEST(ContextEpochTest, ServerLivenessDoesNotFollowTheClientContextOrAVerbStamp) {
#if MOBILEGL_BUILD_DISAGGREGATED
DriverScope scope;
auto context = Move(MG_State::pGLContext);
auto context = MG_State::pGLContext.Take();
const Bool previous = MG_Pipe::MGPipeServerContextIsLive();
MG_Pipe::MGPipeServerSetContextLive(false);
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
EXPECT_FALSE(MG_Pipe::gPipeInputs.IsLive());
EXPECT_FALSE(MG_Pipe::gPipeInputs->IsLive());
MG_Pipe::MGPipeServerSetContextLive(true);
MG_State::pGLContext.reset();
EXPECT_TRUE(MG_Pipe::gPipeInputs.IsLive());
EXPECT_TRUE(MG_Pipe::gPipeInputs->IsLive());
MG_Pipe::MGPipeServerSetContextLive(false);
MG_Pipe::MGPipeServerStampVerbBoundary(MG_Pipe::MGPipeVerb::DrawArrays);
EXPECT_FALSE(MG_Pipe::gPipeInputs.IsLive()) << "a stale command resurrected a destroyed server context";
EXPECT_FALSE(MG_Pipe::gPipeInputs->IsLive()) << "a stale command resurrected a destroyed server context";
MG_Pipe::MGPipeServerClearVerbBoundary();
MG_State::pGLContext = Move(context);
MG_Pipe::MGPipeServerSetContextLive(previous);
+49 -1
View File
@@ -87,7 +87,7 @@ namespace {
m_blockKb = MG_Config::RecordArm.PersistentBlockKb;
m_adoptTier = MG_Config::Ipc.AdoptTier;
m_pipeStats = MG_Config::Features.PipeStats;
m_context = Move(MG_State::pGLContext);
m_context = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
MG_Config::Transport = MG_Config::TransportMode::InProcess;
MG_Config::RecordArm.PersistentBlockKb = 64;
@@ -902,3 +902,51 @@ TEST(EsprytFlushLadder, APartialRangeDoesNotOvertakeAQueuedRingCopy) {
static_cast<GLbitfield>(GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT))
<< "the whole-buffer orphan-map rewrites every byte from the shadow the copies were taken from";
}
// P15: the small-store write rename. A partial range of a small store is drained as the whole
// store - tier 1's orphan-map - instead of one upload-ring copy job per range, but only while the
// host bytes are the store byte for byte, and only while the bytes nobody asked for stay small.
namespace {
using MobileGL::MG_Backend::DirectGLES::BufferImpl::kEsprytWholeStoreRenameMaxBytes;
using MobileGL::MG_Backend::DirectGLES::BufferImpl::kEsprytWholeStoreRenameMaxExtraBytes;
using MobileGL::MG_Backend::DirectGLES::BufferImpl::WholeStoreRenameApplies;
} // namespace
TEST(EsprytFlushLadder, ASmallStoreWhoseHostBytesAreTheStoreIsRenamedWhole) {
// Minecraft's immediate-mode shape: 96 of a 288-byte vertex store, from offset 0.
EXPECT_TRUE(WholeStoreRenameApplies(288, 288, 96, true, false, true));
EXPECT_TRUE(WholeStoreRenameApplies(kEsprytWholeStoreRenameMaxBytes, kEsprytWholeStoreRenameMaxBytes,
kEsprytWholeStoreRenameMaxBytes - kEsprytWholeStoreRenameMaxExtraBytes, true,
false, true));
// And the renamed range is one tier 1 takes as the whole-buffer orphan-map, with or without a
// ring copy still queued on the store.
EXPECT_EQ(InvalidateFlushAccessFor(0, 288, 0, 288, 288, 288, true),
static_cast<GLbitfield>(GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT));
}
TEST(EsprytFlushLadder, ARenameThatWouldMoveTooManyUnaskedBytesKeepsItsQueuedRanges) {
EXPECT_FALSE(WholeStoreRenameApplies(kEsprytWholeStoreRenameMaxBytes + 1, kEsprytWholeStoreRenameMaxBytes + 1,
kEsprytWholeStoreRenameMaxBytes + 1, true, false, true))
<< "above the store bound the queue is drained as it stands";
// The 1.21.5 trace's other shape: 128 bytes into a 53 KiB index store.
EXPECT_FALSE(WholeStoreRenameApplies(53824, 53824, 128, true, false, true))
<< "rewriting 53 KiB for a 128-byte write moves more bytes than the copy job it saves";
EXPECT_FALSE(WholeStoreRenameApplies(16384, 16384, 16384 - kEsprytWholeStoreRenameMaxExtraBytes - 1, true,
false, true));
EXPECT_FALSE(WholeStoreRenameApplies(0, 0, 0, true, false, true));
EXPECT_FALSE(WholeStoreRenameApplies(288, 288, 0, true, false, true)) << "nothing queued, nothing to rename";
}
// The refusals are the widening rule: the rename rewrites bytes outside the queued ranges, which
// is exact only when the host copy holds them.
TEST(EsprytFlushLadder, AStoreHoldingBytesTheHostCopyDoesNotIsNeverRenamed) {
EXPECT_FALSE(WholeStoreRenameApplies(288, 288, 96, true, true, true))
<< "a shader-written (or coherent, imported, resident-written) store would get the stale "
"host bytes back over what the GPU put there";
EXPECT_FALSE(WholeStoreRenameApplies(288, 288, 96, false, false, true))
<< "under split a staged copy that does not cover the store has no bytes for the rest of it";
EXPECT_FALSE(WholeStoreRenameApplies(288, 576, 96, true, false, true))
<< "a store the frontend has already resized is a respecify, not a rename";
EXPECT_FALSE(WholeStoreRenameApplies(288, 288, 96, true, false, false))
<< "without tier 1's map the whole store would only be a bigger ring copy";
}
+76 -76
View File
@@ -87,7 +87,7 @@ namespace {
class FieldOwnershipTest : public ::testing::Test {
protected:
void SetUp() override {
m_previous = Move(MG_State::pGLContext);
m_previous = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
#if MOBILEGL_BUILD_DISAGGREGATED
MG_Config::Ipc.StrictErrors = false;
@@ -486,14 +486,14 @@ TEST_F(FieldOwnershipTest, TheResidualFillsSuppliedMemoReKeysOnEveryInputThatMov
TEST_F(FieldOwnershipTest, AServerStampMakesRecordSuppliedFieldsFreshAndWithdrawsTheRest) {
MGPipeServerStampVerbBoundary(MGPipeVerb::Clear);
EXPECT_TRUE(gPipeInputs.ServerStampedVerb());
EXPECT_EQ(gPipeInputs.CurrentVerb(), MGPipeVerb::Clear);
EXPECT_TRUE(gPipeInputs->ServerStampedVerb());
EXPECT_EQ(gPipeInputs->CurrentVerb(), MGPipeVerb::Clear);
const MGPipeFieldMask& mask = kMGPipeClassFieldMask[static_cast<SizeT>(
kMGPipeVerbClass[static_cast<SizeT>(MGPipeVerb::Clear)])];
SizeT stamped = 0;
for (SizeT i = 0; i < kMGPipeInputFieldCount; ++i) {
const auto field = static_cast<MGPipeInputField>(i);
const Bool fresh = MGPipeInputFieldIsFresh(gPipeInputs.FilledState(), field);
const Bool fresh = MGPipeInputFieldIsFresh(gPipeInputs->FilledState(), field);
// The stamp respects the verb's own may-read table for the client fill's reason: a
// field outside the class was never copied for this verb, so answering it would hand
// the server the previous verb's value.
@@ -512,7 +512,7 @@ TEST_F(FieldOwnershipTest, AServerStampMakesRecordSuppliedFieldsFreshAndWithdraw
// `answerable` out of kMGPipeFieldOwnership, so it can only catch a stamp that disagrees
// with the table - never a table that is wrong. These four say what the stamp must do for
// four fields whose class is an argument of this package rather than a lookup.
const MGPipeFilledState& filled = gPipeInputs.FilledState();
const MGPipeFilledState& filled = gPipeInputs->FilledState();
EXPECT_TRUE(MGPipeInputFieldIsFresh(filled, MGPipeInputField::GetClearColor)); // supplied
EXPECT_TRUE(MGPipeInputFieldIsFresh(filled, MGPipeInputField::GetRenderStateParameters));
EXPECT_FALSE(MGPipeInputFieldIsFresh(filled, MGPipeInputField::GetFramebufferBindingSlot)); // pulled
@@ -525,14 +525,14 @@ TEST_F(FieldOwnershipTest, AServerStampMakesRecordSuppliedFieldsFreshAndWithdraw
// changing. Before this, the seven most dangerous fields were exempt by construction.
TEST_F(FieldOwnershipTest, TheStickyExemptionIsCancelledByTheServerStamp) {
MGPipeValidateForVerb(MGPipeVerb::Clear); // the CLIENT fills and stamps all 63, sticky included
EXPECT_TRUE(MGPipeInputFieldIsFresh(gPipeInputs.FilledState(), MGPipeInputField::RecordError));
EXPECT_TRUE(MGPipeInputFieldIsFresh(gPipeInputs->FilledState(), MGPipeInputField::RecordError));
MGPipeServerStampVerbBoundary(MGPipeVerb::Clear);
for (SizeT i = 0; i < kMGPipeFieldOwnershipForwardCount; ++i) {
const MGPipeInputField field = kMGPipeFieldOwnershipForwardField[i];
// P5f fe retired the scalar forwards to server-owned answers. Their freshness
// comes from that ownership; the remaining client forwards lose the exemption.
const Bool serverOwned = MGPipeFieldOwnershipOf(field) == MGPipeFieldOwnership::kApplierDerived;
EXPECT_EQ(MGPipeInputFieldIsFresh(gPipeInputs.FilledState(), field), serverOwned)
EXPECT_EQ(MGPipeInputFieldIsFresh(gPipeInputs->FilledState(), field), serverOwned)
<< kMGPipeInputFieldNames[Index(field)] << " has the wrong server-stamp freshness";
}
}
@@ -543,21 +543,21 @@ TEST_F(FieldOwnershipTest, ARecordSuppliedFieldIsReadableAfterAServerStamp) {
ASSERT_EQ(MGPipeFieldOwnershipOf(MGPipeInputField::GetClearColor),
MGPipeFieldOwnership::kRecordSupplied);
MGPipeServerStampVerbBoundary(MGPipeVerb::Clear);
(void)gPipeInputs.GetClearColor();
(void)gPipeInputs.GetRenderStateParameters();
(void)gPipeInputs->GetClearColor();
(void)gPipeInputs->GetRenderStateParameters();
EXPECT_EQ(MGPipeResidualPullCount(), Uint64{0});
// The pixel store is in kReadback's class, not kClear's, so its readable half is exercised
// under the verb that actually reads it. And P5c rv's record-supplied rows join it there:
// GetActiveTextureUnit is exactly the read that used to count into `rsp`.
MGPipeServerStampVerbBoundary(MGPipeVerb::ReadPixels);
(void)gPipeInputs.GetPixelStoreParameters(false); // the half that has a carrier
(void)gPipeInputs.GetActiveTextureUnit(); // P5c rv: set_context_values carries it
(void)gPipeInputs.GetMaxTouchedTextureUnit();
(void)gPipeInputs->GetPixelStoreParameters(false); // the half that has a carrier
(void)gPipeInputs->GetActiveTextureUnit(); // P5c rv: set_context_values carries it
(void)gPipeInputs->GetMaxTouchedTextureUnit();
EXPECT_EQ(MGPipeResidualPullCount(), Uint64{0});
// And a shutter answers the applier's own Serial under a server stamp (APPLIER-DERIVED),
// not the client's residual-fill copy: still zero pulls, and the answer MOVES when the
// applier's texture state does.
(void)gPipeInputs.GetTextureBindGeneration();
(void)gPipeInputs->GetTextureBindGeneration();
EXPECT_EQ(MGPipeResidualPullCount(), Uint64{0});
}
@@ -578,16 +578,16 @@ TEST_F(FieldOwnershipTest, SetContextValuesLandsInPipeInputsAndTheShuttersAnswer
MGPipeApplySetContextValues(values);
MGPipeServerStampVerbBoundary(MGPipeVerb::ReadPixels);
EXPECT_EQ(gPipeInputs.GetActiveTextureUnit(), 5);
EXPECT_EQ(gPipeInputs.GetMaxTouchedTextureUnit(), 23);
EXPECT_EQ(gPipeInputs->GetActiveTextureUnit(), 5);
EXPECT_EQ(gPipeInputs->GetMaxTouchedTextureUnit(), 23);
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
EXPECT_EQ(gPipeInputs.GetTouchedBufferBindingPointCount(BufferTarget::Uniform), SizeT{7});
EXPECT_EQ(gPipeInputs.GetTouchedBufferBindingPointCount(BufferTarget::Vertex), SizeT{0});
EXPECT_TRUE(gPipeInputs.IsTransformFeedbackActive());
EXPECT_FALSE(gPipeInputs.IsTransformFeedbackPaused());
EXPECT_EQ(gPipeInputs.GetTransformFeedbackGeneration(), 0x1112131415161718ull);
EXPECT_EQ(gPipeInputs.GetBoundTransformFeedbackLifetimeId(), 0x2122232425262728ull);
EXPECT_EQ(gPipeInputs.GetTransformFeedbackCapturedVertices(), 0x3132333435363738ull);
EXPECT_EQ(gPipeInputs->GetTouchedBufferBindingPointCount(BufferTarget::Uniform), SizeT{7});
EXPECT_EQ(gPipeInputs->GetTouchedBufferBindingPointCount(BufferTarget::Vertex), SizeT{0});
EXPECT_TRUE(gPipeInputs->IsTransformFeedbackActive());
EXPECT_FALSE(gPipeInputs->IsTransformFeedbackPaused());
EXPECT_EQ(gPipeInputs->GetTransformFeedbackGeneration(), 0x1112131415161718ull);
EXPECT_EQ(gPipeInputs->GetBoundTransformFeedbackLifetimeId(), 0x2122232425262728ull);
EXPECT_EQ(gPipeInputs->GetTransformFeedbackCapturedVertices(), 0x3132333435363738ull);
// Eight record-supplied reads and not one residual pull.
EXPECT_EQ(MGPipeResidualPullCount(), Uint64{0});
@@ -595,12 +595,12 @@ TEST_F(FieldOwnershipTest, SetContextValuesLandsInPipeInputsAndTheShuttersAnswer
// SHUTTERS - the value matters only in that it MOVES when the server's texture state does
// and never walks backwards - so the pin is the identity with the applier's counters, not
// any particular number.
EXPECT_EQ(gPipeInputs.GetTextureBindGeneration(), MGPipeApplierTextureShutterSerial());
EXPECT_EQ(gPipeInputs.GetSamplingResolutionGeneration(), MGPipeApplierTextureShutterSerial());
EXPECT_EQ(gPipeInputs.GetTextureContextId(), MGPipeApplierContextSerial());
EXPECT_EQ(gPipeInputs->GetTextureBindGeneration(), MGPipeApplierTextureShutterSerial());
EXPECT_EQ(gPipeInputs->GetSamplingResolutionGeneration(), MGPipeApplierTextureShutterSerial());
EXPECT_EQ(gPipeInputs->GetTextureContextId(), MGPipeApplierContextSerial());
const Uint64 before = MGPipeApplierTextureShutterSerial();
MGPipeApplierNoteTextureStateMoved();
EXPECT_EQ(gPipeInputs.GetTextureBindGeneration(), before + 1)
EXPECT_EQ(gPipeInputs->GetTextureBindGeneration(), before + 1)
<< "a texture-state apply moved the serial but the shutter did not answer with it";
EXPECT_EQ(MGPipeResidualPullCount(), Uint64{0});
}
@@ -612,7 +612,7 @@ TEST_F(FieldOwnershipTest, ABarrierPulledReadAfterAServerStampIsCountedNotFatal)
const ChildResult r = RunInChild([] {
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
(void)gPipeInputs.GetBoundVertexArray();
(void)gPipeInputs->GetBoundVertexArray();
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, \"GetBoundVertexArray@DrawArrays\"}"), std::string::npos) << r.Log;
@@ -629,7 +629,7 @@ TEST_F(FieldOwnershipTest, AStickyForwardIsCountedAsAResidualPull) {
const ChildResult r = RunInChild([] {
MGPipeServerStampVerbBoundary(MGPipeVerb::Clear);
(void)gPipeInputs.ValidateProgramName(1u);
(void)gPipeInputs->ValidateProgramName(1u);
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, \"ValidateProgramName@Clear\"}"), std::string::npos) << r.Log;
@@ -644,11 +644,11 @@ TEST_F(FieldOwnershipTest, AStickyForwardIsCountedAsAResidualPull) {
// for - and what keeps build-split's monolith lanes behaving as a verify build's do.
TEST_F(FieldOwnershipTest, NothingIsCountedOutsideAServerStampedVerb) {
MGPipeValidateForVerb(MGPipeVerb::ReadPixels);
(void)gPipeInputs.ValidateProgramName(1u);
gPipeInputs.InvalidateCompileEnv();
(void)gPipeInputs.GetActiveTextureUnit();
(void)gPipeInputs->ValidateProgramName(1u);
gPipeInputs->InvalidateCompileEnv();
(void)gPipeInputs->GetActiveTextureUnit();
EXPECT_EQ(MGPipeResidualPullCount(), Uint64{0});
EXPECT_FALSE(gPipeInputs.ServerStampedVerb());
EXPECT_FALSE(gPipeInputs->ServerStampedVerb());
}
// THE APPLIER'S OWN CLEAR, reached directly rather than through the client's fill. In a spawned
@@ -658,13 +658,13 @@ TEST_F(FieldOwnershipTest, NothingIsCountedOutsideAServerStampedVerb) {
// InvalidateCompileEnv is reached from backend initialisation under - is gone for good.
TEST_F(FieldOwnershipTest, TheAppliersOwnClearDisarmsTheStampWithoutTheClientsFill) {
MGPipeServerStampVerbBoundary(MGPipeVerb::ReadPixels);
ASSERT_TRUE(gPipeInputs.ServerStampedVerb());
(void)gPipeInputs.GetActiveTextureUnit();
ASSERT_TRUE(gPipeInputs->ServerStampedVerb());
(void)gPipeInputs->GetActiveTextureUnit();
ASSERT_EQ(MGPipeResidualPullCount(), Uint64{0});
MGPipeServerClearVerbBoundary();
EXPECT_FALSE(gPipeInputs.ServerStampedVerb());
(void)gPipeInputs.ValidateProgramName(1u);
gPipeInputs.InvalidateCompileEnv();
EXPECT_FALSE(gPipeInputs->ServerStampedVerb());
(void)gPipeInputs->ValidateProgramName(1u);
gPipeInputs->InvalidateCompileEnv();
EXPECT_EQ(MGPipeResidualPullCount(), Uint64{0});
}
@@ -677,7 +677,7 @@ TEST_F(FieldOwnershipTest, ABarrierPulledFieldOutsideTheVerbsClassIsStillFatal)
#if MGTEST_HAVE_FORK
const ChildResult r = RunInChild([] {
MGPipeServerStampVerbBoundary(MGPipeVerb::Clear);
(void)gPipeInputs.GetProgramForDraw(); // retired accessor, outside kClear too
(void)gPipeInputs->GetProgramForDraw(); // retired accessor, outside kClear too
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, \"GetProgramForDraw@Clear\"}"), std::string::npos)
@@ -693,7 +693,7 @@ TEST_F(FieldOwnershipTest, ResidualPullsReachThePublishedPerFrameCounter) {
PS::SetEnabledForTesting(true);
PS::ResetForTesting();
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
(void)gPipeInputs.GetCurrentVertexAttribute(0);
(void)gPipeInputs->GetCurrentVertexAttribute(0);
EXPECT_EQ(PS::FrameCalls(PS::CallClass::ResidualPulls), Uint64{0});
EXPECT_NE(PS::FormatWindowLine().find(" rsp=0"), std::string::npos) << PS::FormatWindowLine();
// Prove the reporting channel did not merely become a constant zero after retirement.
@@ -742,9 +742,9 @@ TEST_F(FieldOwnershipTest, SplitBindingPointCapacityNeverConsultsTheFrontend) {
RoleSplitArm guard;
guard.Arm(true);
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
EXPECT_EQ(gPipeInputs.GetBufferBindingPointCount(BufferTarget::Uniform), 84u);
EXPECT_EQ(gPipeInputs.GetBufferBindingPointCount(BufferTarget::TransformFeedback), 84u);
EXPECT_EQ(gPipeInputs.GetBufferBindingPointCount(BufferTarget::PixelPack), 0u);
EXPECT_EQ(gPipeInputs->GetBufferBindingPointCount(BufferTarget::Uniform), 84u);
EXPECT_EQ(gPipeInputs->GetBufferBindingPointCount(BufferTarget::TransformFeedback), 84u);
EXPECT_EQ(gPipeInputs->GetBufferBindingPointCount(BufferTarget::PixelPack), 0u);
EXPECT_EQ(MGPipeFieldOwnershipOf(MGPipeInputField::GetBufferBindingPointCount),
MGPipeFieldOwnership::kApplierDerived);
MGPipeServerClearVerbBoundary();
@@ -756,16 +756,16 @@ TEST_F(FieldOwnershipTest, SplitOpenSpansAreOwnedByTheApplierAndSurviveOtherBind
auto& state = MGPipeApplier();
state.StreamOutputSpans.clear();
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
EXPECT_FALSE(gPipeInputs.HasOpenTransformFeedbackSpan(0));
EXPECT_FALSE(gPipeInputs.HasOpenTransformFeedbackSpan(11));
EXPECT_FALSE(gPipeInputs->HasOpenTransformFeedbackSpan(0));
EXPECT_FALSE(gPipeInputs->HasOpenTransformFeedbackSpan(11));
state.StreamOutputSpans[11] = {};
state.StreamOutputSpans[12] = {};
state.BoundStreamOutputLifetimeId = 12;
EXPECT_TRUE(gPipeInputs.HasOpenTransformFeedbackSpan(11));
EXPECT_TRUE(gPipeInputs.HasOpenTransformFeedbackSpan(12));
EXPECT_TRUE(gPipeInputs->HasOpenTransformFeedbackSpan(11));
EXPECT_TRUE(gPipeInputs->HasOpenTransformFeedbackSpan(12));
state.StreamOutputSpans.erase(12);
EXPECT_TRUE(gPipeInputs.HasOpenTransformFeedbackSpan(11));
EXPECT_FALSE(gPipeInputs.HasOpenTransformFeedbackSpan(12));
EXPECT_TRUE(gPipeInputs->HasOpenTransformFeedbackSpan(11));
EXPECT_FALSE(gPipeInputs->HasOpenTransformFeedbackSpan(12));
EXPECT_EQ(MGPipeFieldOwnershipOf(MGPipeInputField::HasOpenTransformFeedbackSpan),
MGPipeFieldOwnership::kApplierDerived);
state.StreamOutputSpans.clear();
@@ -793,7 +793,7 @@ TEST_F(FieldOwnershipTest, SplitCaptureSnapshotSurvivesMakeCurrentUntilObjectRel
returning.IsTransformFeedbackActive = 1;
MGPipeApplySetContextValues(returning);
EXPECT_EQ(state.BoundStreamOutputLifetimeId, begin.LifetimeId);
EXPECT_TRUE(gPipeInputs.HasOpenTransformFeedbackSpan(begin.LifetimeId));
EXPECT_TRUE(gPipeInputs->HasOpenTransformFeedbackSpan(begin.LifetimeId));
const auto found = state.StreamOutputSpans.find(begin.LifetimeId);
EXPECT_NE(found, state.StreamOutputSpans.end());
if (found != state.StreamOutputSpans.end()) {
@@ -803,13 +803,13 @@ TEST_F(FieldOwnershipTest, SplitCaptureSnapshotSurvivesMakeCurrentUntilObjectRel
EXPECT_EQ(found->second.Targets[3].Size, 64u);
}
MGPipeApplierReleaseObjectRecords();
EXPECT_FALSE(gPipeInputs.HasOpenTransformFeedbackSpan(begin.LifetimeId));
EXPECT_FALSE(gPipeInputs->HasOpenTransformFeedbackSpan(begin.LifetimeId));
EXPECT_EQ(state.BoundStreamOutputLifetimeId, 0u);
}
TEST_F(FieldOwnershipTest, RoleSplitOffFoldsTheFillSideOntoTheSharedBlock) {
EXPECT_FALSE(MGPipeRoleSplitRehearsalActive());
EXPECT_EQ(&MGPipeClientInputs(), &gPipeInputs);
EXPECT_EQ(&MGPipeClientInputs(), &*gPipeInputs);
}
// The knob alone is not the arm: under monolith transport the two roles are one thread and
@@ -820,7 +820,7 @@ TEST_F(FieldOwnershipTest, RoleSplitUnderMonolithTransportIsStillOneBlock) {
MG_Config::Ipc.RoleSplitState = true;
MG_Config::Transport = MG_Config::TransportMode::Monolith;
EXPECT_FALSE(MGPipeRoleSplitRehearsalActive());
EXPECT_EQ(&MGPipeClientInputs(), &gPipeInputs);
EXPECT_EQ(&MGPipeClientInputs(), &*gPipeInputs);
}
// D1c/D10 (CONTRACT-P6 3.2, 3.4). THE PREDICATE THAT IS TRUE WITHOUT THE KNOB, and the reason
@@ -850,38 +850,38 @@ TEST_F(FieldOwnershipTest, MonolithKeepsOneBlockAndTheWiderPredicateSaysSo) {
MG_Config::Ipc.RoleSplitState = false;
MG_Config::Transport = MG_Config::TransportMode::Monolith;
EXPECT_FALSE(MGPipeBlocksAreDistinct());
EXPECT_EQ(&MGPipeClientInputs(), &gPipeInputs);
EXPECT_EQ(&MGPipeClientInputs(), &*gPipeInputs);
}
TEST_F(FieldOwnershipTest, RoleSplitGivesTheFillSideADistinctBlockTheStampNeverTouches) {
RoleSplitArm guard;
guard.Arm(true);
ASSERT_TRUE(MGPipeRoleSplitRehearsalActive());
ASSERT_NE(&MGPipeClientInputs(), &gPipeInputs);
ASSERT_NE(&MGPipeClientInputs(), &*gPipeInputs);
const Uint64 serverSerialBefore = gPipeInputs.FilledState().CurrentVerbSerial;
const Uint64 serverSerialBefore = gPipeInputs->FilledState().CurrentVerbSerial;
const Uint64 clientSerialBefore = MGPipeClientInputs().FilledState().CurrentVerbSerial;
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
EXPECT_EQ(gPipeInputs.FilledState().CurrentVerbSerial, serverSerialBefore + 1);
EXPECT_EQ(gPipeInputs->FilledState().CurrentVerbSerial, serverSerialBefore + 1);
EXPECT_EQ(MGPipeClientInputs().FilledState().CurrentVerbSerial, clientSerialBefore)
<< "the server's verb stamp reached into the client block";
EXPECT_TRUE(gPipeInputs.ServerStampedVerb());
EXPECT_TRUE(gPipeInputs->ServerStampedVerb());
EXPECT_FALSE(MGPipeClientInputs().ServerStampedVerb());
// The fill side's clear is the client block's own: it must not disarm the server's stamp,
// which is CONTRACT-P5E §3.2's "the server's stamp is server-private" as a fact rather
// than as a comment.
MGPipeClientClearVerbBoundary();
EXPECT_TRUE(gPipeInputs.ServerStampedVerb())
EXPECT_TRUE(gPipeInputs->ServerStampedVerb())
<< "the client-role clear withdrew the SERVER's stamp";
MGPipeServerClearVerbBoundary();
EXPECT_FALSE(gPipeInputs.ServerStampedVerb());
EXPECT_FALSE(gPipeInputs->ServerStampedVerb());
// And the server block's identity is server-owned under the rehearsal (§3.2's other half):
// the stamp set it, and it is non-null - a null identity reads as a hit against
// DirectGLES' zero-initialised fb-slot memo cache, which is the unnamed crash this line
// exists to preclude.
EXPECT_NE(gPipeInputs.ContextIdentity(), nullptr);
EXPECT_NE(gPipeInputs->ContextIdentity(), nullptr);
}
// The fill side's writers land in the client block alone. MGPipeLeaveVerb rather than
@@ -891,12 +891,12 @@ TEST_F(FieldOwnershipTest, RoleSplitGivesTheFillSideADistinctBlockTheStampNeverT
TEST_F(FieldOwnershipTest, TheClientVerbLeaveWritesTheClientBlockAlone) {
RoleSplitArm guard;
guard.Arm(true);
ASSERT_NE(&MGPipeClientInputs(), &gPipeInputs);
const Uint64 serverSerialBefore = gPipeInputs.FilledState().CurrentVerbSerial;
ASSERT_NE(&MGPipeClientInputs(), &*gPipeInputs);
const Uint64 serverSerialBefore = gPipeInputs->FilledState().CurrentVerbSerial;
const Uint64 clientSerialBefore = MGPipeClientInputs().FilledState().CurrentVerbSerial;
MGPipeLeaveVerb();
EXPECT_EQ(MGPipeClientInputs().FilledState().CurrentVerbSerial, clientSerialBefore + 1);
EXPECT_EQ(gPipeInputs.FilledState().CurrentVerbSerial, serverSerialBefore)
EXPECT_EQ(gPipeInputs->FilledState().CurrentVerbSerial, serverSerialBefore)
<< "a fill-side write reached the server block";
EXPECT_EQ(MGPipeClientInputs().CurrentVerb(), MGPipeVerb::kVerbCount);
}
@@ -909,9 +909,9 @@ TEST_F(FieldOwnershipTest, AClientFreshStampCannotReviveARetiredServerGetter) {
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
// Simulate a regressed writer stamping the old mirror as fresh. FATAL is a
// representation verdict, not a freshness verdict, and must still reject it.
auto& filled = const_cast<MGPipeFilledState&>(gPipeInputs.FilledState());
auto& filled = const_cast<MGPipeFilledState&>(gPipeInputs->FilledState());
filled.FilledGen[Index(MGPipeInputField::GetBoundVertexArray)] = filled.CurrentVerbSerial;
(void)gPipeInputs.GetBoundVertexArray();
(void)gPipeInputs->GetBoundVertexArray();
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, \"GetBoundVertexArray@DrawArrays\"}"),
@@ -923,7 +923,7 @@ TEST_F(FieldOwnershipTest, StrictErrorsTurnsABarrierPulledReadIntoANamedAbort) {
const ChildResult r = RunInChild([] {
MG_Config::Ipc.StrictErrors = true;
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
(void)gPipeInputs.GetBoundVertexArray();
(void)gPipeInputs->GetBoundVertexArray();
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, \"GetBoundVertexArray@DrawArrays\"}"), std::string::npos) << r.Log;
@@ -936,7 +936,7 @@ TEST_F(FieldOwnershipTest, TheSameReadWithoutStrictErrorsSurvivesAndIsCounted) {
const ChildResult r = RunInChild([] {
MG_Config::Ipc.StrictErrors = false;
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
(void)gPipeInputs.GetBoundVertexArray();
(void)gPipeInputs->GetBoundVertexArray();
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, \"GetBoundVertexArray@DrawArrays\"}"), std::string::npos) << r.Log;
@@ -950,7 +950,7 @@ TEST_F(FieldOwnershipTest, AnEscalatedRecordsPullIsAdmittedAndSaysWhy) {
MG_Config::Ipc.StrictErrors = true;
MGPipeApplierSetCurrentRecordBarrieredByEscalation(true);
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
(void)gPipeInputs.GetBoundVertexArray();
(void)gPipeInputs->GetBoundVertexArray();
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, \"GetBoundVertexArray@DrawArrays\"}"), std::string::npos) << r.Log;
@@ -963,7 +963,7 @@ TEST_F(FieldOwnershipTest, StrictErrorsReachTheStickyForwardsAndNameThemByField)
const ChildResult r = RunInChild([] {
MG_Config::Ipc.StrictErrors = true;
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
(void)gPipeInputs.ValidateProgramName(1u);
(void)gPipeInputs->ValidateProgramName(1u);
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, \"ValidateProgramName@DrawArrays\"}"), std::string::npos) << r.Log;
@@ -976,7 +976,7 @@ TEST_F(FieldOwnershipTest, AnAdmittedBarrierPullIsLoudOnceAndNotFatal) {
const ChildResult r = RunInChild([] {
MG_Config::Ipc.StrictErrors = true;
MGPipeServerStampVerbBoundary(MGPipeVerb::ReadPixels);
(void)gPipeInputs.ValidateProgramName(1u);
(void)gPipeInputs->ValidateProgramName(1u);
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, \"ValidateProgramName@ReadPixels\"}"), std::string::npos) << r.Log;
@@ -987,7 +987,7 @@ TEST_F(FieldOwnershipTest, AnAdmittedBarrierPullIsLoudOnceAndNotFatal) {
TEST_F(FieldOwnershipTest, AFatalClassReadAbortsEvenWithoutStrictErrors) {
const ChildResult r = RunInChild([] {
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
(void)gPipeInputs.GetTransformFeedbackPausedPrimitiveCounter();
(void)gPipeInputs->GetTransformFeedbackPausedPrimitiveCounter();
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, "
@@ -1002,7 +1002,7 @@ TEST_F(FieldOwnershipTest, TheComputeProgramIsServedUnderADispatchStampFromP5bOn
const ChildResult r = RunInChild([] {
MGPipeServerStampVerbBoundary(MGPipeVerb::DispatchCompute);
(void)gPipeInputs.GetProgramForDispatch();
(void)gPipeInputs->GetProgramForDispatch();
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, \"GetProgramForDispatch@DispatchCompute\"}"), std::string::npos) << r.Log;
@@ -1016,7 +1016,7 @@ TEST_F(FieldOwnershipTest, TheComputeProgramIsServedUnderADispatchStampFromP5bOn
TEST_F(FieldOwnershipTest, TheUnpackHalfOfThePixelStoreAbortsWhileThePackHalfDoesNot) {
const ChildResult fatal = RunInChild([] {
MGPipeServerStampVerbBoundary(MGPipeVerb::ReadPixels);
(void)gPipeInputs.GetPixelStoreParameters(true);
(void)gPipeInputs->GetPixelStoreParameters(true);
});
ASSERT_TRUE(DiedOfAbort(fatal)) << DescribeStatus(fatal) << "\n" << fatal.Log;
EXPECT_NE(fatal.Log.find("Fatal{UnmigratedPipeInput, \"GetPixelStoreParameters@ReadPixels\"}"),
@@ -1032,7 +1032,7 @@ TEST_F(FieldOwnershipTest, TheUnpackHalfOfThePixelStoreAbortsWhileThePackHalfDoe
const ChildResult ok = RunInChild([] {
MGPipeServerStampVerbBoundary(MGPipeVerb::ReadPixels);
(void)gPipeInputs.GetPixelStoreParameters(false);
(void)gPipeInputs->GetPixelStoreParameters(false);
if (MGPipeResidualPullCount() != 0) ::_exit(7);
});
ASSERT_TRUE(ExitedWith(ok, 0)) << DescribeStatus(ok) << "\n" << ok.Log;
@@ -1067,7 +1067,7 @@ TEST_F(FieldOwnershipTest, DualBlockMakesABarrierPulledReadANamedAbortWithoutStr
MG_Config::Ipc.RoleSplitState = true;
MG_Config::Ipc.StrictErrors = false;
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
(void)gPipeInputs.GetBoundVertexArray();
(void)gPipeInputs->GetBoundVertexArray();
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnmigratedPipeInput, \"GetBoundVertexArray@DrawArrays\"}"), std::string::npos) << r.Log;
@@ -1081,7 +1081,7 @@ TEST_F(FieldOwnershipTest, DualBlockDoesNotArmUnderMonolithTransport) {
MG_Config::Ipc.RoleSplitState = true;
// A real monolith fill, not a manufactured server stamp on a monolith process.
MGPipeValidateForVerb(MGPipeVerb::DrawArrays);
(void)gPipeInputs.GetBoundVertexArray();
(void)gPipeInputs->GetBoundVertexArray();
if (MGPipeRoleSplitRehearsalActive() || MGPipeResidualPullCount() != 0) ::_exit(7);
});
ASSERT_TRUE(ExitedWith(r, 0)) << DescribeStatus(r) << "\n" << r.Log;
@@ -246,7 +246,7 @@ namespace {
kMGPipeSubsystemFramebuffer |
kMGPipeSubsystemTextureResources |
kMGPipeSubsystemSamplers;
m_previousContext = Move(MG_State::pGLContext);
m_previousContext = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
MGPipeFramebufferEmitterInstance().ResetForTest();
MGPipeTextureEmitterInstance().ResetForTest();
+35 -35
View File
@@ -73,7 +73,7 @@ namespace {
class PipeInputsTest : public ::testing::Test {
protected:
void SetUp() override {
m_previous = Move(MG_State::pGLContext);
m_previous = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
MGPipeSetPoisonOmission(nullptr, nullptr);
}
@@ -85,7 +85,7 @@ namespace {
};
#if MOBILEGL_PIPE_POISON
Bool Fresh(MGPipeInputField field) { return MGPipeInputFieldIsFresh(gPipeInputs.FilledState(), field); }
Bool Fresh(MGPipeInputField field) { return MGPipeInputFieldIsFresh(gPipeInputs->FilledState(), field); }
#endif
[[maybe_unused]] constexpr const char* kOmittedFatal ="Fatal{UnmigratedPipeInput, \"GetActiveTextureUnit@GenerateMipmap\"}";
@@ -147,7 +147,7 @@ TEST_F(PipeInputsTest, OmittingOneFieldForOneVerbLeavesExactlyThatFieldStale) {
EXPECT_TRUE(Fresh(MGPipeInputField::GetTextureUnitObject));
EXPECT_FALSE(Fresh(MGPipeInputField::GetActiveTextureUnit));
// The value was still copied: only the stamp is withheld.
EXPECT_EQ(gPipeInputs.CurrentVerb(), MGPipeVerb::GenerateMipmap);
EXPECT_EQ(gPipeInputs->CurrentVerb(), MGPipeVerb::GenerateMipmap);
// Exactly that field: a field is fresh iff its bit is in kTextureOp's mask and it is not
// the omitted one.
{
@@ -174,7 +174,7 @@ TEST_F(PipeInputsTest, OmittingOneFieldForOneVerbLeavesExactlyThatFieldStale) {
}
// Negative control B, layer 2 (G5): the read itself. The child fills GenerateMipmap with the
// omission and reads gPipeInputs.GetActiveTextureUnit(); the parent expects SIGABRT and the
// omission and reads gPipeInputs->GetActiveTextureUnit(); the parent expects SIGABRT and the
// exact Fatal line, and that nothing else was fatal.
TEST_F(PipeInputsTest, ReadingAnOmittedFieldAbortsNamingTheVerb) {
#if !MOBILEGL_PIPE_POISON
@@ -186,10 +186,10 @@ TEST_F(PipeInputsTest, ReadingAnOmittedFieldAbortsNamingTheVerb) {
const ChildResult r = RunInChild([] {
MGPipeSetPoisonOmission("GenerateMipmap", "GetActiveTextureUnit");
MGPipeValidateForVerb(MGPipeVerb::DrawArrays);
(void)gPipeInputs.GetRenderStateParameters(); // a filled field of the preceding draw: must not abort
(void)gPipeInputs->GetRenderStateParameters(); // a filled field of the preceding draw: must not abort
MGPipeValidateForVerb(MGPipeVerb::GenerateMipmap);
(void)gPipeInputs.GetTextureUnitObject(0); // the sibling field: filled, must not abort
(void)gPipeInputs.GetActiveTextureUnit(); // the omitted field: Fatal
(void)gPipeInputs->GetTextureUnitObject(0); // the sibling field: filled, must not abort
(void)gPipeInputs->GetActiveTextureUnit(); // the omitted field: Fatal
::_exit(3); // reached only if the poison failed
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
@@ -207,10 +207,10 @@ TEST_F(PipeInputsTest, ReadingAFilledFieldCompletes) {
ASSERT_FALSE(g_logPath.empty()) << "main() did not set MOBILEGL_LOG_FILE_PATH";
const ChildResult r = RunInChild([] {
MGPipeValidateForVerb(MGPipeVerb::DrawArrays);
(void)gPipeInputs.GetRenderStateParameters();
(void)gPipeInputs->GetRenderStateParameters();
MGPipeValidateForVerb(MGPipeVerb::GenerateMipmap);
(void)gPipeInputs.GetTextureUnitObject(0);
(void)gPipeInputs.GetActiveTextureUnit();
(void)gPipeInputs->GetTextureUnitObject(0);
(void)gPipeInputs->GetActiveTextureUnit();
});
ASSERT_TRUE(ExitedWith(r, 0)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_EQ(r.Log.find("Fatal{"), std::string::npos) << r.Log;
@@ -229,7 +229,7 @@ TEST_F(PipeInputsTest, ReadingBeforeAnyFillAbortsNamingNoVerb) {
GTEST_SKIP() << "no fork() on this platform";
#else
ASSERT_FALSE(g_logPath.empty()) << "main() did not set MOBILEGL_LOG_FILE_PATH";
if (gPipeInputs.FilledState().CurrentVerbSerial != 0) {
if (gPipeInputs->FilledState().CurrentVerbSerial != 0) {
GTEST_SKIP() << "another case already filled in this process; gtest_discover_tests runs each case alone";
}
MG_State::pGLContext->SetLineWidth(7.0f); // a live value the default storage (0) does not hold
@@ -237,7 +237,7 @@ TEST_F(PipeInputsTest, ReadingBeforeAnyFillAbortsNamingNoVerb) {
#if MOBILEGL_PIPE_VERIFY
MG_Config::Features.PipeVerify = true;
#endif
(void)gPipeInputs.GetLineWidth(); // Fatal{UnmigratedPipeInput, "GetLineWidth@<none>"}
(void)gPipeInputs->GetLineWidth(); // Fatal{UnmigratedPipeInput, "GetLineWidth@<none>"}
::_exit(3); // reached only if the pre-fill window read as fresh
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
@@ -261,8 +261,8 @@ TEST_F(PipeInputsTest, PoisonOmitKnobArmsTheOmission) {
const ChildResult r = RunInChild([] {
MG_Config::Features.PipePoisonOmit = kOmissionKnob;
MGPipeValidateForVerb(MGPipeVerb::GenerateMipmap);
(void)gPipeInputs.GetTextureUnitObject(0); // the sibling field: filled, must not abort
(void)gPipeInputs.GetActiveTextureUnit(); // the omitted field: Fatal
(void)gPipeInputs->GetTextureUnitObject(0); // the sibling field: filled, must not abort
(void)gPipeInputs->GetActiveTextureUnit(); // the omitted field: Fatal
::_exit(3);
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
@@ -301,9 +301,9 @@ TEST_F(PipeInputsTest, CorruptedSnapshotFieldIsNamedWithItsSerial) {
#if !MOBILEGL_PIPE_VERIFY
GTEST_SKIP() << "verify not compiled in (MOBILEGL_PIPE_VERIFY=OFF)";
#else
const Uint64 serialBefore = gPipeInputs.FilledState().CurrentVerbSerial;
const Uint64 serialBefore = gPipeInputs->FilledState().CurrentVerbSerial;
MGPipeValidateForVerb(MGPipeVerb::DrawArrays);
const Uint64 serial = gPipeInputs.FilledState().CurrentVerbSerial;
const Uint64 serial = gPipeInputs->FilledState().CurrentVerbSerial;
EXPECT_EQ(serial, serialBefore + 1);
const MGPipeFieldMask& mask = kMGPipeClassFieldMask[static_cast<SizeT>(MGPipeVerbClass::kDraw)];
@@ -318,7 +318,7 @@ TEST_F(PipeInputsTest, CorruptedSnapshotFieldIsNamedWithItsSerial) {
EXPECT_EQ(field, MGPipeInputField::GetRenderStateParameters);
EXPECT_STREQ(kMGPipeInputFieldNames[static_cast<SizeT>(field)], "GetRenderStateParameters");
// The serial the report would print is the fill's, and it stamped that field.
EXPECT_EQ(gPipeInputs.FilledState().FilledGen[static_cast<SizeT>(field)], serial);
EXPECT_EQ(gPipeInputs->FilledState().FilledGen[static_cast<SizeT>(field)], serial);
// A forwarded field has nothing to corrupt, and the corruption of a field outside the
// mask is not seen by a compare over that mask.
@@ -341,15 +341,15 @@ TEST_F(PipeInputsTest, MutatedFieldIsNamedAtRead) {
#else
ASSERT_FALSE(g_logPath.empty()) << "main() did not set MOBILEGL_LOG_FILE_PATH";
MGPipeValidateForVerb(MGPipeVerb::Clear); // the parent armed nothing: Features.PipeVerify is false here
const Uint64 serial = gPipeInputs.FilledState().CurrentVerbSerial + 1; // the child's DrawArrays fill
const Uint64 serial = gPipeInputs->FilledState().CurrentVerbSerial + 1; // the child's DrawArrays fill
const ChildResult r = RunInChild([] {
MG_Config::Features.PipeVerify = true;
MGPipeValidateForVerb(MGPipeVerb::DrawArrays);
const Float boundary = gPipeInputs.GetLineWidth(); // boundary == live: completes
(void)gPipeInputs.GetRenderStateParameters();
const Float boundary = gPipeInputs->GetLineWidth(); // boundary == live: completes
(void)gPipeInputs->GetRenderStateParameters();
MG_State::pGLContext->SetLineWidth(boundary + 1.0f);
if (MG_State::pGLContext->GetLineWidth() == boundary) ::_exit(7); // the mutation did not take
(void)gPipeInputs.GetLineWidth(); // the stored value is stale against the live one: Fatal
(void)gPipeInputs->GetLineWidth(); // the stored value is stale against the live one: Fatal
::_exit(3);
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
@@ -375,7 +375,7 @@ TEST_F(PipeInputsTest, VerifyCorruptKnobNamesTheFieldAtEntry) {
#else
ASSERT_FALSE(g_logPath.empty()) << "main() did not set MOBILEGL_LOG_FILE_PATH";
MGPipeValidateForVerb(MGPipeVerb::Clear);
const Uint64 serial = gPipeInputs.FilledState().CurrentVerbSerial + 1;
const Uint64 serial = gPipeInputs->FilledState().CurrentVerbSerial + 1;
const ChildResult r = RunInChild([] {
MG_Config::Features.PipeVerify = true;
MG_Config::Features.PipeVerifyCorrupt = "GetRenderStateParameters";
@@ -428,7 +428,7 @@ TEST_F(PipeInputsTest, VerifyFatalOffLogsTheDivergenceAndContinues) {
#else
ASSERT_FALSE(g_logPath.empty()) << "main() did not set MOBILEGL_LOG_FILE_PATH";
MGPipeValidateForVerb(MGPipeVerb::Clear);
const Uint64 serial = gPipeInputs.FilledState().CurrentVerbSerial + 1;
const Uint64 serial = gPipeInputs->FilledState().CurrentVerbSerial + 1;
const ChildResult r = RunInChild([] {
MG_Config::Features.PipeVerify = true;
MG_Config::Features.PipeVerifyFatal = false;
@@ -467,8 +467,8 @@ TEST_F(PipeInputsTest, EveryVerbFillsItsClassAndNothingElse) {
<< kMGPipeInputFieldNames[f] << " after " << kMGPipeVerbNames[v];
}
}
EXPECT_EQ(gPipeInputs.ContextIdentity(), static_cast<const void*>(MG_State::pGLContext.get()));
EXPECT_TRUE(gPipeInputs.IsLive());
EXPECT_EQ(gPipeInputs->ContextIdentity(), static_cast<const void*>(MG_State::pGLContext.get()));
EXPECT_TRUE(gPipeInputs->IsLive());
#endif
}
@@ -481,9 +481,9 @@ TEST_F(PipeInputsTest, EveryVerbFillsItsClassAndNothingElse) {
TEST_F(PipeInputsTest, AFrontendMutationInsideAVerbRefreshesThePushedField) {
auto& ctx = *MG_State::pGLContext;
MGPipeValidateForVerb(MGPipeVerb::DrawArrays);
ASSERT_EQ(gPipeInputs.GetSamplingResolutionGeneration(), ctx.GetSamplingResolutionGeneration());
ASSERT_EQ(gPipeInputs.GetTextureBindGeneration(), ctx.GetTextureBindGeneration());
ASSERT_EQ(gPipeInputs.GetMaxTouchedTextureUnit(), ctx.GetMaxTouchedTextureUnit());
ASSERT_EQ(gPipeInputs->GetSamplingResolutionGeneration(), ctx.GetSamplingResolutionGeneration());
ASSERT_EQ(gPipeInputs->GetTextureBindGeneration(), ctx.GetTextureBindGeneration());
ASSERT_EQ(gPipeInputs->GetMaxTouchedTextureUnit(), ctx.GetMaxTouchedTextureUnit());
// What UniformManager's fallback path does mid-draw: change a sampler object's filter,
// which bumps the context-wide sampling-resolution generation (SamplerObject.cpp).
@@ -492,7 +492,7 @@ TEST_F(PipeInputsTest, AFrontendMutationInsideAVerbRefreshesThePushedField) {
sampler->SetMinFilter(sampler->GetMinFilter() == SamplerFilterMode::Nearest ? SamplerFilterMode::Linear
: SamplerFilterMode::Nearest);
ASSERT_NE(ctx.GetSamplingResolutionGeneration(), samplingBefore) << "the mutation did not move the counter";
EXPECT_EQ(gPipeInputs.GetSamplingResolutionGeneration(), ctx.GetSamplingResolutionGeneration());
EXPECT_EQ(gPipeInputs->GetSamplingResolutionGeneration(), ctx.GetSamplingResolutionGeneration());
// And a bind reached from inside a verb moves both the bind generation and the
// high-water mark of touched units (TextureState::NoteUnitTouched).
@@ -501,8 +501,8 @@ TEST_F(PipeInputsTest, AFrontendMutationInsideAVerbRefreshesThePushedField) {
ctx.NoteTextureUnitTouched(unit);
ASSERT_NE(ctx.GetTextureBindGeneration(), bindBefore) << "the bind did not move the counter";
ASSERT_EQ(ctx.GetMaxTouchedTextureUnit(), unit);
EXPECT_EQ(gPipeInputs.GetTextureBindGeneration(), ctx.GetTextureBindGeneration());
EXPECT_EQ(gPipeInputs.GetMaxTouchedTextureUnit(), ctx.GetMaxTouchedTextureUnit());
EXPECT_EQ(gPipeInputs->GetTextureBindGeneration(), ctx.GetTextureBindGeneration());
EXPECT_EQ(gPipeInputs->GetMaxTouchedTextureUnit(), ctx.GetMaxTouchedTextureUnit());
}
// The notice refreshes the VALUE and never the stamp: a field this verb withheld the stamp
@@ -547,7 +547,7 @@ TEST_F(PipeInputsTest, AFrontendMutationInsideAVerbDoesNotDivergeAtRead) {
const ChildResult r = RunInChild([] {
MG_Config::Features.PipeVerify = true;
MGPipeValidateForVerb(MGPipeVerb::DrawArrays);
(void)gPipeInputs.GetSamplingResolutionGeneration(); // boundary == live: completes
(void)gPipeInputs->GetSamplingResolutionGeneration(); // boundary == live: completes
auto& ctx = *MG_State::pGLContext;
const Uint64 before = ctx.GetSamplingResolutionGeneration();
auto sampler = MakeShared<MG_State::GLState::SamplerObject>(0u);
@@ -556,10 +556,10 @@ TEST_F(PipeInputsTest, AFrontendMutationInsideAVerbDoesNotDivergeAtRead) {
if (ctx.GetSamplingResolutionGeneration() == before) {
::_exit(7); // the mutation did not take: the case would pass for the wrong reason
}
(void)gPipeInputs.GetSamplingResolutionGeneration(); // Fatal{PipeVerifyDiffer} without the notice
(void)gPipeInputs->GetSamplingResolutionGeneration(); // Fatal{PipeVerifyDiffer} without the notice
ctx.NoteTextureUnitTouched(ctx.GetMaxTouchedTextureUnit() + 1);
(void)gPipeInputs.GetTextureBindGeneration();
(void)gPipeInputs.GetMaxTouchedTextureUnit();
(void)gPipeInputs->GetTextureBindGeneration();
(void)gPipeInputs->GetMaxTouchedTextureUnit();
});
ASSERT_TRUE(ExitedWith(r, 0)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("MGPipe: verify armed"), std::string::npos) << r.Log;
+1 -1
View File
@@ -375,7 +375,7 @@ namespace {
m_savedResourceOps = MGPipeGetResourceOps();
static const MGPipeResourceOps kEmpty{};
MGPipeSetResourceOps(&kEmpty);
m_savedContext = Move(MG_State::pGLContext);
m_savedContext = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
m_savedTable = MG_Backend::gBackendFunctionsTable;
+45 -45
View File
@@ -146,60 +146,60 @@ namespace {
// ---------------------------------------------------------------------------------
void ExpectDerivedDrawFieldsMatch(GLContext& ctx, const char* tag) {
SCOPED_TRACE(tag);
EXPECT_EQ(gPipeInputs.GetBlendColor(), ctx.GetBlendColor());
EXPECT_EQ(gPipeInputs->GetBlendColor(), ctx.GetBlendColor());
for (Uint i = 0; i < kMGMaxDrawBuffers; ++i) {
BlendEquation gotColor{}, gotAlpha{}, wantColor{}, wantAlpha{};
gPipeInputs.GetBlendEquationIndexed(i, gotColor, gotAlpha);
gPipeInputs->GetBlendEquationIndexed(i, gotColor, gotAlpha);
ctx.GetBlendEquationIndexed(i, wantColor, wantAlpha);
EXPECT_EQ(gotColor, wantColor) << "blend equation " << i;
EXPECT_EQ(gotAlpha, wantAlpha) << "blend equation " << i;
BlendFactor gotSrcRGB{}, gotDstRGB{}, gotSrcA{}, gotDstA{};
BlendFactor wantSrcRGB{}, wantDstRGB{}, wantSrcA{}, wantDstA{};
gPipeInputs.GetBlendFuncIndexed(i, gotSrcRGB, gotDstRGB, gotSrcA, gotDstA);
gPipeInputs->GetBlendFuncIndexed(i, gotSrcRGB, gotDstRGB, gotSrcA, gotDstA);
ctx.GetBlendFuncIndexed(i, wantSrcRGB, wantDstRGB, wantSrcA, wantDstA);
EXPECT_EQ(gotSrcRGB, wantSrcRGB) << "blend func " << i;
EXPECT_EQ(gotDstRGB, wantDstRGB) << "blend func " << i;
EXPECT_EQ(gotSrcA, wantSrcA) << "blend func " << i;
EXPECT_EQ(gotDstA, wantDstA) << "blend func " << i;
EXPECT_EQ(gPipeInputs.GetColorMaskIndexed(i), ctx.GetColorMaskIndexed(i)) << "colour mask " << i;
EXPECT_EQ(gPipeInputs.IsCapabilityEnabledIndexed(CapabilityInput::Blend, i),
EXPECT_EQ(gPipeInputs->GetColorMaskIndexed(i), ctx.GetColorMaskIndexed(i)) << "colour mask " << i;
EXPECT_EQ(gPipeInputs->IsCapabilityEnabledIndexed(CapabilityInput::Blend, i),
ctx.IsCapabilityEnabledIndexed(CapabilityInput::Blend, i))
<< "indexed blend enable " << i;
}
EXPECT_EQ(gPipeInputs.GetCullFaceMode(), ctx.GetCullFaceMode());
EXPECT_EQ(gPipeInputs.GetDepthFunc(), ctx.GetDepthFunc());
EXPECT_EQ(gPipeInputs.GetDepthMask(), ctx.GetDepthMask());
EXPECT_EQ(gPipeInputs->GetCullFaceMode(), ctx.GetCullFaceMode());
EXPECT_EQ(gPipeInputs->GetDepthFunc(), ctx.GetDepthFunc());
EXPECT_EQ(gPipeInputs->GetDepthMask(), ctx.GetDepthMask());
for (Uint i = 0; i < RenderStateParameters::MAX_VIEWPORTS; ++i) {
EXPECT_EQ(gPipeInputs.GetDepthRangeIndexed(i), ctx.GetDepthRangeIndexed(i)) << "depth range " << i;
EXPECT_EQ(gPipeInputs.GetViewportIndexed(i), ctx.GetViewportIndexed(i)) << "viewport " << i;
EXPECT_EQ(gPipeInputs.IsCapabilityEnabledIndexed(CapabilityInput::ScissorTest, i),
EXPECT_EQ(gPipeInputs->GetDepthRangeIndexed(i), ctx.GetDepthRangeIndexed(i)) << "depth range " << i;
EXPECT_EQ(gPipeInputs->GetViewportIndexed(i), ctx.GetViewportIndexed(i)) << "viewport " << i;
EXPECT_EQ(gPipeInputs->IsCapabilityEnabledIndexed(CapabilityInput::ScissorTest, i),
ctx.IsCapabilityEnabledIndexed(CapabilityInput::ScissorTest, i))
<< "indexed scissor enable " << i;
}
EXPECT_EQ(gPipeInputs.GetLineWidth(), ctx.GetLineWidth());
EXPECT_EQ(gPipeInputs.GetLogicOp(), ctx.GetLogicOp());
EXPECT_EQ(gPipeInputs.GetMinSampleShadingValue(), ctx.GetMinSampleShadingValue());
EXPECT_EQ(gPipeInputs.GetPatchDefaultInnerLevel(), ctx.GetPatchDefaultInnerLevel());
EXPECT_EQ(gPipeInputs.GetPatchDefaultOuterLevel(), ctx.GetPatchDefaultOuterLevel());
EXPECT_EQ(gPipeInputs.GetPatchVertices(), ctx.GetPatchVertices());
EXPECT_EQ(gPipeInputs.GetPolygonModeFront(), ctx.GetPolygonModeFront());
EXPECT_EQ(gPipeInputs.GetPolygonOffsetFactor(), ctx.GetPolygonOffsetFactor());
EXPECT_EQ(gPipeInputs.GetPolygonOffsetUnits(), ctx.GetPolygonOffsetUnits());
EXPECT_EQ(gPipeInputs.GetPrimitiveRestartIndex(), ctx.GetPrimitiveRestartIndex());
EXPECT_EQ(gPipeInputs.GetProvokingVertexMode(), ctx.GetProvokingVertexMode());
EXPECT_EQ(gPipeInputs.GetScissorBox(), ctx.GetScissorBox());
EXPECT_EQ(gPipeInputs.GetViewport(), ctx.GetViewport());
EXPECT_EQ(gPipeInputs->GetLineWidth(), ctx.GetLineWidth());
EXPECT_EQ(gPipeInputs->GetLogicOp(), ctx.GetLogicOp());
EXPECT_EQ(gPipeInputs->GetMinSampleShadingValue(), ctx.GetMinSampleShadingValue());
EXPECT_EQ(gPipeInputs->GetPatchDefaultInnerLevel(), ctx.GetPatchDefaultInnerLevel());
EXPECT_EQ(gPipeInputs->GetPatchDefaultOuterLevel(), ctx.GetPatchDefaultOuterLevel());
EXPECT_EQ(gPipeInputs->GetPatchVertices(), ctx.GetPatchVertices());
EXPECT_EQ(gPipeInputs->GetPolygonModeFront(), ctx.GetPolygonModeFront());
EXPECT_EQ(gPipeInputs->GetPolygonOffsetFactor(), ctx.GetPolygonOffsetFactor());
EXPECT_EQ(gPipeInputs->GetPolygonOffsetUnits(), ctx.GetPolygonOffsetUnits());
EXPECT_EQ(gPipeInputs->GetPrimitiveRestartIndex(), ctx.GetPrimitiveRestartIndex());
EXPECT_EQ(gPipeInputs->GetProvokingVertexMode(), ctx.GetProvokingVertexMode());
EXPECT_EQ(gPipeInputs->GetScissorBox(), ctx.GetScissorBox());
EXPECT_EQ(gPipeInputs->GetViewport(), ctx.GetViewport());
for (const StencilFace face : {StencilFace::Front, StencilFace::Back}) {
const StencilFaceState& got = gPipeInputs.GetStencilState(face);
const StencilFaceState& got = gPipeInputs->GetStencilState(face);
const StencilFaceState& want = ctx.GetStencilState(face);
EXPECT_EQ(std::memcmp(&got, &want, sizeof(StencilFaceState)), 0)
<< "stencil face " << static_cast<int>(face);
}
for (SizeT i = 0; i < static_cast<SizeT>(CapabilityInput::CapabilityInputCount); ++i) {
const CapabilityInput cap = static_cast<CapabilityInput>(i);
EXPECT_EQ(gPipeInputs.IsCapabilityEnabled(cap), ctx.IsCapabilityEnabled(cap)) << "capability " << i;
EXPECT_EQ(gPipeInputs->IsCapabilityEnabled(cap), ctx.IsCapabilityEnabled(cap)) << "capability " << i;
}
}
@@ -214,7 +214,7 @@ namespace {
// the only thing in the suite that covers them.
void ExpectAssembledBlockIsTheLiveBlock(GLContext& ctx, const char* tag) {
SCOPED_TRACE(tag);
EXPECT_EQ(std::memcmp(&gPipeInputs.GetRenderStateParameters(), &ctx.GetRenderStateParameters(),
EXPECT_EQ(std::memcmp(&gPipeInputs->GetRenderStateParameters(), &ctx.GetRenderStateParameters(),
sizeof(RenderStateParameters)),
0)
<< "the assembled working block is not byte-identical to the live one - a chunk of "
@@ -554,7 +554,7 @@ namespace {
// restored on the way out so the case stays independent (SanityTest's idiom).
struct ContextGuard {
SharedPtr<GLContext> Previous;
ContextGuard() : Previous(Move(MG_State::pGLContext)) {
ContextGuard() : Previous(MG_State::pGLContext.Take()) {
MG_State::pGLContext = MakeUnique<GLContext>();
MGPipeApplierReset();
}
@@ -653,7 +653,7 @@ namespace {
// The vacuity guard: the block still holds what the fill copied out of the DEFAULT
// context, so it must currently DISAGREE with the live one. If this ever passes, the
// comparisons below would be checking the filler against itself.
ASSERT_NE(gPipeInputs.GetLineWidth(), ctx.GetLineWidth());
ASSERT_NE(gPipeInputs->GetLineWidth(), ctx.GetLineWidth());
applyWholeBlock();
@@ -667,7 +667,7 @@ namespace {
// would hand the backends a 63-wide rectangle where 64 was asked for. The literal
// is std::lround's answer - round half AWAY FROM ZERO, so 1.5 -> 2 and 2.5 -> 3,
// not the banker's rounding a nearbyint() transcription would give.
EXPECT_EQ(gPipeInputs.GetViewport(), IntVec4(2, 3, 64, 32));
EXPECT_EQ(gPipeInputs->GetViewport(), IntVec4(2, 3, 64, 32));
} // phase 1, kDraw
// Phase 2, kClear: the three clear values. The verb's own fill runs FIRST and copies
@@ -678,13 +678,13 @@ namespace {
ctx.SetClearColor(FloatVec4(0.9f, 0.8f, 0.7f, 0.6f));
ctx.SetClearDepth(0.125f);
ctx.SetClearStencil(21);
ASSERT_NE(gPipeInputs.GetClearDepth(), ctx.GetClearDepth());
ASSERT_NE(gPipeInputs->GetClearDepth(), ctx.GetClearDepth());
applyWholeBlock();
EXPECT_EQ(gPipeInputs.GetClearColor(), ctx.GetClearColor());
EXPECT_EQ(gPipeInputs.GetClearDepth(), ctx.GetClearDepth());
EXPECT_EQ(gPipeInputs.GetClearStencil(), ctx.GetClearStencil());
EXPECT_EQ(gPipeInputs->GetClearColor(), ctx.GetClearColor());
EXPECT_EQ(gPipeInputs->GetClearDepth(), ctx.GetClearDepth());
EXPECT_EQ(gPipeInputs->GetClearStencil(), ctx.GetClearStencil());
}
// Phase 3, kReadback: GetClampReadColor, the one derived field no draw and no clear
@@ -692,12 +692,12 @@ namespace {
{
MG_Test::ScopedPipeVerb verb(MGPipeVerb::ReadPixels);
ctx.SetClampReadColor(GL_FALSE);
ASSERT_NE(gPipeInputs.GetClampReadColor(), ctx.GetClampReadColor());
ASSERT_NE(gPipeInputs->GetClampReadColor(), ctx.GetClampReadColor());
applyWholeBlock();
EXPECT_EQ(gPipeInputs.GetClampReadColor(), ctx.GetClampReadColor());
EXPECT_EQ(gPipeInputs.GetClampReadColor(), static_cast<GLenum>(GL_FALSE));
EXPECT_EQ(gPipeInputs->GetClampReadColor(), ctx.GetClampReadColor());
EXPECT_EQ(gPipeInputs->GetClampReadColor(), static_cast<GLenum>(GL_FALSE));
}
}
@@ -764,7 +764,7 @@ namespace {
TEST(RenderStateSpans, IncrementalChunksKeepEveryDerivedFieldInStep) {
struct ContextGuard {
SharedPtr<GLContext> Previous;
ContextGuard() : Previous(Move(MG_State::pGLContext)) {
ContextGuard() : Previous(MG_State::pGLContext.Take()) {
MG_State::pGLContext = MakeUnique<GLContext>();
MGPipeApplierReset();
}
@@ -926,7 +926,7 @@ namespace {
// idiom, and the same guard cases 3 and 5 declare inline).
struct ApplierContextGuard {
SharedPtr<GLContext> Previous;
ApplierContextGuard() : Previous(Move(MG_State::pGLContext)) {
ApplierContextGuard() : Previous(MG_State::pGLContext.Take()) {
MG_State::pGLContext = MakeUnique<GLContext>();
MGPipeApplierReset();
}
@@ -1122,7 +1122,7 @@ namespace {
pack.Pack.SkipRows = 5;
pack.Pack.SwapBytes = true;
MGPipeApplySetPixelPackState(pack);
const PixelStoreParameters got = gPipeInputs.GetPixelStoreParameters(false);
const PixelStoreParameters got = gPipeInputs->GetPixelStoreParameters(false);
EXPECT_EQ(got.Alignment, 8);
EXPECT_EQ(got.RowLength, 37);
EXPECT_EQ(got.SkipRows, 5);
@@ -1155,13 +1155,13 @@ namespace {
std::memcpy(tail[1].IntView, secondInt, sizeof(secondInt));
MGPipeApplySetVertexAttribDefaults(hdr, tail);
EXPECT_EQ(gPipeInputs.GetCurrentVertexAttribute(2).floatValue[0], 1.5f);
EXPECT_EQ(gPipeInputs.GetCurrentVertexAttribute(2).floatValue[3], 4.5f);
EXPECT_EQ(gPipeInputs.GetCurrentVertexAttribute(9).floatValue[2], 0.5f);
EXPECT_EQ(gPipeInputs->GetCurrentVertexAttribute(2).floatValue[0], 1.5f);
EXPECT_EQ(gPipeInputs->GetCurrentVertexAttribute(2).floatValue[3], 4.5f);
EXPECT_EQ(gPipeInputs->GetCurrentVertexAttribute(9).floatValue[2], 0.5f);
// ... and the CONVERTED views are the record's, not a memcpy of the float bits:
// 1.5f's bits are 0x3FC00000, and the frontend's int view of it is 1.
EXPECT_EQ(gPipeInputs.GetCurrentVertexAttribute(2).intValue[0], 1);
EXPECT_EQ(gPipeInputs.GetCurrentVertexAttribute(9).intValue[0], -1);
EXPECT_EQ(gPipeInputs->GetCurrentVertexAttribute(2).intValue[0], 1);
EXPECT_EQ(gPipeInputs->GetCurrentVertexAttribute(9).intValue[0], -1);
}
// delete_render_state: the record stops being live and a bound handle stops being
+1 -1
View File
@@ -1807,7 +1807,7 @@ namespace {
m_previousPush = MG_Config::Features.PipePush;
MG_Config::Features.PipePush |= kMGPipeSubsystemResources;
MGPipeSetResourceOps(&m_ops);
m_previousContext = Move(MG_State::pGLContext);
m_previousContext = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
}
~PushArm() {
+1 -1
View File
@@ -231,7 +231,7 @@ namespace {
MG_Config::Features.PipePush |= kMGPipeSubsystemResources |
kMGPipeSubsystemTextureResources |
kMGPipeSubsystemSamplers;
m_previousContext = Move(MG_State::pGLContext);
m_previousContext = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
MGPipeTextureEmitterInstance().ResetForTest();
// AND THE APPLIER IS A PROCESS SINGLETON, so its object records outlive a case. With
+169 -8
View File
@@ -58,7 +58,7 @@ namespace {
class TrackerAggregates : public ::testing::Test {
protected:
void SetUp() override {
m_previous = Move(MG_State::pGLContext);
m_previous = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
}
void TearDown() override { MG_State::pGLContext = Move(m_previous); }
@@ -174,7 +174,7 @@ namespace {
}
TEST_F(TrackerAggregates, ANoteWithoutALiveContextIsANoOp) {
SharedPtr<GLContext> held = Move(MG_State::pGLContext);
SharedPtr<GLContext> held = MG_State::pGLContext.Take();
MGP_NOTE_AGGREGATE(BufferChange); // must not dereference a null context
MG_State::pGLContext = Move(held);
SUCCEED();
@@ -246,7 +246,7 @@ namespace {
class TrackerWalk : public ::testing::Test {
protected:
void SetUp() override {
m_previous = Move(MG_State::pGLContext);
m_previous = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
m_savedPush = MG_Config::Features.PipePush;
ResetTheServerSideSingletons();
@@ -904,7 +904,7 @@ namespace {
class TrackerAttribPayload : public ::testing::Test {
protected:
void SetUp() override {
m_previous = Move(MG_State::pGLContext);
m_previous = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
}
void TearDown() override { MG_State::pGLContext = Move(m_previous); }
@@ -993,7 +993,7 @@ namespace {
class TrackerShippedEmitter : public ::testing::Test {
protected:
void SetUp() override {
m_previous = Move(MG_State::pGLContext);
m_previous = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
m_savedPush = MG_Config::Features.PipePush;
MG_Config::Features.PipePush = kMGPipeSubsystemsMigratedAtP2;
@@ -1166,7 +1166,7 @@ namespace {
// that the capability itself reaches the applier's assembled block on the next draw.
TEST_F(TrackerShippedEmitter, AClipDistanceEnableReArmsTheResidualBlock) {
Draw();
ASSERT_FALSE(MobileGL::MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::ClipDistance0))
ASSERT_FALSE(MobileGL::MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::ClipDistance0))
<< "the premise is gone: a fresh context already has clip distance 0 enabled";
Ctx().SetCapability(CapabilityInput::ClipDistance0, true);
@@ -1177,7 +1177,7 @@ namespace {
<< "the premise is gone: a clip-distance enable now moves the pipeline version";
EXPECT_EQ(static_cast<Uint16>(Ctx().GetPipelineStateVersion()), pipelineBefore);
EXPECT_TRUE(MobileGL::MG_Pipe::gPipeInputs.IsCapabilityEnabled(CapabilityInput::ClipDistance0))
EXPECT_TRUE(MobileGL::MG_Pipe::gPipeInputs->IsCapabilityEnabled(CapabilityInput::ClipDistance0))
<< "a capability change that moves only m_version never reached the applier's block";
}
@@ -1295,11 +1295,172 @@ namespace {
// stand into the next verb. A draw with no context is a no-op; its argument must not
// outlive it.
MGPipeSetPendingBaseInstance(11);
SharedPtr<GLContext> parked = Move(MG_State::pGLContext);
SharedPtr<GLContext> parked = MG_State::pGLContext.Take();
Draw();
EXPECT_EQ(MGPipePendingBaseInstance(), 0u)
<< "the no-live-context exit left the draw's base instance standing for the next verb";
MG_State::pGLContext = Move(parked);
}
// ===================================================================================
// Bits 11-14 across the contexts of one share group (C8)
// ===================================================================================
//
// Textures, renderbuffers and samplers belong to the share group, but the aggregates
// bits 11-14 read are bumped on the context a change is made THROUGH. These change an
// object through context B and then walk context A with B never walking in between -
// what a second thread drawing into its own context does, and on one thread the shape
// that leaves the monolith's one tracker latched on A (no context switch reaches it).
class TrackerShareGroup : public ::testing::Test {
protected:
void SetUp() override {
m_previous = MG_State::pGLContext.Take();
const auto group = MakeShared<MG_State::GLState::ShareGroupState>();
m_a = MakeShared<GLContext>(group);
m_b = MakeShared<GLContext>(group);
MakeLive(m_a);
}
void TearDown() override { MG_State::pGLContext = Move(m_previous); }
// The live context is the one MGP_NOTE_AGGREGATE lands on.
static void MakeLive(const SharedPtr<GLContext>& ctx) { MG_State::pGLContext = ctx; }
Uint32 WalkA() {
MakeLive(m_a);
return m_tracker.Update(*m_a, MGPipeVerbClass::kDraw);
}
// Prime A and prove the steady state, so whatever fires next is the change's.
void PrimeA() {
WalkA();
ASSERT_EQ(WalkA(), 0u) << "the fixture did not reach a steady state";
}
static void ExpectFired(Uint32 dirty, MGPipeDirty bit, const char* why) {
EXPECT_NE(dirty & MGPipeDirtyBit(bit), 0u)
<< kMGPipeDirtyNames[static_cast<SizeT>(bit)] << " did not fire on A: " << why;
}
MGPipeTracker m_tracker;
SharedPtr<GLContext> m_a;
SharedPtr<GLContext> m_b;
SharedPtr<GLContext> m_previous;
};
TEST_F(TrackerShareGroup, OnlyASecondContextMakesTheWalkReadTheShareClocks) {
EXPECT_TRUE(m_a->GetShareGroup()->HasSeveralContexts());
const GLContext solo;
EXPECT_FALSE(solo.GetShareGroup()->HasSeveralContexts());
}
// glTexParameteri through B on a texture A samples: completeness (bit 12's null view),
// the effective sampler (bit 13) and the image window (bit 14) all moved.
TEST_F(TrackerShareGroup, ATextureParameterThroughASiblingFiresTheUnitSetBits) {
const auto& tex = m_a->CreateTextureObject(1, TextureTarget::Texture2D);
ASSERT_TRUE(tex != nullptr);
ASSERT_EQ(m_b->GetTextureObject(1), tex) << "the premise is ONE texture seen by both contexts";
PrimeA();
MakeLive(m_b);
tex->SetMaxLevel(4);
const Uint32 dirty = WalkA();
ExpectFired(dirty, MGPipeDirty::NewSamplerViews, "a sibling's glTexParameteri moved completeness");
ExpectFired(dirty, MGPipeDirty::NewSamplers, "a sibling's glTexParameteri moved the sampler state");
ExpectFired(dirty, MGPipeDirty::NewShaderImages, "a sibling's glTexParameteri moved the image window");
EXPECT_EQ(WalkA(), 0u) << "the share clocks fire forever";
}
TEST_F(TrackerShareGroup, ATextureUploadThroughASiblingFiresTheViewAndImageBits) {
const auto& tex = m_a->CreateTextureObject(1, TextureTarget::Texture2D);
ASSERT_TRUE(tex != nullptr);
PrimeA();
MakeLive(m_b);
static_cast<TextureObjectBase*>(tex.get())->BumpContentVersion();
const Uint32 dirty = WalkA();
ExpectFired(dirty, MGPipeDirty::NewSamplerViews, "a sibling's upload can define the level a view needs");
ExpectFired(dirty, MGPipeDirty::NewShaderImages, "a sibling's upload moved the image window's input");
EXPECT_EQ(WalkA(), 0u);
}
// F-3 across contexts: set_framebuffer_state inlines an attachment's format and extent, so
// B redefining the storage of a texture attached to A's framebuffer has to re-emit A's.
TEST_F(TrackerShareGroup, ATextureStorageDefinitionThroughASiblingFiresTheFramebufferBit) {
const auto& tex = m_a->CreateTextureObject(1, TextureTarget::Texture2D);
ASSERT_TRUE(tex != nullptr);
const auto& fbo = m_a->CreateFramebufferObject(1);
ASSERT_TRUE(fbo != nullptr);
fbo->AttachTexture(FramebufferAttachmentType::Color0, tex, TextureUploadTarget::Texture2D);
m_a->GetFramebufferBindingSlot(FramebufferTarget::Draw).Bind(fbo);
PrimeA();
MakeLive(m_b);
tex->SetInternalFormat(MobileGL::TextureInternalFormat::RGBA8);
const Uint32 dirty = WalkA();
ExpectFired(dirty, MGPipeDirty::NewFramebuffer, "A's attachment was redefined through B (F-3)");
ExpectFired(dirty, MGPipeDirty::NewSamplerViews, "the definition moved the params aggregate too");
EXPECT_EQ(WalkA(), 0u);
}
TEST_F(TrackerShareGroup, ARenderbufferStorageThroughASiblingFiresTheFramebufferBit) {
const auto& rbo = m_a->CreateRenderbufferObject(1);
ASSERT_TRUE(rbo != nullptr);
rbo->AllocateStorage(IntVec2{4, 4});
const auto& fbo = m_a->CreateFramebufferObject(1);
ASSERT_TRUE(fbo != nullptr);
fbo->AttachRenderbuffer(FramebufferAttachmentType::Color0, rbo);
m_a->GetFramebufferBindingSlot(FramebufferTarget::Draw).Bind(fbo);
PrimeA();
MakeLive(m_b);
rbo->AllocateStorage(IntVec2{8, 8});
const Uint32 dirty = WalkA();
ExpectFired(dirty, MGPipeDirty::NewFramebuffer, "A's attached renderbuffer was resized through B");
EXPECT_EQ(WalkA(), 0u);
}
TEST_F(TrackerShareGroup, ASamplerParameterThroughASiblingFiresTheSamplerBit) {
const auto& sampler = m_a->CreateSamplerObject(1);
ASSERT_TRUE(sampler != nullptr);
PrimeA();
MakeLive(m_b);
sampler->SetWrapS(MobileGL::SamplerWrapMode::ClampToEdge);
const Uint32 dirty = WalkA();
ExpectFired(dirty, MGPipeDirty::NewSamplers, "a sibling's glSamplerParameteri moved the CSO");
EXPECT_EQ(WalkA(), 0u);
}
// The split shape: one tracker per context, and B walks as well. B's own walk sees its own
// aggregate; A's sees the clock.
TEST_F(TrackerShareGroup, EachContextsOwnTrackerSeesTheSiblingsChange) {
const auto& tex = m_a->CreateTextureObject(1, TextureTarget::Texture2D);
ASSERT_TRUE(tex != nullptr);
MGPipeTracker trackerB;
PrimeA();
MakeLive(m_b);
trackerB.Update(*m_b, MGPipeVerbClass::kDraw);
ASSERT_EQ(trackerB.Update(*m_b, MGPipeVerbClass::kDraw), 0u);
tex->SetMaxLevel(4);
EXPECT_NE(trackerB.Update(*m_b, MGPipeVerbClass::kDraw) & MGPipeDirtyBit(MGPipeDirty::NewSamplers), 0u);
ExpectFired(WalkA(), MGPipeDirty::NewSamplers, "B's tracker saw the change and A's did not");
EXPECT_EQ(WalkA(), 0u);
MakeLive(m_b);
EXPECT_EQ(trackerB.Update(*m_b, MGPipeVerbClass::kDraw), 0u)
<< "B fired again with nothing moved: its own change reached it twice";
}
// The claim the share clocks rest on for the program bits: a program is a group object too,
// but bits 6-8 read its versions off the object itself, so a change through B already
// reaches A's walk with no clock at all.
TEST_F(TrackerShareGroup, AProgramChangeThroughASiblingNeedsNoShareClock) {
const Uint program = m_a->CreateProgram();
m_a->UseProgram(program);
PrimeA();
MakeLive(m_b);
m_b->GetProgramObject(program)->MarkUBOContentDirty();
ExpectFired(WalkA(), MGPipeDirty::NewGlobalConstants, "a sibling's glUniform* on the program in use");
}
} // namespace
@@ -132,7 +132,7 @@ namespace {
// case out of the gate's reach.
struct EmitterScope {
EmitterScope() {
m_previousContext = Move(MG_State::pGLContext);
m_previousContext = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
MGPipeVertexInputEmitterInstance().Reset();
MGPipeVertexInputEmitterInstance().ResetCounters();
+12 -12
View File
@@ -234,7 +234,7 @@ namespace {
// restores the process-wide state even when a gtest assertion unwinds the test body.
struct ScopedDirectGLESTextureBindings {
ScopedDirectGLESTextureBindings():
previousContext(MobileGL::Move(MobileGL::MG_State::pGLContext)),
previousContext(MobileGL::MG_State::pGLContext.Take()),
previousFunctions(MobileGL::MG_Backend::DirectGLES::g_GLESFuncs),
previousActiveUnit(MobileGL::MG_Backend::DirectGLES::TextureImpl::g_activeTextureUnit),
previousCache(MobileGL::MG_Backend::DirectGLES::TextureImpl::g_boundTexturesCache),
@@ -894,7 +894,7 @@ TEST(DirectVulkanSanity, AdvertisesSubgroupOnlyWhenVulkanReportsUsableSupport) {
TEST(DirectVulkanSanity, CapabilityRefreshInvalidatesTheCachedCompileEnvironment) {
using namespace MobileGL;
auto previousContext = Move(MG_State::pGLContext);
auto previousContext = MG_State::pGLContext.Take();
auto previousBackend = Move(MG_Backend::pActiveBackendObject);
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
@@ -1006,7 +1006,7 @@ TEST(GetterSanity, ClampsMaxVertexAttribsToCurrentValueStorageCapacity) {
TEST(GetterSanity, ReportsFragmentInterpolationLimitsForFloatAndIntegerQueries) {
using namespace MobileGL;
auto previousContext = Move(MG_State::pGLContext);
auto previousContext = MG_State::pGLContext.Take();
auto previousBackend = Move(MG_Backend::pActiveBackendObject);
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
@@ -1056,7 +1056,7 @@ TEST(GetterSanity, ReportsFragmentInterpolationLimitsForFloatAndIntegerQueries)
TEST(GetterSanity, StorageAndUniformBufferOffsetAlignmentsAreSeparateLimits) {
using namespace MobileGL;
auto previousContext = Move(MG_State::pGLContext);
auto previousContext = MG_State::pGLContext.Take();
auto previousBackend = Move(MG_Backend::pActiveBackendObject);
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
@@ -1145,7 +1145,7 @@ TEST(GetterSanity, AtomicCounterQueriesMatchShaderCompilerLimits) {
using namespace MobileGL;
namespace Transpiler = MG_Util::ShaderTranspiler;
auto previousContext = Move(MG_State::pGLContext);
auto previousContext = MG_State::pGLContext.Take();
auto previousBackend = Move(MG_Backend::pActiveBackendObject);
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
MG_Backend::pActiveBackendObject = MakeUnique<DynamicParameterBackend>(MG_Backend::DynamicBackendParameters{});
@@ -1224,7 +1224,7 @@ void main() {
TEST(GetterSanity, ComputeWorkGroupQueriesMatchShaderCompilerLimits) {
using namespace MobileGL;
auto previousContext = Move(MG_State::pGLContext);
auto previousContext = MG_State::pGLContext.Take();
auto previousBackend = Move(MG_Backend::pActiveBackendObject);
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
MG_Backend::pActiveBackendObject = MakeUnique<DynamicParameterBackend>(MG_Backend::DynamicBackendParameters{});
@@ -1305,7 +1305,7 @@ void main() {
TEST(GetterSanity, EveryLimitWithABuiltinAgreesWithItsQuery) {
using namespace MobileGL;
auto previousContext = Move(MG_State::pGLContext);
auto previousContext = MG_State::pGLContext.Take();
auto previousBackend = Move(MG_Backend::pActiveBackendObject);
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
MG_Backend::pActiveBackendObject =
@@ -1404,7 +1404,7 @@ TEST(GetterSanity, EveryLimitWithABuiltinAgreesWithItsQuery) {
TEST(GetterSanity, MaxElementIndexIsTheFull32BitIndexCeiling) {
using namespace MobileGL;
auto previousContext = Move(MG_State::pGLContext);
auto previousContext = MG_State::pGLContext.Take();
auto previousBackend = Move(MG_Backend::pActiveBackendObject);
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
MG_Backend::pActiveBackendObject = MakeUnique<DynamicParameterBackend>(MG_Backend::DynamicBackendParameters{});
@@ -1431,7 +1431,7 @@ TEST(GetterSanity, MaxElementIndexIsTheFull32BitIndexCeiling) {
TEST(GetterSanity, PerCategoryMultisampleCeilingsAreProbedRatherThanFlooredAtFour) {
using namespace MobileGL;
auto previousContext = Move(MG_State::pGLContext);
auto previousContext = MG_State::pGLContext.Take();
auto previousBackend = Move(MG_Backend::pActiveBackendObject);
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
@@ -1473,7 +1473,7 @@ TEST(GetterSanity, PerCategoryMultisampleCeilingsAreProbedRatherThanFlooredAtFou
TEST(ShaderCompilerSanity, ArbCullDistanceIsUsableBelow450) {
using namespace MobileGL;
auto previousContext = Move(MG_State::pGLContext);
auto previousContext = MG_State::pGLContext.Take();
auto previousBackend = Move(MG_Backend::pActiveBackendObject);
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
MG_Backend::pActiveBackendObject = MakeUnique<DynamicParameterBackend>(MG_Backend::DynamicBackendParameters{});
@@ -4579,7 +4579,7 @@ TEST(DirectGLESVertexInputDraw, TheAttributeWalkTakesItsBuffersFromTheRecordNotT
// this case exists to catch - gPipeInputs->GetBoundVertexArray()->GetAllAttributes() - has
// anything to read at all; a free-standing object would make the revert crash instead of
// disagree, which is a red for the wrong reason.
SharedPtr<GLContext> previousContext = Move(MG_State::pGLContext);
SharedPtr<GLContext> previousContext = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
MG_State::pGLContext->CreateVertexArrayObject(1);
MG_State::pGLContext->BindVertexArray(1);
@@ -4650,7 +4650,7 @@ TEST(DirectGLESVertexInputDraw, TheIndexArmTakesItsBufferAndItsSerialFromTheReco
// The frontend's element slot has moved to another buffer with nothing emitted, in a real
// context for the reason the case above gives.
SharedPtr<GLContext> previousContext = Move(MG_State::pGLContext);
SharedPtr<GLContext> previousContext = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<GLContext>();
MG_State::pGLContext->CreateVertexArrayObject(1);
MG_State::pGLContext->BindVertexArray(1);
@@ -222,7 +222,7 @@ TEST_F(ContextStateOwnershipTest, DestroyingOneContextLeavesTheOtherAlone) {
TEST_F(ContextStateOwnershipTest, ReleasingAnEglContextRestoresTheThreadsPreviousGLState) {
const auto contextA = NewContext(EGL_NO_CONTEXT);
const auto before = MG_State::pGLContext;
const auto before = MG_State::pGLContext.Shared();
ASSERT_NE(before, nullptr);
MakeCurrent(contextA);
@@ -234,7 +234,7 @@ TEST_F(ContextStateOwnershipTest, ReleasingAnEglContextRestoresTheThreadsPreviou
}
TEST_F(ContextStateOwnershipTest, AThreadWithoutACurrentContextUsesTheProcessDefaultContext) {
const auto processDefault = MG_State::pGLContext;
const auto processDefault = MG_State::pGLContext.Shared();
ASSERT_NE(processDefault, nullptr);
EXPECT_EQ(processDefault, MG_State::ProcessDefaultGLContext());
+8 -8
View File
@@ -1469,19 +1469,19 @@ TEST_F(PipeWireCodecTest, SetContextValuesRoundTripsIntoPipeInputs) {
// kReadback's class carries the two texture-unit counters, kDraw's the rest
// (FillPoints.def) - the stamp is what publishes a RECORD-SUPPLIED field for the read.
MGPipeServerStampVerbBoundary(MGPipeVerb::ReadPixels);
EXPECT_EQ(gPipeInputs.GetActiveTextureUnit(), 9);
EXPECT_EQ(gPipeInputs.GetMaxTouchedTextureUnit(), 41);
EXPECT_EQ(gPipeInputs->GetActiveTextureUnit(), 9);
EXPECT_EQ(gPipeInputs->GetMaxTouchedTextureUnit(), 41);
MGPipeServerStampVerbBoundary(MGPipeVerb::DrawArrays);
for (Uint32 t = 0; t < 15; ++t) {
EXPECT_EQ(gPipeInputs.GetTouchedBufferBindingPointCount(static_cast<BufferTarget>(t)),
EXPECT_EQ(gPipeInputs->GetTouchedBufferBindingPointCount(static_cast<BufferTarget>(t)),
SizeT{100 + t})
<< "target " << t;
}
EXPECT_TRUE(gPipeInputs.IsTransformFeedbackActive());
EXPECT_TRUE(gPipeInputs.IsTransformFeedbackPaused());
EXPECT_EQ(gPipeInputs.GetTransformFeedbackGeneration(), 0xA1A2A3A4A5A6A7A8ull);
EXPECT_EQ(gPipeInputs.GetBoundTransformFeedbackLifetimeId(), 0xB1B2B3B4B5B6B7B8ull);
EXPECT_EQ(gPipeInputs.GetTransformFeedbackCapturedVertices(), 0xC1C2C3C4C5C6C7C8ull);
EXPECT_TRUE(gPipeInputs->IsTransformFeedbackActive());
EXPECT_TRUE(gPipeInputs->IsTransformFeedbackPaused());
EXPECT_EQ(gPipeInputs->GetTransformFeedbackGeneration(), 0xA1A2A3A4A5A6A7A8ull);
EXPECT_EQ(gPipeInputs->GetBoundTransformFeedbackLifetimeId(), 0xB1B2B3B4B5B6B7B8ull);
EXPECT_EQ(gPipeInputs->GetTransformFeedbackCapturedVertices(), 0xC1C2C3C4C5C6C7C8ull);
MGPipeServerClearVerbBoundary();
}
+12 -12
View File
@@ -816,21 +816,21 @@ TEST(ServerLoopTest, AClearRecordCrossesAndIsStampedAsAVerbBoundary) {
ASSERT_TRUE(fixture.StartLoop());
// The pre-state is the honest one: nothing has stamped yet in this process.
ASSERT_NE(MG_Pipe::gPipeInputs.CurrentVerb(), MG_Pipe::MGPipeVerb::Clear);
ASSERT_NE(MG_Pipe::gPipeInputs->CurrentVerb(), MG_Pipe::MGPipeVerb::Clear);
const MG_Pipe::MGPClear clear = WholeFramebufferClear();
ASSERT_TRUE(fixture.EmitAndWait(MG_Pipe::MGPWireOp::Clear, &clear, sizeof(clear)));
Server::ServerLoop& loop = Server::ServerLoopInstance();
EXPECT_EQ(loop.DrainedRecords(), 1u);
EXPECT_EQ(MG_Pipe::gPipeInputs.CurrentVerb(), MG_Pipe::MGPipeVerb::Clear)
EXPECT_EQ(MG_Pipe::gPipeInputs->CurrentVerb(), MG_Pipe::MGPipeVerb::Clear)
<< "PipeApplier::StampVerbBoundary did not run, so every server-side PipeInputs read "
"would abort on the first field inside SyncRenderState";
// MANDATORY on leaving the applier (p1's M-5): without it a SPAWNED server latches the flag
// for its whole life, every later read is judged against the last verb's mask, and the
// sticky forwards start aborting under strict on the very case their exemption exists for.
EXPECT_FALSE(MG_Pipe::gPipeInputs.ServerStampedVerb())
EXPECT_FALSE(MG_Pipe::gPipeInputs->ServerStampedVerb())
<< "MGPipeServerClearVerbBoundary was not called when the apply thread left the applier";
// No backend object in this process, so the five class-B verbs DECLINE. Asserted rather
@@ -1629,7 +1629,7 @@ namespace {
// Empty on success, else the step that failed - the harness's SkipReason shape.
std::string BringUp() {
PinHeadlessEglEnvironment();
savedContext = Move(MG_State::pGLContext);
savedContext = MG_State::pGLContext.Take();
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
Server::ServerLoop& loop = Server::ServerLoopInstance();
// InitSplitRoles step 1: the server's private backend, no GL and no EGL yet; its
@@ -1944,13 +1944,13 @@ TEST(ServerLoopEglTest, ServerLivenessFollowsControlFramesAcrossReleaseAndRecrea
MGL_EGL_BRING_UP_OR_BAIL(fixture);
const auto live = [] {
Bool answer = false;
EXPECT_EQ(OnApply([&] { answer = MG_Pipe::gPipeInputs.IsLive(); }), MOBILEGL_OK);
EXPECT_EQ(OnApply([&] { answer = MG_Pipe::gPipeInputs->IsLive(); }), MOBILEGL_OK);
return answer;
};
EXPECT_FALSE(live()) << "surface creation alone is not a served current context";
ASSERT_TRUE(fixture.MakeCurrent());
EXPECT_TRUE(live());
auto client = Move(MG_State::pGLContext);
auto client = MG_State::pGLContext.Take();
EXPECT_TRUE(live()) << "server liveness must not consult the client GLContext";
MG_State::pGLContext = Move(client);
ASSERT_TRUE(fixture.ReleaseCurrent());
@@ -2571,7 +2571,7 @@ TEST(ServerLoopTest, AnInstancedBaseVertexDrawRecordReachesTheSinkWithItsFieldsI
EXPECT_EQ(seen.FirstRange.IndexBias, 5);
EXPECT_FALSE(seen.HadUserIndices);
EXPECT_FALSE(seen.HadIndirect);
EXPECT_FALSE(MG_Pipe::gPipeInputs.ServerStampedVerb());
EXPECT_FALSE(MG_Pipe::gPipeInputs->ServerStampedVerb());
fixture.Stop();
}
@@ -2714,7 +2714,7 @@ TEST(P5fReverseChannel, GlErrorsUseTheOwnedCallbackWithoutAResidualPull) {
g_fvErrorCalls = 0;
MG_Pipe::MGPipeResetResidualPullCountForTesting();
MG_Pipe::MGPipeServerStampVerbBoundary(MG_Pipe::MGPipeVerb::Clear);
MG_Pipe::gPipeInputs.RecordError(ErrorCode::InvalidOperation,
MG_Pipe::gPipeInputs->RecordError(ErrorCode::InvalidOperation,
MakeUnique<GenericErrorInfo>("fv", "draw", "driver message"));
EXPECT_EQ(g_fvErrorCalls, 1u);
EXPECT_EQ(g_fvErrorCode, static_cast<Uint32>(ErrorCode::InvalidOperation));
@@ -2780,7 +2780,7 @@ TEST(P5fReverseChannel, RecordErrorWithoutCallbackIsNamedFatal) {
MG_Config::Ipc.StrictErrors = true;
MG_Config::Ipc.RoleSplitState = true;
MG_Pipe::gMGPipeCallbacks.OnGlError = nullptr;
MG_Pipe::gPipeInputs.RecordError(ErrorCode::InvalidOperation, nullptr);
MG_Pipe::gPipeInputs->RecordError(ErrorCode::InvalidOperation, nullptr);
std::_Exit(9);
}, ::testing::KilledBySignal(SIGABRT), "");
EXPECT_NE(ReadLog().find("OnGlError.callback-missing"), std::string::npos);
@@ -2815,7 +2815,7 @@ TEST(P5fReverseChannel, GlErrorMessagesShareFifoWithOtherReverseEvents) {
ASSERT_EQ(Server::ServerLoopInstance().RunProbeOnApplyThreadForTesting(
+[](void*) -> MobileGLResult {
MG_Pipe::MGPipeServerStampVerbBoundary(MG_Pipe::MGPipeVerb::Clear);
MG_Pipe::gPipeInputs.RecordError(ErrorCode::InvalidOperation,
MG_Pipe::gPipeInputs->RecordError(ErrorCode::InvalidOperation,
MakeUnique<GenericErrorInfo>("fv", "driver error"));
const MG_Pipe::MGPRange whole{0, MG_Pipe::kMGPipeWholeBuffer};
MG_Pipe::gMGPipeCallbacks.OnGpuWritten({17, 3}, 1, &whole);
@@ -3165,7 +3165,7 @@ namespace {
const MG_Pipe::MGPDrawRange range{0, 3, 0};
if (!fixture.EmitAndWaitWithTail(MG_Pipe::MGPWireOp::DrawVbo, &info, sizeof(info), &range, sizeof(range)))
::_exit(65);
if (MG_Pipe::gPipeInputs.CurrentVerb() == MG_Pipe::MGPipeVerb::Clear) ::_exit(66);
if (MG_Pipe::gPipeInputs->CurrentVerb() == MG_Pipe::MGPipeVerb::Clear) ::_exit(66);
// A Clear encoded legally and then SHORTENED in the ring before it is published - the
// raw-record peer driver's move, in process: its header says 8 bytes, a header and no
// MGPClear at all.
@@ -3185,7 +3185,7 @@ namespace {
Server::ServerLoop& loop = Server::ServerLoopInstance();
(void)PollUntil([&] { return !loop.Running(); }, 3000);
int failed = 0;
if (MG_Pipe::gPipeInputs.CurrentVerb() == MG_Pipe::MGPipeVerb::Clear) failed |= kShortStamped;
if (MG_Pipe::gPipeInputs->CurrentVerb() == MG_Pipe::MGPipeVerb::Clear) failed |= kShortStamped;
if (!Remote::SessionLatched() || std::strstr(Remote::SessionLatchedLine(), "\"record.Minimum\"") == nullptr)
failed |= kShortWrongFault;
if (loop.DrainedRecords() != 2) failed |= kShortDrained;
+1
View File
@@ -173,6 +173,7 @@ MobileGL supports runtime configuration via environment variables.
| `MOBILEGL_FRAMES_IN_FLIGHT` | How many frames may be queued ahead of the GPU (Magma: its frame contexts; Espryt: how far presents may run ahead). The old name `MOBILEGL_MAGMA_FRAMESINFLIGHT` still works but is deprecated. | Integer `1`–`64` | `3` |
| `MOBILEGL_MAGMA_MAX_DRAWS_PER_COMMAND_BUFFER` | Draws and dispatches Magma records into one command buffer before it submits the buffer mid-frame and continues on a fresh one. `0` never splits. | Integer `0`–`16777216` | `16384` |
| `MOBILEGL_MAGMA_DESCRIPTOR_TRIM_FRAMES` | Frames a frame slot's descriptor pools must stay under a quarter full before Magma frees the slot's cached descriptor sets and grown pools. `0` never trims. | Integer `0`–`1048576` | `120` |
| `MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES` | Swapchain images Magma asks for beyond the surface's minimum, capped at its maximum. More images delay the reuse of the window buffer the display has just released, so fewer frames wait for its release; each costs a full-size colour buffer and a depth/stencil buffer. | Integer `0`–`16` | `0` |
| `MOBILEGL_ESPRYT_AVOID_SAMPLER_MIPMAP_MIN_FILTER` | Avoid sampler mipmap minification filters. | `0`, `1` | `0` |
| `MOBILEGL_COHERENT_AS_FLUSH` | Treat persistent `GL_MAP_FLUSH_EXPLICIT_BIT` maps as coherent (app-compat for engines like Flywheel that never flush them). | `0`, `1` | `0` |
| `MOBILEGL_ESPRYT_FORCE_DS_READBACK_EMULATION` | Always emulate depth/stencil `glReadPixels`/`glGetTexImage` by shader sampling on Espryt, instead of using the driver's own depth/stencil readback where it has one. | `0`, `1` | `0` |
+268 -2
View File
@@ -17,7 +17,9 @@ The plan and its measurements are in [PLAN-P15.md](PLAN-P15.md); the audit is in
- No minSdk raise for the shipped build: API 29 is a SEPARATE artifact (its own library, plugin APK and
FCL-embedded copy).
- No record bypass: monolith = record arm.
- No emulated-TLS work below 29: b-i/b-ii/b-iii are dropped; native TLS at 29 is the TLS answer.
- TLS (superseded 2026-10-09): API 29 did not remove the TLS cost (native TLSDESC in a dlopen'ed library
costs about the same as emulated TLS), so portable hot-path TLS elimination is approved for all API
levels. No TLS-model attributes or API-level gates as the mechanism.
- No new Android API usage. Keep MobileGL platform-agnostic unless a platform path is measured and has
no portable alternative.
- ASurfaceControl, frame-rate hints and ADPF are deferred.
@@ -104,6 +106,22 @@ The plan and its measurements are in [PLAN-P15.md](PLAN-P15.md); the audit is in
- The one extra unit failure seen once, CompositorRecovery.ACompositorOnTheServerWindowRecovers..., is a
pre-existing load flake: under full CPU load it fails 6/20 without the change and 2/20 with it.
**Hot-path TLS cut (2026-10-09 night, worktree `.claude/worktrees/tlshoist`, branch `tlshoist` on origin
e70925d3, local, not pushed):**
- c0a9b2cd pGLContext and gPipeInputs become constant-initialized pointer slots (no TLS init wrapper or
guard; the owning SharedPtr lives in a second thread_local, released before the slot is cleared at
thread exit). 36f55af8 the applier lookup cache is one block. 6191cbf2 Magma session read and built-slot
lookup inline. abb22eef Espryt bound serial and per-context cache share one block (epoch bump closes ABA).
d4a00835 owner release order + SanityTest fix.
- Host: unit 92 failures, the same set as the baseline; integration 2 (Spawn.ColdStart.ClearThenReadPixels
on both backends), as the baseline. Split-OFF NDK arm64 and the plugin LTO build compile.
- Device (SCOREBOARD tls): Magma +6.3 % fps, GL CPU -0.14 ms; Espryt +0.9 %, -0.05 ms. TLS resolver
0.058 -> 0.034 (Magma), 0.049 -> 0.035 (Espryt) ms/frame.
- Remaining emutls per frame (~3-4k): pGLContext ~2.3k, gPipeInputs 0.6-1.1k, Magma session 0.6k
(GetActiveRenderPass), ResolveAttributeFromBinding note bumps, SetupWireDraw. Each further cut is
~0.002 ms; not done.
- Perfetto traces of a second A/B (tlspf) are in `runs/tlspf/*/p15.pftrace` for the present-wait work.
**LTO and the server check (coordinator):**
- libMobileGLServer.so is built and packaged by the LTO-ON assemblePluginRelease. Its only libMobileGL
import, `mobilegl_server_main`, is exported by the LTO lib.
@@ -149,7 +167,7 @@ The plan and its measurements are in [PLAN-P15.md](PLAN-P15.md); the audit is in
- Open: whether a static TLS model (initial-exec) on the hot variables can remove the 0.05 ms in a dlopen'ed lib on
bionic; and what actually makes the api29 Magma build faster (not isolated).
- The shipped build stays API 26. The FCL-embedded 29 copy still needs FCL's own minSdk switch.
5b. IN PROGRESS 2026-10-09, offline (no new capture): present-wait timeline from the existing P15 traces (fbm, c4, c1c2: sched, kgsl submit/retire, gfx atrace, SF frametimeline). Confirm against the TLS agent's base-vs-change Perfetto traces on e70925d3.
5b. DONE 2026-10-09 (offline), see [PRESENT-WAIT.md](PRESENT-WAIT.md). Cause: the display buffer release (~every other frame renders into the buffer just handed back) gates the whole single-batch frame, then ~0.8 ms GPU start latency + 0.5 ms execution; the next queueBuffer throttles on it. MobileGL CPU is not on that path. Options: more Magma swapchain images, gate only the window pass, present off the GL thread. Original scope: present-wait timeline from the existing P15 traces (fbm, c4, c1c2: sched, kgsl submit/retire, gfx atrace, SF frametimeline). Confirm against the TLS agent's base-vs-change Perfetto traces on e70925d3.
- Finding (egc profiles, e70925d3, cpuhunt, monolith): render-thread on-CPU + off-CPU = frame time.
| | Espryt | Magma |
|---|---|---|
@@ -169,6 +187,13 @@ The plan and its measurements are in [PLAN-P15.md](PLAN-P15.md); the audit is in
- fence create/signal times;
- SurfaceFlinger latch/release.
- Decide whether earlier submission (or another portable change) shrinks the wait.
5c. QUEUED 2026-10-10, after the quick before/after fps run:
- Capture: one Perfetto run per arm (Espryt monolith base vs pwgate+pmflush; Magma monolith base vs
pwgate+pmflush+extra 2), traces in scratchpad p15/runs/pwlat.
- Derive offline: a rough per-frame timeline, and the input-to-present latency from the SF
frametimeline.
- Write it up in docs/Disaggregated/pwait/: what the levers do, the effect on fps and latency,
the knob, and the FIFO caveat (extra images add latency only with vsync on).
6. Smaller follow-ups:
- DONE 2026-10-09: `bench_session.sh stop` now runs `pin_clocks.sh restore` first (verified over a
17-session run: max clocks back to stock after every session, daemons running, no session file).
@@ -227,6 +252,238 @@ The plan and its measurements are in [PLAN-P15.md](PLAN-P15.md); the audit is in
- The device lock is released by devjob2 when m2ab ends.
- The plugin installs `top.mobilegl.plugin.*.trace` from earlier phases are still on the device.
## Open: Espryt small-store write rename (branch `pmflush`, 2026-10-09, host-verified, needs device)
**Not a p15 regression.** MONOLITH-DIFF's top Espryt row (`FlushPendingRangesFrom` driver 0.091 + libc
0.025, "dev 0") is the rename the doc's own caveat lists: dev's `FlushPendingRangesNow` costs 0.086 + 0.019
in the same profiles. Both are the same three-tier ladder, unchanged since dev f973008c. Inclusive:
dev 0.066 / p15 0.078 (feat-esp-1), 0.106 on the newer api29ab e26 run. So the drain is real cost that
dev pays too.
**What the drain is.** Under it, 0.080 of 0.106 ms/frame is one Adreno driver routine reached from
`glCopyBufferSubData` (dispatch slot 0x670 -> 0x3250c0 -> 0x2ee9d0, with heap allocations inside).
So it is the upload-ring tier: one GPU copy job per queued partial range. The 1.21.5 in-world trace
(5998912 calls, last 252 frames) shows the shape: 162 glBufferSubData a frame. 122 of them are partial
writes from offset 0, mostly 96 or 192 bytes into 288-byte vertex stores, and ~3 KB into 6.7 KB ones.
That is Minecraft's per-format immediate vertex buffer. Magma already renames these stores
(`RenameBusyWireStore`, S0 M4); `WriteWireBuffer` costs 0.031 ms/frame there, so Magma needs nothing.
**Change.** `RenameSmallStoreForDrain` (Managers.cpp) runs before the draw-time drain. For a store
<= 64 KiB whose unwritten bytes are <= 8 KiB, it replaces the queue with [0, store). The pinned ladder
then takes its tier 1, the whole-buffer orphan-map: no copy job, and recorded draws keep the old
storage. It refuses when the store holds bytes the host copy does not have: `serverGpuWritten`,
queued resident writes, persistent/immutable/imported stores, or split staged coverage short of the
whole store. On the trace this renames 108 of 122 partial writes a frame, at +101 KiB of host memcpy a
frame; a plain 64 KiB bound would cost +811 KiB, because of 128-byte writes into a 53 KiB index store.
The ladder bodies and the G5 pins are untouched.
**Tests.** EsprytFlushLadder has 3 new unit cases. There are 2 new scenarios, one per backend on every
arm: AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour and
CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes. The skip
census mirrors their siblings' skipped lanes. Red-once: dropping the `serverGpuWritten` refusal reds
the atomic case on DirectGLES.Spawn, which reads back 16 instead of 32; monolith and inproc pass
because the frontend reads GPU writes back before a partial CPU write.
**Suite results.** WSL archlinux, clang Release, lavapipe, env MOBILEGL_ITEST_REQUIRE_GPU=1, suites run
one at a time:
- unit 2907/2907;
- integration 5300/5300 on the labels gpu, split, magma-all-split, magma-full-split,
monolith-control, cold-start, cpu-mip-split, clientarrays-split and remint-fallback-split;
- 354/354 spawn+TCP buffer, SSBO, atomic, persistent, XFB and index scenarios;
- 18/18 Espryt retraces (OpenRA, 1.21.4-in-world, 1.21.11-main-menu, sodium, create-instancing, Iris
BSL; each monolith, SPLIT and SPAWN);
- both Android arm64 shapes compile (disaggregated ON and OFF, android-26).
A first run with the dozen ICD (REQUIRE_GPU=ON in the cache) failed 1488 DirectVulkan cases. That is
the ICD, not this change: there were 0 DirectGLES failures.
**Host blocker for retrace evidence (pre-existing).** Espryt on llvmpipe segfaults in the 1.21.5 fixture
at call 75682 (a glDrawElements right after vertex buffer 8 is deleted and recreated). This happens on
the base tree too. Magma completes (SSIM 0.985 on dozen). So Espryt cannot be checked for SSIM on this
trace on the host.
**Device ask (Perfetto first, per the 2026-10-09 rule).** FCL MC 1.21.5 vanilla bench scene, monolith,
cpuhunt pinned, base = origin e70925d3 vs pmflush, same LTO settings. Run Espryt (the arm under test)
and Magma (control, expected identical). Capture a Perfetto trace per arm with:
- sched_switch/wakeup, cpu_frequency;
- atrace gfx/view/hal;
- kgsl gpu_frequency and GPU busy/slices;
- dma-fence signals;
- SurfaceFlinger frame timeline.
Report one typical frame as a timeline: render thread runnable/running/blocked, queueBuffer/dequeueBuffer
waits, the GPU slice and its end against the next frame's throttle wait. The question is whether
removing ~100 copy jobs a frame shortens the GPU slice and with it the ~0.8-1.0 ms queueBuffer wait (a
shorter frame), or only cuts CPU (a longer wait, the same frame). simpleperf zoom: `FlushPendingRangesFrom`
inclusive and its callees, expected to drop from ~0.106 towards ~0.03 ms/frame (the orphan-map plus the
extra memcpy). Also check the driver's map path (slot 0x550 -> 0x1db8a0) does not grow into new
allocations per rename. Correctness: SSIM/golden on the device retrace of minecraft-1.21.5-vanilla-fcl
plus the Iris/BSL cases, Espryt.
## Present-wait levers A + B (branch `pwgate`, worktree `.claude/worktrees/pwgate`, 2026-10-09)
Built on origin/feat/disaggregated a759b4b7. Host-only so far; the device plan is below. Mechanism:
PRESENT-WAIT.md (p15/pwait): every other frame renders into the buffer the display just released,
and the whole frame batch was gated behind that buffer's release fence.
**Commits (local, not pushed):**
- 168451bc Magma: submit a frame's off-screen work ahead of the swapchain acquire wait.
- 66adc7aa Espryt: flush once per frame ahead of the window buffer's first use.
- dd3e608a Tests: WindowPassGateScenario covers frames split around the window pass.
- cdd2160f Magma: MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES asks for swapchain images beyond the
surface minimum.
**Lever A, Magma (no knob).**
- `FrameData::acquiredImageReferenced` means the open recording uses the acquired swapchain image.
It is reset at every acquire (`WaitAndAcquireNextImage`, `AcquireNextImageInCurrentSlot`).
- `SubmitPendingCommandBuffer` waits on `imageAvailableSemaphore` only when the recording references
the image, or when the caller forces the wait (`ParkActiveTarget`'s wait-out). It marks the
semaphore consumed only when it waited. Present's own submission still waits whenever the
semaphore is unconsumed.
- `SubmitAheadOfAcquiredImage()` runs before the frame's first use of the acquired image. It flushes
what is recorded so far without the wait, then marks the image referenced. It is called from:
- `SetupDraw` when the draw framebuffer is the default one, next to `SplitOversizedRecording`,
before anything of the draw is recorded. Splitting later in setup lands after the draw's
descriptor bind, because the attachment pre-resolve reads the default framebuffer's read index.
That was measured as VUID-vkCmdDraw-None-08600 plus an llvmpipe segfault.
- `ClearWireFramebuffer` for the default framebuffer.
- `ResolveWireImage` for the acquired colour image. This is the net under blits, copies, readbacks
and shared-image presents.
- `Present`. A frame that never touched the window submits its work unwaited, and the present's
own submission carries the wait, possibly with no command buffer.
- Inside a draw's preparation (`m_wirePreparationDepth != 0`) it only marks the image; it never
submits.
- Wait stage: every acquire wait now uses `FrameContext::kAcquireWaitStages`
(COLOR_ATTACHMENT_OUTPUT | TRANSFER). Before, mid-frame flushes waited at ALL_COMMANDS and the
present submit at TOP_OF_PIPE, which waits for nothing.
- `TransitionWireImage` adds those stages to the source scope when a default colour image leaves
PRESENT_SRC_KHR or UNDEFINED.
- Engagement proof: one latched log line,
`DirectVulkan: a frame's off-screen work goes to the queue ahead of its window pass ...`.
- Acquire timing is unchanged: the next image is still acquired at the end of Present.
- Acquiring later cannot move the gate. The buffer queue's free list is FIFO, so a later dequeue
gets the same buffer, or a more recently released one, with the same release time R.
- It would also break the buffer-age contract: `CurrentDrawBufferAge` answers for the image
acquired at the previous present.
- So no device A/B was spent on it.
**Sync-correctness argument (Magma).**
- One wait per signal. Each acquire signals imageAvailableSemaphore once. Exactly one submission
waits on it: the first whose recording references the image, or the present's, or the park
wait-out. All three check and set `imageAvailableSemaphoreConsumed`. The next acquire on the slot
comes after the slot's fence wait, so by then the semaphore is unsignaled with no pending wait.
- Recordings that never reference the acquired image carry no wait. That is correct because none of
their commands access it.
- Reads of `m_defaultFramebufferImageIndex` that name the previously presented image touch a
different image.
- The old code did not order those reads against an acquire either.
- Every first access of an acquired image is a layout transition out of PRESENT_SRC_KHR or UNDEFINED:
- `TransitionWireImage`, whose source scope includes kAcquireWaitStages;
- `TransitionToPresent`, whose source scope is ALL_COMMANDS.
- The semaphore wait's second scope covers kAcquireWaitStages in its own batch and in every later
batch. So the transition is ordered after the presentation engine's release, even when the use is
in a later submission than the wait. Through the transition's ALL_COMMANDS destination, everything
after it is ordered too.
- renderFinished is signaled by the present submission. That is last in submission order, so its
first scope covers the off-screen submissions too.
- Unchanged by this work:
- Frames in flight: split submissions take pooled fences and advance `lastSubmitIndex`, and the
present's slot wait covers them.
- Wire render-pass guard: `FlushPendingCommands` ends the open pass.
- Pass-barrier coalescing: barriers order across submissions.
- Deferred clears: the default framebuffer never defers.
- Not machine-checked. lavapipe syncval does not flag a broken acquire chain.
- Positive control: removing the source-stage fix while keeping the narrowed wait still gave
0 hazards.
- It never flagged the old present submit's TOP_OF_PIPE either.
- The argument above rests on the spec.
**Lever A, Espryt (no knob).**
- `FlushAheadOfWindowBufferUse()` issues one `glFlush` per frame, just before `BindCurrentFBO` or
`SyncAndBindFramebufferByHandle` moves the driver's binding to framebuffer 0. A thread-local flag
limits it to once per frame and is reset at the present's swap.
- Window surfaces only: a pbuffer has no lazy dequeue.
- Not issued on MobileGL's own scoped binding restores, or when the binding is already 0. A frame
that renders straight into framebuffer 0 has nothing to flush ahead.
- No wait and no glFinish. Adreno dequeues lazily at the first default-framebuffer use.
- Host coverage is pixels only, because the harness has no window surface.
**Lever B (knob, default 0).**
- `MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES` (0-16) requests
`max(frames-in-flight hint, surface minImageCount + extra)` images, clamped to maxImageCount.
- Logged as `Set minImageCount = N (surface min M, max X, extra K)`.
- Documented in userguide/configuration.md and the README knob table.
- Cost per extra image at 2560x1600: one RGBA colour buffer (~16 MB) plus the default framebuffer's
same-size depth/stencil image.
- Vulkan only. Espryt's EGL buffer count needs a platform API, so it is deferred.
**Host verification.** Setup: WSL archlinux, clang, CMake 3.31.10, `~/mgl-pwgate-ci31`, lavapipe,
suites run serially.
| Check | Result | Baseline |
|---|---|---|
| Unit | 2904 tests, 92 failed (ServerSpawn / PeerLatch / FuzzArm2) | same 92, environmental |
| Integration: `integration-gpu`, `-magma-all-split`, `-magma-full-split`, minus spawn and tcp, `MOBILEGL_ITEST_REQUIRE_GPU=1` | 3883 tests, 2 failed (both Spawn.ColdStart ClearThenReadPixels) | same 2 |
| Syncval (submit-time, shader heuristic): WindowPassGate + CrossFrameBuffer + DefaultFramebufferAcrossSwap.ADraw*, monolith and inproc | 0 hazards, 0 VUIDs; also clean with EXTRA_SWAPCHAIN_IMAGES=2 and FRAMES_IN_FLIGHT=2 | — |
| CI gates `magma_runahead_checks.py negative`, `validation`, `magma_cache_checks.py` | rc 0 | — |
| EXTRA_SWAPCHAIN_IMAGES=2 | 85 present-shaped Magma entries pass; minImageCount 4+2 = 6 on the headless surface | — |
| Android arm64 plugin release (`assemblePluginRelease`), API 26 and API 29 | both rc 0 | — |
- The integration run includes WindowPassGateScenario on DirectGLES and DirectVulkan (monolith,
Split, Split.Full), plus the `DirectVulkan.WindowPassGate.` arming entry.
- Verb tables are unchanged, so split_coverage was not needed.
- The spawn and tcp lanes fail on this host for every scenario: TcpServer.Start fails, and spawn
bring-up aborts with CapsBeforeFirstSnapshot.
- Pre-existing, not from this work: DefaultFramebufferAcrossSwap.AReadbackAfterASwap reads an image
already handed to presentation, which syncval reports as WRITE_AFTER_PRESENT. That is why the new
scenario reads back before its swaps.
**Device plan (not run; another agent has the phone).**
- Libs: both are API 26 default plugin builds.
- base: origin/feat/disaggregated a759b4b7.
- A: pwgate cdd2160f.
- Setup: same FCL, MC 1.21.5 vanilla frozen world, cpuhunt clocks, FCL pinned to cpu2-6.
- Validity rules: `fcl_bench.sh` VALID, freq and thermal sampled every 1-2 s, throttled runs dropped.
- Perfetto (PF=1): `p15_perfetto.cfg` with every `kgsl/*` ftrace event removed (not on this kernel).
Keep:
- sched (switch, waking, wakeup, blocked_reason), cpu_frequency and cpu_idle;
- atrace `gfx` + `view` for the FCL package and surfaceflinger (gfx is what creates the
`GPU completion` / `HWC release` FenceMonitor threads);
- process_stats and `android.surfaceflinger.frametimeline`;
- 5 s duration.
- Arms, 3 interleaved reps each:
1. Espryt monolith: base, A.
2. Espryt inproc: base, A.
3. Magma monolith: base, A, A+`MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES=1`, A+`=2`.
4. Magma inproc: base, A, A+1, A+2.
- Engagement proof:
- Magma A: logcat has the latched "goes to the queue ahead of its window pass" line, and the trace
shows QueueSubmit per frame rising from ~1.33 to ~2.3 (one submit just before the blit's draw,
one at present).
- Extra images: logcat shows `Set minImageCount = 6/7 (surface min 5 ...)`.
- Espryt A has no marker. Take one extra `gpu.renderstages` capture per Espryt arm (it works on
this device); it should show A's off-screen stages running before R.
- Analysis, with the scratchpad `p15/pwait/` scripts:
- `cycle.py <label> <runs...>`
- `pairs.py`
- `gexec.py`
- `sim.py <label> <start> <exec> <runs...>`
- Report per-frame timelines, not ms tables.
- Expected for lever A (PRESENT-WAIT, "What a fresh trace should confirm"):
- Gated frames stay at ~50 %.
- For gated frames, E - R falls from ~1.35 to ~0.9 ms: start latency plus the window pass only.
- Back-to-back execution is unchanged at ~0.5 ms.
- sim's throttle, ms/frame: Espryt mono 0.62 -> 0.49, Magma mono 0.72 -> 0.54,
Magma inproc 1.31 -> 1.09, Espryt inproc 1.09 -> 0.91.
- If E - R does not fall, either the driver gates the off-screen submission too, or the split is
not engaged. Check the submit count, and when the GPU work starts relative to R.
- Expected for lever B:
- `HWC release fence N has signaled` at >= 85 % of AcquireNextImageKHR.
- Gated frames < 20 %.
- Throttle < 0.2 ms/frame on monolith.
- inproc may need +2 (sim: 23 % still gated at k=2).
- The user picks lever B's default from these curves.
## Earlier (2026-10-09): cuts 1b + 1c, cut 4, pipe-record pieces
- **Landed locally (pushed after the BSL gpuhunt check):**
@@ -542,3 +799,12 @@ edit sources during a build; `touch` the edited headers if in doubt.
- Iris properties are backed up at `/data/local/tmp/p15-iris.properties`.
- `fcl_scene.sh restore` restores Iris; `fcl_p14.sh restore` restores the lib and `config.json`.
- The anland desktop is stopped during runs and restarted afterwards.
## pwab: device A/B of the present-wait levers (2026-10-10)
Result table, engagement evidence and the failed lever-B expectations are in [SCOREBOARD.md](SCOREBOARD.md) (section pwab). Summary: before a759b4b7, after pwgate cdd2160f + pmflush eec5e6e8 (+ `MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES=2` on Magma). fps after/before: Magma inproc 1.32 (1.495 of MobileGlues), Magma mono 1.34 (1.176), Espryt inproc 1.09 (1.102), Espryt mono 1.12 on reps 1+3 (0.896; before rep 2 NO WORLD, not re-run).
- Libs: `p15/libs/{pwbase,pwA,pwF,pwAF}`, symbols in `p15/syms/`. Worktrees `.claude/worktrees/{pwbase,pwF,pwAF}` hold the builds (pwF/pwAF are detached HEADs with eec5e6e8 cherry-picked, not pushed). The 3rdparty copy also needs `include/ska` (a gitlink) copied into a fresh worktree.
- Harness: `p15/pw/dev/` (chain.sh, session.sh, fcl_bench.sh with the post-Perfetto atrace stage made opt-in, devjob.sh), run data in `p15/runs/pwab`, Perfetto in `p15/runs/pwlat`.
- Not done: the per-arm timeline analysis (cycle.py/pairs.py/gexec.py) and the separate lever A / F / extra=1 arms, both cut by the user. Next: derive the timelines from `runs/pwlat` and find why the Magma gain exceeds the lever-B model.
- Harness note: a launch can fail with NO WORLD after four 240 s attempts (b-DirectGLES-r2); fclab2.sh only retries INVALID runs, not NO WORLD.
@@ -0,0 +1,358 @@
# P15 present wait on FCL: per-frame timeline
Offline analysis of the existing P15 Perfetto traces. Scene: Minecraft 1.21.5 vanilla, frozen world,
cpuhunt clocks (CPU 1497/1248 MHz, GPU 903 MHz, FCL pinned to cpu2-6), display at 165 Hz (6.06 ms
vsync). All 35 runs used are VALID. Frames counted: Espryt monolith 11049 (fbm/y, c4/v, c4/w), Magma
monolith 10938 (c1c2/t, c1c2/x, fbm/y), Magma inproc 10079 (c1c2/t, c1c2/x), Espryt inproc 4639
(c1/u), MobileGlues 14398 (c1c2, fbm, c4).
## Answer
The producer throttle in `queueBuffer` waits for the previous frame's GPU-completion fence. That fence
is late because of the display, not because the GPU is busy:
1. About every other frame (45-56 %) renders into the window buffer that the display has just handed
back. Its release fence is still pending, and it signals only at the display's next commit-done
(0.24 ms after the `crtc_event` kernel thread runs).
2. The whole frame's GPU work waits behind that fence. MobileGL submits the frame as one batch at the
swap (Espryt: one driver flush at `eglSwapBuffers`; Magma: the frame's first `vkQueueSubmit`
carries the acquire-semaphore wait with `ALL_COMMANDS`).
3. Once the buffer is released, the batch still needs about 1.3 ms before its fence signals: about
0.8 ms of GPU start latency plus 0.5 ms of execution.
4. Meanwhile the CPU has already rendered the next frame. Its `queueBuffer` throttles on that late
fence.
How the candidates come out:
- **(b) The wait for the compositor's buffer release is the trigger.** 99.4-99.6 % of all throttle
time follows such a gated frame. Frames whose buffer was already released cause no wait (0.00
ms/frame on every arm).
- **(a) Late, single-batch submission is an amplifier.** It puts the whole frame, not just the final
window pass, behind the gate.
- **(d) Something else: a fixed GPU start latency of about 0.8 ms** whenever a batch becomes runnable
on an idle GPU. It does not depend on how long the GPU was idle (0.3 ms or 4 ms), and it does not
count as GPU busy. It is the larger part of the time after the release.
- **(c) SurfaceFlinger GPU composition is ruled out.** `hasClientComposition` is 0 on every
SurfaceFlinger frame in every run, so composition is device-only and SurfaceFlinger does no GPU
work.
The GPU is idle about 4 ms per burst and runs about 0.5 ms per frame. That is the 15 %
`gpu_busy_percentage` the frequency sampler records.
## What the throttle waits on (mechanism)
- FCL's SurfaceView is a BLAST surface: the BufferQueue and its consumer (BLASTBufferQueue) live in
the FCL process. Both EGL and the Android Vulkan swapchain connect as `NATIVE_WINDOW_API_EGL`, so
`BufferQueueProducer::queueBuffer` ends with `lastQueuedFence->waitForever` (the `waitForever`
slice) on the previous queued buffer's acquire fence, which is its GPU-completion fence.
- The display runs at 165 Hz. SurfaceFlinger commits about 10.1-10.3 ms ahead of the target vsync
(`beginFrame ... vsyncIn 10.1ms`), and the HWC commit takes 3.2-4.1 ms. One FCL buffer per vsync is
latched (about 813 per 5 s). Every other queued frame is dropped by replacement in the BufferQueue,
which runs in async (MAILBOX / swap-interval-0) mode.
- BLAST keeps 2-3 buffers in flight to SurfaceFlinger (the `BufferTX` counter). Magma's swapchain has
5 images: MAILBOX, `max(FIF hint 3, surface minImageCount 5)`. That leaves the app 2 buffers: one
being rendered and one queued, which may be dropped. The Espryt and MobileGlues EGL surfaces show
the same A/B alternation, so they also leave the app 2 buffers (inferred, not read from the
driver).
- Each vsync, SurfaceFlinger hands back the buffer leaving the screen, with a release fence that
signals when the display flips. The free list is FIFO, so the app's next dequeue takes that buffer.
This is a gated frame (A). The frame after it (B) gets a dropped buffer, which is already free.
- GPU timing comes from libgui's `FenceMonitor` threads in the FCL process. They exist because atrace
`gfx` is on:
- `GPU completion` gives one `waiting for GPU completion N` slice per queued fence; its end is the
fence signal time E;
- `HWC release` does the same per dequeued buffer; its end is the release time R, and a
`... has signaled` instant marks a buffer that was already free.
- They are cross-checked against kernel-thread scheduling:
- `kgsl_hwsched` runs at R (median offset -0.00 ms): the kgsl sync object is satisfied and the
batch is dispatched;
- `kgsl-events` runs 0.12-0.16 ms before E (the fence signal);
- `kgsl-events` is also what wakes the presenting thread out of `waitForever` in 100 % of long
waits, with a 60-70 us runnable latency (clocks pinned, no frequency changes in the window).
## Espryt monolith: the typical cycle
Anchor: swap entry of a gated frame A = 0. Values are medians, with p10..p90 in brackets. Frame A is
followed by frame B; about 1.5 frames per vsync. Medians of different events do not compose exactly.
Per frame pair, B's throttle ends when A's fence signals. `kgsl-events` wakes the presenting
thread directly (+0.06 ms), so W1_B lands at or slightly before the FenceMonitor's E_A, which is
about 0.1 ms late.
```
Espryt monolith
t(ms) -3 -2 -1 0 1 2 3 4 5
|---------|---------|---------|---------|---------|---------|---------|---------|--
render thr ============A cpu========d===S ============B cpu========d===S~~~~~
display v R
GPU (FCL) .........A held........+++st+++##A####B###
fence A E
(d = dequeue, S = swap entry, ~ = queueBuffer throttle, v = crtc_event, R = buffer release,
. = A's batch submitted but held by the release fence, st = GPU start latency, # = GPU execution)
```
1. **-2.90** [-3.44..-2.47]: the previous swap returns and A's CPU frame starts on the render thread.
2. **-0.43** [-0.58..-0.38]: the first default-framebuffer use makes the Adreno EGL dequeue lazily.
A gets buffer X, whose release is pending.
3. **0.00**: `eglSwapBuffersWithDamageKHR(A)`. The driver flushes A's whole frame as one batch, and
kgsl holds it behind X's release fence. The GPU stays idle.
4. **0.09 to 0.10**: `queueBuffer(A)` throttles on the previous frame's fence. That fence has already
signaled, so there is no wait.
5. **0.19**: the swap returns and B's CPU frame starts.
6. **1.97** [0.85..4.66]: `crtc_event` runs (display commit-done).
7. **2.27** [1.11..4.98]: R_A, X is released. `kgsl_hwsched` dispatches A's batch at the same
instant.
8. **2.27 to about 3.1**: GPU start latency of about 0.8 ms, for dispatch and power-up (not GPU busy).
9. **2.71**: B dequeues a buffer that is already free.
10. **3.09**: `eglSwapBuffers(B)`. B's batch queues behind A's in the in-order context.
11. **About 3.1 to 3.58**: A executes on the GPU (0.5 ms).
12. **3.20** [2.69..4.11]: `queueBuffer(B)` starts throttling on E_A.
13. **3.58** [2.42..6.31]: E_A. `kgsl-events` signals, and the render thread is runnable after 60
us.
14. **About 3.6**: `queueBuffer(B)` returns. B's batch then runs back to back with A (E_B is about
E_A + 0.5), and the GPU idles about 4 ms until the next release.
The throttle is 0.61 ms/frame on average. 58 % of the frames that follow a gated frame wait, with a
median of 2.0 ms [0.35..3.35]. The two halves of the wait:
- **0.27: display before release.** B is already throttling before the display has released A's
buffer.
- **0.33: GPU after release.** About 0.20 of this is start latency and about 0.13 is A's execution.
Critical path for B's wait: display commit-done (`crtc_event`), then +0.24 ms to the release fence of
A's buffer, then the kgsl sync object, then `kgsl_hwsched` dispatch, then about 0.8 ms of GPU start,
then about 0.5 ms of A's execution, then `kgsl-events` signals E_A, then the render thread wakes
(+60 us) and `queueBuffer(B)` returns. MobileGL CPU work is not on this path.
Worked example: `fbm/y-DirectGLES-r1`, frames 648-649, from `win.py`, offsets from swap 648:
- crtc_event 1.874;
- HWC release thread wakes 2.054, R 2.09;
- `kgsl_hwsched` 2.082;
- swap 649 at 2.471, throttle from 2.57;
- `kgsl_hwsched` (retire) 3.247, `kgsl-events` 3.317;
- the render thread resumes at 3.38 (a 0.82 ms wait);
- 649 completes at 4.056, 0.48 ms after 648, back to back.
## Magma monolith
```
Magma monolith
t(ms) -3 -2 -1 0 1 2 3 4 5
|---------|---------|---------|---------|---------|---------|---------|---------|--
render thr d=========A cpu=========S d=========B cpu==========S~~~~wait~~~~
display v R
GPU (FCL) .........A held.........++++st+++##A####B###
fence A E
```
1. **-2.36**: `AcquireNextImageKHR` runs right after the previous present. A gets X, whose release is
pending; `HWC release` waits on it.
2. **-2.36 to 0**: A's CPU frame. All GPU work is recorded and nothing is submitted. There are 1.33
`QueueSubmit` per frame: the first comes 2.34 ms after the previous present, and the last 0.07 ms
before `QueuePresentKHR`.
3. **0**: `QueueSubmit`, then `QueuePresentKHR(A)`. The first submit of the frame carries the
image-available semaphore wait with `VK_PIPELINE_STAGE_ALL_COMMANDS_BIT`
(`SubmitPendingCommandBuffer` / `FrameContext::GetSubmitInfo`, `imageAvailableSemaphoreConsumed`),
so the whole frame is gated. `queueBuffer(A)` has no wait.
4. **0.20**: B acquires a buffer that is already free.
5. **2.11**: `crtc_event` runs.
6. **2.41** [1.64..5.46]: R_A. `kgsl_hwsched` dispatches A's batch.
7. **2.66 to 2.75**: B submits and presents, then throttles on E_A.
8. **3.79** [3.06..6.88]: E_A, which is R + 1.39 (about 0.87 start latency + 0.52 execution). B's
throttle ends about here.
The throttle is 0.71 ms/frame: display before release 0.26, GPU after release 0.45. 85 % of the
frames after a gated frame wait, with a median of 1.21 ms. Magma waits more per frame than Espryt
because it is faster on CPU: B reaches its throttle about 0.45 ms earlier relative to the release.
## Inproc arms (the apply thread presents)
```
Magma inproc (apply thread)
t(ms) -3 -2 -1 0 1 2 3 4 5
|---------|---------|---------|---------|---------|---------|---------|---------|--
apply thr =d==A cpu====S d===B cpu===S~~~~~~~~~~~~~~wait~~~~~~~~~~~~~~~
display v R
GPU (FCL) .............A held............++++st+++###A#####B###
fence A E
Espryt inproc (apply thread)
apply thr ======A cpu=d====S ======B cpu==d==S~~~~~~~~~~wait~~~~~~~~~~~
display v R
GPU (FCL) ...........A held...........++++st+++##A####B###
fence A E
```
Magma inproc:
1. **-1.21**: acquire, release pending.
2. **0**: A's submit and present on `mgl-srv-apply`.
3. **0.20**: B acquires a free buffer.
4. **1.41 to 1.52**: B presents, then throttles on E_A.
5. **2.82**: `crtc_event` runs.
6. **3.12**: R_A.
7. **4.59**: E_A, which is R + 1.46 (0.90 start latency + 0.56 execution). B's throttle ends here, a
3.0 ms wait in the median waiting pair.
The throttle is 1.28 ms/frame: display before release 0.69, GPU after release 0.58. 96 % of the
frames after a gated frame wait. Espryt inproc has the same shape: throttle 1.08 ms/frame
(0.54 + 0.53), with R at 2.79 and E_A at 4.20.
The chain reaches the GL thread (Thread-14) too. It sleeps 1.3-1.6 ms/frame, and 0.7-1.1 ms/frame of
those sleeps end within 0.3 ms of the apply thread's throttle ending. So the chain is: display, then
GPU, then the apply thread's `queueBuffer`, then the present credit, then the GL thread.
This explains the HANDOFF's "about 0.3 ms per frame beyond the apply CPU is unexplained". It is not
CPU. The apply thread's frame is its CPU plus this throttle, and the throttle grows as the presenting
thread gets faster, because the release is locked to the display and 1.3 ms of GPU path is chained
after it. Present credit 2 helps for the same reason (+3-7 % measured in HANDOFF): it lets the GL
thread run on while the apply thread sits in the throttle.
## MobileGlues control
```
MobileGlues
render thr =====A cpu==d=S =====B cpu==d=S ~~~~~~~~~~~wait~~~~~~~~~~~
display v R
GPU (FCL) .............A held............++++st+++##A####B###
fence A E
```
MobileGlues has the identical mechanism: the same lazy dequeue just before the swap, the same
whole-frame batch at `eglSwapBuffers`, and the same 47 % gated frames. Its offsets:
1. **-0.24**: A dequeues.
2. **0**: A swaps. `queueBuffer` comes 0.29 ms into `eglSwapBuffers`, which spends about 0.3 ms
before queueing.
3. **1.60**: B dequeues.
4. **2.08**: B throttles.
5. **3.13**: R_A.
6. **4.48**: E_A, which is R + 1.35 (0.87 start latency + 0.48 execution).
The throttle is 1.12 ms/frame: display before release 0.59, GPU after release 0.52. That matches the
1.4 ms/frame off-CPU seen in simpleperf. MobileGlues waits more than MobileGL monolith only because
its CPU frame is shorter (1.95 ms against 2.9-3.4 ms), so B reaches the gate earlier. Its GPU per
frame is the same: 0.48 ms back to back, against 0.50-0.56 for MobileGL.
## Why CPU cuts are partly absorbed
Across the arms, frame time is the presenting thread's CPU plus the throttle, and the throttle grows
as the CPU shrinks:
- Espryt monolith: CPU 3.35 + wait 0.61 = 4.00;
- Magma monolith: CPU 2.86 + wait 0.71 = 3.60;
- Espryt inproc: CPU 2.04 + wait 1.08 = 3.18;
- MobileGlues: CPU 1.95 + wait 1.12 = 3.07;
- Magma inproc: CPU 1.53 + wait 1.28 = 2.93.
CPU comes from `sched` over the trace window. At the monolith operating point about 80 % of a CPU
saving reaches frame time (Espryt to Magma: 0.49 less CPU gives 0.40 less frame). At the
inproc/MobileGlues point only about a third does (MobileGlues to Magma inproc: 0.42 less CPU gives
0.14 less frame).
The e70925d3 simpleperf numbers fit the same trend: Espryt has 3.08 ms on CPU and 0.82 off CPU in
Present; Magma has 2.63 and 1.03. The faster CPU waits more.
## Options (portable), with the effect read off the timeline
The effects come from `sim.py`. It is an in-order GPU queue model replayed on the measured CPU
schedule: start latency + execution from `gexec.py`, and each frame's measured release time. Its base
scenario reproduces the measured throttle within 0.01-0.03 ms/frame on all five arms. The results are
first-order: the CPU schedule is held fixed, so phase feedback is not modelled.
1. **One or two more swapchain images (Magma).** Request `surface minImageCount + 1` (or + 2) instead
of `max(FIF, minImageCount)` = 5. Then the buffer the display has just released goes to the back
of the FIFO free list and is reused one (or two) frames later, by which time its release fence has
usually signaled.
- In the current traces, a buffer reused k frames later at the CPU-bound cadence would still be
gated in:
- Magma monolith: 16 % of frames at k=1, 3 % at k=2 (50 % today);
- Espryt monolith: 21 % at k=1, 0 % at k=2;
- Magma inproc: 40 % at k=1, 23 % at k=2, 8 % at k=3.
- First-order effect: Magma monolith's throttle goes from 0.71 to about 0.0 ms/frame, so the frame
drops from 3.60 ms toward the CPU's 2.9 ms. Treat this as an upper bound; the faster schedule
reuses buffers sooner.
- Inproc needs +2 or +3.
- Cost: one 2560x1600 RGBA buffer (about 16 MB) per image. MAILBOX adds no latency.
- This is a real trade-off (memory), so A/B the count.
- Espryt has no NDK-public way to set an EGL window's buffer count. The private `ANativeWindow`
perform call or ASurfaceControl would need the user's greenlight under the platform-agnostic
rule.
2. **Gate only the window pass (split the frame's submission).**
- Magma:
- submit the offscreen work recorded so far without the image-available semaphore, at least once
before the swapchain image is first touched;
- attach the acquire wait only to the submit that contains the first swapchain-image access (the
final blit and present transition), not to the frame's first submit.
- Espryt: `glFlush` at the first default-framebuffer bind of a frame, just before the driver's lazy
dequeue. The offscreen work is then submitted with no release sync object in front of it.
- Effect: throttle 0.62 to 0.49 (Espryt monolith), 0.72 to 0.54 (Magma monolith), 1.31 to 1.09
(Magma inproc), 1.09 to 0.91 (Espryt inproc).
- The gain is small because the 0.8 ms GPU start latency is paid again for the final pass after
the release.
- It is the only portable lever for Espryt. With option 1 on top, the model gives about 0 on all
arms.
3. **Take the throttle off the GL thread.**
- Inproc: present credit 2 (already measured at +3-7 %; it costs a frame of latency, so it is the
user's decision).
- Magma monolith: the equivalent is a present thread that issues `vkQueuePresentKHR` off the GL
thread, with the same latency trade.
- Espryt monolith cannot do this: `eglSwapBuffers` stays on the context thread.
4. Not recommended:
- keeping the GPU awake to hide the 0.8 ms start latency (a power trade, not portable);
- anything in SurfaceFlinger or vsync.
## What a fresh e70925d3 trace should confirm
Run the scripts in `p15/pwait/` on the new run directories:
- `cycle.py <label> <runs...>`
- `pairs.py`
- `gexec.py`
- `sim.py <label> <start> <exec> <runs...>`
Expected on base e70925d3:
- gated frames about 50 %;
- throttle about 0.8 ms/frame (Espryt) and about 1.0 (Magma), matching simpleperf's Present off-CPU;
- 99+ % of the throttle after gated frames;
- R 0.24 ms after `crtc_event`, with `kgsl_hwsched` at R;
- E - R about 1.3-1.4 ms for gated frames, with back-to-back execution about 0.5 ms.
For a CPU-only change (the TLS agent's): frame time should drop by about 0.8 x the CPU saving at the
monolith point, with the throttle rising by the rest. If it does not rise, the model is wrong.
For the change in option 1:
- `HWC release fence N has signaled` should appear at 85 % or more of `AcquireNextImageKHR`;
- gated frames below 20 %;
- throttle below 0.2 ms/frame (monolith).
For the change in option 2: E - R for gated frames should fall from about 1.35 to about 0.9 ms (start
latency + final pass), and back-to-back execution should not change.
Config notes:
- The `kgsl/adreno_cmdbatch_*`, `adreno_syncobj_*` and `kgsl_waittimestamp_*` ftrace events in
`perfetto.cfg` are not recorded on this kernel (`ftrace_setup_errors` = 43 in every trace). Drop
them, or list `/sys/kernel/tracing/events/kgsl/` for the kgsl hardware-scheduler event names.
- `gpu.renderstages` does work on this device: `runs/gpu-bsl/*/gpu.pftrace` has Render/Surface/Blit
stages. One extra capture with it would split the 0.8 ms start latency from execution directly. Its
overhead should be A/B'd before using it in a perf capture.
- Keep atrace `gfx`: the `GPU completion` / `HWC release` FenceMonitor threads only exist while it is
on.
- MobileGL emits no atrace markers. A marker at the frame's flush/submit points and at the first
default-framebuffer bind would make option 2 directly visible.
## Files
All under scratchpad `p15/pwait/`:
- `tp.py`: trace_processor wrapper, cached;
- `pw.py`: per-frame alignment of S, D, R, W0/W1 and E;
- `cycle.py`: attribution and the cycle medians;
- `pairs.py`, `gexec.py`, `gapcost.py`, `reuse.py`, `wakelat.py`, `glchain.py`;
- `sim.py`: the counterfactuals;
- `win.py`, `seq.py`: raw windows;
- `diag.py`, `mkdiag.py`: the diagrams;
- outputs in `out/`.
@@ -84,6 +84,7 @@ H2 sessions:
| fbm2 ~11:00 (10-09) | y; z (as fbm); h = y + batch h (485dff14 + c85c9439) | 319.7 (1.68) | y 0.763 / 0.86 dev (3.03); h 0.768 / 0.87 dev (3.00) | y 0.805 / 0.85 dev (2.68); z 0.798 / 0.84 dev (2.69); h 0.812 / 0.85 dev (2.62) | - | - |
| lto ~17:30 (10-09) | o = ca0a3b74 + 2a/2b, -Pmobilegl.enableLto=OFF; l = the same, LTO ON (default) | 314.1 (1.71) | o 0.794 (2.99); l 0.800 (2.90) | o 0.850 (2.52); l 0.907 (2.36) | - | - |
| api29 ~19:00-21:30 (10-09) | a26 = 0650608d + e543e289 (default, API 26); a29 = the same tree, -Pmobilegl.androidApi=29 (42922d21); both LTO ON | 324.6 (1.67) | a26 0.771 (2.87); a29 0.777 (2.85) | a26 0.874 (2.33); a29 0.910 (2.26) | a26 0.998 (1.27 / 1.53); a29 1.013 (1.22 / 1.50) | a26 1.088 (1.23 / 1.16); a29 1.136 (1.15 / 1.09) |
| tls ~22:00 (10-09) | b = origin e70925d3 (libs/egc); t = tlshoist d4a00835 (libs/tls1); both LTO, API 26 | 318.6 (1.67) | b 0.805 (2.84); t 0.812 (2.79) | b 0.878 (2.35); t 0.933 (2.21) | - | - |
- **pt:** the blit view cache gives Magma inproc +1.2 % fps, with apply −0.03 ms/frame.
- **c1:** cut 1 is within noise (−1.7 % fps, +0.06 ms). It engaged (the mid-frame submit is gone) but saves ≤0.04 ms; see MONOLITH-DIFF.md.
@@ -144,6 +145,19 @@ H2 sessions:
- API 29 does not remove the TLS cost of the monolith render thread. MobileGL is dlopen'ed, so bionic resolves each TLSDESC through the linker's dynamic resolver (`tlsdesc_resolver_dynamic`), a call that costs about what `__emutls_get_address` did (0.05 ms/frame, about 2 % of the thread). The native-TLS switch is therefore not the source of the Magma gain; whatever it is (code layout and codegen of a different link, or the android-29 platform), this A/B does not isolate it.
- Untested lead for a real TLS saving: a static TLS model (initial-exec) for the hot variables. Bionic's room for static TLS in a dlopen'ed library is limited, so it needs its own measurement.
- The Espryt monolith profile run read 242.6 / 245.4 fps against 252.2 / 254.0 for api26, opposite to the 3-rep means; it is one run, the 3 interleaved reps decide.
- **tls (cpuhunt, 3 interleaved reps, all 15 runs VALID, tpl=0 thr=0, peak CPU 57.7-61.3 C):** hot-path
TLS cut (tlshoist: constinit pointer slots for pGLContext and gPipeInputs, one-block thread_local caches,
inline Magma session read). Emulated-TLS calls per frame (counting build, run tlsdiag): Magma 9111 -> 4336,
Espryt 7585 -> 3149.
- fps r1 / r2 / r3: Magma b 285.6 / 275.4 / 277.8 (279.6), t 295.1 / 301.4 / 295.2 (297.2, +6.3 %);
Espryt b 269.5 / 251.9 / 248.4 (256.6), t 260.6 / 270.6 / 245.2 (258.8, +0.9 %); MobileGlues 318.6.
- GL CPU (schedstat): Magma 2.35 -> 2.21, Espryt 2.84 -> 2.79 ms/frame.
- `__emutls_get_address` on the render thread (simpleperf, mean of 3 reps): Magma 0.058 -> 0.034,
Espryt 0.049 -> 0.035 ms/frame. Magma's MobileGL-side total falls more than that (-0.04 to -0.20 per
rep): the callers lose the init-wrapper/guard calls and spills too.
- A second session (tlspf, Perfetto, no simpleperf, 12 runs VALID) read Magma 278.6 -> 284.4 fps
(CPU 2.40 -> 2.30) and Espryt 246.2 -> 254.5 (2.94 -> 2.83). Traces in `runs/tlspf/*/p15.pftrace`,
not analysed yet.
- **bsl3 (gpuhunt, stopped on a CPU max cap in rep 2):** r1 Magma 55.6, Espryt 52.8, MobileGlues 57.2 fps.
That is Magma 0.97 and Espryt 0.92 of MobileGlues.
- **c1cbsl (gpuhunt, Iris + BSL, after a cooldown, 3 reps):** 1c does not cost GPU time.
@@ -245,3 +259,29 @@ Baseline b = 0650608d, x = e70925d3 (both LTO-ON, API 26), FCL on cpu2-6, simple
| Espryt | x | 252.8 | 2.82 | 0.194 | 0.0136 (0.013 / 0.014 / 0.014) |
EmitGlobalConstants drops by 0.0078 ms/frame on both backends (about 35 %), inside the expected 0.007-0.010. The whole frame (fps, GL CPU, ValidateForVerb) is within noise: ValidateForVerb varies 0.17-0.22 between reps of one arm.
## pwab: present-wait levers before/after, cpuhunt, vanilla frozen world (2026-10-10)
Before = a759b4b7. After = pwgate cdd2160f (lever A) + pmflush eec5e6e8 (cherry-picked on cdd2160f); Magma "after" also has `MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES=2` (lever B). All libs LTO-ON, API 26 plugin release (`libs/pwbase`, `libs/pwAF`, `libs/pwA`, `libs/pwF`). Harness H2 (`fcl_bench.sh`), FCL on cpu2-6, 20 s warmup then 5 s windows until stable within 3 %, two 5 s measurement windows, no tracer. 3 interleaved reps in one bench session each (arm order rotated, battery <= 33.0 C before each session), thermal daemons stopped, swap interval 0, anland off. All 26 measured runs VALID (CPU pinned 1497/1248 MHz, GPU 903 MHz, tpl=0 thr=0). Espryt monolith "before" has reps 1 and 3 only: rep 2 was NO WORLD (FCL never reached the world in 4 launches) and was not re-run, by user decision.
Inproc first (the wanted numbers). fps = mean of the two windows; ratio is to MobileGlues' mean in the same sessions (315.7 fps; 305.6 / 320.7 / 320.9; CPU 1.69 ms/frame).
| arm | fps r1 / r2 / r3 | mean | after / before | ratio to MG | GL-thread CPU | apply-thread CPU |
|---|---|---|---|---|---|---|
| Magma inproc before | 334.1 / 359.6 / 378.8 | 357.5 | | 1.132 | 1.19 | 1.12 |
| Magma inproc after (AF + extra 2) | 442.2 / 478.9 / 494.6 | 471.9 | **1.32** (1.32 / 1.33 / 1.31 per rep) | **1.495** | 1.13 | 1.12 |
| Espryt inproc before | 302.1 / 332.9 / 325.8 | 320.3 | | 1.014 | 1.26 | 1.54 |
| Espryt inproc after (AF) | 323.0 / 366.4 / 354.5 | 347.9 | **1.09** (1.07 / 1.10 / 1.09) | **1.102** | 1.27 | 1.49 |
| Magma monolith before | 251.2 / 300.0 / 282.1 | 277.8 | | 0.880 | 2.39 | |
| Magma monolith after (AF + extra 2) | 352.9 / 390.6 / 369.9 | 371.2 | **1.34** (1.41 / 1.30 / 1.31) | **1.176** | 2.22 | |
| Espryt monolith before | 238.2 / NO WORLD / 252.9 | 245.6 (r1, r3) | | 0.778 | 2.89 | |
| Espryt monolith after (AF) | 260.3 / 300.0 / 288.8 | 283.0 | **1.12** on r1+r3 (1.09 / 1.14), 1.15 on all reps | **0.896** | 2.70 | |
- Reps drift upward with time (MobileGlues 305.6 -> 320.9 over the three sessions), so compare per rep. The after/before ratio is stable within a backend (Magma 1.30-1.41, Espryt 1.07-1.14).
- Engagement, from logcat in every Magma after run (mono and inproc): `Set minImageCount = 7 (surface min 5, max 64, extra 2)` and the latched "off-screen work goes to the queue ahead of its window pass" line; neither appears in the before runs. From the single Perfetto runs (`runs/pwlat`): QueueSubmit per frame 1.30 -> 2.25 (mono) and 1.25 -> 2.20 (inproc), as expected for lever A.
- Espryt has no log marker for lever A or pmflush (F). The CPU drop on the monolith (2.89 -> 2.70 ms/frame) fits the saved copy jobs, but A and F were not separated and no profile was taken (user scope cut), so their individual shares are unmeasured.
- Expectations that failed (lever B): the HANDOFF predicted `HWC release fence ... has signaled` at >= 85 % of acquires and < 20 % gated frames. The single Perfetto runs show 58 % signaled / 37 % gated (Magma mono) and 66 % / 33 % (Magma inproc). The fps gain is larger than the sim's upper bound for lever B alone (Magma mono frame 3.60 -> about 2.9 ms, i.e. +24 %; measured 3.60 -> 2.70), so something beyond the modelled throttle moved. Not investigated: the timeline analysis was cut; the traces are for the follow-up.
- Presenting-thread CPU barely moved on Magma (2.39 -> 2.22 mono, 1.19 -> 1.13 inproc): the gain is frame time, not CPU.
- Single Perfetto runs, one per arm (not part of the fps table; fps of those runs: Espryt mono 250.1 -> 296.0, Espryt inproc 330.6 -> 357.1, Magma mono 302.2 -> 378.8, Magma inproc 369.6 -> 468.9): `p15/runs/pwlat/{b,AF}-DirectGLES{,-inproc}-r1/p15.pftrace` and `{b,AF2}-DirectVulkan{,-inproc}-r1/p15.pftrace`. All eight are non-empty (19-22 MB, 4.9 s), have the frametimeline (812-835 actual frames) and the FCL presenting thread (Thread-14 mono, mgl-srv-apply inproc). Config: p15_perfetto.cfg without kgsl/* events (`p15/pw/dev/perfetto.cfg`).
- A partial first attempt with Perfetto in every run (Espryt mono b, A, F, AF) was cancelled by scope change: `runs/pwab0-pf-partial`.
+45
View File
@@ -311,6 +311,7 @@
"DirectGLES.AsyncOn.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectGLES.AsyncOn.AsyncCompileScenario.IrisShapedTwoPhaseBatchRendersCorrectly",
"DirectGLES.AsyncOn.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectGLES.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -362,6 +363,7 @@
"DirectGLES.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectGLES.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectGLES.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -944,6 +946,7 @@
"DirectGLES.Spawn.AsyncOn.AsyncCompileScenario.CompletionStatusPollingThenForcedJoin",
"DirectGLES.Spawn.AsyncOn.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectGLES.Spawn.AsyncOn.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectGLES.Spawn.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Spawn.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Spawn.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Spawn.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -1002,6 +1005,7 @@
"DirectGLES.Spawn.CpuMip.GenerateMipmapServerScenario.Rgb32fUploadedBaseGeneratesItsChain",
"DirectGLES.Spawn.CpuMipRefused.GenerateMipmapServerScenario.Rgb16fDrawnBaseWithARefusedReadbackDeclinesByName",
"DirectGLES.Spawn.CpuMipRefused.GenerateMipmapServerScenario.Rgb16fUploadedBaseWithARefusedReadbackIsFilteredFromTheStore",
"DirectGLES.Spawn.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Spawn.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Spawn.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Spawn.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -1604,6 +1608,7 @@
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.CompletionStatusPollingThenForcedJoin",
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectGLES.Split.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Split.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Split.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Split.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -1661,6 +1666,7 @@
"DirectGLES.Split.CpuMip.GenerateMipmapServerScenario.Rgb32fUploadedBaseGeneratesItsChain",
"DirectGLES.Split.CpuMipRefused.GenerateMipmapServerScenario.Rgb16fDrawnBaseWithARefusedReadbackDeclinesByName",
"DirectGLES.Split.CpuMipRefused.GenerateMipmapServerScenario.Rgb16fUploadedBaseWithARefusedReadbackIsFilteredFromTheStore",
"DirectGLES.Split.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Split.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Split.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Split.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -2358,6 +2364,7 @@
"DirectGLES.Tcp.AsyncOn.AsyncCompileScenario.CompletionStatusPollingThenForcedJoin",
"DirectGLES.Tcp.AsyncOn.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectGLES.Tcp.AsyncOn.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectGLES.Tcp.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Tcp.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Tcp.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Tcp.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -2409,6 +2416,7 @@
"DirectGLES.Tcp.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectGLES.Tcp.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectGLES.Tcp.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.Tcp.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Tcp.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Tcp.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Tcp.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -3153,6 +3161,7 @@
"DirectVulkan.AsyncOn.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectVulkan.AsyncOn.AsyncCompileScenario.IrisShapedTwoPhaseBatchRendersCorrectly",
"DirectVulkan.AsyncOn.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectVulkan.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectVulkan.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectVulkan.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectVulkan.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -3204,6 +3213,7 @@
"DirectVulkan.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectVulkan.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectVulkan.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectVulkan.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectVulkan.CrossFrameBufferScenario.IndexBufferSubData",
"DirectVulkan.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectVulkan.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -3963,6 +3973,7 @@
"names": [
"DirectGLES.AdvertisedLimitsScenario.EveryBufferLimitIsWithinItsAdvertisedRange",
"DirectGLES.AdvertisedLimitsScenario.IndexedBufferBindingsAreReportedVerbatimOnBothWidths",
"DirectGLES.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -3982,6 +3993,7 @@
"DirectGLES.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectGLES.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectGLES.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -4138,6 +4150,7 @@
"DirectGLES.Spawn.AdoptTier0.LargeArenaAdoptionScenario.SubDataAfterAnInFlightDrawReachesTheNextDraw",
"DirectGLES.Spawn.AdoptTier0.LargeArenaAdoptionScenario.TheArenaLandsInTheTierItsLaneDeclares",
"DirectGLES.Spawn.AdvertisedLimitsScenario.IndexedBufferBindingsAreReportedVerbatimOnBothWidths",
"DirectGLES.Spawn.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Spawn.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Spawn.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Spawn.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -4159,6 +4172,7 @@
"DirectGLES.Spawn.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.Spawn.CpuMipRefused.GenerateMipmapServerScenario.Rgb16fDrawnBaseWithARefusedReadbackDeclinesByName",
"DirectGLES.Spawn.CpuMipRefused.GenerateMipmapServerScenario.Rgb16fUploadedBaseWithARefusedReadbackIsFilteredFromTheStore",
"DirectGLES.Spawn.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Spawn.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Spawn.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Spawn.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -4308,6 +4322,7 @@
"DirectGLES.Split.AdoptTier0.LargeArenaAdoptionScenario.SubDataAfterAnInFlightDrawReachesTheNextDraw",
"DirectGLES.Split.AdoptTier0.LargeArenaAdoptionScenario.TheArenaLandsInTheTierItsLaneDeclares",
"DirectGLES.Split.AdvertisedLimitsScenario.IndexedBufferBindingsAreReportedVerbatimOnBothWidths",
"DirectGLES.Split.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Split.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Split.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Split.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -4329,6 +4344,7 @@
"DirectGLES.Split.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.Split.CpuMipRefused.GenerateMipmapServerScenario.Rgb16fDrawnBaseWithARefusedReadbackDeclinesByName",
"DirectGLES.Split.CpuMipRefused.GenerateMipmapServerScenario.Rgb16fUploadedBaseWithARefusedReadbackIsFilteredFromTheStore",
"DirectGLES.Split.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Split.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Split.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Split.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -4501,6 +4517,7 @@
"DirectGLES.Tcp.AdoptTier0.LargeArenaAdoptionScenario.SubDataAfterAnInFlightDrawReachesTheNextDraw",
"DirectGLES.Tcp.AdoptTier0.LargeArenaAdoptionScenario.TheArenaLandsInTheTierItsLaneDeclares",
"DirectGLES.Tcp.AdvertisedLimitsScenario.IndexedBufferBindingsAreReportedVerbatimOnBothWidths",
"DirectGLES.Tcp.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Tcp.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Tcp.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Tcp.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -4520,6 +4537,7 @@
"DirectGLES.Tcp.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectGLES.Tcp.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectGLES.Tcp.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.Tcp.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Tcp.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Tcp.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Tcp.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -4677,6 +4695,7 @@
"DirectVulkan.AdvertisedLimitsScenario.EveryBufferLimitIsWithinItsAdvertisedRange",
"DirectVulkan.AdvertisedLimitsScenario.IndexedBufferBindingsAreReportedVerbatimOnBothWidths",
"DirectVulkan.ArenaArm.LargeArenaAdoptionScenario.TheArenaLandsInTheTierItsLaneDeclares",
"DirectVulkan.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectVulkan.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectVulkan.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectVulkan.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -4696,6 +4715,7 @@
"DirectVulkan.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectVulkan.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectVulkan.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectVulkan.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectVulkan.CrossFrameBufferScenario.IndexBufferSubData",
"DirectVulkan.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectVulkan.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -5412,6 +5432,7 @@
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.CompletionStatusPollingThenForcedJoin",
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectGLES.Split.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Split.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Split.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Split.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -5463,6 +5484,7 @@
"DirectGLES.Split.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectGLES.Split.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectGLES.Split.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.Split.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Split.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Split.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Split.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -5987,6 +6009,7 @@
"DirectGLES.Split.StreamedArenaScenario.StreamedIndexDataSurvivesArenaRecycling",
"DirectGLES.Split.StreamedArenaScenario.StreamedVertexDataSurvivesArenaRecycling",
"DirectGLES.Split.StrictArming.TriangleScenario.TheServerStampedAVerbBoundaryOnThisDrawingFrame",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -6151,6 +6174,7 @@
"DirectVulkan.Split.Band.BandedReadbackScenario.GetTexImageLargerThanAReplySlotIsWindowed",
"DirectVulkan.Split.Band.BandedReadbackScenario.RenderbufferReadOfExactlyTwoMiBIsBandedNotRefused",
"DirectVulkan.Split.Band.BandedReadbackScenario.TwoMiBPlusOneRowIsBanded",
"DirectVulkan.Split.Buffers.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectVulkan.Split.Buffers.CrossFrameBufferScenario.IndexBufferSubData",
"DirectVulkan.Split.Buffers.CrossFrameBufferScenario.IndexOrphanAndReupload",
"DirectVulkan.Split.Buffers.CrossFrameBufferScenario.VertexBufferSubData",
@@ -6415,6 +6439,7 @@
"junit-integration-split-strict/magma-buffers": {
"skipped": [],
"names": [
"DirectVulkan.Split.Buffers.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectVulkan.Split.Buffers.CrossFrameBufferScenario.IndexBufferSubData",
"DirectVulkan.Split.Buffers.CrossFrameBufferScenario.IndexOrphanAndReupload",
"DirectVulkan.Split.Buffers.CrossFrameBufferScenario.VertexBufferSubData",
@@ -6447,6 +6472,7 @@
"junit-integration-split-strict/magma-buffers-spawn": {
"skipped": [],
"names": [
"DirectVulkan.Spawn.Buffers.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectVulkan.Spawn.Buffers.CrossFrameBufferScenario.IndexBufferSubData",
"DirectVulkan.Spawn.Buffers.CrossFrameBufferScenario.IndexOrphanAndReupload",
"DirectVulkan.Spawn.Buffers.CrossFrameBufferScenario.VertexBufferSubData",
@@ -6479,6 +6505,7 @@
"junit-integration-split-strict/magma-buffers-tcp": {
"skipped": [],
"names": [
"DirectVulkan.Tcp.Buffers.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectVulkan.Tcp.Buffers.CrossFrameBufferScenario.IndexBufferSubData",
"DirectVulkan.Tcp.Buffers.CrossFrameBufferScenario.IndexOrphanAndReupload",
"DirectVulkan.Tcp.Buffers.CrossFrameBufferScenario.VertexBufferSubData",
@@ -6632,6 +6659,7 @@
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.CompletionStatusPollingThenForcedJoin",
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectGLES.Split.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Split.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Split.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Split.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -6683,6 +6711,7 @@
"DirectGLES.Split.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectGLES.Split.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectGLES.Split.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.Split.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Split.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Split.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Split.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -7207,6 +7236,7 @@
"DirectGLES.Split.StreamedArenaScenario.StreamedIndexDataSurvivesArenaRecycling",
"DirectGLES.Split.StreamedArenaScenario.StreamedVertexDataSurvivesArenaRecycling",
"DirectGLES.Split.StrictArming.TriangleScenario.TheServerStampedAVerbBoundaryOnThisDrawingFrame",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -10992,6 +11022,7 @@
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.CompletionStatusPollingThenForcedJoin",
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectGLES.Split.AsyncOn.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectGLES.Split.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Split.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Split.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Split.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -11043,6 +11074,7 @@
"DirectGLES.Split.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectGLES.Split.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectGLES.Split.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.Split.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Split.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Split.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Split.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -11567,6 +11599,7 @@
"DirectGLES.Split.StreamedArenaScenario.StreamedIndexDataSurvivesArenaRecycling",
"DirectGLES.Split.StreamedArenaScenario.StreamedVertexDataSurvivesArenaRecycling",
"DirectGLES.Split.StrictArming.TriangleScenario.TheServerStampedAVerbBoundaryOnThisDrawingFrame",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Split.StrictProgramArm.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -11747,6 +11780,7 @@
"DirectGLES.Spawn.AsyncOn.AsyncCompileScenario.CompletionStatusPollingThenForcedJoin",
"DirectGLES.Spawn.AsyncOn.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectGLES.Spawn.AsyncOn.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectGLES.Spawn.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Spawn.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Spawn.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Spawn.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -11798,6 +11832,7 @@
"DirectGLES.Spawn.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectGLES.Spawn.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectGLES.Spawn.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.Spawn.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Spawn.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Spawn.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Spawn.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -12439,6 +12474,7 @@
"DirectGLES.Tcp.AsyncOn.AsyncCompileScenario.CompletionStatusPollingThenForcedJoin",
"DirectGLES.Tcp.AsyncOn.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectGLES.Tcp.AsyncOn.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectGLES.Tcp.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Tcp.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Tcp.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Tcp.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -12490,6 +12526,7 @@
"DirectGLES.Tcp.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectGLES.Tcp.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectGLES.Tcp.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.Tcp.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Tcp.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Tcp.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Tcp.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -13266,6 +13303,7 @@
"DirectGLES.VerifySplit.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectGLES.VerifySplit.AsyncCompileScenario.IrisShapedTwoPhaseBatchRendersCorrectly",
"DirectGLES.VerifySplit.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectGLES.VerifySplit.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.VerifySplit.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.VerifySplit.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.VerifySplit.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -13317,6 +13355,7 @@
"DirectGLES.VerifySplit.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectGLES.VerifySplit.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectGLES.VerifySplit.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.VerifySplit.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.VerifySplit.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.VerifySplit.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.VerifySplit.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -13947,6 +13986,7 @@
"DirectVulkan.VerifySplit.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectVulkan.VerifySplit.AsyncCompileScenario.IrisShapedTwoPhaseBatchRendersCorrectly",
"DirectVulkan.VerifySplit.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectVulkan.VerifySplit.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectVulkan.VerifySplit.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectVulkan.VerifySplit.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectVulkan.VerifySplit.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -13998,6 +14038,7 @@
"DirectVulkan.VerifySplit.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectVulkan.VerifySplit.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectVulkan.VerifySplit.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectVulkan.VerifySplit.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectVulkan.VerifySplit.CrossFrameBufferScenario.IndexBufferSubData",
"DirectVulkan.VerifySplit.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectVulkan.VerifySplit.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -16887,6 +16928,7 @@
"DirectGLES.Verify.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectGLES.Verify.AsyncCompileScenario.IrisShapedTwoPhaseBatchRendersCorrectly",
"DirectGLES.Verify.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectGLES.Verify.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectGLES.Verify.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectGLES.Verify.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectGLES.Verify.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -16938,6 +16980,7 @@
"DirectGLES.Verify.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectGLES.Verify.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectGLES.Verify.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectGLES.Verify.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectGLES.Verify.CrossFrameBufferScenario.IndexBufferSubData",
"DirectGLES.Verify.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectGLES.Verify.CrossFrameBufferScenario.IndexMapWriteUnmap",
@@ -17519,6 +17562,7 @@
"DirectVulkan.Verify.AsyncCompileScenario.ExtensionStringMatchesTheConfiguration",
"DirectVulkan.Verify.AsyncCompileScenario.IrisShapedTwoPhaseBatchRendersCorrectly",
"DirectVulkan.Verify.AsyncCompileScenario.ZeroCompilerThreadsSettlesEverythingImmediately",
"DirectVulkan.Verify.AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour",
"DirectVulkan.Verify.AtomicCounterScenario.CountersAccumulateAcrossDispatchesAndFollowAReseed",
"DirectVulkan.Verify.AtomicCounterScenario.DispatchIncrementsTheBoundCounterBuffers",
"DirectVulkan.Verify.AtomicCounterScenario.SubDataAfterDispatchSurvivesAnImmediateReadback",
@@ -17570,6 +17614,7 @@
"DirectVulkan.Verify.CopyImageStoreReadbackScenario.APartialUploadAfterTheCopyKeepsTheCopiedWindow",
"DirectVulkan.Verify.CopyImageStoreReadbackScenario.ARenderbufferSourceLandsInTheTexture",
"DirectVulkan.Verify.CopyImageStoreReadbackScenario.AnUploadedLevelReadsBackExactly",
"DirectVulkan.Verify.CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes",
"DirectVulkan.Verify.CrossFrameBufferScenario.IndexBufferSubData",
"DirectVulkan.Verify.CrossFrameBufferScenario.IndexCopyBufferSubData",
"DirectVulkan.Verify.CrossFrameBufferScenario.IndexMapWriteUnmap",
+1
View File
@@ -74,6 +74,7 @@ environment too. The backend itself is the exception: the client asks for it (se
| `MOBILEGL_MAGMA_R11G11B10F_FALLBACK` | flag | off | Use a fallback format for `GL_R11F_G11F_B10F` |
| `MOBILEGL_MAGMA_MAX_DRAWS_PER_COMMAND_BUFFER` | 0-16777216 | 16384 | Submit a command buffer mid-frame after this many draws/dispatches (0 = never). Bounds driver memory in huge loading frames. |
| `MOBILEGL_MAGMA_DESCRIPTOR_TRIM_FRAMES` | 0-1048576 | 120 | Free grown descriptor pools after this many quiet frames (0 = never) |
| `MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES` | 0-16 | 0 | Ask for this many swapchain images beyond the surface's minimum (capped at its maximum). The window buffer the display has just released is then reused later, when its release has usually signaled, so fewer frames wait for it. Each image costs a full-size colour buffer plus a depth/stencil buffer of the same size. |
| `VK_ICD_FILENAMES` | path to an ICD JSON | loader default | Standard Vulkan loader variable: picks the Vulkan driver |
## Logging and diagnostics