[MG_Backend, MG_IntegrationTest, docs] (P7): the shader mip arm names the format it refused and renders through scratch when the image cannot be attached

Two Iris cases died on the Redmi (Adreno 830v2, DirectVulkan inproc) with
Fatal{UnmigratedVerb, "Magma:mipmap-shader-format-or-shape"}, deterministically and
under both run-ahead and lockstep, while the monolith arm and the whole host lane
stayed green. That one line was the entire evidence, and five disjunctions share the
name, so the one thing the device could have told us - which format, at what shape,
missing which feature bit - was the one thing it did not.

The name stays first and unprefixed, because the census, the retrace refusal tally
and every log grep key on the leading word; the driver's own answer follows it:
format enum, the view's storage format when it reinterprets, extent, levels, aspect,
view type, usage bits, layer range, and the names of the optimalTilingFeatures bits
that are ABSENT. The next device run reads a line instead of re-deriving it.

The refusal also loses half its territory. The shader arm rendered STRAIGHT INTO the
next level, which needs the image to carry COLOR_ATTACHMENT usage - and a texture
whose format the device declines as a colour attachment never gets that bit, so every
sampled-only texture without BLIT support fell into the refusal rather than into a
fallback. When the FORMAT can be rendered and only the IMAGE cannot, an owned scratch
attachment of the destination level's size takes the pass and vkCmdCopyImage moves the
mip in: a raw texel move, no conversion, texels still from GPU contents rather than a
staged shadow, and the scratch retires with the submit that consumes it - the shape the
multisample resolve arm above it already uses.

Neither shader arm had ever executed on the gate machine. lavapipe reports
BLIT_SRC|BLIT_DST for every colour format this binary can create, so GenerateWireMipmap
takes its native arm for all of them; GenerateMipmapPackedFloatPixels next door looks
like it covers the shader arm and does not, because R11F_G11F_B10F blits natively here
too. MGITEST_MAGMA_FORCE_SHADER_MIPMAP drops the native arm instead, one tier per shape
(1 = render into the level, 2 = render into scratch and copy back), read once and
compiled only into the disaggregated build.

F1WireScenario.GenerateMipmapWithoutNativeBlitPixels paints two different halves rather
than one flat colour - a pass that loses GL's row order averages to the same number
everywhere, and a single-colour assertion would call that correct - and asserts level
one per half. It is registered on the three Magma arms twice, ONE ENVIRONMENT EACH: the
knob changes how every mipmap in the process is generated, so a lane-wide flip would
silently retarget the four green mipmap entries beside it.

Red once (executed, reverted): with the scratch arm forced off, the tier-2 entry dies
with Fatal{UnmigratedVerb, "Magma:mipmap-shader-format-or-shape format=37 extent=8x8x1
levels=4 aspect=0x1 view=1 usage=0x17 layers=0+1/1 missing=DEPTH_STENCIL_ATTACHMENT"},
by name and with the shape in it; restored, the same filter is 8/8 green.

Gates: integration-magma-split 75 (+2), -spawn 54 (+2), -tcp 56 (+2), 0 red;
ctest -L unit 2402/2402; informational integration-magma-full-split 511, 0 red, 58 skip
(the new case skips where the knob is unset); fatal_census green (79 abort sites, 43
family words, 0 unmarked - no site added, the funnel is unchanged); link_ratchet
--assert-monotone unchanged at 186, p7-magma bucket 101.
This commit is contained in:
2026-09-22 16:37:54 -04:00
parent 5937b4fcf2
commit c4be38005a
4 changed files with 354 additions and 10 deletions
@@ -2684,6 +2684,32 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
${mglItestArmProperties}
ENVIRONMENT "${mglItestMagmaWireEnvironment}\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/p5f-fm${mglItestArmLogTag}-${fmCase}.log")
endforeach()
# ---- P7 wave 2-B: THE TWO SHADER MIP ARMS, FORCED ------------------------------------
#
# WHY A KNOB AND NOT A FORMAT. The refusal these two entries cover
# (`Magma:mipmap-shader-format-or-shape`) killed two Iris cases on an Adreno 830v2 and
# has never once fired on this host, because lavapipe reports BLIT_SRC|BLIT_DST for
# every colour format the integration binary can create - so GenerateWireMipmap takes
# its NATIVE arm for all of them and neither shader arm is reachable by choosing a
# format. `GenerateMipmapPackedFloatPixels` next door looks like it covers the shader
# arm and does not: R11F_G11F_B10F blits natively here too.
# MGITEST_MAGMA_FORCE_SHADER_MIPMAP drops that arm instead, one tier per shape, so the
# host lane exercises the code the device actually runs.
#
# ITS OWN ENTRIES RATHER THAN A LANE-WIDE FLIP, for the reason the strict-arming entry
# gives: the knob changes how EVERY mipmap in the process is generated, so putting it in
# the shared Fm environment would silently retarget GenerateMipmapPixels,
# GenerateMipmapPackedFloatPixels, GenerateMipmapDepthPixels and the two base/view cases
# as well - four green entries that would stop measuring the arm they were written for.
foreach(shaderMipTier 1 2)
gtest_discover_tests(MobileGLIntegrationTest
TEST_PREFIX "DirectVulkan.${mglItestArm}.ShaderMip${shaderMipTier}."
TEST_FILTER "F1WireScenario.GenerateMipmapWithoutNativeBlitPixels"
DISCOVERY_TIMEOUT 30
PROPERTIES LABELS "${mglItestMagmaLabels}" TIMEOUT ${MGL_ITEST_TIMEOUT}
${mglItestArmProperties}
ENVIRONMENT "${mglItestMagmaWireEnvironment}\;MGITEST_MAGMA_FORCE_SHADER_MIPMAP=${shaderMipTier}\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/p7-shadermip${mglItestArmLogTag}-tier${shaderMipTier}.log")
endforeach()
endforeach()
endif()
@@ -481,6 +481,66 @@ TEST_F(F1WireScenario, GenerateMipmapPackedFloatPixels) {
for (int i = 0; i < 8; ++i) EXPECT_NEAR(rows[i], generated[i], 0.01f);
}
// P7 wave 2-B: THE ARM THE HOST CANNOT REACH ON ITS OWN.
//
// Two Iris cases (minecraft-1.21.4-fabric-iris-iterationt-in-world and its -nodsa twin) killed
// the server apply thread on a Redmi (Adreno 830v2) with
// MGPipe: Fatal{UnmigratedVerb, "Magma:mipmap-shader-format-or-shape"}
// deterministically, under both run-ahead and lockstep, while the monolith arm passed and the
// host lane stayed green. It stayed green because lavapipe reports BLIT_SRC|BLIT_DST for every
// colour format this scenario can create: `nativeBlit` is always true here, so NEITHER shader
// arm of GenerateWireMipmap has ever executed on the gate machine. A refusal no host lane can
// reach is a refusal that ships.
//
// MGITEST_MAGMA_FORCE_SHADER_MIPMAP is what makes them reachable, and it selects which one:
// 1 - drop the native blit only. The destination level is still a colour attachment, so the
// pass renders straight into it (the arm an Adreno takes for a format without BLIT_DST).
// 2 - also treat the destination as not attachable. The pass renders into owned scratch and
// copies the mip in (the arm it takes for a texture whose image never got
// COLOR_ATTACHMENT usage - which, before this package, was the refusal itself).
//
// The assertion is the ORDINARY mip result, per half: a shader mip that renders somewhere else
// is still wrong unless the level holds what a blit would have put there, in GL's row order.
// Red once (executed, reverted): drop the scratch arm (force `viaScratch` false) and the tier-2
// entry dies with Fatal{UnmigratedVerb, "Magma:mipmap-shader-format-or-shape ..."} by name.
TEST_F(F1WireScenario, GenerateMipmapWithoutNativeBlitPixels) {
if (!Ready()) return;
const std::string tier = SplitLane::MarkerValue("MGITEST_MAGMA_FORCE_SHADER_MIPMAP");
if (tier.empty())
GTEST_SKIP() << "MGITEST_MAGMA_FORCE_SHADER_MIPMAP is unset: this driver reports "
"BLIT_SRC|BLIT_DST for GL_RGBA8, so the shader mip arms under test are "
"not entered and this case would assert the native blit twice over";
Attach(GL_RGBA8, GL_COLOR_ATTACHMENT0, 4);
glDisable(GL_SCISSOR_TEST);
glClearColor(0.75f, 0.25f, 0.5f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// Two different halves, not one flat colour: a pass that loses GL's row order averages to
// the same number everywhere and a single-colour assertion would call that correct.
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, 8, 4);
glClearColor(0.25f, 0.75f, 0.5f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);
const auto before = PeekSplitRuntime().emitSeq;
glGenerateMipmap(GL_TEXTURE_2D);
ASSERT_GT(PeekSplitRuntime().emitSeq, before) << "F1.ShaderMip.wire";
// Level one is 4x4, and each of its rows averages two source rows from ONE half - the
// boundary never falls inside a destination texel, so the two colours survive unmixed.
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 1);
ASSERT_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GLenum(GL_FRAMEBUFFER_COMPLETE));
GLubyte rows[4][4]{};
glReadPixels(1, 0, 1, 4, GL_RGBA, GL_UNSIGNED_BYTE, rows);
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "F1.ShaderMip.error";
const int bottom[4] = {64, 191, 128, 255};
const int top[4] = {191, 64, 128, 255};
for (int row = 0; row < 4; ++row) {
const int* expected = row < 2 ? bottom : top;
for (int channel = 0; channel < 4; ++channel)
EXPECT_NEAR(rows[row][channel], expected[channel], 2)
<< "F1.ShaderMip.pixels tier=" << tier << " row=" << row << " channel=" << channel;
}
}
TEST_F(F1WireScenario, GenerateMipmapDepthPixels) {
if (!Ready()) return;
std::array<GLfloat, 8 * 8> source{};