mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-16 14:33:24 +09:00
Compare commits
47
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
648800a2da | ||
|
|
b4bee9dd38 | ||
|
|
494305381e | ||
|
|
fb106a682e | ||
|
|
c8c4397475 | ||
|
|
9c24a14d2b | ||
|
|
ac9ab078cc | ||
|
|
377d90d9f1 | ||
|
|
4cfb29a553 | ||
|
|
51e95c9260 | ||
|
|
982958ebb1 | ||
|
|
3717424229 | ||
|
|
f973008c4d | ||
|
|
edcb9328e2 | ||
|
|
e61060fbdf | ||
|
|
3ce8ce3cb1 | ||
|
|
394d255487 | ||
|
|
0222852b94 | ||
|
|
2edb2aa82a | ||
|
|
fc415aee76 | ||
|
|
307267c188 | ||
|
|
cbbaf77f6d | ||
|
|
39cd8fb73b | ||
|
|
92eab9f3b7 | ||
|
|
9441071567 | ||
|
|
2f530ad8a2 | ||
|
|
c00f5eabae | ||
|
|
24b8aef616 | ||
|
|
8133cd52ae | ||
|
|
06f28b0a1b | ||
|
|
b9feb9d7be | ||
|
|
2b4ae539da | ||
|
|
e815ce8d33 | ||
|
|
00d6c2480e | ||
|
|
f823422bfa | ||
|
|
e52a997f34 | ||
|
|
c7a14ed790 | ||
|
|
d639e54616 | ||
|
|
32f222dbc2 | ||
|
|
a2c81a2f64 | ||
|
|
8dac1fd8a4 | ||
|
|
b71cb9cc2c | ||
|
|
efd3533bd1 | ||
|
|
67890f523a | ||
|
|
976fbe4cd4 | ||
|
|
7030d307be | ||
|
|
853c5f1264 |
@@ -1461,6 +1461,22 @@ jobs:
|
||||
- name: Spawn/split lane parity (9.2)
|
||||
run: python3 scripts/ci/spawn_lane_parity.py build-split
|
||||
|
||||
# P8-A (ID-P8-2): every monolith case, tails normalised, is on a gated split arm or is named
|
||||
# with a reason class in scripts/data/split_coverage_exemptions.txt. The same `ctest -N`
|
||||
# cost as the parity step above, and the question it cannot answer: parity compares the
|
||||
# split arms with EACH OTHER, so a case missing from all three passes it.
|
||||
- name: Split coverage against monolith (P8-A)
|
||||
run: |
|
||||
python3 scripts/ci/split_coverage.py --self-test
|
||||
python3 scripts/ci/split_coverage.py build-split
|
||||
|
||||
# P8-SE: PipeCatalogueTest's unmigrated-emulation list equals the MGPipeUnmigratedEmulation
|
||||
# call sites in the tree, one site per name. A source lint: no build needed.
|
||||
- name: Unmigrated-emulation list against its call sites (P8-SE)
|
||||
run: |
|
||||
python3 scripts/ci/unmigrated_emulation_sites.py --self-test
|
||||
python3 scripts/ci/unmigrated_emulation_sites.py
|
||||
|
||||
- name: Unit tests on the split runtime
|
||||
working-directory: build-split
|
||||
env:
|
||||
|
||||
@@ -483,11 +483,19 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
const MG_Pipe::MGPipeHandle handle = MG_Pipe::MGPipeApplier().VerbIndirectBuffer;
|
||||
if (!MG_Pipe::MGPipeHandleIsNull(handle)) {
|
||||
auto* resource = BufferImpl::FindBufferResourceForHandle(handle);
|
||||
const Uint8* const base = resource ? BufferImpl::SplitHostBytes(*resource) : nullptr;
|
||||
const Uint8* base = resource ? BufferImpl::SplitHostBytes(*resource) : nullptr;
|
||||
// P8-C: a store nothing ever staged but a shader wrote (the GPU-culling shape)
|
||||
// takes its first copy from this server's own GL buffer. A store that HAS a copy
|
||||
// is not refreshed here: most indirect draws execute natively and read no field
|
||||
// on the CPU, so ExecuteIndexed/ArraysIndirectCommands refresh the fields only
|
||||
// when they consume them.
|
||||
if (base == nullptr && resource != nullptr) {
|
||||
base = BufferImpl::SplitHostBytesForCpuRead(*resource, handle, "indirect_command_bytes");
|
||||
}
|
||||
const SizeT commandOffset = reinterpret_cast<SizeT>(indirect);
|
||||
if (base == nullptr) {
|
||||
MGLOG_E_ONCE("%s skipped: the verb's indirect buffer {%u, %u} has no staged "
|
||||
"shadow on this side (GPU-written indirect commands are P8's)",
|
||||
"shadow on this side and no GPU write to take one from",
|
||||
label, handle.Slot, handle.Gen);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -769,6 +777,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
entry.Res.Gen);
|
||||
continue;
|
||||
}
|
||||
// P8-C: the SERVER's half of the mark MarkShaderStorageBuffersGpuWritten no longer
|
||||
// makes under a transport - on this side's twin, for this side's CPU readers
|
||||
// (SplitHostBytesForCpuRead). Every bound storage point, which is the client's
|
||||
// own conservative set (ShaderBufferEmit.h marks every one writable); a uniform
|
||||
// point is read-only by definition.
|
||||
if (shaderBufferClass != MG_Pipe::kMGPipeShaderBufferClassUniform) {
|
||||
backendResource->serverGpuWritten = true;
|
||||
}
|
||||
const auto backendBufferId = backendResource->id;
|
||||
if (entry.Offset == 0 && entry.Size == MG_Pipe::kMGPipeWholeBuffer) {
|
||||
BindBufferBaseCached(glTarget, static_cast<GLuint>(i), backendBufferId);
|
||||
@@ -997,6 +1013,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// from MarkGpuWritesForDraw, WIDER on purpose - it marks every touched
|
||||
// counter point rather than only the ones this program declares, which is
|
||||
// the safe direction for an over-approximate set.
|
||||
//
|
||||
// P8-C: the server's own twin is marked instead, for the server's own CPU
|
||||
// readers (SplitHostBytesForCpuRead) - a counter buffer later bound as a
|
||||
// parameter or element buffer is read on this side.
|
||||
backendResource->serverGpuWritten = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1803,7 +1824,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
const MG_Pipe::MGPipeHandle res = target.handle;
|
||||
auto* resource = BufferImpl::FindBufferResourceForHandle(res);
|
||||
if (resource == nullptr || resource->persistentMapped) continue;
|
||||
if (resource == nullptr) continue;
|
||||
if (resource->persistentMapped) {
|
||||
// P8-C: nothing to copy - the capture reaches a coherent map -
|
||||
// but this side's CPU readers must finish before reading it.
|
||||
resource->serverGpuWritten = true;
|
||||
continue;
|
||||
}
|
||||
const SizeT size = target.end - target.start;
|
||||
BufferImpl::BindBufferId(BufferImpl::TempBufferTarget, target.backendId);
|
||||
void* mapped = g_GLESFuncs.glMapBufferRange(BufferImpl::TempBufferTarget,
|
||||
@@ -1844,6 +1871,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
"captured bytes of buffer {%u,%u} cannot reach the client shadow",
|
||||
res.Slot, res.Gen);
|
||||
}
|
||||
// P8-C: the server's own staged copy takes the same bytes, from the
|
||||
// same mapping, so this side's CPU readers see the capture too.
|
||||
BufferImpl::StageServerWrittenRange(*resource, res, mapped, target.start, size);
|
||||
g_GLESFuncs.glUnmapBuffer(BufferImpl::TempBufferTarget);
|
||||
// Ops_H_Readback's order: writeback, unmap, THEN the serial
|
||||
// stamp, so the next draw does not re-upload the server's stale
|
||||
@@ -2004,7 +2034,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
splitRes.Slot, splitRes.Gen);
|
||||
continue;
|
||||
}
|
||||
const Uint8* hostBytes = splitResource->hostBytes;
|
||||
// P8-C: made current first - a store a shader wrote here is refreshed.
|
||||
const Uint8* hostBytes = BufferImpl::SplitHostBytesForCpuRead(*splitResource, splitRes,
|
||||
"xfb_scatter_pre_capture");
|
||||
// A NULL SHADOW IS NOT A LOST CAPTURE. It is the ORPHANED store
|
||||
// (glBufferData(size, NULL) with no resource_subdata since), which
|
||||
// M-3 declares legal: every byte the application has not staged is
|
||||
@@ -2069,9 +2101,12 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
"scattered capture of buffer {%u,%u} cannot reach the client shadow",
|
||||
splitRes.Slot, splitRes.Gen);
|
||||
}
|
||||
// Ops_H_Readback's stamp, for its reason: the GL store now holds
|
||||
// bytes the server's staged shadow does not, and the next draw must
|
||||
// not re-upload the stale shadow over the capture.
|
||||
// P8-C: the staged copy takes the composed range too, so this side's CPU
|
||||
// readers see the capture (before P8 it kept the pre-capture bytes).
|
||||
BufferImpl::StageServerWrittenRange(*splitResource, splitRes, staged.data(), target.start,
|
||||
rangeBytes);
|
||||
// Ops_H_Readback's stamp, for its reason: the GL store now holds the
|
||||
// capture, and the next draw must not re-upload an older range over it.
|
||||
splitResource->syncedChangeSerial = BufferImpl::ResourceSerialForHandle(splitRes);
|
||||
} else
|
||||
#endif
|
||||
@@ -4425,7 +4460,26 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// reach of an apply thread entirely.
|
||||
void MarkWritableImageBufferTexturesGpuWritten() {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) return;
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
// P8-C: the SERVER's twin of the buffer behind each writable buffer image, for
|
||||
// this side's CPU readers (SplitHostBytesForCpuRead). Every read is a record:
|
||||
// the unit set SyncImageTextureBinding(view) tracked, the applier's image view,
|
||||
// and the texture descriptor's backing-store handle.
|
||||
if (g_writableImageBufferUnitCount == 0) return;
|
||||
const auto& st = MG_Pipe::MGPipeApplier();
|
||||
for (Uint unit = 0; unit < g_writableImageBufferUnits.size() && unit < st.BoundShaderImages.size();
|
||||
++unit) {
|
||||
if (!g_writableImageBufferUnits[unit]) continue;
|
||||
const MG_Pipe::MGPImageView& view = st.BoundShaderImages[unit];
|
||||
if (!IsWritableImageBufferView(view)) continue;
|
||||
const auto* record = PipeTextureRecordForHandle(view.Res);
|
||||
if (record == nullptr) continue;
|
||||
if (auto* buffer = BufferImpl::FindBufferResourceForHandle(record->Desc.BufferForTexBuffer)) {
|
||||
buffer->serverGpuWritten = true;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (g_writableImageBufferUnitCount == 0) return;
|
||||
for (Uint unit = 0; unit < g_writableImageBufferUnits.size(); ++unit) {
|
||||
@@ -8491,6 +8545,30 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
return g_GLESCapabilities.SupportsDrawIndirect;
|
||||
}
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-C: the command bytes an indirect executor is about to CONSUME on the CPU, made current.
|
||||
// Consumed means: every field on the CPU path (no native indirect), or on the native path the
|
||||
// uniforms fed from the command - gl_BaseVertex whenever the program reads it, and
|
||||
// gl_BaseInstance when the program reads it without the mg_IndirectParams storage view that
|
||||
// would give it the GPU's word. A native draw that feeds neither reads nothing and keeps its
|
||||
// pointer, so a compute-culled indirect buffer drawn every frame costs no readback.
|
||||
static const Uint8* CurrentIndirectCommandBytes(MG_Pipe::MGPipeHandle handle, const Uint8* commandBytes,
|
||||
SizeT commandOffset, Bool useNative, Bool indexed) {
|
||||
if (MG_Pipe::MGPipeHandleIsNull(handle)) return commandBytes;
|
||||
if (useNative) {
|
||||
const auto program = GetCurrentBackendProgram();
|
||||
if (program == nullptr) return commandBytes;
|
||||
const Bool baseVertexFromCpu = indexed && program->ReadsBaseVertex();
|
||||
const Bool baseInstanceFromCpu = program->GetIndirectParamsBinding() < 0 && program->ReadsBaseInstance();
|
||||
if (!baseVertexFromCpu && !baseInstanceFromCpu) return commandBytes;
|
||||
}
|
||||
auto* resource = BufferImpl::FindBufferResourceForHandle(handle);
|
||||
if (resource == nullptr) return commandBytes;
|
||||
const Uint8* base = BufferImpl::SplitHostBytesForCpuRead(*resource, handle, "indirect_command_fields");
|
||||
return base != nullptr ? base + commandOffset : commandBytes;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Runs an (indexed) indirect multi-draw. When a GL_DRAW_INDIRECT_BUFFER is bound the draws
|
||||
// execute natively on the GPU so commands written by compute shaders (e.g. Flywheel's
|
||||
// culling pipeline updating instanceCount) are honored; the CPU shadow is still consulted
|
||||
@@ -8537,6 +8615,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
:
|
||||
#endif
|
||||
drawIndirectBuffer != nullptr && SupportsNativeIndirectDraws();
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
commandBytes = CurrentIndirectCommandBytes(verbBufferHandle, commandBytes, commandOffset, useNative,
|
||||
/*indexed=*/true);
|
||||
#endif
|
||||
if (useNative) {
|
||||
// gl_BaseInstance must observe GPU-written command fields; expose the indirect
|
||||
// buffer to the program's mg_IndirectParams SSBO view and address it per draw.
|
||||
@@ -8635,6 +8717,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
:
|
||||
#endif
|
||||
drawIndirectBuffer != nullptr && SupportsNativeIndirectDraws();
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
commandBytes = CurrentIndirectCommandBytes(verbBufferHandle, commandBytes, commandOffset, useNative,
|
||||
/*indexed=*/false);
|
||||
#endif
|
||||
if (useNative) {
|
||||
const auto backendProgram = GetCurrentBackendProgram();
|
||||
const Int paramsBinding = backendProgram ? backendProgram->GetIndirectParamsBinding() : -1;
|
||||
@@ -9219,9 +9305,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
return;
|
||||
}
|
||||
// The staged shadow is the source of truth for CPU reads on this side: a
|
||||
// persistent map's blocks and a shader write's writeback were consumed by the
|
||||
// applier before this verb ran.
|
||||
const Uint8* hostBytes = elementResource ? BufferImpl::SplitHostBytes(*elementResource) : nullptr;
|
||||
// persistent map's blocks were consumed by the applier before this verb ran, and
|
||||
// (P8-C) a store a shader wrote on this side is read back from this server's own
|
||||
// GL buffer first - no writeback ever reaches the server's copy.
|
||||
const Uint8* hostBytes =
|
||||
elementResource
|
||||
? BufferImpl::SplitHostBytesForCpuRead(*elementResource, elements,
|
||||
"primitive_restart_substitution")
|
||||
: nullptr;
|
||||
if (hostBytes == nullptr) {
|
||||
MGLOG_E_ONCE("Draw skipped: GL_PRIMITIVE_RESTART with restart index %u needs a CPU-readable copy of "
|
||||
"the bound element array buffer and none is available.",
|
||||
@@ -9538,8 +9629,20 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
auto* drawResource = BufferImpl::FindBufferResourceForHandle(applierState.VerbIndirectBuffer);
|
||||
auto* paramResource =
|
||||
BufferImpl::FindBufferResourceForHandle(applierState.VerbIndirectParameterBuffer);
|
||||
const Uint8* const drawBytes = drawResource ? BufferImpl::SplitHostBytes(*drawResource) : nullptr;
|
||||
const Uint8* const parameterBytes = paramResource ? BufferImpl::SplitHostBytes(*paramResource) : nullptr;
|
||||
// P8-C: the count is CONSUMED here, so the parameter buffer is made current first
|
||||
// (a store a shader wrote on this side is read back); the command buffer only gets a
|
||||
// first copy when it has none - its fields are made current by the executor, and
|
||||
// only when it consumes them (CurrentIndirectCommandBytes).
|
||||
const Uint8* const parameterBytes =
|
||||
paramResource ? BufferImpl::SplitHostBytesForCpuRead(*paramResource,
|
||||
applierState.VerbIndirectParameterBuffer,
|
||||
"indirect_count_parameter")
|
||||
: nullptr;
|
||||
const Uint8* drawBytes = drawResource ? BufferImpl::SplitHostBytes(*drawResource) : nullptr;
|
||||
if (drawBytes == nullptr && drawResource != nullptr) {
|
||||
drawBytes = BufferImpl::SplitHostBytesForCpuRead(*drawResource, applierState.VerbIndirectBuffer,
|
||||
"indirect_count_commands");
|
||||
}
|
||||
if (commandBytes > BufferImpl::ResourceWidthForHandle(applierState.VerbIndirectBuffer)) {
|
||||
MGLOG_E_ONCE("MultiDrawElementsIndirectCount skipped: invalid GL_DRAW_INDIRECT_BUFFER binding or range");
|
||||
return;
|
||||
@@ -9692,8 +9795,20 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
auto* drawResource = BufferImpl::FindBufferResourceForHandle(applierState.VerbIndirectBuffer);
|
||||
auto* paramResource =
|
||||
BufferImpl::FindBufferResourceForHandle(applierState.VerbIndirectParameterBuffer);
|
||||
const Uint8* const drawBytes = drawResource ? BufferImpl::SplitHostBytes(*drawResource) : nullptr;
|
||||
const Uint8* const parameterBytes = paramResource ? BufferImpl::SplitHostBytes(*paramResource) : nullptr;
|
||||
// P8-C: the count is CONSUMED here, so the parameter buffer is made current first
|
||||
// (a store a shader wrote on this side is read back); the command buffer only gets a
|
||||
// first copy when it has none - its fields are made current by the executor, and
|
||||
// only when it consumes them (CurrentIndirectCommandBytes).
|
||||
const Uint8* const parameterBytes =
|
||||
paramResource ? BufferImpl::SplitHostBytesForCpuRead(*paramResource,
|
||||
applierState.VerbIndirectParameterBuffer,
|
||||
"indirect_count_parameter")
|
||||
: nullptr;
|
||||
const Uint8* drawBytes = drawResource ? BufferImpl::SplitHostBytes(*drawResource) : nullptr;
|
||||
if (drawBytes == nullptr && drawResource != nullptr) {
|
||||
drawBytes = BufferImpl::SplitHostBytesForCpuRead(*drawResource, applierState.VerbIndirectBuffer,
|
||||
"indirect_count_commands");
|
||||
}
|
||||
if (commandBytes > BufferImpl::ResourceWidthForHandle(applierState.VerbIndirectBuffer)) {
|
||||
MGLOG_E_ONCE("MultiDrawArraysIndirectCount skipped: invalid GL_DRAW_INDIRECT_BUFFER binding or range");
|
||||
return;
|
||||
@@ -11625,51 +11740,49 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
}
|
||||
}
|
||||
|
||||
// P5c (hd), P5e (tx2): the verification half, with the RECORD passed in instead of re-read
|
||||
// from the verb stash - the caller has it and the two must not disagree about which texture
|
||||
// is being verified.
|
||||
static void EnsureGenerateMipmapStorageDescribed(const MG_Pipe::MGPipeResourceRecord& record) {
|
||||
// P8-B1: THE LEVELS A generate_mipmap RECORD GENERATES, end-exclusive. GL generates levels
|
||||
// BASE_LEVEL+1 .. q, q = min(p, MAX_LEVEL) with p the last level the base image's own chain
|
||||
// reaches, and an immutable texture's storage bounds the chain too (GL 4.6 core 8.14.4). The
|
||||
// client already computed that window (ComputeMipmapGenerationRange) and defined its levels
|
||||
// before emitting the verb, so the record's plan is the window and the descriptor is what
|
||||
// holds it: Base = VerbMipBaseLevel, End = min(VerbMipLevelCount, Desc.Levels, MaxLevel + 1,
|
||||
// Base + the base extent's chain) - the same clip Magma's GenerateWireMipmap makes.
|
||||
//
|
||||
// What stood here instead demanded the full chain from LEVEL 0 and died with
|
||||
// Fatal{UnmigratedEmulation, "generate-mipmap-storage"} whenever the descriptor held less: a
|
||||
// MAX_LEVEL below the chain, or glTexStorage2D with fewer levels, both legal GL.
|
||||
struct RecordMipWindow {
|
||||
Uint32 Base = 0;
|
||||
Uint32 End = 0; // end-exclusive; End <= Base + 1 generates nothing
|
||||
};
|
||||
|
||||
static RecordMipWindow GenerateMipmapWindowByRecord(const MG_Pipe::MGPipeResourceRecord& record) {
|
||||
const auto& applier = MG_Pipe::MGPipeApplier();
|
||||
const auto& desc = record.Desc;
|
||||
if (desc.Width == 0 || desc.Levels == 0) {
|
||||
MG_Pipe::MGPipeUnmigratedEmulation("generate-mipmap-storage");
|
||||
}
|
||||
Uint maxDimension = desc.Width;
|
||||
const auto target = static_cast<MG_Pipe::MGPipeResourceTarget>(desc.Target);
|
||||
if (target != MG_Pipe::MGPipeResourceTarget::Tex1D &&
|
||||
target != MG_Pipe::MGPipeResourceTarget::Tex1DArray) {
|
||||
maxDimension = std::max(maxDimension, desc.Height);
|
||||
}
|
||||
if (target == MG_Pipe::MGPipeResourceTarget::Tex3D) {
|
||||
maxDimension = std::max(maxDimension, desc.Depth);
|
||||
}
|
||||
Uint requiredLevels = 1;
|
||||
while (maxDimension > 1) {
|
||||
maxDimension /= 2;
|
||||
++requiredLevels;
|
||||
}
|
||||
if (desc.Levels < requiredLevels) {
|
||||
MG_Pipe::MGPipeUnmigratedEmulation("generate-mipmap-storage");
|
||||
RecordMipWindow window{applier.VerbMipBaseLevel, applier.VerbMipBaseLevel};
|
||||
if (desc.Width == 0 || desc.Levels == 0 || window.Base >= desc.Levels) return window;
|
||||
Uint32 end = std::min<Uint32>(applier.VerbMipLevelCount, desc.Levels);
|
||||
if (record.ParamsSerial) end = std::min<Uint32>(end, static_cast<Uint32>(record.Params.MaxLevel) + 1u);
|
||||
const IntVec3 baseExtent = MG_Remote::Server::StagedTextureMipExtent(desc.Target, desc.Width, desc.Height,
|
||||
desc.Depth, window.Base);
|
||||
const Int shrinking = MG_Remote::Server::StagedTextureShrinkingAxisCount(desc.Target);
|
||||
Int largest = 1;
|
||||
for (Int axis = 0; axis < shrinking && axis < 3; ++axis) largest = std::max<Int>(largest, baseExtent[axis]);
|
||||
Uint32 chain = 1;
|
||||
while (largest > 1) {
|
||||
largest /= 2;
|
||||
++chain;
|
||||
}
|
||||
window.End = std::max(window.Base, std::min(end, window.Base + chain));
|
||||
return window;
|
||||
}
|
||||
#endif
|
||||
|
||||
static Bool EnsureGenerateMipmapStorageAllocated(const SharedPtr<MG_State::GLState::ITextureObject>& texture) {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
// The frontend has already defined the generated chain before emitting this verb.
|
||||
// Its resource_respecify carries that shape, so the server only verifies the
|
||||
// descriptor; it must not allocate or dirty the client's level shadows again.
|
||||
// P5c (hd): identity is the handle the generate_mipmap record carried
|
||||
// (MGPMipPlan::Res, the verb stash) - the client allocator is never probed (T2).
|
||||
const auto handle = MG_Pipe::MGPipeApplier().VerbMipRes;
|
||||
const auto* record = PipeTextureRecordForHandle(handle);
|
||||
if (record == nullptr) {
|
||||
MG_Pipe::MGPipeUnmigratedEmulation("generate-mipmap-storage");
|
||||
}
|
||||
EnsureGenerateMipmapStorageDescribed(*record);
|
||||
return false; // No server-side shadow allocation was necessary.
|
||||
}
|
||||
#endif
|
||||
// P8-B1: the transport arm that stood here (a descriptor check under the same
|
||||
// `generate-mipmap-storage` name) was unreachable - GenerateMipmap returns through
|
||||
// GenerateMipmapByRecord before this call on every split arm - and the record arm's
|
||||
// window above replaces the check it made.
|
||||
auto* mipmapTexture = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(texture.get());
|
||||
MOBILEGL_ASSERT(mipmapTexture != nullptr, "GenerateMipmap requires mipmap texture storage.");
|
||||
Bool allocatedStorage = false;
|
||||
@@ -12403,11 +12516,16 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// re-derived its handle with a scoped `HandleOf` probe (the two sites §4.4 listed as
|
||||
// barriered), and the handle is now simply passed in - the extent derivation, the per-level
|
||||
// blits and the format question are §1's descriptor reads exactly as P5c wrote them.
|
||||
//
|
||||
// P8-B1: both chains run over the record's WINDOW (GenerateMipmapWindowByRecord), not from
|
||||
// level 1 to the end of the descriptor: a BASE_LEVEL above 0 is the source and a level past
|
||||
// MAX_LEVEL is left as it is, which is what the monolith twins below still get wrong.
|
||||
static void GenerateDepthTexture2DMipmapByRecord(const MG_Pipe::MGPipeResourceRecord& record,
|
||||
const SharedPtr<TextureImpl::BackendTextureObject>& backendTexture) {
|
||||
const SharedPtr<TextureImpl::BackendTextureObject>& backendTexture,
|
||||
const RecordMipWindow& window) {
|
||||
const auto& desc = record.Desc;
|
||||
const GLuint textureId = backendTexture->GetBackendTextureId();
|
||||
for (Uint32 level = 1; level < desc.Levels; ++level) {
|
||||
for (Uint32 level = window.Base + 1; level < window.End; ++level) {
|
||||
const IntVec3 srcSize = MG_Remote::Server::StagedTextureMipExtent(desc.Target, desc.Width, desc.Height,
|
||||
desc.Depth, level - 1);
|
||||
const IntVec3 dstSize = MG_Remote::Server::StagedTextureMipExtent(desc.Target, desc.Width, desc.Height,
|
||||
@@ -12420,12 +12538,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
}
|
||||
|
||||
static void GenerateColorTexture2DMipmapByRecord(const MG_Pipe::MGPipeResourceRecord& record,
|
||||
const SharedPtr<TextureImpl::BackendTextureObject>& backendTexture) {
|
||||
const SharedPtr<TextureImpl::BackendTextureObject>& backendTexture,
|
||||
const RecordMipWindow& window) {
|
||||
const auto& desc = record.Desc;
|
||||
const GLenum filter =
|
||||
IsIntegerColorFormat(static_cast<TextureInternalFormat>(desc.InternalFormat)) ? GL_NEAREST : GL_LINEAR;
|
||||
const GLuint textureId = backendTexture->GetBackendTextureId();
|
||||
for (Uint32 level = 1; level < desc.Levels; ++level) {
|
||||
for (Uint32 level = window.Base + 1; level < window.End; ++level) {
|
||||
const IntVec3 srcSize = MG_Remote::Server::StagedTextureMipExtent(desc.Target, desc.Width, desc.Height,
|
||||
desc.Depth, level - 1);
|
||||
const IntVec3 dstSize = MG_Remote::Server::StagedTextureMipExtent(desc.Target, desc.Width, desc.Height,
|
||||
@@ -12879,65 +12998,268 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
}
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-B2: RGB16F / RGB32F MIP GENERATION ON THE SERVER, FROM THE SERVER'S OWN LEVEL.
|
||||
//
|
||||
// ES generates a chain only for a colour-renderable, filterable format, and whether the
|
||||
// driver's storage for these two is one depends on the driver: Espryt stores them natively
|
||||
// where the driver renders the three-channel form and widens them to RGBA16F / RGBA32F where
|
||||
// it does not (TextureImpl::BackendTextureFormatAddsAlpha), and a widened RGBA32F still needs
|
||||
// OES_texture_float_linear to be filterable. So GenerateMipmapByRecord asks the driver first
|
||||
// and comes here only when it refuses - or when MGITEST_ESPRYT_FORCE_CPU_MIPMAP says to, which
|
||||
// is the only way a host whose driver never refuses reaches this arm.
|
||||
//
|
||||
// THE SOURCE IS THE SERVER'S LEVEL, NEVER THE CLIENT'S. The base level is read back from the
|
||||
// driver (ReadTextureLevelTight), because a render target's texels exist only there - the
|
||||
// monolith arm (GenerateThreeChannelFloatMipmapOnCpu) filters the frontend's level shadow
|
||||
// instead and reads a stale base after a draw. Only when the driver cannot read the level back
|
||||
// (storage it cannot attach) does the staged store answer, and a store that does not cover the
|
||||
// level declines by name rather than inventing texels.
|
||||
static Bool ForcedServerCpuMipmap() {
|
||||
// The R-16 control. Read by the SERVER, like the MGITEST_MAGMA_FORCE_* knobs.
|
||||
static const Bool s_forced = std::getenv("MGITEST_ESPRYT_FORCE_CPU_MIPMAP") != nullptr;
|
||||
return s_forced;
|
||||
}
|
||||
|
||||
// WireTextureReadback.inc (included further down) defines it: E's extent-scoped stand-in for a
|
||||
// driver that refuses to read a colour level back, asked here too so a host reaches the store
|
||||
// route below (P8-SE).
|
||||
static Bool WireTextureReadbackRefusedForTesting(const IntVec3& extent);
|
||||
|
||||
// The base level as tight RGB floats: the driver's texels first, the staged store second.
|
||||
//
|
||||
// P8-SE: THE STORE ANSWERS ONLY FOR A TEXTURE THE DRIVER NEVER WROTE (P8-E's sticky mark). A
|
||||
// render target's level 0 lives on the driver; the store still holds whatever crossed before
|
||||
// the draw, and filtering it would hand the chain stale texels. `driverWrittenBefore` is the
|
||||
// mark as it stood BEFORE this generation noted its own write (GenerateMipmap's split arm),
|
||||
// because that note is unconditional and would otherwise decline every store read. Anything
|
||||
// the store cannot stand for is a named decline, `declined` says why.
|
||||
static Bool ReadThreeChannelFloatLevelOnServer(MG_Pipe::MGPipeHandle mipRes,
|
||||
const MG_Pipe::MGPipeResourceRecord& record,
|
||||
const SharedPtr<TextureImpl::BackendTextureObject>& backendTexture,
|
||||
TextureTarget textureTarget, TextureUploadTarget face, Uint32 level,
|
||||
const IntVec3& extent, Bool driverWrittenBefore,
|
||||
Vector<Float>& rgb, const char*& declined) {
|
||||
const auto format = static_cast<TextureInternalFormat>(record.Desc.InternalFormat);
|
||||
const SizeT texels = static_cast<SizeT>(extent.x()) * static_cast<SizeT>(extent.y());
|
||||
Vector<Uint8> bytes;
|
||||
if (!WireTextureReadbackRefusedForTesting(extent) &&
|
||||
ReadTextureLevelTight(backendTexture->GetBackendTextureId(), textureTarget, face, format,
|
||||
static_cast<GLint>(level), extent, backendTexture->RequiresImageBindableStorage(),
|
||||
GL_RGB, GL_FLOAT, bytes) &&
|
||||
bytes.size() == texels * 3 * sizeof(Float)) {
|
||||
rgb.resize(texels * 3);
|
||||
Memcpy(rgb.data(), bytes.data(), bytes.size());
|
||||
return true;
|
||||
}
|
||||
auto& store = MG_Remote::Server::ServerStagedTexture();
|
||||
const Uint64 key = MG_Remote::Server::StagedTextureStore::KeyForHandle(mipRes);
|
||||
const auto faceCode = static_cast<Uint16>(face);
|
||||
const auto levelCode = static_cast<Uint16>(level);
|
||||
const Bool half = format == TextureInternalFormat::RGB16F;
|
||||
const SizeT componentBytes = half ? sizeof(Uint16) : sizeof(Float);
|
||||
// A view's staged bytes live under its storage owner's key, in the owner's levels; a view
|
||||
// whose level the driver cannot read has no answer here.
|
||||
if (!MG_Pipe::MGPipeHandleIsNull(record.Desc.ViewOf)) {
|
||||
declined = "a view has no staged level of its own";
|
||||
} else if (!store.CopiesIntoServerStorage()) {
|
||||
declined = "this arm keeps no staged store";
|
||||
} else if (driverWrittenBefore) {
|
||||
declined = "the driver has written the texture since its bytes crossed";
|
||||
} else if (!store.IsCovered(key, faceCode, levelCode)) {
|
||||
declined = "not every byte of the level crossed";
|
||||
} else if (store.LevelByteSize(key, faceCode, levelCode) != texels * 3 * componentBytes) {
|
||||
declined = "the staged level is not the size of the level";
|
||||
}
|
||||
if (declined != nullptr) return false;
|
||||
const Uint8* staged = store.RequireLevelBytes(key, faceCode, levelCode, "generate-mipmap-server-cpu");
|
||||
rgb.resize(texels * 3);
|
||||
for (SizeT i = 0; i < texels * 3; ++i) {
|
||||
if (half) {
|
||||
Uint16 bits = 0;
|
||||
Memcpy(&bits, staged + i * componentBytes, sizeof(bits));
|
||||
rgb[i] = MG_Util::DecodeHalfBitsToFloat(bits);
|
||||
} else {
|
||||
Memcpy(&rgb[i], staged + i * componentBytes, sizeof(Float));
|
||||
}
|
||||
}
|
||||
MGLOG_W_ONCE("MGPipe: generate-mipmap-server-cpu: texture {%u, %u} level %u could not be read back from "
|
||||
"the driver; filtering the staged store's copy of it instead",
|
||||
mipRes.Slot, mipRes.Gen, level);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void GenerateThreeChannelFloatMipmapOnServer(MG_Pipe::MGPipeHandle mipRes,
|
||||
const MG_Pipe::MGPipeResourceRecord& record,
|
||||
const SharedPtr<TextureImpl::BackendTextureObject>& backendTexture,
|
||||
Bool driverWrittenBefore, const char* why) {
|
||||
const auto& desc = record.Desc;
|
||||
const auto format = static_cast<TextureInternalFormat>(desc.InternalFormat);
|
||||
const auto textureTarget = TextureTargetForPipeResourceTarget(desc.Target);
|
||||
const RecordMipWindow window = GenerateMipmapWindowByRecord(record);
|
||||
if (window.End <= window.Base + 1) return;
|
||||
Vector<TextureUploadTarget> faces;
|
||||
if (textureTarget == TextureTarget::Texture2D) {
|
||||
faces.push_back(TextureUploadTarget::Texture2D);
|
||||
} else if (textureTarget == TextureTarget::TextureCubeMap) {
|
||||
for (Int face = 0; face < 6; ++face)
|
||||
faces.push_back(static_cast<TextureUploadTarget>(
|
||||
static_cast<Int>(TextureUploadTarget::CubeMapPositiveX) + face));
|
||||
}
|
||||
// The upload spelling the driver's storage takes: GL_FLOAT is legal for all four float
|
||||
// internal formats (ES 3.2 table 8.2), and the channel count follows the storage.
|
||||
GLenum esInternal = GL_NONE, esFormat = GL_NONE, esType = GL_NONE;
|
||||
TextureImpl::GenerateTextureFormatInfo(format, &esInternal, &esFormat, &esType, textureTarget);
|
||||
const Bool fourChannel = esInternal == GL_RGBA16F || esInternal == GL_RGBA32F;
|
||||
if (faces.empty() || (!fourChannel && esInternal != GL_RGB16F && esInternal != GL_RGB32F)) {
|
||||
MGLOG_E_ONCE("MGPipe: generate-mipmap-server-cpu declines texture {%u, %u}: target %s stored as %s has "
|
||||
"no server CPU arm (%s); levels %u..%u are left as they are",
|
||||
mipRes.Slot, mipRes.Gen, MG_Util::ConvertTextureTargetToString(textureTarget).c_str(),
|
||||
MG_Util::ConvertGLEnumToString(esInternal).c_str(), why, window.Base + 1, window.End - 1);
|
||||
return;
|
||||
}
|
||||
MGLOG_I_ONCE("MGPipe: generate-mipmap-server-cpu: %s levels filtered on the server's CPU from its own "
|
||||
"level (%s)", MG_Util::ConvertTextureInternalFormatToString(format).c_str(), why);
|
||||
|
||||
const GLuint textureId = backendTexture->GetBackendTextureId();
|
||||
const GLenum bindTarget = TextureImpl::ConvertTextureTargetToBackendGLEnum(textureTarget);
|
||||
for (const TextureUploadTarget face : faces) {
|
||||
IntVec3 extent = MG_Remote::Server::StagedTextureMipExtent(desc.Target, desc.Width, desc.Height,
|
||||
desc.Depth, window.Base);
|
||||
Vector<Float> level;
|
||||
const char* declined = nullptr;
|
||||
if (!ReadThreeChannelFloatLevelOnServer(mipRes, record, backendTexture, textureTarget, face, window.Base,
|
||||
extent, driverWrittenBefore, level, declined)) {
|
||||
MGLOG_E_ONCE("MGPipe: generate-mipmap-server-cpu declines texture {%u, %u}: base level %u could not "
|
||||
"be read back from the driver and the staged store cannot stand for it (%s); levels "
|
||||
"%u..%u are left as they are - DECLINED (generate-mipmap-store-declined)",
|
||||
mipRes.Slot, mipRes.Gen, window.Base, declined != nullptr ? declined : "?",
|
||||
window.Base + 1, window.End - 1);
|
||||
return;
|
||||
}
|
||||
for (Uint32 dst = window.Base + 1; dst < window.End; ++dst) {
|
||||
const IntVec3 dstExtent =
|
||||
MG_Remote::Server::StagedTextureMipExtent(desc.Target, desc.Width, desc.Height, desc.Depth, dst);
|
||||
// The monolith's box filter: the 2x2 source footprint, clamped where a dimension
|
||||
// is already 1 (GL 4.6 core 8.14.4 leaves the filter to the implementation).
|
||||
Vector<Float> next(static_cast<SizeT>(dstExtent.x()) * static_cast<SizeT>(dstExtent.y()) * 3);
|
||||
const auto at = [&](Int x, Int y, Int c) {
|
||||
return level[(static_cast<SizeT>(y) * static_cast<SizeT>(extent.x()) + static_cast<SizeT>(x)) * 3 +
|
||||
static_cast<SizeT>(c)];
|
||||
};
|
||||
for (Int y = 0; y < dstExtent.y(); ++y) {
|
||||
for (Int x = 0; x < dstExtent.x(); ++x) {
|
||||
const Int x0 = std::min(x * 2, extent.x() - 1), x1 = std::min(x * 2 + 1, extent.x() - 1);
|
||||
const Int y0 = std::min(y * 2, extent.y() - 1), y1 = std::min(y * 2 + 1, extent.y() - 1);
|
||||
for (Int c = 0; c < 3; ++c)
|
||||
next[(static_cast<SizeT>(y) * static_cast<SizeT>(dstExtent.x()) + static_cast<SizeT>(x)) *
|
||||
3 + static_cast<SizeT>(c)] =
|
||||
0.25f * (at(x0, y0, c) + at(x1, y0, c) + at(x0, y1, c) + at(x1, y1, c));
|
||||
}
|
||||
}
|
||||
Vector<Float> upload;
|
||||
if (fourChannel) {
|
||||
const SizeT count = next.size() / 3;
|
||||
upload.resize(count * 4);
|
||||
for (SizeT i = 0; i < count; ++i) {
|
||||
upload[i * 4] = next[i * 3];
|
||||
upload[i * 4 + 1] = next[i * 3 + 1];
|
||||
upload[i * 4 + 2] = next[i * 3 + 2];
|
||||
upload[i * 4 + 3] = 1.0f;
|
||||
}
|
||||
}
|
||||
// Tight float rows are a multiple of four bytes, which the resting UNPACK state
|
||||
// (4/0/0/0, and the unpack-PBO binding at 0) parses as they are - CopyR32FTexture2D's
|
||||
// discipline, including the re-bind that keeps the binding cache truthful.
|
||||
ClearGLErrors();
|
||||
BufferImpl::BindPixelUnpackBufferId(0);
|
||||
TextureImpl::ActivateTextureUnit(TextureImpl::TempTextureUnit);
|
||||
g_GLESFuncs.glBindTexture(bindTarget, textureId);
|
||||
g_GLESFuncs.glTexSubImage2D(TextureImpl::ConvertTextureUploadTargetToBackendGLEnum(face),
|
||||
static_cast<GLint>(dst), 0, 0, static_cast<GLsizei>(dstExtent.x()),
|
||||
static_cast<GLsizei>(dstExtent.y()), fourChannel ? GL_RGBA : GL_RGB,
|
||||
GL_FLOAT, fourChannel ? upload.data() : next.data());
|
||||
const GLenum err = g_GLESFuncs.glGetError();
|
||||
auto* cachedBound = TextureImpl::g_boundTexturesCache[TextureImpl::TempTextureUnit]
|
||||
[static_cast<SizeT>(textureTarget)];
|
||||
g_GLESFuncs.glBindTexture(bindTarget, cachedBound ? cachedBound->GetBackendTextureId() : 0);
|
||||
if (err != GL_NO_ERROR) {
|
||||
MGLOG_E_ONCE("MGPipe: generate-mipmap-server-cpu: uploading level %u of texture {%u, %u} "
|
||||
"failed: %s", dst, mipRes.Slot, mipRes.Gen,
|
||||
MG_Util::ConvertGLEnumToString(err).c_str());
|
||||
return;
|
||||
}
|
||||
level = Move(next);
|
||||
extent = dstExtent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// P5e (tx2), CONTRACT-P5E §5.2: glGenerateMipmap's body once the texture came from
|
||||
// VerbMipRes. Same four arms as the frontend body, with every shape question answered from
|
||||
// the descriptor.
|
||||
//
|
||||
// RULING 14, AND WHY THE ROW IS NOT FLIPPED HERE. The unit read this arm retires is what the
|
||||
// wait existed for, but ONE frontend contact is left on the path and it is not tx2's to
|
||||
// retire: the RGB16F/RGB32F CPU filter reaches into the client's level shadows
|
||||
// (GenerateThreeChannelFloatMipmapOnCpu, kimi audit row 61) and P8/P9 own the pull. So the
|
||||
// brief's escape applies - the arm is not complete, the row stays kWaitApplied and the flip
|
||||
// is listed as trailing - and the record stays barriered, which is what keeps the CPU arm's
|
||||
// refusal a refusal rather than a wrong picture.
|
||||
// RULING 14's TRAILING FLIP. tx2 kept this verb's PipeCalls.def row at kWaitApplied because
|
||||
// one frontend contact was left on the path: the RGB16F/RGB32F CPU filter reached into the
|
||||
// client's level shadows. P8-B2 retired it (GenerateThreeChannelFloatMipmapOnServer reads the
|
||||
// server's own level), so no arm here reads client memory any more; the WaitClass flip itself
|
||||
// is a protocol change and is left to the integrator.
|
||||
//
|
||||
// `driverWrittenBefore`: P8-E's driver-written mark on the texture's staged store as it stood
|
||||
// before this call noted its own write - the CPU arm's store route reads it (P8-SE).
|
||||
static void GenerateMipmapByRecord(GLenum target, MG_Pipe::MGPipeHandle mipRes,
|
||||
const MG_Pipe::MGPipeResourceRecord& record,
|
||||
const SharedPtr<TextureImpl::BackendTextureObject>& backendTexture) {
|
||||
const SharedPtr<TextureImpl::BackendTextureObject>& backendTexture,
|
||||
Bool driverWrittenBefore) {
|
||||
const auto format = static_cast<TextureInternalFormat>(record.Desc.InternalFormat);
|
||||
const auto textureTarget = TextureTargetForPipeResourceTarget(record.Desc.Target);
|
||||
const Bool threeChannelFloat =
|
||||
format == TextureInternalFormat::RGB16F || format == TextureInternalFormat::RGB32F;
|
||||
|
||||
if (format == TextureInternalFormat::R11FG11FB10F || IsDepthOnlyFormat(format) ||
|
||||
format == TextureInternalFormat::RGB16F || format == TextureInternalFormat::RGB32F) {
|
||||
// The storage verification EnsureGenerateMipmapStorageAllocated's disaggregated arm
|
||||
// already makes, with the record passed in rather than re-read from VerbMipRes: the
|
||||
// frontend defined the generated chain before emitting this verb, so the server only
|
||||
// checks that the descriptor it was given can carry it.
|
||||
EnsureGenerateMipmapStorageDescribed(record);
|
||||
}
|
||||
if (format == TextureInternalFormat::RGB16F || format == TextureInternalFormat::RGB32F) {
|
||||
// The CPU filter reads and writes the CLIENT's level shadows. It already aborts
|
||||
// three frames deep at the MipmapStorage guard under a transport; naming it here
|
||||
// says which emulation, which is what the guard cannot.
|
||||
MG_Pipe::MGPipeUnmigratedEmulation("generate-mipmap-cpu-filter");
|
||||
}
|
||||
// A view's layer window is the one bound the native arm cannot express, so it is asked
|
||||
// for before the format arms - those two are 2D-only emulations of the same generation
|
||||
// and a view reaches them too.
|
||||
if (GenerateMipmapThroughViewWindowByRecord(mipRes, record, format)) return;
|
||||
if (IsDepthOnlyFormat(format)) {
|
||||
GenerateDepthTexture2DMipmapByRecord(record, backendTexture);
|
||||
GenerateDepthTexture2DMipmapByRecord(record, backendTexture, GenerateMipmapWindowByRecord(record));
|
||||
return;
|
||||
}
|
||||
if (format == TextureInternalFormat::R11FG11FB10F && textureTarget == TextureTarget::Texture2D) {
|
||||
GenerateColorTexture2DMipmapByRecord(record, backendTexture);
|
||||
GenerateColorTexture2DMipmapByRecord(record, backendTexture, GenerateMipmapWindowByRecord(record));
|
||||
return;
|
||||
}
|
||||
if (threeChannelFloat && ForcedServerCpuMipmap()) {
|
||||
GenerateThreeChannelFloatMipmapOnServer(mipRes, record, backendTexture, driverWrittenBefore,
|
||||
"forced by MGITEST_ESPRYT_FORCE_CPU_MIPMAP");
|
||||
return;
|
||||
}
|
||||
|
||||
const GLenum backendTarget =
|
||||
TextureImpl::ConvertTextureTargetToBackendGLEnum(MG_Util::ConvertGLEnumToTextureTarget(target));
|
||||
// TempTextureUnit, not the active unit: the scratch bind is the backend's own and
|
||||
// BindCurrentTextures re-establishes the sampling bindings regardless. The ACTIVE unit
|
||||
// was never anything but the frontend's way of naming the texture, and the record names
|
||||
// it now.
|
||||
backendTexture->Bind(backendTarget, TextureImpl::TempTextureUnit);
|
||||
// ANGLE/Mesa may validate the currently bound FBO while generating mipmaps, so the
|
||||
// source texture is detached from every framebuffer that attaches it - by handle, over
|
||||
// the applier's own framebuffer records.
|
||||
ScopedDetachedTextureFramebufferAttachments detachedAttachments(mipRes);
|
||||
ScopedCompleteFramebufferBinding completeFramebuffer;
|
||||
ClearGLErrors();
|
||||
g_GLESFuncs.glGenerateMipmap(backendTarget);
|
||||
RecordGLError("glGenerateMipmap", backendTarget, format);
|
||||
GLenum refused = GL_NO_ERROR;
|
||||
{
|
||||
// TempTextureUnit, not the active unit: the scratch bind is the backend's own and
|
||||
// BindCurrentTextures re-establishes the sampling bindings regardless. The ACTIVE unit
|
||||
// was never anything but the frontend's way of naming the texture, and the record
|
||||
// names it now.
|
||||
backendTexture->Bind(backendTarget, TextureImpl::TempTextureUnit);
|
||||
// ANGLE/Mesa may validate the currently bound FBO while generating mipmaps, so the
|
||||
// source texture is detached from every framebuffer that attaches it - by handle,
|
||||
// over the applier's own framebuffer records.
|
||||
ScopedDetachedTextureFramebufferAttachments detachedAttachments(mipRes);
|
||||
ScopedCompleteFramebufferBinding completeFramebuffer;
|
||||
ClearGLErrors();
|
||||
g_GLESFuncs.glGenerateMipmap(backendTarget);
|
||||
if (!threeChannelFloat) {
|
||||
RecordGLError("glGenerateMipmap", backendTarget, format);
|
||||
return;
|
||||
}
|
||||
// The driver's refusal of a three-channel float chain is not the application's
|
||||
// error: the CPU arm below answers it.
|
||||
refused = g_GLESFuncs.glGetError();
|
||||
}
|
||||
if (refused == GL_NO_ERROR) return;
|
||||
GenerateThreeChannelFloatMipmapOnServer(mipRes, record, backendTexture, driverWrittenBefore,
|
||||
"the driver refused glGenerateMipmap");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12964,8 +13286,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// for GenerateMipmap move to kWaitNone.
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
const auto mipRes = MG_Pipe::MGPipeApplier().VerbMipRes;
|
||||
// P8-SE: whether the staged store still stands for the texture is read BEFORE the note
|
||||
// below sets the mark, or the CPU arm's store route could never answer at all.
|
||||
const Bool driverWrittenBefore = MG_Remote::Server::ServerStagedTexture().IsDriverWritten(
|
||||
MG_Remote::Server::StagedTextureStore::KeyForHandle(mipRes));
|
||||
// Every arm GenerateMipmapByRecord takes writes the levels above the base on the
|
||||
// driver only (its CPU filter is unmigrated and aborts), so the note is unconditional.
|
||||
// driver only (P8-B2's CPU arm uploads its levels there too), so the note is
|
||||
// unconditional.
|
||||
TextureImpl::NoteDriverSideTextureWriteByHandle(mipRes);
|
||||
auto& backendTexture = TextureImpl::SyncTextureToBackendByHandle(mipRes);
|
||||
const auto* record = PipeTextureRecordForHandle(mipRes);
|
||||
@@ -12975,7 +13302,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
mipRes.Slot, mipRes.Gen);
|
||||
return;
|
||||
}
|
||||
GenerateMipmapByRecord(target, mipRes, *record, backendTexture);
|
||||
GenerateMipmapByRecord(target, mipRes, *record, backendTexture, driverWrittenBefore);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -13109,25 +13436,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
|
||||
// The renderbuffer twin of TextureImpl::SyncTextureObjectToBackend: the same
|
||||
// find-or-create-then-sync the framebuffer attachment walk does (see SyncAttachmentObject),
|
||||
// reachable from a path that has a renderbuffer but no framebuffer.
|
||||
// reachable from a path that has a renderbuffer but no framebuffer. The MONOLITH arm's only:
|
||||
// under a transport MakeGLESCopyImageEndpoint resolves a renderbuffer endpoint by handle and
|
||||
// never calls this. (P8-E removed the `CopyImageSubData+RENDERBUFFER` latch that stood here -
|
||||
// its transport condition could not hold at the only call site - and
|
||||
// CopyImageStoreReadbackScenario's renderbuffer case runs the handle arm on every transport.)
|
||||
static SharedPtr<RenderbufferImpl::BackendRenderbufferObject> SyncRenderbufferObjectToBackend(
|
||||
const SharedPtr<MG_State::GLState::RenderbufferObject>& renderbufferObject) {
|
||||
if (!renderbufferObject) return nullptr;
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P5e (fb, CONTRACT-P5E.md §4.4): the scope at this site is DELETED, and with it the
|
||||
// arm that needed it. The only caller is the glCopyImageSubData endpoint builder, and a
|
||||
// RENDERBUFFER endpoint is refused on the wire before it is emitted and again at the
|
||||
// sink (PipeApplier.cpp's ServerUnmigratedVerbFatal("CopyImageSubData+RENDERBUFFER")),
|
||||
// so under a transport nothing can reach here with one. Saying so by name is better
|
||||
// than a find-or-MINT against the frontend address that the refusal already proved
|
||||
// unreachable - if it ever becomes reachable, the name is where to start.
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
MGLOG_F("MGPipe: Fatal{UnmigratedVerb, \"CopyImageSubData+RENDERBUFFER\"} a renderbuffer "
|
||||
"endpoint reached the backend under an active transport, where both the client "
|
||||
"emitter and the sink refuse one");
|
||||
std::abort();
|
||||
}
|
||||
#endif
|
||||
SharedPtr<RenderbufferImpl::BackendRenderbufferObject> backendRenderbufferObject;
|
||||
if (auto* slot = RenderbufferImpl::g_backendRenderbufferObjects.Find(renderbufferObject.get())) {
|
||||
backendRenderbufferObject = *slot;
|
||||
@@ -13248,19 +13564,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
auto* dstMipmap = MG_State::GLState::AsMipmapTexture(dstEndpoint.Texture.get());
|
||||
if (!srcMipmap || !dstMipmap) return;
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P5b package i1's ONE backend edit, and the contract names this site
|
||||
// (MG_Remote/CONTRACT-P5B.md §2 i1 "the copy-image-shadow-mirror emulation", ruling
|
||||
// §6.7). Migrating glCopyImageSubData moves the first blocker off the client's
|
||||
// Fatal{UnmigratedVerb} and onto the Fatal below, on every Espryt copy between two
|
||||
// textures with CPU shadows - so the ruling is: UNDER A REAL TRANSPORT THE SERVER SKIPS
|
||||
// THE MIRROR, and the client-side mirror ROADMAP P8 names ("CopyImage 镜像搬到 client")
|
||||
// stays P8's.
|
||||
//
|
||||
// WHAT THE SKIP LOSES IS BOUNDED BY TWO FATALS, which is the whole reason it is allowed
|
||||
// to be a skip rather than a port: a later glGetTexImage of the destination served from
|
||||
// the shadow is class C wave 3 (Fatal{UnmigratedVerb, "GetTexImage"}, P9), and a texture
|
||||
// re-mint under a transport reads the GPU level itself (RequireImageBindableStorageByHandle,
|
||||
// P9 W2) rather than any shadow. Neither can silently read the un-mirrored shadow.
|
||||
// UNDER A REAL TRANSPORT THE SERVER HAS NO FRONTEND SHADOW TO MIRROR INTO (P5b i1, ruling
|
||||
// §6.7), and P8-E settled where the move lives instead - not on the client (ROADMAP P8's
|
||||
// original row) but in the server's staged store: CopyImageSubData's handle arm makes the
|
||||
// same texel-block move there (TextureImpl::FollowCopyImageInStagedStore) for EVERY
|
||||
// format, not only the redundant-encoding ones this mirror serves, and marks the store
|
||||
// driver-written where it cannot. The store is what answers a split glGetTexImage the
|
||||
// driver refuses to read back (WireTextureReadback.inc's store route); every other split
|
||||
// read of the destination reads the GPU level itself (notes/p8/E.md).
|
||||
//
|
||||
// BEHIND #if MOBILEGL_BUILD_DISAGGREGATED so the pull build's code does not move (G1),
|
||||
// and the arm is the TRANSPORT and not the build - build-split runs its unit and
|
||||
@@ -13268,14 +13579,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// ordinary correct path and must still run.
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) return;
|
||||
#endif
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
// P4a (D-M). glCopyImageSubData's CPU-shadow mirror copies the source level's shadow
|
||||
// rows into the DESTINATION's shadow so a later readback of the destination sees what
|
||||
// the GPU copy put there. Both shadows are the client's, so this is the clearest case
|
||||
// in the family of an emulation that cannot survive a split; ROADMAP puts the move
|
||||
// itself in P8 and this names the site until then.
|
||||
MG_Pipe::MGPipeUnmigratedEmulation("copy-image-shadow-mirror");
|
||||
#endif
|
||||
// P4a (D-M) named this site `copy-image-shadow-mirror` with MGPipeUnmigratedEmulation.
|
||||
// P8-SE removed the call: the return above means no transport reaches it, and on a
|
||||
// monolith arm the call was a no-op (PipeCatalogueTest's list and the lint
|
||||
// scripts/ci/unmigrated_emulation_sites.py follow).
|
||||
|
||||
const auto srcUploadTarget = srcEndpoint.Texture->GetUploadTargets()[0];
|
||||
const auto dstUploadTarget = dstEndpoint.Texture->GetUploadTargets()[0];
|
||||
@@ -13347,9 +13654,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
}
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// The handle arm's endpoint names its texture by handle, and the server has no frontend
|
||||
// object to note.
|
||||
if (!dstEndpoint.IsRenderbuffer() && !MG_Pipe::MGPipeHandleIsNull(dstEndpoint.TextureHandle)) {
|
||||
TextureImpl::NoteDriverSideTextureWriteByHandle(dstEndpoint.TextureHandle);
|
||||
// object to note. The staged store's half of the note waits for the copy (P8-E, below).
|
||||
const Bool handleArmDestination =
|
||||
!dstEndpoint.IsRenderbuffer() && !MG_Pipe::MGPipeHandleIsNull(dstEndpoint.TextureHandle);
|
||||
if (handleArmDestination) {
|
||||
TextureImpl::NoteDriverSideTextureWriteByHandle(dstEndpoint.TextureHandle, /*storeFollowsTheWrite=*/true);
|
||||
}
|
||||
#endif
|
||||
if (!MakeGLESCopyImageEndpoint(srcEndpoint, srcTarget, srcX, srcY, srcZ, src) ||
|
||||
@@ -13357,6 +13666,26 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
MGLOG_E_ONCE("%s: source or destination image failed to sync; declining the copy", __func__);
|
||||
return;
|
||||
}
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-E (notes/p8/E.md): THE SERVER'S STAGED STORE FOLLOWS THE COPY. Both endpoints are synced,
|
||||
// so every byte the store holds for them is on the driver, and the copy below is a raw
|
||||
// texel-block move - the store makes the same move, which keeps the destination level
|
||||
// answerable from here when the driver will not read it back (ReadTextureImageWire's store
|
||||
// route) and keeps a whole-level replay of it (a re-mint's refused readback, a full-level
|
||||
// re-upload) from putting the pre-copy texels back. Where the store cannot follow (a
|
||||
// renderbuffer, a cube or 1D-array endpoint, a source the driver has written, a level whose
|
||||
// bytes did not all cross) it is marked driver-written instead, so it declines rather than
|
||||
// answering with stale bytes. Nothing moves to the client (ROADMAP P8's original row).
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith && handleArmDestination) {
|
||||
const Bool followed =
|
||||
!srcEndpoint.IsRenderbuffer() && !MG_Pipe::MGPipeHandleIsNull(srcEndpoint.TextureHandle) &&
|
||||
TextureImpl::FollowCopyImageInStagedStore(
|
||||
srcEndpoint.TextureHandle, static_cast<Uint32>(srcLevel), IntVec3{srcX, srcY, srcZ},
|
||||
dstEndpoint.TextureHandle, static_cast<Uint32>(dstLevel), IntVec3{dstX, dstY, dstZ},
|
||||
IntVec3{srcWidth, srcHeight, srcDepth});
|
||||
if (!followed) TextureImpl::NoteDriverSideTextureWriteByHandle(dstEndpoint.TextureHandle);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Verbatim: GL already spells a 1D array's extent the way the ES 2D array it maps onto
|
||||
// wants it (height 1, layers on depth) - see MakeGLESCopyImageEndpoint.
|
||||
@@ -13430,6 +13759,12 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
MG_Util::ConvertGLEnumToString(dst.target).c_str(),
|
||||
MG_Util::ConvertGLEnumToString(dstTarget).c_str());
|
||||
MOBILEGL_ASSERT(false, "glCopyImageSubData failed after frontend validation accepted the request.");
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-E: the store already made the move the driver just refused.
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith && handleArmDestination) {
|
||||
TextureImpl::NoteDriverSideTextureWriteByHandle(dstEndpoint.TextureHandle);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
// The copy landed on the GPU. For a destination whose readback cannot be bit-exact the
|
||||
@@ -14988,10 +15323,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// Session::Fail entirely, which is the funnel the census gate watches.
|
||||
//
|
||||
// THE FUNNEL KEEPS ITS TEETH FOR THE OTHER SITES: MGPipeUnmigratedEmulation still
|
||||
// aborts for generate-mipmap-storage, generate-mipmap-cpu-fallback and
|
||||
// generate-mipmap-cpu-filter, which really do reach into a client address space. Only
|
||||
// this call site is retired here, and only because its own premise did not hold
|
||||
// (texture-remint-pull went the same way in P9 W2, for the same reason).
|
||||
// names generate-mipmap-storage and generate-mipmap-cpu-fallback, on monolith arms only
|
||||
// (P8-SE dropped copy-image-shadow-mirror, a site no transport reached). Only this call
|
||||
// site is retired here, and only because its own premise did not hold (texture-remint-pull
|
||||
// went the same way in P9 W2, and P8-B the two split generate-mipmap names, likewise).
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
if (shadow == nullptr) {
|
||||
MGLOG_E_ONCE("GetTexImage: no level shadow on this side for target=0x%x level=%d, and under an "
|
||||
@@ -15893,7 +16228,18 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// resizing depth/stencil without colour would report the default framebuffer incomplete.
|
||||
static void PublishDefaultFramebufferDepthStencilFormat() {
|
||||
auto& defaultFBOInfo = MG_Impl::GLImpl::FramebufferImpl::pDefaultFramebufferInfo;
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
// P8-SE: THE PLACEHOLDER IS ONLY THE MONOLITH ARM'S TARGET. With a transport the answer is
|
||||
// posted (OnSurfaceChanged, below) and the client writes its own placeholder; a spawn or tcp
|
||||
// server process has no frontend at all, so pDefaultFramebufferInfo is null there. Gating on
|
||||
// it returned before the post, the client kept Init.cpp's GL_DEPTH32F_STENCIL8 guess for a
|
||||
// D24S8 pbuffer, and a blit into a buffer allocated from that guess lost depth and stencil
|
||||
// (notes/p8/SE.md). Inproc only passed because client and server share the process.
|
||||
if (!g_GLESFuncs.glGetFramebufferAttachmentParameteriv) return;
|
||||
if (!defaultFBOInfo && MG_Pipe::gMGPipeCallbacks.OnSurfaceChanged == nullptr) return;
|
||||
#else
|
||||
if (!defaultFBOInfo || !g_GLESFuncs.glGetFramebufferAttachmentParameteriv) return;
|
||||
#endif
|
||||
|
||||
// GL_DEPTH / GL_STENCIL are the default framebuffer's spellings; a user framebuffer
|
||||
// would need GL_DEPTH_ATTACHMENT / GL_STENCIL_ATTACHMENT and answers GL_INVALID_ENUM
|
||||
@@ -15974,8 +16320,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
stencilFormat = TextureInternalFormat::StencilIndex8;
|
||||
}
|
||||
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
// Null in a spawn / tcp server (above); only the monolith arm below writes through them.
|
||||
auto* depthTexture = defaultFBOInfo ? defaultFBOInfo->depthAttachment.get() : nullptr;
|
||||
auto* stencilTexture = defaultFBOInfo ? defaultFBOInfo->stencilAttachment.get() : nullptr;
|
||||
#else
|
||||
auto* depthTexture = defaultFBOInfo->depthAttachment.get();
|
||||
auto* stencilTexture = defaultFBOInfo->stencilAttachment.get();
|
||||
#endif
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
if (MG_Pipe::gMGPipeCallbacks.OnSurfaceChanged != nullptr) {
|
||||
// P5c ev (CONTRACT-P5C §4.2): with an active transport the attachments are CLIENT
|
||||
|
||||
@@ -1490,9 +1490,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
hostBaseFrom, hostBaseTo, start, end);
|
||||
}
|
||||
#endif
|
||||
// Read per range, like the pull arm: a ring copy staged for an earlier range of
|
||||
// this same drain puts every later partial range of the store behind it
|
||||
// (InvalidateFlushAccessFor's queued-copy rule, dev f973008c).
|
||||
const Bool ringCopyInFlight = resource.ringCopyRetireSerial > DirectGLES::CompletedFrameSerial();
|
||||
const GLbitfield access =
|
||||
mapUsable ? InvalidateFlushAccessFor(start, end, coveredFrom, coveredTo, limit,
|
||||
resource.storageSize)
|
||||
resource.storageSize, ringCopyInFlight)
|
||||
: 0u;
|
||||
if (access != 0) {
|
||||
BindBufferId(TempBufferTarget, resource.id);
|
||||
@@ -1512,6 +1516,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
BindBufferId(GL_COPY_WRITE_BUFFER, resource.id);
|
||||
g_GLESFuncs.glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER,
|
||||
(GLintptr)ringOffset, (GLintptr)start, (GLsizeiptr)size);
|
||||
// Commands recorded now retire with the fence the next Present inserts.
|
||||
resource.ringCopyRetireSerial = DirectGLES::CurrentFrameSerial() + 1;
|
||||
} else {
|
||||
UploadRangeFrom(resource, hostBase, start, end);
|
||||
}
|
||||
@@ -1766,8 +1772,18 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// shadow's to rewrite. Widening to page bounds looked free and was
|
||||
// not - the widened bytes clobbered GPU-written data (an SSBO
|
||||
// counter beside the app's SubData) with the stale shadow.
|
||||
//
|
||||
// A partial range-invalidating map must not overtake a ring copy into
|
||||
// this store the GPU has not run yet. Adreno 830 answers such a map on
|
||||
// a store with a copy still queued by losing the copy: the Embeddium
|
||||
// section meshes create-instancing staged through the ring came out
|
||||
// empty (whole terrain sections missing, SSIM 0.870), and routing the
|
||||
// map ranges behind the copies - the ring tier, GPU-ordered after them -
|
||||
// brings every one back. The whole-buffer orphan-map is exempt: it
|
||||
// rewrites every byte from the shadow the queued copies were taken from.
|
||||
const Bool wholeBuffer = start == 0 && end == limit && limit == resource.storageSize;
|
||||
if (mapUsable && (wholeBuffer || size >= kInvalidateRangeMinBytes)) {
|
||||
const Bool ringCopyInFlight = resource.ringCopyRetireSerial > DirectGLES::CompletedFrameSerial();
|
||||
if (mapUsable && (wholeBuffer || (size >= kInvalidateRangeMinBytes && !ringCopyInFlight))) {
|
||||
BindBufferId(TempBufferTarget, resource.id);
|
||||
const GLbitfield access =
|
||||
GL_MAP_WRITE_BIT |
|
||||
@@ -1788,6 +1804,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
BindBufferId(GL_COPY_WRITE_BUFFER, resource.id);
|
||||
g_GLESFuncs.glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER,
|
||||
(GLintptr)ringOffset, (GLintptr)start, (GLsizeiptr)size);
|
||||
// Commands recorded now retire with the fence the next Present inserts.
|
||||
resource.ringCopyRetireSerial = DirectGLES::CurrentFrameSerial() + 1;
|
||||
} else {
|
||||
UploadRangeNow(resource, bufferObject, start, end);
|
||||
}
|
||||
@@ -2304,6 +2322,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
MGL_SERVER_STAGED_DROP(*resource);
|
||||
resource->hostBytes = nullptr;
|
||||
}
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-C: whatever a shader wrote belonged to the store this call replaces.
|
||||
resource->serverGpuWritten = false;
|
||||
#endif
|
||||
}
|
||||
if (!resource) return; // lazy: the ensure path full-uploads on creation
|
||||
if (resource->immutableStorage) {
|
||||
@@ -3185,6 +3207,31 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
const Uint16 uploadTarget = MG_Pipe::MGPipeSubDataUploadTargetOf(record.Target);
|
||||
const IntVec3 extent = MG_Remote::Server::StagedTextureUploadExtent(stored->Desc, record);
|
||||
const SizeT runBytes = static_cast<SizeT>(record.Blob.Size);
|
||||
// P8-E (notes/p8/E.md): THE LEVEL HOLDS A COPY THE CLIENT NEVER SAW
|
||||
// (FollowCopyImageInStagedStore). The run is the client's shadow, stale everywhere it
|
||||
// did not write, so only the texels it names land - its regions, or its union box
|
||||
// when it carries none (D-D3's "the box is the whole story"). A run the store cannot
|
||||
// place that way is adopted as ever, and the store stops standing for the texture.
|
||||
if (store.LevelHoldsFollowedCopy(key, uploadTarget, record.Level) &&
|
||||
(record.RegionCount == 0 || regions != nullptr)) {
|
||||
Vector<MG_Remote::Server::StagedTextureStore::ClientTexelBox> boxes;
|
||||
if (record.RegionCount == 0) {
|
||||
const auto& box = record.UnionBox;
|
||||
boxes.push_back({box.X, box.Y, box.Z, box.W, box.H, box.D});
|
||||
} else {
|
||||
for (Uint32 i = 0; i < record.RegionCount; ++i) {
|
||||
const auto& region = regions[i];
|
||||
boxes.push_back({region.X, region.Y, region.Z, region.W, region.H, region.D});
|
||||
}
|
||||
}
|
||||
const Uint64 imageOffset = record.RegionCount == 0
|
||||
? 0 : MG_Remote::Server::StagedTextureRunImageOffset(record, regions);
|
||||
if (store.AdoptClientBoxes(key, uploadTarget, record.Level, extent, imageOffset, bytes, runBytes,
|
||||
boxes.data(), boxes.size())) {
|
||||
return;
|
||||
}
|
||||
store.MarkDriverWritten(key);
|
||||
}
|
||||
// RegionCount == 0 IS the whole-level spelling - "the run is the level shadow",
|
||||
// beginning at the level's first byte - so it is adopted with the spelling that
|
||||
// replaces the level; every other record names a RUN of the level by its own box.
|
||||
@@ -3554,6 +3601,81 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
const auto* record = ResourceRecordOf(res);
|
||||
return record != nullptr && record->Desc.HasDefinedContent != 0;
|
||||
}
|
||||
|
||||
// P8-C. The declaration says what; this says in what order, and it is Ops_H_Readback's
|
||||
// order because it is the same question asked by the server of itself instead of by the
|
||||
// client: (1) queued uploads land in the GL store first - reading back past them would
|
||||
// revert them in the copy - under the same staged-coverage assertion that drain carries;
|
||||
// (2) queued resident writes land (GPU-ordered, behind every command already recorded);
|
||||
// (3) the whole store is read back into the staged copy, which leaves its coverage whole
|
||||
// and so also answers RequireStagedCoverage for an orphaned store's first copy; (4) the
|
||||
// serial stamp and the epoch bump, as Ops_H_ReadbackTracked does them.
|
||||
const Uint8* SplitHostBytesForCpuRead(GLESBufferResource& resource, MG_Pipe::MGPipeHandle res,
|
||||
const char* site) {
|
||||
Bool residentWritesQueued = false;
|
||||
if (resource.externalAhb != nullptr) {
|
||||
const std::lock_guard<std::mutex> lock(resource.pendingMutex);
|
||||
residentWritesQueued = !resource.pendingResidentWrites.empty();
|
||||
}
|
||||
if (!resource.serverGpuWritten && !residentWritesQueued) return SplitHostBytes(resource);
|
||||
// The marks are made only under a transport, where the staged store COPIES; the guard
|
||||
// keeps a monolith store (which keeps the caller's pointer) from adopting a mapping.
|
||||
if (!ServerStaged().CopiesIntoServerStorage()) return SplitHostBytes(resource);
|
||||
if (!CanTouchGLNow() || resource.id == 0 || !resource.storageInitialized ||
|
||||
resource.pendingRespecify || resource.contextGeneration != g_bufferContextGeneration ||
|
||||
!g_GLESFuncs.glMapBufferRange || !g_GLESFuncs.glUnmapBuffer) {
|
||||
MGLOG_E_ONCE("%s: buffer {%u, %u} was written on the GPU but its GL store cannot be read "
|
||||
"back here, so the CPU reads the staged copy as it is",
|
||||
site, res.Slot, res.Gen);
|
||||
return SplitHostBytes(resource);
|
||||
}
|
||||
if (resource.externalAhb != nullptr) {
|
||||
// T0: the copy IS this server's coherent map of the client's pages. Landing the
|
||||
// queued writes and finishing makes them, and every shader write already queued,
|
||||
// visible through it - Ops_H_Readback's persistent-map arm, for the same reason.
|
||||
DrainResidentWritesNow(resource);
|
||||
if (g_GLESFuncs.glFinish) g_GLESFuncs.glFinish();
|
||||
resource.serverGpuWritten = false;
|
||||
return SplitHostBytes(resource);
|
||||
}
|
||||
const SizeT width = ResourceWidthOf(res);
|
||||
const SizeT size = std::min(width, resource.storageSize);
|
||||
if (size == 0) return SplitHostBytes(resource);
|
||||
MGL_SERVER_STAGED_REQUIRE_PENDING(resource, resource.hostBytes, width, "gpu_written_refresh_flush_pending");
|
||||
FlushPendingRangesFrom(resource, resource.hostBytes, width);
|
||||
DrainResidentWritesNow(resource);
|
||||
BindBufferId(TempBufferTarget, resource.id);
|
||||
void* mapped = g_GLESFuncs.glMapBufferRange(TempBufferTarget, 0, static_cast<GLsizeiptr>(size),
|
||||
GL_MAP_READ_BIT);
|
||||
if (mapped == nullptr) {
|
||||
MGLOG_E_ONCE("%s: glMapBufferRange(read) failed for GPU-written buffer %u; the CPU reads the "
|
||||
"staged copy as it is",
|
||||
site, resource.id);
|
||||
return SplitHostBytes(resource);
|
||||
}
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(resource.pendingMutex);
|
||||
resource.hostBytes = MGL_SERVER_STAGED_ADOPT(resource, width, mapped, 0, size);
|
||||
}
|
||||
g_GLESFuncs.glUnmapBuffer(TempBufferTarget);
|
||||
resource.serverGpuWritten = false;
|
||||
resource.syncedChangeSerial = ResourceSerialOf(res);
|
||||
BumpBufferMutationEpoch();
|
||||
MGLOG_D("%s: refreshed the staged copy of GPU-written buffer {%u, %u} (%zu bytes)", site, res.Slot,
|
||||
res.Gen, size);
|
||||
return resource.hostBytes;
|
||||
}
|
||||
|
||||
void StageServerWrittenRange(GLESBufferResource& resource, MG_Pipe::MGPipeHandle res, const void* bytes,
|
||||
SizeT offset, SizeT size) {
|
||||
if (bytes == nullptr || size == 0 || resource.externalAhb != nullptr) return;
|
||||
// Only a COPYING store may take bytes that die with a mapping: the monolith one keeps
|
||||
// the caller's pointer (StagedShadow.h), which here would dangle after the unmap.
|
||||
if (!ServerStaged().CopiesIntoServerStorage()) return;
|
||||
// Under pendingMutex, as every other hostBytes store is (M-2).
|
||||
const std::lock_guard<std::mutex> lock(resource.pendingMutex);
|
||||
resource.hostBytes = MGL_SERVER_STAGED_ADOPT(resource, ResourceWidthOf(res), bytes, offset, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
MG_Pipe::MGPipeHandle HandleOfBuffer(const MG_State::GLState::BufferObject* bufferObject) {
|
||||
@@ -6589,10 +6711,12 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// path, and a persistently mapped source is excluded separately below (the memo
|
||||
// never trusts one, so those re-read every draw through the coherent map).
|
||||
//
|
||||
// P8 closes it by moving the pull to the client, where the object lives. Until then
|
||||
// this is the ONE behavioural difference between the two arms under the default
|
||||
// mask, and it is written here rather than only in a document so that the next
|
||||
// reader of this function finds it at the site.
|
||||
// P8-C CLOSES IT UNDER A TRANSPORT, on the server rather than by moving the pull to the
|
||||
// client: a source a shader wrote on this side is read back from this server's own GL
|
||||
// buffer (SplitHostBytesForCpuRead), and that write also voids the memo below, whose
|
||||
// serial a GPU write never moves. The MONOLITH arm of this function keeps the
|
||||
// deviation (its hostBytes is the client's shadow and its mark is the frontend
|
||||
// object's); that half is dev's (ID-P8-3).
|
||||
// WHERE THE BYTES ARE, and it is not one fixed place: an ADOPTED store has no client
|
||||
// shadow left at all (PipeResource::AdoptPersistentMap clears and shrinks it), so
|
||||
// the coherent map IS the source of truth - which is exactly the case the memo
|
||||
@@ -6601,6 +6725,15 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// recorded shadow base for such a resource read freed memory; hostBytes is nulled
|
||||
// at adoption for the same reason, so the fallback below is a null and a refusal
|
||||
// rather than a stale read.
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
const Bool sourceGpuWritten =
|
||||
MG_Config::Transport != MG_Config::TransportMode::Monolith && resource->serverGpuWritten;
|
||||
if (sourceGpuWritten) {
|
||||
BufferImpl::SplitHostBytesForCpuRead(*resource, binding.Res, "fp64_vertex_narrowing");
|
||||
}
|
||||
#else
|
||||
constexpr Bool sourceGpuWritten = false;
|
||||
#endif
|
||||
const Uint8* const sourceBase =
|
||||
(resource->persistentMapped && resource->persistentPtr != nullptr)
|
||||
? static_cast<const Uint8*>(resource->persistentPtr)
|
||||
@@ -6637,7 +6770,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// still never trusted - it is written through the pointer with no call at all, so
|
||||
// no serial on either side can prove the converted copy is current.
|
||||
const Bool memoHit = stream.valid && convertedBufferId != 0 && !resource->persistentMapped &&
|
||||
stream.sourceHandle == binding.Res &&
|
||||
!sourceGpuWritten && stream.sourceHandle == binding.Res &&
|
||||
stream.sourceChangeSerial == sourceSerial &&
|
||||
stream.sourceOffset == static_cast<SizeT>(attrib.Offset) &&
|
||||
stream.sourceStride == sourceStride &&
|
||||
@@ -10873,7 +11006,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
return slot->get();
|
||||
}
|
||||
|
||||
void NoteDriverSideTextureWriteByHandle(MG_Pipe::MGPipeHandle res) {
|
||||
void NoteDriverSideTextureWriteByHandle(MG_Pipe::MGPipeHandle res, Bool storeFollowsTheWrite) {
|
||||
// The storage owner's handle, one hop per view like the frontend walk above (the
|
||||
// client composes a view of a view onto its root, so one hop is the real shape).
|
||||
MG_Pipe::MGPipeHandle storage = res;
|
||||
@@ -10883,6 +11016,55 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
storage = record->Desc.ViewOf;
|
||||
}
|
||||
if (auto* twin = ResolveTextureTwin(storage)) twin->NoteDriverSideWrite();
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-E: the staged store stops standing for this texture's content (a no-op on a
|
||||
// monolith arm, where the store does not copy).
|
||||
if (!storeFollowsTheWrite && !MG_Pipe::MGPipeHandleIsNull(storage)) {
|
||||
MG_Remote::Server::ServerStagedTexture().MarkDriverWritten(
|
||||
MG_Remote::Server::StagedTextureStore::KeyForHandle(storage));
|
||||
}
|
||||
#else
|
||||
(void)storeFollowsTheWrite;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
Bool FollowCopyImageInStagedStore(MG_Pipe::MGPipeHandle source, Uint32 sourceLevel, const IntVec3& sourceOrigin,
|
||||
MG_Pipe::MGPipeHandle destination, Uint32 destinationLevel,
|
||||
const IntVec3& destinationOrigin, const IntVec3& size) {
|
||||
auto& store = MG_Remote::Server::ServerStagedTexture();
|
||||
if (!store.CopiesIntoServerStorage()) return false;
|
||||
// The store's level key for an endpoint copy-image addresses as ONE image with its
|
||||
// layers on z: exactly one upload target (not a cube map, whose faces are six store
|
||||
// levels) and not a 1D array (the store keeps its layers as rows). A view's own levels
|
||||
// are byteless, so FollowCopy answers false for it by itself.
|
||||
const auto storeTarget = [](MG_Pipe::MGPipeHandle handle, Uint16& target) {
|
||||
const auto* record = PipeTextureRecordForHandle(handle);
|
||||
if (record == nullptr ||
|
||||
record->Desc.Target == static_cast<Uint8>(MG_Pipe::MGPipeResourceTarget::Tex1DArray)) {
|
||||
return false;
|
||||
}
|
||||
const auto& targets = BufferImpl::StagedUploadTargetsForPipeTarget(record->Desc.Target);
|
||||
if (targets.size() != 1) return false;
|
||||
target = static_cast<Uint16>(targets[0]);
|
||||
return true;
|
||||
};
|
||||
Uint16 sourceTarget = 0, destinationTarget = 0;
|
||||
if (!storeTarget(source, sourceTarget) || !storeTarget(destination, destinationTarget)) return false;
|
||||
// ONE FORMAT BOTH ENDS. Copy-image moves the GL texel bits; the store holds each
|
||||
// format's canonical shadow, which for most formats IS those bits and for some is not
|
||||
// (the 16-bit packed formats are kept as UNorm8, RGB10 / RGB12 as UNorm16). Between two
|
||||
// levels of one format the canonical move and the GL move agree whatever the format;
|
||||
// across two compatible formats they need not, so that copy is not followed.
|
||||
if (PipeTextureRecordForHandle(source)->Desc.InternalFormat !=
|
||||
PipeTextureRecordForHandle(destination)->Desc.InternalFormat) {
|
||||
return false;
|
||||
}
|
||||
return store.FollowCopy(MG_Remote::Server::StagedTextureStore::KeyForHandle(source), sourceTarget,
|
||||
static_cast<Uint16>(sourceLevel), sourceOrigin,
|
||||
MG_Remote::Server::StagedTextureStore::KeyForHandle(destination),
|
||||
destinationTarget, static_cast<Uint16>(destinationLevel), destinationOrigin,
|
||||
size);
|
||||
}
|
||||
#endif
|
||||
} // namespace TextureImpl
|
||||
|
||||
@@ -1004,6 +1004,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// (the UBO binding walk) skip the probe while their pre-pass epoch read
|
||||
// matches, exactly like the per-VAO memo stamps.
|
||||
Uint64 drawCleanEpoch = 0;
|
||||
// Frame serial whose completion retires the last glCopyBufferSubData the upload
|
||||
// ring staged INTO this store (the flush ladder's ring tier: FlushPendingRangesNow
|
||||
// on the pull arm, FlushPendingRangesFrom on the push arm); 0 = none. Until it
|
||||
// retires, both keep every partial range off the range-invalidating map: on
|
||||
// Adreno 830 that map, on a store with a queued copy, loses the copy (see
|
||||
// FlushPendingRangesNow and InvalidateFlushAccessFor). Draw thread only, like the
|
||||
// flush.
|
||||
Uint64 ringCopyRetireSerial = 0;
|
||||
// Zero-copy coherent persistent map (EXT_buffer_storage): the GL store is
|
||||
// immutable, persistently+coherently mapped, and persistentPtr is what the app
|
||||
// (and the frontend PipeResource) write into directly. While set, draw-time
|
||||
@@ -1051,6 +1059,12 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// store's last use has signalled (RetireT0Import). Survives an ES context loss:
|
||||
// the next ensure re-imports it. Null for every store T0 did not adopt.
|
||||
void* externalAhb = nullptr;
|
||||
// P8-C: A SHADER WROTE THIS STORE ON THIS SIDE since the R-11 staged copy (or, for
|
||||
// T0, the coherent map) was last known to match it - set by the draw / dispatch that
|
||||
// bound it writable (storage block, atomic counter, writable buffer image), cleared
|
||||
// by SplitHostBytesForCpuRead's refresh and by a respecify. Only the server's own
|
||||
// CPU readers consult it; the client keeps its own set (GpuWritePending.h).
|
||||
Bool serverGpuWritten = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -1123,6 +1137,24 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
return resource.externalAhb != nullptr ? static_cast<const Uint8*>(resource.persistentPtr) : nullptr;
|
||||
}
|
||||
|
||||
// P8-C: THE SAME BYTES, MADE CURRENT FIRST - for a reader that CONSUMES them (the restart
|
||||
// rewrite, the multi-draw rebase, the *IndirectCount count, an indirect command's
|
||||
// CPU-fed fields, the XFB scatter's pre-capture bytes). SplitHostBytes above is only
|
||||
// "what uploads staged": a store a shader wrote on this side (serverGpuWritten) is
|
||||
// refreshed from this server's own GL buffer - queued uploads flushed into it first,
|
||||
// then the whole store read back into the staged copy, which also gives an orphaned
|
||||
// store its first copy - and a T0 store lands its queued resident writes and finishes
|
||||
// before its coherent map is read. A clean staged store costs one flag test.
|
||||
// `res` names the record whose descriptor width the copy takes; `site` names the
|
||||
// reader in the one-time diagnostic when the refresh cannot run.
|
||||
const Uint8* SplitHostBytesForCpuRead(GLESBufferResource& resource, MG_Pipe::MGPipeHandle res,
|
||||
const char* site);
|
||||
// P8-C: bytes the SERVER itself put into a store's GL buffer and already holds on the CPU
|
||||
// (an XFB capture it mapped for the client's writeback, a scatter it composed) go into
|
||||
// the staged copy as well, so no refresh is owed for them. A T0 store has no copy.
|
||||
void StageServerWrittenRange(GLESBufferResource& resource, MG_Pipe::MGPipeHandle res, const void* bytes,
|
||||
SizeT offset, SizeT size);
|
||||
|
||||
// M-3's WHOLE-STORE predicate, and the GUARD every caller of RequireStagedCoverage over
|
||||
// a whole-store read has to carry: true when the application DECLARED the store's
|
||||
// content (glBufferData(size, data)), so a coverage gap is a missing record; false when
|
||||
@@ -1162,10 +1194,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// ("do not take tier 1"), which drops the range onto the staging ring and costs a copy
|
||||
// rather than a corruption.
|
||||
//
|
||||
// `ringCopyInFlight`: the store still has an upload-ring glCopyBufferSubData queued that the
|
||||
// GPU may not have run (GLESBufferResource::ringCopyRetireSerial not yet retired).
|
||||
//
|
||||
// Returns the glMapBufferRange access bits, or 0 when tier 1 must not be taken.
|
||||
inline constexpr SizeT kEsprytInvalidateRangeMinBytes = 128u * 1024u;
|
||||
constexpr GLbitfield InvalidateFlushAccessFor(SizeT queuedStart, SizeT queuedEnd, SizeT mapStart,
|
||||
SizeT mapEnd, SizeT limit, SizeT storageSize) {
|
||||
SizeT mapEnd, SizeT limit, SizeT storageSize,
|
||||
Bool ringCopyInFlight) {
|
||||
if (mapEnd <= mapStart) return 0u;
|
||||
// THE WIDENING REFUSAL. Not >=, not "covers": exactly, in both directions. A map
|
||||
// narrower than the queued range leaves bytes unwritten inside a range it has just
|
||||
@@ -1177,6 +1213,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// page-substitution fast path needs a page-coverable range to engage, and below it
|
||||
// the driver falls back to waiting out the WAR hazard on the CPU.
|
||||
if (!wholeBuffer && size < kEsprytInvalidateRangeMinBytes) return 0u;
|
||||
// A partial range-invalidating map must not overtake a ring copy into this store the GPU
|
||||
// has not run yet. Adreno 830 answers such a map on a store with a copy still queued by
|
||||
// losing the copy (dev f973008c, the pull arm's FlushPendingRangesNow: create-instancing
|
||||
// drew whole Embeddium terrain sections empty, SSIM 0.870). The range goes to the ring
|
||||
// instead, GPU-ordered behind the copies. The whole-buffer orphan-map is exempt: it
|
||||
// rewrites every byte from the shadow the queued copies were taken from.
|
||||
if (!wholeBuffer && ringCopyInFlight) return 0u;
|
||||
return GL_MAP_WRITE_BIT |
|
||||
(wholeBuffer ? GL_MAP_INVALIDATE_BUFFER_BIT : GL_MAP_INVALIDATE_RANGE_BIT);
|
||||
}
|
||||
@@ -2321,7 +2364,24 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// VerbCopyTexDst, a copy-image endpoint): the twin the handle's record names is marked, or
|
||||
// its storage owner's (Desc.ViewOf) for a view. Nothing on the apply thread reads a
|
||||
// frontend object for it.
|
||||
void NoteDriverSideTextureWriteByHandle(MG_Pipe::MGPipeHandle texture);
|
||||
//
|
||||
// P8-E: under a transport the same storage owner's staged store is marked driver-written
|
||||
// too (StagedTextureStore::MarkDriverWritten), so a refused readback does not answer from
|
||||
// bytes the driver has since overwritten - unless `storeFollowsTheWrite`, which only
|
||||
// glCopyImageSubData passes: it tries FollowCopyImageInStagedStore first and marks the store
|
||||
// itself when that fails.
|
||||
void NoteDriverSideTextureWriteByHandle(MG_Pipe::MGPipeHandle texture, Bool storeFollowsTheWrite = false);
|
||||
#endif
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-E (notes/p8/E.md): make glCopyImageSubData's texel-block move in the server's staged
|
||||
// store too (StagedTextureStore::FollowCopy), so the destination level's bytes stay its
|
||||
// content. Box in each image's own texel grid. False when the store cannot follow: a cube
|
||||
// map or 1D array endpoint (copy-image puts faces / layers on z, the store does not), a view,
|
||||
// two different internal formats, a level whose bytes did not all cross, a source the
|
||||
// driver has written, or a monolith arm.
|
||||
Bool FollowCopyImageInStagedStore(MG_Pipe::MGPipeHandle source, Uint32 sourceLevel, const IntVec3& sourceOrigin,
|
||||
MG_Pipe::MGPipeHandle destination, Uint32 destinationLevel,
|
||||
const IntVec3& destinationOrigin, const IntVec3& size);
|
||||
#endif
|
||||
// Brings every texture the next draw reads - the touched units' bindings and the draw
|
||||
// FBO's texture attachments - onto the backend, through the two borrowed-pair memos
|
||||
@@ -3079,6 +3139,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
// Same for gl_BaseVertex: only a program that reads it pays for the per-draw
|
||||
// uniform write, and only such a program needs the reset after one.
|
||||
Bool ReadsBaseVertex() const { return m_baseVertexUniformLocation >= 0; }
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-C: same for the gl_BaseInstance uniform - which an indirect draw feeds from the
|
||||
// command on the CPU only when the mg_IndirectParams view is absent.
|
||||
Bool ReadsBaseInstance() const { return m_baseInstanceUniformLocation >= 0; }
|
||||
#endif
|
||||
// Which viewport indices the next draw's fragments may keep, one bit each. Written
|
||||
// once per replay pass; see ForEachViewportRoutingPass.
|
||||
void SetViewportPassMask(Uint32 indexMask) const;
|
||||
|
||||
@@ -191,15 +191,16 @@ namespace MobileGL::MG_Backend::DirectGLES::MultiDrawImpl {
|
||||
if (question == IndexBufferQuestion::Presence) return view;
|
||||
|
||||
if (question == IndexBufferQuestion::HostBytes) {
|
||||
// No Sync* pair here and none is missing: on this side the applier has
|
||||
// already consumed the persistent-map blocks and the shader writebacks for
|
||||
// this resource before the draw verb replayed, so the server's staged shadow
|
||||
// IS the synced copy. That is also why this arm cannot be expressed as "find
|
||||
// the object and run the monolith body".
|
||||
// The applier has already consumed the persistent-map blocks for this
|
||||
// resource before the draw verb replayed; the one Sync* this arm owes is the
|
||||
// monolith's SyncGpuWrites, and (P8-C) SplitHostBytesForCpuRead is it: a store
|
||||
// a shader wrote on this side is read back from this server's own GL buffer,
|
||||
// because no writeback ever reaches the server's staged copy. That is also why
|
||||
// this arm cannot be expressed as "find the object and run the monolith body".
|
||||
auto* resource = BufferImpl::FindBufferResourceForHandle(res);
|
||||
if (resource == nullptr) RefuseMissingIndexBufferRecord(entry, res, "backend resource");
|
||||
view.Size = BufferImpl::ResourceWidthForHandle(res);
|
||||
view.HostBytes = BufferImpl::SplitHostBytes(*resource);
|
||||
view.HostBytes = BufferImpl::SplitHostBytesForCpuRead(*resource, res, "multidraw_index_rebase");
|
||||
if (view.HostBytes != nullptr && IndexBufferRecordHasDefinedContent(st, res)) {
|
||||
BufferImpl::RequireStagedCoverage(*resource, view.HostBytes, 0, view.Size,
|
||||
"multidraw_index_rebase");
|
||||
|
||||
@@ -320,6 +320,105 @@
|
||||
return width == extent.x() && height == extent.y() && (!layered || depth == extent.z());
|
||||
}
|
||||
|
||||
// P8-E (notes/p8/E.md). MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT=<w>x<h>, READ BY THE SERVER:
|
||||
// a colour level of exactly that extent is treated as one the driver refused to attach - what an
|
||||
// Adreno does for RGB16 and the 16-bit SNORM formats, and what no host driver can be made to do.
|
||||
// Scoped by the extent so the tcp lane's shared supervisor can carry it for the whole lane: only
|
||||
// the scenario that builds that extent (CopyImageStoreReadbackScenario) ever meets it.
|
||||
static Bool WireTextureReadbackRefusedForTesting(const IntVec3& extent) {
|
||||
static const IntVec3 s_refused = [] {
|
||||
const char* value = std::getenv("MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT");
|
||||
if (value == nullptr) return IntVec3{0, 0, 0};
|
||||
char* end = nullptr;
|
||||
const long width = std::strtol(value, &end, 10);
|
||||
if (end == value || *end != 'x') return IntVec3{0, 0, 0};
|
||||
const long height = std::strtol(end + 1, nullptr, 10);
|
||||
if (width <= 0 || height <= 0) return IntVec3{0, 0, 0};
|
||||
return IntVec3{static_cast<Int>(width), static_cast<Int>(height), 1};
|
||||
}();
|
||||
return s_refused.x() > 0 && extent == s_refused;
|
||||
}
|
||||
|
||||
// P8-E: THE STORE ROUTE, for a level the driver refused to read back. The server's staged store
|
||||
// is the only CPU copy of the level on this side, and it answers only while its bytes ARE the
|
||||
// level: every byte crossed (IsCovered), at the extent asked for, and the texture was never
|
||||
// written by the driver except by copies the store followed (!IsDriverWritten - see
|
||||
// StagedTextureStore's P8-E block and FollowCopyImageInStagedStore). The conversion is
|
||||
// GetTexImageViaShadowConversion's, into tight rows: a packed format read with its own type
|
||||
// takes the stored words verbatim, everything else decodes to wide RGBA and converts row by row.
|
||||
// Anything else DECLINES BY NAME: the reply is an error, and the client's
|
||||
// Fatal{ReplyError, "ReadPixels"} ends the session instead of handing back bytes the driver has
|
||||
// since overwritten.
|
||||
static Bool ReadWireLevelFromStagedStore(MG_Pipe::MGPipeHandle res, TextureInternalFormat logicalFormat,
|
||||
TextureUploadTarget uploadTarget, GLint level, const IntVec3& extent,
|
||||
GLenum format, GLenum type, Vector<Uint8>& bytes) {
|
||||
auto& store = MG_Remote::Server::ServerStagedTexture();
|
||||
const Uint64 key = MG_Remote::Server::StagedTextureStore::KeyForHandle(res);
|
||||
const auto target = static_cast<Uint16>(uploadTarget);
|
||||
const auto mip = static_cast<Uint16>(level);
|
||||
ReadbackChannelMapping mapping{};
|
||||
const SizeT pixelBytes = GetReadbackChannelMapping(format, mapping) ? GetReadbackDstPixelSize(mapping, type) : 0;
|
||||
const SizeT texels = static_cast<SizeT>(std::max(extent.x(), 0)) * static_cast<SizeT>(std::max(extent.y(), 0)) *
|
||||
static_cast<SizeT>(std::max(extent.z(), 0));
|
||||
const char* declined = nullptr;
|
||||
if (!store.CopiesIntoServerStorage()) {
|
||||
declined = "this arm keeps no staged store";
|
||||
} else if (store.IsDriverWritten(key)) {
|
||||
declined = "the driver has written the texture since its bytes crossed";
|
||||
} else if (!store.IsCovered(key, target, mip)) {
|
||||
declined = "not every byte of the level crossed";
|
||||
} else if (store.LevelExtentOrUndefined(key, target, mip) != extent) {
|
||||
declined = "the staged level is not the extent asked for";
|
||||
} else if (pixelBytes == 0 || texels == 0) {
|
||||
declined = "the format/type pair has no readback mapping";
|
||||
}
|
||||
Vector<Uint8> out;
|
||||
if (declined == nullptr) {
|
||||
const Uint8* staged = store.RequireLevelBytes(key, target, mip, "texture-readback-from-store");
|
||||
if (MG_Util::PixelStoreProcessor::IsRawPackedPixelTransfer(
|
||||
logicalFormat, MG_Util::ConvertGLEnumToTextureInputFormat(format),
|
||||
MG_Util::ConvertGLEnumToTexturePixelDataType(type))) {
|
||||
if (store.LevelByteSize(key, target, mip) != texels * pixelBytes) {
|
||||
declined = "the staged words are not the client's word size";
|
||||
} else {
|
||||
out.assign(staged, staged + texels * pixelBytes);
|
||||
}
|
||||
} else {
|
||||
Vector<Uint8> wide;
|
||||
Bool isInteger = false;
|
||||
Bool isSigned = false;
|
||||
if (!MG_Util::PixelStoreProcessor::DecodeShadowDataToWideRGBA(logicalFormat, staged, texels, wide,
|
||||
isInteger, isSigned)) {
|
||||
declined = "the staged format has no wide decoding";
|
||||
} else if (mapping.isInteger != isInteger) {
|
||||
declined = "an integer read of a normalized level, or the reverse";
|
||||
} else {
|
||||
const GLenum wideType = isInteger ? (isSigned ? GL_INT : GL_UNSIGNED_INT) : GL_FLOAT;
|
||||
const SizeT rowTexels = static_cast<SizeT>(extent.x());
|
||||
const SizeT rows = texels / rowTexels;
|
||||
const SizeT wideRowBytes = rowTexels * 4 * GetReadbackComponentSize(wideType);
|
||||
out.resize(texels * pixelBytes);
|
||||
for (SizeT row = 0; row < rows; ++row) {
|
||||
ReadbackImpl::ConvertWideReadbackRow(wide.data() + row * wideRowBytes,
|
||||
out.data() + row * rowTexels * pixelBytes, rowTexels,
|
||||
wideType, mapping, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (declined != nullptr) {
|
||||
MGLOG_E_ONCE("MGPipe: texture {%u,%u} level %d: the driver refused the readback and the staged store "
|
||||
"cannot answer it (%s) - DECLINED (texture-readback-store-declined)",
|
||||
res.Slot, res.Gen, level, declined);
|
||||
return false;
|
||||
}
|
||||
MGLOG_W_ONCE("MGPipe: texture {%u,%u} level %d: the driver refused the readback (internal format %u); "
|
||||
"answered from the server's staged store (texture-readback-from-store)",
|
||||
res.Slot, res.Gen, level, static_cast<unsigned>(logicalFormat));
|
||||
bytes = Move(out);
|
||||
return true;
|
||||
}
|
||||
|
||||
Bool ReadTextureImageWire(const MG_Pipe::MGPReadbackInfo& info, Vector<Uint8>& bytes) {
|
||||
const auto* record = PipeTextureRecordForHandle(info.Res);
|
||||
if (!record) return false;
|
||||
@@ -333,15 +432,29 @@
|
||||
const Bool wholeCube = info.Target == GL_TEXTURE_CUBE_MAP;
|
||||
const IntVec3 extent{static_cast<Int>(info.Box.W), static_cast<Int>(info.Box.H),
|
||||
wholeCube ? 1 : static_cast<Int>(info.Box.D)};
|
||||
const auto logicalFormat = static_cast<TextureInternalFormat>(record->Desc.InternalFormat);
|
||||
// The R32UI word leg never goes through a framebuffer, so the knob leaves it alone (it is
|
||||
// ReadTextureLevelTight's first choice for exactly these reads).
|
||||
const Bool packedWordRead =
|
||||
!twin->RequiresImageBindableStorage() &&
|
||||
MG_Util::PixelStoreProcessor::IsRawPackedPixelTransfer(
|
||||
logicalFormat, MG_Util::ConvertGLEnumToTextureInputFormat(info.Format),
|
||||
MG_Util::ConvertGLEnumToTexturePixelDataType(info.Type)) &&
|
||||
MG_Util::GetInputBytesPerPixel(MG_Util::ConvertGLEnumToTextureInputFormat(info.Format),
|
||||
MG_Util::ConvertGLEnumToTexturePixelDataType(info.Type)) == sizeof(Uint32);
|
||||
const Bool refusedForTesting = !packedWordRead && WireTextureReadbackRefusedForTesting(extent);
|
||||
Vector<Uint8> result;
|
||||
for (Int face = 0; face < (wholeCube ? 6 : 1); ++face) {
|
||||
const auto uploadTarget = wholeCube
|
||||
? static_cast<TextureUploadTarget>(static_cast<Int>(TextureUploadTarget::CubeMapPositiveX) + face)
|
||||
: MG_Util::ConvertGLEnumToTextureUploadTarget(info.Target);
|
||||
Vector<Uint8> slice;
|
||||
if (!ReadTextureLevelTight(twin->GetBackendTextureId(), target, uploadTarget,
|
||||
static_cast<TextureInternalFormat>(record->Desc.InternalFormat), info.Level, extent,
|
||||
twin->RequiresImageBindableStorage(), info.Format, info.Type, slice)) return false;
|
||||
if (refusedForTesting ||
|
||||
!ReadTextureLevelTight(twin->GetBackendTextureId(), target, uploadTarget, logicalFormat, info.Level,
|
||||
extent, twin->RequiresImageBindableStorage(), info.Format, info.Type, slice)) {
|
||||
if (!ReadWireLevelFromStagedStore(info.Res, logicalFormat, uploadTarget, info.Level, extent,
|
||||
info.Format, info.Type, slice)) return false;
|
||||
}
|
||||
result.insert(result.end(), slice.begin(), slice.end());
|
||||
}
|
||||
bytes = Move(result);
|
||||
|
||||
@@ -370,16 +370,36 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
#endif // !MOBILEGL_BUILD_DISAGGREGATED
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// The verb's handles identify server stores. Readback orders GPU-produced
|
||||
// command/count bytes before CPU tier expansion; never inspect a client binding.
|
||||
// The verb's handles identify server stores; never inspect a client binding.
|
||||
//
|
||||
// P8-D: THE GPU READS THE WORDS (VulkanRenderer::DrawWireIndirectNative, WireDraw.inc), as
|
||||
// on the monolith arm. The CPU expansion below is kept for the one shape the monolith arm
|
||||
// also expands - a COUNT form the device cannot issue natively (no VK_KHR_draw_indirect_count,
|
||||
// or maxdrawcount > 1 without multiDrawIndirect: VulkanRenderer.cpp's
|
||||
// MultiDrawElementsIndirectCount) - where ReadWireBuffer orders GPU-produced command/count
|
||||
// bytes before the expansion.
|
||||
void DrawWireIndirect(GLenum mode, GLenum type, const void* indirect, GLsizei drawcount,
|
||||
GLsizei stride, Bool indexed, Bool counted = false, GLintptr countOffset = 0) {
|
||||
if (drawcount <= 0) return;
|
||||
if (drawcount <= 0 || countOffset < 0) return;
|
||||
if (pVulkanRenderer->DrawWireIndirectNative(mode, type, reinterpret_cast<Uint64>(indirect), drawcount,
|
||||
stride, indexed, counted, static_cast<Uint64>(countOffset)))
|
||||
return;
|
||||
auto& buffers = pVulkanRenderer->GetWireBufferManager();
|
||||
const auto& state = MG_Pipe::MGPipeApplier();
|
||||
// P8-D: this call reads its words on the CPU; the waits those reads take are its own.
|
||||
struct ExpansionCount {
|
||||
VkBufferManager& buffers;
|
||||
const Uint64 waitsBefore = buffers.GetWireHostWaitCount();
|
||||
~ExpansionCount() {
|
||||
if (!MG_Util::PipeStats::Enabled()) return;
|
||||
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::WireIndirectCpuExpansions, 1);
|
||||
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::WireHostWaitsIndirect,
|
||||
buffers.GetWireHostWaitCount() - waitsBefore);
|
||||
}
|
||||
} expansionCount{buffers};
|
||||
if (counted) {
|
||||
Uint32 count = 0;
|
||||
if (countOffset < 0 || !buffers.ReadWireBuffer(state.VerbIndirectParameterBuffer,
|
||||
if (!buffers.ReadWireBuffer(state.VerbIndirectParameterBuffer,
|
||||
static_cast<Uint64>(countOffset), sizeof(count), &count)) return;
|
||||
drawcount = static_cast<GLsizei>(std::min<Uint32>(count, static_cast<Uint32>(drawcount)));
|
||||
if (!drawcount) return;
|
||||
@@ -917,12 +937,12 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
|
||||
void DispatchComputeIndirect(GLintptr indirect) {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-SV: THE GPU READS THE GROUP COUNTS on the wire arm too - VulkanRenderer's
|
||||
// DispatchComputeIndirect takes its transport branch into DispatchWireComputeIndirect
|
||||
// (WireDraw.inc), which issues vkCmdDispatchIndirect from the verb's store. The CPU read
|
||||
// that was here (ReadWireBuffer, a whole-GPU wait once a shader had written the store) is gone.
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
Uint32 groups[3]{};
|
||||
if (indirect >= 0 && pVulkanRenderer->GetWireBufferManager().ReadWireBuffer(
|
||||
MG_Pipe::MGPipeApplier().VerbDispatchIndirectBuffer,
|
||||
static_cast<Uint64>(indirect), sizeof(groups), groups))
|
||||
pVulkanRenderer->DispatchCompute(groups[0], groups[1], groups[2]);
|
||||
pVulkanRenderer->DispatchComputeIndirect(indirect);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2786,11 +2786,11 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
const auto& bufferObject = bindingPoint.GetBoundObject();
|
||||
static thread_local Vector<Uint8> paddedUbo;
|
||||
if (bufferObject == nullptr) {
|
||||
// A block the program declares at a point with nothing bound - e.g. its buffer was
|
||||
// deleted while bound, which unbinds it (DeletedBoundBufferScenario). GL leaves what
|
||||
// the shader READS undefined and raises no error; this used to dereference the null
|
||||
// object. The wire arm already answers it with a zeroed block
|
||||
// (ResolveWireUniformBufferPayload), so this one does too.
|
||||
// A block the program declares at a point with nothing bound - never bound, or its
|
||||
// buffer was deleted while bound, which unbinds it (UnboundUniformBlockScenario,
|
||||
// DeletedBoundBufferScenario). GL leaves what the shader READS undefined and raises no
|
||||
// error; this used to dereference the null object. Answer it with a zeroed block of the
|
||||
// reflected size, as the wire arm does (ResolveWireUniformBufferPayload).
|
||||
const VkDeviceSize blockSize =
|
||||
static_cast<VkDeviceSize>(program.GetUBOSizeAt(static_cast<Uint32>(blockIndex)));
|
||||
paddedUbo.assign(static_cast<SizeT>(blockSize > 0 ? blockSize : 16), 0);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <android/hardware_buffer.h>
|
||||
#endif
|
||||
#include <Config.h>
|
||||
#include <chrono>
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
@@ -271,6 +272,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
resource->lastUseSerial = 0;
|
||||
resource->lastUseSubmitIndex = 0; // M2 r2: the new store carries no submission yet (B3's stamp is per store)
|
||||
resource->gpuWritesPending = false;
|
||||
resource->indirectReadBarrierPending = false;
|
||||
resource->stagedCoverage.clear();
|
||||
++m_sliceEpochCounter;
|
||||
if (resource->size == 0) return;
|
||||
@@ -315,7 +317,19 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
barrier.dstAccessMask = VK_ACCESS_HOST_READ_BIT | VK_ACCESS_HOST_WRITE_BIT;
|
||||
vkCmdPipelineBarrier(commands, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_HOST_BIT,
|
||||
0, 1, &barrier, 0, nullptr, 0, nullptr);
|
||||
if (!pVulkanRenderer->WaitForSubmitIndex(pVulkanRenderer->GetSyncPointSubmitIndex(), UINT64_MAX, true)) {
|
||||
// P8-D: counted here, past the idle early-out, so `whw` is waits TAKEN, not calls.
|
||||
++m_wireHostWaits;
|
||||
const Bool timed = MG_Util::PipeStats::Enabled();
|
||||
const auto waitStart = timed ? std::chrono::steady_clock::now() : std::chrono::steady_clock::time_point{};
|
||||
const Bool waited =
|
||||
pVulkanRenderer->WaitForSubmitIndex(pVulkanRenderer->GetSyncPointSubmitIndex(), UINT64_MAX, true);
|
||||
if (timed) {
|
||||
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::WireHostWaits, 1);
|
||||
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::WireHostWaitMicros,
|
||||
static_cast<Uint64>(std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::steady_clock::now() - waitStart).count()));
|
||||
}
|
||||
if (!waited) {
|
||||
return false;
|
||||
}
|
||||
resource.lastUseSerial = 0;
|
||||
@@ -594,6 +608,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
resource->lastUseSerial = m_frameSerial;
|
||||
resource->stagedCoverage.clear();
|
||||
resource->gpuWritesPending = true;
|
||||
resource->indirectReadBarrierPending = true;
|
||||
++m_sliceEpochCounter;
|
||||
// The existing client dirty-state protocol accepts one whole-store
|
||||
// notification. The store remains on the GPU and exact later SubData
|
||||
@@ -606,6 +621,13 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
MG_Pipe::gMGPipeCallbacks.OnGpuWritten(res, 1, &range);
|
||||
}
|
||||
|
||||
Bool VkBufferManager::TakeWireIndirectReadBarrier(MG_Pipe::MGPipeHandle res) {
|
||||
auto* resource = FindWireBuffer(res);
|
||||
if (!resource || !resource->indirectReadBarrierPending) return false;
|
||||
resource->indirectReadBarrierPending = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---- P11 B2: T0 - THE CLIENT'S AHardwareBuffer AS A WIRE STORE -----------------------------
|
||||
|
||||
// The serial a T0 store is released under: its last use, or - when no GPU command has named it
|
||||
|
||||
@@ -125,6 +125,14 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
Bool CopyWireBufferSubWordRangeToSlice(MG_Pipe::MGPipeHandle res, Uint64 offset, Uint64 size,
|
||||
Uint32 frameIndex, const BufferSlice& dst, Uint64 dstSkip);
|
||||
void MarkWireBufferGpuWritten(MG_Pipe::MGPipeHandle res, Uint64 offset, Uint64 size);
|
||||
// P8-D: whether a shader write was marked on this store since the last indirect draw
|
||||
// read it natively, clearing the mark. The caller records the INDIRECT_COMMAND_READ
|
||||
// barrier before the draw when this answers true. Transfer writes need no mark: their own
|
||||
// after-barriers already make them visible to MEMORY_READ at ALL_COMMANDS.
|
||||
Bool TakeWireIndirectReadBarrier(MG_Pipe::MGPipeHandle res);
|
||||
// P8-D: every WaitForWireBufferHostAccess that actually waited, over this manager's life -
|
||||
// the attribution base a caller reads before and after its own ReadWireBuffer.
|
||||
Uint64 GetWireHostWaitCount() const { return m_wireHostWaits; }
|
||||
|
||||
// Resource-op entry points. All run on the server apply owner.
|
||||
void CreateWireBuffer(MG_Pipe::MGPipeHandle res, const MG_Pipe::MGPResourceDesc& desc);
|
||||
@@ -257,7 +265,12 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
// P11 B2 (T0): `buffer` is the client's imported AHardwareBuffer. Its readback posts
|
||||
// no bytes (the client reads its own pages once the wait below it is done).
|
||||
Bool imported = false;
|
||||
// P8-D: a shader write was marked (MarkWireBufferGpuWritten) and no indirect draw has
|
||||
// recorded its INDIRECT_COMMAND_READ barrier since (TakeWireIndirectReadBarrier).
|
||||
Bool indirectReadBarrierPending = false;
|
||||
};
|
||||
// P8-D: see GetWireHostWaitCount.
|
||||
Uint64 m_wireHostWaits = 0;
|
||||
static Uint64 WireBufferKey(MG_Pipe::MGPipeHandle res) {
|
||||
return (static_cast<Uint64>(res.Gen) << 32) | res.Slot;
|
||||
}
|
||||
|
||||
@@ -3582,6 +3582,9 @@ void main() {
|
||||
m_device = VK_NULL_HANDLE;
|
||||
}
|
||||
s_vkCmdDrawIndexedIndirectCount = nullptr;
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
s_vkCmdWireDrawIndirectCount = nullptr;
|
||||
#endif
|
||||
s_vkCmdDrawMultiEXT = nullptr;
|
||||
s_vkCmdDrawMultiIndexedEXT = nullptr;
|
||||
|
||||
@@ -7786,6 +7789,15 @@ void main() {
|
||||
|
||||
void VulkanRenderer::DispatchComputeIndirect(GLintptr indirect) {
|
||||
SplitOversizedRecording();
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-SV: the wire arm's own indirect dispatch, DispatchCompute's shape one call over.
|
||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
|
||||
RewindWireDescriptorSetsIfDue();
|
||||
m_textureManager->CollectGarbage();
|
||||
DispatchWireComputeIndirect(indirect);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
m_textureManager->CollectGarbage();
|
||||
auto& frame = m_frameContext.GetCurrent();
|
||||
// See DispatchCompute: the dispatch accessor, not the draw one.
|
||||
@@ -15933,6 +15945,16 @@ void main() {
|
||||
MGLOG_W("VK_KHR_draw_indirect_count enabled but vkCmdDrawIndexedIndirectCount entry point is missing, will continue as if VK_KHR_draw_indirect_count is not supported!");
|
||||
m_drawIndirectCountExtensionEnabled = false;
|
||||
}
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-D: the wire arm's glMultiDrawArraysIndirectCount. Null = that verb reads its count on
|
||||
// the CPU (WireDraw.inc's DrawWireIndirectNative answers false for it).
|
||||
s_vkCmdWireDrawIndirectCount = reinterpret_cast<PFNDrawIndexedIndirectCountFunc>(
|
||||
vkGetDeviceProcAddr(m_device, "vkCmdDrawIndirectCountKHR"));
|
||||
if (s_vkCmdWireDrawIndirectCount == nullptr) {
|
||||
s_vkCmdWireDrawIndirectCount = reinterpret_cast<PFNDrawIndexedIndirectCountFunc>(
|
||||
vkGetDeviceProcAddr(m_device, "vkCmdDrawIndirectCount"));
|
||||
}
|
||||
#endif
|
||||
|
||||
s_vkCmdDrawMultiEXT = nullptr;
|
||||
s_vkCmdDrawMultiIndexedEXT = nullptr;
|
||||
|
||||
@@ -160,6 +160,14 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
// GetSyncPointSubmitIndex(), which answers m_submitCounter when nothing is recorded -
|
||||
// true for a fence taken at that instant, wrong for work about to be recorded.
|
||||
Uint64 GetWireNextSubmitIndex() const { return m_submitCounter + 1; }
|
||||
// P8-D: the wire arm's indirect draw families, issued as vkCmdDraw[Indexed]Indirect[Count]
|
||||
// from the wire stores MGPipeApplier().VerbIndirectBuffer / VerbIndirectParameterBuffer
|
||||
// name. `offset` / `countOffset` are byte offsets into those stores; `stride` 0 means
|
||||
// tightly packed. FALSE = this device cannot issue the COUNT form natively (the monolith
|
||||
// arm's own condition, see the definition in WireDraw.inc) and the caller must read the
|
||||
// words on the CPU; TRUE = issued, or declined by name.
|
||||
Bool DrawWireIndirectNative(GLenum mode, GLenum type, Uint64 offset, GLsizei drawcount, GLsizei stride,
|
||||
Bool indexed, Bool counted, Uint64 countOffset);
|
||||
// P11 B2 (T0): what importing a client's AHardwareBuffer as a wire buffer store needs from
|
||||
// this device. False when the device did not take VK_ANDROID_external_memory_android_
|
||||
// hardware_buffer at creation (not Android, not advertised, or a monolith device).
|
||||
@@ -680,7 +688,14 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
void CollectWireObjects(Uint64 completedSubmit, Bool all = false);
|
||||
Vector<WireRetiredObjects> m_wireRetiredObjects;
|
||||
Uint32 m_wirePreparationDepth = 0;
|
||||
// P8-D: set only while DrawWireIndirectNative is inside SetupDraw, so SetupWireDraw can
|
||||
// tell the wire arm's own indirect draw from a monolith indirect entry point reached under
|
||||
// a transport (still the `buffer-legacy-arm` role violation).
|
||||
Bool m_wireNativeIndirectDraw = false;
|
||||
void DispatchWireCompute(GLuint x, GLuint y, GLuint z);
|
||||
// P8-SV: glDispatchComputeIndirect on the wire arm - vkCmdDispatchIndirect from the
|
||||
// dispatch-indirect store, as the monolith arm issues it (WireDraw.inc).
|
||||
void DispatchWireComputeIndirect(GLintptr offset);
|
||||
void RewindWireDescriptorSetsIfDue();
|
||||
UniquePtr<RenderPassEntry> m_wireDrawPass;
|
||||
Vector<VkImageView> m_wireDrawViews;
|
||||
@@ -921,6 +936,12 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
VkDeviceSize countBufferOffset, Uint32 maxDrawCount,
|
||||
Uint32 stride);
|
||||
static inline PFNDrawIndexedIndirectCountFunc s_vkCmdDrawIndexedIndirectCount = nullptr;
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P8-D: vkCmdDrawIndirectCount (same signature, same extension), for the wire arm's
|
||||
// glMultiDrawArraysIndirectCount. The monolith arm never loads it: it reads that count on
|
||||
// the CPU (DirectVulkan.cpp's MultiDrawArraysIndirectCount).
|
||||
static inline PFNDrawIndexedIndirectCountFunc s_vkCmdWireDrawIndirectCount = nullptr;
|
||||
#endif
|
||||
// VK_EXT_multi_draw entry points, loaded at device creation when the extension
|
||||
// (and its multiDraw feature) is enabled; null otherwise.
|
||||
static inline PFN_vkCmdDrawMultiEXT s_vkCmdDrawMultiEXT = nullptr;
|
||||
|
||||
@@ -58,7 +58,7 @@ MGL_WIRE_DECLINE(CurrentAttributePayload)
|
||||
MGL_WIRE_DECLINE(CurrentAttributeUpload)
|
||||
MGL_WIRE_DECLINE(BeginRenderPass)
|
||||
|
||||
// ---- DispatchWireCompute ----------------------------------------------------------------
|
||||
// ---- DispatchWireCompute (and DispatchWireComputeIndirect, P8-SV) -------------------------
|
||||
MGL_WIRE_DECLINE(ComputeProgramLinkOrSpirv)
|
||||
MGL_WIRE_DECLINE(ComputeTextureResourcesUnprepared)
|
||||
MGL_WIRE_DECLINE(ComputePipelineUnavailable)
|
||||
@@ -104,3 +104,25 @@ MGL_WIRE_DECLINE(ShapeCreateImageFailed)
|
||||
// Appended by the B3 review round: the preserve-copy arm of a reallocation was the one exit in
|
||||
// SyncWireTextureShape still leaving no trace at all.
|
||||
MGL_WIRE_DECLINE(ShapePreserveCopyFailed)
|
||||
|
||||
// ---- VulkanRenderer::GenerateWireMipmap (P8-F) -----------------------------------------
|
||||
// `mipmap-shader-format-or-shape` was a Fatal on this arm and a decline on the monolith arm; it
|
||||
// is the monolith's decline now. Counted once per refused glGenerateMipmap, whose chain is left
|
||||
// as it was.
|
||||
MGL_WIRE_DECLINE(MipmapShaderFormatOrShape)
|
||||
|
||||
// ---- VulkanRenderer::DrawWireIndirectNative (P8-D), in statement order -----------------------
|
||||
MGL_WIRE_DECLINE(IndirectBufferUnbound)
|
||||
MGL_WIRE_DECLINE(IndirectCommandRange)
|
||||
MGL_WIRE_DECLINE(IndirectCountRange)
|
||||
MGL_WIRE_DECLINE(IndirectIndexStore)
|
||||
|
||||
// ---- P8-SV -------------------------------------------------------------------------------
|
||||
// VulkanRenderer::GenerateWireMipmap: a combined depth/stencil (or stencil-only) chain, which no
|
||||
// arm generates (CONTRACT-P7 §3.2). It logged but was never counted, so MGWIRE-DECLINES could
|
||||
// not see it. Counted once per refused glGenerateMipmap, whose chain is left as it was.
|
||||
MGL_WIRE_DECLINE(MipmapDepthStencilAspect)
|
||||
// VulkanRenderer::DispatchWireComputeIndirect, in statement order: the dispatch-indirect store
|
||||
// is missing, or the three group-count words lie outside it or are misaligned.
|
||||
MGL_WIRE_DECLINE(DispatchIndirectBufferUnbound)
|
||||
MGL_WIRE_DECLINE(DispatchIndirectRange)
|
||||
|
||||
@@ -64,6 +64,14 @@
|
||||
if (source.samples != VK_SAMPLE_COUNT_1_BIT || destination.samples != VK_SAMPLE_COUNT_1_BIT)
|
||||
return false;
|
||||
if (source.is3D || destination.is3D) return false;
|
||||
// P8-SV: THE PASS MAKES 2D VIEWS (makeView below), which a 1D, 1D-array or 3D image does
|
||||
// not admit. A caller that fills viewType from the image gets a refusal here, and the
|
||||
// wire arm's GenerateWireMipmap asks the same question before it grows the chain.
|
||||
for (const VkImageViewType viewType : {source.viewType, destination.viewType}) {
|
||||
if (viewType == VK_IMAGE_VIEW_TYPE_1D || viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY ||
|
||||
viewType == VK_IMAGE_VIEW_TYPE_3D)
|
||||
return false;
|
||||
}
|
||||
if (source.format != destination.format) return false;
|
||||
// DEPTH ONLY. A combined depth/stencil image can be sampled for its depth and
|
||||
// rendered as a depth attachment, but this pass writes gl_FragDepth and NOTHING
|
||||
|
||||
@@ -207,7 +207,10 @@
|
||||
MGL_WIRE_DECLINE_AT(ProgramLinkOrSpirv, "program is not linked or carries no SPIR-V");
|
||||
return false;
|
||||
}
|
||||
if (aspects & DrawSetupAspect::IndirectDrawBuffer)
|
||||
// P8-D: the wire arm's own indirect draw (DrawWireIndirectNative) is the one caller that
|
||||
// may pass this aspect; a monolith indirect entry point reached here is still the role
|
||||
// violation.
|
||||
if ((aspects & DrawSetupAspect::IndirectDrawBuffer) && !m_wireNativeIndirectDraw)
|
||||
WireBufferLegacyFatal();
|
||||
MakeXfbWritesVisible();
|
||||
const auto* fbo = state.DrawFramebuffer();
|
||||
@@ -294,7 +297,14 @@
|
||||
const Uint32 location = input.bindingAttributeLocations[binding];
|
||||
const auto& attr = vao.Attributes[location];
|
||||
const auto& resource = state.VertexBuffers[location];
|
||||
if (MG_Pipe::MGPipeHandleIsNull(resource.Res)) MagmaWireFatal("client-vertex-array@P8");
|
||||
// P8-F: A RECORD INVARIANT, NOT AN UNMIGRATED VERB (it carried a P8 phase tag).
|
||||
// The client turns every enabled client-memory array into an owned buffer before the
|
||||
// draw record is built, or refuses the draw itself (MG_Impl/Pipe/OwnedDrawInputs.h),
|
||||
// so an attribute the program reads with no buffer handle is a foreign peer's record.
|
||||
if (MG_Pipe::MGPipeHandleIsNull(resource.Res))
|
||||
MG_Pipe::MGPipeSessionFail(MG_Pipe::MGPipeFatalFamily::ProtocolCorruption,
|
||||
"MGPipe: Fatal{ProtocolCorruption, \"Magma:client-vertex-array\"} location=%u: an "
|
||||
"attribute the program reads carries no buffer handle", location);
|
||||
BufferSlice slice{};
|
||||
if (!m_bufferManager.AcquireWireSlice(BufferKind::Vertex, resource.Res, slice))
|
||||
MagmaWireFatal("vertex-buffer-resource");
|
||||
@@ -310,8 +320,10 @@
|
||||
const SizeT stride = static_cast<SizeT>(attr.Stride);
|
||||
SizeT count = stride ? 1 + (static_cast<SizeT>(slice.size - offset) - elementSize) / stride : 1;
|
||||
// Direct non-indexed draws bound the conversion; indexed/multi-draw may
|
||||
// name arbitrary vertices, so preserve the entire valid source stream.
|
||||
if (stride && !(aspects & DrawSetupAspect::IndexBuffer) && !resource.Divisor)
|
||||
// name arbitrary vertices, so preserve the entire valid source stream. So may an
|
||||
// indirect draw (P8-D): its vertex range is in GPU words nobody read.
|
||||
if (stride && !(aspects & DrawSetupAspect::IndexBuffer) &&
|
||||
!(aspects & DrawSetupAspect::IndirectDrawBuffer) && !resource.Divisor)
|
||||
count = std::min<SizeT>(count, static_cast<SizeT>(drawParams.firstVertex) + drawParams.vertexCount);
|
||||
if (!count) {
|
||||
MGL_WIRE_DECLINE_AT(VertexStreamCountZero, "the converted vertex stream would hold no elements");
|
||||
@@ -601,6 +613,136 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---- P8-D: THE WIRE ARM'S INDIRECT DRAWS READ THEIR WORDS ON THE GPU ----------------------
|
||||
//
|
||||
// The shape the monolith arm records (VulkanRenderer.cpp's MultiDraw{Elements,Arrays}Indirect
|
||||
// and MultiDrawElementsIndirectCount), with the wire store's own VkBuffer in place of the
|
||||
// frontend buffer's resident slice. Before this, every wire indirect draw read its commands
|
||||
// through ReadWireBuffer and expanded them on the CPU, and a store a shader had written made
|
||||
// that read a whole-GPU wait (WaitForWireBufferHostAccess) per draw.
|
||||
//
|
||||
// THE ONE FALSE: a COUNT form this device cannot issue - the monolith arm's own condition for
|
||||
// vkCmdDrawIndexedIndirectCount (MultiDrawElementsIndirectCount), extended to the non-indexed
|
||||
// twin the monolith never loads. Everything else is issued here or declined by name.
|
||||
Bool VulkanRenderer::DrawWireIndirectNative(GLenum mode, GLenum type, Uint64 offset, GLsizei drawcount,
|
||||
GLsizei stride, Bool indexed, Bool counted, Uint64 countOffset) {
|
||||
if (drawcount <= 0) return true;
|
||||
if (counted) {
|
||||
const auto countEntry = indexed ? s_vkCmdDrawIndexedIndirectCount : s_vkCmdWireDrawIndirectCount;
|
||||
if (!m_drawIndirectCountExtensionEnabled || countEntry == nullptr ||
|
||||
(!m_multiDrawIndirectFeatureEnabled && drawcount != 1))
|
||||
return false;
|
||||
}
|
||||
const auto& state = MG_Pipe::MGPipeApplier();
|
||||
// GL's command sizes (GL 4.6 10.3.10), which are also Vulkan's.
|
||||
const Uint64 commandSize = indexed ? 5 * sizeof(Uint32) : 4 * sizeof(Uint32);
|
||||
if (stride == 0) stride = static_cast<GLsizei>(commandSize);
|
||||
BufferSlice commands{};
|
||||
if (MG_Pipe::MGPipeHandleIsNull(state.VerbIndirectBuffer) ||
|
||||
!m_bufferManager.AcquireWireSlice(BufferKind::Indirect, state.VerbIndirectBuffer, commands)) {
|
||||
MGL_WIRE_DECLINE_AT(IndirectBufferUnbound, "an indirect draw names no live indirect buffer store");
|
||||
return true;
|
||||
}
|
||||
const Uint64 span = static_cast<Uint64>(stride) * static_cast<Uint64>(drawcount - 1) + commandSize;
|
||||
// GL refuses a stride that is not a multiple of four (INVALID_VALUE), and Vulkan requires
|
||||
// it for drawCount > 1; a peer's record that breaks either is declined, not issued.
|
||||
if (stride < static_cast<GLsizei>(commandSize) || (stride & 3) != 0 || (offset & 3u) != 0 ||
|
||||
offset > commands.size || span > commands.size - offset) {
|
||||
MGL_WIRE_DECLINE_AT(IndirectCommandRange, "the indirect commands lie outside their store or are misaligned");
|
||||
return true;
|
||||
}
|
||||
BufferSlice parameters{};
|
||||
if (counted) {
|
||||
if (MG_Pipe::MGPipeHandleIsNull(state.VerbIndirectParameterBuffer) ||
|
||||
!m_bufferManager.AcquireWireSlice(BufferKind::Indirect, state.VerbIndirectParameterBuffer, parameters) ||
|
||||
(countOffset & 3u) != 0 || countOffset > parameters.size || parameters.size - countOffset < sizeof(Uint32)) {
|
||||
MGL_WIRE_DECLINE_AT(IndirectCountRange, "the indirect draw count lies outside its parameter store");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// The index view is the WHOLE bound element store past its binding offset, as the monolith
|
||||
// arm binds it: the commands name their own firstIndex, which only the GPU reads.
|
||||
IndexBufferView indices{};
|
||||
DrawCmdParam vertexRange{};
|
||||
vertexRange.instanceCount = 1;
|
||||
Flags<DrawSetupAspect> aspects = DrawSetupAspect::IndirectDrawBuffer;
|
||||
if (indexed) {
|
||||
const SizeT width = MG_Util::GetGLTypeSize(type);
|
||||
BufferSlice elements{};
|
||||
if (width == 0 || MG_Pipe::MGPipeHandleIsNull(state.IndexBuffer.Res) ||
|
||||
!m_bufferManager.AcquireWireSlice(BufferKind::Index, state.IndexBuffer.Res, elements) ||
|
||||
state.IndexBuffer.Offset > elements.size) {
|
||||
MGL_WIRE_DECLINE_AT(IndirectIndexStore, "an indexed indirect draw names no usable element store");
|
||||
return true;
|
||||
}
|
||||
indices.indexType = type;
|
||||
indices.indexByteOffset = 0;
|
||||
indices.indexByteSize = static_cast<SizeT>(elements.size - state.IndexBuffer.Offset);
|
||||
vertexRange.vertexCount = static_cast<Uint32>(indices.indexByteSize / width);
|
||||
aspects |= DrawSetupAspect::IndexBuffer;
|
||||
}
|
||||
|
||||
// A shader write the store was marked with (MarkWireBufferGpuWritten) is made visible to
|
||||
// the indirect read here, once per write, so a program that omits GL_COMMAND_BARRIER_BIT
|
||||
// is not left racing a read the old CPU path used to take after a whole-GPU wait. The
|
||||
// application's own glMemoryBarrier is BuildMemoryBarrierForGlBarriers, as on the monolith
|
||||
// arm; transfer writes carry their own MEMORY_READ after-barrier (VkBufferManager.cpp).
|
||||
const Bool commandsWritten = m_bufferManager.TakeWireIndirectReadBarrier(state.VerbIndirectBuffer);
|
||||
const Bool countWritten = counted && m_bufferManager.TakeWireIndirectReadBarrier(state.VerbIndirectParameterBuffer);
|
||||
if (commandsWritten || countWritten) {
|
||||
RetireWireDrawPass();
|
||||
auto& barrierFrame = m_frameContext.GetCurrent();
|
||||
if (!barrierFrame.isCommandRecording) m_frameContext.BeginCommandRecording();
|
||||
if (VkRenderPassManager::GetActiveRenderPass() != nullptr)
|
||||
VkRenderPassManager::EndRenderPass(barrierFrame.commandBuffer);
|
||||
VkMemoryBarrier barrier{VK_STRUCTURE_TYPE_MEMORY_BARRIER};
|
||||
barrier.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT;
|
||||
barrier.dstAccessMask = VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
|
||||
vkCmdPipelineBarrier(barrierFrame.commandBuffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT, 0, 1, &barrier, 0, nullptr, 0, nullptr);
|
||||
if (MG_Util::PipeStats::Enabled())
|
||||
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::WireIndirectBarriers, 1);
|
||||
}
|
||||
|
||||
auto& frame = m_frameContext.GetCurrent();
|
||||
m_wireNativeIndirectDraw = true;
|
||||
const Bool ready = SetupDraw(frame, mode, aspects, vertexRange, indexed ? &indices : nullptr);
|
||||
m_wireNativeIndirectDraw = false;
|
||||
if (!ready) return true;
|
||||
MOBILEGL_ASSERT(frame.isCommandRecording, "%s: frame recording was not started", __func__);
|
||||
|
||||
const VkCommandBuffer commandBuffer = frame.commandBuffer;
|
||||
const VkDeviceSize first = commands.offset + offset;
|
||||
const Uint32 count = static_cast<Uint32>(drawcount);
|
||||
const Uint32 byteStride = static_cast<Uint32>(stride);
|
||||
if (counted) {
|
||||
const auto countEntry = indexed ? s_vkCmdDrawIndexedIndirectCount : s_vkCmdWireDrawIndirectCount;
|
||||
countEntry(commandBuffer, commands.buffer, first, parameters.buffer, parameters.offset + countOffset,
|
||||
count, byteStride);
|
||||
} else if (count == 1 || (!m_multiDrawForceUnrollIndirect && m_multiDrawIndirectFeatureEnabled)) {
|
||||
// maxDrawIndirectCount bounds one call; GL's drawcount does not.
|
||||
const Uint32 limit = std::max<Uint32>(1u, m_physicalDevice.properties.limits.maxDrawIndirectCount);
|
||||
for (Uint32 base = 0; base < count; base += limit) {
|
||||
const Uint32 chunk = std::min(count - base, limit);
|
||||
const VkDeviceSize at = first + static_cast<VkDeviceSize>(base) * byteStride;
|
||||
if (indexed) vkCmdDrawIndexedIndirect(commandBuffer, commands.buffer, at, chunk, byteStride);
|
||||
else vkCmdDrawIndirect(commandBuffer, commands.buffer, at, chunk, byteStride);
|
||||
}
|
||||
} else {
|
||||
// No multiDrawIndirect: one indirect draw per command, still read by the GPU
|
||||
// (the monolith arm's own fallback).
|
||||
for (Uint32 i = 0; i < count; ++i) {
|
||||
const VkDeviceSize at = first + static_cast<VkDeviceSize>(i) * byteStride;
|
||||
if (indexed) vkCmdDrawIndexedIndirect(commandBuffer, commands.buffer, at, 1, 0);
|
||||
else vkCmdDrawIndirect(commandBuffer, commands.buffer, at, 1, 0);
|
||||
}
|
||||
}
|
||||
if (MG_Util::PipeStats::Enabled())
|
||||
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::WireIndirectNativeDraws, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
void VulkanRenderer::DispatchWireCompute(GLuint x, GLuint y, GLuint z) {
|
||||
RetireWireDrawPass();
|
||||
auto& frame = m_frameContext.GetCurrent();
|
||||
@@ -628,4 +770,80 @@
|
||||
vkCmdBindPipeline(frame.commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
|
||||
vkCmdDispatch(frame.commandBuffer, x, y, z);
|
||||
}
|
||||
|
||||
// ---- P8-SV: THE WIRE ARM'S INDIRECT DISPATCH READS ITS GROUP COUNTS ON THE GPU ----------
|
||||
//
|
||||
// The monolith arm's shape (VulkanRenderer.cpp's DispatchComputeIndirect) with the wire
|
||||
// store's own VkBuffer in place of the frontend buffer's resident slice. Before this the wire
|
||||
// arm read the three words through ReadWireBuffer and dispatched them from the CPU, and a store
|
||||
// a shader had written made that read a whole-GPU wait (WaitForWireBufferHostAccess) per call.
|
||||
// There is no shape the device cannot issue, so there is no CPU path left: a record whose
|
||||
// store or words are unusable is declined by name.
|
||||
//
|
||||
// The barrier is P8-D's draw rule (DrawWireIndirectNative): a store marked shader-written gets
|
||||
// one MEMORY_WRITE -> INDIRECT_COMMAND_READ barrier before its next indirect read, whether or
|
||||
// not the application issued GL_COMMAND_BARRIER_BIT; DRAW_INDIRECT is the stage that consumes
|
||||
// VkDispatchIndirectCommand too. It is TAKEN before the bindings below, because binding this
|
||||
// dispatch's own storage buffers marks them written, and a store that is both this dispatch's
|
||||
// parameters and one of its outputs must keep that mark for the next reader.
|
||||
void VulkanRenderer::DispatchWireComputeIndirect(GLintptr offset) {
|
||||
RetireWireDrawPass();
|
||||
const auto& state = MG_Pipe::MGPipeApplier();
|
||||
constexpr Uint64 kCommandSize = 3 * sizeof(Uint32); // GL 4.6 10.3.10 / VkDispatchIndirectCommand
|
||||
BufferSlice parameters{};
|
||||
if (MG_Pipe::MGPipeHandleIsNull(state.VerbDispatchIndirectBuffer) ||
|
||||
!m_bufferManager.AcquireWireSlice(BufferKind::Indirect, state.VerbDispatchIndirectBuffer, parameters)) {
|
||||
MGL_WIRE_DECLINE_AT(DispatchIndirectBufferUnbound, "an indirect dispatch names no live dispatch-indirect store");
|
||||
return;
|
||||
}
|
||||
// GL refuses an offset that is negative or not a multiple of four (INVALID_VALUE) and a
|
||||
// command past the end of the buffer (INVALID_OPERATION); a peer's record that breaks
|
||||
// either is declined, not issued.
|
||||
if (offset < 0 || (static_cast<Uint64>(offset) & 3u) != 0 || static_cast<Uint64>(offset) > parameters.size ||
|
||||
parameters.size - static_cast<Uint64>(offset) < kCommandSize) {
|
||||
MGL_WIRE_DECLINE_AT(DispatchIndirectRange, "the dispatch group counts lie outside their store or are misaligned");
|
||||
return;
|
||||
}
|
||||
auto& frame = m_frameContext.GetCurrent();
|
||||
if (m_bufferManager.TakeWireIndirectReadBarrier(state.VerbDispatchIndirectBuffer)) {
|
||||
if (!frame.isCommandRecording) m_frameContext.BeginCommandRecording();
|
||||
if (VkRenderPassManager::GetActiveRenderPass() != nullptr)
|
||||
VkRenderPassManager::EndRenderPass(frame.commandBuffer);
|
||||
VkMemoryBarrier barrier{VK_STRUCTURE_TYPE_MEMORY_BARRIER};
|
||||
barrier.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT;
|
||||
barrier.dstAccessMask = VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
|
||||
vkCmdPipelineBarrier(frame.commandBuffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT, 0, 1, &barrier, 0, nullptr, 0, nullptr);
|
||||
if (MG_Util::PipeStats::Enabled())
|
||||
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::WireIndirectBarriers, 1);
|
||||
}
|
||||
const auto program = WireProgramSource(state.DispatchProgram);
|
||||
if (!program.GetLinkStatus() || !program.GetSpirvStatus()) {
|
||||
MGL_WIRE_DECLINE_AT(ComputeProgramLinkOrSpirv, "the compute program is not linked or carries no SPIR-V");
|
||||
return;
|
||||
}
|
||||
const auto& programObj = m_programFactory->GetOrCreateProgram(program, {});
|
||||
if (!m_uniformManager->PrepareWireTextureResources(program, programObj)) {
|
||||
MGL_WIRE_DECLINE_AT(ComputeTextureResourcesUnprepared, "a sampled/storage image could not be made ready for the dispatch");
|
||||
return;
|
||||
}
|
||||
const auto pipeline = GetOrCreateComputePipeline(programObj);
|
||||
if (!pipeline) {
|
||||
MGL_WIRE_DECLINE_AT(ComputePipelineUnavailable, "no compute pipeline could be created for this dispatch");
|
||||
return;
|
||||
}
|
||||
// PrepareWireTextureResources may have flushed and begun a new recording.
|
||||
auto& dispatchFrame = m_frameContext.GetCurrent();
|
||||
if (!dispatchFrame.isCommandRecording) m_frameContext.BeginCommandRecording();
|
||||
if (!m_uniformManager->BindProgramUniformBuffers(dispatchFrame.commandBuffer, program, programObj,
|
||||
m_frameContext.GetCurrentFrameIndex(), VK_PIPELINE_BIND_POINT_COMPUTE)) {
|
||||
MGL_WIRE_DECLINE_AT(ComputeUniformBufferBinding, "the dispatch's uniform/storage bindings could not be bound");
|
||||
return;
|
||||
}
|
||||
vkCmdBindPipeline(dispatchFrame.commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
|
||||
vkCmdDispatchIndirect(dispatchFrame.commandBuffer, parameters.buffer,
|
||||
parameters.offset + static_cast<VkDeviceSize>(offset));
|
||||
if (MG_Util::PipeStats::Enabled())
|
||||
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::WireIndirectNativeDispatches, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
// missing WHICH feature bit - was the one thing it did not. The census, the retrace
|
||||
// refusal tally and every log grep key on the leading word, so it is unchanged and
|
||||
// unprefixed; everything after the first space is for the reader of the next device run.
|
||||
// P8-F: the refusal is a named decline now (WireDeclines.def MipmapShaderFormatOrShape);
|
||||
// the line it logs keeps this word and this detail.
|
||||
static String MagmaWireShapeDetail(const char* name, VkFormat format, VkFormat storageFormat,
|
||||
const VkFormatProperties& props, VkImageAspectFlags aspect,
|
||||
VkImageViewType viewType, VkImageUsageFlags usage,
|
||||
@@ -1392,16 +1394,22 @@
|
||||
// release build both arms ship as. Nothing in GL promises a stencil mip either - the
|
||||
// pass writes gl_FragDepth and would leave the stencil aspect of the level it produced
|
||||
// undefined, which is worse than leaving the whole level alone and saying so.
|
||||
//
|
||||
// P8-SV: a NAMED decline (WireDeclines.def MipmapDepthStencilAspect), so MGWIRE-DECLINES
|
||||
// counts it like every other refusal on this arm; the line keeps its words.
|
||||
if (resource->aspect != VK_IMAGE_ASPECT_COLOR_BIT && resource->aspect != VK_IMAGE_ASPECT_DEPTH_BIT) {
|
||||
MGLOG_E_ONCE("DirectVulkan::GenerateWireMipmap: aspect 0x%x (a combined depth/stencil or "
|
||||
"stencil-only texture, format %d) has no mip generation on either arm; "
|
||||
"declining and leaving levels %u..%u as they are",
|
||||
static_cast<Uint32>(resource->aspect), static_cast<Int>(resource->format),
|
||||
base + 1, base + count - 1);
|
||||
MGL_WIRE_DECLINE_AT(MipmapDepthStencilAspect,
|
||||
"DirectVulkan::GenerateWireMipmap: aspect 0x%x (a combined depth/stencil or "
|
||||
"stencil-only texture, format %d) has no mip generation on either arm; "
|
||||
"declining and leaving levels %u..%u as they are",
|
||||
static_cast<Uint32>(resource->aspect), static_cast<Int>(resource->format),
|
||||
base + 1, base + count - 1);
|
||||
return;
|
||||
}
|
||||
if (!m_textureManager->GrowWireTextureMipChain(handle,base+count,frame.commandBuffer))
|
||||
MagmaWireFatal("mipmap-growth");
|
||||
// P8-F: WHICH ARM TAKES THIS CHAIN IS DECIDED BEFORE THE CHAIN IS GROWN, for the
|
||||
// depth-stencil decline's reason above. Nothing here depends on the growth: the format,
|
||||
// its features, the knob tier, the aspect, view type, usage and layer window are the
|
||||
// same before and after it (GrowWireTextureMipChain carries every one of them over).
|
||||
VkFormatProperties props{};
|
||||
const VkFormat format = viewFormat == VK_FORMAT_UNDEFINED ? resource->format : viewFormat;
|
||||
vkGetPhysicalDeviceFormatProperties(m_physicalDevice.handle,format,&props);
|
||||
@@ -1411,6 +1419,55 @@
|
||||
(props.optimalTilingFeatures & required) == required;
|
||||
const VkFilter filter = props.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT ?
|
||||
VK_FILTER_LINEAR : VK_FILTER_NEAREST;
|
||||
const Bool layersInRange = baseLayer < resource->arrayLayers &&
|
||||
layerCount <= resource->arrayLayers - baseLayer;
|
||||
// Both shader arms render a 2D view of one layer of one level, so a 1D, 1D-array or 3D
|
||||
// image is a shape neither takes.
|
||||
const Bool planar = resource->viewType != VK_IMAGE_VIEW_TYPE_1D &&
|
||||
resource->viewType != VK_IMAGE_VIEW_TYPE_1D_ARRAY &&
|
||||
resource->viewType != VK_IMAGE_VIEW_TYPE_3D;
|
||||
// The depth arm's shape: the layer window, and what WireDepthMipmap.inc's pass refuses
|
||||
// for an image this function hands it (the view type is passed to it below) - a 1D,
|
||||
// 1D-array or 3D view type, and a format that does not both sample and attach as depth.
|
||||
// Its other refusals, multisample and a default image, are never built here. P8-SV: the
|
||||
// view type half is new; before it a 1D depth chain reached the pass, which made a 2D
|
||||
// view of the 1D image.
|
||||
const auto depthPassFeatures =
|
||||
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
const Bool depthArmTakesShape = planar &&
|
||||
layersInRange && (props.optimalTilingFeatures & depthPassFeatures) == depthPassFeatures;
|
||||
// The colour arm's shape (the two shader shapes are explained at the colour arm below).
|
||||
const Bool colour = resource->aspect == VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
// The shader arm samples through a sampler2D and writes a vec4, which is what
|
||||
// BlitWireColorImage's own float check enforces; naming it here rather than letting the
|
||||
// blit return false is what puts the reason in the decline line.
|
||||
const Bool sampledFloat = vkuFormatIsSampledFloat(format);
|
||||
const Bool renderableFormat =
|
||||
(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) != 0;
|
||||
const Bool attachable = forcedShaderTier < 2 &&
|
||||
(resource->usageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0;
|
||||
const Bool viaScratch = !attachable && renderableFormat &&
|
||||
(resource->usageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT) != 0;
|
||||
const Bool colourArmTakesShape =
|
||||
colour && planar && layersInRange && sampledFloat && (attachable || viaScratch);
|
||||
// P8-F: `mipmap-shader-format-or-shape` IS A NAMED DECLINE, NOT A FATAL (rule I (a)).
|
||||
// The monolith arm has always answered this chain with a decline (VulkanRenderer.cpp's
|
||||
// GenerateMipmap: a format without blit support is skipped and the chain left unwritten),
|
||||
// and a shape no shader arm takes is a coverage gap in this backend, not a broken record.
|
||||
// The leading word stays, so every device-log grep keyed on it still finds the line.
|
||||
const Bool shaderArmTakesShape =
|
||||
resource->aspect == VK_IMAGE_ASPECT_DEPTH_BIT ? depthArmTakesShape : colourArmTakesShape;
|
||||
if (!nativeBlit && !shaderArmTakesShape) {
|
||||
const String detail = MagmaWireShapeDetail("mipmap-shader-format-or-shape", format,
|
||||
resource->format, props, resource->aspect, resource->viewType, resource->usageFlags,
|
||||
resource->extent, resource->depth, resource->mipLevels, baseLayer, layerCount,
|
||||
resource->arrayLayers);
|
||||
MGL_WIRE_DECLINE_AT(MipmapShaderFormatOrShape, "%s; no mip arm takes this shape, levels %u..%u left as they are",
|
||||
detail.c_str(), base + 1, base + count - 1);
|
||||
return;
|
||||
}
|
||||
if (!m_textureManager->GrowWireTextureMipChain(handle,base+count,frame.commandBuffer))
|
||||
MagmaWireFatal("mipmap-growth");
|
||||
if (!nativeBlit && resource->aspect == VK_IMAGE_ASPECT_DEPTH_BIT) {
|
||||
// P7 wave 2-B, CONTRACT-P7 §5.1 (A): THE DEPTH ARM, and it is first because a
|
||||
// depth format without BLIT_DST is the ordinary case, not the exotic one -
|
||||
@@ -1422,18 +1479,17 @@
|
||||
// The per-level pass is WireDepthMipmap.inc's, which is the monolith's fragment
|
||||
// shader with the monolith's arithmetic on a baked pipeline that owns no frontend
|
||||
// object - §3.2's "observably the monolith's" without the GL program the monolith
|
||||
// needs to get there.
|
||||
if (baseLayer >= resource->arrayLayers || layerCount > resource->arrayLayers - baseLayer)
|
||||
MagmaWireFatal(MagmaWireShapeDetail("mipmap-shader-format-or-shape", format,
|
||||
resource->format, props, resource->aspect, resource->viewType,
|
||||
resource->usageFlags, resource->extent, resource->depth, resource->mipLevels,
|
||||
baseLayer, layerCount, resource->arrayLayers).c_str());
|
||||
// needs to get there. Its layer window and format were checked before the growth.
|
||||
for (Uint32 level = base + 1; level < base + count; ++level) {
|
||||
for (Uint32 layer = baseLayer; layer < baseLayer + layerCount; ++layer) {
|
||||
WireImage source{};
|
||||
source.image = resource->image;
|
||||
source.format = format;
|
||||
source.aspect = VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
// P8-SV: the image's own view type, so the pass can refuse a shape it cannot
|
||||
// render (it makes 2D views) instead of receiving the struct's 2D default.
|
||||
source.viewType = resource->viewType;
|
||||
source.is3D = resource->viewType == VK_IMAGE_VIEW_TYPE_3D;
|
||||
source.layout = resource->layout;
|
||||
source.trackedLayout = &resource->layout;
|
||||
source.levels = resource->mipLevels;
|
||||
@@ -1445,15 +1501,19 @@
|
||||
destination.level = level;
|
||||
destination.extent = {std::max(resource->extent.width >> level, 1u),
|
||||
std::max(resource->extent.height >> level, 1u)};
|
||||
// The pass reports the SHAPE it cannot take (1D, 3D, multisample, a
|
||||
// format without sampled or depth-attachment support), so the refusal
|
||||
// keeps its name and gains the reason.
|
||||
if (!GenerateWireDepthMipLevel(source, destination))
|
||||
MagmaWireFatal(MagmaWireShapeDetail("mipmap-shader-format-or-shape", format,
|
||||
// The pass reports the SHAPE it cannot take. depthArmTakesShape above asks
|
||||
// its questions first, so this is reached only if the two lists drift apart
|
||||
// - and then it is the same named decline (P8-F), not a session's end. It
|
||||
// can only refuse the first level: the shape does not change down the chain.
|
||||
if (!GenerateWireDepthMipLevel(source, destination)) {
|
||||
const String detail = MagmaWireShapeDetail("mipmap-shader-format-or-shape", format,
|
||||
resource->format, props, resource->aspect, resource->viewType,
|
||||
resource->usageFlags, resource->extent, resource->depth,
|
||||
resource->mipLevels, baseLayer, layerCount,
|
||||
resource->arrayLayers).c_str());
|
||||
resource->mipLevels, baseLayer, layerCount, resource->arrayLayers);
|
||||
MGL_WIRE_DECLINE_AT(MipmapShaderFormatOrShape, "%s; the depth pass refused level %u",
|
||||
detail.c_str(), level);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!nativeBlit) {
|
||||
@@ -1470,27 +1530,9 @@
|
||||
// cannot, an owned scratch attachment of the destination level's size renders
|
||||
// the mip and vkCmdCopyImage moves it in: a raw texel move, no conversion, and
|
||||
// the texels still come from GPU contents rather than from a staged shadow.
|
||||
const Bool colour = resource->aspect == VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
const Bool planar = resource->viewType != VK_IMAGE_VIEW_TYPE_1D &&
|
||||
resource->viewType != VK_IMAGE_VIEW_TYPE_1D_ARRAY &&
|
||||
resource->viewType != VK_IMAGE_VIEW_TYPE_3D;
|
||||
const Bool layersInRange = baseLayer < resource->arrayLayers &&
|
||||
layerCount <= resource->arrayLayers - baseLayer;
|
||||
// The shader arm samples through a sampler2D and writes a vec4, which is what
|
||||
// BlitWireColorImage's own float check enforces; naming it here rather than
|
||||
// letting the blit return false is what puts the reason in the fatal line.
|
||||
const Bool sampledFloat = vkuFormatIsSampledFloat(format);
|
||||
const Bool renderableFormat =
|
||||
(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) != 0;
|
||||
const Bool attachable = forcedShaderTier < 2 &&
|
||||
(resource->usageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0;
|
||||
const Bool viaScratch = !attachable && renderableFormat &&
|
||||
(resource->usageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT) != 0;
|
||||
if (!colour || !planar || !layersInRange || !sampledFloat || (!attachable && !viaScratch))
|
||||
MagmaWireFatal(MagmaWireShapeDetail("mipmap-shader-format-or-shape", format,
|
||||
resource->format, props, resource->aspect, resource->viewType,
|
||||
resource->usageFlags, resource->extent, resource->depth, resource->mipLevels,
|
||||
baseLayer, layerCount, resource->arrayLayers).c_str());
|
||||
//
|
||||
// Which of the two (`attachable` or `viaScratch`), and whether either takes the
|
||||
// shape at all, was decided before the growth (colourArmTakesShape, P8-F).
|
||||
for (Uint32 level = base + 1; level < base + count; ++level) {
|
||||
for (Uint32 layer = baseLayer; layer < baseLayer + layerCount; ++layer) {
|
||||
WireImage source{};
|
||||
@@ -1574,14 +1616,24 @@
|
||||
if (!VkTextureManager::TransitionImageLayout(frame.commandBuffer,resource->image,resource->layout,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,stage,VK_PIPELINE_STAGE_TRANSFER_BIT,access,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,resource->aspect,0,resource->mipLevels)) MagmaWireFatal("mipmap-transition");
|
||||
// P8-SV: A 3D IMAGE HAS ONE ARRAY LAYER, AND ITS DEPTH IS THE Z EXTENT OF THE BLIT.
|
||||
// ResolveWireTextureStorage answers `layerCount` in slices for Tex3D (Depth >> level,
|
||||
// VkTextureManager.cpp) - the addressing attachments, descriptors and readback use - and
|
||||
// passing that on as the blit's subresource layerCount names layers the image (created
|
||||
// with arrayLayers = 1) does not have (VUID-vkCmdBlitImage-srcImage-00240,
|
||||
// -srcSubresource-01707, -dstSubresource-01708). The monolith arm blits layer 0, count 1,
|
||||
// with the z offsets below halving the depth level by level; so does this one now.
|
||||
const Bool volume = resource->viewType == VK_IMAGE_VIEW_TYPE_3D;
|
||||
const Uint32 blitBaseLayer = volume ? 0u : baseLayer;
|
||||
const Uint32 blitLayerCount = volume ? 1u : layerCount;
|
||||
for (Uint32 level=base+1;level<base+count;++level) {
|
||||
VkImageLayout previous = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||
VkTextureManager::TransitionImageLayout(frame.commandBuffer,resource->image,previous,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,VK_PIPELINE_STAGE_TRANSFER_BIT,VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,VK_ACCESS_TRANSFER_READ_BIT,resource->aspect,level-1,1);
|
||||
VkImageBlit blit{};
|
||||
blit.srcSubresource = {resource->aspect,level-1,baseLayer,layerCount};
|
||||
blit.dstSubresource = {resource->aspect,level,baseLayer,layerCount};
|
||||
blit.srcSubresource = {resource->aspect,level-1,blitBaseLayer,blitLayerCount};
|
||||
blit.dstSubresource = {resource->aspect,level,blitBaseLayer,blitLayerCount};
|
||||
blit.srcOffsets[1] = {static_cast<Int32>(std::max(resource->extent.width>>(level-1),1u)),
|
||||
static_cast<Int32>(std::max(resource->extent.height>>(level-1),1u)),
|
||||
static_cast<Int32>(std::max(resource->depth>>(level-1),1u))};
|
||||
|
||||
@@ -186,9 +186,9 @@ namespace MobileGL::MG_Backend {
|
||||
// ZERO IS THE EXPLICIT ANSWER FOR P5, not an omission (ServerSession.h's block):
|
||||
// every optional capability bit belongs to the package that owns its question, and
|
||||
// withholding one leaves the legacy path running, which is the safe direction.
|
||||
// kCapNeedsHostIndexBytes and kCapNeedsHostUboBytes must be 0 for the whole of P5
|
||||
// by ruling - they are the only two things that ask for an MGHostSpan, and 0 is
|
||||
// what keeps every one of them out of the first IPC frame (contract table 0).
|
||||
// kCapNeedsHostIndexBytes, kCapNeedsHostUboBytes and kCapViewportArray are RESERVED
|
||||
// (P8-F) and never set here: the first two are the only things that ask for an
|
||||
// MGHostSpan, and 0 keeps every one of them off the wire (contract table 0).
|
||||
//
|
||||
// P5b t2 (CONTRACT-P5B.md §6.5) PUBLISHES THE ONE BIT P5b ADDS, and this is the
|
||||
// only place that can: the question kCapBackendOwnsXfbCapture answers is "does the
|
||||
|
||||
@@ -247,10 +247,10 @@ namespace MobileGL::MG_Pipe {
|
||||
for (Uint32 w = 0; w < kMGPipeShaderBufferWritableMaskWords; ++w) {
|
||||
header.WritableMask[w] = writableMask[w];
|
||||
}
|
||||
// HostSpanCount IS 0 ALWAYS on Espryt, and that is a ruling rather than an omission:
|
||||
// the second var-tail exists for kCapNeedsHostUboBytes (Magma's named-UBO ring) and
|
||||
// that bit is 0 for the whole of P5 (CONTRACT-P5.md table 0). The codec's host-span
|
||||
// honesty pass is the guard that says so out loud if a backend ever publishes it.
|
||||
// HostSpanCount IS 0 ALWAYS, and that is a ruling rather than an omission: the
|
||||
// second var-tail exists for kCapNeedsHostUboBytes (a Magma named-UBO ring that was
|
||||
// never built) and that bit is RESERVED (P8-F): no server publishes it. The codec's
|
||||
// host-span honesty pass is the guard that says so out loud if a peer sends one.
|
||||
header.HostSpanCount = 0;
|
||||
header.ContentHash = hash;
|
||||
MGPipeRouteSetShaderBuffers(header, m_entries.data());
|
||||
|
||||
@@ -263,8 +263,8 @@ namespace MobileGL::MG_Pipe {
|
||||
if (vao) {
|
||||
if (const auto& bound = vao->GetIndexBufferBindingSlot().GetBoundObject()) {
|
||||
m_lastIndex.Res = MGPipeSlots().Acquire(MGPipeKind::Buffer, bound->GetLifetimeId());
|
||||
// The ELEMENT_ARRAY bit, and it is the one the split path keys on
|
||||
// (kCapNeedsHostIndexBytes -> restart rewriting, multi-draw flattening).
|
||||
// The INDEX|ELEMENT_ARRAY bind bits. ELEMENT_ARRAY's D-B7 reader
|
||||
// (kCapNeedsHostIndexBytes) is RESERVED (P8-F) and was never built.
|
||||
// Noted at every draw for RefreshBindMask's reason: an EBO defined through
|
||||
// DSA and unbound before its last respecify would otherwise never publish
|
||||
// it, and getting that bit wrong is invisible in monolith.
|
||||
|
||||
@@ -111,6 +111,9 @@ add_executable(MobileGLIntegrationTest
|
||||
Scenarios/ImageTargetKindScenario.cpp
|
||||
Scenarios/ImageFormatQualifierScenario.cpp
|
||||
Scenarios/TextureRemintPullScenario.cpp
|
||||
# P8-B: glGenerateMipmap's window and RGB16F / RGB32F on Espryt's server. Ordinary GL, so the
|
||||
# monolith arms of both backends run it too.
|
||||
Scenarios/GenerateMipmapServerScenario.cpp
|
||||
Scenarios/NonCoreImageFormatScenario.cpp
|
||||
Scenarios/ImageSizeAfterRespecScenario.cpp
|
||||
Scenarios/EmptyTextureLevelScenario.cpp
|
||||
@@ -137,6 +140,7 @@ add_executable(MobileGLIntegrationTest
|
||||
Scenarios/CopyImageLevelRangeScenario.cpp
|
||||
Scenarios/CopyImageLayeredScenario.cpp
|
||||
Scenarios/CopyImagePacked16Scenario.cpp
|
||||
Scenarios/CopyImageStoreReadbackScenario.cpp
|
||||
Scenarios/TextureViewScenario.cpp
|
||||
# P3b/P4b wave 2-D package D2: the verification half of the owner-keyed emission cursor.
|
||||
Scenarios/TextureViewAliasScenario.cpp
|
||||
@@ -155,6 +159,7 @@ add_executable(MobileGLIntegrationTest
|
||||
Scenarios/UnboundImageDescriptorScenario.cpp
|
||||
# P7 gate 5: an image unit naming a (level, layer) its texture lacks (GL 4.6 core 8.26).
|
||||
Scenarios/InvalidImageUnitScenario.cpp
|
||||
Scenarios/UnboundUniformBlockScenario.cpp
|
||||
Scenarios/IntegerBorderColorScenario.cpp
|
||||
Scenarios/ClearTexImageUndefinedLevelZeroScenario.cpp
|
||||
Scenarios/RenderbufferBlendFormatScenario.cpp
|
||||
@@ -2148,8 +2153,21 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
# - because under inproc and spawn the server inherits the client's environment and under tcp
|
||||
# it does not. A feature knob that reaches two of three arms is the worst of the three states:
|
||||
# the lane is green and tests nothing.
|
||||
#
|
||||
# P8-A: THE VULKAN PINS FOR THE SAME REASON - the ICD and, on lavapipe, the three iterationRP
|
||||
# repairs every DirectVulkan entry carries (MGL_ITEST_VULKAN_ENV above). Magma reads them in
|
||||
# the SERVER. Measured: DirectVulkan.Tcp.IterationRPProgram203Scenario and its Tcp.Full. twin
|
||||
# missed the golden output by one texel while the Split and Spawn copies passed - the
|
||||
# unrepaired shape that block describes. All four are Vulkan-only, so Espryt's server is
|
||||
# unchanged.
|
||||
set(mglItestTcpServerEnvironment "MOBILEGL_ESPRYT_ENABLE_TEXTURE_VIEW=1")
|
||||
foreach(mglItestVulkanPin IN LISTS MGL_ITEST_VULKAN_ENV)
|
||||
if(NOT mglItestVulkanPin IN_LIST MGL_ITEST_COMMON_ENV)
|
||||
list(APPEND mglItestTcpServerEnvironment "${mglItestVulkanPin}")
|
||||
endif()
|
||||
endforeach()
|
||||
set_tests_properties(TcpServer.Start PROPERTIES FIXTURES_SETUP mobilegl-tcp TIMEOUT 20
|
||||
ENVIRONMENT "MOBILEGL_ESPRYT_ENABLE_TEXTURE_VIEW=1")
|
||||
ENVIRONMENT "${mglItestTcpServerEnvironment}")
|
||||
set_tests_properties(TcpServer.Stop PROPERTIES FIXTURES_CLEANUP mobilegl-tcp TIMEOUT 20)
|
||||
add_test(NAME TcpLane.AccountingControls COMMAND "${Python3_EXECUTABLE}"
|
||||
"${CMAKE_SOURCE_DIR}/scripts/ci/tcp_lane_tools_test.py")
|
||||
@@ -2587,8 +2605,8 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
# had no split coverage at all, so every claim about it was a reading of the code rather than
|
||||
# a run of it. Arming the lanes is the first half of the work and the census is the second:
|
||||
# what reds here IS the remaining worklist, and each red is either D1's to fix or excluded BY
|
||||
# NAME with the Fatal quoted, the way the d1 draw block excludes
|
||||
# MultiDrawScenario.ClientSideIndicesBatchMatchesUnrolledDraws.
|
||||
# NAME with the Fatal quoted, the way the d1 draw block excluded
|
||||
# MultiDrawScenario.ClientSideIndicesBatchMatchesUnrolledDraws until P8-A.
|
||||
mgl_itest_register_split_arms("PixelStoreSweepScenario.*" "")
|
||||
mgl_itest_register_split_arms("PackedWordReadbackScenario.*" "")
|
||||
mgl_itest_register_split_arms("LayeredTextureReadbackScenario.*" "")
|
||||
@@ -2627,7 +2645,12 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
# left all of them passing. A split arm that inherited the ambient default would be measuring
|
||||
# the same non-path three more times. So the pin is MIRRORED here, which is what the plan's
|
||||
# row asks for.
|
||||
foreach(mglItestDsArm IN LISTS MGL_ITEST_MAGMA_ARMS)
|
||||
#
|
||||
# P8-A: SPLIT AND SPAWN ONLY HERE. The knob is read by the server, and the Tcp arm's server
|
||||
# is the lane-wide fixture, so a Tcp copy registered here ran the NATIVE readback under the
|
||||
# ForcedDs. name. The same-named Tcp entries are registered in P8Coverage.cmake, against a
|
||||
# supervisor started with the knob.
|
||||
foreach(mglItestDsArm Split Spawn)
|
||||
mgl_itest_magma_arm_shape(${mglItestDsArm})
|
||||
string(TOLOWER "${mglItestDsArm}" mglItestDsArmLower)
|
||||
mgl_itest_join_environment(mglItestDsEnvironment
|
||||
@@ -2755,19 +2778,20 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
# the two multi-draws, an indirect draw), so a record that did not cross is a wrong picture
|
||||
# and not a green. MultiDrawScenario, DrawParametersScenario and PrimitiveRestartScenario are
|
||||
# the census's own DrawElements / MultiDrawElementsBaseVertex / DrawArraysInstancedBaseInstance
|
||||
# / MultiDraw*Indirect* first-blocker scenarios, now at their pictures. The ONE case excluded
|
||||
# by filter is MultiDrawScenario's ClientSideIndicesBatchMatchesUnrolledDraws: a multi-draw
|
||||
# with client-side indices is refused BY NAME under split (Fatal{UnmigratedVerb,
|
||||
# "MultiDrawElementsBaseVertex+CLIENT_INDICES"}, CONTRACT-P5B.md d1 - P8's HostResolve.cpp
|
||||
# flattens it), which is its next first blocker and not a lane failure. It is listed in
|
||||
# d1-v1.md, not deleted (G14). GuiBatchScenario (the census's other DrawElements scenario) is
|
||||
# NOT registered: past its draws it stops at Fatal{UnmigratedVerb, "MemoryBarrier"}, which is
|
||||
# i1's to flip; i1 registers it when that lands.
|
||||
# / MultiDraw*Indirect* first-blocker scenarios, now at their pictures. The whole of
|
||||
# MultiDrawScenario is here since P8-A: its ClientSideIndicesBatchMatchesUnrolledDraws was
|
||||
# excluded while a multi-draw with client-side indices was refused BY NAME under split
|
||||
# (Fatal{UnmigratedVerb, "MultiDrawElementsBaseVertex+CLIENT_INDICES"}), and the client now
|
||||
# flattens every sub-draw's client indices into one owned element buffer before the record is
|
||||
# emitted (EmitTables.cpp's EmitMultiIndexedDraw, OwnedDrawInputs.h), so the
|
||||
# server's CLIENT_INDICES latch is unreachable from our client and this case is the entry that
|
||||
# would see it come back. GuiBatchScenario (the census's other DrawElements scenario) waited
|
||||
# on Fatal{UnmigratedVerb, "MemoryBarrier"}; that verb has crossed since i1 and class C is
|
||||
# empty, so P8Coverage.cmake registers it with the other monolith-only cases.
|
||||
set(MGL_SPLIT_D1_SCENARIOS IndexedDrawFamilyScenario MultiDrawScenario DrawParametersScenario
|
||||
PrimitiveRestartScenario)
|
||||
set(MGL_SPLIT_D1_FILTER_IndexedDrawFamilyScenario "IndexedDrawFamilyScenario.*")
|
||||
set(MGL_SPLIT_D1_FILTER_MultiDrawScenario
|
||||
"MultiDrawScenario.*-MultiDrawScenario.ClientSideIndicesBatchMatchesUnrolledDraws")
|
||||
set(MGL_SPLIT_D1_FILTER_MultiDrawScenario "MultiDrawScenario.*")
|
||||
set(MGL_SPLIT_D1_FILTER_DrawParametersScenario "DrawParametersScenario.*")
|
||||
set(MGL_SPLIT_D1_FILTER_PrimitiveRestartScenario "PrimitiveRestartScenario.*")
|
||||
foreach(mglItestD1Scenario IN LISTS MGL_SPLIT_D1_SCENARIOS)
|
||||
@@ -2810,8 +2834,9 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
# THE FILTER IS THE TIER-SENSITIVE WORKLOAD and nothing else, which is this file's own rule
|
||||
# for an armed Split entry: MultiDrawScenario (its whole point is that a batch matches the
|
||||
# unrolled draws, which is precisely what a wrong index buffer breaks quietly) and
|
||||
# IndexedDrawFamilyScenario's three MultiDraw cases. The client-side-indices case keeps the
|
||||
# d1 block's exclusion - it is refused by name under split before any tier is chosen.
|
||||
# IndexedDrawFamilyScenario's three MultiDraw cases. The client-side-indices case joined with
|
||||
# the d1 block's (P8-A): its flattened indices arrive as one owned element buffer, which is
|
||||
# exactly the bound index buffer each tier asks its questions of.
|
||||
#
|
||||
# NOTE FOR THE STRICT-MARKER CENSUS (PREAMBLE-ADDENDUM-WAVE3 §4): these entries carry a THIRD
|
||||
# name segment, so `strict_census2.sh` re-derives their gtest filter from the last two
|
||||
@@ -2827,7 +2852,7 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
set(MGL_SPLIT_MULTIDRAW_TIER_PREFIX_drawelements "DrawElements")
|
||||
set(MGL_SPLIT_MULTIDRAW_TIER_PREFIX_compute "Compute")
|
||||
set(MGL_SPLIT_MULTIDRAW_TIER_FILTER
|
||||
"MultiDrawScenario.*:IndexedDrawFamilyScenario.MultiDraw*-MultiDrawScenario.ClientSideIndicesBatchMatchesUnrolledDraws")
|
||||
"MultiDrawScenario.*:IndexedDrawFamilyScenario.MultiDraw*")
|
||||
foreach(mglItestMultiDrawTier IN LISTS MGL_SPLIT_MULTIDRAW_TIERS)
|
||||
mgl_itest_join_environment(MGL_ITEST_GLES_SPLIT_MULTIDRAW_ENVIRONMENT
|
||||
"MOBILEGL_BACKEND_TYPE=DirectGLES" "MOBILEGL_TRANSPORT=inproc" "MOBILEGL_ITEST_REQUIRE_GPU=1"
|
||||
@@ -3225,6 +3250,72 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
# case that produced no record RED for having nothing to say - which is the rule working, not
|
||||
# a defect. They stay unregistered for that reason and are listed in the census note.
|
||||
|
||||
# P8-E (docs/Disaggregated/notes/p8/E.md): glCopyImageSubData into a level the driver will not
|
||||
# read back, then glGetTexImage. The knob-free cases on Espryt's three arms; Magma's gated arms
|
||||
# are the `DirectVulkan.<arm>.CopyStore.` entries just below; both monolith entries come from
|
||||
# the whole-binary discovery.
|
||||
mgl_itest_register_split_arms("CopyImageStoreReadbackScenario.*" "")
|
||||
# The same cases with MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT pinned: the Espryt server
|
||||
# treats a colour level of exactly that extent as one the driver refused to attach (what an
|
||||
# Adreno does for RGB16 and 16-bit SNORM), so its staged store has to answer. READ BY THE
|
||||
# SERVER, and it reaches all three arms: inproc sees this entry's environment, spawn copies it
|
||||
# into the child, and the tcp supervisor carries it in its own fixture ENVIRONMENT (appended to
|
||||
# TcpServer.Start here). Lane-wide there is harmless because the knob names an EXTENT and the
|
||||
# scenario builds that extent only when it finds the knob in its own environment - every other
|
||||
# tcp entry, this scenario's knob-free ones included, reads levels of other sizes. The
|
||||
# renderbuffer case is not here: a renderbuffer's texels were never uploaded, so no store can
|
||||
# answer for them, and a declined readback ends the session by design.
|
||||
set(MGL_P8E_REFUSE_EXTENT "13x7")
|
||||
set_property(TEST TcpServer.Start APPEND PROPERTY ENVIRONMENT
|
||||
"MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT=${MGL_P8E_REFUSE_EXTENT}")
|
||||
foreach(mglItestArm IN ITEMS Split Spawn Tcp)
|
||||
string(TOUPPER "${mglItestArm}" mglItestArmUpper)
|
||||
string(TOLOWER "${mglItestArm}" mglItestArmLower)
|
||||
set(mglItestStoreReadProperties)
|
||||
if(mglItestArm STREQUAL "Tcp")
|
||||
set(mglItestStoreReadProperties FIXTURES_REQUIRED mobilegl-tcp RESOURCE_LOCK mobilegl-tcp)
|
||||
endif()
|
||||
foreach(storeReadCase AnUploadedLevelReadsBackExactly
|
||||
ACopiedWindowReadsBackOverTheUpload
|
||||
ACopiedWindowReadsBackFromAnImmutableLevel
|
||||
APartialUploadAfterTheCopyKeepsTheCopiedWindow)
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectGLES.${mglItestArm}.StoreRead."
|
||||
TEST_LIST "MGL_SPLIT_ARM_TESTS_${MGL_SPLIT_ARM_INDEX}"
|
||||
TEST_FILTER "CopyImageStoreReadbackScenario.${storeReadCase}"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES
|
||||
LABELS "integration-gpu\\;integration-${mglItestArmLower}"
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
ENVIRONMENT "${MGL_ITEST_GLES_${mglItestArmUpper}_ENVIRONMENT}\;MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT=${MGL_P8E_REFUSE_EXTENT}"
|
||||
${mglItestStoreReadProperties}
|
||||
)
|
||||
# Into the accumulated list, so SplitLogPaths gives each entry a private log: the
|
||||
# store-route assertion reads the server's half of it.
|
||||
list(APPEND MGL_SPLIT_ARM_TEST_LISTS "MGL_SPLIT_ARM_TESTS_${MGL_SPLIT_ARM_INDEX}")
|
||||
math(EXPR MGL_SPLIT_ARM_INDEX "${MGL_SPLIT_ARM_INDEX} + 1")
|
||||
endforeach()
|
||||
# Magma, the control backend, GATED on its three arms: it reads the VkImage back whatever
|
||||
# the format, so it has no store route and no knob - only the copy and the read.
|
||||
set(mglItestMagmaCopyStoreProperties)
|
||||
if(mglItestArm STREQUAL "Tcp")
|
||||
set(mglItestMagmaCopyStoreProperties FIXTURES_REQUIRED mobilegl-tcp RESOURCE_LOCK mobilegl-tcp)
|
||||
endif()
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectVulkan.${mglItestArm}.CopyStore."
|
||||
TEST_LIST "MGL_SPLIT_ARM_TESTS_${MGL_SPLIT_ARM_INDEX}"
|
||||
TEST_FILTER "CopyImageStoreReadbackScenario.*"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES
|
||||
LABELS "integration-magma-${mglItestArmLower}"
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
ENVIRONMENT "${MGL_ITEST_VULKAN_${mglItestArmUpper}_ENVIRONMENT}"
|
||||
${mglItestMagmaCopyStoreProperties}
|
||||
)
|
||||
list(APPEND MGL_SPLIT_ARM_TEST_LISTS "MGL_SPLIT_ARM_TESTS_${MGL_SPLIT_ARM_INDEX}")
|
||||
math(EXPR MGL_SPLIT_ARM_INDEX "${MGL_SPLIT_ARM_INDEX} + 1")
|
||||
endforeach()
|
||||
|
||||
# The split half of the counting pair. MGITEST_PERSISTENT_MAP_ARM=emulated is R-6: under split
|
||||
# the adopt tier is pinned at T2, the resource owner declines every acquisition and the client
|
||||
# pushes the mapping's dirty blocks - so pmap must be non-zero and mpr must be the monolith
|
||||
@@ -3340,6 +3431,42 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_STRICT_ENVIRONMENT}"
|
||||
)
|
||||
|
||||
# P8-B: glGenerateMipmap ON ESPRYT'S SERVER (notes/p8/B.md). The window a record names (B1) and
|
||||
# RGB16F / RGB32F (B2) on the three Espryt arms; the Magma control is the gated
|
||||
# `DirectVulkan.<arm>.Mip.` block beside `Remint.`, and both monoliths come from the ambient
|
||||
# discovery. The FORCED-CPU entries run the three-channel cases with
|
||||
# MGITEST_ESPRYT_FORCE_CPU_MIPMAP=1, which the SERVER reads: inproc and spawn only, because the
|
||||
# tcp arm's server is the one shared TcpServer.Start fixture and the knob there would take the
|
||||
# native arm off every tcp entry. Their own label keeps the spawn-parity sets knob-free, as the
|
||||
# `RemintFallback.` entries do; integration-gpu is what runs them in the gate.
|
||||
mgl_itest_register_split_arms("GenerateMipmapServerScenario.*" "")
|
||||
foreach(mglItestArm IN ITEMS Split Spawn)
|
||||
string(TOUPPER "${mglItestArm}" mglItestArmUpper)
|
||||
string(TOLOWER "${mglItestArm}" mglItestArmLower)
|
||||
foreach(cpuMipCase Rgb16fUploadedBaseGeneratesItsChain
|
||||
Rgb16fRenderTargetBaseGeneratesFromTheGpuWrittenLevel
|
||||
Rgb32fUploadedBaseGeneratesItsChain
|
||||
Rgb32fRenderTargetBaseGeneratesFromTheGpuWrittenLevel)
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectGLES.${mglItestArm}.CpuMip."
|
||||
TEST_FILTER "GenerateMipmapServerScenario.${cpuMipCase}"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES
|
||||
LABELS "integration-gpu\\;integration-cpu-mip-${mglItestArmLower}"
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
ENVIRONMENT "${MGL_ITEST_GLES_${mglItestArmUpper}_ENVIRONMENT}\;MGITEST_ESPRYT_FORCE_CPU_MIPMAP=1\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/p8b-cpu-mip-${mglItestArmLower}-${cpuMipCase}.log")
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
# P8-C: draw inputs a compute shader wrote, read on the CPU by the side that applies the draw
|
||||
# (restart rewrite, multi-draw rebase, *IndirectCount, indirect gl_BaseVertex, an orphaned
|
||||
# indirect store). Split-only source, like F1: the ambient DirectGLES./DirectVulkan. entries
|
||||
# of the split build are the monolith control and the inproc A/B; this call adds the three
|
||||
# gated Espryt arms and records the Magma tier-2 replay (integration-magma-all-*).
|
||||
target_sources(MobileGLIntegrationTest PRIVATE Scenarios/GpuWrittenDrawInputScenario.cpp)
|
||||
mgl_itest_register_split_arms("GpuWrittenDrawInputScenario.*" "")
|
||||
|
||||
# The configure_file that used to sit here MOVED TO THE END OF THIS FILE (P6 `t6`).
|
||||
#
|
||||
# It substitutes @MGL_SPLIT_ARM_TEST_LISTS@, which the registration macro appends to - so
|
||||
@@ -3354,6 +3481,26 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Harness/split_log_paths.py"
|
||||
check "${CMAKE_CTEST_COMMAND}" "${CMAKE_BINARY_DIR}")
|
||||
set_tests_properties(SplitLogPaths.PrivateAndDistinct PROPERTIES LABELS "integration-split")
|
||||
|
||||
# P8-F: `Magma:mipmap-shader-format-or-shape` is a named DECLINE on the wire arm now
|
||||
# (WireDeclines.def MipmapShaderFormatOrShape), as the monolith arm's GenerateMipmap already
|
||||
# declines. The shape is a 3D chain with the native blit forced off - neither shader mip arm
|
||||
# takes it - and the knob is read BY THE SERVER, so split + spawn only (the ShaderMip entries'
|
||||
# tcp note below). Its own `.ShaderMipDecline.` tail is in MAGMA_SERVER_ENV_KNOB_NO_TCP
|
||||
# (scripts/ci/spawn_lane_parity.py: one tail per knob case). The Fm lane's flavour plus the arm.
|
||||
foreach(mglItestArm IN ITEMS Split Spawn)
|
||||
mgl_itest_magma_arm_shape(${mglItestArm})
|
||||
mgl_itest_join_environment(mglItestP8fMipEnvironment
|
||||
"MOBILEGL_BACKEND_TYPE=DirectVulkan" "MOBILEGL_ITEST_REQUIRE_GPU=1" "MGITEST_SPLIT_LANE=1"
|
||||
${MGL_ITEST_CAPABILITY_ENV} ${MGL_ITEST_VULKAN_ENV} ${mglItestArmTransportEnv})
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectVulkan.${mglItestArm}.ShaderMipDecline."
|
||||
TEST_FILTER "F1WireScenario.GenerateMipmapWithoutAShaderArmShapeDeclinesAndKeepsTheSession"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES LABELS "${mglItestMagmaLabels}" TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
${mglItestArmProperties}
|
||||
ENVIRONMENT "${mglItestP8fMipEnvironment}\;MGITEST_MAGMA_FORCE_SHADER_MIPMAP=1\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/p8f-shadermip-decline${mglItestArmLogTag}.log")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# f1: split-only source keeps the monolith registry unchanged.
|
||||
@@ -4025,6 +4172,35 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# P8-B: THE MAGMA CONTROL for GenerateMipmapServerScenario, all three arms, GATED, in the band
|
||||
# flavour. Magma generates every case on the GPU (GenerateWireMipmap), so these entries say what
|
||||
# the Espryt arms above must match. One entry per case for a private log each.
|
||||
if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
foreach(mglItestArm IN LISTS MGL_ITEST_MAGMA_ARMS)
|
||||
mgl_itest_magma_arm_shape(${mglItestArm})
|
||||
mgl_itest_join_environment(mglItestMagmaMipEnvironment
|
||||
${MGL_ITEST_MAGMA_BAND_FLAVOUR_ENV} ${mglItestArmTransportEnv})
|
||||
foreach(mipCase PackedFloatMutableMaxLevelBelowTheChain
|
||||
PackedFloatStorageWithFewerLevelsThanTheChain
|
||||
PackedFloatMutableBaseLevelOneKeepsTheLevelsOutsideItsWindow
|
||||
DepthMutableMaxLevelBelowTheChain
|
||||
DepthStorageWithFewerLevelsThanTheChain
|
||||
DepthMutableBaseLevelOneKeepsTheLevelsOutsideItsWindow
|
||||
Rgb16fUploadedBaseGeneratesItsChain
|
||||
Rgb16fRenderTargetBaseGeneratesFromTheGpuWrittenLevel
|
||||
Rgb32fUploadedBaseGeneratesItsChain
|
||||
Rgb32fRenderTargetBaseGeneratesFromTheGpuWrittenLevel)
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectVulkan.${mglItestArm}.Mip."
|
||||
TEST_FILTER "GenerateMipmapServerScenario.${mipCase}"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES LABELS "${mglItestMagmaLabels}" TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
${mglItestArmProperties}
|
||||
ENVIRONMENT "${mglItestMagmaMipEnvironment}\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/p8b-mip${mglItestArmLogTag}-${mipCase}.log")
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# P11 M: DEV'S TWO GPU-CONTENT SCENARIOS ON MAGMA, all three arms, GATED, in the band flavour -
|
||||
# ImageBindableRemintScenario (Magma is its control backend: a storage upgrade copies image to
|
||||
# image) and PartialUploadOverGpuContentScenario (8966d5c2's RGB->RGBA region cut and b1d60523's
|
||||
@@ -4648,6 +4824,158 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# P8-A
|
||||
if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/P8Coverage.cmake)
|
||||
endif()
|
||||
|
||||
# P8-D: the Magma wire arm issues indirect draws natively (docs/Disaggregated/notes/p8/D.md).
|
||||
# Public GL, so the source joins the binary unguarded and the ambient `DirectGLES.` /
|
||||
# `DirectVulkan.` monolith discovery runs it too. Split arms: DirectGLES through the registration
|
||||
# macro (which also replays it on Magma's informational tier), Magma's gated tier by hand, all
|
||||
# three transports - the counter halves read only on the inproc arm (WireIndirectPeek.h) and the
|
||||
# pixel halves everywhere, so there is no arm-only property to declare.
|
||||
target_sources(MobileGLIntegrationTest PRIVATE Harness/WireIndirectPeek.cpp Scenarios/WireIndirectDrawScenario.cpp)
|
||||
if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
mgl_itest_register_split_arms("WireIndirectDrawScenario.*" "")
|
||||
set(MGL_ITEST_MAGMA_INDIRECT_FLAVOUR_ENV
|
||||
"MOBILEGL_BACKEND_TYPE=DirectVulkan"
|
||||
"MOBILEGL_IPC_ROLE_SPLIT_STATE=1" "MOBILEGL_IPC_STRICT_ERRORS=1"
|
||||
"MOBILEGL_ITEST_REQUIRE_GPU=1" "MGITEST_SPLIT_LANE=1"
|
||||
${MGL_ITEST_CAPABILITY_ENV} ${MGL_ITEST_VULKAN_ENV})
|
||||
foreach(mglItestArm IN LISTS MGL_ITEST_MAGMA_ARMS)
|
||||
mgl_itest_magma_arm_shape(${mglItestArm} indirect)
|
||||
mgl_itest_join_environment(MGL_ITEST_MAGMA_INDIRECT_ENVIRONMENT
|
||||
${MGL_ITEST_MAGMA_INDIRECT_FLAVOUR_ENV} ${mglItestArmTransportEnv})
|
||||
foreach(indirectCase
|
||||
EveryIndirectFormIsIssuedNativelyFromItsStore
|
||||
ComputeWrittenCommandsDrawWithoutAHostWait
|
||||
ComputeWrittenCountWordIsTheOneTheGpuReads
|
||||
ShaderWrittenCommandsWithoutAnApplicationBarrierAreOrdered)
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectVulkan.${mglItestArm}.Indirect."
|
||||
TEST_FILTER "WireIndirectDrawScenario.${indirectCase}"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES LABELS "${mglItestMagmaLabels}"
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
${mglItestArmProperties}
|
||||
ENVIRONMENT "${MGL_ITEST_MAGMA_INDIRECT_ENVIRONMENT}\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/magma-indirect${mglItestArmLogTag}-${indirectCase}.log")
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# P8-SE (docs/Disaggregated/notes/p8/SE.md): Espryt split residuals.
|
||||
if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
# The default framebuffer's depth/stencil format reaches a spawn / tcp client now (the server
|
||||
# process has no frontend placeholder, and the publish used to return on it before posting),
|
||||
# so the case A left as `pending-fix` joins the three Espryt arms.
|
||||
mgl_itest_register_split_arms(
|
||||
"DepthStencilReadbackAttachmentShapeScenario.DefaultFramebufferDepthStencilFormatIsBlitCompatible" "")
|
||||
# B2's CPU mip arm x P8-E's driver-written mark: the forced-CPU knob plus E's refused-readback
|
||||
# knob at the base level's extent (16x16), both read by the SERVER - so inproc and spawn only,
|
||||
# and their own label as B's `CpuMip.` entries have (the tcp arm's server is the shared
|
||||
# TcpServer.Start fixture, and the refusal there would reach every 16x16 colour readback).
|
||||
foreach(mglItestArm IN ITEMS Split Spawn)
|
||||
string(TOUPPER "${mglItestArm}" mglItestArmUpper)
|
||||
string(TOLOWER "${mglItestArm}" mglItestArmLower)
|
||||
foreach(cpuMipCase Rgb16fDrawnBaseWithARefusedReadbackDeclinesByName
|
||||
Rgb16fUploadedBaseWithARefusedReadbackIsFilteredFromTheStore)
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectGLES.${mglItestArm}.CpuMipRefused."
|
||||
TEST_FILTER "GenerateMipmapServerScenario.${cpuMipCase}"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES
|
||||
LABELS "integration-gpu\\;integration-cpu-mip-${mglItestArmLower}"
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
ENVIRONMENT "${MGL_ITEST_GLES_${mglItestArmUpper}_ENVIRONMENT}\;MGITEST_ESPRYT_FORCE_CPU_MIPMAP=1\;MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT=16x16\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/p8se-cpu-mip-refused-${mglItestArmLower}-${cpuMipCase}.log")
|
||||
endforeach()
|
||||
endforeach()
|
||||
# PipeCatalogueTest's unmigrated-emulation list against the call sites in the tree (a source
|
||||
# lint, so the unit lane runs it wherever the split build's unit tests run; CI also runs it
|
||||
# beside split_coverage.py).
|
||||
add_test(NAME PipeCatalogue.UnmigratedEmulationSitesSelfTest
|
||||
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/scripts/ci/unmigrated_emulation_sites.py" --self-test)
|
||||
add_test(NAME PipeCatalogue.UnmigratedEmulationSitesMatchTheList
|
||||
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/scripts/ci/unmigrated_emulation_sites.py"
|
||||
"${CMAKE_SOURCE_DIR}")
|
||||
set_tests_properties(PipeCatalogue.UnmigratedEmulationSitesSelfTest
|
||||
PipeCatalogue.UnmigratedEmulationSitesMatchTheList PROPERTIES LABELS unit TIMEOUT 60)
|
||||
endif()
|
||||
|
||||
# P8-SV: Magma split residuals (docs/Disaggregated/notes/p8/SV.md) - the 3D native mip blit's layer
|
||||
# count, the 1D depth mip decline, the depth/stencil mip decline's tally row (asserted inside
|
||||
# F1WireScenario) and the wire arm's native glDispatchComputeIndirect. Public GL, so the sources join
|
||||
# the binary unguarded and the ambient `DirectGLES.` / `DirectVulkan.` monolith discovery runs them
|
||||
# too (the Espryt entries are the control). Split arms: DirectGLES through the registration macro
|
||||
# (which also replays them on Magma's informational tier), Magma's gated tier by hand:
|
||||
# `.Mip3D.` and `.IndirectDispatch.` - all three transports; the counter halves read only on the
|
||||
# inproc arm (WireIndirectPeek.h, WireDeclinePeek.h), the pixel/grid halves everywhere.
|
||||
# `.ShaderMipDepth1D.` - split + spawn: MGITEST_MAGMA_FORCE_SHADER_MIPMAP is read BY THE SERVER,
|
||||
# so a tcp copy would run the default arm (its tail is in spawn_lane_parity.py's
|
||||
# MAGMA_SERVER_ENV_KNOB_NO_TCP).
|
||||
# `.Mip3DValidation.` - inproc only: the 3D chain under VK_LAYER_KHRONOS_validation, red on any
|
||||
# vkCmdBlitImage VUID in the output. The server's Vulkan instance must be this process for its
|
||||
# stdout to be the entry's and for the case to prove the layer loaded (/proc/self/maps), so it
|
||||
# is in MAGMA_INPROC_ONLY. The lane that runs integration-magma-split in CI installs the layer.
|
||||
target_sources(MobileGLIntegrationTest PRIVATE Harness/WireDeclinePeek.cpp Scenarios/WireMipShapeScenario.cpp
|
||||
Scenarios/WireIndirectDispatchScenario.cpp)
|
||||
if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
mgl_itest_register_split_arms("WireMipShapeScenario.*" "")
|
||||
mgl_itest_register_split_arms("WireIndirectDispatchScenario.*" "")
|
||||
set(MGL_ITEST_MAGMA_SV_FLAVOUR_ENV
|
||||
"MOBILEGL_BACKEND_TYPE=DirectVulkan"
|
||||
"MOBILEGL_IPC_ROLE_SPLIT_STATE=1" "MOBILEGL_IPC_STRICT_ERRORS=1"
|
||||
"MOBILEGL_ITEST_REQUIRE_GPU=1" "MGITEST_SPLIT_LANE=1"
|
||||
${MGL_ITEST_CAPABILITY_ENV} ${MGL_ITEST_VULKAN_ENV})
|
||||
foreach(mglItestArm IN LISTS MGL_ITEST_MAGMA_ARMS)
|
||||
mgl_itest_magma_arm_shape(${mglItestArm})
|
||||
mgl_itest_join_environment(MGL_ITEST_MAGMA_SV_ENVIRONMENT
|
||||
${MGL_ITEST_MAGMA_SV_FLAVOUR_ENV} ${mglItestArmTransportEnv})
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectVulkan.${mglItestArm}.Mip3D."
|
||||
TEST_FILTER "WireMipShapeScenario.VolumeChainIsGeneratedAlongItsDepth"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES LABELS "${mglItestMagmaLabels}"
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
${mglItestArmProperties}
|
||||
ENVIRONMENT "${MGL_ITEST_MAGMA_SV_ENVIRONMENT}\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/magma-sv-mip3d${mglItestArmLogTag}.log")
|
||||
foreach(dispatchCase
|
||||
CpuWrittenGroupCountsAreReadByTheGpuAtTheirOffsets
|
||||
ComputeWrittenGroupCountsDispatchWithoutAHostWait
|
||||
ShaderWrittenGroupCountsWithoutAnApplicationBarrierAreOrdered)
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectVulkan.${mglItestArm}.IndirectDispatch."
|
||||
TEST_FILTER "WireIndirectDispatchScenario.${dispatchCase}"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES LABELS "${mglItestMagmaLabels}"
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
${mglItestArmProperties}
|
||||
ENVIRONMENT "${MGL_ITEST_MAGMA_SV_ENVIRONMENT}\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/magma-sv-dispatch${mglItestArmLogTag}-${dispatchCase}.log")
|
||||
endforeach()
|
||||
if (NOT mglItestArm STREQUAL "Tcp")
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectVulkan.${mglItestArm}.ShaderMipDepth1D."
|
||||
TEST_FILTER "WireMipShapeScenario.Depth1DChainWithoutANativeBlitDeclinesByName"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES LABELS "${mglItestMagmaLabels}"
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
${mglItestArmProperties}
|
||||
ENVIRONMENT "${MGL_ITEST_MAGMA_SV_ENVIRONMENT}\;MGITEST_MAGMA_FORCE_SHADER_MIPMAP=1\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/magma-sv-depth1d${mglItestArmLogTag}.log")
|
||||
endif()
|
||||
endforeach()
|
||||
mgl_itest_magma_arm_shape(Split)
|
||||
mgl_itest_join_environment(MGL_ITEST_MAGMA_SV_ENVIRONMENT
|
||||
${MGL_ITEST_MAGMA_SV_FLAVOUR_ENV} ${mglItestArmTransportEnv})
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectVulkan.Split.Mip3DValidation."
|
||||
TEST_FILTER "WireMipShapeScenario.VolumeChainIsGeneratedAlongItsDepth"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES LABELS "${mglItestMagmaLabels}"
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
FAIL_REGULAR_EXPRESSION "VUID-vkCmdBlitImage-"
|
||||
ENVIRONMENT "${MGL_ITEST_MAGMA_SV_ENVIRONMENT}\;VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation\;MGITEST_REQUIRE_VK_VALIDATION_LAYER=1\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/magma-sv-mip3d-validation.log")
|
||||
endif()
|
||||
|
||||
# =====================================================================================
|
||||
# P7 PACKAGE L: THE INFORMATIONAL MAGMA CENSUS - TIER 2 OF TWO
|
||||
# =====================================================================================
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Harness/WireDeclinePeek.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
|
||||
|
||||
#include "WireDeclinePeek.h"
|
||||
|
||||
#if !defined(__ANDROID__)
|
||||
#include <Config.h>
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
#include <MG_Backend/DirectVulkan/Renderer/WireDeclineTally.h>
|
||||
#include <cstring>
|
||||
#define MGITEST_WIRE_DECLINE_PEEK_LIVE 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace MGITest {
|
||||
|
||||
#if defined(MGITEST_WIRE_DECLINE_PEEK_LIVE)
|
||||
bool PeekWireDeclineCount(const char* row, unsigned long long* out) {
|
||||
if (row == nullptr || out == nullptr) return false;
|
||||
namespace Magma = MobileGL::MG_Backend::DirectVulkan;
|
||||
for (MobileGL::SizeT i = 0; i < Magma::WireDeclineTally::kSiteCount; ++i) {
|
||||
const auto site = static_cast<Magma::WireDeclineSite>(i);
|
||||
if (std::strcmp(Magma::WireDeclineSiteName(site), row) != 0) continue;
|
||||
*out = Magma::WireDeclineTally::Get(site);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
bool PeekWireDeclineCount(const char*, unsigned long long*) { return false; }
|
||||
#endif
|
||||
|
||||
} // namespace MGITest
|
||||
@@ -0,0 +1,20 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Harness/WireDeclinePeek.h
|
||||
// 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
|
||||
//
|
||||
// P8-SV: one row of the Magma wire arm's decline tally (WireDeclines.def, the counts behind the
|
||||
// server's MGWIRE-DECLINES lines), read as a run total out of THIS process - WireIndirectPeek.h's
|
||||
// shape. Process-wide means the SERVER's counts only where the server is this process: the inproc
|
||||
// arm, never spawn or tcp, and never the monolith arm, which takes no wire path. False where the
|
||||
// reading cannot be taken: a pull build, Android, or a name that is not a row.
|
||||
#pragma once
|
||||
|
||||
namespace MGITest {
|
||||
|
||||
bool PeekWireDeclineCount(const char* row, unsigned long long* out);
|
||||
|
||||
} // namespace MGITest
|
||||
@@ -0,0 +1,38 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Harness/WireIndirectPeek.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
|
||||
|
||||
#include "WireIndirectPeek.h"
|
||||
|
||||
#if !defined(__ANDROID__)
|
||||
#include <MG_Pipe/MGPipe.h>
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
#include <MG_Util/Metrics/PipeStats.h>
|
||||
#define MGITEST_WIRE_INDIRECT_PEEK_LIVE 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace MGITest {
|
||||
|
||||
#if defined(MGITEST_WIRE_INDIRECT_PEEK_LIVE)
|
||||
bool PeekWireIndirectCounters(WireIndirectCounters* out) {
|
||||
if (out == nullptr) return false;
|
||||
namespace Stats = MobileGL::MG_Util::PipeStats;
|
||||
if (!Stats::Enabled()) Stats::SetEnabledForTesting(true);
|
||||
out->nativeDraws = Stats::TotalCalls(Stats::CallClass::WireIndirectNativeDraws);
|
||||
out->cpuExpansions = Stats::TotalCalls(Stats::CallClass::WireIndirectCpuExpansions);
|
||||
out->barriers = Stats::TotalCalls(Stats::CallClass::WireIndirectBarriers);
|
||||
out->hostWaits = Stats::TotalCalls(Stats::CallClass::WireHostWaits);
|
||||
out->indirectWaits = Stats::TotalCalls(Stats::CallClass::WireHostWaitsIndirect);
|
||||
out->nativeDispatches = Stats::TotalCalls(Stats::CallClass::WireIndirectNativeDispatches);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
bool PeekWireIndirectCounters(WireIndirectCounters*) { return false; }
|
||||
#endif
|
||||
|
||||
} // namespace MGITest
|
||||
@@ -0,0 +1,29 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Harness/WireIndirectPeek.h
|
||||
// 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
|
||||
//
|
||||
// P8-D: the Magma wire arm's indirect-draw counters (PipeStats `windr[...]`), read as run totals
|
||||
// out of THIS process - P4aFinalFixPeek.cpp's shape. Process-wide means the SERVER's counts only
|
||||
// where the server is this process: monolith and inproc, never spawn or tcp. The first call arms
|
||||
// the counters (a case reads before and after its workload, so it must peek before it draws).
|
||||
// False where the reading cannot be taken: a pull build, Android.
|
||||
#pragma once
|
||||
|
||||
namespace MGITest {
|
||||
|
||||
struct WireIndirectCounters {
|
||||
unsigned long long nativeDraws = 0; // wire-indirect-native-draws (`wind`)
|
||||
unsigned long long cpuExpansions = 0; // wire-indirect-cpu-expansions (`wixp`)
|
||||
unsigned long long barriers = 0; // wire-indirect-barriers (`wibar`)
|
||||
unsigned long long hostWaits = 0; // wire-host-waits (`whw`)
|
||||
unsigned long long indirectWaits = 0; // wire-host-waits-indirect (`whwi`)
|
||||
unsigned long long nativeDispatches = 0; // P8-SV: wire-indirect-native-dispatches (`wdsp`)
|
||||
};
|
||||
|
||||
bool PeekWireIndirectCounters(WireIndirectCounters* out);
|
||||
|
||||
} // namespace MGITest
|
||||
@@ -0,0 +1,244 @@
|
||||
# P8-A (ID-P8-2): the monolith cases' split, spawn and tcp registrations.
|
||||
#
|
||||
# Included ONCE from CMakeLists.txt, inside `if (MOBILEGL_BUILD_DISAGGREGATED)`, and the place is
|
||||
# load-bearing twice over: it must come BEFORE the Magma tier-2 replay (every
|
||||
# mgl_itest_register_split_arms call here is replayed onto DirectVulkan's informational
|
||||
# integration-magma-all-{split,spawn,tcp} arms from MGL_SPLIT_ARM_CALLS) and BEFORE the
|
||||
# SplitLogPaths configure_file at the end of that file (every entry here gets its private
|
||||
# MOBILEGL_LOG_FILE_PATH from MGL_SPLIT_ARM_TEST_LISTS, or SplitLogPaths.PrivateAndDistinct reds).
|
||||
#
|
||||
# THE GATE IS scripts/ci/split_coverage.py: after the arm and tail segments come off, every
|
||||
# monolith DirectGLES. / DirectVulkan. case is on a gated split arm or is named, with a reason
|
||||
# class, in scripts/data/split_coverage_exemptions.txt. Deleting a line below reds it BY NAME.
|
||||
# The per-case census this list was cut from (inproc / spawn / tcp, junit per arm) is
|
||||
# docs/Disaggregated/notes/p8/A.md.
|
||||
|
||||
# ---- (a) THE AMBIENT CASES -----------------------------------------------------------------
|
||||
#
|
||||
# Every case here was registered on monolith only, and on all three arms under the armed split
|
||||
# environment it either PASSED (records crossed: ScenarioFixture's EmitSeq assertion is armed on
|
||||
# these arms) or SKIPPED for the same reason its monolith entry skips on this host (ClipDistance,
|
||||
# DualSourceBlend, IterationRP*, SsboDeclarationForm's two known gaps, and the knob-pinned cases
|
||||
# the (a') block below runs with their knob). Cases that belong to monolith by nature are in the
|
||||
# exemption table instead, never here: no-records (limits / shader-binary queries answered from
|
||||
# the caps mirror), single-backend (Magma-only lanes and declines), mechanism, pending-fix.
|
||||
#
|
||||
# ONE FILTER, not one call per scenario: each call is three discovery runs plus three more for
|
||||
# the Magma replay. Explicit names where a scenario is split between registered and exempt
|
||||
# cases; `Scenario.*` only where every case of the scenario is here.
|
||||
set(MGL_P8A_AMBIENT_CASES
|
||||
AdvertisedLimitsScenario.ImageUnitBindingsAreReportedFromTheFrontendState
|
||||
AdvertisedLimitsScenario.IndexedBufferBindingsAreReportedVerbatimOnBothWidths
|
||||
BufferTextureScenario.*
|
||||
ClearTexImageUndefinedLevelZeroScenario.*
|
||||
ClipDistanceScenario.*
|
||||
CopyImageLevelRangeScenario.*
|
||||
CopyImagePacked16Scenario.*
|
||||
CrossFrameBufferScenario.*
|
||||
DefaultFramebufferAcrossSwapScenario.*
|
||||
DepthStencilReadbackAttachmentShapeScenario.DepthOfALayeredCubeAttachmentReadsBack
|
||||
DepthStencilReadbackAttachmentShapeScenario.DepthOfAPlainTexture2DAttachmentReadsBack
|
||||
DepthStencilReadbackAttachmentShapeScenario.DepthOfAnArrayLayerAttachmentReadsBack
|
||||
DepthStencilReadbackAttachmentShapeScenario.PackedArrayLayerAttachmentReadsBackBothAspects
|
||||
DepthStencilReadbackScenario.*
|
||||
DoublePrecisionScenario.*
|
||||
DualSourceBlendScenario.*
|
||||
EmptyScissorScenario.*
|
||||
F1WireScenario.ColorBlitToDefaultFromANonSampleableSourceDegrades
|
||||
F1WireScenario.ColorBlitToDefaultHonorsScissorAndReversedRect
|
||||
F1WireScenario.ColorBlitToDefaultIgnoresViewportAndPreservesOrientation
|
||||
F1WireScenario.ComputeImageStoreFramebufferPixels
|
||||
F1WireScenario.ComputeImageStoreThroughViewPreservesOtherRootLayer
|
||||
F1WireScenario.ComputeWrittenVertexAndIndexBuffersDrawAndReadBack
|
||||
F1WireScenario.CopyImageInPlaceAcrossLevelsAndLayers
|
||||
F1WireScenario.EnabledVertexBufferDrawKeepsNamedP7Fatal
|
||||
F1WireScenario.GenerateMipmapHonorsMutableBaseAndMaxWithoutChangingOtherLevels
|
||||
F1WireScenario.GenerateMipmapThroughViewKeepsOwnerLevelsAndLayersOutsideItsWindow
|
||||
F1WireScenario.MultisampleColorBlitScalesAndFlipsThroughTheResolveScratch
|
||||
F1WireScenario.PartialTextureUploadPreservesGpuClearPixels
|
||||
F1WireScenario.SrgbDrawTracksFramebufferConversion
|
||||
F1WireScenario.StreamedBufferSubDataBeforeEachDrawIsOrdered
|
||||
F1WireScenario.Texture1DFramebufferClearPixels
|
||||
F1WireScenario.TextureReadbackLargerThanAReplySlotContainsGpuWrites
|
||||
F1WireScenario.TextureViewClearTargetsItsRootMipAndLayer
|
||||
F1WireScenario.UniformBufferRangeAndRebindPixels
|
||||
F1WireScenario.VertexIdSamplerAndScalarUniformPixels
|
||||
FormatlessImageBakeScenario.*
|
||||
FragCoordOriginScenario.*
|
||||
FragmentOutputArrayIndexScenario.*
|
||||
GeometryDrawModeScenario.*
|
||||
GuiBatchScenario.*
|
||||
# dev f973008c merge: the empty-binding uniform block (853c5f12 + P11 7784d6bb)
|
||||
UnboundUniformBlockScenario.*
|
||||
ImageFormatQualifierScenario.*
|
||||
ImageLoadStoreSsoScenario.PerElementImageUnitsReachAPipelineDraw
|
||||
ImageLoadStoreSsoScenario.ReassigningAnImageUnitBetweenDrawsReachesTheNextDraw
|
||||
IterationRPFirstReductionScenario.*
|
||||
IterationRPProgram203Scenario.*
|
||||
IterationRPScratchFixScenario.*
|
||||
LayeredAttachmentBarrierScenario.*
|
||||
LayeredAttachmentShapeScenario.*
|
||||
NonCoreImageFormatScenario.*
|
||||
OrientationScenario.*
|
||||
P4aFinalFixScenario.*
|
||||
P4aSeamAuditScenario.*
|
||||
PipelineFailureScenario.*
|
||||
PointSizeDemotionScenario.*
|
||||
ProgramPipelineScenario.ASamplerUnitRewrittenBetweenDrawsKeepsPaintingTheRightTexture
|
||||
ProgramPipelineScenario.AStageProgramsUniformBlockBindingReachesThePipelineDraw
|
||||
ProgramPipelineScenario.ATwoStagePipelinePaintsWhatItsStagesDescribe
|
||||
ProgramPipelineScenario.AUniformDeclaredInTwoStagesKeepsTheValueTheWrittenStageHolds
|
||||
ProgramPipelineScenario.ComputeAndGraphicsStagesShareOnePipeline
|
||||
ProgramPipelineScenario.RebindingAUniformBlockBetweenDrawsReachesTheNextDraw
|
||||
ProgramPipelineScenario.SwitchingBetweenAPipelineAndAMonolithicProgramLeavesNoError
|
||||
ProgramPipelineScenario.UniformsGoToTheActiveShaderProgram
|
||||
RenderbufferBlendFormatScenario.*
|
||||
ResidentIndexScenario.*
|
||||
SampleMaskScopeScenario.*
|
||||
SampleVariablesScenario.*
|
||||
SnormAttachmentScenario.*
|
||||
SpirvShaderBinaryScenario.SpecializedModulesLinkAndRenderWithTheirConstantsApplied
|
||||
SsboArrayDynamicIndexScenario.*
|
||||
SsboArrayLengthScenario.*
|
||||
SsboDeclarationFormScenario.*
|
||||
StorageBufferRegrowScenario.AGrownStoreIsVisibleThroughItsExistingIndexedBinding
|
||||
StreamedArenaScenario.*
|
||||
TessellationDrawModeScenario.*
|
||||
ThreeChannelAttachmentScenario.*
|
||||
UnboundCounterBlockScenario.*
|
||||
UnlocatedIoBlockScenario.*
|
||||
UnwrittenPositionOutputScenario.ARedeclaredButUnwrittenPositionStillDraws
|
||||
UnwrittenPositionOutputScenario.AShaderWithNoPositionBlockStillDraws
|
||||
UnwrittenPositionOutputScenario.AWrittenRedeclaredPositionStillDraws
|
||||
UnwrittenPositionOutputScenario.CapturingAWrittenPositionStillDraws
|
||||
VertexArrayEnableDisableScenario.*
|
||||
VertexAttribBindingScenario.*
|
||||
ViewportArrayScenario.*
|
||||
)
|
||||
list(JOIN MGL_P8A_AMBIENT_CASES ":" mglP8aAmbientFilter)
|
||||
mgl_itest_register_split_arms("${mglP8aAmbientFilter}" "")
|
||||
|
||||
# ---- (a') THE SERVER-READ KNOB LANES, EACH WITH A TCP SUPERVISOR OF ITS OWN ------------------
|
||||
#
|
||||
# The monolith file pins five whole-process knobs in lanes of their own (PointSizeDemotion.,
|
||||
# UnlocatedIoBlocks., NoViewportArrayEmulation., WidenedPacked16., ForcedDepthStencilEmulation.),
|
||||
# because without them the cases are unfalsifiable on llvmpipe or skip. Every one of the five is
|
||||
# read through ConfigLoader IN THE PROCESS THAT RUNS THE BACKEND - the server. Under inproc that
|
||||
# is this process and under spawn the child inherits ::environ, so the entry's ENVIRONMENT
|
||||
# reaches it; under tcp the server is a supervisor started by a fixture, and the lane-wide
|
||||
# TcpServer.Start supervisor never sees a per-entry variable. MEASURED on this tree before this
|
||||
# block existed: with the knob in the client's environment only, the Tcp copies of
|
||||
# PointSizeDemotion's and UnlocatedIoBlocks' arming cases read no arming line and
|
||||
# NoViewportArrayEmulation's negative control saw the emulation still on - red, where the Split
|
||||
# and Spawn copies were green.
|
||||
#
|
||||
# THE KNOB CANNOT GO ON THE SHARED FIXTURE (the IC TcpServer.Start precedent, which works for
|
||||
# MOBILEGL_ESPRYT_ENABLE_TEXTURE_VIEW only because every arm sets that one): it would retarget
|
||||
# every other tcp case - viewport emulation off breaks ViewportArrayScenario's positive cases,
|
||||
# the IO-block strip rewrites every interface block. So each lane gets a supervisor of its own,
|
||||
# on its own port, started by its own fixture with the knob in the fixture's ENVIRONMENT.
|
||||
#
|
||||
# THE PORTS: the lane endpoint's port + MOBILEGL_ITEST_TCP_KNOB_PORT_OFFSET + the lane's index.
|
||||
# The default offset (1000) keeps the five clear of every per-tree lane endpoint in use (40613
|
||||
# CI, 407xx / 409xx split and verify builds, 484x0 package trees). One overlap remains: a tree
|
||||
# whose split and verify builds sit one port apart (409x3 / 409x4) gets knob ports one apart as
|
||||
# well, so the two builds must not run integration-tcp at the same moment - set the cache
|
||||
# variable differently in one of them if they ever do.
|
||||
#
|
||||
# THE LOCK IS STILL mobilegl-tcp: spawn_lane_parity.py / junit_tally.py require it of every
|
||||
# integration-tcp entry, and one tcp session at a time is what every other tcp entry assumes.
|
||||
#
|
||||
# NOT FOR DirectVulkan: all five knobs are Espryt's (Magma routes viewports natively, has no
|
||||
# IO-block strip, no packed-16 widening, no DS readback emulation; point-size demotion's Magma
|
||||
# lane is monolith-only and stays so here).
|
||||
set(MOBILEGL_ITEST_TCP_KNOB_PORT_OFFSET 1000 CACHE STRING
|
||||
"Port offset (from MOBILEGL_ITEST_TCP_ENDPOINT's) of the per-knob loopback supervisors")
|
||||
if(NOT MOBILEGL_ITEST_TCP_ENDPOINT MATCHES "^(tcp://.+):([0-9]+)$")
|
||||
message(FATAL_ERROR "P8-A: MOBILEGL_ITEST_TCP_ENDPOINT '${MOBILEGL_ITEST_TCP_ENDPOINT}' is not "
|
||||
"tcp://<host>:<port>; the per-knob tcp supervisors derive their ports from it")
|
||||
endif()
|
||||
set(mglP8aTcpHost "${CMAKE_MATCH_1}")
|
||||
set(mglP8aTcpPort "${CMAKE_MATCH_2}")
|
||||
|
||||
set(MGL_P8A_KNOB_LANES PointSizeDemotion UnlocatedIoBlocks NoViewportArrayEmulation WidenedPacked16
|
||||
ForcedDs)
|
||||
set(MGL_P8A_KNOB_FILTER_PointSizeDemotion "PointSizeDemotionScenario.*")
|
||||
set(MGL_P8A_KNOB_ENV_PointSizeDemotion "MOBILEGL_POINT_SIZE_DEMOTION=1")
|
||||
set(MGL_P8A_KNOB_FILTER_UnlocatedIoBlocks "UnlocatedIoBlockScenario.*")
|
||||
set(MGL_P8A_KNOB_ENV_UnlocatedIoBlocks "MOBILEGL_ESPRYT_UNLOCATED_IO_BLOCKS=1")
|
||||
# One case, as on monolith: the three positive cases describe behaviour the backend does not
|
||||
# have with the emulation off.
|
||||
set(MGL_P8A_KNOB_FILTER_NoViewportArrayEmulation
|
||||
"ViewportArrayScenario.WithoutTheEmulationEveryIndexCollapsesOntoViewportZero")
|
||||
set(MGL_P8A_KNOB_ENV_NoViewportArrayEmulation "MOBILEGL_ESPRYT_FORCE_VIEWPORT_ARRAY_EMULATION=0")
|
||||
set(MGL_P8A_KNOB_FILTER_WidenedPacked16 "CopyImagePacked16Scenario.*")
|
||||
set(MGL_P8A_KNOB_ENV_WidenedPacked16 "MOBILEGL_ESPRYT_WIDEN_PACKED16_STORAGE=1")
|
||||
# ForcedDs keeps the spelling the existing Split/Spawn DepthStencilReadbackMatrix block uses. The
|
||||
# default-framebuffer case was left out here while it was red on spawn and tcp; P8-SE fixed it
|
||||
# (notes/p8/SE.md) and it runs under the knob on every arm like the rest.
|
||||
set(MGL_P8A_KNOB_FILTER_ForcedDs
|
||||
"DepthStencilReadbackScenario.*:DepthStencilReadbackAttachmentShapeScenario.*")
|
||||
set(MGL_P8A_KNOB_ENV_ForcedDs "MOBILEGL_ESPRYT_FORCE_DS_READBACK_EMULATION=1")
|
||||
# The Matrix scenario's Tcp copy moves HERE from the ForcedDs block (same names): that block
|
||||
# put the knob in the client's environment only, so its Tcp arm ran the native readback path.
|
||||
set(MGL_P8A_KNOB_TCP_FILTER_ForcedDs
|
||||
"DepthStencilReadbackMatrixScenario.*:${MGL_P8A_KNOB_FILTER_ForcedDs}")
|
||||
|
||||
set(mglP8aKnobIndex 0)
|
||||
foreach(mglP8aLane IN LISTS MGL_P8A_KNOB_LANES)
|
||||
string(TOLOWER "${mglP8aLane}" mglP8aLaneLower)
|
||||
math(EXPR mglP8aKnobPort "${mglP8aTcpPort} + ${MOBILEGL_ITEST_TCP_KNOB_PORT_OFFSET} + ${mglP8aKnobIndex}")
|
||||
math(EXPR mglP8aKnobIndex "${mglP8aKnobIndex} + 1")
|
||||
set(mglP8aKnobEndpoint "${mglP8aTcpHost}:${mglP8aKnobPort}")
|
||||
set(mglP8aKnobFixture "mobilegl-tcp-p8a-${mglP8aLaneLower}")
|
||||
set(mglP8aKnobState "${CMAKE_CURRENT_BINARY_DIR}/tcp-server-p8a-${mglP8aLaneLower}.json")
|
||||
set(mglP8aKnob "${MGL_P8A_KNOB_ENV_${mglP8aLane}}")
|
||||
add_test(NAME TcpServer.Start.P8a${mglP8aLane} COMMAND "${Python3_EXECUTABLE}" "${MGL_TCP_FIXTURE}"
|
||||
start --server "${MGL_ITEST_SPLIT_SERVER_PATH}" --endpoint "${mglP8aKnobEndpoint}"
|
||||
--state "${mglP8aKnobState}")
|
||||
add_test(NAME TcpServer.Stop.P8a${mglP8aLane} COMMAND "${Python3_EXECUTABLE}" "${MGL_TCP_FIXTURE}"
|
||||
stop --state "${mglP8aKnobState}")
|
||||
# The texture-view opt-in as on the shared fixture, so this supervisor differs from it in
|
||||
# the knob alone.
|
||||
set_tests_properties(TcpServer.Start.P8a${mglP8aLane} PROPERTIES
|
||||
FIXTURES_SETUP ${mglP8aKnobFixture} TIMEOUT 20
|
||||
ENVIRONMENT "MOBILEGL_ESPRYT_ENABLE_TEXTURE_VIEW=1;${mglP8aKnob}")
|
||||
set_tests_properties(TcpServer.Stop.P8a${mglP8aLane} PROPERTIES
|
||||
FIXTURES_CLEANUP ${mglP8aKnobFixture} TIMEOUT 20)
|
||||
|
||||
foreach(mglP8aArm Split Spawn Tcp)
|
||||
string(TOLOWER "${mglP8aArm}" mglP8aArmLower)
|
||||
string(TOUPPER "${mglP8aArm}" mglP8aArmUpper)
|
||||
set(mglP8aEnvironment "${MGL_ITEST_GLES_${mglP8aArmUpper}_ENVIRONMENT}")
|
||||
set(mglP8aFilter "${MGL_P8A_KNOB_FILTER_${mglP8aLane}}")
|
||||
set(mglP8aProperties)
|
||||
if(mglP8aArm STREQUAL "Tcp")
|
||||
string(REPLACE "MOBILEGL_IPC_CONTROL=${MOBILEGL_ITEST_TCP_ENDPOINT}"
|
||||
"MOBILEGL_IPC_CONTROL=${mglP8aKnobEndpoint}"
|
||||
mglP8aEnvironment "${mglP8aEnvironment}")
|
||||
if(mglP8aEnvironment STREQUAL MGL_ITEST_GLES_TCP_ENVIRONMENT)
|
||||
message(FATAL_ERROR "P8-A: the Tcp arm environment names no "
|
||||
"MOBILEGL_IPC_CONTROL=${MOBILEGL_ITEST_TCP_ENDPOINT} to retarget")
|
||||
endif()
|
||||
set(mglP8aProperties FIXTURES_REQUIRED ${mglP8aKnobFixture} RESOURCE_LOCK mobilegl-tcp)
|
||||
if(DEFINED MGL_P8A_KNOB_TCP_FILTER_${mglP8aLane})
|
||||
set(mglP8aFilter "${MGL_P8A_KNOB_TCP_FILTER_${mglP8aLane}}")
|
||||
endif()
|
||||
endif()
|
||||
gtest_discover_tests(MobileGLIntegrationTest
|
||||
TEST_PREFIX "DirectGLES.${mglP8aArm}.${mglP8aLane}."
|
||||
TEST_LIST "MGL_SPLIT_ARM_TESTS_${MGL_SPLIT_ARM_INDEX}"
|
||||
TEST_FILTER "${mglP8aFilter}"
|
||||
DISCOVERY_TIMEOUT 30
|
||||
PROPERTIES
|
||||
LABELS "integration-gpu\;integration-${mglP8aArmLower}"
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
ENVIRONMENT "${mglP8aEnvironment}\;${mglP8aKnob}"
|
||||
${mglP8aProperties}
|
||||
)
|
||||
list(APPEND MGL_SPLIT_ARM_TEST_LISTS "MGL_SPLIT_ARM_TESTS_${MGL_SPLIT_ARM_INDEX}")
|
||||
math(EXPR MGL_SPLIT_ARM_INDEX "${MGL_SPLIT_ARM_INDEX} + 1")
|
||||
endforeach()
|
||||
endforeach()
|
||||
message(STATUS "Integration tests: P8-A registers ${mglP8aKnobIndex} server-knob lane(s) on "
|
||||
"split/spawn/tcp, each tcp arm on its own supervisor")
|
||||
@@ -0,0 +1,373 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Scenarios/CopyImageStoreReadbackScenario.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 - glCopyImageSubData INTO A LEVEL THE DRIVER WILL NOT READ BACK (P8-E,
|
||||
// docs/Disaggregated/notes/p8/E.md).
|
||||
//
|
||||
// The formats are the ones an ES driver keeps as texture-only storage: GL_RGB16 (EXT_texture_norm16
|
||||
// makes the three-channel spelling sampleable, never colour-renderable) and the 16-bit SNORM family
|
||||
// (renderable only with EXT_render_snorm, which Adreno does not have). Their glGetTexImage cannot go
|
||||
// through a framebuffer on such a driver, so something other than the GPU image has to answer it:
|
||||
// the CPU shadow on the monolith arm, the server's staged store on a split one. A copy writes the
|
||||
// GPU image and nothing else, which is exactly the write such a byte store never sees.
|
||||
//
|
||||
// GL_RGB9_E5 is the positive control: a 32-bit packed format, read through the scratch GL_R32UI
|
||||
// image whoever wrote the level, so it must stay green under every configuration below.
|
||||
//
|
||||
// ARMS. Both backends on the monolith arm and on Split / Spawn / Tcp, every case, with no knob:
|
||||
// on llvmpipe every one of these formats is attachable, so these runs pin the GPU route and the
|
||||
// copy itself. Magma is the control backend - it reads the VkImage back whatever the format, so it
|
||||
// has no store route to exercise.
|
||||
//
|
||||
// THE KNOB. MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT=<w>x<h> is read BY THE ESPRYT SERVER
|
||||
// (WireTextureReadback.inc, ReadTextureImageWire): a colour level of exactly that extent is
|
||||
// treated as a level the driver refused to attach, which is what an Adreno does for every one of
|
||||
// these formats and what llvmpipe can be made to do no other way. The `DirectGLES.<arm>.StoreRead.`
|
||||
// entries set it, and this scenario then builds its textures at THAT extent instead of the default
|
||||
// one - so the knob is scoped by the extent, and the tcp lane's shared supervisor can carry it
|
||||
// (the TcpServer.Start fixture's ENVIRONMENT) without touching any other entry, this scenario's
|
||||
// own knob-free tcp entries included. Under the knob every read must still be right, and the
|
||||
// server log must name the store route - otherwise the entry would be pinning the GPU route a
|
||||
// second time under a name that claims otherwise.
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../Harness/HeadlessGL.h"
|
||||
#include "../Harness/PipeStatsWindow.h"
|
||||
#include "../Harness/ScenarioFixture.h"
|
||||
#include "../Harness/SplitRuntimePeek.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* kRefuseExtentKnob = "MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT";
|
||||
// What the Espryt server logs (once per process) when it answers a read from its store.
|
||||
constexpr const char* kStoreReadMarker = "texture-readback-from-store";
|
||||
// The knob-free extent. Deliberately not the extent the knob entries use, so the tcp
|
||||
// supervisor - which carries the knob for the whole lane - leaves these textures alone.
|
||||
constexpr int kDefaultWidth = 12;
|
||||
constexpr int kDefaultHeight = 6;
|
||||
|
||||
struct CopyFormat {
|
||||
GLenum internalFormat;
|
||||
GLenum format;
|
||||
GLenum type;
|
||||
int components; // 16-bit components per texel; 0 for the one 32-bit packed format
|
||||
bool isSigned;
|
||||
const char* name;
|
||||
};
|
||||
|
||||
const CopyFormat kFormats[] = {
|
||||
{GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT, 3, false, "rgb16"},
|
||||
{GL_RGBA16_SNORM, GL_RGBA, GL_SHORT, 4, true, "rgba16_snorm"},
|
||||
{GL_RGB16_SNORM, GL_RGB, GL_SHORT, 3, true, "rgb16_snorm"},
|
||||
{GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, 4, false, "rgba16"},
|
||||
{GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, 0, false, "rgb9_e5"},
|
||||
};
|
||||
|
||||
int TexelBytes(const CopyFormat& format) { return format.components == 0 ? 4 : format.components * 2; }
|
||||
|
||||
// Every word differs from its neighbours and from the other patterns, so a mis-addressed
|
||||
// row, a swapped endpoint or a copy that never happened cannot cancel out. SNORM never
|
||||
// gets -32768: it and -32767 are the same value (-1.0), and a read that goes through a
|
||||
// normalized float is entitled to answer either.
|
||||
std::vector<std::uint8_t> MakeTexels(const CopyFormat& format, int width, int height, std::uint32_t seed) {
|
||||
const std::size_t texels = static_cast<std::size_t>(width) * static_cast<std::size_t>(height);
|
||||
std::vector<std::uint8_t> bytes(texels * static_cast<std::size_t>(TexelBytes(format)));
|
||||
if (format.components == 0) {
|
||||
for (std::size_t i = 0; i < texels; ++i) {
|
||||
std::uint32_t word = (static_cast<std::uint32_t>(i) + 1u) * 2654435761u ^ seed * 40503u;
|
||||
word ^= word >> 13;
|
||||
std::memcpy(bytes.data() + i * 4, &word, 4);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
const std::size_t words = texels * static_cast<std::size_t>(format.components);
|
||||
for (std::size_t i = 0; i < words; ++i) {
|
||||
std::uint32_t mix = (static_cast<std::uint32_t>(i) + 1u) * 2654435761u ^ seed * 40503u;
|
||||
mix ^= mix >> 15;
|
||||
std::uint16_t value = static_cast<std::uint16_t>(mix >> 8);
|
||||
if (format.isSigned && value == 0x8000u) value = 0x8001u;
|
||||
std::memcpy(bytes.data() + i * 2, &value, 2);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// `image` with the w x h block at (dx, dy) replaced by the block of `source` at (sx, sy).
|
||||
std::vector<std::uint8_t> WithBlock(std::vector<std::uint8_t> image, int width, const std::vector<std::uint8_t>& source,
|
||||
int sourceWidth, int sx, int sy, int dx, int dy, int w, int h,
|
||||
int texelBytes) {
|
||||
for (int row = 0; row < h; ++row) {
|
||||
std::memcpy(image.data() + (static_cast<std::size_t>(dy + row) * width + dx) * texelBytes,
|
||||
source.data() + (static_cast<std::size_t>(sy + row) * sourceWidth + sx) * texelBytes,
|
||||
static_cast<std::size_t>(w) * texelBytes);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
class CopyImageStoreReadbackScenario : public ScenarioTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ScenarioTest::SetUp();
|
||||
if (!Ready()) return;
|
||||
m_wire = SplitRuntimeSkipReason().empty();
|
||||
m_espryt = Gl().BackendName() == "DirectGLES";
|
||||
if (const char* knob = std::getenv(kRefuseExtentKnob)) {
|
||||
int width = 0, height = 0;
|
||||
ASSERT_EQ(std::sscanf(knob, "%dx%d", &width, &height), 2)
|
||||
<< kRefuseExtentKnob << "=" << knob << " is not <w>x<h>";
|
||||
ASSERT_GE(width, 12) << "the copy windows below need at least a 12x6 level";
|
||||
ASSERT_GE(height, 6) << "the copy windows below need at least a 12x6 level";
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
m_forced = true;
|
||||
}
|
||||
// 16-bit RGB rows are 6 bytes a texel: the default 4-byte alignment would pad every
|
||||
// row of an odd-width level and shear both the upload and the read.
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
ASSERT_EQ(FirstGLError(), 0u);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (!Ready()) return;
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
if (!m_textures.empty()) {
|
||||
glDeleteTextures(static_cast<GLsizei>(m_textures.size()), m_textures.data());
|
||||
}
|
||||
if (m_renderbuffer != 0) glDeleteRenderbuffers(1, &m_renderbuffer);
|
||||
if (m_fbo != 0) {
|
||||
BindDefaultFramebuffer();
|
||||
glDeleteFramebuffers(1, &m_fbo);
|
||||
}
|
||||
FirstGLError();
|
||||
}
|
||||
|
||||
GLuint MakeTexture(const CopyFormat& format, const std::vector<std::uint8_t>& texels, bool immutable) {
|
||||
GLuint texture = 0;
|
||||
glGenTextures(1, &texture);
|
||||
m_textures.push_back(texture);
|
||||
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);
|
||||
if (immutable) {
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, format.internalFormat, m_width, m_height);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_width, m_height, format.format, format.type,
|
||||
texels.data());
|
||||
} else {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, static_cast<GLint>(format.internalFormat), m_width, m_height, 0,
|
||||
format.format, format.type, texels.data());
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
return texture;
|
||||
}
|
||||
|
||||
std::vector<std::uint8_t> ReadTexImage(GLuint texture, const CopyFormat& format) {
|
||||
std::vector<std::uint8_t> bytes(
|
||||
static_cast<std::size_t>(m_width) * m_height * static_cast<std::size_t>(TexelBytes(format)), 0xA5);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, format.format, format.type, bytes.data());
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// The first texel that differs names the defect (which half of the copy, which word);
|
||||
// the rest would only bury it.
|
||||
void ExpectImage(const std::vector<std::uint8_t>& got, const std::vector<std::uint8_t>& want,
|
||||
const CopyFormat& format, const std::string& what) {
|
||||
ASSERT_EQ(got.size(), want.size());
|
||||
const int texelBytes = TexelBytes(format);
|
||||
for (std::size_t at = 0; at < got.size(); ++at) {
|
||||
if (got[at] == want[at]) continue;
|
||||
const std::size_t texel = at / static_cast<std::size_t>(texelBytes);
|
||||
const int x = static_cast<int>(texel % static_cast<std::size_t>(m_width));
|
||||
const int y = static_cast<int>(texel / static_cast<std::size_t>(m_width));
|
||||
std::string gotHex, wantHex;
|
||||
char buffer[4];
|
||||
for (int b = 0; b < texelBytes; ++b) {
|
||||
std::snprintf(buffer, sizeof(buffer), "%02x", got[texel * texelBytes + b]);
|
||||
gotHex += buffer;
|
||||
std::snprintf(buffer, sizeof(buffer), "%02x", want[texel * texelBytes + b]);
|
||||
wantHex += buffer;
|
||||
}
|
||||
ADD_FAILURE() << what << " (" << format.name << ", " << Gl().BackendName() << ", "
|
||||
<< (m_wire ? "split" : "monolith") << (m_forced ? ", store read forced" : "")
|
||||
<< "): texel (" << x << ", " << y << ") reads " << gotHex << ", want " << wantHex;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Under the knob the Espryt server must have answered from its store at least once;
|
||||
// otherwise the entry proves nothing about that route.
|
||||
void ExpectStoreReadNamedSince(const PipeStatsWindow::LogMark& mark) {
|
||||
if (!m_forced || !m_espryt || !m_wire) return;
|
||||
const std::string log = PipeStatsWindow::ReadServerLogSince(mark);
|
||||
EXPECT_NE(log.find(kStoreReadMarker), std::string::npos)
|
||||
<< kRefuseExtentKnob << " is set but the server log carries no '" << kStoreReadMarker
|
||||
<< "' line: the knob did not reach the server, or no read took the store route";
|
||||
}
|
||||
|
||||
// The copy window: 5x3 texels from (1, 1) of the source to (6, 2) of the destination,
|
||||
// inside a 12x6 level and away from the partial upload's (0, 0) 3x2 corner.
|
||||
static constexpr int kSrcX = 1, kSrcY = 1, kDstX = 6, kDstY = 2, kCopyW = 5, kCopyH = 3;
|
||||
|
||||
void CopyWindow(GLuint source, GLuint destination) {
|
||||
glCopyImageSubData(source, GL_TEXTURE_2D, 0, kSrcX, kSrcY, 0, destination, GL_TEXTURE_2D, 0, kDstX,
|
||||
kDstY, 0, kCopyW, kCopyH, 1);
|
||||
}
|
||||
|
||||
bool m_wire = false;
|
||||
bool m_espryt = false;
|
||||
bool m_forced = false;
|
||||
int m_width = kDefaultWidth;
|
||||
int m_height = kDefaultHeight;
|
||||
std::vector<GLuint> m_textures;
|
||||
GLuint m_renderbuffer = 0;
|
||||
GLuint m_fbo = 0;
|
||||
};
|
||||
|
||||
// The control: an uploaded level reads back as uploaded.
|
||||
TEST_F(CopyImageStoreReadbackScenario, AnUploadedLevelReadsBackExactly) {
|
||||
if (!Ready()) return;
|
||||
const auto mark = PipeStatsWindow::MarkLaneLog();
|
||||
for (const CopyFormat& format : kFormats) {
|
||||
const auto texels = MakeTexels(format, m_width, m_height, 11);
|
||||
const GLuint texture = MakeTexture(format, texels, /*immutable=*/false);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << format.name << ": setup raised a GL error";
|
||||
ExpectImage(ReadTexImage(texture, format), texels, format, "the uploaded level");
|
||||
ASSERT_EQ(FirstGLError(), 0u) << format.name << ": glGetTexImage raised a GL error";
|
||||
}
|
||||
ExpectStoreReadNamedSince(mark);
|
||||
}
|
||||
|
||||
// THE CASE THE PACKAGE IS ABOUT: the copy lands in the destination's GPU image only, and the
|
||||
// read has to see it - whatever answers the read.
|
||||
TEST_F(CopyImageStoreReadbackScenario, ACopiedWindowReadsBackOverTheUpload) {
|
||||
if (!Ready()) return;
|
||||
const auto mark = PipeStatsWindow::MarkLaneLog();
|
||||
for (const CopyFormat& format : kFormats) {
|
||||
const auto sourceTexels = MakeTexels(format, m_width, m_height, 23);
|
||||
const auto destinationTexels = MakeTexels(format, m_width, m_height, 37);
|
||||
const GLuint source = MakeTexture(format, sourceTexels, /*immutable=*/false);
|
||||
const GLuint destination = MakeTexture(format, destinationTexels, /*immutable=*/false);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << format.name << ": setup raised a GL error";
|
||||
CopyWindow(source, destination);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << format.name << ": glCopyImageSubData raised a GL error";
|
||||
const auto want = WithBlock(destinationTexels, m_width, sourceTexels, m_width, kSrcX, kSrcY, kDstX,
|
||||
kDstY, kCopyW, kCopyH, TexelBytes(format));
|
||||
ExpectImage(ReadTexImage(destination, format), want, format, "the copy destination");
|
||||
ExpectImage(ReadTexImage(source, format), sourceTexels, format, "the copy source");
|
||||
ASSERT_EQ(FirstGLError(), 0u) << format.name << ": glGetTexImage raised a GL error";
|
||||
}
|
||||
ExpectStoreReadNamedSince(mark);
|
||||
}
|
||||
|
||||
// The same into immutable storage (glTexStorage2D, then the whole level uploaded).
|
||||
TEST_F(CopyImageStoreReadbackScenario, ACopiedWindowReadsBackFromAnImmutableLevel) {
|
||||
if (!Ready()) return;
|
||||
const auto mark = PipeStatsWindow::MarkLaneLog();
|
||||
for (const CopyFormat& format : kFormats) {
|
||||
const auto sourceTexels = MakeTexels(format, m_width, m_height, 41);
|
||||
const auto destinationTexels = MakeTexels(format, m_width, m_height, 43);
|
||||
const GLuint source = MakeTexture(format, sourceTexels, /*immutable=*/true);
|
||||
const GLuint destination = MakeTexture(format, destinationTexels, /*immutable=*/true);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << format.name << ": setup raised a GL error";
|
||||
CopyWindow(source, destination);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << format.name << ": glCopyImageSubData raised a GL error";
|
||||
const auto want = WithBlock(destinationTexels, m_width, sourceTexels, m_width, kSrcX, kSrcY, kDstX,
|
||||
kDstY, kCopyW, kCopyH, TexelBytes(format));
|
||||
ExpectImage(ReadTexImage(destination, format), want, format, "the immutable copy destination");
|
||||
ASSERT_EQ(FirstGLError(), 0u) << format.name << ": glGetTexImage raised a GL error";
|
||||
}
|
||||
ExpectStoreReadNamedSince(mark);
|
||||
}
|
||||
|
||||
// A copy, then an ordinary partial upload into the same level elsewhere. The upload is the
|
||||
// client's; the copied window is not, and a byte store that took the upload as "the level"
|
||||
// would lose it again.
|
||||
TEST_F(CopyImageStoreReadbackScenario, APartialUploadAfterTheCopyKeepsTheCopiedWindow) {
|
||||
if (!Ready()) return;
|
||||
const auto mark = PipeStatsWindow::MarkLaneLog();
|
||||
for (const CopyFormat& format : kFormats) {
|
||||
const auto sourceTexels = MakeTexels(format, m_width, m_height, 53);
|
||||
const auto destinationTexels = MakeTexels(format, m_width, m_height, 59);
|
||||
const auto patch = MakeTexels(format, 3, 2, 61);
|
||||
const GLuint source = MakeTexture(format, sourceTexels, /*immutable=*/false);
|
||||
const GLuint destination = MakeTexture(format, destinationTexels, /*immutable=*/false);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << format.name << ": setup raised a GL error";
|
||||
CopyWindow(source, destination);
|
||||
glBindTexture(GL_TEXTURE_2D, destination);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 3, 2, format.format, format.type, patch.data());
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << format.name << ": the copy or the upload raised a GL error";
|
||||
auto want = WithBlock(destinationTexels, m_width, sourceTexels, m_width, kSrcX, kSrcY, kDstX, kDstY,
|
||||
kCopyW, kCopyH, TexelBytes(format));
|
||||
want = WithBlock(want, m_width, patch, 3, 0, 0, 0, 0, 3, 2, TexelBytes(format));
|
||||
ExpectImage(ReadTexImage(destination, format), want, format, "the copy destination after the upload");
|
||||
ASSERT_EQ(FirstGLError(), 0u) << format.name << ": glGetTexImage raised a GL error";
|
||||
}
|
||||
ExpectStoreReadNamedSince(mark);
|
||||
}
|
||||
|
||||
// A RENDERBUFFER endpoint. The split arm resolves it by handle (DirectGLES.cpp,
|
||||
// MakeGLESCopyImageEndpoint), which is what retired the "CopyImageSubData+RENDERBUFFER"
|
||||
// latch; this is the case that says so on every arm. It has no store to answer from - a
|
||||
// renderbuffer's texels were never uploaded - so the knob entries do not run it.
|
||||
TEST_F(CopyImageStoreReadbackScenario, ARenderbufferSourceLandsInTheTexture) {
|
||||
if (!Ready()) return;
|
||||
const CopyFormat format{GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, 4, false, "rgba16"};
|
||||
const auto destinationTexels = MakeTexels(format, m_width, m_height, 71);
|
||||
const GLuint destination = MakeTexture(format, destinationTexels, /*immutable=*/false);
|
||||
glGenRenderbuffers(1, &m_renderbuffer);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, m_renderbuffer);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA16, m_width, m_height);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
glGenFramebuffers(1, &m_fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_renderbuffer);
|
||||
ASSERT_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE))
|
||||
<< "the RGBA16 renderbuffer is not attachable";
|
||||
// k / 65535 for four 16-bit words: exact through a float clear and a UNORM16 store.
|
||||
const std::uint16_t words[4] = {0x1234, 0x5678, 0x9abc, 0xffff};
|
||||
const GLfloat color[4] = {words[0] / 65535.0f, words[1] / 65535.0f, words[2] / 65535.0f,
|
||||
words[3] / 65535.0f};
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glClearBufferfv(GL_COLOR, 0, color);
|
||||
BindDefaultFramebuffer();
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "setup raised a GL error";
|
||||
glCopyImageSubData(m_renderbuffer, GL_RENDERBUFFER, 0, kSrcX, kSrcY, 0, destination, GL_TEXTURE_2D, 0,
|
||||
kDstX, kDstY, 0, kCopyW, kCopyH, 1);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "glCopyImageSubData from the renderbuffer raised a GL error";
|
||||
std::vector<std::uint8_t> cleared(static_cast<std::size_t>(m_width) * m_height * 8);
|
||||
for (std::size_t texel = 0; texel < cleared.size() / 8; ++texel) {
|
||||
std::memcpy(cleared.data() + texel * 8, words, 8);
|
||||
}
|
||||
const auto want = WithBlock(destinationTexels, m_width, cleared, m_width, kSrcX, kSrcY, kDstX, kDstY,
|
||||
kCopyW, kCopyH, 8);
|
||||
ExpectImage(ReadTexImage(destination, format), want, format, "the texture a renderbuffer was copied into");
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "glGetTexImage raised a GL error";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace MGITest
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "../Harness/SplitRuntimePeek.h"
|
||||
#include "../Harness/PipeStatsWindow.h"
|
||||
#include "../Harness/SplitLane.h"
|
||||
#include "../Harness/WireDeclinePeek.h"
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
@@ -659,6 +660,12 @@ TEST_F(F1WireScenario, GenerateMipmapDepthStencilDeclinesAndKeepsTheSession) {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glClearDepth(0.5);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
// P8-SV: the decline is a WireDeclines.def row now (MipmapDepthStencilAspect), so the server's
|
||||
// MGWIRE-DECLINES dump sees it. Readable where the server is this process: the inproc arm.
|
||||
// Red once (executed, reverted): the site back to a bare MGLOG_E_ONCE - the count stays 0.
|
||||
unsigned long long declinesBefore = 0;
|
||||
const bool counted = PeekSplitRuntime().transportName == "inproc" &&
|
||||
PeekWireDeclineCount("MipmapDepthStencilAspect", &declinesBefore);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
EXPECT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "F1.DepthStencilMip.error";
|
||||
// The session is what the retired Fatal used to take with it. A readback is a round trip
|
||||
@@ -669,12 +676,77 @@ TEST_F(F1WireScenario, GenerateMipmapDepthStencilDeclinesAndKeepsTheSession) {
|
||||
glReadPixels(1, 1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &level0);
|
||||
EXPECT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "F1.DepthStencilMip.readback";
|
||||
EXPECT_NEAR(level0, 0.5f, 0.002f) << "F1.DepthStencilMip.level0";
|
||||
if (counted) {
|
||||
unsigned long long declinesAfter = 0;
|
||||
ASSERT_TRUE(PeekWireDeclineCount("MipmapDepthStencilAspect", &declinesAfter));
|
||||
EXPECT_EQ(declinesAfter - declinesBefore, 1u) << "F1.DepthStencilMip.tally: one named decline per refused "
|
||||
"glGenerateMipmap (WireDeclines.def MipmapDepthStencilAspect)";
|
||||
}
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||
glDeleteTextures(1, &depthStencil);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glClearDepth(1.0);
|
||||
}
|
||||
|
||||
// P8-F: `Magma:mipmap-shader-format-or-shape` IS A NAMED DECLINE ON THE WIRE ARM NOW, which is
|
||||
// the monolith arm's answer for a chain it cannot build (VulkanRenderer.cpp's GenerateMipmap
|
||||
// declines a format without blit support and leaves the chain unwritten). It used to end the
|
||||
// session. A 3D texture is a shape neither wire shader arm takes (the colour pass samples a
|
||||
// sampler2D), so with the native blit forced off (MGITEST_MAGMA_FORCE_SHADER_MIPMAP) it is what
|
||||
// reaches the refusal on this host - lavapipe blits a 3D RGBA8 chain natively otherwise.
|
||||
//
|
||||
// What this case pins: no GL error, the session still answering (two readback round trips), level
|
||||
// 0 untouched, and level 1 still holding the application's own texels - the decline wrote nothing.
|
||||
// Magma only, and knob-gated, like GenerateMipmapWithoutNativeBlitPixels above.
|
||||
// Red once (executed, reverted): restore the MagmaWireFatal and this case dies with
|
||||
// Fatal{UnmigratedVerb, "Magma:mipmap-shader-format-or-shape ..."}.
|
||||
TEST_F(F1WireScenario, GenerateMipmapWithoutAShaderArmShapeDeclinesAndKeepsTheSession) {
|
||||
if (!Ready()) return;
|
||||
if (Gl().BackendName() != "DirectVulkan")
|
||||
GTEST_SKIP() << "Magma wire-arm decline (P8-F, mipmap-shader-format-or-shape): the knob and "
|
||||
"the shader mip arms it forces are Magma's; Espryt ("
|
||||
<< Gl().BackendName() << ") generates this chain itself";
|
||||
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 blits a 3D RGBA8 "
|
||||
"chain natively, so the decline under test is not entered";
|
||||
GLuint volume = 0;
|
||||
glGenTextures(1, &volume);
|
||||
glBindTexture(GL_TEXTURE_3D, volume);
|
||||
glTexStorage3D(GL_TEXTURE_3D, 3, GL_RGBA8, 4, 4, 4);
|
||||
const std::array<GLubyte, 4> base{200, 40, 80, 255};
|
||||
const std::array<GLubyte, 4> sentinel{10, 220, 30, 255};
|
||||
const auto fill = [](int side, const std::array<GLubyte, 4>& texel) {
|
||||
std::vector<GLubyte> pixels(static_cast<size_t>(side * side * side * 4));
|
||||
for (size_t at = 0; at < pixels.size(); at += 4) std::copy(texel.begin(), texel.end(), pixels.begin() + at);
|
||||
return pixels;
|
||||
};
|
||||
const auto level0 = fill(4, base);
|
||||
const auto level1 = fill(2, sentinel);
|
||||
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 4, 4, 4, GL_RGBA, GL_UNSIGNED_BYTE, level0.data());
|
||||
glTexSubImage3D(GL_TEXTURE_3D, 1, 0, 0, 0, 2, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, level1.data());
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "F1.ShaderMipDecline.setup";
|
||||
const auto before = PeekSplitRuntime().emitSeq;
|
||||
glGenerateMipmap(GL_TEXTURE_3D);
|
||||
ASSERT_GT(PeekSplitRuntime().emitSeq, before) << "F1.ShaderMipDecline.wire";
|
||||
EXPECT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "F1.ShaderMipDecline.error";
|
||||
for (const int level : {0, 1}) {
|
||||
const int side = 4 >> level;
|
||||
std::vector<GLubyte> pixels(static_cast<size_t>(side * side * side * 4), 0x5a);
|
||||
glGetTexImage(GL_TEXTURE_3D, level, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "F1.ShaderMipDecline.readback level " << level;
|
||||
const std::array<GLubyte, 4>& expected = level == 0 ? base : sentinel;
|
||||
size_t wrong = 0;
|
||||
for (size_t at = 0; at < pixels.size(); at += 4)
|
||||
if (!std::equal(expected.begin(), expected.end(), pixels.begin() + at)) ++wrong;
|
||||
EXPECT_EQ(wrong, 0u) << "F1.ShaderMipDecline.level" << level << " tier=" << tier
|
||||
<< ": a declined mip must leave every level as the application wrote it";
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_3D, 0);
|
||||
glDeleteTextures(1, &volume);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
}
|
||||
|
||||
TEST_F(F1WireScenario, GenerateMipmapHonorsMutableBaseAndMaxWithoutChangingOtherLevels) {
|
||||
if (!Ready()) return;
|
||||
const std::array<GLubyte, 4> colors[5] = {
|
||||
|
||||
@@ -0,0 +1,555 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Scenarios/GenerateMipmapServerScenario.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 - glGenerateMipmap ON THE FORMATS ESPRYT DOES NOT HAND STRAIGHT TO THE DRIVER
|
||||
// (P8-B, docs/Disaggregated/notes/p8/B.md).
|
||||
//
|
||||
// Espryt generates R11F_G11F_B10F and depth chains with per-level blits, and RGB16F / RGB32F
|
||||
// chains outside glGenerateMipmap because ES refuses a three-channel float format there. Until
|
||||
// P8-B the split arms of both were named refusals:
|
||||
// B1 Fatal{UnmigratedEmulation, "generate-mipmap-storage"} whenever the texture's descriptor
|
||||
// held fewer levels than the full chain from level 0 - a MAX_LEVEL below the chain, or a
|
||||
// glTexStorage2D with fewer levels - which is legal GL (the generated window is
|
||||
// BASE_LEVEL+1 .. min(p, MAX_LEVEL), and immutable storage bounds it too);
|
||||
// B2 Fatal{UnmigratedEmulation, "generate-mipmap-cpu-filter"} on every RGB16F / RGB32F
|
||||
// generation, because the monolith filters the frontend's level shadows on the CPU.
|
||||
//
|
||||
// EVERY CASE CHECKS THE GL ANSWER BY SAMPLING. The base level is split into two halves (bottom
|
||||
// rows A, top rows B) so a generation that loses the row order, or reads another level, cannot
|
||||
// average to the right colour. Each generated level is read back through texelFetch into an RGBA8
|
||||
// target, and the levels outside the window are checked unchanged (or still undefined).
|
||||
//
|
||||
// ARMS. Both backends, monolith and Split / Spawn / Tcp; Magma is the control. The forced-CPU arm
|
||||
// (MGITEST_ESPRYT_FORCE_CPU_MIPMAP=1, read by the SERVER) runs the three-channel cases through
|
||||
// Espryt's server-side CPU filter, which a host driver never needs: llvmpipe generates both
|
||||
// formats natively. Under the knob the server log must name that arm, or the entry proved nothing.
|
||||
//
|
||||
// THE CPU ARM'S STORE ROUTE (P8-SE). When the driver cannot read the base level back, the server's
|
||||
// CPU arm filters the staged store's copy of it - but only for a texture the driver never wrote
|
||||
// (P8-E's sticky mark), because a render target's level 0 exists only on the driver and the store
|
||||
// still holds what crossed before the draw. The `CpuMipRefused.` entries add
|
||||
// MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT=16x16 (P8-E's knob, also read by the SERVER) to the
|
||||
// forced-CPU knob: a render-target base must decline by name (generate-mipmap-store-declined) and
|
||||
// never filter the stale store, and an uploaded-only base must still be filtered from the store.
|
||||
//
|
||||
// MONOLITH DEFECTS, recorded for dev (ID-P8-3) and skipped by name on the monolith arm they live
|
||||
// on unless MGITEST_RUN_MONOLITH_MIP_DEFECTS=1 is set (which is how each was shown red):
|
||||
// M1 Espryt: the RGB16F / RGB32F CPU filter reads the frontend's level shadow, which a GPU
|
||||
// write to level 0 leaves stale (DirectGLES.cpp GenerateThreeChannelFloatMipmapOnCpu);
|
||||
// M2 Espryt: the R11F / depth blit chains start at level 1 and run to the end of the chain,
|
||||
// ignoring BASE_LEVEL and MAX_LEVEL, and the storage grow before them defines levels past
|
||||
// MAX_LEVEL (DirectGLES.cpp GenerateColorTexture2DMipmap / GenerateDepthTexture2DMipmap /
|
||||
// EnsureGenerateMipmapStorageAllocated);
|
||||
// M3 Magma: a colour format without BLIT_SRC|BLIT_DST (R11F_G11F_B10F on lavapipe) is skipped
|
||||
// with a warning and its levels stay undefined texels - the monolith has no shader arm,
|
||||
// which the wire arm has had since P7 (VulkanRenderer.cpp GenerateMipmap).
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../Harness/HeadlessGL.h"
|
||||
#include "../Harness/PipeStatsWindow.h"
|
||||
#include "../Harness/ScenarioFixture.h"
|
||||
#include "../Harness/SplitRuntimePeek.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 kEdge = 16;
|
||||
constexpr const char* kForceCpuMipmap = "MGITEST_ESPRYT_FORCE_CPU_MIPMAP";
|
||||
constexpr const char* kCpuMipmapMarker = "generate-mipmap-server-cpu";
|
||||
constexpr const char* kRunMonolithDefects = "MGITEST_RUN_MONOLITH_MIP_DEFECTS";
|
||||
// P8-SE: E's server-read knob; the entries set it to kEdge x kEdge, the base level's extent.
|
||||
constexpr const char* kRefuseReadback = "MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT";
|
||||
constexpr const char* kStoreDeclinedMarker = "generate-mipmap-store-declined";
|
||||
constexpr const char* kStoreFilteredMarker = "filtering the staged store's copy";
|
||||
|
||||
constexpr const char* kVertexSource = R"(#version 430 core
|
||||
void main() {
|
||||
vec2 positions[3] = vec2[3](vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0));
|
||||
gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
constexpr const char* kSampleSource = R"(#version 430 core
|
||||
uniform sampler2D u_texture;
|
||||
uniform int u_level;
|
||||
out vec4 o_color;
|
||||
void main() { o_color = texelFetch(u_texture, ivec2(gl_FragCoord.xy), u_level); }
|
||||
)";
|
||||
constexpr const char* kPaintSource = R"(#version 430 core
|
||||
uniform vec4 u_bottom;
|
||||
uniform vec4 u_top;
|
||||
uniform float u_split;
|
||||
out vec4 o_color;
|
||||
void main() { o_color = gl_FragCoord.y < u_split ? u_bottom : u_top; }
|
||||
)";
|
||||
|
||||
using Rgb = std::array<float, 3>;
|
||||
// Exact in R11F_G11F_B10F, RGB16F and RGB32F alike, and apart in every channel.
|
||||
constexpr Rgb kBottom = {0.25f, 0.5f, 0.75f};
|
||||
constexpr Rgb kTop = {0.875f, 0.375f, 0.125f};
|
||||
constexpr Rgb kSentinel = {1.0f, 0.0f, 1.0f};
|
||||
constexpr Rgb kLevelZero = {1.0f, 0.0f, 0.0f};
|
||||
constexpr Rgb kLevelTwo = {0.0f, 0.0f, 1.0f};
|
||||
constexpr Rgb kLevelThree = {1.0f, 1.0f, 0.0f};
|
||||
constexpr float kDepthBottom = 0.25f;
|
||||
constexpr float kDepthTop = 0.75f;
|
||||
constexpr float kDepthLevelZero = 0.125f;
|
||||
constexpr float kDepthLevelTwo = 0.5f;
|
||||
constexpr float kDepthLevelThree = 1.0f;
|
||||
|
||||
struct Format {
|
||||
GLenum internalFormat;
|
||||
bool depth;
|
||||
const char* name;
|
||||
};
|
||||
constexpr Format kPackedFloat = {GL_R11F_G11F_B10F, false, "R11F_G11F_B10F"};
|
||||
constexpr Format kDepth32F = {GL_DEPTH_COMPONENT32F, true, "DEPTH_COMPONENT32F"};
|
||||
constexpr Format kRgb16F = {GL_RGB16F, false, "RGB16F"};
|
||||
constexpr Format kRgb32F = {GL_RGB32F, false, "RGB32F"};
|
||||
|
||||
int ToByte(float value) { return static_cast<int>(std::lround(value * 255.0f)); }
|
||||
|
||||
class GenerateMipmapServerScenario : public ScenarioTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ScenarioTest::SetUp();
|
||||
if (!Ready()) return;
|
||||
m_wire = SplitRuntimeSkipReason().empty();
|
||||
m_espryt = Gl().BackendName() == "DirectGLES";
|
||||
m_forcedCpu = std::getenv(kForceCpuMipmap) != nullptr;
|
||||
m_refusedReadback = std::getenv(kRefuseReadback) != nullptr;
|
||||
std::string error;
|
||||
m_sampleProgram = CompileProgram(kVertexSource, kSampleSource, &error);
|
||||
ASSERT_NE(m_sampleProgram, 0u) << error;
|
||||
m_paintProgram = CompileProgram(kVertexSource, kPaintSource, &error);
|
||||
ASSERT_NE(m_paintProgram, 0u) << error;
|
||||
m_target = MakeColorFbo(kEdge, kEdge);
|
||||
ASSERT_NE(m_target.fbo, 0u) << "could not create the sampling target";
|
||||
glGenVertexArrays(1, &m_vao);
|
||||
glGenFramebuffers(1, &m_fbo);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
ASSERT_EQ(FirstGLError(), 0u);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (!Ready()) return;
|
||||
glUseProgram(0);
|
||||
glBindVertexArray(0);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
if (m_sampleProgram != 0) glDeleteProgram(m_sampleProgram);
|
||||
if (m_paintProgram != 0) glDeleteProgram(m_paintProgram);
|
||||
if (m_vao != 0) glDeleteVertexArrays(1, &m_vao);
|
||||
if (m_fbo != 0) glDeleteFramebuffers(1, &m_fbo);
|
||||
if (m_texture != 0) glDeleteTextures(1, &m_texture);
|
||||
BindDefaultFramebuffer();
|
||||
if (m_target.fbo != 0) DestroyColorFbo(m_target);
|
||||
glViewport(0, 0, Gl().Width(), Gl().Height());
|
||||
FirstGLError();
|
||||
}
|
||||
|
||||
// Whether this case meets a recorded monolith defect on this arm (see the header). The
|
||||
// knob runs it anyway, which is how each defect is shown red and how dev's fix is checked.
|
||||
bool MonolithDefect(bool onEspryt, bool onMagma) const {
|
||||
if (m_wire || std::getenv(kRunMonolithDefects) != nullptr) return false;
|
||||
return m_espryt ? onEspryt : onMagma;
|
||||
}
|
||||
static constexpr const char* kM1 =
|
||||
"monolith defect M1 (recorded for dev, ID-P8-3): Espryt's CPU filter reads the frontend's "
|
||||
"level shadow, which the draw into level 0 left stale";
|
||||
static constexpr const char* kM2 =
|
||||
"monolith defect M2 (recorded for dev, ID-P8-3): Espryt's blit chain ignores BASE_LEVEL and "
|
||||
"MAX_LEVEL and its storage grow defines levels past MAX_LEVEL";
|
||||
static constexpr const char* kM3 =
|
||||
"monolith defect M3 (recorded for dev, ID-P8-3): Magma skips a format without native blit "
|
||||
"and leaves the generated levels empty";
|
||||
|
||||
GLuint NewTexture() {
|
||||
glGenTextures(1, &m_texture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_texture);
|
||||
return m_texture;
|
||||
}
|
||||
|
||||
// A level `edge` x `edge` whose rows below the middle are `bottom` and above it `top`.
|
||||
static std::vector<float> Halves(const Format& format, int edge, const Rgb& bottom, const Rgb& top,
|
||||
float depthBottom, float depthTop) {
|
||||
const int channels = format.depth ? 1 : 3;
|
||||
std::vector<float> texels(static_cast<std::size_t>(edge * edge * channels));
|
||||
for (int y = 0; y < edge; ++y) {
|
||||
for (int x = 0; x < edge; ++x) {
|
||||
float* texel = texels.data() + static_cast<std::size_t>((y * edge + x) * channels);
|
||||
const bool low = y < edge / 2;
|
||||
if (format.depth) {
|
||||
texel[0] = low ? depthBottom : depthTop;
|
||||
} else {
|
||||
for (int c = 0; c < 3; ++c) texel[c] = low ? bottom[c] : top[c];
|
||||
}
|
||||
}
|
||||
}
|
||||
return texels;
|
||||
}
|
||||
|
||||
static std::vector<float> Flat(const Format& format, int edge, const Rgb& colour, float depth) {
|
||||
return Halves(format, edge, colour, colour, depth, depth);
|
||||
}
|
||||
|
||||
static void DefineLevel(const Format& format, int level, int edge, const std::vector<float>& texels) {
|
||||
glTexImage2D(GL_TEXTURE_2D, level, static_cast<GLint>(format.internalFormat), edge, edge, 0,
|
||||
format.depth ? GL_DEPTH_COMPONENT : GL_RGB, GL_FLOAT, texels.data());
|
||||
}
|
||||
|
||||
static void UploadLevel(const Format& format, int level, int edge, const std::vector<float>& texels) {
|
||||
glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, edge, edge, format.depth ? GL_DEPTH_COMPONENT : GL_RGB,
|
||||
GL_FLOAT, texels.data());
|
||||
}
|
||||
|
||||
static int LevelWidth(int level) {
|
||||
GLint width = 0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_WIDTH, &width);
|
||||
return width;
|
||||
}
|
||||
|
||||
// texelFetch's level is relative to BASE_LEVEL and bounded by MAX_LEVEL, so the window is
|
||||
// reopened over every defined level before any of them is read.
|
||||
Image SampleLevel(int level, int maxLevel) {
|
||||
const int edge = std::max(kEdge >> level, 1);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, maxLevel);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glUseProgram(m_sampleProgram);
|
||||
glUniform1i(glGetUniformLocation(m_sampleProgram, "u_texture"), 0);
|
||||
glUniform1i(glGetUniformLocation(m_sampleProgram, "u_level"), level);
|
||||
BindFbo(m_target);
|
||||
glViewport(0, 0, edge, edge);
|
||||
glBindVertexArray(m_vao);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
return ReadPixelsRect(0, 0, edge, edge);
|
||||
}
|
||||
|
||||
// Every row of `image` against the half it belongs to. A depth level is read in its red
|
||||
// channel only, and only in its bottom and top rows: the rows next to the boundary are
|
||||
// where a shader-based depth mip is entitled to a half-texel offset.
|
||||
static void ExpectHalves(const Image& image, const Format& format, const Rgb& bottom, const Rgb& top,
|
||||
float depthBottom, float depthTop, const std::string& what) {
|
||||
const int height = image.Height();
|
||||
for (int y = 0; y < height; ++y) {
|
||||
if (format.depth && y != 0 && y != height - 1) continue;
|
||||
const bool low = y < height / 2;
|
||||
for (int x = 0; x < image.Width(); ++x) {
|
||||
const Rgba8 got = image.At(x, y);
|
||||
if (format.depth) {
|
||||
const int want = ToByte(low ? depthBottom : depthTop);
|
||||
EXPECT_NEAR(got.r, want, 2) << what << " depth at (" << x << "," << y << ") got " << got;
|
||||
if (std::abs(got.r - want) > 2) return;
|
||||
continue;
|
||||
}
|
||||
const Rgb& colour = low ? bottom : top;
|
||||
const int want[3] = {ToByte(colour[0]), ToByte(colour[1]), ToByte(colour[2])};
|
||||
const int have[3] = {got.r, got.g, got.b};
|
||||
for (int c = 0; c < 3; ++c) {
|
||||
EXPECT_NEAR(have[c], want[c], 2) << what << " channel " << c << " at (" << x << ","
|
||||
<< y << ") got " << got;
|
||||
if (std::abs(have[c] - want[c]) > 2) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ExpectFlat(const Image& image, const Format& format, const Rgb& colour, float depth,
|
||||
const std::string& what) {
|
||||
ExpectHalves(image, format, colour, colour, depth, depth, what);
|
||||
}
|
||||
|
||||
void Generate() {
|
||||
m_mark = PipeStatsWindow::MarkLaneLog();
|
||||
glBindTexture(GL_TEXTURE_2D, m_texture);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "glGenerateMipmap";
|
||||
}
|
||||
|
||||
// Under the knob the SERVER must say it filtered on the CPU; without that line the entry
|
||||
// ran the native arm and its green says nothing about the arm it is named for.
|
||||
void ExpectCpuArmNamed() {
|
||||
if (!m_forcedCpu || !m_wire || !m_espryt) return;
|
||||
const std::string log = PipeStatsWindow::ReadServerLogSince(m_mark);
|
||||
EXPECT_NE(log.find(kCpuMipmapMarker), std::string::npos)
|
||||
<< kForceCpuMipmap << " is set but the server log after glGenerateMipmap carries no '"
|
||||
<< kCpuMipmapMarker << "' line: the knob did not reach the server, or the three-channel "
|
||||
<< "generation never took the server's CPU arm";
|
||||
}
|
||||
|
||||
// ---- B1: the generated window, on the two formats Espryt blits level by level ----------
|
||||
|
||||
// Levels 0..2 defined, MAX_LEVEL = 2: the descriptor holds three of the chain's five levels.
|
||||
void MutableMaxLevelTwo(const Format& format) {
|
||||
if (MonolithDefect(true, !format.depth)) GTEST_SKIP() << (m_espryt ? kM2 : kM3);
|
||||
NewTexture();
|
||||
DefineLevel(format, 0, kEdge, Halves(format, kEdge, kBottom, kTop, kDepthBottom, kDepthTop));
|
||||
DefineLevel(format, 1, kEdge / 2, Flat(format, kEdge / 2, kSentinel, kDepthLevelZero));
|
||||
DefineLevel(format, 2, kEdge / 4, Flat(format, kEdge / 4, kSentinel, kDepthLevelZero));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "define levels 0..2";
|
||||
Generate();
|
||||
EXPECT_EQ(LevelWidth(3), 0) << format.name << ": level 3 is past MAX_LEVEL and must stay undefined";
|
||||
for (int level = 1; level <= 2; ++level)
|
||||
ExpectHalves(SampleLevel(level, 2), format, kBottom, kTop, kDepthBottom, kDepthTop,
|
||||
std::string(format.name) + " MAX_LEVEL=2 level " + std::to_string(level));
|
||||
ExpectHalves(SampleLevel(0, 2), format, kBottom, kTop, kDepthBottom, kDepthTop,
|
||||
std::string(format.name) + " MAX_LEVEL=2 level 0 (the base, unchanged)");
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
}
|
||||
|
||||
// glTexStorage2D with three of the chain's five levels.
|
||||
void PartialStorage(const Format& format) {
|
||||
if (MonolithDefect(false, !format.depth)) GTEST_SKIP() << kM3;
|
||||
NewTexture();
|
||||
glTexStorage2D(GL_TEXTURE_2D, 3, format.internalFormat, kEdge, kEdge);
|
||||
UploadLevel(format, 0, kEdge, Halves(format, kEdge, kBottom, kTop, kDepthBottom, kDepthTop));
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "partial storage";
|
||||
Generate();
|
||||
for (int level = 1; level <= 2; ++level)
|
||||
ExpectHalves(SampleLevel(level, 2), format, kBottom, kTop, kDepthBottom, kDepthTop,
|
||||
std::string(format.name) + " three-level storage level " + std::to_string(level));
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
}
|
||||
|
||||
// BASE_LEVEL = 1, MAX_LEVEL = 2 over four defined levels: only level 2 is generated, from
|
||||
// level 1; levels 0 and 3 keep what they held and level 4 is never defined.
|
||||
void MutableBaseLevelOne(const Format& format) {
|
||||
if (MonolithDefect(true, !format.depth)) GTEST_SKIP() << (m_espryt ? kM2 : kM3);
|
||||
NewTexture();
|
||||
DefineLevel(format, 0, kEdge, Flat(format, kEdge, kLevelZero, kDepthLevelZero));
|
||||
DefineLevel(format, 1, kEdge / 2,
|
||||
Halves(format, kEdge / 2, kBottom, kTop, kDepthBottom, kDepthTop));
|
||||
DefineLevel(format, 2, kEdge / 4, Flat(format, kEdge / 4, kLevelTwo, kDepthLevelTwo));
|
||||
DefineLevel(format, 3, kEdge / 8, Flat(format, kEdge / 8, kLevelThree, kDepthLevelThree));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "define levels 0..3";
|
||||
Generate();
|
||||
EXPECT_EQ(LevelWidth(4), 0) << format.name << ": level 4 is past MAX_LEVEL and must stay undefined";
|
||||
const std::string name(format.name);
|
||||
ExpectFlat(SampleLevel(0, 3), format, kLevelZero, kDepthLevelZero, name + " level 0 (below BASE_LEVEL)");
|
||||
ExpectHalves(SampleLevel(1, 3), format, kBottom, kTop, kDepthBottom, kDepthTop, name + " level 1 (base)");
|
||||
ExpectHalves(SampleLevel(2, 3), format, kBottom, kTop, kDepthBottom, kDepthTop,
|
||||
name + " level 2 (generated from level 1)");
|
||||
ExpectFlat(SampleLevel(3, 3), format, kLevelThree, kDepthLevelThree,
|
||||
name + " level 3 (past MAX_LEVEL)");
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
}
|
||||
|
||||
// ---- B2: RGB16F / RGB32F ----------------------------------------------------------------
|
||||
|
||||
void UploadedBase(const Format& format) {
|
||||
NewTexture();
|
||||
DefineLevel(format, 0, kEdge, Halves(format, kEdge, kBottom, kTop, 0, 0));
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "define level 0";
|
||||
Generate();
|
||||
const int last = 4;
|
||||
for (int level = 1; level < last; ++level)
|
||||
ExpectHalves(SampleLevel(level, last), format, kBottom, kTop, 0, 0,
|
||||
std::string(format.name) + " uploaded base, level " + std::to_string(level));
|
||||
EXPECT_EQ(LevelWidth(last), 1) << format.name << ": the generated chain ends at 1x1";
|
||||
ExpectCpuArmNamed();
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
}
|
||||
|
||||
// Complementary's colortex2 shape: the base is a render target the GPU wrote after its one
|
||||
// upload, so the chain must come from the GPU's level 0 and never from the uploaded texels.
|
||||
void RenderTargetBase(const Format& format) {
|
||||
if (MonolithDefect(true, false)) GTEST_SKIP() << kM1;
|
||||
PaintSentinelBaseAsRenderTarget(format);
|
||||
if (HasFatalFailure() || IsSkipped()) return;
|
||||
Generate();
|
||||
const int last = 4;
|
||||
for (int level = 0; level < last; ++level)
|
||||
ExpectHalves(SampleLevel(level, last), format, kBottom, kTop, 0, 0,
|
||||
std::string(format.name) + " render-target base, level " + std::to_string(level));
|
||||
ExpectCpuArmNamed();
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
}
|
||||
|
||||
// ---- P8-SE: the CPU arm's store route under a refused readback ----------------------
|
||||
|
||||
// Only the `CpuMipRefused.` entries carry both server knobs; anywhere else the store route
|
||||
// is unreachable on a host (its driver reads every level back) and the case says so.
|
||||
void SkipUnlessTheStoreRouteIsArmed() {
|
||||
if (m_wire && m_espryt && m_forcedCpu && m_refusedReadback) return;
|
||||
GTEST_SKIP() << "the store route needs Espryt's split server with " << kForceCpuMipmap << " and "
|
||||
<< kRefuseReadback << "=" << kEdge << "x" << kEdge << " (the CpuMipRefused. entries)";
|
||||
}
|
||||
|
||||
// The render-target base again, with the driver refusing to read level 0 back: the store
|
||||
// holds the uploaded sentinel, the driver the drawn halves, and P8-E's mark says so. The
|
||||
// arm must decline by name - a stale chain of sentinel texels is the defect.
|
||||
void RefusedReadbackOfADrawnBase(const Format& format) {
|
||||
SkipUnlessTheStoreRouteIsArmed();
|
||||
if (IsSkipped()) return;
|
||||
PaintSentinelBaseAsRenderTarget(format);
|
||||
if (HasFatalFailure() || IsSkipped()) return;
|
||||
Generate();
|
||||
const std::string log = PipeStatsWindow::ReadServerLogSince(m_mark);
|
||||
EXPECT_NE(log.find(kStoreDeclinedMarker), std::string::npos)
|
||||
<< "the base level was drawn and its readback refused, but the server log after glGenerateMipmap "
|
||||
"has no '" << kStoreDeclinedMarker << "' line";
|
||||
EXPECT_EQ(log.find(kStoreFilteredMarker), std::string::npos)
|
||||
<< "the CPU arm filtered the staged store's copy of a level the driver has since drawn over";
|
||||
const int last = 4;
|
||||
ExpectHalves(SampleLevel(0, last), format, kBottom, kTop, 0, 0,
|
||||
std::string(format.name) + " drawn base (untouched by the decline)");
|
||||
for (int level = 1; level < last; ++level) {
|
||||
const Image image = SampleLevel(level, last);
|
||||
const Rgba8 got = image.At(0, 0);
|
||||
EXPECT_FALSE(std::abs(got.r - ToByte(kSentinel[0])) <= 2 && std::abs(got.g - ToByte(kSentinel[1])) <= 2 &&
|
||||
std::abs(got.b - ToByte(kSentinel[2])) <= 2)
|
||||
<< format.name << " level " << level << " is the uploaded sentinel " << got
|
||||
<< ": the chain was filtered from the stale staged store";
|
||||
}
|
||||
ExpectCpuArmNamed();
|
||||
FirstGLError();
|
||||
}
|
||||
|
||||
// The control: a base that only ever crossed as an upload IS what the store holds, so a
|
||||
// refused readback is answered from the store and the chain is right. This is what tells
|
||||
// the check above from "the store route always declines" - the generation's own
|
||||
// driver-write note must not count against the level it reads.
|
||||
void RefusedReadbackOfAnUploadedBase(const Format& format) {
|
||||
SkipUnlessTheStoreRouteIsArmed();
|
||||
if (IsSkipped()) return;
|
||||
NewTexture();
|
||||
DefineLevel(format, 0, kEdge, Halves(format, kEdge, kBottom, kTop, 0, 0));
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "define level 0";
|
||||
Generate();
|
||||
const std::string log = PipeStatsWindow::ReadServerLogSince(m_mark);
|
||||
EXPECT_NE(log.find(kStoreFilteredMarker), std::string::npos)
|
||||
<< "the uploaded base's readback was refused, but the server log has no '" << kStoreFilteredMarker
|
||||
<< "' line: the store route did not answer";
|
||||
EXPECT_EQ(log.find(kStoreDeclinedMarker), std::string::npos)
|
||||
<< "the store route declined a level that only ever crossed as an upload";
|
||||
const int last = 4;
|
||||
for (int level = 1; level < last; ++level)
|
||||
ExpectHalves(SampleLevel(level, last), format, kBottom, kTop, 0, 0,
|
||||
std::string(format.name) + " uploaded base, store-filtered level " +
|
||||
std::to_string(level));
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
}
|
||||
|
||||
// Level 0 uploaded as the sentinel, then drawn over as a render target (bottom / top halves).
|
||||
void PaintSentinelBaseAsRenderTarget(const Format& format) {
|
||||
NewTexture();
|
||||
DefineLevel(format, 0, kEdge, Flat(format, kEdge, kSentinel, 0));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0);
|
||||
const GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
FirstGLError();
|
||||
GTEST_SKIP() << format.name << " is not colour-renderable on " << Gl().BackendName()
|
||||
<< " (status 0x" << std::hex << status << ")";
|
||||
}
|
||||
glViewport(0, 0, kEdge, kEdge);
|
||||
glUseProgram(m_paintProgram);
|
||||
glUniform4f(glGetUniformLocation(m_paintProgram, "u_bottom"), kBottom[0], kBottom[1], kBottom[2], 1);
|
||||
glUniform4f(glGetUniformLocation(m_paintProgram, "u_top"), kTop[0], kTop[1], kTop[2], 1);
|
||||
glUniform1f(glGetUniformLocation(m_paintProgram, "u_split"), kEdge / 2.0f);
|
||||
glBindVertexArray(m_vao);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "draw into level 0";
|
||||
}
|
||||
|
||||
bool m_wire = false;
|
||||
bool m_espryt = false;
|
||||
bool m_forcedCpu = false;
|
||||
bool m_refusedReadback = false;
|
||||
GLuint m_sampleProgram = 0;
|
||||
GLuint m_paintProgram = 0;
|
||||
GLuint m_vao = 0;
|
||||
GLuint m_fbo = 0;
|
||||
GLuint m_texture = 0;
|
||||
ColorFbo m_target{};
|
||||
PipeStatsWindow::LogMark m_mark{};
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// B1.
|
||||
TEST_F(GenerateMipmapServerScenario, PackedFloatMutableMaxLevelBelowTheChain) {
|
||||
if (!Ready()) return;
|
||||
MutableMaxLevelTwo(kPackedFloat);
|
||||
}
|
||||
TEST_F(GenerateMipmapServerScenario, PackedFloatStorageWithFewerLevelsThanTheChain) {
|
||||
if (!Ready()) return;
|
||||
PartialStorage(kPackedFloat);
|
||||
}
|
||||
TEST_F(GenerateMipmapServerScenario, PackedFloatMutableBaseLevelOneKeepsTheLevelsOutsideItsWindow) {
|
||||
if (!Ready()) return;
|
||||
MutableBaseLevelOne(kPackedFloat);
|
||||
}
|
||||
TEST_F(GenerateMipmapServerScenario, DepthMutableMaxLevelBelowTheChain) {
|
||||
if (!Ready()) return;
|
||||
MutableMaxLevelTwo(kDepth32F);
|
||||
}
|
||||
TEST_F(GenerateMipmapServerScenario, DepthStorageWithFewerLevelsThanTheChain) {
|
||||
if (!Ready()) return;
|
||||
PartialStorage(kDepth32F);
|
||||
}
|
||||
TEST_F(GenerateMipmapServerScenario, DepthMutableBaseLevelOneKeepsTheLevelsOutsideItsWindow) {
|
||||
if (!Ready()) return;
|
||||
MutableBaseLevelOne(kDepth32F);
|
||||
}
|
||||
|
||||
// B2.
|
||||
TEST_F(GenerateMipmapServerScenario, Rgb16fUploadedBaseGeneratesItsChain) {
|
||||
if (!Ready()) return;
|
||||
UploadedBase(kRgb16F);
|
||||
}
|
||||
TEST_F(GenerateMipmapServerScenario, Rgb16fRenderTargetBaseGeneratesFromTheGpuWrittenLevel) {
|
||||
if (!Ready()) return;
|
||||
RenderTargetBase(kRgb16F);
|
||||
}
|
||||
TEST_F(GenerateMipmapServerScenario, Rgb32fUploadedBaseGeneratesItsChain) {
|
||||
if (!Ready()) return;
|
||||
UploadedBase(kRgb32F);
|
||||
}
|
||||
TEST_F(GenerateMipmapServerScenario, Rgb32fRenderTargetBaseGeneratesFromTheGpuWrittenLevel) {
|
||||
if (!Ready()) return;
|
||||
RenderTargetBase(kRgb32F);
|
||||
}
|
||||
|
||||
// P8-SE: the CPU arm's store route (header; the CpuMipRefused. entries).
|
||||
TEST_F(GenerateMipmapServerScenario, Rgb16fDrawnBaseWithARefusedReadbackDeclinesByName) {
|
||||
if (!Ready()) return;
|
||||
RefusedReadbackOfADrawnBase(kRgb16F);
|
||||
}
|
||||
TEST_F(GenerateMipmapServerScenario, Rgb16fUploadedBaseWithARefusedReadbackIsFilteredFromTheStore) {
|
||||
if (!Ready()) return;
|
||||
RefusedReadbackOfAnUploadedBase(kRgb16F);
|
||||
}
|
||||
|
||||
} // namespace MGITest
|
||||
@@ -0,0 +1,800 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Scenarios/GpuWrittenDrawInputScenario.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 - DRAW INPUTS A SHADER WROTE, READ BY A BACKEND ON THE CPU (P8-C).
|
||||
//
|
||||
// Espryt emulates five desktop-GL draw features on the CPU, and each one reads a buffer's bytes
|
||||
// on the side that applies the draw:
|
||||
//
|
||||
// * the primitive-restart rewrite (an application restart index that is not the all-ones value
|
||||
// of the index type): the whole element array buffer, rewritten into a scratch copy;
|
||||
// * the multi-draw rebase tier, which a batch with such a restart index is forced onto;
|
||||
// * *IndirectCount: the count word of the parameter buffer (GLES has no counted indirect draw);
|
||||
// * a native indirect draw's gl_BaseVertex, fed to the shader as a uniform from the command;
|
||||
// * a GL_DOUBLE vertex array, narrowed to float from the source buffer's bytes.
|
||||
//
|
||||
// Under split those bytes are the server's R-11 staged copy, which only uploads fill. A buffer a
|
||||
// shader WROTE on the server - storage block, atomic counter, buffer image, transform feedback -
|
||||
// is therefore read stale unless the server refreshes its copy first. Every case below writes
|
||||
// the buffer on the GPU only (the staged copy holds a poison the correct picture cannot come
|
||||
// from), so a stale read is a wrong picture, never a lucky one.
|
||||
//
|
||||
// MONOLITH ARMS KNOWN BROKEN HERE SKIP BY NAME (SkipBrokenMonolith). Espryt reads three from the
|
||||
// frontend shadow without SyncGpuWrites: *IndirectCount (OPEN-QUESTIONS 15), an indirect
|
||||
// gl_BaseVertex (the comment beside it in DirectGLES.cpp says so) and a GL_DOUBLE vertex array
|
||||
// (the M-3 deviation declared in Managers.cpp). Magma reads MultiDrawArraysIndirectCount's count
|
||||
// the same way, and its restart rewrite and GL_DOUBLE conversion call SyncGpuWrites while the
|
||||
// draw is being recorded, so the draw then records into an ended command buffer (SIGSEGV in
|
||||
// lavapipe). Those arms are dev's to fix (ID-P8-3); the skip keeps the ambient monolith lane
|
||||
// honest without hiding the split arms, which run the same cases under DirectGLES.Split/Spawn/Tcp,
|
||||
// DirectVulkan.*.Full and the inproc A/B.
|
||||
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../Harness/HeadlessGL.h"
|
||||
#include "../Harness/ScenarioFixture.h"
|
||||
#include "../Harness/SplitRuntimePeek.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 kSurface = 64;
|
||||
|
||||
constexpr const char* kFlatVertex = R"(#version 430 core
|
||||
layout(location = 0) in vec2 aPos;
|
||||
void main() { gl_Position = vec4(aPos, 0.0, 1.0); }
|
||||
)";
|
||||
|
||||
constexpr const char* kFlatFragment = R"(#version 430 core
|
||||
out vec4 oColor;
|
||||
void main() { oColor = vec4(0.0, 1.0, 0.0, 1.0); }
|
||||
)";
|
||||
|
||||
// Green when the shader saw gl_BaseVertex == 9 (the value the compute shader wrote),
|
||||
// red for anything else - in particular 3, the value the staged copy still holds.
|
||||
constexpr const char* kBaseVertexVertex = R"(#version 450 core
|
||||
#extension GL_ARB_shader_draw_parameters : require
|
||||
layout(location = 0) in vec2 aPos;
|
||||
flat out vec4 vColor;
|
||||
void main() {
|
||||
vColor = gl_BaseVertexARB == 9 ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
|
||||
gl_Position = vec4(aPos, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
constexpr const char* kBaseVertexFragment = R"(#version 450 core
|
||||
flat in vec4 vColor;
|
||||
out vec4 oColor;
|
||||
void main() { oColor = vColor; }
|
||||
)";
|
||||
|
||||
// ---- the restart scene (PrimitiveRestartScenario's geometry) ----
|
||||
//
|
||||
// Two triangles with a gap between them, plus two spare vertices at the origin. Index 7 is
|
||||
// the application's restart index and a legal vertex, so a dropped restart welds the strip
|
||||
// across the gap (caught by the gap probe) instead of reading out of bounds.
|
||||
constexpr GLfloat kRestartVertices[] = {
|
||||
-0.9f, -0.9f, -0.1f, -0.9f, -0.9f, 0.9f, // 0-2: left triangle
|
||||
0.1f, -0.9f, 0.9f, -0.9f, 0.9f, 0.9f, // 3-5: right triangle
|
||||
0.0f, 0.0f, 0.0f, 0.0f, // 6, 7: spares
|
||||
};
|
||||
constexpr GLuint kRestartIndex = 7;
|
||||
constexpr GLuint kRestartIndexCount = 7;
|
||||
// What the compute shader writes: {0, 1, 2, 7, 3, 4, 5}.
|
||||
constexpr const char* kWriteRestartIndices = R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(std430, binding = 0) buffer Indices { uint value[]; };
|
||||
void main() {
|
||||
value[0] = 0u; value[1] = 1u; value[2] = 2u; value[3] = 7u;
|
||||
value[4] = 3u; value[5] = 4u; value[6] = 5u;
|
||||
}
|
||||
)";
|
||||
// The staged poison: every index names spare vertex 6, a strip of degenerate triangles
|
||||
// that paints nothing.
|
||||
const std::vector<GLuint> kRestartPoison(kRestartIndexCount, 6u);
|
||||
|
||||
// The same seven indices, produced by a TRANSFORM FEEDBACK capture: one point per index.
|
||||
constexpr const char* kCaptureIndicesVertex = R"(#version 430 core
|
||||
flat out uint idx;
|
||||
const uint kTable[7] = uint[7](0u, 1u, 2u, 7u, 3u, 4u, 5u);
|
||||
void main() {
|
||||
idx = kTable[gl_VertexID];
|
||||
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
gl_PointSize = 1.0;
|
||||
}
|
||||
)";
|
||||
// ...and by a capture with a HOLE after every index (gl_SkipComponents1), which ES cannot
|
||||
// express and Espryt therefore scatters itself. The captured words land at the even
|
||||
// slots; the odd slots keep what the application staged there.
|
||||
constexpr const char* kCaptureScatteredVertex = R"(#version 430 core
|
||||
flat out uint idx;
|
||||
const uint kTable[4] = uint[4](0u, 2u, 3u, 5u);
|
||||
void main() {
|
||||
idx = kTable[gl_VertexID];
|
||||
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
gl_PointSize = 1.0;
|
||||
}
|
||||
)";
|
||||
constexpr const char* kCaptureFragment = R"(#version 430 core
|
||||
out vec4 oColor;
|
||||
void main() { oColor = vec4(1.0); }
|
||||
)";
|
||||
// Even slots are the capture's (poison 6 until it lands), odd slots the holes: after the
|
||||
// scatter the first seven words are {0, 1, 2, 7, 3, 4, 5}; before it, a strip of
|
||||
// degenerate triangles.
|
||||
constexpr GLuint kScatterStaged[8] = {6u, 1u, 6u, 7u, 6u, 4u, 6u, 6u};
|
||||
|
||||
// ...and by IMAGE STORES into a buffer texture over the element array buffer.
|
||||
constexpr const char* kImageStoreRestartIndices = R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(r32ui, binding = 0) uniform writeonly uimageBuffer indices;
|
||||
const uint kTable[7] = uint[7](0u, 1u, 2u, 7u, 3u, 4u, 5u);
|
||||
void main() {
|
||||
for (int i = 0; i < 7; ++i) imageStore(indices, i, uvec4(kTable[i]));
|
||||
}
|
||||
)";
|
||||
|
||||
// NDC (-0.5, -0.5), (0.6, -0.5), (0.2, -0.5) on the 64x64 surface.
|
||||
constexpr int kLeftX = 16, kRightX = 51, kGapX = 38, kProbeY = 16;
|
||||
|
||||
// ---- the indirect scene (DrawParametersScenario's geometry) ----
|
||||
//
|
||||
// Three pad vertices at the origin, then the left half of the surface as two triangles
|
||||
// (vertices 3-8), then the right half (9-14). Element indices 0..5 address one half
|
||||
// through the command's baseVertex.
|
||||
constexpr int kLeftFirst = 3;
|
||||
constexpr int kRightFirst = 9;
|
||||
constexpr int kHalfCount = 6;
|
||||
|
||||
std::vector<GLfloat> HalvesVertices() {
|
||||
std::vector<GLfloat> v(6, 0.0f);
|
||||
const float bounds[2][2] = {{-1.0f, 0.0f}, {0.0f, 1.0f}};
|
||||
for (const auto& half : bounds) {
|
||||
const float x0 = half[0];
|
||||
const float x1 = half[1];
|
||||
const float quad[] = {x0, -1.0f, x1, -1.0f, x1, 1.0f, x0, -1.0f, x1, 1.0f, x0, 1.0f};
|
||||
v.insert(v.end(), std::begin(quad), std::end(quad));
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
struct ElementsCommand {
|
||||
std::uint32_t count, instanceCount, firstIndex;
|
||||
std::int32_t baseVertex;
|
||||
std::uint32_t baseInstance;
|
||||
};
|
||||
struct ArraysCommand {
|
||||
std::uint32_t count, instanceCount, first, baseInstance;
|
||||
};
|
||||
|
||||
bool IsGreen(const Rgba8& p) { return p.g > 128 && p.r < 128; }
|
||||
|
||||
class GpuWrittenDrawInputScenario : public ScenarioTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ScenarioTest::SetUp();
|
||||
if (!Ready()) return;
|
||||
m_target = MakeColorFbo(kSurface, kSurface);
|
||||
ASSERT_NE(m_target.fbo, 0u) << "the 64x64 colour target did not build";
|
||||
glGenVertexArrays(1, &m_vao);
|
||||
glBindVertexArray(m_vao);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
DrainErrors();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (!Ready()) return;
|
||||
glDisable(GL_PRIMITIVE_RESTART);
|
||||
glPrimitiveRestartIndex(0);
|
||||
glUseProgram(0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0);
|
||||
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
|
||||
glBindBuffer(GL_PARAMETER_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
glBindImageTexture(0, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R32UI);
|
||||
if (m_texture != 0) glDeleteTextures(1, &m_texture);
|
||||
m_texture = 0;
|
||||
for (GLuint* buffer : {&m_vbo, &m_ebo, &m_commands, &m_parameters}) {
|
||||
if (*buffer != 0) glDeleteBuffers(1, buffer);
|
||||
*buffer = 0;
|
||||
}
|
||||
if (m_vao != 0) glDeleteVertexArrays(1, &m_vao);
|
||||
for (GLuint program : m_programs) glDeleteProgram(program);
|
||||
m_programs.clear();
|
||||
BindDefaultFramebuffer();
|
||||
DestroyColorFbo(m_target);
|
||||
DrainErrors();
|
||||
}
|
||||
|
||||
static void DrainErrors() {
|
||||
for (int i = 0; i < 16 && glGetError() != GL_NO_ERROR; ++i) {
|
||||
}
|
||||
}
|
||||
|
||||
// THE ARMS THIS FILE SKIPS, BY NAME: the monolith arm of a backend whose reason is
|
||||
// non-null. Every split arm, and the inproc A/B, runs the case.
|
||||
bool SkipBrokenMonolith(const char* espryt, const char* magma) {
|
||||
if (PeekSplitRuntime().transportName != "monolith") return false;
|
||||
const std::string backend = Gl().BackendName();
|
||||
const char* why = backend == "DirectGLES" ? espryt : backend == "DirectVulkan" ? magma : nullptr;
|
||||
if (why == nullptr) return false;
|
||||
m_skipReason = "monolith " + backend + ": " + why +
|
||||
" (dev's fix, ID-P8-3) - this case gates the split arms";
|
||||
return true;
|
||||
}
|
||||
static constexpr const char* kUnsyncedCount =
|
||||
"the *IndirectCount count is read from the frontend shadow without SyncGpuWrites "
|
||||
"(OPEN-QUESTIONS 15)";
|
||||
static constexpr const char* kUnsyncedBaseVertex =
|
||||
"an indirect command's gl_BaseVertex is read from the frontend shadow without "
|
||||
"SyncGpuWrites";
|
||||
static constexpr const char* kUnsyncedDoubles =
|
||||
"a GL_DOUBLE vertex array is narrowed from the client shadow without SyncGpuWrites "
|
||||
"(the M-3 deviation declared in Managers.cpp)";
|
||||
static constexpr const char* kSyncMidRecording =
|
||||
"SyncGpuWrites inside the draw (the restart rewrite, the GL_DOUBLE vertex conversion) "
|
||||
"submits the frame mid-recording and the draw then records into the ended command "
|
||||
"buffer (SIGSEGV)";
|
||||
|
||||
GLuint Program(const char* vertex, const char* fragment) {
|
||||
std::string error;
|
||||
const GLuint program = CompileProgram(vertex, fragment, &error);
|
||||
EXPECT_NE(program, 0u) << error;
|
||||
if (program != 0) m_programs.push_back(program);
|
||||
return program;
|
||||
}
|
||||
|
||||
GLuint ComputeProgram(const char* source) {
|
||||
const GLuint shader = glCreateShader(GL_COMPUTE_SHADER);
|
||||
glShaderSource(shader, 1, &source, nullptr);
|
||||
glCompileShader(shader);
|
||||
GLint compiled = GL_FALSE;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
|
||||
if (!compiled) {
|
||||
char log[4096]{};
|
||||
glGetShaderInfoLog(shader, sizeof(log), nullptr, log);
|
||||
ADD_FAILURE() << log;
|
||||
glDeleteShader(shader);
|
||||
return 0;
|
||||
}
|
||||
const GLuint program = glCreateProgram();
|
||||
glAttachShader(program, shader);
|
||||
glLinkProgram(program);
|
||||
glDeleteShader(shader);
|
||||
GLint linked = GL_FALSE;
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &linked);
|
||||
if (!linked) {
|
||||
char log[4096]{};
|
||||
glGetProgramInfoLog(program, sizeof(log), nullptr, log);
|
||||
ADD_FAILURE() << log;
|
||||
glDeleteProgram(program);
|
||||
return 0;
|
||||
}
|
||||
m_programs.push_back(program);
|
||||
return program;
|
||||
}
|
||||
|
||||
// Buffer `name` at `target` with `bytes` bytes of `data` (null: an orphaned store).
|
||||
static void Store(GLuint& name, GLenum target, GLsizeiptr bytes, const void* data) {
|
||||
if (name == 0) glGenBuffers(1, &name);
|
||||
glBindBuffer(target, name);
|
||||
glBufferData(target, bytes, data, GL_DYNAMIC_COPY);
|
||||
}
|
||||
|
||||
void BindVertices(const GLfloat* vertices, GLsizeiptr bytes) {
|
||||
glBindVertexArray(m_vao);
|
||||
Store(m_vbo, GL_ARRAY_BUFFER, bytes, vertices);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), nullptr);
|
||||
}
|
||||
|
||||
// One dispatch of `source` with `first` (and `second`, if non-zero) bound as storage
|
||||
// buffers 0 and 1, then the barrier the draw that consumes them needs.
|
||||
void WriteWithCompute(const char* source, GLuint first, GLuint second, GLbitfield barrier) {
|
||||
const GLuint compute = ComputeProgram(source);
|
||||
ASSERT_NE(compute, 0u);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, first);
|
||||
if (second != 0) glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, second);
|
||||
glUseProgram(compute);
|
||||
glDispatchCompute(1, 1, 1);
|
||||
glMemoryBarrier(barrier | GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
template <typename DrawFn>
|
||||
Image Render(GLuint program, DrawFn&& draw) {
|
||||
BindFbo(m_target);
|
||||
ClearTo(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glUseProgram(program);
|
||||
glBindVertexArray(m_vao);
|
||||
draw();
|
||||
return ReadPixels(kSurface, kSurface);
|
||||
}
|
||||
|
||||
// The element array buffer of the restart scene, written by a compute shader over the
|
||||
// poison (or over an orphaned store when `orphaned`).
|
||||
void BuildRestartScene(bool orphaned) {
|
||||
BindVertices(kRestartVertices, sizeof(kRestartVertices));
|
||||
Store(m_ebo, GL_ELEMENT_ARRAY_BUFFER, kRestartIndexCount * sizeof(GLuint),
|
||||
orphaned ? nullptr : kRestartPoison.data());
|
||||
WriteWithCompute(kWriteRestartIndices, m_ebo, 0, GL_ELEMENT_ARRAY_BARRIER_BIT);
|
||||
ArmRestart();
|
||||
}
|
||||
|
||||
// The element array buffer bound to the scene's VAO, restart index 7 on.
|
||||
void ArmRestart() {
|
||||
glBindVertexArray(m_vao);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo);
|
||||
glEnable(GL_PRIMITIVE_RESTART);
|
||||
glPrimitiveRestartIndex(kRestartIndex);
|
||||
}
|
||||
|
||||
// A vertex + fragment program whose `varyings` are captured INTERLEAVED.
|
||||
GLuint XfbProgram(const char* vertex, const char* fragment, const char* const* varyings,
|
||||
GLsizei count) {
|
||||
const GLuint vs = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(vs, 1, &vertex, nullptr);
|
||||
glCompileShader(vs);
|
||||
const GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(fs, 1, &fragment, nullptr);
|
||||
glCompileShader(fs);
|
||||
const GLuint program = glCreateProgram();
|
||||
glAttachShader(program, vs);
|
||||
glAttachShader(program, fs);
|
||||
glTransformFeedbackVaryings(program, count, varyings, GL_INTERLEAVED_ATTRIBS);
|
||||
glLinkProgram(program);
|
||||
glDeleteShader(vs);
|
||||
glDeleteShader(fs);
|
||||
GLint linked = GL_FALSE;
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &linked);
|
||||
if (!linked) {
|
||||
char log[4096]{};
|
||||
glGetProgramInfoLog(program, sizeof(log), nullptr, log);
|
||||
ADD_FAILURE() << "the capture program did not link: " << log;
|
||||
glDeleteProgram(program);
|
||||
return 0;
|
||||
}
|
||||
m_programs.push_back(program);
|
||||
return program;
|
||||
}
|
||||
|
||||
// `vertices` points drawn with rasterization off, captured into m_ebo from byte 0.
|
||||
void CaptureIntoElementBuffer(GLuint program, GLsizei vertices) {
|
||||
glBindVertexArray(m_vao);
|
||||
glUseProgram(program);
|
||||
glEnable(GL_RASTERIZER_DISCARD);
|
||||
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, m_ebo);
|
||||
glBeginTransformFeedback(GL_POINTS);
|
||||
glDrawArrays(GL_POINTS, 0, vertices);
|
||||
glEndTransformFeedback();
|
||||
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
|
||||
glDisable(GL_RASTERIZER_DISCARD);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
static void ExpectSplitStrip(const Image& image, const char* what) {
|
||||
EXPECT_TRUE(IsGreen(image.At(kLeftX, kProbeY)))
|
||||
<< what << ": the left triangle did not render (" << image.At(kLeftX, kProbeY)
|
||||
<< ") - the backend drew the indices it had staged, not the ones the compute "
|
||||
"shader wrote";
|
||||
EXPECT_TRUE(IsGreen(image.At(kRightX, kProbeY)))
|
||||
<< what << ": the right triangle did not render (" << image.At(kRightX, kProbeY) << ")";
|
||||
EXPECT_FALSE(IsGreen(image.At(kGapX, kProbeY)))
|
||||
<< what << ": the gap is covered, so the restart at index 7 was dropped";
|
||||
}
|
||||
|
||||
// Left and right half of the halves scene, sampled at their centres.
|
||||
static Rgba8 Half(const Image& image, int half) {
|
||||
return image.At(kSurface * (1 + 2 * half) / 4, kSurface / 2);
|
||||
}
|
||||
|
||||
ColorFbo m_target;
|
||||
GLuint m_vao = 0;
|
||||
GLuint m_vbo = 0;
|
||||
GLuint m_ebo = 0;
|
||||
GLuint m_commands = 0;
|
||||
GLuint m_parameters = 0;
|
||||
GLuint m_texture = 0;
|
||||
std::vector<GLuint> m_programs;
|
||||
std::string m_skipReason;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// ---- the primitive-restart rewrite (DirectGLES.cpp ScopedRestartIndexSubstitution) ----
|
||||
|
||||
TEST_F(GpuWrittenDrawInputScenario, RestartIndicesAComputeShaderWroteSplitTheStrip) {
|
||||
if (!Ready()) return;
|
||||
if (SkipBrokenMonolith(nullptr, kSyncMidRecording)) GTEST_SKIP() << m_skipReason;
|
||||
const GLuint program = Program(kFlatVertex, kFlatFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
BuildRestartScene(/*orphaned=*/false);
|
||||
const Image image = Render(program, [] {
|
||||
glDrawElements(GL_TRIANGLE_STRIP, kRestartIndexCount, GL_UNSIGNED_INT, nullptr);
|
||||
});
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
ExpectSplitStrip(image, "glDrawElements over compute-written restart indices");
|
||||
}
|
||||
|
||||
// The same indices in a store the application ORPHANED (glBufferData(NULL)): nothing was
|
||||
// ever staged for it, so the only copy of its bytes is the one the GPU holds.
|
||||
TEST_F(GpuWrittenDrawInputScenario, RestartIndicesAComputeShaderWroteIntoAnOrphanedStoreSplitTheStrip) {
|
||||
if (!Ready()) return;
|
||||
if (SkipBrokenMonolith(nullptr, kSyncMidRecording)) GTEST_SKIP() << m_skipReason;
|
||||
const GLuint program = Program(kFlatVertex, kFlatFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
BuildRestartScene(/*orphaned=*/true);
|
||||
const Image image = Render(program, [] {
|
||||
glDrawElements(GL_TRIANGLE_STRIP, kRestartIndexCount, GL_UNSIGNED_INT, nullptr);
|
||||
});
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
ExpectSplitStrip(image, "glDrawElements over compute-written restart indices in an orphaned store");
|
||||
}
|
||||
|
||||
// ---- the multi-draw rebase tier (MultiDraw.cpp RunRebasedDrawElements) ----
|
||||
//
|
||||
// An arbitrary restart index forces a multi-draw onto the one tier that rewrites the stream,
|
||||
// and that tier reads the whole element array buffer on the CPU. Sub-draw 0 is {0,1,2} (the
|
||||
// left triangle); sub-draw 1 is {7,3,4,5} (a restart, then the right triangle).
|
||||
TEST_F(GpuWrittenDrawInputScenario, RestartIndicesAComputeShaderWroteSplitEveryMultiDrawStrip) {
|
||||
if (!Ready()) return;
|
||||
if (SkipBrokenMonolith(nullptr, kSyncMidRecording)) GTEST_SKIP() << m_skipReason;
|
||||
const GLuint program = Program(kFlatVertex, kFlatFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
BuildRestartScene(/*orphaned=*/false);
|
||||
const GLsizei counts[2] = {3, 4};
|
||||
const void* offsets[2] = {nullptr, reinterpret_cast<const void*>(3 * sizeof(GLuint))};
|
||||
const Image image = Render(program, [&] {
|
||||
glMultiDrawElements(GL_TRIANGLE_STRIP, counts, GL_UNSIGNED_INT, offsets, 2);
|
||||
});
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
ExpectSplitStrip(image, "glMultiDrawElements over compute-written restart indices");
|
||||
}
|
||||
|
||||
// ---- *IndirectCount (DirectGLES.cpp MultiDraw{Elements,Arrays}IndirectCount) ----
|
||||
//
|
||||
// The compute shader writes BOTH commands and the count; the staged copies hold zeroes, so a
|
||||
// stale count draws nothing and a stale command (on a device without native indirect) draws
|
||||
// nothing either.
|
||||
TEST_F(GpuWrittenDrawInputScenario, ACountAComputeShaderWroteDrivesMultiDrawElementsIndirectCount) {
|
||||
if (!Ready()) return;
|
||||
if (SkipBrokenMonolith(kUnsyncedCount, nullptr)) GTEST_SKIP() << m_skipReason;
|
||||
const GLuint program = Program(kFlatVertex, kFlatFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
const std::vector<GLfloat> vertices = HalvesVertices();
|
||||
BindVertices(vertices.data(), static_cast<GLsizeiptr>(vertices.size() * sizeof(GLfloat)));
|
||||
const GLuint indices[kHalfCount] = {0, 1, 2, 3, 4, 5};
|
||||
Store(m_ebo, GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices);
|
||||
const ElementsCommand zeroCommands[2] = {};
|
||||
Store(m_commands, GL_DRAW_INDIRECT_BUFFER, sizeof(zeroCommands), zeroCommands);
|
||||
const GLuint zeroCount = 0;
|
||||
Store(m_parameters, GL_PARAMETER_BUFFER, sizeof(zeroCount), &zeroCount);
|
||||
WriteWithCompute(R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(std430, binding = 0) buffer Commands { uint command[]; };
|
||||
layout(std430, binding = 1) buffer Parameters { uint count; };
|
||||
void main() {
|
||||
command[0] = 6u; command[1] = 1u; command[2] = 0u; command[3] = 3u; command[4] = 0u;
|
||||
command[5] = 6u; command[6] = 1u; command[7] = 0u; command[8] = 9u; command[9] = 0u;
|
||||
count = 2u;
|
||||
}
|
||||
)",
|
||||
m_commands, m_parameters, GL_COMMAND_BARRIER_BIT);
|
||||
glBindVertexArray(m_vao);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo);
|
||||
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, m_commands);
|
||||
glBindBuffer(GL_PARAMETER_BUFFER, m_parameters);
|
||||
const Image image = Render(program, [] {
|
||||
glMultiDrawElementsIndirectCount(GL_TRIANGLES, GL_UNSIGNED_INT, nullptr, 0, 2, 0);
|
||||
});
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(IsGreen(Half(image, 0)))
|
||||
<< "command 0 did not draw (" << Half(image, 0)
|
||||
<< "): the count was read from a copy the compute shader never reached";
|
||||
EXPECT_TRUE(IsGreen(Half(image, 1))) << "command 1 did not draw (" << Half(image, 1) << ")";
|
||||
}
|
||||
|
||||
TEST_F(GpuWrittenDrawInputScenario, ACountAComputeShaderWroteDrivesMultiDrawArraysIndirectCount) {
|
||||
if (!Ready()) return;
|
||||
if (SkipBrokenMonolith(kUnsyncedCount, kUnsyncedCount)) GTEST_SKIP() << m_skipReason;
|
||||
const GLuint program = Program(kFlatVertex, kFlatFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
const std::vector<GLfloat> vertices = HalvesVertices();
|
||||
BindVertices(vertices.data(), static_cast<GLsizeiptr>(vertices.size() * sizeof(GLfloat)));
|
||||
const ArraysCommand zeroCommands[2] = {};
|
||||
Store(m_commands, GL_DRAW_INDIRECT_BUFFER, sizeof(zeroCommands), zeroCommands);
|
||||
const GLuint zeroCount = 0;
|
||||
Store(m_parameters, GL_PARAMETER_BUFFER, sizeof(zeroCount), &zeroCount);
|
||||
WriteWithCompute(R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(std430, binding = 0) buffer Commands { uint command[]; };
|
||||
layout(std430, binding = 1) buffer Parameters { uint count; };
|
||||
void main() {
|
||||
command[0] = 6u; command[1] = 1u; command[2] = 3u; command[3] = 0u;
|
||||
command[4] = 6u; command[5] = 1u; command[6] = 9u; command[7] = 0u;
|
||||
count = 2u;
|
||||
}
|
||||
)",
|
||||
m_commands, m_parameters, GL_COMMAND_BARRIER_BIT);
|
||||
glBindVertexArray(m_vao);
|
||||
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, m_commands);
|
||||
glBindBuffer(GL_PARAMETER_BUFFER, m_parameters);
|
||||
const Image image = Render(program, [] {
|
||||
glMultiDrawArraysIndirectCount(GL_TRIANGLES, nullptr, 0, 2, 0);
|
||||
});
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(IsGreen(Half(image, 0)))
|
||||
<< "command 0 did not draw (" << Half(image, 0)
|
||||
<< "): the count was read from a copy the compute shader never reached";
|
||||
EXPECT_TRUE(IsGreen(Half(image, 1))) << "command 1 did not draw (" << Half(image, 1) << ")";
|
||||
}
|
||||
|
||||
// ---- a native indirect draw's gl_BaseVertex (DirectGLES.cpp ExecuteIndexedIndirectCommands) ----
|
||||
//
|
||||
// The GPU executes the command itself, so the geometry is right whatever the backend's copy
|
||||
// says; gl_BaseVertex is the one field Espryt feeds from the CPU. The staged command names
|
||||
// the left half (baseVertex 3), the compute shader moves it to the right half (9).
|
||||
TEST_F(GpuWrittenDrawInputScenario, ABaseVertexAComputeShaderWroteReachesGlBaseVertex) {
|
||||
if (!Ready()) return;
|
||||
if (SkipBrokenMonolith(kUnsyncedBaseVertex, nullptr)) GTEST_SKIP() << m_skipReason;
|
||||
const GLuint program = Program(kBaseVertexVertex, kBaseVertexFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
const std::vector<GLfloat> vertices = HalvesVertices();
|
||||
BindVertices(vertices.data(), static_cast<GLsizeiptr>(vertices.size() * sizeof(GLfloat)));
|
||||
const GLuint indices[kHalfCount] = {0, 1, 2, 3, 4, 5};
|
||||
Store(m_ebo, GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices);
|
||||
const ElementsCommand staged{kHalfCount, 1, 0, kLeftFirst, 0};
|
||||
Store(m_commands, GL_DRAW_INDIRECT_BUFFER, sizeof(staged), &staged);
|
||||
WriteWithCompute(R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(std430, binding = 0) buffer Commands { int command[]; };
|
||||
void main() { command[3] = 9; }
|
||||
)",
|
||||
m_commands, 0, GL_COMMAND_BARRIER_BIT);
|
||||
glBindVertexArray(m_vao);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo);
|
||||
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, m_commands);
|
||||
const Image image = Render(program, [] {
|
||||
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, nullptr);
|
||||
});
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(IsGreen(Half(image, 1)))
|
||||
<< "the right half is " << Half(image, 1)
|
||||
<< ": red means the draw ran with the compute-written baseVertex but gl_BaseVertex was "
|
||||
"fed from the staged command; black means the draw did not run there at all";
|
||||
EXPECT_FALSE(IsGreen(Half(image, 0))) << "the left half drew: the GPU saw the staged command";
|
||||
}
|
||||
|
||||
// ---- indirect commands with no staged copy at all (DirectGLES.cpp ResolveIndirectCommandBytes) ----
|
||||
//
|
||||
// The command buffer is ORPHANED and only the compute shader ever writes it - the GPU-culling
|
||||
// shape. Nothing was staged for it, so a backend that needs a CPU copy before it will issue
|
||||
// the draw has to make one from its own GL buffer.
|
||||
TEST_F(GpuWrittenDrawInputScenario, IndirectCommandsAComputeShaderWroteIntoAnOrphanedStoreDraw) {
|
||||
if (!Ready()) return;
|
||||
const GLuint program = Program(kFlatVertex, kFlatFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
const std::vector<GLfloat> vertices = HalvesVertices();
|
||||
BindVertices(vertices.data(), static_cast<GLsizeiptr>(vertices.size() * sizeof(GLfloat)));
|
||||
const GLuint indices[kHalfCount] = {0, 1, 2, 3, 4, 5};
|
||||
Store(m_ebo, GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices);
|
||||
Store(m_commands, GL_DRAW_INDIRECT_BUFFER, sizeof(ElementsCommand), nullptr);
|
||||
WriteWithCompute(R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(std430, binding = 0) buffer Commands { uint command[]; };
|
||||
void main() { command[0] = 6u; command[1] = 1u; command[2] = 0u; command[3] = 3u; command[4] = 0u; }
|
||||
)",
|
||||
m_commands, 0, GL_COMMAND_BARRIER_BIT);
|
||||
glBindVertexArray(m_vao);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo);
|
||||
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, m_commands);
|
||||
const Image image = Render(program, [] {
|
||||
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, nullptr);
|
||||
});
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(IsGreen(Half(image, 0)))
|
||||
<< "the compute-written command did not draw (" << Half(image, 0)
|
||||
<< "): the backend refused a draw whose command buffer it had no CPU copy of";
|
||||
EXPECT_FALSE(IsGreen(Half(image, 1))) << "the right half drew: the command was not the one written";
|
||||
}
|
||||
|
||||
// ---- the other GPU writers: transform feedback, buffer images, atomic counters ----
|
||||
//
|
||||
// The same restart reader over indices a CAPTURE produced. Espryt maps the captured range
|
||||
// back at glEndTransformFeedback for the client; the server's own copy has to take it too.
|
||||
TEST_F(GpuWrittenDrawInputScenario, RestartIndicesATransformFeedbackCapturedSplitTheStrip) {
|
||||
if (!Ready()) return;
|
||||
if (SkipBrokenMonolith(nullptr, kSyncMidRecording)) GTEST_SKIP() << m_skipReason;
|
||||
const GLuint program = Program(kFlatVertex, kFlatFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
const char* varyings[] = {"idx"};
|
||||
const GLuint capture = XfbProgram(kCaptureIndicesVertex, kCaptureFragment, varyings, 1);
|
||||
ASSERT_NE(capture, 0u);
|
||||
BindVertices(kRestartVertices, sizeof(kRestartVertices));
|
||||
Store(m_ebo, GL_ELEMENT_ARRAY_BUFFER, kRestartIndexCount * sizeof(GLuint), kRestartPoison.data());
|
||||
CaptureIntoElementBuffer(capture, kRestartIndexCount);
|
||||
ArmRestart();
|
||||
const Image image = Render(program, [] {
|
||||
glDrawElements(GL_TRIANGLE_STRIP, kRestartIndexCount, GL_UNSIGNED_INT, nullptr);
|
||||
});
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
ExpectSplitStrip(image, "glDrawElements over restart indices a transform feedback captured");
|
||||
}
|
||||
|
||||
// ...through the SCATTER Espryt runs for a layout with holes: the server composes the range
|
||||
// from its pre-capture bytes and the captured words, and its own copy has to keep the result.
|
||||
TEST_F(GpuWrittenDrawInputScenario, RestartIndicesAScatteredTransformFeedbackCapturedSplitTheStrip) {
|
||||
if (!Ready()) return;
|
||||
if (SkipBrokenMonolith(nullptr, kSyncMidRecording)) GTEST_SKIP() << m_skipReason;
|
||||
const GLuint program = Program(kFlatVertex, kFlatFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
const char* varyings[] = {"idx", "gl_SkipComponents1"};
|
||||
const GLuint capture = XfbProgram(kCaptureScatteredVertex, kCaptureFragment, varyings, 2);
|
||||
ASSERT_NE(capture, 0u);
|
||||
BindVertices(kRestartVertices, sizeof(kRestartVertices));
|
||||
Store(m_ebo, GL_ELEMENT_ARRAY_BUFFER, sizeof(kScatterStaged), kScatterStaged);
|
||||
CaptureIntoElementBuffer(capture, 4);
|
||||
ArmRestart();
|
||||
const Image image = Render(program, [] {
|
||||
glDrawElements(GL_TRIANGLE_STRIP, kRestartIndexCount, GL_UNSIGNED_INT, nullptr);
|
||||
});
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
ExpectSplitStrip(image, "glDrawElements over restart indices a scattered capture composed");
|
||||
}
|
||||
|
||||
// ...and over indices IMAGE STORES wrote through a buffer texture on the element buffer.
|
||||
TEST_F(GpuWrittenDrawInputScenario, RestartIndicesImageStoresWroteSplitTheStrip) {
|
||||
if (!Ready()) return;
|
||||
if (SkipBrokenMonolith(nullptr, kSyncMidRecording)) GTEST_SKIP() << m_skipReason;
|
||||
const GLuint program = Program(kFlatVertex, kFlatFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
const GLuint compute = ComputeProgram(kImageStoreRestartIndices);
|
||||
ASSERT_NE(compute, 0u);
|
||||
BindVertices(kRestartVertices, sizeof(kRestartVertices));
|
||||
Store(m_ebo, GL_ELEMENT_ARRAY_BUFFER, kRestartIndexCount * sizeof(GLuint), kRestartPoison.data());
|
||||
glGenTextures(1, &m_texture);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, m_texture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32UI, m_ebo);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
glBindImageTexture(0, m_texture, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_R32UI);
|
||||
glUseProgram(compute);
|
||||
glDispatchCompute(1, 1, 1);
|
||||
glMemoryBarrier(GL_ELEMENT_ARRAY_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||
glUseProgram(0);
|
||||
glBindImageTexture(0, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R32UI);
|
||||
ArmRestart();
|
||||
const Image image = Render(program, [] {
|
||||
glDrawElements(GL_TRIANGLE_STRIP, kRestartIndexCount, GL_UNSIGNED_INT, nullptr);
|
||||
});
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
ExpectSplitStrip(image, "glDrawElements over restart indices image stores wrote");
|
||||
}
|
||||
|
||||
// The GPU-culling shape at its most common: the draw count is an ATOMIC COUNTER the compute
|
||||
// shader bumped once per surviving command, and that counter buffer is the parameter buffer.
|
||||
TEST_F(GpuWrittenDrawInputScenario, ACountAnAtomicCounterProducedDrivesMultiDrawElementsIndirectCount) {
|
||||
if (!Ready()) return;
|
||||
if (SkipBrokenMonolith(kUnsyncedCount, nullptr)) GTEST_SKIP() << m_skipReason;
|
||||
const GLuint program = Program(kFlatVertex, kFlatFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
const GLuint compute = ComputeProgram(R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(binding = 0, offset = 0) uniform atomic_uint drawCount;
|
||||
layout(std430, binding = 0) buffer Commands { uint command[]; };
|
||||
void main() {
|
||||
const uint baseVertex[2] = uint[2](3u, 9u);
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
uint slot = atomicCounterIncrement(drawCount);
|
||||
command[slot * 5u + 0u] = 6u;
|
||||
command[slot * 5u + 1u] = 1u;
|
||||
command[slot * 5u + 2u] = 0u;
|
||||
command[slot * 5u + 3u] = baseVertex[i];
|
||||
command[slot * 5u + 4u] = 0u;
|
||||
}
|
||||
}
|
||||
)");
|
||||
ASSERT_NE(compute, 0u);
|
||||
const std::vector<GLfloat> vertices = HalvesVertices();
|
||||
BindVertices(vertices.data(), static_cast<GLsizeiptr>(vertices.size() * sizeof(GLfloat)));
|
||||
const GLuint indices[kHalfCount] = {0, 1, 2, 3, 4, 5};
|
||||
Store(m_ebo, GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices);
|
||||
const ElementsCommand zeroCommands[2] = {};
|
||||
Store(m_commands, GL_DRAW_INDIRECT_BUFFER, sizeof(zeroCommands), zeroCommands);
|
||||
const GLuint zeroCount = 0;
|
||||
Store(m_parameters, GL_ATOMIC_COUNTER_BUFFER, sizeof(zeroCount), &zeroCount);
|
||||
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, m_parameters);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_commands);
|
||||
glUseProgram(compute);
|
||||
glDispatchCompute(1, 1, 1);
|
||||
glMemoryBarrier(GL_COMMAND_BARRIER_BIT | GL_ATOMIC_COUNTER_BARRIER_BIT | GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
glUseProgram(0);
|
||||
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
|
||||
glBindVertexArray(m_vao);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo);
|
||||
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, m_commands);
|
||||
glBindBuffer(GL_PARAMETER_BUFFER, m_parameters);
|
||||
const Image image = Render(program, [] {
|
||||
glMultiDrawElementsIndirectCount(GL_TRIANGLES, GL_UNSIGNED_INT, nullptr, 0, 2, 0);
|
||||
});
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(IsGreen(Half(image, 0)))
|
||||
<< "command 0 did not draw (" << Half(image, 0)
|
||||
<< "): the count was read from a copy the atomic counter never reached";
|
||||
EXPECT_TRUE(IsGreen(Half(image, 1))) << "command 1 did not draw (" << Half(image, 1) << ")";
|
||||
}
|
||||
|
||||
// ---- fp64 vertex narrowing (Managers.cpp SyncFloat64AttributeAsFloat32ByHandle) ----
|
||||
//
|
||||
// A GL_DOUBLE vertex array is narrowed to float on the CPU from the source buffer's bytes,
|
||||
// and the narrowed copy is memoised on the source's serial - which a GPU write never moves.
|
||||
// Two rounds: the first catches a stale read, the second a stale memo. The compute shader
|
||||
// writes each double as its two IEEE-754 words (low word 0), so it needs no fp64 itself.
|
||||
TEST_F(GpuWrittenDrawInputScenario, DoubleVerticesAComputeShaderWroteAreNarrowedFromTheWrittenBytes) {
|
||||
if (!Ready()) return;
|
||||
if (SkipBrokenMonolith(kUnsyncedDoubles, kSyncMidRecording)) GTEST_SKIP() << m_skipReason;
|
||||
const GLuint program = Program(kFlatVertex, kFlatFragment);
|
||||
ASSERT_NE(program, 0u);
|
||||
// Four vertices, x then y, all 100.0: a strip wholly off the surface.
|
||||
const double poison[8] = {100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0};
|
||||
glBindVertexArray(m_vao);
|
||||
Store(m_vbo, GL_ARRAY_BUFFER, sizeof(poison), poison);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_DOUBLE, GL_FALSE, 2 * sizeof(double), nullptr);
|
||||
|
||||
// High words: -1.0 = 0xBFF00000, 1.0 = 0x3FF00000, 0.0 = 0.
|
||||
const auto writeQuad = [&](const char* highWords) {
|
||||
const std::string source = std::string(R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(std430, binding = 0) buffer Positions { uint word[]; };
|
||||
void main() {
|
||||
const uint hi[8] = uint[8]()") + highWords + R"();
|
||||
for (int i = 0; i < 8; ++i) { word[2 * i] = 0u; word[2 * i + 1] = hi[i]; }
|
||||
}
|
||||
)";
|
||||
WriteWithCompute(source.c_str(), m_vbo, 0, GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT);
|
||||
};
|
||||
|
||||
// Round 1: the whole surface, (-1,-1) (1,-1) (-1,1) (1,1).
|
||||
writeQuad("0xBFF00000u, 0xBFF00000u, 0x3FF00000u, 0xBFF00000u, 0xBFF00000u, 0x3FF00000u, "
|
||||
"0x3FF00000u, 0x3FF00000u");
|
||||
Image image = Render(program, [] { glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); });
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(IsGreen(Half(image, 0)) && IsGreen(Half(image, 1)))
|
||||
<< "round 1: the quad is " << Half(image, 0) << " / " << Half(image, 1)
|
||||
<< " - black means the doubles were narrowed from the staged poison, not the written bytes";
|
||||
|
||||
// Round 2: only the left half, (-1,-1) (0,-1) (-1,1) (0,1).
|
||||
writeQuad("0xBFF00000u, 0xBFF00000u, 0u, 0xBFF00000u, 0xBFF00000u, 0x3FF00000u, 0u, 0x3FF00000u");
|
||||
image = Render(program, [] { glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); });
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(IsGreen(Half(image, 0))) << "round 2: the left half is " << Half(image, 0);
|
||||
EXPECT_FALSE(IsGreen(Half(image, 1)))
|
||||
<< "round 2: the right half still drew - the narrowed copy of round 1 was reused after the "
|
||||
"second GPU write";
|
||||
}
|
||||
|
||||
} // namespace MGITest
|
||||
@@ -0,0 +1,314 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Scenarios/UnboundUniformBlockScenario.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 PROGRAM DECLARES A UNIFORM BLOCK AND NOTHING IS BOUND AT ITS BINDING POINT.
|
||||
//
|
||||
// The uniform-block sibling of UnboundImageDescriptorScenario. A draw or dispatch whose program
|
||||
// declares a uniform block at an indexed point with no buffer on it raises no GL error - whether
|
||||
// the point was never bound or its buffer was deleted while bound (glDeleteBuffers unbinds it
|
||||
// from every indexed point of the current context). Only what the shader READS from the block is
|
||||
// undefined.
|
||||
//
|
||||
// DirectVulkan's ResolveUniformBufferPayload looked up the buffer at the block's point and
|
||||
// dereferenced it with nothing there: a SIGSEGV inside the draw or the dispatch, taking the whole
|
||||
// process with it. It now answers with a zeroed block of the reflected size.
|
||||
//
|
||||
// The block is STATICALLY USED in every case, because an unreferenced block is optimised out
|
||||
// before it ever reaches a descriptor and would prove nothing. Its one read sits behind a
|
||||
// uniform-controlled branch that is false whenever the point is empty, so no undefined value
|
||||
// reaches an assertion. Each case also binds a buffer at the same point and reads it back through
|
||||
// the same program - proof that the block is live and wired to that point - and then empties the
|
||||
// point again, so the transition back to "nothing bound" is covered as well as the first use.
|
||||
//
|
||||
// DirectGLES forwards the empty point to the GLES driver, which does what GL says, so it is the
|
||||
// control - every test here must stay green on both backends.
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
#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;
|
||||
// The point under test. Not 0, so a stray glBindBufferBase(GL_UNIFORM_BUFFER, 0, ...) from
|
||||
// an earlier scenario in this process is not what decides the case - and SetUp empties
|
||||
// this one explicitly anyway.
|
||||
constexpr GLuint kUniformPoint = 5;
|
||||
constexpr GLuint kResultPoint = 0;
|
||||
constexpr unsigned int kMarker = 0xC0FFEEu;
|
||||
constexpr unsigned int kFallback = 7u;
|
||||
constexpr unsigned int kBoundWord = 0x1234u;
|
||||
|
||||
// No vertex attributes: the quad's corners come from gl_VertexID, so nothing about the
|
||||
// vertex fetch can be confused with the descriptor question under test.
|
||||
constexpr const char* kQuadVertexSource = R"(#version 430 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);
|
||||
}
|
||||
)";
|
||||
|
||||
// Green unless u_read is set, in which case the block's tint.
|
||||
constexpr const char* kFragmentSource = R"(#version 430 core
|
||||
layout(std140, binding = 5) uniform Target { vec4 u_tint; };
|
||||
uniform int u_read;
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec4 color = vec4(0.0, 1.0, 0.0, 1.0);
|
||||
if (u_read != 0) {
|
||||
color = u_tint;
|
||||
}
|
||||
o_color = color;
|
||||
}
|
||||
)";
|
||||
|
||||
// The marker is unconditional, so a zero marker means the dispatch never ran; the value is
|
||||
// the fallback unless u_read is set, in which case it is the block's word.
|
||||
constexpr const char* kComputeSource = R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(std430, binding = 0) buffer Result { uint g_marker; uint g_value; };
|
||||
layout(std140, binding = 5) uniform Target { uint u_word; };
|
||||
uniform int u_read;
|
||||
void main() {
|
||||
uint value = 7u;
|
||||
if (u_read != 0) {
|
||||
value = u_word;
|
||||
}
|
||||
g_marker = 0xC0FFEEu;
|
||||
g_value = value;
|
||||
}
|
||||
)";
|
||||
|
||||
class UnboundUniformBlockScenario : public ScenarioTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ScenarioTest::SetUp();
|
||||
if (!Ready()) return;
|
||||
m_target = MakeColorFbo(kFboSize, kFboSize);
|
||||
ASSERT_NE(m_target.fbo, 0u) << "could not create the render target";
|
||||
glGenVertexArrays(1, &m_vao);
|
||||
|
||||
const unsigned int zero[2] = {0u, 0u};
|
||||
glGenBuffers(1, &m_result);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_result);
|
||||
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(zero), zero, GL_DYNAMIC_COPY);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, kResultPoint, m_result);
|
||||
|
||||
// The harness shares one context across every scenario in the process, so an
|
||||
// earlier one may have left a buffer at this point. The whole subject here is that
|
||||
// nothing is bound, so say so rather than assume it.
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, kUniformPoint, 0);
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "setting up the scenario raised a GL error";
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (!Ready()) return;
|
||||
glUseProgram(0);
|
||||
glBindVertexArray(0);
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, kUniformPoint, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, kResultPoint, 0);
|
||||
if (m_block != 0) glDeleteBuffers(1, &m_block);
|
||||
if (m_result != 0) glDeleteBuffers(1, &m_result);
|
||||
if (m_vao != 0) glDeleteVertexArrays(1, &m_vao);
|
||||
if (m_draw != 0) glDeleteProgram(m_draw);
|
||||
if (m_compute != 0) glDeleteProgram(m_compute);
|
||||
BindDefaultFramebuffer();
|
||||
DestroyColorFbo(m_target);
|
||||
glViewport(0, 0, Gl().Width(), Gl().Height());
|
||||
FirstGLError();
|
||||
}
|
||||
|
||||
unsigned int MakeComputeProgram(const char* source) {
|
||||
const GLuint shader = glCreateShader(GL_COMPUTE_SHADER);
|
||||
glShaderSource(shader, 1, &source, nullptr);
|
||||
glCompileShader(shader);
|
||||
GLint compiled = GL_FALSE;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
|
||||
if (compiled == GL_FALSE) {
|
||||
char log[4096] = {};
|
||||
glGetShaderInfoLog(shader, sizeof(log) - 1, nullptr, log);
|
||||
ADD_FAILURE() << "the compute shader did not compile: " << log;
|
||||
glDeleteShader(shader);
|
||||
return 0;
|
||||
}
|
||||
const GLuint program = glCreateProgram();
|
||||
glAttachShader(program, shader);
|
||||
glLinkProgram(program);
|
||||
glDeleteShader(shader);
|
||||
GLint linked = GL_FALSE;
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &linked);
|
||||
if (linked == GL_FALSE) {
|
||||
char log[4096] = {};
|
||||
glGetProgramInfoLog(program, sizeof(log) - 1, nullptr, log);
|
||||
ADD_FAILURE() << "the compute program did not link: " << log;
|
||||
glDeleteProgram(program);
|
||||
return 0;
|
||||
}
|
||||
return program;
|
||||
}
|
||||
|
||||
// The block must be ACTIVE and at kUniformPoint, and the guard uniform must exist:
|
||||
// if either were optimised away the program would never ask for the empty point and
|
||||
// every case below would pass without testing anything.
|
||||
static void ExpectTheBlockIsLiveAtThePoint(GLuint program) {
|
||||
const GLuint block = glGetUniformBlockIndex(program, "Target");
|
||||
ASSERT_NE(block, GL_INVALID_INDEX) << "the uniform block was optimised out - the case proves nothing";
|
||||
GLint binding = -1;
|
||||
glGetActiveUniformBlockiv(program, block, GL_UNIFORM_BLOCK_BINDING, &binding);
|
||||
ASSERT_EQ(binding, static_cast<GLint>(kUniformPoint)) << "the block is not at the point under test";
|
||||
ASSERT_NE(glGetUniformLocation(program, "u_read"), -1) << "the guard uniform was optimised out";
|
||||
ASSERT_EQ(FirstGLError(), 0u) << "querying the block raised a GL error";
|
||||
}
|
||||
|
||||
static void ExpectThePointIsEmpty(const char* when) {
|
||||
GLint bound = -1;
|
||||
glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, kUniformPoint, &bound);
|
||||
ASSERT_EQ(bound, 0) << "uniform point " << kUniformPoint << " is not empty " << when;
|
||||
}
|
||||
|
||||
// A 16-byte std140 block at kUniformPoint holding `words`.
|
||||
void BindBlock(const std::array<unsigned int, 4>& words) {
|
||||
if (m_block == 0) glGenBuffers(1, &m_block);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, m_block);
|
||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(words), words.data(), GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, kUniformPoint, m_block);
|
||||
}
|
||||
|
||||
// Runs the compute program once; returns {marker, value}.
|
||||
std::array<unsigned int, 2> Dispatch(int read) {
|
||||
const unsigned int zero[2] = {0u, 0u};
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_result);
|
||||
glBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, sizeof(zero), zero);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||
glUseProgram(m_compute);
|
||||
glUniform1i(glGetUniformLocation(m_compute, "u_read"), read);
|
||||
glDispatchCompute(1, 1, 1);
|
||||
glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
|
||||
std::array<unsigned int, 2> out = {0xDEADBEEFu, 0xDEADBEEFu};
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_result);
|
||||
glGetBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, sizeof(out), out.data());
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||
glUseProgram(0);
|
||||
return out;
|
||||
}
|
||||
|
||||
void ExpectTheDispatchRunsOnAnEmptyPoint(const char* when) {
|
||||
ASSERT_NO_FATAL_FAILURE(ExpectThePointIsEmpty(when));
|
||||
const auto result = Dispatch(0);
|
||||
EXPECT_EQ(FirstGLError(), 0u) << "the dispatch raised a GL error " << when;
|
||||
EXPECT_EQ(result[0], kMarker) << "the dispatch did not run " << when;
|
||||
EXPECT_EQ(result[1], kFallback) << "the dispatch took the block's branch " << when;
|
||||
}
|
||||
|
||||
// Draws the full-target quad and expects every pixel to be `color`.
|
||||
void ExpectTheDraw(int read, const char* color, const std::string& when) {
|
||||
BindFbo(m_target);
|
||||
ClearTo(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glBindVertexArray(m_vao);
|
||||
glUseProgram(m_draw);
|
||||
glUniform1i(glGetUniformLocation(m_draw, "u_read"), read);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindVertexArray(0);
|
||||
glUseProgram(0);
|
||||
EXPECT_EQ(FirstGLError(), 0u) << "the draw raised a GL error " << when;
|
||||
|
||||
const Image image = ReadPixels(kFboSize, kFboSize);
|
||||
ASSERT_FALSE(image.Empty()) << "the readback came back empty " << when;
|
||||
EXPECT_TRUE(RegionIsMostly(image, 0, kFboSize - 1, 0, kFboSize - 1, color, 0.0, when))
|
||||
<< "an all-black target means the draw was dropped";
|
||||
}
|
||||
|
||||
void ExpectTheDrawRunsOnAnEmptyPoint(const std::string& when) {
|
||||
ASSERT_NO_FATAL_FAILURE(ExpectThePointIsEmpty(when.c_str()));
|
||||
ExpectTheDraw(0, "green", when);
|
||||
}
|
||||
|
||||
ColorFbo m_target{};
|
||||
GLuint m_vao = 0;
|
||||
GLuint m_result = 0;
|
||||
GLuint m_block = 0;
|
||||
unsigned int m_draw = 0;
|
||||
unsigned int m_compute = 0;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_F(UnboundUniformBlockScenario, ADispatchDeclaringAnEmptyUniformPointRuns) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
m_compute = MakeComputeProgram(kComputeSource);
|
||||
ASSERT_NE(m_compute, 0u);
|
||||
ASSERT_NO_FATAL_FAILURE(ExpectTheBlockIsLiveAtThePoint(m_compute));
|
||||
|
||||
ExpectTheDispatchRunsOnAnEmptyPoint("with nothing ever bound at the point");
|
||||
|
||||
BindBlock({kBoundWord, 0u, 0u, 0u});
|
||||
const auto bound = Dispatch(1);
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_EQ(bound[0], kMarker) << "the dispatch did not run with a buffer bound";
|
||||
EXPECT_EQ(bound[1], kBoundWord) << "the program did not read the buffer bound at the block's point";
|
||||
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, kUniformPoint, 0);
|
||||
ExpectTheDispatchRunsOnAnEmptyPoint("after the point was emptied again");
|
||||
}
|
||||
|
||||
TEST_F(UnboundUniformBlockScenario, ADrawDeclaringAnEmptyUniformPointPaintsTheFrame) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
std::string error;
|
||||
m_draw = CompileProgram(kQuadVertexSource, kFragmentSource, &error);
|
||||
ASSERT_NE(m_draw, 0u) << error;
|
||||
ASSERT_NO_FATAL_FAILURE(ExpectTheBlockIsLiveAtThePoint(m_draw));
|
||||
|
||||
ExpectTheDrawRunsOnAnEmptyPoint("with nothing ever bound at the point");
|
||||
|
||||
// Opaque red: 1.0f and 0.0f as their IEEE-754 words, so the block is one vec4.
|
||||
BindBlock({0x3F800000u, 0u, 0u, 0x3F800000u});
|
||||
ExpectTheDraw(1, "red", "reading the buffer bound at the block's point");
|
||||
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, kUniformPoint, 0);
|
||||
ExpectTheDrawRunsOnAnEmptyPoint("after the point was emptied again");
|
||||
}
|
||||
|
||||
// The shape real applications reach it by: the buffer is bound and used, then deleted while
|
||||
// still bound, which empties the point without the application ever unbinding it.
|
||||
TEST_F(UnboundUniformBlockScenario, AUniformBufferDeletedWhileBoundLeavesAnEmptyPointBothPathsSurvive) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
m_compute = MakeComputeProgram(kComputeSource);
|
||||
ASSERT_NE(m_compute, 0u);
|
||||
ASSERT_NO_FATAL_FAILURE(ExpectTheBlockIsLiveAtThePoint(m_compute));
|
||||
std::string error;
|
||||
m_draw = CompileProgram(kQuadVertexSource, kFragmentSource, &error);
|
||||
ASSERT_NE(m_draw, 0u) << error;
|
||||
ASSERT_NO_FATAL_FAILURE(ExpectTheBlockIsLiveAtThePoint(m_draw));
|
||||
|
||||
BindBlock({kBoundWord, 0u, 0u, 0u});
|
||||
const auto bound = Dispatch(1);
|
||||
EXPECT_EQ(bound[0], kMarker) << "the dispatch did not run with a buffer bound";
|
||||
EXPECT_EQ(bound[1], kBoundWord) << "the program did not read the buffer bound at the block's point";
|
||||
ASSERT_EQ(FirstGLError(), 0u);
|
||||
|
||||
glDeleteBuffers(1, &m_block);
|
||||
m_block = 0;
|
||||
ExpectTheDispatchRunsOnAnEmptyPoint("after the bound buffer was deleted");
|
||||
ExpectTheDrawRunsOnAnEmptyPoint("after the bound buffer was deleted");
|
||||
}
|
||||
|
||||
} // namespace MGITest
|
||||
@@ -0,0 +1,292 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Scenarios/WireIndirectDispatchScenario.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
|
||||
//
|
||||
// P8-SV: THE MAGMA WIRE ARM ISSUES glDispatchComputeIndirect FROM THE WIRE STORE, AS THE MONOLITH
|
||||
// ARM DOES (docs/Disaggregated/notes/p8/SV.md).
|
||||
//
|
||||
// Before P8-SV the wire arm read the three group counts through ReadWireBuffer and dispatched them
|
||||
// from the CPU, so a dispatch buffer a shader had written cost a whole-GPU wait per call - the
|
||||
// dispatch twin of what P8-D removed for indirect draws (WireIndirectDrawScenario.cpp). The cases
|
||||
// pin both halves:
|
||||
// * THE GRID, on every arm and both backends - each dispatch marks exactly the work groups its
|
||||
// counts name, and GPU-written counts are the ones the dispatch sees (the buffer starts with
|
||||
// OTHER counts, so a stale read shows as the wrong grid);
|
||||
// * THE SERVER'S OWN COUNTERS (Harness/WireIndirectPeek.h), where they can be read - Magma on the
|
||||
// inproc arm: every call issued as vkCmdDispatchIndirect (`wdsp`), no host wait (`whw`), and the
|
||||
// INDIRECT_COMMAND_READ barrier exactly once per shader write (`wibar`).
|
||||
// The counters are read BEFORE the grids are read back: that readback is a host read of a store a
|
||||
// shader wrote, so it takes a host wait of its own, which is the application's and not the
|
||||
// dispatch's.
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../Harness/HeadlessGL.h"
|
||||
#include "../Harness/ScenarioFixture.h"
|
||||
#include "../Harness/SplitRuntimePeek.h"
|
||||
#include "../Harness/WireIndirectPeek.h"
|
||||
|
||||
#ifdef GLAPI
|
||||
#undef GLAPI
|
||||
#endif
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
namespace MGITest {
|
||||
namespace {
|
||||
|
||||
// Grids up to 4 x 4 x 2: one cell per work group.
|
||||
constexpr std::uint32_t kGridX = 4, kGridY = 4, kGridZ = 2;
|
||||
constexpr std::uint32_t kCells = kGridX * kGridY * kGridZ;
|
||||
|
||||
// One invocation per work group, and each group marks its own cell.
|
||||
constexpr const char* kMarkSource = R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(std430, binding = 2) buffer Marks { uint marks[]; };
|
||||
void main() {
|
||||
uvec3 g = gl_WorkGroupID;
|
||||
atomicAdd(marks[(g.z * 4u + g.y) * 4u + g.x], 1u);
|
||||
}
|
||||
)";
|
||||
// Copies `source` into `words`, one word per invocation: the compute write under test.
|
||||
constexpr const char* kCopySource = R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(std430, binding = 0) buffer Words { uint words[]; };
|
||||
layout(std430, binding = 1) readonly buffer Source { uint source[]; };
|
||||
void main() { words[gl_GlobalInvocationID.x] = source[gl_GlobalInvocationID.x]; }
|
||||
)";
|
||||
|
||||
using Grid = std::array<std::uint32_t, 3>;
|
||||
|
||||
class WireIndirectDispatchScenario : public ScenarioTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ScenarioTest::SetUp();
|
||||
if (!Ready()) return;
|
||||
m_magma = Gl().BackendName() == "DirectVulkan";
|
||||
m_transport = PeekSplitRuntime().transportName;
|
||||
m_mark = CompileCompute(kMarkSource);
|
||||
ASSERT_NE(m_mark, 0u);
|
||||
m_copy = CompileCompute(kCopySource);
|
||||
ASSERT_NE(m_copy, 0u);
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "scene setup left a GL error behind";
|
||||
// The counters are armed by the first peek, so it has to come before any dispatch.
|
||||
if (CountersReadable()) {
|
||||
ASSERT_TRUE(PeekWireIndirectCounters(&m_before))
|
||||
<< "Magma on the inproc arm must be able to read the wire arm's own counters";
|
||||
}
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (!Ready()) return;
|
||||
glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0);
|
||||
for (GLuint& buffer : m_marks) {
|
||||
if (buffer != 0) glDeleteBuffers(1, &buffer);
|
||||
}
|
||||
for (GLuint* buffer : {&m_groupCounts, &m_source}) {
|
||||
if (*buffer != 0) glDeleteBuffers(1, buffer);
|
||||
*buffer = 0;
|
||||
}
|
||||
if (m_mark != 0) glDeleteProgram(m_mark);
|
||||
if (m_copy != 0) glDeleteProgram(m_copy);
|
||||
}
|
||||
|
||||
static GLuint CompileCompute(const char* source) {
|
||||
const GLuint shader = glCreateShader(GL_COMPUTE_SHADER);
|
||||
glShaderSource(shader, 1, &source, nullptr);
|
||||
glCompileShader(shader);
|
||||
GLint ok = GL_FALSE;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
|
||||
if (ok != GL_TRUE) {
|
||||
glDeleteShader(shader);
|
||||
return 0;
|
||||
}
|
||||
const GLuint program = glCreateProgram();
|
||||
glAttachShader(program, shader);
|
||||
glLinkProgram(program);
|
||||
glDeleteShader(shader);
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &ok);
|
||||
if (ok != GL_TRUE) {
|
||||
glDeleteProgram(program);
|
||||
return 0;
|
||||
}
|
||||
return program;
|
||||
}
|
||||
|
||||
static void Fill(GLuint& name, GLenum target, const std::vector<std::uint32_t>& words) {
|
||||
if (name == 0) glGenBuffers(1, &name);
|
||||
glBindBuffer(target, name);
|
||||
glBufferData(target, static_cast<GLsizeiptr>(words.size() * sizeof(std::uint32_t)), words.data(),
|
||||
GL_DYNAMIC_COPY);
|
||||
}
|
||||
|
||||
// The dispatch-indirect store, holding CPU-written counts.
|
||||
void Parameters(const std::vector<std::uint32_t>& words) {
|
||||
Fill(m_groupCounts, GL_DISPATCH_INDIRECT_BUFFER, words);
|
||||
}
|
||||
|
||||
// The compute write: the parameter store (already holding its poison) receives `words`.
|
||||
void ComputeWriteParameters(const std::vector<std::uint32_t>& words) {
|
||||
Fill(m_source, GL_SHADER_STORAGE_BUFFER, words);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_groupCounts);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_source);
|
||||
glUseProgram(m_copy);
|
||||
glDispatchCompute(static_cast<GLuint>(words.size()), 1, 1);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0);
|
||||
}
|
||||
|
||||
// One indirect dispatch of the mark program into a fresh, zeroed cell buffer. Returns
|
||||
// the index of that buffer for ExpectGrid.
|
||||
size_t DispatchIndirect(GLintptr offset) {
|
||||
GLuint marks = 0;
|
||||
Fill(marks, GL_SHADER_STORAGE_BUFFER, std::vector<std::uint32_t>(kCells, 0u));
|
||||
m_marks.push_back(marks);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, marks);
|
||||
glUseProgram(m_mark);
|
||||
glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, m_groupCounts);
|
||||
glDispatchComputeIndirect(offset);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, 0);
|
||||
return m_marks.size() - 1;
|
||||
}
|
||||
|
||||
// A round trip that reads no buffer store, so the server has applied every dispatch
|
||||
// above before the counters are read - and no host wait of its own is added.
|
||||
static void Settle() {
|
||||
BindDefaultFramebuffer();
|
||||
(void)ReadPixels(1, 1);
|
||||
}
|
||||
|
||||
void ExpectGrid(size_t which, const Grid& grid, const std::string& what) {
|
||||
glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
|
||||
std::vector<std::uint32_t> cells(kCells, 0xDEADu);
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_marks[which]);
|
||||
glGetBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, static_cast<GLsizeiptr>(kCells * sizeof(std::uint32_t)),
|
||||
cells.data());
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << what << ": readback";
|
||||
size_t wrong = 0;
|
||||
std::string first;
|
||||
for (std::uint32_t z = 0; z < kGridZ; ++z) {
|
||||
for (std::uint32_t y = 0; y < kGridY; ++y) {
|
||||
for (std::uint32_t x = 0; x < kGridX; ++x) {
|
||||
const bool inside = x < grid[0] && y < grid[1] && z < grid[2];
|
||||
const std::uint32_t got = cells[(z * kGridY + y) * kGridX + x];
|
||||
if (got != (inside ? 1u : 0u) && wrong++ == 0) {
|
||||
first = "group (" + std::to_string(x) + "," + std::to_string(y) + "," +
|
||||
std::to_string(z) + ") = " + std::to_string(got);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(wrong, 0u) << what << ": expected exactly the " << grid[0] << "x" << grid[1] << "x"
|
||||
<< grid[2] << " grid marked once; first wrong " << first;
|
||||
}
|
||||
|
||||
// Magma's server in THIS process: the inproc arm. Spawn and tcp servers are other
|
||||
// processes, and the monolith arm never takes the wire path at all.
|
||||
bool CountersReadable() const { return m_magma && m_transport == "inproc"; }
|
||||
|
||||
WireIndirectCounters Delta() const {
|
||||
WireIndirectCounters now{};
|
||||
EXPECT_TRUE(PeekWireIndirectCounters(&now));
|
||||
WireIndirectCounters delta{};
|
||||
delta.nativeDraws = now.nativeDraws - m_before.nativeDraws;
|
||||
delta.cpuExpansions = now.cpuExpansions - m_before.cpuExpansions;
|
||||
delta.barriers = now.barriers - m_before.barriers;
|
||||
delta.hostWaits = now.hostWaits - m_before.hostWaits;
|
||||
delta.indirectWaits = now.indirectWaits - m_before.indirectWaits;
|
||||
delta.nativeDispatches = now.nativeDispatches - m_before.nativeDispatches;
|
||||
return delta;
|
||||
}
|
||||
|
||||
bool m_magma = false;
|
||||
std::string m_transport;
|
||||
WireIndirectCounters m_before{};
|
||||
GLuint m_mark = 0, m_copy = 0, m_groupCounts = 0, m_source = 0;
|
||||
std::vector<GLuint> m_marks;
|
||||
};
|
||||
|
||||
// CPU-written counts at two non-zero offsets of one store. On Magma/inproc both calls must
|
||||
// be issued natively, with no host wait and no barrier (no shader wrote the store).
|
||||
TEST_F(WireIndirectDispatchScenario, CpuWrittenGroupCountsAreReadByTheGpuAtTheirOffsets) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
Parameters({1, 1, 1, 3, 2, 1, 4, 1, 2});
|
||||
const size_t first = DispatchIndirect(12);
|
||||
const size_t second = DispatchIndirect(24);
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR));
|
||||
Settle();
|
||||
if (CountersReadable()) {
|
||||
const WireIndirectCounters delta = Delta();
|
||||
EXPECT_EQ(delta.nativeDispatches, 2u) << "every indirect dispatch must be vkCmdDispatchIndirect";
|
||||
EXPECT_EQ(delta.hostWaits, 0u) << "a host wait was taken with no GPU write to the counts";
|
||||
EXPECT_EQ(delta.barriers, 0u) << "no shader wrote this store, so no barrier is due";
|
||||
}
|
||||
ExpectGrid(first, {3, 2, 1}, "glDispatchComputeIndirect at byte 12");
|
||||
ExpectGrid(second, {4, 1, 2}, "glDispatchComputeIndirect at byte 24");
|
||||
}
|
||||
|
||||
// Counts a compute shader wrote, behind the application's own GL_COMMAND_BARRIER_BIT. The
|
||||
// store starts with OTHER counts, so a stale read dispatches the wrong grid. On
|
||||
// Magma/inproc: issued natively and - the point of the change - NO host wait.
|
||||
TEST_F(WireIndirectDispatchScenario, ComputeWrittenGroupCountsDispatchWithoutAHostWait) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
Parameters({1, 1, 1});
|
||||
ComputeWriteParameters({3, 2, 1});
|
||||
glMemoryBarrier(GL_COMMAND_BARRIER_BIT);
|
||||
const size_t first = DispatchIndirect(0);
|
||||
|
||||
Parameters({1, 1, 1, 1, 1, 1});
|
||||
ComputeWriteParameters({1, 1, 1, 2, 2, 2});
|
||||
glMemoryBarrier(GL_COMMAND_BARRIER_BIT);
|
||||
const size_t second = DispatchIndirect(12);
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR));
|
||||
Settle();
|
||||
if (CountersReadable()) {
|
||||
const WireIndirectCounters delta = Delta();
|
||||
EXPECT_EQ(delta.nativeDispatches, 2u) << "both dispatches must be issued natively";
|
||||
EXPECT_EQ(delta.hostWaits, 0u)
|
||||
<< "an indirect dispatch of shader-written counts waited for the GPU on the host";
|
||||
EXPECT_EQ(delta.barriers, 2u) << "one INDIRECT_COMMAND_READ barrier per freshly written store";
|
||||
}
|
||||
ExpectGrid(first, {3, 2, 1}, "compute-written counts at byte 0");
|
||||
ExpectGrid(second, {2, 2, 2}, "compute-written counts at byte 12");
|
||||
}
|
||||
|
||||
// Flywheel's shape, one call over: the counts are written and dispatched with no
|
||||
// glMemoryBarrier between (GL leaves it undefined). The wire arm orders it anyway, once per
|
||||
// write, as P8-D does for draws. Magma's split arms only: the monolith arm records no
|
||||
// dependency here (P8-D recorded that half for dev), and Espryt's is its driver's.
|
||||
TEST_F(WireIndirectDispatchScenario, ShaderWrittenGroupCountsWithoutAnApplicationBarrierAreOrdered) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
if (!m_magma || m_transport == "monolith") {
|
||||
GTEST_SKIP() << "the implicit INDIRECT_COMMAND_READ barrier is the Magma wire arm's (P8-D, P8-SV)";
|
||||
}
|
||||
Parameters({1, 1, 1});
|
||||
ComputeWriteParameters({3, 2, 1});
|
||||
const size_t first = DispatchIndirect(0);
|
||||
const size_t again = DispatchIndirect(0);
|
||||
ComputeWriteParameters({1, 2, 2});
|
||||
const size_t third = DispatchIndirect(0);
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR));
|
||||
Settle();
|
||||
if (CountersReadable()) {
|
||||
const WireIndirectCounters delta = Delta();
|
||||
EXPECT_EQ(delta.nativeDispatches, 3u);
|
||||
EXPECT_EQ(delta.hostWaits, 0u) << "a host wait was taken";
|
||||
EXPECT_EQ(delta.barriers, 2u) << "exactly one barrier per write: the second dispatch reads no new write";
|
||||
}
|
||||
ExpectGrid(first, {3, 2, 1}, "the first dispatch after the write");
|
||||
ExpectGrid(again, {3, 2, 1}, "a second dispatch, no write between");
|
||||
ExpectGrid(third, {1, 2, 2}, "the dispatch after a second write");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace MGITest
|
||||
@@ -0,0 +1,368 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Scenarios/WireIndirectDrawScenario.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
|
||||
//
|
||||
// P8-D: THE MAGMA WIRE ARM ISSUES INDIRECT DRAWS FROM THE WIRE STORE, AS THE MONOLITH ARM DOES.
|
||||
//
|
||||
// Before P8-D every wire indirect draw read its commands (and its count word) through
|
||||
// ReadWireBuffer and expanded them on the CPU, and a store a shader had written turned that read
|
||||
// into a whole-GPU wait per draw (create-indirect: 321 expansions, 327 waits, ~4-8 s of waiting
|
||||
// per replay on lavapipe). The cases pin both halves of the change:
|
||||
// * PIXELS, on every arm and both backends where the backend's own semantics allow it - each
|
||||
// indirect form draws exactly the strips its commands name, and GPU-written commands are the
|
||||
// ones the draw sees (the poison the buffers start with names the OTHER strips);
|
||||
// * THE SERVER'S OWN COUNTERS (Harness/WireIndirectPeek.h), where they can be read - Magma on
|
||||
// the inproc arm, whose server is this process: every call issued natively, no CPU
|
||||
// expansion, no host wait, and the INDIRECT_COMMAND_READ barrier exactly once per write.
|
||||
//
|
||||
// Four strips across the viewport, one per quarter; a command draws one strip. Green = drawn,
|
||||
// red = the clear. The VBO opens with three padding vertices so a command that loses its `first`
|
||||
// or `firstIndex` draws a degenerate triangle rather than the right strip.
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../Harness/HeadlessGL.h"
|
||||
#include "../Harness/ScenarioFixture.h"
|
||||
#include "../Harness/SplitRuntimePeek.h"
|
||||
#include "../Harness/WireIndirectPeek.h"
|
||||
|
||||
#ifdef GLAPI
|
||||
#undef GLAPI
|
||||
#endif
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
namespace MGITest {
|
||||
namespace {
|
||||
|
||||
constexpr int kStrips = 4;
|
||||
constexpr std::uint32_t kPad = 3;
|
||||
constexpr std::uint32_t kStripVertices = 6;
|
||||
|
||||
constexpr const char* kVertexSource = R"(#version 430 core
|
||||
layout(location = 0) in vec2 aPos;
|
||||
void main() { gl_Position = vec4(aPos, 0.0, 1.0); }
|
||||
)";
|
||||
constexpr const char* kFragmentSource = R"(#version 430 core
|
||||
out vec4 oColor;
|
||||
void main() { oColor = vec4(0.0, 1.0, 0.0, 1.0); }
|
||||
)";
|
||||
// Copies `source` into `words`, one word per invocation: the compute write under test.
|
||||
constexpr const char* kCopySource = R"(#version 430 core
|
||||
layout(local_size_x = 1) in;
|
||||
layout(std430, binding = 0) buffer Words { uint words[]; };
|
||||
layout(std430, binding = 1) readonly buffer Source { uint source[]; };
|
||||
void main() { words[gl_GlobalInvocationID.x] = source[gl_GlobalInvocationID.x]; }
|
||||
)";
|
||||
|
||||
struct ArraysCommand {
|
||||
std::uint32_t count, instanceCount, first, baseInstance;
|
||||
};
|
||||
struct ElementsCommand {
|
||||
std::uint32_t count, instanceCount, firstIndex;
|
||||
std::int32_t baseVertex;
|
||||
std::uint32_t baseInstance;
|
||||
};
|
||||
// A padded elements command, for the stride case: 32 bytes, the tail unread.
|
||||
struct PaddedElementsCommand {
|
||||
ElementsCommand command;
|
||||
std::uint32_t padding[3];
|
||||
};
|
||||
|
||||
ArraysCommand Arrays(int strip) { return {kStripVertices, 1, kPad + kStripVertices * strip, 0}; }
|
||||
ElementsCommand Elements(int strip) { return {kStripVertices, 1, kStripVertices * strip, 0, 0}; }
|
||||
|
||||
using Strips = std::array<bool, kStrips>;
|
||||
|
||||
class WireIndirectDrawScenario : public ScenarioTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ScenarioTest::SetUp();
|
||||
if (!Ready()) return;
|
||||
m_magma = Gl().BackendName() == "DirectVulkan";
|
||||
m_transport = PeekSplitRuntime().transportName;
|
||||
std::string error;
|
||||
m_program = CompileProgram(kVertexSource, kFragmentSource, &error);
|
||||
ASSERT_NE(m_program, 0u) << error;
|
||||
m_copy = CompileCompute(kCopySource);
|
||||
ASSERT_NE(m_copy, 0u);
|
||||
|
||||
std::vector<float> vertices(2 * kPad, 0.0f);
|
||||
for (int strip = 0; strip < kStrips; ++strip) {
|
||||
const float x0 = -1.0f + 0.5f * static_cast<float>(strip);
|
||||
const float x1 = x0 + 0.5f;
|
||||
const float quad[12] = {x0, -1.0f, x1, -1.0f, x1, 1.0f, x0, -1.0f, x1, 1.0f, x0, 1.0f};
|
||||
vertices.insert(vertices.end(), quad, quad + 12);
|
||||
}
|
||||
std::vector<std::uint32_t> indices;
|
||||
for (std::uint32_t i = 0; i < kStripVertices * kStrips; ++i) indices.push_back(kPad + i);
|
||||
|
||||
glGenVertexArrays(1, &m_vao);
|
||||
glBindVertexArray(m_vao);
|
||||
glGenBuffers(1, &m_vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, static_cast<GLsizeiptr>(vertices.size() * sizeof(float)),
|
||||
vertices.data(), GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), nullptr);
|
||||
glGenBuffers(1, &m_ebo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, static_cast<GLsizeiptr>(indices.size() * sizeof(std::uint32_t)),
|
||||
indices.data(), GL_STATIC_DRAW);
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "scene setup left a GL error behind";
|
||||
|
||||
// The counters are armed by the first peek, so it has to come before any draw.
|
||||
if (CountersReadable()) {
|
||||
ASSERT_TRUE(PeekWireIndirectCounters(&m_before))
|
||||
<< "Magma on the inproc arm must be able to read the wire arm's own counters";
|
||||
}
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (!Ready()) return;
|
||||
glBindVertexArray(0);
|
||||
for (GLuint* buffer : {&m_vbo, &m_ebo, &m_indirect, &m_parameter, &m_source}) {
|
||||
if (*buffer != 0) glDeleteBuffers(1, buffer);
|
||||
*buffer = 0;
|
||||
}
|
||||
if (m_vao != 0) glDeleteVertexArrays(1, &m_vao);
|
||||
if (m_program != 0) glDeleteProgram(m_program);
|
||||
if (m_copy != 0) glDeleteProgram(m_copy);
|
||||
}
|
||||
|
||||
static GLuint CompileCompute(const char* source) {
|
||||
const GLuint shader = glCreateShader(GL_COMPUTE_SHADER);
|
||||
glShaderSource(shader, 1, &source, nullptr);
|
||||
glCompileShader(shader);
|
||||
GLint ok = GL_FALSE;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
|
||||
if (ok != GL_TRUE) {
|
||||
glDeleteShader(shader);
|
||||
return 0;
|
||||
}
|
||||
const GLuint program = glCreateProgram();
|
||||
glAttachShader(program, shader);
|
||||
glLinkProgram(program);
|
||||
glDeleteShader(shader);
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &ok);
|
||||
if (ok != GL_TRUE) {
|
||||
glDeleteProgram(program);
|
||||
return 0;
|
||||
}
|
||||
return program;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void Fill(GLuint& name, GLenum target, const std::vector<T>& data) {
|
||||
if (name == 0) glGenBuffers(1, &name);
|
||||
glBindBuffer(target, name);
|
||||
glBufferData(target, static_cast<GLsizeiptr>(data.size() * sizeof(T)), data.data(), GL_DYNAMIC_COPY);
|
||||
}
|
||||
|
||||
// The compute write: `words` (already holding its poison) receives `data` from the GPU.
|
||||
template <typename T>
|
||||
void ComputeWrite(GLuint words, const std::vector<T>& data) {
|
||||
Fill(m_source, GL_SHADER_STORAGE_BUFFER, data);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, words);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_source);
|
||||
glUseProgram(m_copy);
|
||||
glDispatchCompute(static_cast<GLuint>(data.size() * sizeof(T) / sizeof(std::uint32_t)), 1, 1);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0);
|
||||
}
|
||||
|
||||
template <typename DrawFn>
|
||||
Image Render(DrawFn&& draw) {
|
||||
BindDefaultFramebuffer();
|
||||
glViewport(0, 0, Gl().Width(), Gl().Height());
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
ClearTo(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
glUseProgram(m_program);
|
||||
glBindVertexArray(m_vao);
|
||||
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, m_indirect);
|
||||
draw();
|
||||
return ReadPixels(Gl().Width(), Gl().Height());
|
||||
}
|
||||
|
||||
static void ExpectStrips(const Image& image, const Strips& drawn, const std::string& what) {
|
||||
for (int strip = 0; strip < kStrips; ++strip) {
|
||||
const int x = image.Width() * (2 * strip + 1) / (2 * kStrips);
|
||||
EXPECT_STREQ(image.ColorName(x, image.Height() / 2), drawn[strip] ? "green" : "red")
|
||||
<< what << ": strip " << strip;
|
||||
}
|
||||
}
|
||||
|
||||
// Magma's server in THIS process: the inproc arm. Spawn and tcp servers are other
|
||||
// processes, and the monolith arm never takes the wire path at all.
|
||||
bool CountersReadable() const { return m_magma && m_transport == "inproc"; }
|
||||
|
||||
WireIndirectCounters Delta() const {
|
||||
WireIndirectCounters now{};
|
||||
EXPECT_TRUE(PeekWireIndirectCounters(&now));
|
||||
return {now.nativeDraws - m_before.nativeDraws, now.cpuExpansions - m_before.cpuExpansions,
|
||||
now.barriers - m_before.barriers, now.hostWaits - m_before.hostWaits,
|
||||
now.indirectWaits - m_before.indirectWaits};
|
||||
}
|
||||
|
||||
bool m_magma = false;
|
||||
std::string m_transport;
|
||||
WireIndirectCounters m_before{};
|
||||
GLuint m_program = 0, m_copy = 0, m_vao = 0, m_vbo = 0, m_ebo = 0;
|
||||
GLuint m_indirect = 0, m_parameter = 0, m_source = 0;
|
||||
};
|
||||
|
||||
// Every indirect form from CPU-written commands. On Magma/inproc the server must have
|
||||
// issued all six natively, expanded none, waited for nothing and recorded no barrier (no
|
||||
// shader ever wrote these stores).
|
||||
TEST_F(WireIndirectDrawScenario, EveryIndirectFormIsIssuedNativelyFromItsStore) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
// Arrays commands at 0.., elements commands after them: the offsets are byte offsets
|
||||
// into one store, as an application packs them.
|
||||
const std::vector<ArraysCommand> arrays = {Arrays(0), Arrays(1), Arrays(3), Arrays(2)};
|
||||
Fill(m_indirect, GL_DRAW_INDIRECT_BUFFER, arrays);
|
||||
Image image = Render([&] { glDrawArraysIndirect(GL_TRIANGLES, reinterpret_cast<const void*>(16)); });
|
||||
ExpectStrips(image, {false, true, false, false}, "glDrawArraysIndirect at byte 16");
|
||||
image = Render([&] { glMultiDrawArraysIndirect(GL_TRIANGLES, nullptr, 3, 0); });
|
||||
ExpectStrips(image, {true, true, false, true}, "glMultiDrawArraysIndirect, 3 commands");
|
||||
|
||||
const std::vector<PaddedElementsCommand> padded = {{Elements(3), {}}, {Elements(0), {}}};
|
||||
Fill(m_indirect, GL_DRAW_INDIRECT_BUFFER, padded);
|
||||
image = Render([&] {
|
||||
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, nullptr, 2, sizeof(PaddedElementsCommand));
|
||||
});
|
||||
ExpectStrips(image, {true, false, false, true}, "glMultiDrawElementsIndirect, stride 32");
|
||||
image = Render([&] {
|
||||
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT,
|
||||
reinterpret_cast<const void*>(sizeof(PaddedElementsCommand)));
|
||||
});
|
||||
ExpectStrips(image, {true, false, false, false}, "glDrawElementsIndirect at byte 32");
|
||||
|
||||
// The count forms: three commands each, a count word that allows fewer.
|
||||
Fill(m_parameter, GL_PARAMETER_BUFFER, std::vector<std::uint32_t>{7, 2, 1});
|
||||
Fill(m_indirect, GL_DRAW_INDIRECT_BUFFER, std::vector<ArraysCommand>{Arrays(0), Arrays(1), Arrays(2)});
|
||||
image = Render([&] {
|
||||
glMultiDrawArraysIndirectCount(GL_TRIANGLES, nullptr, 4, 3, 0);
|
||||
});
|
||||
ExpectStrips(image, {true, true, false, false}, "glMultiDrawArraysIndirectCount, count word 2 of 3");
|
||||
Fill(m_indirect, GL_DRAW_INDIRECT_BUFFER, std::vector<ElementsCommand>{Elements(3), Elements(2), Elements(1)});
|
||||
image = Render([&] {
|
||||
glMultiDrawElementsIndirectCount(GL_TRIANGLES, GL_UNSIGNED_INT, nullptr, 8, 3, 0);
|
||||
});
|
||||
ExpectStrips(image, {false, false, false, true}, "glMultiDrawElementsIndirectCount, count word 1 of 3");
|
||||
EXPECT_EQ(FirstGLError(), GLenum(GL_NO_ERROR));
|
||||
|
||||
if (!CountersReadable()) return;
|
||||
const WireIndirectCounters delta = Delta();
|
||||
EXPECT_EQ(delta.nativeDraws, 6u) << "every indirect call must be issued as vkCmdDraw*Indirect[Count]";
|
||||
EXPECT_EQ(delta.cpuExpansions, 0u) << "no indirect call may read its words on the CPU";
|
||||
EXPECT_EQ(delta.indirectWaits, 0u) << "an indirect call took a host wait";
|
||||
EXPECT_EQ(delta.hostWaits, 0u) << "a host wait was taken with no GPU write anywhere";
|
||||
EXPECT_EQ(delta.barriers, 0u) << "no shader wrote these stores, so no barrier is due";
|
||||
}
|
||||
|
||||
// Commands a compute shader wrote, behind the application's own GL_COMMAND_BARRIER_BIT.
|
||||
// The buffers start with commands for the OTHER strips, so a read of stale words shows.
|
||||
// On Magma/inproc: issued natively, and - the point of the package - NO host wait.
|
||||
TEST_F(WireIndirectDrawScenario, ComputeWrittenCommandsDrawWithoutAHostWait) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
Fill(m_indirect, GL_DRAW_INDIRECT_BUFFER, std::vector<ArraysCommand>{Arrays(2), Arrays(3)});
|
||||
ComputeWrite(m_indirect, std::vector<ArraysCommand>{Arrays(0), Arrays(1)});
|
||||
glMemoryBarrier(GL_COMMAND_BARRIER_BIT);
|
||||
Image image = Render([&] { glMultiDrawArraysIndirect(GL_TRIANGLES, nullptr, 2, 0); });
|
||||
ExpectStrips(image, {true, true, false, false}, "glMultiDrawArraysIndirect of compute-written commands");
|
||||
|
||||
Fill(m_indirect, GL_DRAW_INDIRECT_BUFFER, std::vector<ElementsCommand>{Elements(0), Elements(1)});
|
||||
ComputeWrite(m_indirect, std::vector<ElementsCommand>{Elements(3), Elements(2)});
|
||||
glMemoryBarrier(GL_COMMAND_BARRIER_BIT);
|
||||
image = Render([&] { glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, nullptr, 2, 0); });
|
||||
ExpectStrips(image, {false, false, true, true}, "glMultiDrawElementsIndirect of compute-written commands");
|
||||
EXPECT_EQ(FirstGLError(), GLenum(GL_NO_ERROR));
|
||||
|
||||
if (!CountersReadable()) return;
|
||||
const WireIndirectCounters delta = Delta();
|
||||
EXPECT_EQ(delta.nativeDraws, 2u) << "both draws must be issued natively";
|
||||
EXPECT_EQ(delta.cpuExpansions, 0u) << "no indirect call may read its words on the CPU";
|
||||
EXPECT_EQ(delta.indirectWaits, 0u)
|
||||
<< "an indirect draw of shader-written commands waited for the GPU on the host";
|
||||
EXPECT_EQ(delta.hostWaits, 0u) << "a host wait was taken";
|
||||
EXPECT_EQ(delta.barriers, 2u) << "one INDIRECT_COMMAND_READ barrier per freshly written store";
|
||||
}
|
||||
|
||||
// The COUNT word a compute shader wrote. Espryt reads that word on the CPU from the
|
||||
// server's staged copy of the parameter buffer; P8-C refreshes that copy after a shader
|
||||
// write (SplitHostBytesForCpuRead), so its split arms answer here too (P8-SE). Espryt's
|
||||
// MONOLITH arm still reads the frontend shadow without a sync (OPEN-QUESTIONS 15, C.md's
|
||||
// monolith defects), left to P13 (ID-P8-13).
|
||||
TEST_F(WireIndirectDrawScenario, ComputeWrittenCountWordIsTheOneTheGpuReads) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
if (!m_magma && m_transport == "monolith") {
|
||||
GTEST_SKIP() << "Espryt's monolith arm reads the count word from the frontend shadow without "
|
||||
"a sync (OQ15; recorded for P13, ID-P8-13)";
|
||||
}
|
||||
Fill(m_indirect, GL_DRAW_INDIRECT_BUFFER, std::vector<ElementsCommand>{Elements(0), Elements(3), Elements(2)});
|
||||
Fill(m_parameter, GL_PARAMETER_BUFFER, std::vector<std::uint32_t>{3});
|
||||
ComputeWrite(m_parameter, std::vector<std::uint32_t>{1});
|
||||
glMemoryBarrier(GL_COMMAND_BARRIER_BIT);
|
||||
Image image = Render([&] {
|
||||
glMultiDrawElementsIndirectCount(GL_TRIANGLES, GL_UNSIGNED_INT, nullptr, 0, 3, 0);
|
||||
});
|
||||
ExpectStrips(image, {true, false, false, false}, "glMultiDrawElementsIndirectCount, shader-written count 1");
|
||||
if (m_transport == "monolith") {
|
||||
// DirectVulkan.cpp's monolith MultiDrawArraysIndirectCount reads this word from the
|
||||
// frontend shadow without SyncGpuWrites: recorded for dev (ID-P8-3), not this lane's.
|
||||
return;
|
||||
}
|
||||
Fill(m_indirect, GL_DRAW_INDIRECT_BUFFER, std::vector<ArraysCommand>{Arrays(1), Arrays(2), Arrays(3)});
|
||||
Fill(m_parameter, GL_PARAMETER_BUFFER, std::vector<std::uint32_t>{0});
|
||||
ComputeWrite(m_parameter, std::vector<std::uint32_t>{2});
|
||||
glMemoryBarrier(GL_COMMAND_BARRIER_BIT);
|
||||
image = Render([&] { glMultiDrawArraysIndirectCount(GL_TRIANGLES, nullptr, 0, 3, 0); });
|
||||
ExpectStrips(image, {false, true, true, false}, "glMultiDrawArraysIndirectCount, shader-written count 2");
|
||||
EXPECT_EQ(FirstGLError(), GLenum(GL_NO_ERROR));
|
||||
|
||||
if (!CountersReadable()) return;
|
||||
const WireIndirectCounters delta = Delta();
|
||||
EXPECT_EQ(delta.nativeDraws, 2u);
|
||||
EXPECT_EQ(delta.cpuExpansions, 0u) << "a count word was read on the CPU";
|
||||
EXPECT_EQ(delta.hostWaits, 0u) << "a host wait was taken";
|
||||
EXPECT_EQ(delta.barriers, 2u) << "one barrier per draw whose count store a shader wrote";
|
||||
}
|
||||
|
||||
// Flywheel's shape (create-indirect's trace: 322 cull-then-draw rounds, no glMemoryBarrier
|
||||
// between them). GL leaves it undefined; the wire arm orders it anyway, once per write,
|
||||
// because the CPU path it replaced did (by waiting). Magma's split arms only: the monolith
|
||||
// arm records no dependency here (recorded for dev), and Espryt's is its driver's.
|
||||
TEST_F(WireIndirectDrawScenario, ShaderWrittenCommandsWithoutAnApplicationBarrierAreOrdered) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
if (!m_magma || m_transport == "monolith") {
|
||||
GTEST_SKIP() << "the implicit INDIRECT_COMMAND_READ barrier is the Magma wire arm's (P8-D)";
|
||||
}
|
||||
Fill(m_indirect, GL_DRAW_INDIRECT_BUFFER, std::vector<ArraysCommand>{Arrays(3), Arrays(2)});
|
||||
ComputeWrite(m_indirect, std::vector<ArraysCommand>{Arrays(0), Arrays(1)});
|
||||
Image image = Render([&] { glMultiDrawArraysIndirect(GL_TRIANGLES, nullptr, 2, 0); });
|
||||
ExpectStrips(image, {true, true, false, false}, "the first draw after the write");
|
||||
image = Render([&] { glDrawArraysIndirect(GL_TRIANGLES, reinterpret_cast<const void*>(16)); });
|
||||
ExpectStrips(image, {false, true, false, false}, "a second draw, no write between");
|
||||
ComputeWrite(m_indirect, std::vector<ArraysCommand>{Arrays(2), Arrays(3)});
|
||||
image = Render([&] { glMultiDrawArraysIndirect(GL_TRIANGLES, nullptr, 2, 0); });
|
||||
ExpectStrips(image, {false, false, true, true}, "the draw after a second write");
|
||||
EXPECT_EQ(FirstGLError(), GLenum(GL_NO_ERROR));
|
||||
|
||||
if (!CountersReadable()) return;
|
||||
const WireIndirectCounters delta = Delta();
|
||||
EXPECT_EQ(delta.nativeDraws, 3u);
|
||||
EXPECT_EQ(delta.cpuExpansions, 0u);
|
||||
EXPECT_EQ(delta.hostWaits, 0u) << "a host wait was taken";
|
||||
EXPECT_EQ(delta.barriers, 2u) << "exactly one barrier per write: the second draw reads no new write";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace MGITest
|
||||
@@ -0,0 +1,220 @@
|
||||
// MobileGL - MobileGL/MG_IntegrationTest/Scenarios/WireMipShapeScenario.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
|
||||
//
|
||||
// P8-SV: TWO glGenerateMipmap SHAPES THE MAGMA WIRE ARM GOT WRONG (docs/Disaggregated/notes/p8/SV.md).
|
||||
//
|
||||
// * A 3D chain through the NATIVE blit. The wire arm passed the level's depth as the blit's
|
||||
// subresource layerCount on an image with one array layer (VUID-vkCmdBlitImage-srcImage-00240,
|
||||
// -srcSubresource-01707, -dstSubresource-01708). Lavapipe blits a 3D image by its z offsets and
|
||||
// ignores layerCount, so the PIXELS below are right with or without the fix on this host; what
|
||||
// goes red on the host is the validation layer, which the `.Mip3DValidation.` entry runs this
|
||||
// case under (inproc, so the server's Vulkan instance is this process and its stdout is ours).
|
||||
// The pixel half runs on both backends and every arm, and is what a driver that honours
|
||||
// layerCount would fail.
|
||||
// * A 1D DEPTH chain with no native blit. The depth shader arm renders 2D views, which a 1D image
|
||||
// does not admit; the wire arm handed it the chain anyway. It is now the named decline
|
||||
// MipmapShaderFormatOrShape, decided before the chain grows, and the session carries on.
|
||||
// Magma only, and reachable on this host only with MGITEST_MAGMA_FORCE_SHADER_MIPMAP (lavapipe
|
||||
// blits depth natively), which the SERVER reads: split and spawn entries only.
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../Harness/HeadlessGL.h"
|
||||
#include "../Harness/ScenarioFixture.h"
|
||||
#include "../Harness/SplitLane.h"
|
||||
#include "../Harness/SplitRuntimePeek.h"
|
||||
#include "../Harness/WireDeclinePeek.h"
|
||||
|
||||
#ifdef GLAPI
|
||||
#undef GLAPI
|
||||
#endif
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
namespace MGITest {
|
||||
namespace {
|
||||
|
||||
using Texel = std::array<int, 4>;
|
||||
|
||||
// Is the Khronos validation layer loaded into THIS process? On the inproc arm the server's
|
||||
// Vulkan instance lives here, so this is the proof that a run "under the layer" really was.
|
||||
bool ValidationLayerMapped() {
|
||||
#if defined(__linux__)
|
||||
std::ifstream maps("/proc/self/maps");
|
||||
std::string line;
|
||||
while (std::getline(maps, line)) {
|
||||
if (line.find("VkLayer_khronos_validation") != std::string::npos) return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
class WireMipShapeScenario : public ScenarioTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ScenarioTest::SetUp();
|
||||
if (!Ready()) return;
|
||||
m_magma = Gl().BackendName() == "DirectVulkan";
|
||||
m_transport = PeekSplitRuntime().transportName;
|
||||
}
|
||||
|
||||
// The Magma server's decline tally is readable where the server is this process.
|
||||
bool DeclinesReadable() const { return m_magma && m_transport == "inproc"; }
|
||||
|
||||
bool m_magma = false;
|
||||
std::string m_transport;
|
||||
};
|
||||
|
||||
// A 3D RGBA8 chain, 8x8x8 with its full storage, whose level-0 slices come in PAIRS of one
|
||||
// colour: level 1's slice k is then pair k's colour exactly, and every level below is the
|
||||
// average of two slices of the level above. A blit that loses the z axis (one slice only,
|
||||
// or slices read as array layers of a 2D image) cannot produce those numbers.
|
||||
TEST_F(WireMipShapeScenario, VolumeChainIsGeneratedAlongItsDepth) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
constexpr int kSide = 8, kLevels = 4;
|
||||
const std::array<Texel, 4> pairs = {Texel{200, 40, 80, 255}, Texel{40, 200, 120, 255},
|
||||
Texel{100, 100, 240, 255}, Texel{240, 160, 0, 255}};
|
||||
GLuint volume = 0;
|
||||
glGenTextures(1, &volume);
|
||||
glBindTexture(GL_TEXTURE_3D, volume);
|
||||
glTexStorage3D(GL_TEXTURE_3D, kLevels, GL_RGBA8, kSide, kSide, kSide);
|
||||
std::vector<GLubyte> level0(static_cast<size_t>(kSide * kSide * kSide * 4));
|
||||
for (int z = 0; z < kSide; ++z) {
|
||||
const Texel& texel = pairs[static_cast<size_t>(z / 2)];
|
||||
for (int at = 0; at < kSide * kSide; ++at) {
|
||||
for (int c = 0; c < 4; ++c)
|
||||
level0[static_cast<size_t>((z * kSide * kSide + at) * 4 + c)] = static_cast<GLubyte>(texel[c]);
|
||||
}
|
||||
}
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, kSide, kSide, kSide, GL_RGBA, GL_UNSIGNED_BYTE, level0.data());
|
||||
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "3D texture setup";
|
||||
glGenerateMipmap(GL_TEXTURE_3D);
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "glGenerateMipmap(GL_TEXTURE_3D)";
|
||||
|
||||
const auto average = [](const Texel& a, const Texel& b) {
|
||||
return Texel{(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2, (a[3] + b[3]) / 2};
|
||||
};
|
||||
// expected[level][slice]
|
||||
std::vector<std::vector<Texel>> expected(kLevels);
|
||||
expected[1].assign(pairs.begin(), pairs.end());
|
||||
expected[2] = {average(pairs[0], pairs[1]), average(pairs[2], pairs[3])};
|
||||
expected[3] = {average(expected[2][0], expected[2][1])};
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||
for (int level = 1; level < kLevels; ++level) {
|
||||
const int side = kSide >> level;
|
||||
GLint width = 0, height = 0, depth = 0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_3D, level, GL_TEXTURE_WIDTH, &width);
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_3D, level, GL_TEXTURE_HEIGHT, &height);
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_3D, level, GL_TEXTURE_DEPTH, &depth);
|
||||
EXPECT_EQ(width, side) << "level " << level;
|
||||
EXPECT_EQ(height, side) << "level " << level;
|
||||
EXPECT_EQ(depth, side) << "level " << level;
|
||||
std::vector<GLubyte> pixels(static_cast<size_t>(side * side * side * 4), 0x5a);
|
||||
glGetTexImage(GL_TEXTURE_3D, level, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "readback of level " << level;
|
||||
for (int z = 0; z < side; ++z) {
|
||||
const Texel& want = expected[static_cast<size_t>(level)][static_cast<size_t>(z)];
|
||||
size_t wrong = 0;
|
||||
Texel first{};
|
||||
for (int at = 0; at < side * side; ++at) {
|
||||
const size_t base = static_cast<size_t>((z * side * side + at) * 4);
|
||||
bool ok = true;
|
||||
for (int c = 0; c < 4; ++c) {
|
||||
const int got = pixels[base + static_cast<size_t>(c)];
|
||||
if (got < want[c] - 2 || got > want[c] + 2) ok = false;
|
||||
}
|
||||
if (!ok && wrong++ == 0) {
|
||||
for (int c = 0; c < 4; ++c) first[c] = pixels[base + static_cast<size_t>(c)];
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(wrong, 0u) << "level " << level << " slice " << z << ": expected (" << want[0] << ","
|
||||
<< want[1] << "," << want[2] << "," << want[3] << "), first wrong texel ("
|
||||
<< first[0] << "," << first[1] << "," << first[2] << "," << first[3] << ")";
|
||||
}
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_3D, 0);
|
||||
glDeleteTextures(1, &volume);
|
||||
|
||||
// The `.Mip3DValidation.` entry: the blit above ran under the Khronos validation layer,
|
||||
// whose VUID lines the entry's FAIL_REGULAR_EXPRESSION reads. Without the layer actually
|
||||
// loaded, a clean output would prove nothing, so the entry requires it.
|
||||
if (SplitLane::MarkerIsOne("MGITEST_REQUIRE_VK_VALIDATION_LAYER")) {
|
||||
ASSERT_TRUE(m_magma && m_transport == "inproc")
|
||||
<< "the validation entry reads the server's layer output in-process: Magma, inproc";
|
||||
EXPECT_TRUE(ValidationLayerMapped())
|
||||
<< "VK_LAYER_KHRONOS_validation is not loaded in this process, so the absence of "
|
||||
"VUID lines in this entry's output says nothing";
|
||||
}
|
||||
}
|
||||
|
||||
// A 1D DEPTH chain with the native blit forced off: no mip arm renders a 1D image, so the
|
||||
// wire arm declines by name (MipmapShaderFormatOrShape) before growing the chain. Pinned:
|
||||
// no GL error, the session answering (two readback round trips), level 0 as uploaded, level
|
||||
// 1 still the application's own sentinel - and, where the server is this process, exactly
|
||||
// one MipmapShaderFormatOrShape decline counted.
|
||||
TEST_F(WireMipShapeScenario, Depth1DChainWithoutANativeBlitDeclinesByName) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
if (!m_magma)
|
||||
GTEST_SKIP() << "Magma wire-arm decline (P8-SV): the knob and the depth shader arm it forces are "
|
||||
"Magma's; Espryt (" << Gl().BackendName() << ") generates this chain itself";
|
||||
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 blits depth natively, "
|
||||
"so the depth shader arm this case refuses is not entered";
|
||||
constexpr int kWidth = 16;
|
||||
GLuint line = 0;
|
||||
glGenTextures(1, &line);
|
||||
glBindTexture(GL_TEXTURE_1D, line);
|
||||
glTexStorage1D(GL_TEXTURE_1D, 5, GL_DEPTH_COMPONENT32F, kWidth);
|
||||
const std::vector<GLfloat> level0(kWidth, 0.25f), level1(kWidth / 2, 0.75f);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, kWidth, GL_DEPTH_COMPONENT, GL_FLOAT, level0.data());
|
||||
glTexSubImage1D(GL_TEXTURE_1D, 1, 0, kWidth / 2, GL_DEPTH_COMPONENT, GL_FLOAT, level1.data());
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "1D depth texture setup";
|
||||
unsigned long long declinesBefore = 0;
|
||||
const bool counted =
|
||||
DeclinesReadable() && PeekWireDeclineCount("MipmapShaderFormatOrShape", &declinesBefore);
|
||||
glGenerateMipmap(GL_TEXTURE_1D);
|
||||
EXPECT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "glGenerateMipmap(GL_TEXTURE_1D) on a depth chain";
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||
for (const int level : {0, 1}) {
|
||||
const int width = kWidth >> level;
|
||||
std::vector<GLfloat> depths(static_cast<size_t>(width), -1.0f);
|
||||
glGetTexImage(GL_TEXTURE_1D, level, GL_DEPTH_COMPONENT, GL_FLOAT, depths.data());
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR)) << "readback of level " << level;
|
||||
const GLfloat want = level == 0 ? 0.25f : 0.75f;
|
||||
size_t wrong = 0;
|
||||
GLfloat first = 0.0f;
|
||||
for (const GLfloat depth : depths) {
|
||||
if (depth < want - 0.0001f || depth > want + 0.0001f) {
|
||||
if (wrong++ == 0) first = depth;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(wrong, 0u) << "level " << level << " tier=" << tier << ": a declined mip must leave "
|
||||
<< "every level as the application wrote it (expected " << want
|
||||
<< ", first wrong " << first << ")";
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_1D, 0);
|
||||
glDeleteTextures(1, &line);
|
||||
if (counted) {
|
||||
unsigned long long declinesAfter = 0;
|
||||
ASSERT_TRUE(PeekWireDeclineCount("MipmapShaderFormatOrShape", &declinesAfter));
|
||||
EXPECT_EQ(declinesAfter - declinesBefore, 1u)
|
||||
<< "the 1D depth chain must be refused once, by name, before the chain grows";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace MGITest
|
||||
@@ -13,16 +13,16 @@
|
||||
//
|
||||
// Monolith: Ptr addresses the frontend shadow or the application's own memory and the
|
||||
// accessor is one predictable branch. Split: Ptr is null and the bytes live in a staging
|
||||
// segment named by Seg/Offset, or - for the index bytes a server-side primitive-restart
|
||||
// rewrite or multi-draw flattening consumes - in the server's own index host mirror, which
|
||||
// costs no wire traffic at all (D-B7).
|
||||
// segment named by Seg/Offset. D-B7's third shape - index bytes a server-side restart
|
||||
// rewrite reads out of its own index host mirror, at no wire cost - was never built; its
|
||||
// sentinel below is RESERVED (P8-F).
|
||||
namespace MobileGL::MG_Pipe {
|
||||
// Seg sentinels. Anything else is a real SEG_STAGE id assigned by the transport.
|
||||
inline constexpr Uint32 kMGHostSpanSegNone = 0;
|
||||
// "The bytes are already on your side": the server reads them out of the index host
|
||||
// mirror it maintains for every resource created with the ELEMENT_ARRAY bind bit while
|
||||
// kCapNeedsHostIndexBytes is set. When the mirror is over budget the tracker degrades
|
||||
// to per-draw staging and counts the bytes in index-bytes-shipped.
|
||||
// RESERVED (P8-F). It was to mean "the bytes are already on your side", read out of an
|
||||
// index host mirror armed by kCapNeedsHostIndexBytes. Neither was built (client indices
|
||||
// travel as owned element buffers; the cap is reserved), so no encoder writes this value
|
||||
// and SegmentTable::Resolve answers it "unknown". Kept so the value is never reused.
|
||||
inline constexpr Uint32 kMGHostSpanSegFromServerIndexMirror = 0xFFFFFFFFu;
|
||||
|
||||
struct MGHostSpan {
|
||||
|
||||
@@ -107,19 +107,19 @@ namespace MobileGL::MG_Pipe {
|
||||
// flattening - is not expressible as a capability (D-B7).
|
||||
enum MGPCapBit : Uint64 {
|
||||
kCapNone = 0,
|
||||
kCapViewportArray = 1ull << 0,
|
||||
kCapViewportArray = 1ull << 0, // RESERVED (P8-F): no producer, no consumer; never renumber
|
||||
kCapFloat64VertexAttrib = 1ull << 1,
|
||||
kCapResidentSubData = 1ull << 2,
|
||||
kCapCpuXfbPrimitiveAccounting = 1ull << 3,
|
||||
kCapTimerQuery = 1ull << 4,
|
||||
kCapOcclusionQuery = 1ull << 5,
|
||||
kCapXfbPrimitivesQuery = 1ull << 6,
|
||||
// The server rewrites restart indices / flattens multi-draws itself and therefore
|
||||
// needs the index bytes on its side: under split this arms the index host mirror
|
||||
// (D-B7).
|
||||
// RESERVED (P8-F): never published, never read. The index host mirror it would arm
|
||||
// (D-B7) was not built: client indices travel as owned element buffers and the server
|
||||
// reads its own staged bytes. The bit position is wire format: never reuse/renumber it.
|
||||
kCapNeedsHostIndexBytes = 1ull << 7,
|
||||
// The server packs named uniform blocks into its own ring and therefore needs the
|
||||
// host bytes of a set_shader_buffers(Uniform) range (D-B8).
|
||||
// RESERVED (P8-F): never published, never read - the named-UBO host span (D-B8) has
|
||||
// no producer. The bit position is wire format: never reuse or renumber it.
|
||||
kCapNeedsHostUboBytes = 1ull << 8,
|
||||
// P5b t2 (CONTRACT-P5B.md §6.5), the one cap bit P5b adds. The SERVER's backend owns
|
||||
// the transform-feedback capture, i.e. its own table registers EndTransformFeedback.
|
||||
@@ -312,11 +312,11 @@ namespace MobileGL::MG_Pipe {
|
||||
kMGPipeBindDepthStencil = 1u << 8,
|
||||
kMGPipeBindStreamOutput = 1u << 9,
|
||||
kMGPipeBindAtomic = 1u << 10,
|
||||
// THE D-B7 SWITCH. With kCapNeedsHostIndexBytes set the server mirrors this
|
||||
// resource's bytes so it can rewrite restart indices and flatten multi-draws
|
||||
// (ARCHITECTURE.md 10.3). Getting it wrong is invisible in monolith and silently
|
||||
// disables both under split, which is why it is set from a table rather than from a
|
||||
// special case at the emission site.
|
||||
// Set beside INDEX on every element-array buffer, from a table (ResourceTracker.h).
|
||||
// It was THE D-B7 SWITCH: with kCapNeedsHostIndexBytes the server would mirror this
|
||||
// resource's bytes for restart rewriting and multi-draw flattening (ARCHITECTURE.md
|
||||
// 10.3). That cap is RESERVED (P8-F) and the mirror was never built, so no reader
|
||||
// consumes this bit today; it stays on the wire, at this position.
|
||||
kMGPipeBindElementArray = 1u << 11,
|
||||
};
|
||||
|
||||
@@ -331,8 +331,8 @@ namespace MobileGL::MG_Pipe {
|
||||
Uint8 StorageKind; // == TextureStorageType (Mipmap | Buffer)
|
||||
// MGPipeBindBit, above: VERTEX|INDEX|CONSTANT|SHADER_BUFFER|INDIRECT|SAMPLER|
|
||||
// SHADER_IMAGE|RENDER_TARGET|DEPTH_STENCIL|STREAM_OUTPUT|ATOMIC|ELEMENT_ARRAY. The
|
||||
// ELEMENT_ARRAY bit is the D-B7 switch: with kCapNeedsHostIndexBytes set the server
|
||||
// mirrors this resource.
|
||||
// ELEMENT_ARRAY bit was the D-B7 switch; kCapNeedsHostIndexBytes is RESERVED (P8-F)
|
||||
// and no server mirrors this resource.
|
||||
Uint16 BindMask;
|
||||
Uint32 InternalFormat; // already resolved to an uncompressed fallback by the client
|
||||
Uint32 Width, Height, Depth;
|
||||
@@ -992,11 +992,11 @@ namespace MobileGL::MG_Pipe {
|
||||
MGP_ASSERT_POD(MGPShaderImages, 16);
|
||||
|
||||
// One bound buffer range: 24 bytes, no inline host span. The named-UBO host bytes a
|
||||
// backend needs under kCapNeedsHostUboBytes (D-B8) travel as an OPTIONAL second var-tail,
|
||||
// MGHostSpan[HostSpanCount] behind the ranges, announced by MGPShaderBuffers below. An
|
||||
// inline span would have cost every SSBO, atomic-counter and XFB range 32 dead bytes, and
|
||||
// D-B8 says not to freeze that payload's shape before the stage-ubo-named counter has
|
||||
// produced numbers.
|
||||
// backend would need under kCapNeedsHostUboBytes (D-B8; that cap is RESERVED since P8-F
|
||||
// and nothing sends the tail) travel as an OPTIONAL second var-tail, MGHostSpan[HostSpanCount]
|
||||
// behind the ranges, announced by MGPShaderBuffers below. An inline span would have cost
|
||||
// every SSBO, atomic-counter and XFB range 32 dead bytes, and D-B8 says not to freeze that
|
||||
// payload's shape before the stage-ubo-named counter has produced numbers.
|
||||
struct MGPBufferRange {
|
||||
MGPipeHandle Res;
|
||||
Uint64 Offset;
|
||||
@@ -1005,8 +1005,8 @@ namespace MobileGL::MG_Pipe {
|
||||
MGP_ASSERT_POD(MGPBufferRange, 24);
|
||||
|
||||
// Var-tail header: MGPBufferRange[Count], then MGHostSpan[HostSpanCount]. HostSpanCount is
|
||||
// 0, or Count for the Uniform class under kCapNeedsHostUboBytes (a range with nothing to
|
||||
// ship carries an empty span, so the two arrays stay index-aligned).
|
||||
// 0, or Count for the Uniform class under kCapNeedsHostUboBytes (RESERVED, P8-F: 0 today;
|
||||
// a range with nothing to ship carries an empty span, so the two arrays stay aligned).
|
||||
// MGPShaderBuffers::Class's three values, and the ONLY spelling of them (P5e,
|
||||
// MG_Remote/CONTRACT-P5E.md §1). The payload's comment has named them since P4a and
|
||||
// nothing numbered them, so the emitter and the applier were one literal each away from
|
||||
|
||||
@@ -149,7 +149,9 @@ VBO-backed index buffers (restart rewriting, multi-draw flattening) and is answe
|
||||
`Server/IndexHostMirror` (ARCHITECTURE §10.3), not by a per-draw span. **A multi-draw with
|
||||
client-side indices** (`indices[i]` are `drawcount` separate client pointers, one span can
|
||||
name one run) is refused by name, `Fatal{UnmigratedVerb, "MultiDrawElements+CLIENT_INDICES"}`,
|
||||
until P8's `HostResolve.cpp` flattens it; no measured workload has one.
|
||||
until P8's `HostResolve.cpp` flattens it; no measured workload has one. **P8 amendment (ID-P8-6):**
|
||||
the client flattens client indices into an owned EBO (`EmitTables.cpp:688-709`), so only a foreign
|
||||
peer can reach the server latch, which is now `ProtocolCorruption`.
|
||||
|
||||
**Client-side VERTEX arrays** (attribute pointers into client memory, no VBO) are NOT d1's
|
||||
and are not a wire question: Espryt's `SyncClientSideAttributesForDrawArrays`
|
||||
|
||||
@@ -441,7 +441,9 @@ pointer, `Managers.cpp:5382`): under `RunAheadArmed` a draw with `kDrawClientArr
|
||||
array arm; the lockstep arm is unchanged; the staged form (a per-attribute `{BindingIndex,
|
||||
MGHostSpan}` tail like `kDrawHasUserIndices`) is P8's. Two pins by test: `CurrentBufferMutationEpoch()`
|
||||
(`Managers.cpp:794`) is apply-thread-only under a transport; the VAO twin key is 1:1 only while the
|
||||
vertex-elements CSO stays identity-addressed.
|
||||
vertex-elements CSO stays identity-addressed. **P8 amendment (ID-P8-6):** client arrays and client
|
||||
indices became owned buffers (`beba0256`); Magma's `client-vertex-array` site is unreachable from our
|
||||
client and is now `ProtocolCorruption`.
|
||||
|
||||
### 5.2 Textures (tx2)
|
||||
Every draw-path entry is `SyncTextureToBackendByHandle(h, imageBindable)`: record first, twin by
|
||||
|
||||
@@ -60,7 +60,7 @@ P7 收官 = 五道出口门同时成立(§2–§7),而不是路线图 P7
|
||||
|---|---|---|---|
|
||||
| `uniform-buffer-byte-tail` | `UniformManager.cpp:2391` | **退役**(真机 MC 报告 §5 的活边界) | 拷贝窗口外扩到 4 字节边界进 transient slice,再 `vkCmdCopyBuffer` 对齐内部到正确子字目的;`CopyWireBufferRangeToSlice` 扩 |
|
||||
| `copy-image-in-place` | `VulkanRenderer.cpp` | **已退役(wave 2-B,`4f857aa5`)** | `srcImage == dstImage` 时单次转 `GENERAL`、两侧布局 GENERAL、一次写回;同 mip+layer 且矩形重叠 → decline(GL 未定义) |
|
||||
| `mipmap-shader-format-or-shape`(真机 iterationt 的死因) | `WireFramebuffer.inc` | **半退役(wave 2-B,`c4be3800`)** | Fatal 行带上格式 / 尺寸 / aspect / 缺的 feature 位;image 不能作附件时经 scratch 走颜色 shader mip;仍无 shader 臂的形状**具名**拒绝 |
|
||||
| `mipmap-shader-format-or-shape`(真机 iterationt 的死因) | `WireFramebuffer.inc` | **已退役(P8-F,ID-P8-6)**:wire 臂改具名拒绝 `MipmapShaderFormatOrShape`,与 monolith 一致;此前半退役(wave 2-B,`c4be3800`) | Fatal 行带上格式 / 尺寸 / aspect / 缺的 feature 位;image 不能作附件时经 scratch 走颜色 shader mip;仍无 shader 臂的形状**具名**拒绝 |
|
||||
| **wire 回读竞态(曾被当作 OpenRA 真机 0.976494 的原因;真因是下一行)** | `WireFramebuffer.inc` / `VulkanRenderer.cpp` | **已修(wave 2-B,`76b74693`)** |
|
||||
| **wire 臂 completed-frame-serial floor 不健全(OpenRA 真机 0.976494 / 0.988998 的真因,ID-P7-33)** | `VulkanRenderer.cpp` `OnSubmitsCompletedUpTo`、`VkBufferManager.cpp` `WriteWireBuffer` | **已修(wave 2-B3,`511c1f16` / `c9164f25`)** | 一个 serial 两次提交(S1 pooled-fence 中帧 flush、S2 Present),逐记录退休把 floor 提前 → 帧 N 首次 `glBufferSubData` 走无序 host memcpy 被 S2(N-1) 的排队拷贝盖掉;floor 只升到可证 serial + 有读者在飞的 buffer 一律有序;计数 26→0,red-once `StreamedBufferSubDataBeforeEachDrawIsOrdered` Split+Spawn;32 处静默出口具名(`WireDeclines.def`)。留:三处单 fence 退休站点的聚合等待(B4) | `ReadWirePixels` 在 pooled fence 下 flush 帧内 draw 但不等待,拷贝是后一次提交,二者只靠一条 barrier 相连,而 `UNDEFINED` / `PRESENT_SRC_KHR` 的源 scope 映射成 `TOP_OF_PIPE`+0 = 空 scope——刚 present 过的默认 framebuffer正是这个布局;修后回读等它读的那一帧(red-once:`fences=2` vs `1`,`completed=71` 不变)。真机验收 = 三次 `pm clear` 冷跑 1.0 |
|
||||
| `vertex-layout` | `WireDraw.inc:245`、`VertexInputStateFactory.cpp:439-500` | **已拆分(wave 2-C,`f1b04edf`)** | `buffer-window` 一种保留为协议错(经 hook 的具名 Fatal,家族词暂留 `UnmigratedVerb`——改成更诚实的 `ProtocolCorruption` 要在 `MG_Pipe::MGPipeFatalFamily` 加一行 + 适配臂,§3.3 未花这笔,记 §12);其余**七**种形状/格式原因(含审计之后新增的 `offset-overflow`)改 monolith 的「屏蔽该属性继续画」,`BuildWireVertexInput` 出 `unsupportedAttribMask`;`vertex-format-conversion` 同包改 decline。`WireDraw.inc` 从此无 `@P7`(普查 15 → 13 处 / 3 文件) |
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# CONTRACT-P8:server 侧仿真缺口与 split 覆盖
|
||||
|
||||
> P8(2026-09-29 起,重定界见 `docs/Disaggregated/notes/p8/PLAN-P8.md`)落地后的规则。每条写明:规则、代码落点、守住它的用例。包说明见 `docs/Disaggregated/notes/p8/{A,B,C,D,E,F,SE,SV,MF,S}.md`,裁定见 `INTEGRATOR-DECISIONS-P8.md`。
|
||||
|
||||
## 1. Espryt 生成 mip(B、SE)
|
||||
|
||||
- server 按记录的生成窗口 [BASE+1, min(MAX+1, 存储层数, 链长)) 生成,与 Magma 同口径:`GenerateMipmapWindowByRecord`(`DirectGLES.cpp:11759`);两条 blit 链都走这个窗口。
|
||||
- RGB16F / RGB32F:先试驱动原生生成;驱动拒绝时 server 从**自己的**基级做 2×2 box,永不读 client 影子。
|
||||
- 基级读不回来时,暂存 store 只在「整级、extent 相符、未被驱动写过」时可代替;否则具名拒绝 `generate-mipmap-store-declined`(`DirectGLES.cpp:13134`),生成的层保持原样。driver-written 标在本次生成自己打标之前读取。
|
||||
- 用例:`GenerateMipmapServerScenario`(两后端 × monolith / Split / Spawn / Tcp;Espryt 强制 CPU 臂 `.CpuMip.`、`.CpuMipRefused.` 只上 Split / Spawn)。
|
||||
|
||||
## 2. Espryt server 暂存副本与 GPU 写(C)
|
||||
|
||||
- shader 写过的 buffer(SSBO / 原子计数、可写 buffer image、XFB)在 server 孪生体上打 `serverGpuWritten` 标。
|
||||
- server 的 CPU 读者(restart 重写、multi-draw rebase、`*IndirectCount`、CPU 取用的 indirect 字段、XFB scatter、fp64 收窄)一律经 `SplitHostBytesForCpuRead`(`Managers.cpp:3613`):有标或有排队常驻写时先刷新再读;T0 store 先落写再 `glFinish`。
|
||||
- 用例:`GpuWrittenDrawInputScenario`(Espryt Split / Spawn / Tcp 门控)。
|
||||
|
||||
## 3. Magma wire 臂的 indirect(D、SV)
|
||||
|
||||
- `glDraw*Indirect` / `glMultiDraw*Indirect[Count]` 从 wire store 直接录成 `vkCmdDraw*Indirect[Count]`(`DrawWireIndirectNative`,`WireDraw.inc:627`);CPU 展开只留给设备发不出的 COUNT 形态(与 monolith 同条件)。
|
||||
- `glDispatchComputeIndirect` 同样原生(`WireDraw.inc:844`),无 CPU 路径。
|
||||
- 屏障规则:store 被 shader 写过(`MarkWireBufferGpuWritten`)后,首个 indirect 读之前录一次 MEMORY_WRITE → INDIRECT_COMMAND_READ。
|
||||
- 用例:`WireIndirectDrawScenario`、`WireIndirectDispatchScenario`(计数经 `WireIndirectPeek`:原生可发时 CPU 展开 = 0)。
|
||||
|
||||
## 4. 驱动拒读的纹理回读(E)
|
||||
|
||||
- split 的 `glGetTexImage` 只读 GPU。驱动拒绝时由 server 暂存 store 作答,条件同 §1(整级、extent 相符、未被驱动写过),否则具名拒绝 `texture-readback-store-declined`(`DirectGLES/WireTextureReadback.inc:411`)。
|
||||
- store 跟随同格式、单上传目标、源可信的 `glCopyImageSubData`(`FollowCopyImageInStagedStore`,`Managers.cpp:11032`);跟不了的形状打粘性 driver-written 标。
|
||||
|
||||
## 5. 分类与拒绝(F、SV)
|
||||
|
||||
- 我们的 client 发不出的形状一律 `ProtocolCorruption`:multi-draw `CLIENT_INDICES` / `INSTANCED`(`MultiDrawShapeLatch`,`PipeApplier.cpp:779`)、Magma `client-vertex-array`。
|
||||
- Magma 生成 mip 的形状 / 格式缺口是具名拒绝:`MipmapShaderFormatOrShape`、`MipmapDepthStencilAspect`(`WireFramebuffer.inc:1401`、`:1465`),判定在长链之前;3D 原生 blit 用 1 层、深度走 z 偏移。
|
||||
|
||||
## 6. 默认帧缓冲的 surface 发布(SE)
|
||||
|
||||
- push 构建里,只要 `OnSurfaceChanged` 回调在,Espryt 就发布默认帧缓冲的格式与尺寸,不再以本进程的前端占位为条件(`DirectGLES.cpp:16239`);spawn / tcp 的 client 由此拿到 server surface 的真实深度模板格式。pull 构建不变。
|
||||
|
||||
## 7. Espryt flush 阶梯(MF,dev `f973008c`)
|
||||
|
||||
- 部分范围的失效映射不得越过同一 store 上 GPU 还没跑的环形拷贝:两条阶梯(push `FlushPendingRangesFrom`、pull `FlushPendingRangesNow`)都以 `ringCopyRetireSerial` 守住(`Managers.cpp:1496`、`:1785`);整 buffer 映射除外。
|
||||
- G5 两个脚本把两条阶梯的评审后正文钉在 ID-P8-14。
|
||||
|
||||
## 8. 覆盖与门(A、SE)
|
||||
|
||||
- 归一化前缀后,每个 monolith 用例要么登上 split 门控臂,要么在 `scripts/data/split_coverage_exemptions.txt` 里有原因类(mechanism / single-backend / no-records / pending-fix):`scripts/ci/split_coverage.py`。
|
||||
- `MGPipeUnmigratedEmulation` 的名单与调用点一一对应:`scripts/ci/unmigrated_emulation_sites.py`。
|
||||
- server 读的旋钮车道:要么独立 tcp supervisor,要么只上 split + spawn,要么证明对其他用例惰性。
|
||||
|
||||
## 不变量
|
||||
|
||||
- G1:pull 构建符号不变(整阶段 0 / 0);pull 的 `.text` 只随 dev 修复变化。
|
||||
- 控制协议修订号不变(5);线上格式不变。
|
||||
@@ -44,9 +44,9 @@ namespace MobileGL::MG_Remote {
|
||||
// (MGPipeTypes.h:108-124) and has no per-family bit at all, so "read the CallMask" was
|
||||
// not yet an implementable instruction. It is now:
|
||||
//
|
||||
// bits 0..8 MGPCapBit, unchanged. kCapNeedsHostIndexBytes and kCapNeedsHostUboBytes
|
||||
// are BOTH ZERO in P5 by ruling (table 0), which is what keeps every
|
||||
// MGHostSpan out of the first IPC frame.
|
||||
// bits 0..8 MGPCapBit, unchanged. kCapViewportArray (0), kCapNeedsHostIndexBytes (7)
|
||||
// and kCapNeedsHostUboBytes (8) are RESERVED (P8-F): never published, and
|
||||
// their positions are never reused, which keeps every MGHostSpan off the wire.
|
||||
// bits 9..31 reserved for further MGPCapBits.
|
||||
// bits 32..47 THE CONSUMER MASK: bit (32 + n) means "the server has a consumer for
|
||||
// MGPipe subsystem bit n" - i.e. the server's own subsystem mask, shifted.
|
||||
|
||||
@@ -251,7 +251,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// P5e (sb, CONTRACT-P5E.md §5.6): the indexed buffer binding points, one record per
|
||||
// class. The generic tail wrapper carries the FIRST tail only, which is the whole of
|
||||
// the record on Espryt - the optional MGHostSpan tail exists for kCapNeedsHostUboBytes
|
||||
// and that bit is 0 for the whole of P5.
|
||||
// and that bit is RESERVED (P8-F): no server publishes it.
|
||||
MGP_WIRE_TAIL(SetShaderBuffers, MGPShaderBuffers, MGPBufferRange)
|
||||
MGP_WIRE_TAIL(SetVertexAttribDefaults, MGPVertexAttribDefaults, MGPAttribValue)
|
||||
|
||||
|
||||
@@ -766,17 +766,20 @@ namespace MobileGL::MG_Remote::Server {
|
||||
return LandReadbackInBuffer(record, bytes.data(), bpp);
|
||||
}
|
||||
|
||||
// P5b's server-side stub shape (CONTRACT-P5B.md): the same line the client's class-C table
|
||||
// raises (EmitTables.cpp UnmigratedVerbFatal) and the same family the census greps, so a
|
||||
// slot flipped on the client ahead of its server half aborts BY NAME on the apply thread
|
||||
// rather than rendering nothing. Named "(server sink)" in the message so a log reader can
|
||||
// tell which half is missing.
|
||||
// P8-F: A PROTOCOL GUARD, NOT AN UNMIGRATED VERB. This was P5b's server-side stub shape
|
||||
// (`Fatal{UnmigratedVerb, ...}`, "ServerVerbSink has no body for it yet"), but no package is
|
||||
// going to give these two multi-draw shapes a body, because our client can no longer send
|
||||
// either: client index arrays become one owned element buffer before the record is built
|
||||
// (EmitTables.cpp's multi-draw arm, OwnedDrawInputs.h clears kDrawHasUserIndices), and no GL
|
||||
// entry point produces an instanced multi-draw. A record that carries one came from a
|
||||
// foreign peer, so the family is the one every other malformed-record check uses.
|
||||
//
|
||||
// PH-1 (3): the shape is the PEER's (a multi-draw record it chose to send), so in an armed
|
||||
// session child the refusal latches and the verb returns false; unarmed it still dies.
|
||||
static Bool ServerUnmigratedVerbLatch(const char* slot) {
|
||||
return SessionLatch(MGFatalFamily::UnmigratedVerb, "MGPipe: Fatal{UnmigratedVerb, \"%s\"} (server sink: the record crossed and "
|
||||
"ServerVerbSink has no body for it yet - CONTRACT-P5B.md names the package)",
|
||||
static Bool MultiDrawShapeLatch(const char* slot) {
|
||||
return SessionLatch(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s\"} a multi-draw "
|
||||
"record with a shape this protocol does not carry: client indices travel as an owned "
|
||||
"element buffer and no GL entry point produces an instanced multi-draw",
|
||||
slot);
|
||||
}
|
||||
|
||||
@@ -802,10 +805,10 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// of 1 and no base instance is the plain draw it is equivalent to, and a count of 0 must
|
||||
// NOT collapse onto the plain draw (it draws nothing, the plain draw would draw once).
|
||||
//
|
||||
// What is still refused by name (the census's own grep family): a multi-draw that arrived
|
||||
// with a span (the client refuses "MultiDrawElements+CLIENT_INDICES" first; P8's
|
||||
// HostResolve.cpp flattens it) and a multi-draw that claims instancing (no GL entry point
|
||||
// produces one; the client never sends it).
|
||||
// What is still refused by name, as protocol corruption (P8-F): a multi-draw that arrived
|
||||
// with a span (our client stages client indices into an owned element buffer and never sets
|
||||
// kDrawHasUserIndices) and a multi-draw that claims instancing (no GL entry point produces
|
||||
// one; the client never sends it). Only a foreign peer reaches either.
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
namespace {
|
||||
// P5e (tx2), CONTRACT-P5E §5.3 / ruling 19 (ID-95, A8 closed). THE TWO UNIT WINDOWS MUST
|
||||
@@ -970,12 +973,12 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// ---- the multi-draws: the two arrays rebuilt from the ranges (rule C) --------------
|
||||
if (info.NumDraws != 1) {
|
||||
if (userIndices != nullptr) {
|
||||
return ServerUnmigratedVerbLatch(info.IndexSize == 0 ? "MultiDrawArrays+CLIENT_INDICES"
|
||||
: "MultiDrawElements+CLIENT_INDICES");
|
||||
return MultiDrawShapeLatch(info.IndexSize == 0 ? "MultiDrawArrays+CLIENT_INDICES"
|
||||
: "MultiDrawElements+CLIENT_INDICES");
|
||||
}
|
||||
if (instanced) {
|
||||
return ServerUnmigratedVerbLatch(info.IndexSize == 0 ? "MultiDrawArrays+INSTANCED"
|
||||
: "MultiDrawElements+INSTANCED");
|
||||
return MultiDrawShapeLatch(info.IndexSize == 0 ? "MultiDrawArrays+INSTANCED"
|
||||
: "MultiDrawElements+INSTANCED");
|
||||
}
|
||||
const auto n = static_cast<SizeT>(info.NumDraws);
|
||||
m_multiCounts.resize(n);
|
||||
|
||||
@@ -162,9 +162,9 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// that owns the question (kCapTimerQuery to the query family, kCapResidentSubData to
|
||||
// b1, and so on). `SetCapabilityBits(0)` is a legitimate and explicit answer - "this
|
||||
// server offers no optional capability" - and is the right call while those packages
|
||||
// land. kCapNeedsHostIndexBytes / kCapNeedsHostUboBytes must stay 0 for the whole of
|
||||
// P5 by ruling (CONTRACT-P5 table 0): they are the only two things that ask for an
|
||||
// MGHostSpan, and 0 is what keeps every one of them out of the first IPC frame.
|
||||
// land. kCapNeedsHostIndexBytes / kCapNeedsHostUboBytes / kCapViewportArray are RESERVED
|
||||
// (P8-F; CONTRACT-P5 table 0 first held the two host-byte bits at 0): the first two are
|
||||
// the only things that ask for an MGHostSpan, and 0 keeps every one of them off the wire.
|
||||
void SetCapabilityBits(Uint64 capBits);
|
||||
|
||||
// BITS 32..47, THE CONSUMER MASK (R-8 / C-4): which MGPipe subsystems this server has
|
||||
|
||||
@@ -350,6 +350,12 @@ namespace MobileGL::MG_Remote::Server {
|
||||
shadow.Covered.clear();
|
||||
}
|
||||
#endif
|
||||
if (shadow.HoldsFollowedCopy) {
|
||||
// P8-E: a run landed whole over a followed copy (AdoptClientBoxes is the spelling
|
||||
// that keeps it), so the bytes no longer hold what the driver does.
|
||||
shadow.HoldsFollowedCopy = false;
|
||||
m_driverWritten[key] = true;
|
||||
}
|
||||
shadow.GpuDirty = false;
|
||||
return CopyRunInto(shadow, key, uploadTarget, level, imageOffset, bytes, byteSize);
|
||||
}
|
||||
@@ -367,6 +373,8 @@ namespace MobileGL::MG_Remote::Server {
|
||||
LevelShadow& shadow = m_shadows[key].Levels[PackLevel(uploadTarget, level)];
|
||||
RequireDeclaredLevel(shadow, key, uploadTarget, level, extent);
|
||||
shadow.GpuDirty = false;
|
||||
// P8-E: the caller states these bytes ARE the level, which a followed copy is part of.
|
||||
shadow.HoldsFollowedCopy = false;
|
||||
shadow.Bytes.clear();
|
||||
shadow.Covered.clear();
|
||||
return CopyRunInto(shadow, key, uploadTarget, level, 0, bytes, byteSize);
|
||||
@@ -424,6 +432,7 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// the bytes it described.
|
||||
shadow.Covered.clear();
|
||||
shadow.GpuDirty = false;
|
||||
shadow.HoldsFollowedCopy = false;
|
||||
}
|
||||
shadow.Extent = extent;
|
||||
shadow.InternalFormat = internalFormat;
|
||||
@@ -457,12 +466,155 @@ namespace MobileGL::MG_Remote::Server {
|
||||
if (!m_any.load(std::memory_order_acquire)) return;
|
||||
const std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_shadows.erase(key);
|
||||
m_driverWritten.erase(key);
|
||||
}
|
||||
|
||||
void DropAll() {
|
||||
if (!m_any.load(std::memory_order_acquire)) return;
|
||||
const std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_shadows.clear();
|
||||
m_driverWritten.clear();
|
||||
}
|
||||
|
||||
// ---- P8-E (docs/Disaggregated/notes/p8/E.md): WHEN THESE BYTES ARE THE LEVEL'S CONTENT ----
|
||||
//
|
||||
// The store holds what the client uploaded. It is also the only CPU copy of a level the
|
||||
// server has, so a readback the driver refuses (a format the ES driver will not attach -
|
||||
// RGB16 and 16-bit SNORM on Adreno) can be answered from it - but only while the driver
|
||||
// holds nothing the store has not seen. Two facts decide that:
|
||||
//
|
||||
// * THE DRIVER-WRITTEN MARK, per texture and sticky: a framebuffer attachment, a writable
|
||||
// image unit, a glCopyTexSubImage, a generated mip chain, a copy this store could not
|
||||
// follow. The writers know the texture, not the level, and an attachment keeps writing
|
||||
// for as long as it stays attached, so only the key's death (Drop / DropAll) clears it -
|
||||
// a whole-resource respecify (ResetLevels) does not.
|
||||
// * A COPY THE STORE FOLLOWED (FollowCopy): glCopyImageSubData between two levels whose
|
||||
// bytes this store holds is a raw texel-block move, so the store makes the same move and
|
||||
// the destination stays readable from here. Its level is flagged, because the client's
|
||||
// next run for it is the CLIENT's shadow, which never saw the copy: AdoptClientBoxes
|
||||
// lands only the texels that run says the client wrote.
|
||||
void MarkDriverWritten(Uint64 key) {
|
||||
if (!m_copies) return;
|
||||
const std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_driverWritten[key] = true;
|
||||
m_any.store(true, std::memory_order_release);
|
||||
}
|
||||
Bool IsDriverWritten(Uint64 key) const {
|
||||
if (!m_any.load(std::memory_order_acquire)) return false;
|
||||
const std::lock_guard<std::mutex> lock(m_mutex);
|
||||
return m_driverWritten.find(key) != m_driverWritten.end();
|
||||
}
|
||||
Bool LevelHoldsFollowedCopy(Uint64 key, Uint16 uploadTarget, Uint16 level) const {
|
||||
if (!m_any.load(std::memory_order_acquire)) return false;
|
||||
const std::lock_guard<std::mutex> lock(m_mutex);
|
||||
const LevelShadow* shadow = FindLevel(key, uploadTarget, level);
|
||||
return shadow != nullptr && shadow->HoldsFollowedCopy;
|
||||
}
|
||||
|
||||
// The copy, in the level images' own texel grid (x, y, z = texel, row, slice/layer). True
|
||||
// when the destination's bytes now hold it. False - and neither level touched - unless the
|
||||
// source level is complete and its texture was never written by the driver, the destination
|
||||
// level is complete (or the copy covers all of it), both levels' stored texels are one size,
|
||||
// and the box lies inside both. The caller marks the destination driver-written on false.
|
||||
Bool FollowCopy(Uint64 srcKey, Uint16 srcTarget, Uint16 srcLevel, const IntVec3& srcOrigin,
|
||||
Uint64 dstKey, Uint16 dstTarget, Uint16 dstLevel, const IntVec3& dstOrigin,
|
||||
const IntVec3& size) {
|
||||
if (!m_copies) return false;
|
||||
const std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if (m_driverWritten.find(srcKey) != m_driverWritten.end()) return false;
|
||||
const LevelShadow* src = FindLevel(srcKey, srcTarget, srcLevel);
|
||||
LevelShadow* dst = FindLevelMutable(dstKey, dstTarget, dstLevel);
|
||||
if (src == nullptr || dst == nullptr || !LevelComplete(*src)) return false;
|
||||
const SizeT texel = LevelTexelBytes(*src);
|
||||
if (texel == 0 || !dst->Defined || dst->DeclaredByteBound == 0 || LevelTexelBytes(*dst) != texel) return false;
|
||||
if (!BoxInside(srcOrigin, size, src->Extent) || !BoxInside(dstOrigin, size, dst->Extent)) return false;
|
||||
const Bool wholeDestination = dstOrigin == IntVec3{0, 0, 0} && size == dst->Extent;
|
||||
if (!LevelComplete(*dst) && !wholeDestination) return false;
|
||||
// Gathered first, so a copy within one level cannot read rows it has already written.
|
||||
const SizeT rowBytes = static_cast<SizeT>(size.x()) * texel;
|
||||
Vector<Uint8> rows(rowBytes * static_cast<SizeT>(size.y()) * static_cast<SizeT>(size.z()));
|
||||
for (Int z = 0; z < size.z(); ++z) {
|
||||
for (Int y = 0; y < size.y(); ++y) {
|
||||
std::memcpy(rows.data() + (static_cast<SizeT>(z) * size.y() + y) * rowBytes,
|
||||
src->Bytes.data() + TexelOffset(src->Extent, srcOrigin.x(), srcOrigin.y() + y,
|
||||
srcOrigin.z() + z, texel),
|
||||
rowBytes);
|
||||
}
|
||||
}
|
||||
if (!LevelComplete(*dst)) {
|
||||
dst->Bytes.assign(static_cast<SizeT>(dst->DeclaredByteBound), Uint8{0});
|
||||
dst->Covered.clear();
|
||||
StagedShadowStore::CoverageAdd(dst->Covered, 0, static_cast<SizeT>(dst->DeclaredByteBound));
|
||||
}
|
||||
for (Int z = 0; z < size.z(); ++z) {
|
||||
for (Int y = 0; y < size.y(); ++y) {
|
||||
std::memcpy(dst->Bytes.data() + TexelOffset(dst->Extent, dstOrigin.x(), dstOrigin.y() + y,
|
||||
dstOrigin.z() + z, texel),
|
||||
rows.data() + (static_cast<SizeT>(z) * size.y() + y) * rowBytes, rowBytes);
|
||||
}
|
||||
}
|
||||
dst->HoldsFollowedCopy = true;
|
||||
m_any.store(true, std::memory_order_release);
|
||||
return true;
|
||||
}
|
||||
|
||||
// One box of texels, in the level image's grid, that a client record says it wrote.
|
||||
struct ClientTexelBox {
|
||||
Int32 X, Y, Z;
|
||||
Uint32 W, H, D;
|
||||
};
|
||||
|
||||
// A client run for a level that holds a followed copy. The run is the client's level shadow
|
||||
// (or one slab of it) and is stale everywhere the client did not write, so only `boxes` land,
|
||||
// each texel read from where it sits in the run (the run begins at `imageOffset` of the
|
||||
// level image) - the rest of the level keeps the copy. False, touching nothing, when a box
|
||||
// is outside the level or a row of it is outside the run: the caller then adopts the run as
|
||||
// usual and marks the texture driver-written.
|
||||
Bool AdoptClientBoxes(Uint64 key, Uint16 uploadTarget, Uint16 level, const IntVec3& extent,
|
||||
Uint64 imageOffset, const void* bytes, SizeT byteSize,
|
||||
const ClientTexelBox* boxes, SizeT boxCount) {
|
||||
if (!m_copies || bytes == nullptr || (boxCount != 0 && boxes == nullptr)) return false;
|
||||
const std::lock_guard<std::mutex> lock(m_mutex);
|
||||
LevelShadow* shadow = FindLevelMutable(key, uploadTarget, level);
|
||||
if (shadow == nullptr || !shadow->HoldsFollowedCopy || !LevelComplete(*shadow) || shadow->Extent != extent) {
|
||||
return false;
|
||||
}
|
||||
const SizeT texel = LevelTexelBytes(*shadow);
|
||||
if (texel == 0) return false;
|
||||
const auto rowInRun = [&](const ClientTexelBox& box, Uint32 row, Uint32 slice, SizeT& offset) {
|
||||
offset = TexelOffset(shadow->Extent, box.X, box.Y + static_cast<Int>(row), box.Z + static_cast<Int>(slice),
|
||||
texel);
|
||||
const Uint64 begin = static_cast<Uint64>(offset);
|
||||
const Uint64 end = begin + static_cast<Uint64>(box.W) * texel;
|
||||
return begin >= imageOffset && end <= imageOffset + byteSize;
|
||||
};
|
||||
for (SizeT i = 0; i < boxCount; ++i) {
|
||||
const ClientTexelBox& box = boxes[i];
|
||||
if (!BoxInside(IntVec3{box.X, box.Y, box.Z},
|
||||
IntVec3{static_cast<Int>(box.W), static_cast<Int>(box.H), static_cast<Int>(box.D)},
|
||||
shadow->Extent)) {
|
||||
return false;
|
||||
}
|
||||
for (Uint32 slice = 0; slice < box.D; ++slice) {
|
||||
for (Uint32 row = 0; row < box.H; ++row) {
|
||||
SizeT offset = 0;
|
||||
if (!rowInRun(box, row, slice, offset)) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
const auto* run = static_cast<const Uint8*>(bytes);
|
||||
for (SizeT i = 0; i < boxCount; ++i) {
|
||||
const ClientTexelBox& box = boxes[i];
|
||||
for (Uint32 slice = 0; slice < box.D; ++slice) {
|
||||
for (Uint32 row = 0; row < box.H; ++row) {
|
||||
SizeT offset = 0;
|
||||
rowInRun(box, row, slice, offset);
|
||||
std::memcpy(shadow->Bytes.data() + offset, run + (offset - static_cast<SizeT>(imageOffset)),
|
||||
static_cast<SizeT>(box.W) * texel);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fatal when a sync wants texels this store has no covered run for. This is THE data
|
||||
@@ -589,6 +741,8 @@ namespace MobileGL::MG_Remote::Server {
|
||||
Uint64 DeclaredByteBound = 0;
|
||||
Bool Defined = false;
|
||||
Bool GpuDirty = false;
|
||||
// P8-E: FollowCopy wrote server-side texels into Bytes that the client's shadow lacks.
|
||||
Bool HoldsFollowedCopy = false;
|
||||
};
|
||||
struct TextureShadow {
|
||||
ska::flat_hash_map<Uint32, LevelShadow> Levels;
|
||||
@@ -684,11 +838,51 @@ namespace MobileGL::MG_Remote::Server {
|
||||
const auto levelIt = textureIt->second.Levels.find(PackLevel(uploadTarget, level));
|
||||
return levelIt == textureIt->second.Levels.end() ? nullptr : &levelIt->second;
|
||||
}
|
||||
LevelShadow* FindLevelMutable(Uint64 key, Uint16 uploadTarget, Uint16 level) {
|
||||
const auto textureIt = m_shadows.find(key);
|
||||
if (textureIt == m_shadows.end()) return nullptr;
|
||||
const auto levelIt = textureIt->second.Levels.find(PackLevel(uploadTarget, level));
|
||||
return levelIt == textureIt->second.Levels.end() ? nullptr : &levelIt->second;
|
||||
}
|
||||
|
||||
// P8-E helpers, with the lock held. A level is COMPLETE when every declared byte crossed
|
||||
// (IsCovered's test); its texel size is the declared bound over the texel count, and a bound
|
||||
// that does not divide evenly is a level this cannot address texel by texel.
|
||||
static Bool LevelComplete(const LevelShadow& shadow) {
|
||||
return shadow.Defined && shadow.DeclaredByteBound != 0 &&
|
||||
shadow.Bytes.size() == shadow.DeclaredByteBound &&
|
||||
StagedShadowStore::CoverageHas(shadow.Covered, 0, static_cast<SizeT>(shadow.DeclaredByteBound));
|
||||
}
|
||||
static SizeT LevelTexelBytes(const LevelShadow& shadow) {
|
||||
if (shadow.Extent.x() <= 0 || shadow.Extent.y() <= 0 || shadow.Extent.z() <= 0) return 0;
|
||||
const Uint64 texels = static_cast<Uint64>(shadow.Extent.x()) * static_cast<Uint64>(shadow.Extent.y()) *
|
||||
static_cast<Uint64>(shadow.Extent.z());
|
||||
if (shadow.DeclaredByteBound == 0 || shadow.DeclaredByteBound % texels != 0) return 0;
|
||||
return static_cast<SizeT>(shadow.DeclaredByteBound / texels);
|
||||
}
|
||||
static Bool BoxInside(const IntVec3& origin, const IntVec3& size, const IntVec3& extent) {
|
||||
for (Int axis = 0; axis < 3; ++axis) {
|
||||
if (origin[axis] < 0 || size[axis] <= 0 ||
|
||||
static_cast<Int64>(origin[axis]) + size[axis] > static_cast<Int64>(extent[axis])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static SizeT TexelOffset(const IntVec3& extent, Int x, Int y, Int z, SizeT texel) {
|
||||
return ((static_cast<SizeT>(z) * static_cast<SizeT>(extent.y()) + static_cast<SizeT>(y)) *
|
||||
static_cast<SizeT>(extent.x()) +
|
||||
static_cast<SizeT>(x)) *
|
||||
texel;
|
||||
}
|
||||
|
||||
const Bool m_copies;
|
||||
mutable std::mutex m_mutex;
|
||||
StagedTextureDeviceLimits m_deviceLimits{};
|
||||
ska::flat_hash_map<Uint64, TextureShadow> m_shadows;
|
||||
// P8-E: MarkDriverWritten's keys (the value is always true). Apart from m_shadows on purpose,
|
||||
// because ResetLevels erases a key's levels and must not forget this.
|
||||
ska::flat_hash_map<Uint64, Bool> m_driverWritten;
|
||||
// Read on every IsLevelGpuDirty / LevelExtentOrUndefined, so the monolith cost is one
|
||||
// acquire load of a never-written flag rather than a mutex and two hash lookups.
|
||||
std::atomic<Bool> m_any{false};
|
||||
|
||||
@@ -456,8 +456,9 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
}
|
||||
|
||||
const void* SegmentTable::Resolve(Uint32 seg, Uint64 offset, Uint64 size) const {
|
||||
// 0 is "no segment", ALWAYS (table 0), and 0xFFFFFFFF is P8's index-mirror sentinel
|
||||
// which this phase does not resolve. Both land here as "unknown", and the CALLER
|
||||
// 0 is "no segment", ALWAYS (table 0), and 0xFFFFFFFF is the RESERVED index-mirror
|
||||
// sentinel (P8-F: the mirror was never built, so nothing resolves it and no client of
|
||||
// ours sends it). Both land here as "unknown", and the CALLER
|
||||
// escalates to Fatal - a unit case has to be able to exercise this arithmetic without
|
||||
// dying.
|
||||
if (seg == kSegNone || seg > static_cast<Uint32>(kSegAdopt)) {
|
||||
@@ -2121,7 +2122,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// entire point is that the server stops walking the client's binding-point table.
|
||||
//
|
||||
// THE HOST-SPAN PASS STILL RUNS FIRST, and it runs whether or not the record is
|
||||
// applied: kCapNeedsHostUboBytes is 0 for the whole of P5 (table 0), so the second
|
||||
// applied: kCapNeedsHostUboBytes is RESERVED (P8-F, never published), so the second
|
||||
// tail is always absent here, and this pass is what says so out loud if it ever is
|
||||
// not. A span that was going to be refused must be refused BEFORE the applier has
|
||||
// stored the window it rides with.
|
||||
|
||||
@@ -148,9 +148,9 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// declared. Fatal on an absent blob, then CheckBlobIsHonest on a present one.
|
||||
Bool RequireDeclaredBlob(MG_Pipe::MGPWireOp op, const MG_Pipe::MGPBlobRef& blob,
|
||||
const SegmentTable& segments);
|
||||
// R-2.3 arms 1 and 3 for MGHostSpan. P5's reduced path should produce ZERO host spans
|
||||
// (kCapNeedsHostIndexBytes / kCapNeedsHostUboBytes are both 0 in P5, table 0), so this
|
||||
// firing at all is a finding, not just a corruption check.
|
||||
// R-2.3 arms 1 and 3 for MGHostSpan. Our client produces ZERO host spans
|
||||
// (kCapNeedsHostIndexBytes / kCapNeedsHostUboBytes are RESERVED since P8-F, never set), so
|
||||
// this firing at all is a finding, not just a corruption check.
|
||||
//
|
||||
// IT CANNOT DO ARM 4 - it has no segment table - so a span that names a real segment and a
|
||||
// run PAST THE END OF IT passes this function. Use the overload below on any path that has
|
||||
|
||||
@@ -819,19 +819,19 @@ namespace {
|
||||
} // namespace
|
||||
|
||||
TEST(EsprytFlushLadder, AWholeBufferRangeOrphansTheStore) {
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(0, kStore, 0, kStore, kStore, kStore),
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(0, kStore, 0, kStore, kStore, kStore, false),
|
||||
static_cast<GLbitfield>(GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT));
|
||||
}
|
||||
|
||||
TEST(EsprytFlushLadder, ALargePartialRangeInvalidatesExactlyThatRange) {
|
||||
const SizeT start = 4096;
|
||||
const SizeT end = start + kEsprytInvalidateRangeMinBytes;
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(start, end, start, end, kStore, kStore),
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(start, end, start, end, kStore, kStore, false),
|
||||
static_cast<GLbitfield>(GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT));
|
||||
}
|
||||
|
||||
TEST(EsprytFlushLadder, ASmallPartialRangeFallsThroughToTheStagingRing) {
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(4096, 4096 + 64, 4096, 4096 + 64, kStore, kStore), 0u)
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(4096, 4096 + 64, 4096, 4096 + 64, kStore, kStore, false), 0u)
|
||||
<< "below the threshold the map WAITS out the WAR hazard on the CPU instead of "
|
||||
"substituting pages, which is the whole reason tier 2 exists";
|
||||
}
|
||||
@@ -846,19 +846,33 @@ TEST(EsprytFlushLadder, AMapWiderThanTheQueuedRangeRefusesTierOne) {
|
||||
const SizeT queuedStart = 4096;
|
||||
const SizeT queuedEnd = queuedStart + kEsprytInvalidateRangeMinBytes;
|
||||
// Page-aligned outward, the exact widening the in-tree note records.
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(queuedStart, queuedEnd, 0, queuedEnd + 4096, kStore, kStore), 0u)
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(queuedStart, queuedEnd, 0, queuedEnd + 4096, kStore, kStore, false), 0u)
|
||||
<< "a widened INVALIDATE_RANGE declares bytes dead that the shadow is not about to "
|
||||
"rewrite, and overwrites whatever the GPU put there";
|
||||
// And narrower, which is the same corruption read the other way round: bytes left
|
||||
// unwritten inside a range that has just been declared dead.
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(queuedStart, queuedEnd, queuedStart, queuedEnd - 8, kStore, kStore), 0u);
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(queuedStart, queuedEnd, queuedStart, queuedEnd - 8, kStore, kStore, false),
|
||||
0u);
|
||||
}
|
||||
|
||||
TEST(EsprytFlushLadder, AnEmptyRangeIsNeverTierOne) {
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(4096, 4096, 4096, 4096, kStore, kStore), 0u);
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(4096, 4096, 4096, 4096, kStore, kStore, false), 0u);
|
||||
}
|
||||
|
||||
// dev f973008c's rule on the push arm (P8-MF): Adreno 830 loses an upload-ring copy still queued
|
||||
// on a store when a partial range-invalidating map of that store overtakes it, so a partial range
|
||||
// waits behind the copy on the ring. The whole-buffer orphan-map is exempt.
|
||||
TEST(EsprytFlushLadder, APartialRangeDoesNotOvertakeAQueuedRingCopy) {
|
||||
const SizeT start = 4096;
|
||||
const SizeT end = start + kEsprytInvalidateRangeMinBytes;
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(start, end, start, end, kStore, kStore, true), 0u)
|
||||
<< "a range-invalidating map of a store with a queued ring copy loses the copy on Adreno 830";
|
||||
EXPECT_EQ(InvalidateFlushAccessFor(0, kStore, 0, kStore, kStore, kStore, true),
|
||||
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";
|
||||
}
|
||||
#else
|
||||
// The same five names in a pull build, for the G2/G14 reason above: the ladder's push arm
|
||||
// The same six names in a pull build, for the G2/G14 reason above: the ladder's push arm
|
||||
// (FlushPendingRangesFrom) is the only one that carries this decision as a function - the pull
|
||||
// arm's FlushPendingRangesNow is byte-frozen against 5cb826b0 (ID-15) and may not grow one.
|
||||
#define MGL_PUSH_ONLY_OR_SKIP() \
|
||||
@@ -869,4 +883,5 @@ TEST(EsprytFlushLadder, ALargePartialRangeInvalidatesExactlyThatRange) { MGL_PUS
|
||||
TEST(EsprytFlushLadder, ASmallPartialRangeFallsThroughToTheStagingRing) { MGL_PUSH_ONLY_OR_SKIP(); }
|
||||
TEST(EsprytFlushLadder, AMapWiderThanTheQueuedRangeRefusesTierOne) { MGL_PUSH_ONLY_OR_SKIP(); }
|
||||
TEST(EsprytFlushLadder, AnEmptyRangeIsNeverTierOne) { MGL_PUSH_ONLY_OR_SKIP(); }
|
||||
TEST(EsprytFlushLadder, APartialRangeDoesNotOvertakeAQueuedRingCopy) { MGL_PUSH_ONLY_OR_SKIP(); }
|
||||
#endif // MOBILEGL_PIPE_PUSH
|
||||
|
||||
@@ -1423,7 +1423,9 @@ TEST(PipeCatalogue, ResourceRespecifyAcksOnlyImmutableStorage) {
|
||||
// gate rather than a surprise three phases later.
|
||||
//
|
||||
// The names are pinned here rather than counted in the backend, because the count alone cannot
|
||||
// say WHICH one was lost. The purity gate greps the count; this says what the count is of.
|
||||
// say WHICH one was lost. P8-SE: scripts/ci/unmigrated_emulation_sites.py holds this list against
|
||||
// the `MGPipeUnmigratedEmulation("...")` call sites in the tree - equal sets, one site per name -
|
||||
// because nothing did before and the list drifted twice unseen (P8-B, and P8-SE's dead name).
|
||||
TEST(PipeCatalogue, EveryUnmigratedEmulationIsNamedOnce) {
|
||||
// Every one of these is an emulation that reads or writes CLIENT memory a split server
|
||||
// would not have: a CPU shadow mirror, a CPU mipmap fallback and a shadow-conversion
|
||||
@@ -1435,13 +1437,23 @@ TEST(PipeCatalogue, EveryUnmigratedEmulationIsNamedOnce) {
|
||||
// the re-mint is the server's own (RequireImageBindableStorageByHandle reads the GPU level and
|
||||
// replays the staged store), the frontend arm that carried the marker is monolith-only, and no
|
||||
// pull protocol or ResourceSubDataComplete terminator exists (notes/p9/W2-REMINT.md).
|
||||
//
|
||||
// AND THE LIST HAD DRIFTED BY ONE UNTIL P8-B. The tree carried a sixth name this list never
|
||||
// had: "generate-mipmap-cpu-filter", the split arm's RGB16F/RGB32F refusal in
|
||||
// GenerateMipmapByRecord. P8-B2 retired it (the server filters its own level,
|
||||
// GenerateThreeChannelFloatMipmapOnServer), and P8-B1 retired the split arm's two
|
||||
// "generate-mipmap-storage" sites (the record's plan is the window). Every name left is on a
|
||||
// MONOLITH arm - the split arms no longer reach an unmigrated emulation (notes/p8/B.md).
|
||||
//
|
||||
// THREE, NOT FOUR (P8-SE). "copy-image-shadow-mirror" sat after the mirror's own
|
||||
// `Transport != Monolith` return, so no transport ever reached it and on monolith it was a
|
||||
// no-op; the call and the name went together (notes/p8/SE.md).
|
||||
const char* const kNames[] = {
|
||||
"copy-image-shadow-mirror", // the glCopyImageSubData CPU-shadow mirror
|
||||
"generate-mipmap-storage", // EnsureGenerateMipmapStorageAllocated
|
||||
"generate-mipmap-storage", // EnsureGenerateMipmapStorageAllocated (monolith grow)
|
||||
"generate-mipmap-cpu-fallback", // GenerateThreeChannelFloatMipmapOnCpu
|
||||
"get-tex-image-shadow", // GetTexImageViaShadowConversion
|
||||
};
|
||||
EXPECT_EQ(std::size(kNames), 4u);
|
||||
EXPECT_EQ(std::size(kNames), 3u);
|
||||
// No duplicates: two sites sharing a name would make the grepped count and this list
|
||||
// disagree in the one direction nobody would notice.
|
||||
for (SizeT i = 0; i < std::size(kNames); ++i) {
|
||||
|
||||
@@ -574,4 +574,25 @@ namespace {
|
||||
}
|
||||
EXPECT_EQ(PS::FrameCount(), PS::SummaryFramePeriod());
|
||||
}
|
||||
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
// P8-D: the Magma wire arm's indirect-draw bracket. Its short names are what the create
|
||||
// fixtures' measurement (notes/p8/D.md) reads off the server's line, and its long names are
|
||||
// what Harness/WireIndirectPeek.cpp's readers expect in the JSON dump.
|
||||
TEST_F(PipeStatsTest, WireIndirectCountersPrintInTheirOwnBracket) {
|
||||
PS::AddCalls(PS::CallClass::WireIndirectNativeDraws, 3);
|
||||
PS::AddCalls(PS::CallClass::WireIndirectCpuExpansions, 2);
|
||||
PS::AddCalls(PS::CallClass::WireHostWaitMicros, 1500);
|
||||
PS::AddCalls(PS::CallClass::WireIndirectNativeDispatches, 4);
|
||||
const String line = PS::FormatWindowLine();
|
||||
EXPECT_NE(line.find("windr[wind=3 wixp=2 wibar=0 whw=0 whwi=0 whwus=1500 wdsp=4]"), String::npos) << line;
|
||||
EXPECT_STREQ(PS::NameOf(PS::CallClass::WireIndirectNativeDispatches), "wire-indirect-native-dispatches");
|
||||
EXPECT_STREQ(PS::NameOf(PS::CallClass::WireIndirectNativeDraws), "wire-indirect-native-draws");
|
||||
EXPECT_STREQ(PS::NameOf(PS::CallClass::WireIndirectCpuExpansions), "wire-indirect-cpu-expansions");
|
||||
EXPECT_STREQ(PS::NameOf(PS::CallClass::WireIndirectBarriers), "wire-indirect-barriers");
|
||||
EXPECT_STREQ(PS::NameOf(PS::CallClass::WireHostWaits), "wire-host-waits");
|
||||
EXPECT_STREQ(PS::NameOf(PS::CallClass::WireHostWaitsIndirect), "wire-host-waits-indirect");
|
||||
EXPECT_STREQ(PS::NameOf(PS::CallClass::WireHostWaitMicros), "wire-host-wait-us");
|
||||
}
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
@@ -1159,8 +1159,10 @@ namespace {
|
||||
p.FrameSerial = 0;
|
||||
return Forge(c, r, P::MGPWireOp::Present, Bytes(p));
|
||||
}},
|
||||
// P8-F: ProtocolCorruption, no longer UnmigratedVerb - our client cannot send this shape
|
||||
// (nor +CLIENT_INDICES, the same site), so only a foreign peer like this one reaches it.
|
||||
{"MultiDrawInstanced", "PipeApplier.cpp", "MultiDraw*+INSTANCED", Outcome::Latched,
|
||||
"Fatal{UnmigratedVerb, \"MultiDrawArrays+INSTANCED\"}", false,
|
||||
"Fatal{ProtocolCorruption, \"MultiDrawArrays+INSTANCED\"}", false,
|
||||
[](Client::ClientSession& c, PeerReport& r) {
|
||||
P::MGPDrawInfo info{};
|
||||
info.Mode = GL_TRIANGLES;
|
||||
|
||||
@@ -302,6 +302,197 @@ TEST(StagedTextureStoreTest, TheGpuDirtyMarkIsTheServersOwnDirtyAnswer) {
|
||||
EXPECT_EQ(monolithStore.TrackedResources(), 0u);
|
||||
}
|
||||
|
||||
// ---- P8-E (docs/Disaggregated/notes/p8/E.md): the store follows glCopyImageSubData -----------
|
||||
//
|
||||
// Two 4x4 RGBA8 levels (four bytes a texel), each adopted whole with a distinct byte pattern so a
|
||||
// mis-addressed row or a swapped endpoint shows as a wrong byte, not a coincidentally right one.
|
||||
namespace {
|
||||
const IntVec3 kFollowExtent{4, 4, 1};
|
||||
|
||||
Vector<Uint8> FollowPattern(Uint8 base) {
|
||||
Vector<Uint8> bytes(64);
|
||||
for (SizeT i = 0; i < bytes.size(); ++i) bytes[i] = static_cast<Uint8>(base + i);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void DefineAndAdopt(Server::StagedTextureStore& store, Uint64 key, const Vector<Uint8>& bytes) {
|
||||
store.NoteLevelDefined(key, kTex2DTarget, 0, kFollowExtent);
|
||||
store.Adopt(key, kTex2DTarget, 0, kFollowExtent, bytes.data(), bytes.size());
|
||||
}
|
||||
|
||||
// The byte (x, y, channel) of a 4x4 RGBA8 level image.
|
||||
SizeT At(Int x, Int y, Int c) { return static_cast<SizeT>((y * 4 + x) * 4 + c); }
|
||||
} // namespace
|
||||
|
||||
// THE MOVE: the 2x3 window at (1, 1) of the source lands at (2, 0) of the destination, every other
|
||||
// destination byte and every source byte stays, and only the destination is flagged as holding a
|
||||
// copy the client never saw.
|
||||
TEST(StagedTextureStoreTest, AFollowedCopyMovesTheWindowAndLeavesTheSourceAlone) {
|
||||
Server::StagedTextureStore store(/*copies=*/true);
|
||||
const Uint64 src = Server::StagedTextureStore::KeyForHandle(TestHandle(60, 1));
|
||||
const Uint64 dst = Server::StagedTextureStore::KeyForHandle(TestHandle(61, 1));
|
||||
const auto srcBytes = FollowPattern(0x00);
|
||||
const auto dstBytes = FollowPattern(0x80);
|
||||
DefineAndAdopt(store, src, srcBytes);
|
||||
DefineAndAdopt(store, dst, dstBytes);
|
||||
|
||||
ASSERT_TRUE(store.FollowCopy(src, kTex2DTarget, 0, IntVec3{1, 1, 0}, dst, kTex2DTarget, 0, IntVec3{2, 0, 0},
|
||||
IntVec3{2, 3, 1}));
|
||||
EXPECT_TRUE(store.LevelHoldsFollowedCopy(dst, kTex2DTarget, 0));
|
||||
EXPECT_FALSE(store.LevelHoldsFollowedCopy(src, kTex2DTarget, 0));
|
||||
const Uint8* got = store.RequireLevelBytes(dst, kTex2DTarget, 0, "unit");
|
||||
const Uint8* source = store.RequireLevelBytes(src, kTex2DTarget, 0, "unit");
|
||||
for (Int y = 0; y < 4; ++y) {
|
||||
for (Int x = 0; x < 4; ++x) {
|
||||
const Bool copied = x >= 2 && y < 3;
|
||||
for (Int c = 0; c < 4; ++c) {
|
||||
const Uint8 want = copied ? srcBytes[At(x - 2 + 1, y + 1, c)] : dstBytes[At(x, y, c)];
|
||||
ASSERT_EQ(got[At(x, y, c)], want) << "destination texel (" << x << ", " << y << ")";
|
||||
ASSERT_EQ(source[At(x, y, c)], srcBytes[At(x, y, c)]) << "the copy moved a SOURCE byte";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Every shape the store cannot address, and a source it can no longer vouch for, is REFUSED with
|
||||
// the destination untouched - the caller marks it driver-written instead. The monolith store
|
||||
// follows nothing at all.
|
||||
TEST(StagedTextureStoreTest, ACopyTheStoreCannotVouchForIsNotFollowed) {
|
||||
Server::StagedTextureStore store(/*copies=*/true);
|
||||
const Uint64 src = Server::StagedTextureStore::KeyForHandle(TestHandle(62, 1));
|
||||
const Uint64 dst = Server::StagedTextureStore::KeyForHandle(TestHandle(63, 1));
|
||||
const Uint64 narrow = Server::StagedTextureStore::KeyForHandle(TestHandle(64, 1));
|
||||
const Uint64 bare = Server::StagedTextureStore::KeyForHandle(TestHandle(65, 1));
|
||||
const auto dstBytes = FollowPattern(0x80);
|
||||
DefineAndAdopt(store, src, FollowPattern(0x00));
|
||||
DefineAndAdopt(store, dst, dstBytes);
|
||||
store.NoteLevelDefined(narrow, kTex2DTarget, 0, IntVec3{8, 8, 1},
|
||||
static_cast<Uint8>(MG_Pipe::MGPipeResourceTarget::Tex2D),
|
||||
static_cast<Uint32>(TextureInternalFormat::R8)); // 64 bytes, one a texel
|
||||
Vector<Uint8> narrowBytes(64, 0x11);
|
||||
store.Adopt(narrow, kTex2DTarget, 0, IntVec3{8, 8, 1}, narrowBytes.data(), narrowBytes.size());
|
||||
store.NoteLevelDefined(bare, kTex2DTarget, 0, kFollowExtent); // defined, no bytes crossed
|
||||
|
||||
const IntVec3 origin{0, 0, 0};
|
||||
EXPECT_FALSE(store.FollowCopy(src, kTex2DTarget, 0, IntVec3{3, 0, 0}, dst, kTex2DTarget, 0, origin,
|
||||
IntVec3{2, 1, 1}))
|
||||
<< "the box runs off the source's right edge";
|
||||
EXPECT_FALSE(store.FollowCopy(narrow, kTex2DTarget, 0, origin, dst, kTex2DTarget, 0, origin, IntVec3{1, 1, 1}))
|
||||
<< "a one-byte texel moved into a four-byte one";
|
||||
EXPECT_FALSE(store.FollowCopy(src, kTex2DTarget, 0, origin, bare, kTex2DTarget, 0, origin, IntVec3{2, 2, 1}))
|
||||
<< "a partial copy into a level none of whose bytes crossed";
|
||||
EXPECT_FALSE(store.FollowCopy(bare, kTex2DTarget, 0, origin, dst, kTex2DTarget, 0, origin, IntVec3{1, 1, 1}))
|
||||
<< "a source none of whose bytes crossed";
|
||||
store.MarkDriverWritten(src);
|
||||
EXPECT_FALSE(store.FollowCopy(src, kTex2DTarget, 0, origin, dst, kTex2DTarget, 0, origin, IntVec3{1, 1, 1}))
|
||||
<< "the driver wrote the source behind the store's back, so its bytes are not the texels copied";
|
||||
EXPECT_FALSE(store.LevelHoldsFollowedCopy(dst, kTex2DTarget, 0));
|
||||
const Uint8* got = store.RequireLevelBytes(dst, kTex2DTarget, 0, "unit");
|
||||
for (SizeT i = 0; i < dstBytes.size(); ++i) ASSERT_EQ(got[i], dstBytes[i]) << "a refused copy moved byte " << i;
|
||||
|
||||
Server::StagedTextureStore monolithStore(/*copies=*/false);
|
||||
EXPECT_FALSE(monolithStore.FollowCopy(src, kTex2DTarget, 0, origin, dst, kTex2DTarget, 0, origin,
|
||||
IntVec3{1, 1, 1}));
|
||||
}
|
||||
|
||||
// A copy that covers ALL of a destination level whose bytes never crossed (glTexStorage, no upload)
|
||||
// makes that level's content known: the store completes it.
|
||||
TEST(StagedTextureStoreTest, AWholeLevelCopyCompletesADestinationThatHadNoBytes) {
|
||||
Server::StagedTextureStore store(/*copies=*/true);
|
||||
const Uint64 src = Server::StagedTextureStore::KeyForHandle(TestHandle(66, 1));
|
||||
const Uint64 dst = Server::StagedTextureStore::KeyForHandle(TestHandle(67, 1));
|
||||
const auto srcBytes = FollowPattern(0x40);
|
||||
DefineAndAdopt(store, src, srcBytes);
|
||||
store.NoteLevelDefined(dst, kTex2DTarget, 0, kFollowExtent);
|
||||
ASSERT_FALSE(store.IsCovered(dst, kTex2DTarget, 0));
|
||||
ASSERT_TRUE(store.FollowCopy(src, kTex2DTarget, 0, IntVec3{0, 0, 0}, dst, kTex2DTarget, 0, IntVec3{0, 0, 0},
|
||||
kFollowExtent));
|
||||
ASSERT_TRUE(store.IsCovered(dst, kTex2DTarget, 0));
|
||||
const Uint8* got = store.RequireLevelBytes(dst, kTex2DTarget, 0, "unit");
|
||||
for (SizeT i = 0; i < srcBytes.size(); ++i) ASSERT_EQ(got[i], srcBytes[i]) << "byte " << i;
|
||||
}
|
||||
|
||||
// The client's next run for a level holding a followed copy is the CLIENT's shadow, which never saw
|
||||
// the copy: only the boxes it says it wrote land, the copied window survives, and a box whose rows
|
||||
// are not in the run is refused with nothing written.
|
||||
TEST(StagedTextureStoreTest, AClientRunOverAFollowedCopyLandsOnlyItsBoxes) {
|
||||
Server::StagedTextureStore store(/*copies=*/true);
|
||||
const Uint64 src = Server::StagedTextureStore::KeyForHandle(TestHandle(68, 1));
|
||||
const Uint64 dst = Server::StagedTextureStore::KeyForHandle(TestHandle(69, 1));
|
||||
const auto srcBytes = FollowPattern(0x00);
|
||||
const auto dstBytes = FollowPattern(0x80);
|
||||
DefineAndAdopt(store, src, srcBytes);
|
||||
DefineAndAdopt(store, dst, dstBytes);
|
||||
ASSERT_TRUE(store.FollowCopy(src, kTex2DTarget, 0, IntVec3{0, 0, 0}, dst, kTex2DTarget, 0, IntVec3{0, 0, 0},
|
||||
IntVec3{2, 2, 1}));
|
||||
|
||||
// The client's whole-level shadow: its own old bytes everywhere, 0xEE in the one row it wrote.
|
||||
Vector<Uint8> run = dstBytes;
|
||||
for (Int x = 0; x < 4; ++x) {
|
||||
for (Int c = 0; c < 4; ++c) run[At(x, 3, c)] = 0xEE;
|
||||
}
|
||||
const Server::StagedTextureStore::ClientTexelBox lastRow{0, 3, 0, 4, 1, 1};
|
||||
ASSERT_TRUE(store.AdoptClientBoxes(dst, kTex2DTarget, 0, kFollowExtent, 0, run.data(), run.size(), &lastRow, 1));
|
||||
const Uint8* got = store.RequireLevelBytes(dst, kTex2DTarget, 0, "unit");
|
||||
for (Int y = 0; y < 4; ++y) {
|
||||
for (Int x = 0; x < 4; ++x) {
|
||||
for (Int c = 0; c < 4; ++c) {
|
||||
const Uint8 want = y == 3 ? Uint8{0xEE} : (x < 2 && y < 2) ? srcBytes[At(x, y, c)] : dstBytes[At(x, y, c)];
|
||||
ASSERT_EQ(got[At(x, y, c)], want) << "texel (" << x << ", " << y << ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
EXPECT_TRUE(store.LevelHoldsFollowedCopy(dst, kTex2DTarget, 0));
|
||||
EXPECT_FALSE(store.IsDriverWritten(dst));
|
||||
|
||||
// A slab run that holds rows 2..3 only (imageOffset 32): row 0 is not in it.
|
||||
const Server::StagedTextureStore::ClientTexelBox firstRow{0, 0, 0, 4, 1, 1};
|
||||
Vector<Uint8> slab(32, 0x33);
|
||||
EXPECT_FALSE(store.AdoptClientBoxes(dst, kTex2DTarget, 0, kFollowExtent, 32, slab.data(), slab.size(), &firstRow, 1));
|
||||
EXPECT_EQ(got[At(0, 0, 0)], srcBytes[At(0, 0, 0)]) << "a refused run wrote into the level";
|
||||
}
|
||||
|
||||
// A run adopted WHOLE over a followed copy (any caller that does not take AdoptClientBoxes' route)
|
||||
// puts the client's stale texels back over it - so the store stops standing for the texture.
|
||||
TEST(StagedTextureStoreTest, AWholeRunOverAFollowedCopyMarksTheTextureDriverWritten) {
|
||||
Server::StagedTextureStore store(/*copies=*/true);
|
||||
const Uint64 src = Server::StagedTextureStore::KeyForHandle(TestHandle(70, 1));
|
||||
const Uint64 dst = Server::StagedTextureStore::KeyForHandle(TestHandle(71, 1));
|
||||
const auto dstBytes = FollowPattern(0x80);
|
||||
DefineAndAdopt(store, src, FollowPattern(0x00));
|
||||
DefineAndAdopt(store, dst, dstBytes);
|
||||
ASSERT_TRUE(store.FollowCopy(src, kTex2DTarget, 0, IntVec3{0, 0, 0}, dst, kTex2DTarget, 0, IntVec3{0, 0, 0},
|
||||
IntVec3{1, 1, 1}));
|
||||
store.AdoptRun(dst, kTex2DTarget, 0, kFollowExtent, 0, dstBytes.data(), dstBytes.size());
|
||||
EXPECT_TRUE(store.IsDriverWritten(dst));
|
||||
EXPECT_FALSE(store.LevelHoldsFollowedCopy(dst, kTex2DTarget, 0));
|
||||
EXPECT_FALSE(store.IsDriverWritten(src));
|
||||
}
|
||||
|
||||
// The driver-written mark is per texture and sticky: a whole-resource respecify does not clear it
|
||||
// (an attachment made before it keeps writing after it), only the key's death does. Inert on a
|
||||
// monolith store.
|
||||
TEST(StagedTextureStoreTest, TheDriverWrittenMarkOutlivesAResetAndDiesWithTheKey) {
|
||||
Server::StagedTextureStore store(/*copies=*/true);
|
||||
const Uint64 a = Server::StagedTextureStore::KeyForHandle(TestHandle(72, 1));
|
||||
const Uint64 b = Server::StagedTextureStore::KeyForHandle(TestHandle(73, 1));
|
||||
EXPECT_FALSE(store.IsDriverWritten(a));
|
||||
store.MarkDriverWritten(a);
|
||||
store.MarkDriverWritten(b);
|
||||
EXPECT_TRUE(store.IsDriverWritten(a));
|
||||
store.ResetLevels(a);
|
||||
EXPECT_TRUE(store.IsDriverWritten(a)) << "a respecify forgot that the driver writes this texture";
|
||||
store.Drop(a);
|
||||
EXPECT_FALSE(store.IsDriverWritten(a)) << "a destroyed texture's mark must not answer for the slot's next owner";
|
||||
EXPECT_TRUE(store.IsDriverWritten(b));
|
||||
store.DropAll();
|
||||
EXPECT_FALSE(store.IsDriverWritten(b));
|
||||
|
||||
Server::StagedTextureStore monolithStore(/*copies=*/false);
|
||||
monolithStore.MarkDriverWritten(a);
|
||||
EXPECT_FALSE(monolithStore.IsDriverWritten(a));
|
||||
}
|
||||
|
||||
// The two key namespaces share one map, so their disjointness is a property to pin, not to
|
||||
// assume: handle keys carry the top bit, twin addresses (user-space, aligned) never do.
|
||||
TEST(StagedTextureStoreTest, HandleKeysAndTwinAddressKeysCannotCollide) {
|
||||
|
||||
@@ -238,6 +238,9 @@ namespace MobileGL::MG_Util::PipeStats {
|
||||
"shader-image-emissions", "client-tex-upload-emissions", "tex-remint-pulls",
|
||||
"resident-subdata-emissions",
|
||||
"residual-pulls", "server-verb-boundaries", "wire-records",
|
||||
"wire-indirect-native-draws", "wire-indirect-cpu-expansions", "wire-indirect-barriers",
|
||||
"wire-host-waits", "wire-host-waits-indirect", "wire-host-wait-us",
|
||||
"wire-indirect-native-dispatches",
|
||||
#endif
|
||||
};
|
||||
const char* const kGateNames[kGateCount] = {
|
||||
@@ -690,6 +693,17 @@ namespace MobileGL::MG_Util::PipeStats {
|
||||
line += " wlivepk=" + std::to_string(Read(g_gauges[static_cast<Uint32>(Gauge::WireStoresPeak)]));
|
||||
line += " wdefpk=" + std::to_string(Read(g_gauges[static_cast<Uint32>(Gauge::WireDeferredBytesPeak)]));
|
||||
line += " wdefsync=" + std::to_string(Read(g_gauges[static_cast<Uint32>(Gauge::WireDeferredSyncs)]));
|
||||
// P8-D: the Magma wire arm's indirect draws and its host-access waits, windowed like the
|
||||
// other CallClass fields (per window, not per frame: the create fixtures hold one frame).
|
||||
line += "] windr[wind=" +
|
||||
std::to_string(calls[static_cast<Uint32>(CallClass::WireIndirectNativeDraws)]);
|
||||
line += " wixp=" + std::to_string(calls[static_cast<Uint32>(CallClass::WireIndirectCpuExpansions)]);
|
||||
line += " wibar=" + std::to_string(calls[static_cast<Uint32>(CallClass::WireIndirectBarriers)]);
|
||||
line += " whw=" + std::to_string(calls[static_cast<Uint32>(CallClass::WireHostWaits)]);
|
||||
line += " whwi=" + std::to_string(calls[static_cast<Uint32>(CallClass::WireHostWaitsIndirect)]);
|
||||
line += " whwus=" + std::to_string(calls[static_cast<Uint32>(CallClass::WireHostWaitMicros)]);
|
||||
// P8-SV: the indirect dispatches, on the same bracket (their barriers are in `wibar`).
|
||||
line += " wdsp=" + std::to_string(calls[static_cast<Uint32>(CallClass::WireIndirectNativeDispatches)]);
|
||||
#endif
|
||||
line += "] gates[";
|
||||
for (Uint32 i = 0; i < kGateCount; ++i) {
|
||||
|
||||
@@ -270,6 +270,23 @@ namespace MobileGL::MG_Util::PipeStats {
|
||||
// that goes with it (FormatWindowLine prints the run total instead when the window holds
|
||||
// no Present).
|
||||
WireRecords,
|
||||
// P8-D: the Magma wire arm's indirect draws, on the server (`windr[...]` on the line).
|
||||
// `wind` - indirect draw calls issued as vkCmdDraw*Indirect[Count] from the wire store.
|
||||
// `wixp` - indirect draw calls whose words were read on the CPU instead (the count word,
|
||||
// or every command, through ReadWireBuffer).
|
||||
// `wibar` - the INDIRECT_COMMAND_READ barriers recorded for a store marked GPU-written.
|
||||
// `whw` / `whwus` - WaitForWireBufferHostAccess calls that actually waited, and their
|
||||
// microseconds, from any caller; `whwi` - the subset an indirect read caused.
|
||||
WireIndirectNativeDraws,
|
||||
WireIndirectCpuExpansions,
|
||||
WireIndirectBarriers,
|
||||
WireHostWaits,
|
||||
WireHostWaitsIndirect,
|
||||
WireHostWaitMicros,
|
||||
// P8-SV: `wdsp` - glDispatchComputeIndirect calls issued as vkCmdDispatchIndirect from the
|
||||
// wire store (VulkanRenderer::DispatchWireComputeIndirect). Their barriers count in `wibar`
|
||||
// with the draws': one barrier per shader write, whichever indirect read consumes it.
|
||||
WireIndirectNativeDispatches,
|
||||
#endif
|
||||
Count
|
||||
};
|
||||
|
||||
@@ -1,27 +1,31 @@
|
||||
# 当前阶段:P8 进行中(2026-09-29 起)
|
||||
# 当前阶段:P8 已收官(2026-09-30);下一阶段 P13
|
||||
|
||||
> **更新 2026-09-29**。这一页只有摘要;计划与裁定在 [`notes/p8/PLAN-P8.md`](notes/p8/PLAN-P8.md)、[`notes/p8/INTEGRATOR-DECISIONS-P8.md`](notes/p8/INTEGRATOR-DECISIONS-P8.md)。上一阶段 P11 同日收官,见 [`notes/p11/README.md`](notes/p11/README.md)。
|
||||
> **更新 2026-09-30**。这一页只有摘要;计划与裁定在 [`notes/p8/PLAN-P8.md`](notes/p8/PLAN-P8.md)、[`notes/p8/INTEGRATOR-DECISIONS-P8.md`](notes/p8/INTEGRATOR-DECISIONS-P8.md)。上一阶段 P11 于 09-29 收官,见 [`notes/p11/README.md`](notes/p11/README.md)。
|
||||
|
||||
## 目标
|
||||
|
||||
补齐 server 侧仿真缺口(Espryt 生成 mip、Espryt 暂存影子与 GPU 写、Magma wire indirect、CopyImage),并把 monolith 用例登记到 split 各臂;为 P13 删掉旧的「后端直接读前端」路径扫清前置。原范围已重定界(划掉保留在 [`notes/p8/README.md`](notes/p8/README.md))。
|
||||
补齐 server 侧仿真缺口(Espryt 生成 mip、Espryt 暂存影子与 GPU 写、Magma wire indirect、驱动拒读),并把 monolith 用例登记到 split 各臂;为 P13 删掉旧的「后端直接读前端」路径扫清前置。原范围已重定界(划掉保留在 [`notes/p8/README.md`](notes/p8/README.md))。
|
||||
|
||||
## 完成情况
|
||||
|
||||
| 项 | 状态 |
|
||||
|---|---|
|
||||
| 只读核查与重定界 | ✅ 原 10 项里 6 项已完成、直接关闭(ID-P8-1) |
|
||||
| P8-0 普查(设备 + 主机) | 进行中 |
|
||||
| A 覆盖对齐 | 进行中 |
|
||||
| B Espryt 生成 mip | 进行中 |
|
||||
| C Espryt 暂存影子与 GPU 写 | 进行中 |
|
||||
| D Magma wire 原生 indirect | 进行中 |
|
||||
| E CopyImage 在 server store 上 | 进行中 |
|
||||
| F 死闩清理与重分类 | 进行中 |
|
||||
| G 大 blob 分片 | 等 P8-0 的测量 |
|
||||
| P8-0 普查(设备 + 主机) | ✅ 真实内容只 Magma wire indirect 命中;G 不做;create-indirect 门在多帧 trace 上成立(ID-P8-5) |
|
||||
| A 覆盖对齐 | ✅ 246 例登上 split / spawn / tcp,`split_coverage.py` 进门(ID-P8-7) |
|
||||
| B Espryt 生成 mip | ✅(ID-P8-8) |
|
||||
| C Espryt 暂存影子与 GPU 写 | ✅(ID-P8-9) |
|
||||
| D Magma wire 原生 indirect | ✅ create-indirect 每次整 GPU 等待 321 → 0(ID-P8-10) |
|
||||
| E 驱动拒读 / CopyImage | ✅(ID-P8-11) |
|
||||
| F 死闩清理与重分类 | ✅(ID-P8-6) |
|
||||
| G 大 blob 分片 | 不做(ID-P8-5) |
|
||||
| 第一波集成头 `39cd8fb7` | ✅ 整套门全绿,G1 不变(ID-P8-12) |
|
||||
| 第二波 SE / SV(split 余项) | ✅(ID-P8-15、-16) |
|
||||
| 第二波 MD + MF(Create 在 Adreno 上) | ✅ dev `f973008c` + feat 镜像:create-instancing × Espryt × monolith 0.870 → 0.99998;create-indirect 坏在 fixture(ID-P8-14) |
|
||||
| 出口 | ✅ 候选头 `49430538` 整套门全绿;设备矩阵无一格变差;P12 跨机门复跑一致(ID-P8-18、-19) |
|
||||
|
||||
## 下一步
|
||||
|
||||
第一波七包并行(ID-P8-4);逐包集成进 `p8/main` 并跑整套门。
|
||||
**P13**:删掉旧的「后端直接读前端」路径,monolith 换到 P8 已修好的记录臂(P8 留下的 9 条 monolith 缺陷随之消失,`DEBTS.md`)。开工前先做只读核查。
|
||||
|
||||
**待用户决策**:[`DEBTS.md`](notes/DEBTS.md) 六项「需裁定」(CI 触发条件、`TCP_USER_TIMEOUT`、HyperOS 下 FCL 保活、Mali 复测、TLS、`IDLE_EXIT_S`)。
|
||||
|
||||
@@ -50,3 +50,4 @@
|
||||
| 16 | P12 | 审查后真机复测:Espryt SSIM 1.0;Magma 1.0 / 0.999999511;P12 定向 CTest 46/46;纹理上传回包等待 1→0(主机机制门,真机墙钟待测);**P12 已收官(09-29)**:跨机 TCP 门 (b) 通过(rd12 ssim 0.999883、稳态 17–22 fps);FCL 门 (a) 通过(Minecraft 上屏到 render server 窗口,杀 server 后 33–54 ms 闩住 device-lost) | [`notes/p12`](notes/p12/README.md) |
|
||||
| 17 | 五臂传输测量(2026-09-28,非阶段) | inproc/shm 重负载比 monolith 快 ~1/3;tcp localhost 瓶颈是 credit=1 + 唤醒税(SPIN_US=2000 → 2.9×);跨主机 hang 实为主机 xray TUN 代理造成;直连 Wi-Fi 稳态 rd12 17–22 fps、openra 105–133 fps | [`notes/perf-five-arm-20260928`](notes/perf-five-arm-20260928/README.md) |
|
||||
| 18 | P11 | 同机零拷贝(T0)MC 26.3 峰值内存 Espryt −41–42%、Magma −18–26%,ssim / 帧时 / CPU 不变;外部 client 走共享内存 rd12 Espryt 约 119 fps(TCP 40–53);split T2 相对单进程采纳 p99 Espryt +37–42%、Magma 约 2.5×。未量:M2 后 split server 上纹理无 GPU 写时 Espryt 自己按存储阈值取舍精确写入框,非 ring 路径可能多发几个小框 | [`notes/p11`](notes/p11/README.md) |
|
||||
| 19 | P8 | 真实内容只 Magma wire indirect 命中(MC 26.3 × Magma inproc 1,300 万 draw CPU 展开)→ 原生后 create-indirect 每次整 GPU 等待 321 → 0;红米 create-instancing × Espryt × monolith 0.870 → 0.99998(Adreno 丢排队环形拷贝,dev + feat 两条阶梯);最大 program archive 355 KB = arena/4 的 4.2 %(不分片);出口设备矩阵 77 格 / 臂无一变差 | [`notes/p8`](notes/p8/README.md) |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 路线图(索引)
|
||||
|
||||
> **2026-09-29**:P0 到 P7、P12、P9、P10、**P11** 已完成——拆分路线走完。P11:同机大缓冲零拷贝(T0,默认开、用不了静默退回共享内存;MC 26.3 峰值内存 Espryt −41 %、Magma −18–26 %),同机其他 app 启动的 GL 程序(Termux 类)经 `app_process` helper 与令牌 broker 走共享内存,连接按 nonce 配对;契约 `MG_Remote/CONTRACT-P11.md`,G1 仅 Magma 空 uniform 修复 +224 字节 `.text`。当前阶段 **P8**(09-29 起,重定界:~~仿真路径下放与协议广度~~ → 补齐 server 侧仿真缺口与 split 覆盖,[`PLAN-P8.md`](notes/p8/PLAN-P8.md)),之后 P13。每个阶段的计划、验收结果、实测与报告在 `notes/<阶段>/`(点阶段名进入)。
|
||||
> **2026-09-30**:P0 到 P7、P12、P9、P10、P11、**P8** 已完成——拆分路线走完,单进程路线只剩 P13。P8(重定界):server 侧仿真缺口补齐(Espryt 生成 mip、暂存副本与 GPU 写、驱动拒读;Magma wire 原生 indirect),246 个 monolith 用例登上 split 各臂并由覆盖门守住;红米上 Create 画错在 dev 与 feat 两条 flush 阶梯修好;契约 `MG_Remote/CONTRACT-P8.md`,G1 整阶段符号不变。下一阶段 **P13**(删掉旧的「后端直接读前端」路径;P8 已把 monolith 要换到的记录臂修好,9 条 monolith 缺陷随之消失)。每个阶段的计划、验收结果、实测与报告在 `notes/<阶段>/`(点阶段名进入)。
|
||||
|
||||
## 目标
|
||||
|
||||
@@ -8,7 +8,7 @@ client(跑应用的一方)与 server(跑驱动的一方)可以在**不
|
||||
|
||||
## 两条路线
|
||||
|
||||
- **单进程路线**:先把接口建起来,让单进程版本也受益(后端拥有自己的状态、可以挪到渲染线程)。P0 → P0.5 → P1 → P2 → P3a → P4a → P3b/P4b → P7 → P8 → P13。
|
||||
- **单进程路线**:先把接口建起来,让单进程版本也受益(后端拥有自己的状态、可以挪到渲染线程)。P0 → P0.5 → P1 → P2 → P3a → P4a → P3b/P4b → P7 → **P8** → P13。
|
||||
- **拆分路线**:在接口之上逐步拆开前后端。P5 → P5b → P5c → P5d → P5e → P5f → P6 → P6.5 → Ph → P12 → P9 → P10 → **P11**(走完)。
|
||||
|
||||
## 阶段一览
|
||||
@@ -33,7 +33,7 @@ client(跑应用的一方)与 server(跑驱动的一方)可以在**不
|
||||
| [P3b / P4b](notes/p34b/README.md) | GLES 后端的深化与收尾 | 大部分 ✅,余项并行 |
|
||||
| [P7](notes/p7/README.md) | Vulkan 后端完整迁移;真机画面检查 36/36 通过 | ✅ 09-23 |
|
||||
| [**P12**](notes/p12/README.md) | **server 自己开窗口上屏,client 不需要窗口** | ✅ 09-29:出口门 B(跨机 TCP)✅ 09-28、A(FCL + 杀 server)✅ 09-29;契约 `MG_Remote/CONTRACT-P12.md`;G1 成立;余项进 [`DEBTS.md`](notes/DEBTS.md) |
|
||||
| [**P8**](notes/p8/README.md) | ~~把剩余的仿真路径挪到正确的一侧,补齐协议~~ → **补齐 server 侧仿真缺口与 split 覆盖**:Espryt 生成 mip(RGB16F / RGB32F、存储窗口)、Espryt 暂存影子与 GPU 写对账、Magma wire 原生 indirect、CopyImage 在 server store 上处理、monolith 用例登记到 split 各臂;原范围 6 项前序阶段已完成([`PLAN-P8.md`](notes/p8/PLAN-P8.md)) | 进行中(09-29 起) |
|
||||
| [**P8**](notes/p8/README.md) | ~~把剩余的仿真路径挪到正确的一侧,补齐协议~~ → **补齐 server 侧仿真缺口与 split 覆盖** | ✅ 09-30:重定界(原 10 项里 6 项前序已完成);Espryt 生成 mip / 暂存副本与 GPU 写 / 驱动拒读、Magma wire 原生 indirect 与 dispatch;246 例登上 split 三臂(`split_coverage.py`);Create 在 Adreno 上的丢拷贝修到 dev 与 feat;契约 `MG_Remote/CONTRACT-P8.md`;余项进 [`DEBTS.md`](notes/DEBTS.md) |
|
||||
| [**P9**](notes/p9/README.md) | **反向通道:回读、日志、重铸不再同步等待 client** | ✅ 09-29:PACK-PBO 回读 fire-and-forget(两后端)、日志分级转发、重铸无拉取(`OnLog` / `OnTexturePullRequest` 删,回调 9 → 7),F1 / F2;契约 `MG_Remote/CONTRACT-P9.md`;G1 成立;事件量批处理无实测需求不做;余项进 [`DEBTS.md`](notes/DEBTS.md) |
|
||||
| [**P10**](notes/p10/README.md) | **同步对象、查询与帧节奏** | ✅ 09-29:fence 轮询由 server 报告本地作答(`kEventFenceSignaled`、`MOBILEGL_IPC_POLL_ESCALATE`;主机 Magma·tcp −37%,Adreno 830 上两后端 0 次往返);`SetSwapInterval` 转发、class C 清零;query / XFB / AsyncCompile 登记 split 各臂;credit 1/2/3 设备 loopback 在噪声内;契约 `MG_Remote/CONTRACT-P10.md`;G1 成立;余项进 [`DEBTS.md`](notes/DEBTS.md) |
|
||||
| [**P11**](notes/p11/README.md) | **同机大缓冲零拷贝共享** | ✅ 09-29:T0 零拷贝导入(两后端,默认开,自测不过或 Stream 上静默退回 T2);同机外部 client 经 helper + 令牌 broker 走共享内存(B1);连接按 `PairBind` nonce 配对(修订 5);采纳档位在握手时定;契约 `MG_Remote/CONTRACT-P11.md`;余项进 [`DEBTS.md`](notes/DEBTS.md) |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 仍开放的债务(跨阶段)
|
||||
|
||||
> 路线图只列"有债务、看这里"。每条写明去向;已关闭的历史债与当时的完整债务表见 [`p5b/README.md`](p5b/README.md) 末节。开放问题另见 [`OPEN-QUESTIONS.md`](OPEN-QUESTIONS.md)。更新:2026-09-29(P11 收官;按债务审查重排)。去向「需裁定」= 等用户定;「可进行」= 随时可开的小修,不依赖别的阶段。
|
||||
> 路线图只列"有债务、看这里"。每条写明去向;已关闭的历史债与当时的完整债务表见 [`p5b/README.md`](p5b/README.md) 末节。开放问题另见 [`OPEN-QUESTIONS.md`](OPEN-QUESTIONS.md)。更新:2026-09-30(P8 第二波;按债务审查重排)。去向「需裁定」= 等用户定;「可进行」= 随时可开的小修,不依赖别的阶段。
|
||||
|
||||
| 债务 | 去向 |
|
||||
|---|---|
|
||||
@@ -15,14 +15,25 @@
|
||||
| P11 转出:client 与 server 共用日志前缀时,client 以 `"w"` 打开 `<base>.server.log` 写转发来的 server 日志(`MobileGL/MG_Util/Debug/Log.cpp:89`),截断 server 自己的文件;同机两个进程用同一前缀时同样互相截断 | 可进行(小修) |
|
||||
| P11 转出(B1):会话位被慢启动程序占着时,第二个 client 若 2 s 内发 Hello 得具名 `Refuse{Busy}`,更慢的只见发送失败(那条路径不读待发的拒绝);已写进契约 | 可进行(小修) |
|
||||
| P11 转出(B1):会话启动失败后 client 还多报一个误导性的 `Fatal{CapsBeforeFirstSnapshot}`(`CapsMirror.cpp:247`,早于 B1,helper 用户每次被拒都会看到) | 可进行(小修) |
|
||||
| P11 转出(B2):handle 臂的 CPU 读者(indirect、primitive restart、multi-draw rebase → `SplitHostBytes`)读采纳 / T0 映射前不先落完排队的常驻写;单进程大概也要同一条「读前先落」规则 | 可进行(小修;单进程那半 P8 开工时一并看) |
|
||||
| P11 转出(B2):handle 臂的 CPU 读者读采纳 / T0 映射前先落排队常驻写——split 半已由 P8-C 实现(`SplitHostBytesForCpuRead` 的 T0 臂:落写 + `glFinish`,ID-P8-9),但主机无 T0、未能证红 | 需设备验证(红米 Android 集成测试 + static-peek) |
|
||||
| P11 转出(B2):server 准了 T0 而 client 选了 T2 时,每个存储的 `map_persistent` 等 2 s 再具名拒绝(产品里 grant 与 caps 一致,只在变异下见过) | 可进行(小修:每会话一个「client 不要 T0」提示) |
|
||||
| P9 转出:Espryt 重铸保留路径上 framebuffer clear 后 `imageLoad` 偶读旧值(主机 3/30,加 barrier 后 0/30;`TextureRemintPullScenario` case C 暂钉 barrier),疑 llvmpipe(ID-P9-11);P11 合并 dev 后 push 单进程臂上也见过一次,`ImageBindableRemintScenario` 同样钉 barrier(ID-P11-6) | 可进行(在红米上不加 barrier 归因) |
|
||||
| P8 转出(D):应用省略 `glMemoryBarrier` 时,两臂在计算写与顶点着色器读之间都没有依赖(GL 未定义,但真实应用依赖它);D 的每轮屏障在真机上的开销未测;create-indirect 验证不了这两件事(ID-P8-14),需要一个「计算写命令、无应用屏障、不重写」的 fixture | 待归因(需新 fixture) |
|
||||
| P8 转出(E):driver-written 标按整张纹理打(`GenerateMipmap` 也打),驱动拒读时连基级也具名拒绝,偏保守;跨格式拷贝 store 不跟随;拒绝仍是会话 Fatal(要改回包状态才能答 `GL_INVALID_OPERATION`) | 小修(按 level 打标);其余按需 |
|
||||
| P8 转出(B):`PipeCalls.def:260` `GenerateMipmap` 仍是 `kWaitApplied`,裁定 14 的理由(CPU 滤波碰 client 影子)已不成立,可改 `kWaitNone` | 性能工作(协议行为变更,需单独裁定) |
|
||||
| P8 转出(C):server SSBO 标记过近似(窗口内每个绑定的 SSBO 都标);一个留在 SSBO 绑定上又当 restart EBO 用的 buffer 每次 draw 都回读 | 性能工作 |
|
||||
| P8 转出(monolith,ID-P8-13):9 条 monolith 缺陷真实内容 0 命中,不在 dev 上修——Espryt `*IndirectCount` / 原生 indirect `gl_BaseVertex` / fp64 收窄读未同步影子;Magma `glMultiDrawArraysIndirectCount` CPU 臂同病;Magma 录制中途 `SyncGpuWrites` → SIGSEGV;Espryt RGB16F / RGB32F CPU 滤波读陈旧影子、R11F / 深度链无视 BASE / MAX;Magma 无 BLIT 颜色格式缺着色器 mip 臂;Espryt 拷贝后 `glGetTexImage` 读拷贝前影子(证据见 `notes/p8/{B,C,D,E}.md`) | P13(monolith 换到已修好的记录臂) |
|
||||
| P8 转出(monolith,feat,ID-P8-14):feat 的 monolith 臂每次 indirect draw 在命令缓冲有 GPU 写时整 buffer 同步回读(`SyncClientSideVertexArraysForIndirectFetch`,`62bfe461`,dev 无);Magma 的 split 构建 monolith 深度 mip 不传 view 类型,无深度 `BLIT_DST` 的设备上 1D 深度链会拿到 2D view(推断,Release 下断言编译掉,SV) | P13(monolith 换臂) |
|
||||
| P8 转出(ID-P8-19):create-indirect × Magma × spawn 在红米上由 0.84 变为每次丢设备(该 fixture 的 indirect 命令本身是乱的;推断 D 原生化后乱命令直达 GPU,monolith 臂一直原生、基线上也偶发丢设备);坏命令能打挂 GPU 是 GL 未定义行为,robust buffer access 可兜住 | 待归因(fixture 重抓后复测) |
|
||||
| P8 转出(ID-P8-14):create-indirect fixture 在桌面上抓(SSBO 偏移对齐 16),Adreno 要求 64,任何臂任何后端都过不了;设备车道记为不适用 | 需要时在对齐 64 的设备上重抓 |
|
||||
| P8 转出(MD):dev 的 `RingAllocateSlow` 在出错的上下文上无上限地排水(设备上挂在 `glFinish`) | 小修(dev) |
|
||||
| P8 转出:`LogForwardChannel.APeerThatStopsReadingCostsWarnLinesNotTheCallersTime` 在负载下超时(两次),单跑必过 | 小修(放宽时限或隔离) |
|
||||
| P8 转出(SV):`gen_pipe_dirty_surface.py` 扫描集成测试源,测试成员名与 GLContext 成员同名(如 `m_parameters`)会静默弄坏它的自检;`.Mip3DValidation.` 在没装校验层的车道上是失败不是跳过 | 小修 / CI 记录 |
|
||||
| P8 转出(MF):两条 flush 阶梯附近几处注释仍写旧的冻结 / 钉住提交(`5cb826b0`、`3e298c9a`) | 文档小修 |
|
||||
| P8-0 转出:设备上基线就有的 SSIM < 0.99——1.21.11-main-menu(Espryt 0.890、Magma 0.165)、derivative-main(Espryt 0.851);两臂都有 | 待归因 |
|
||||
| P12 未做:D8 窗口种类白名单——X11 / MetalLayer / Win32Hwnd / None 仍被接受(`SurfaceOpCodec.cpp:138-141`),`HandleFromToken` 把 token 强转为指针(`ServerLoop.cpp:1228`,经 `UnpackWindowHandle`;下游是否交给 EGL 未追到底) | 可进行(Ph 类小修) |
|
||||
| P12 未做:修后的横屏 server 窗口未重测 | 可进行(红米只读检查) |
|
||||
| P11 转出(M2,给 dev):dev 的 `DirectVulkan.SplitRecording.` 车道没有 `RESOURCE_LOCK`(dev 上 `MG_IntegrationTest/CMakeLists.txt` 第 609 行)、其用例读字面日志路径——`-j` 下可能互相截断;P11 线的副本已修。另:dev 的 `853c5f12` / `7030d307` 与 B2 的 `7784d6bb` 修同一处 | 下次向 dev 回流时带上;那两处取一份 |
|
||||
| 未接入内容分块的 record 类型:program archive 与 `draw_vbo` range 尾 | P6.5 sl 与 P8 共用的分片(开放问题 11) |
|
||||
| 仿真路径的具名拒绝:RGB CPU mip 等(class C 已于 P10 清零;multi-draw client indices 已不再拒绝——client 转成自有 buffer,`EmitTables.cpp:459`,`RefuseDrawByName` 只剩 NO_CONTEXT / INDEX_TYPE / INDEX_OFFSET / CLIENT_COMMANDS / UNBOUND_PARAMETER) | P8(开工时复核) |
|
||||
| P11 转出(M2,给 dev):dev 的 `DirectVulkan.SplitRecording.` 车道没有 `RESOURCE_LOCK`、其用例读字面日志路径——`-j` 下可能互相截断;P11 线的副本已修(Magma 空 uniform 的重复修复已在 ID-P8-17 合成一条) | 下次向 dev 回流时带上 |
|
||||
| P11 转出(M2):超过 stage 分块预算的大层按分片发出,没有写入框覆盖的分片仍带整框(server 要靠它拼层图),会把影子盖到 GPU 写过的地方;修法要一个两个 server 都跳过的「只定位」区域写法,控制协议修订 +1(split 专属,早于 P11) | 小包或 P8 |
|
||||
| P11 转出(M2):上传仍有两种有损形状,各记一次日志——一层的精确写入框超过 4096 个时按存储的矩形表覆盖发出;applier 一个条目累计超过 4096 个区域时并成并集框。纹理带 GPU 写时两者都会把影子盖进空隙 | 小修,无触发报告 |
|
||||
| P10 转出(性能):设备上 tcp loopback 的 rd12 每帧 19.4 ms 中 ~11.2 ms 是生产者在 stream 传输里的停车(发送 + 环 / stage / ack 等待),credit 等待只有 ~0.2 ms(`notes/p10/C-MEASUREMENTS.md` §2,ID-P10-13) | 路线图推完后的性能工作 |
|
||||
|
||||
@@ -12,13 +12,13 @@ P0 已回答的不再列出(spike A 的域、spike B 的分档、`posix_spawn`
|
||||
6. **具名 UBO host payload 的形状(D-B8)。** Magma 在 26.3 世界每帧重打包 331 KB 具名 UBO 字节,Espryt 为 0。要么冻结第二变长尾形状,要么走备选(Magma 直接描述符绑定常驻 `VkBuffer` range,独立 `dev` PR)。P7。
|
||||
7. **`MG_Util` 的切割缝。** server 需要 SPIRV-Cross / ESSL 转译缓存 / 格式处理器 / POST 探针,client 需要 glslang 与反射层;`MG_Util` 内部是否有干净的 Transpile-vs-Reflect 缝未审计。P7。
|
||||
8. **一份反射归档能否服务三个消费者。** Espryt 那一半已答(P4a):能且不需要复制。Magma 的第一个消费者已由 P5f fm 答:`MagmaProgramSource` 全部从 wire `ProgramArchive` 取,无前端对象、无复制。第二个(storage block 表)今天是**否**且变差了:split 下 `MagmaProgramSource::EnsureStorageBlocks` **每 draw** 重跑 SPIRV-Reflect(monolith 臂 `DirectVulkan.cpp:177-200` 至少有持久缓存);答案是往 `LinkArtifacts` 加有序 `storageBlocks`(数据已在 `blockReflection` 里),两个消费者都改读它。**已答(P7 wave 2-C,`dce9953d..cf7ca59f`)**:`storageBlocks` 入归档、两个消费者改读、每 draw SPIRV-Reflect 4→0;`g_programResourceCaches` 的 monolith 半边归 P13(G1)。
|
||||
9. **viewport-array 回放能否塞进一次 `draw_vbo`**:各遍之间观察到的状态是否与今天一致未验证。P8。
|
||||
9. **viewport-array 回放能否塞进一次 `draw_vbo`**:**已答(2026-09-30,ID-P8-1)**:能——server 在一次 draw 内按状态分组逐遍回放(`DirectGLES.cpp:8421-8465`),`ViewportArrayScenario` 在 split 各臂绿。
|
||||
10. **`ResidentSubData` 的不对称。** 已答一半(2026-09-22 核):**Magma 的实现已补**(`VkBufferManager.cpp:123` monolith 表、`:148` wire 表,`fff9d639f`)。**仍未答:`kCapResidentSubData` 从未被 server 发布**——`MG_Backend/Init.cpp:192-219` 是全树唯一的 `SetCapabilityBits` 生产调用点,只 OR 了 XFB、三个 query 位与 run-ahead 位;于是 `PipeFill.cpp:848` 在 split 下恒 false,**两个后端在拆分模式下都退回 `BufferObject.cpp:711-716` 的就地 memcpy**,Magma 的实现在 split 里是死代码。**已答(P7 wave 2-C,ID-P7-20)**:`InitServerRoleCommon` 按 server 自己的 wire 资源表发布 `kCapResidentSubData`,镜像收到即验收;白盒「发出的是 opcode 49」在 P11 采纳档落地前不可达(§5.4 债)。
|
||||
11. **`SEG_STAGE` 的上限。** 内容侧已答(2026-09-20):**分块已实现**——buffer 范围走查(`1e7c372e`)与纹理整宽 slab(`9469d48e`)按 `MGPipeStageChunkBytes()`(默认 32 MiB 的 1/4 = 8 MiB)切成多条 `resource_subdata`,所以单次 128 MiB 上传不再需要显式 `MOBILEGL_IPC_STAGE_MB=256`;单片仍超 arena 或该 record 类型未接入分片时仍是 `Fatal{RingOverrun, "SEG_STAGE"}` 兜底。**仍未答(2026-09-22 收窄)**:a6 §6 实测没走查的只剩 **program archive**(唯一无界 blob)与 **`draw_vbo` 的 `NumDraws*12` range 尾**;宿主索引 span 无 producer(划掉),`set_global_constants` 有走查。二者的分片是 P6.5 sl 与 P8 共用的同一件事,stream 发送窗口对着它们定尺。MC in-world / Create 的占用分布仍未量(门 8 已给出两条负载的字节/帧与记录/帧,逐 blob 分布只在 integration 车道取到)。
|
||||
11. **`SEG_STAGE` 的上限。** 内容侧已答(2026-09-20):**分块已实现**——buffer 范围走查(`1e7c372e`)与纹理整宽 slab(`9469d48e`)按 `MGPipeStageChunkBytes()`(默认 32 MiB 的 1/4 = 8 MiB)切成多条 `resource_subdata`,所以单次 128 MiB 上传不再需要显式 `MOBILEGL_IPC_STAGE_MB=256`;单片仍超 arena 或该 record 类型未接入分片时仍是 `Fatal{RingOverrun, "SEG_STAGE"}` 兜底。**仍未答(2026-09-22 收窄)**:a6 §6 实测没走查的只剩 **program archive**(唯一无界 blob)与 **`draw_vbo` 的 `NumDraws*12` range 尾**;宿主索引 span 无 producer(划掉),`set_global_constants` 有走查。二者的分片是 P6.5 sl 与 P8 共用的同一件事,stream 发送窗口对着它们定尺。MC in-world / Create 的占用分布仍未量(门 8 已给出两条负载的字节/帧与记录/帧,逐 blob 分布只在 integration 车道取到)。 **P8-0 实测(2026-09-30,ID-P8-5)**:最大 program archive 354,846 B、最大 `draw_vbo` 记录 1,936 B,都远低于 arena/4;**不做分片,关闭**。
|
||||
12. **P13 之后 split-only 渲染 bug 的 server 侧第二意见。** verify 构建 + recorder 只覆盖推送内容,不覆盖后端对它的解释。
|
||||
13. **烘焙后的内部 shader 能否在没有活 `ProgramObject` 的情况下表达 uniform location 与 UBO 布局。** 颜色 blit 已答(P5f fv:`WireColorBlit.{vert,frag}` 用 push constant,`WireColorBlitSpirv.h` 签进树);窄化到深度 mip 程序(今天在 split 下被编译掉、其 split 路径是具名 Fatal)与直通 TCS(`ProgramFactory.cpp:4060-4262`,第三个未盘点的内部 shader 生成器)。**已答(P7 wave 2-B / B2)**:深度 mip 烘焙 (A)(D)(`WireDepthMipmap.*`,push constant,`MOBILEGL_BAKED_INTERNAL_SHADERS` 新鲜度门表驱动)与 (B′)(disaggregated 构建的 monolith 臂改用烘焙模块)落地;multisample resolve 第三套烘焙 shader 随 B2;直通 TCS 仍未盘点。
|
||||
14. **推送模型改变哪些按拉取模式调过的缓存命中率。** 幸存者容量在 P13 重调。一条线索:设备上 26.3 Espryt 的 `sve` ≈ draw 数(每 draw 重发一次 sampler-view 集合),桌面只有 ~0.07/draw;列入 P3b/P4b 优化清单。
|
||||
15. **monolith 的 `*IndirectCount` 不调 `SyncGpuWrites()` 是不是潜在缺口。** 独立 `dev` 问题,拆分不得借机顺手修。
|
||||
15. **monolith 的 `*IndirectCount` 不调 `SyncGpuWrites()` 是不是潜在缺口。** 独立 `dev` 问题,拆分不得借机顺手修。**已答(2026-09-30):是**——P8-C / P8-D 主机 red-once 证实(Espryt `*IndirectCount`、Magma `glMultiDrawArraysIndirectCount` 读到 0);split 半已修(ID-P8-9),monolith 半在 P8 第二波的 dev 包里修(ID-P8-3)。
|
||||
16. **索引宿主镜像的实际内存占用。** MC / Sodium / Iris 语料里 element-array buffer 总量未测;若显著超 64 MiB,退化路径的频率与代价必须实测。P8。
|
||||
17. **`create-indirect` fixture 在 Adreno 830 上的失败**是 `dev@81b17c0b` 就有的(基线 APK 复现),不是本分支造成;`rd12` + Magma 在两台 Adreno 830 上的 `scudo::reportMapError` 崩溃同样是 `dev` 侧。两者排除在设备 A/B 之外、留在桌面语料里;P8 要在 `create-indirect` 上断言 `roundtrips-per-frame == 0`,所以 `dev` 的修复在别人的关键路径上。
|
||||
18. **split 两侧的负载平衡。** P5e 解锁出来的新问题:VD32(~3550 draws/帧)下 apply 线程 **11-12 ms**、client **15.7 ms**,**client 是瓶颈且打满 ~94%**。把工作从 client 挪到 apply 会直接降瓶颈——这在 lockstep 下毫无意义(两侧串行相加),**run-ahead 才使它成为一个杠杆**。供选:编码侧的 emitter、tracker 走查、持久映射的脏页追踪(`change_protection` 在侧写里占 1.3%)。需先重新侧写:等待消失后尾部各项的分母都变了。排在 P5e 之后;无主,2026-09-22 建议挂在路线图推完后的优化阶段,P6.5 的 2×2 矩阵车道顺带重新侧写
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
# P8-A:覆盖对齐与归一化覆盖门(ID-P8-2)
|
||||
|
||||
> 2026-09-29,分支 `p8/a`(基线 `8d3e2317`)。brief `~/w7/notes/p8/BRIEF-A.md`;普查原始输出 `~/w7/notes/p8/evidence-a/`(树外)。
|
||||
|
||||
## 1. 结论
|
||||
|
||||
- 门改为「归一化后 monolith ⊆ 门控 split ∪ 豁免表」,由 `scripts/ci/split_coverage.py` 强制;`test.yml` 在 parity 步之后跑它(含 `--self-test`)。
|
||||
- 当前读数:DirectGLES monolith 669 例 = 门控 split 581 + 豁免 88,缺 0;DirectVulkan 669 = 门控 202 + 仅信息层 435 + 豁免 32,缺 0。
|
||||
- 按 gtest 名只在 monolith 的 DirectGLES 用例是 335(审计的 396 按 TEST_F 计,含它自己列出的约 45 个已带尾登记在 split 的「命名假象」);去掉机制过滤器(`MobileGL/MG_IntegrationTest/CMakeLists.txt:796`)的 31 例后 304 例进普查。
|
||||
- 本包新登记:246 个 ambient 用例 × 三臂;5 条 server 旋钮车道共 21 例 × 三臂(tcp 各有自己的 supervisor);撤 `ClientSideIndices` 排除(d1 块三臂 + 5 个 multi-draw tier);GuiBatch 随 ambient 登记。
|
||||
- 审计 (c′) 的「进程内 peek」类实测为 0:P4aFinalFix / P4aSeamAudit 在 spawn / tcp 上 white-box 读取自行降级,public-GL 半边照跑,三臂全绿,已登记。
|
||||
- DoublePrecision 12 例在同环境的 loopback tcp 上绿,已登记;`DEBTS.md` 的 fp64 行说的是 server 环境与 client 不同(`MOBILEGL_ADVERTISE_FP64`),本机没测到那一形。
|
||||
|
||||
## 2. 普查(304 例 × Split / Spawn / Tcp,armed 环境,每臂一个 junit)
|
||||
|
||||
| 结果 | 例数 | 处置 |
|
||||
|---|---|---|
|
||||
| 三臂通过(含 F1 的 19 个 split 专属例,monolith 上跳过) | 235 | 登记 231;MonolithAttachmentClear 3 豁免 mechanism;MultiDraw ClientSideIndices 1 在 d1 块撤排除 |
|
||||
| 三臂跳过,monolith 同样跳过(主机能力:ClipDistance 2、DualSourceBlend 2、IterationRP* 5、SsboDeclarationForm 2) | 11 | 登记(与 monolith 同形) |
|
||||
| 三臂跳过,缺旋钮(PointSizeDemotion 2、UnlocatedIoBlock 1、ViewportArray 负控 1) | 4 | ambient 登记 + §3 旋钮车道 |
|
||||
| 三臂跳过,属 Magma(Magma* 21、PrimitivesGeneratedNoXfb 8、F1 Magma 拒绝 / 着色器 mip 9、ImageLoadStoreSso 1、UnwrittenPosition 1) | 40 | 豁免 single-backend(`DirectGLES:` 限定) |
|
||||
| 三臂 `EmitSeq` 不动(AdvertisedLimits 8、SpirvShaderBinary 4、ProgramPipeline 1) | 13 | 豁免 no-records(`MobileGL/MG_IntegrationTest/Harness/ScenarioFixture.h:85-99`) |
|
||||
| inproc 绿,spawn / tcp 红 | 1 | 豁免 pending-fix(§6) |
|
||||
|
||||
同一批 304 例经 tier-2 回放在 Magma 三臂:只有 no-records 的 13 例红,外加 tcp 的 IterationRPProgram203(§6 已修)。
|
||||
|
||||
## 3. server 旋钮车道 (a′)
|
||||
|
||||
| 车道(尾) | 旋钮 | 例 | server 读点 | 旋钮只在 client 环境时的 tcp | 各自 supervisor |
|
||||
|---|---|---|---|---|---|
|
||||
| `PointSizeDemotion.` | `MOBILEGL_POINT_SIZE_DEMOTION=1` | 5 | `MobileGL/ConfigLoader.cpp:240` | 2 红(arming、capture) | 绿 |
|
||||
| `UnlocatedIoBlocks.` | `MOBILEGL_ESPRYT_UNLOCATED_IO_BLOCKS=1` | 3 | `MobileGL/ConfigLoader.cpp:239` | 1 红(arming) | 绿 |
|
||||
| `NoViewportArrayEmulation.` | `MOBILEGL_ESPRYT_FORCE_VIEWPORT_ARRAY_EMULATION=0` | 1 | `MobileGL/ConfigLoader.cpp:262` | 1 红 | 绿 |
|
||||
| `WidenedPacked16.` | `MOBILEGL_ESPRYT_WIDEN_PACKED16_STORAGE=1` | 3 | `MobileGL/ConfigLoader.cpp:264` | 绿(无 arming 例,走的是默认臂) | 绿 |
|
||||
| `ForcedDs.` | `MOBILEGL_ESPRYT_FORCE_DS_READBACK_EMULATION=1` | 9(tcp 另含 Matrix 14) | `MobileGL/ConfigLoader.cpp:249` | 绿(无 arming 例,走的是原生回读) | 绿 |
|
||||
|
||||
- 共享 fixture 不能带这些旋钮:会改掉所有 tcp 例(视口仿真关掉即 ViewportArray 正例红)。先例 `MobileGL/MG_IntegrationTest/CMakeLists.txt:2168` 只对三臂本来都设的开关成立。
|
||||
- supervisor 端口 = lane 端点端口 + `MOBILEGL_ITEST_TCP_KNOB_PORT_OFFSET`(默认 1000)+ 车道序号;fixture 名 `mobilegl-tcp-p8a-<lane>`;条目仍持 `RESOURCE_LOCK mobilegl-tcp`(parity / junit_tally 的 tcp 锁规则)。
|
||||
- 既有 `DirectGLES.Tcp.ForcedDs.DepthStencilReadbackMatrixScenario.*` 14 例原先旋钮只在 client 环境(server 跑原生回读);同名条目移到 `ForcedDs` supervisor,旧块只留 Split / Spawn(`MobileGL/MG_IntegrationTest/CMakeLists.txt:2652`)。
|
||||
- 5 个旋钮都是 Espryt 的,车道不上 DirectVulkan。
|
||||
|
||||
## 4. 豁免表 `scripts/data/split_coverage_exemptions.txt`
|
||||
|
||||
| 类 | DirectGLES | DirectVulkan | 内容 |
|
||||
|---|---|---|---|
|
||||
| mechanism | 34 | 32 | 机制过滤器 31;MonolithAttachmentClear 3(钉 push-monolith 臂,ID-107);DualBlock 1(Magma,需 `ROLE_SPLIT_STATE`) |
|
||||
| single-backend | 40 | 0 | §2 |
|
||||
| no-records | 13 | 0 | §2 |
|
||||
| inproc-peek | 0 | 0 | 类保留,现无成员 |
|
||||
| pending-fix | 1 | 0 | §6 |
|
||||
|
||||
脚本规则(都是 error):模式匹配不到 monolith 例;模式所指全部已在 split(过期行);pending-fix 不写包名或 `DEBTS.md`;single-backend 不加 `<Backend>:`;未知类、缺理由、重复行。
|
||||
|
||||
## 5. 门、red-once 与耗时
|
||||
|
||||
| 门 / 断言 | 变异 | 载体 | 观察到的红 |
|
||||
|---|---|---|---|
|
||||
| `split_coverage.py` 按名 | 从 `P8Coverage.cmake` 删 `GuiBatchScenario.*` 一行,重 cmake + ninja | `split_coverage.py build-split` | rc 1,`missing 9`,逐个点名 `DirectGLES.GuiBatchScenario.*` |
|
||||
| 过期行规则 | `elif needed == 0` → `elif False` | `--self-test` | rc 1,「a stale exemption reds: rc 0 (want 1)」 |
|
||||
| 旋钮 supervisor | 5 个 fixture 的 `ENVIRONMENT` 去掉旋钮,重 cmake | 三条车道的 `DirectGLES.Tcp.` 条目(15 例) | 红 4(§3 三车道的 arming / 负控);恢复后 15 绿 |
|
||||
| `ClientSideIndices` 守住 client 拼平 | `MobileGL/MG_Impl/Pipe/OwnedDrawInputs.h:51` 由清 `kDrawHasUserIndices` 改为置位 | `ctest -R ClientSideIndicesBatchMatchesUnrolledDraws` | Split / Spawn / Tcp 与 5 个 tier、Magma 各 split 臂共 14 例 abort:client `Fatal{ProtocolCorruption, "EncodeRecord.tailBytes"} got=0 expected=32`(`MobileGL/MG_Remote/Wire/PipeWireCodec.cpp:1108`);monolith 两后端绿 |
|
||||
|
||||
- 第 4 行不是 brief 预期的 `PipeApplier.cpp:975-978` 闩:client 已无产生 user-index span 的代码,只把第 51 行删掉(不清位)全绿;而 server 解码在进 sink 前对 `NumDraws != 1` 的 span 报 `ProtocolCorruption "DrawVbo.userIndices.shape"`(`MobileGL/MG_Remote/Wire/PipeWireCodec.cpp:623-624`,调用 `:2413`),所以 `CLIENT_INDICES` 闩对任何 peer 都不可达;`+INSTANCED` 闩(`MobileGL/MG_Remote/Server/PipeApplier.cpp:979`)仍可达。交 P8-F。
|
||||
- 车道耗时(本树,`-j 6`,七棵树同时在跑):
|
||||
|
||||
| 车道 | 前 | 后 |
|
||||
|---|---|---|
|
||||
| integration-split | 427 例 24 s | 700 例 68 s |
|
||||
| integration-spawn | 346 例 25 s | 614 例 66 s |
|
||||
| integration-tcp | 348 例 101 s | 626 例 248 s |
|
||||
| integration-magma-all-split / spawn / tcp(信息层) | — | 556 / 556 / 558 例,45 / 57 / 199 s |
|
||||
|
||||
- Magma 门控车道本包未加;新登记经 tier-2 回放自动进入 `integration-magma-all-*`(`MobileGL/MG_IntegrationTest/CMakeLists.txt:4952`)。
|
||||
|
||||
## 6. 发现
|
||||
|
||||
| 项 | 臂 / 后端 | 证据 | 去向 |
|
||||
|---|---|---|---|
|
||||
| `DepthStencilReadbackAttachmentShapeScenario.DefaultFramebufferDepthStencilFormatIsBlitCompatible`:默认 framebuffer 的深度 blit 出来是 0 | Espryt spawn + tcp(inproc 绿;Magma 三臂绿;带不带 FORCE_DS 都红) | 普查 junit;server 是 pbuffer 128×96,EGL config 要了 depth 24 / stencil 8(`MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp:16498`),根因未追到 | pending-fix;需集成方加 `DEBTS.md` 行(不属 B / C / D / E) |
|
||||
| tcp 共享 supervisor 没有 Vulkan ICD 与 iterationRP 修复开关(`MobileGL/MG_IntegrationTest/CMakeLists.txt:348-351` 只进 client 环境) | Magma tcp(tier 2 / tier 3) | `DirectVulkan.Tcp{,.Full}.IterationRPProgram203Scenario` 差 1 texel,Split / Spawn 绿 | 已修(测试接线):`TcpServer.Start` 带上 `MGL_ITEST_VULKAN_ENV` 中非 common 的项(`MobileGL/MG_IntegrationTest/CMakeLists.txt:2163-2169`);IterationRP 全部 78 条绿 |
|
||||
| `CLIENT_INDICES` server 闩不可达 | 两后端 | §5 | P8-F |
|
||||
| monolith 缺陷 | — | 本包未发现 | — |
|
||||
|
||||
## 7. 给集成方
|
||||
|
||||
- `P8Coverage.cmake` 的 include(`MobileGL/MG_IntegrationTest/CMakeLists.txt:4826-4829`)必须在 tier-2 回放与 `SplitLogPaths` 的 `configure_file`(`:5307`)之前;解冲突时不要移到它们下面。
|
||||
- `gate.sh` hygiene 可加:`python3 scripts/ci/split_coverage.py --self-test && python3 scripts/ci/split_coverage.py build-split`。
|
||||
- 其他包新登记 split 用例后,对应的 pending-fix / 缺口行会被脚本判为过期,需同提交删行。
|
||||
@@ -0,0 +1,97 @@
|
||||
# P8-B:Espryt `glGenerateMipmap` 在 split 下(B1 生成窗口、B2 RGB16F / RGB32F)
|
||||
|
||||
> 2026-09-29,分支 `p8/b`(基线 `8d3e2317`),代码提交 `8dac1fd8`。计划:[`PLAN-P8.md`](PLAN-P8.md) 包 B。
|
||||
|
||||
## 1. 结论
|
||||
|
||||
| 名 | 基线(split 臂) | 本包之后 | 位置 |
|
||||
|---|---|---|---|
|
||||
| `generate-mipmap-storage`(split 检查) | 描述符层数少于「从 level 0 起的整链」即 `Fatal{UnmigratedEmulation}`:MAX_LEVEL 偏小、`glTexStorage2D` 层数不足(合法 GL) | 删;生成窗口 = 记录的计划 | `MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp:11759` |
|
||||
| `generate-mipmap-cpu-filter` | RGB16F / RGB32F 生成一律 Fatal | 删;先原生 `glGenerateMipmap`,驱动拒绝或旋钮强制时 server 从自己的层做 CPU 滤波 | `DirectGLES.cpp:13091`、`:13209` |
|
||||
|
||||
- split 臂的 `UnmigratedEmulation` 可达名清零;树里剩 4 名(`copy-image-shadow-mirror`、`generate-mipmap-storage` 的 monolith 生长、`generate-mipmap-cpu-fallback`、`get-tex-image-shadow`),都只在 monolith 臂上。
|
||||
- `PipeCatalogueTest.cpp:1451` 名单保持 4 名,注释补记漂移(它从未列过 `cpu-filter`)与本包的两处退役。
|
||||
- 主机(llvmpipe)上 RGB16F(原生存储)与 RGB32F(加宽为 RGBA32F)都由原生 `glGenerateMipmap` 完成;CPU 臂只在旋钮下走到(日志核实:非强制条目 0 行 `generate-mipmap-server-cpu`)。
|
||||
|
||||
## 2. 设计
|
||||
|
||||
| 项 | 做法 | 位置 |
|
||||
|---|---|---|
|
||||
| B1 窗口 | `Base = VerbMipBaseLevel`;`End = min(VerbMipLevelCount, Desc.Levels, MaxLevel+1, Base + 基准层的整链)`,与 Magma 的裁剪同式(`WireFramebuffer.inc:1358`);client 已按同一窗口定义层(`EmitTables.cpp:384-390`) | `DirectGLES.cpp:11759` |
|
||||
| B1 两条 blit 链 | 深度 / R11F 的记录臂改为只跑 `[Base+1, End)`,不再从 level 1 跑到描述符末尾(BASE_LEVEL=1 时会用 level 0 覆盖 base) | `DirectGLES.cpp:12523`、`:12540` |
|
||||
| B1 死臂 | `EnsureGenerateMipmapStorageAllocated(texture)` 的 transport 臂删除:split 下 `GenerateMipmap` 在它之前已经返回 | `DirectGLES.cpp:11781` |
|
||||
| B2 原生 | 三通道浮点也先走原生 `glGenerateMipmap`;错误不转给应用,改走 CPU 臂 | `DirectGLES.cpp:13258` |
|
||||
| B2 CPU 臂 | 源 = 驱动上的 base 层(`ReadTextureLevelTight`,RGB/FLOAT);驱动读不回(不可附着的存储)才用 staged store,且 store 须整层覆盖;都没有则具名拒绝(`MGLOG_E_ONCE`,不 Fatal);2×2 盒滤波(monolith 同式);按驱动存储的通道数 `glTexSubImage2D`(RGB 或 RGBA,FLOAT);支持 2D 与立方体,其余目标具名拒绝 | `DirectGLES.cpp:13036`、`:13091` |
|
||||
| B2 旋钮 | `MGITEST_ESPRYT_FORCE_CPU_MIPMAP=1`,server 读(`MGITEST_MAGMA_FORCE_SHADER_MIPMAP` 先例);命中打一行 `generate-mipmap-server-cpu`(INFO,每进程一次) | `DirectGLES.cpp:13017` |
|
||||
| B2 client 影子 | 任何臂都不读 client 影子 | — |
|
||||
|
||||
未改:`PipeCalls.def:260` 的 `GenerateMipmap` 仍是 `kWaitApplied`。P5e 裁定 14 留着它的唯一理由(CPU 滤波读 client 影子)已消失;翻成 `kWaitNone` 是协议改动,交集成方。
|
||||
|
||||
## 3. 覆盖(`GenerateMipmapServerScenario`)
|
||||
|
||||
用例:基准层分上下两半(A / B),逐层 `texelFetch` 到 RGBA8 回读;窗口外的层检查未变或仍未定义。
|
||||
|
||||
| 用例 | 形状 | 行 |
|
||||
|---|---|---|
|
||||
| `PackedFloat` / `Depth` × `MutableMaxLevelBelowTheChain` | 可变,定义 0..2,MAX_LEVEL=2;level 3 须未定义 | `GenerateMipmapServerScenario.cpp:307` |
|
||||
| `PackedFloat` / `Depth` × `StorageWithFewerLevelsThanTheChain` | `glTexStorage2D` 3 层(整链 5) | `GenerateMipmapServerScenario.cpp:326` |
|
||||
| `PackedFloat` / `Depth` × `MutableBaseLevelOneKeepsTheLevelsOutsideItsWindow` | 定义 0..3,BASE=1、MAX=2;level 0/3 不变,level 4 未定义 | `GenerateMipmapServerScenario.cpp:341` |
|
||||
| `Rgb16f` / `Rgb32f` × `UploadedBaseGeneratesItsChain` | 仅上传 level 0 | `GenerateMipmapServerScenario.cpp:366` |
|
||||
| `Rgb16f` / `Rgb32f` × `RenderTargetBaseGeneratesFromTheGpuWrittenLevel` | 上传哨兵色后把 level 0 当渲染目标绘制(Complementary colortex2 形状) | `GenerateMipmapServerScenario.cpp:382` |
|
||||
|
||||
| 臂 | 登记 | Espryt | Magma(对照) |
|
||||
|---|---|---|---|
|
||||
| monolith | 环境发现 `DirectGLES.` / `DirectVulkan.` | 4 绿 + 6 按名跳过(M1、M2) | 7 绿 + 3 按名跳过(M3) |
|
||||
| Split / Spawn / Tcp | `MobileGL/MG_IntegrationTest/CMakeLists.txt:3442`;Magma 门控块 `MobileGL/MG_IntegrationTest/CMakeLists.txt:4174` | 10 × 3 绿 | 10 × 3 绿 |
|
||||
| 强制 CPU(Split / Spawn) | `MobileGL/MG_IntegrationTest/CMakeLists.txt:3443-3459`,标签 `integration-cpu-mip-{split,spawn}` | 4 × 2 绿,server 日志须有 `generate-mipmap-server-cpu`(`GenerateMipmapServerScenario.cpp:295`) | — |
|
||||
| A/B inproc(门的 `integration-gpu[inproc]` 环境) | 同环境发现 | 10 绿 | 10 绿 |
|
||||
|
||||
- 强制 CPU 臂不上 tcp:tcp 的 server 是共享的 `TcpServer.Start` 夹具(`MobileGL/MG_IntegrationTest/CMakeLists.txt:2168`),旋钮放那里会让所有 tcp 条目都走 CPU 臂、原生臂在 tcp 上失去覆盖;CPU 臂本身与传输无关(spawn 已证跨进程)。与 P9 `RemintFallback.` 同形,不需要 parity 例外行。
|
||||
|
||||
## 4. red-once
|
||||
|
||||
| # | 变异 | 载体 | 观察到的红 |
|
||||
|---|---|---|---|
|
||||
| 1 | 基线 `8d3e2317`(只加用例) | `DirectGLES.{Split,Spawn,Tcp}.GenerateMipmapServerScenario.*` | 30/30 abort:B1 六例 `Fatal{UnmigratedEmulation, "generate-mipmap-storage"}`,B2 四例 `Fatal{UnmigratedEmulation, "generate-mipmap-cpu-filter"}`;`CpuMip.` 8/8 abort |
|
||||
| 2 | CPU 臂入口放回 `cpu-filter` 闩(去掉新臂) | `DirectGLES.{Split,Spawn}.CpuMip.*` | 8/8 Subprocess aborted |
|
||||
| 3 | CPU 臂跳过驱动回读、改读 store | 同上 | 4/8 Failed:两个渲染目标用例 × 两臂读到哨兵色(陈旧) |
|
||||
| 4 | server 不再读旋钮 | 同上 | 8/8 Failed:像素对(原生臂),server 日志无 `generate-mipmap-server-cpu` |
|
||||
| 5 | 两条 blit 链改回 `1 .. Desc.Levels` | `DirectGLES.{Split,Spawn,Tcp}.GenerateMipmapServerScenario.{PackedFloat,Depth}*` | 6/18 Failed(另 2 条为 tcp 夹具):`MutableBaseLevelOne` 两格式 × 三臂 |
|
||||
| 6 | 窗口不按计划 / MAX_LEVEL 裁剪(`End = Desc.Levels`) | 同上 | 6/18 Failed:同 5 |
|
||||
| 7 | `MGITEST_RUN_MONOLITH_MIP_DEFECTS=1` | `Direct{GLES,Vulkan}.GenerateMipmapServerScenario.*`,`MOBILEGL_TRANSPORT=monolith` | 9/20 Failed:M1 两例、M2 四例、M3 三例(§5) |
|
||||
|
||||
恢复一律复制比对 + `touch`(`cmp` 一致),每次恢复后重建。
|
||||
|
||||
## 5. monolith 缺陷(记给 dev,ID-P8-3;用例在该臂按名跳过,旋钮 `MGITEST_RUN_MONOLITH_MIP_DEFECTS=1` 复现)
|
||||
|
||||
| # | 后端 | 缺陷 | 位置 | red-once 读数 |
|
||||
|---|---|---|---|---|
|
||||
| M1 | Espryt | RGB16F / RGB32F CPU 滤波读前端层影子;level 0 被 GPU 写过后影子陈旧 | `DirectGLES.cpp:12927`(调用 `:13320`) | level 1..3 = 哨兵色 `rgba(255,0,255,255)`,两格式 |
|
||||
| M2 | Espryt | R11F / 深度:存储生长从 level 0 算整链,定义 MAX_LEVEL 之外的层;两条 blit 链从 level 1 跑到末尾,无视 BASE_LEVEL / MAX_LEVEL | `DirectGLES.cpp:11707`、`:12580`、`:12610` | MAX_LEVEL=2 时 level 3 宽 2(应 0);BASE=1 时 level 1..3 全被 level 0 覆盖,level 4 被定义 |
|
||||
| M3 | Magma | 无 BLIT 的颜色格式(lavapipe 上 `B10G11R11_UFLOAT`,VkFormat 122)直接跳过生成,只打 `MGLOG_W_ONCE`;wire 臂自 P7 有着色器臂,monolith 没有 | `MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp:12229` | 三个 PackedFloat 用例生成层读到 `rgba(0,0,0,255)` |
|
||||
|
||||
- M1 修法指向:monolith 也改为回读驱动层(P9 dev `568090f0` 的 `AdoptDriverLevelIntoShadow` 同路)。M2:monolith 两条链与生长改用 `ComputeMipmapGenerationRange` 窗口。M3:monolith 复用 wire 臂的着色器 mip。都动 pull 构建的 `.text`,按 G1 在 dev 修。
|
||||
|
||||
## 6. 门
|
||||
|
||||
`gate.sh ~/w7/p8-b p8b`,头 `1bb77890`,dirty 0:
|
||||
|
||||
| 项 | 读数 |
|
||||
|---|---|
|
||||
| G1 | `added=0 removed=0`(clang 22.1.6);`.text` a5ba13,与建树时相同 |
|
||||
| census / ratchet | 79 个 abort 点、45 个族词,与基线同:`MGPipeUnmigratedEmulation` 的调用点不是 abort 点(abort 在 `PipeApply.cpp` 的漏斗里),删两个名不改计数,基线不动;ratchet 172 不变 |
|
||||
| parity / protocol pin / wire-declines | 0 错;revision 5;53 行 0 未记 |
|
||||
| hygiene | 12/12 OK |
|
||||
| unit | 2714/2714 |
|
||||
| integration-split / spawn / tcp | 437 / 356 / 358,全绿 |
|
||||
| integration-magma-split / spawn / tcp / full-split | 261 / 238 / 207 / 646,全绿 |
|
||||
| integration-gpu[monolith] / [inproc] | 2746 / 2746,全绿 |
|
||||
| retrace(`MOBILEGL_BUILD_TRACE_REPLAY=ON`,236 条) | 230 过;6 条 `iris-iterationrp-in-world`(两后端 × monolith / SPLIT / SPAWN)为已知主机 llvmpipe JIT 崩溃;全部重放日志 0 行 `generate-mipmap-*` |
|
||||
|
||||
## 7. 发现未修
|
||||
|
||||
| 项 | 说明 |
|
||||
|---|---|
|
||||
| `PipeCatalogue` 名单无门 | 名单与树里的调用点没有任何脚本比对,漂移只能靠人发现;`fatal_census` 数的是 abort 点,不数 `MGPipeUnmigratedEmulation` 调用 |
|
||||
| CPU 臂的目标 | 2D 数组 / 3D / 立方体数组的 RGB16F / RGB32F 若驱动拒绝原生生成,CPU 臂具名拒绝(monolith 的 CPU 滤波对这些目标同样只按 2D 取址) |
|
||||
| 层间精度 | CPU 臂层间以 float 传递,不在每层回量化到 half;GL 不规定滤波,与 monolith(每层从 half 影子读)可能差 1 ulp |
|
||||
@@ -0,0 +1,102 @@
|
||||
# P8-C:Espryt server 暂存影子与 GPU 写
|
||||
|
||||
> 2026-09-29,分支 `p8/c`(基线 `8d3e2317`)。计划行:[`PLAN-P8.md`](PLAN-P8.md) 包 C。
|
||||
|
||||
## 1. 结论
|
||||
|
||||
- 前提成立(red-once 见 §4):split 下 server 的 R-11 暂存影子只由上传 / adopt 填,server 上的 GPU 写不进影子;CPU 读者读到旧字节,或因无影子直接拒绝。原 7 例在基线上 Espryt split / spawn / tcp 与 inproc A/B 全红。
|
||||
- 修在 server,不动 client、不动 monolith:写者给 server 孪生体打标(`serverGpuWritten`,`MobileGL/MG_Backend/DirectGLES/Managers.h:1059`),读者消费字节前经 `SplitHostBytesForCpuRead`(`MobileGL/MG_Backend/DirectGLES/Managers.cpp:3595`)从 server 自己的 GL buffer 整 store 回读。
|
||||
- XFB 不打标:两条捕获路径本来就把字节拿在手里(给 client 的 writeback),直接写进影子(`StageServerWrittenRange`,`MobileGL/MG_Backend/DirectGLES/Managers.cpp:3651`)。
|
||||
- 懒刷新:只在读者真正消费字节时回读;原生 indirect 不从 CPU 取字段时不回读,Create / Flywheel 式每帧 compute 剔除 + 原生 indirect 不付回读(`MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp:8555`)。
|
||||
- 顺带关掉 P3a M-3 声明的偏差(fp64 顶点收窄读旧字节)在 split 臂上的一半;monolith 臂不动。
|
||||
- monolith 两后端共 5 处缺陷,skip 按名、记给 dev(§6,ID-P8-3);IndirectCount 的 monolith 按 OQ15 不改。
|
||||
|
||||
## 2. 读者与写者
|
||||
|
||||
| 读者(split 臂) | 位置 | 做法 |
|
||||
|---|---|---|
|
||||
| primitive restart 重写 | `MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp:9309` | `SplitHostBytesForCpuRead`(整 store) |
|
||||
| multi-draw rebase | `MobileGL/MG_Backend/DirectGLES/MultiDraw.cpp:196` | 同上 |
|
||||
| `*IndirectCount` 的 count | `DirectGLES.cpp:9632`、`:9798` | 参数 buffer 刷新;命令 buffer 仅在无影子时取第一份 |
|
||||
| indirect 命令字段 | `DirectGLES.cpp:8549` | CPU 路径全取;原生路径只在程序读 `gl_BaseVertex`、或无 `mg_IndirectParams` 视图而读 `gl_BaseInstance` 时取 |
|
||||
| 无影子的 indirect 命令 buffer | `DirectGLES.cpp:487` | 被 GPU 写过就取第一份(原来 decline,`indirect_command_bytes`) |
|
||||
| XFB scatter 的捕获前字节 | `DirectGLES.cpp:2037` | 刷新 |
|
||||
| fp64 顶点收窄 | `MobileGL/MG_Backend/DirectGLES/Managers.cpp:6696` | 刷新,并让 memo 失效(GPU 写不动 serial) |
|
||||
|
||||
| 写者 | 位置 | 效果 |
|
||||
|---|---|---|
|
||||
| SSBO 记录臂(draw 与 dispatch) | `DirectGLES.cpp:780` | 标记窗口内每个绑定点(与 client 的 `ShaderBufferEmit.h` 同口径) |
|
||||
| 原子计数记录臂 | `DirectGLES.cpp:1017` | 标记 |
|
||||
| 可写 buffer image | `DirectGLES.cpp:4464` | 纹理描述符的 `BufferForTexBuffer` → 标记 |
|
||||
| XFB 普通捕获 | `DirectGLES.cpp:1874` | 映射出的字节写进影子;T0 store 只标记(`:1829`) |
|
||||
| XFB scatter | `DirectGLES.cpp:2104` | 合成结果写进影子 |
|
||||
| 清标记 | `Managers.cpp:2308`(respecify)、刷新末尾 | — |
|
||||
|
||||
- 刷新顺序同 `Ops_H_Readback`:`FlushPendingRangesFrom` 先落排队上传 → `DrainResidentWritesNow` → 整 store `glMapBufferRange(READ)` → `MGL_SERVER_STAGED_ADOPT`(覆盖变整段,孤儿 store 也就有了第一份)→ serial 戳 + epoch bump。
|
||||
- T0 store:影子就是 server 对 client AHB 的一致映射;有标记或有排队常驻写时 `DrainResidentWritesNow` + `glFinish`(DEBTS 的 P11 B2 行的 split 半)。
|
||||
- 刷新与写影子只在复制型暂存 store(split)下生效(`CopiesIntoServerStorage`):monolith 的 store 保留调用方指针,映射一解就悬空。
|
||||
- 全部新代码在 `MOBILEGL_BUILD_DISAGGREGATED` 下;`ReadsBaseInstance`(`Managers.h:3124`)同。
|
||||
|
||||
## 3. 场景
|
||||
|
||||
`GpuWrittenDrawInputScenario`(`MobileGL/MG_IntegrationTest/Scenarios/GpuWrittenDrawInputScenario.cpp`,split-only 源,登记 `MobileGL/MG_IntegrationTest/CMakeLists.txt:3461`)12 例:GPU 只写一次,暂存影子里是画不出正确结果的毒值。
|
||||
|
||||
| 例 | 写者 | 读者 |
|
||||
|---|---|---|
|
||||
| RestartIndicesAComputeShaderWroteSplitTheStrip | SSBO | restart 重写 |
|
||||
| …IntoAnOrphanedStoreSplitTheStrip | SSBO,`glBufferData(NULL)` | restart 重写(原来无影子 → 跳过 draw) |
|
||||
| …SplitEveryMultiDrawStrip | SSBO | multi-draw rebase |
|
||||
| ACountAComputeShaderWroteDrivesMultiDrawElementsIndirectCount | SSBO(命令 + count) | count |
|
||||
| …DrivesMultiDrawArraysIndirectCount | SSBO | count |
|
||||
| ABaseVertexAComputeShaderWroteReachesGlBaseVertex | SSBO | 原生 indirect 的 `gl_BaseVertex` |
|
||||
| IndirectCommandsAComputeShaderWroteIntoAnOrphanedStoreDraw | SSBO,`glBufferData(NULL)` | 无影子命令 buffer |
|
||||
| RestartIndicesATransformFeedbackCapturedSplitTheStrip | XFB | restart 重写 |
|
||||
| RestartIndicesAScatteredTransformFeedbackCapturedSplitTheStrip | XFB + `gl_SkipComponents1`(scatter) | restart 重写 |
|
||||
| RestartIndicesImageStoresWroteSplitTheStrip | `imageStore` 到 buffer 纹理 | restart 重写 |
|
||||
| ACountAnAtomicCounterProducedDrivesMultiDrawElementsIndirectCount | 原子计数即参数 buffer | count |
|
||||
| DoubleVerticesAComputeShaderWroteAreNarrowedFromTheWrittenBytes | SSBO,两轮 | fp64 收窄(第 2 轮查 memo) |
|
||||
|
||||
- 臂:`DirectGLES.{Split,Spawn,Tcp}.`(门控);分裂构建里的 `DirectGLES.` / `DirectVulkan.` 即 monolith 对照与 inproc A/B;Magma split 各臂经 tier 2(`integration-magma-all-*`,信息层)与 `DirectVulkan.*.Full.`(`integration-magma-full-split`,门控)。
|
||||
- 三臂同源登记,`spawn_lane_parity.py` 无需例外行。
|
||||
|
||||
## 4. red-once
|
||||
|
||||
| # | 变异 | 载体 | 观察到的红 |
|
||||
|---|---|---|---|
|
||||
| 前提 | 基线 `8d3e2317` + 原 7 例 | `ctest -R GpuWrittenDrawInput`;inproc A/B 同命令加 gate 的环境 | Espryt split / spawn / tcp 21/21 红(像素:黑 = 旧毒值 / 跳过;baseVertex 例红色 = 几何对、`gl_BaseVertex` 旧);inproc A/B 7/7 红;Magma split 各臂全绿 |
|
||||
| F1 | 去 SSBO 标记、原子标记、image 标记、XFB 两处写影子(一个构建) | `ctest -R '^DirectGLES\.(Split|Spawn|Tcp)\.GpuWrittenDrawInput'` | 12/12 例在 Split、Spawn 红;Tcp 臂 Not Run(`TcpServer.Start` 撞上 :48440 的 TIME_WAIT),F2 覆盖了三臂;每例只依赖其中一个变异 |
|
||||
| F2 | 读者侧:restart / rebase / 两处 count 改回 `SplitHostBytes`,`CurrentIndirectCommandBytes` 恒返回原指针,去无影子取第一份,fp64 memo 去掉 `!sourceGpuWritten`(一个构建) | 同上 | 10 例 × 3 臂 = 30 红;两例 XFB 绿(它们的字节来自写影子,不经刷新,符合设计);fp64 例只红第 2 轮(memo) |
|
||||
| M | 把 `SkipBrokenMonolith` 探针成恒 false | `ctest -R '^Direct(GLES|Vulkan)\.GpuWrittenDrawInput'` | Espryt monolith:两例 count、原子 count、baseVertex、fp64 红;Magma monolith:6 例 restart SIGSEGV、Arrays count 红、fp64 SIGSEGV |
|
||||
|
||||
还原一律 copy + `cmp` + `touch`。
|
||||
|
||||
## 5. 门
|
||||
|
||||
- 场景:134 条(含 monolith skip 13 条)全绿;inproc A/B 24/24;相邻套件(Restart / MultiDraw / DrawParameters / IndexedDrawFamily / ClientVertexArray / Xfb / TransformFeedback / AtomicCounter / BufferTexture / DoublePrecision / ResidentIndex)1304/1304。
|
||||
- G1:`added=0 removed=0`,pull `.text` `a5ba13` 与基线相同。
|
||||
- retrace(主机):Espryt `SPLIT|SPAWN` 78 条 + `create-*` 12 条共 86 条,84 过;挂的 2 条是 `iris-iterationrp-in-world` 的宿主 llvmpipe JIT 崩溃(`LLVM ERROR: Cannot select ... vcvtps2ph`,已知项)。全量 236 条跑到 47 条(全过)时中止,全量留给集成。
|
||||
- create 的 SSIM:indirect Espryt 0.999961275 / Magma 0.999956667,instancing Espryt 0.999957572 / Magma 0.999952470,monolith、SPLIT、SPAWN 三臂逐位一致;Espryt indirect 与 P9 W2 普查的值相同([`../p9/W2-REMINT.md`](../p9/W2-REMINT.md) §4)。
|
||||
- 懒刷新实测:create-indirect / create-instancing 的 Espryt SPLIT、SPAWN 回读 0 次(临时把刷新日志提到 INFO,数 server 日志,未提交)。
|
||||
- 全门数字见包报告(`~/w7/notes/p8/c-report.md`)。
|
||||
|
||||
## 6. monolith 缺陷(给 dev,ID-P8-3)
|
||||
|
||||
| 后端 | 缺陷 | 位置 | 场景里的表现 |
|
||||
|---|---|---|---|
|
||||
| Espryt | `*IndirectCount` 读前端影子不调 `SyncGpuWrites`(OQ15) | `DirectGLES.cpp:9688-9689`、`:9852-9853` | count 读 0,什么都不画 |
|
||||
| Espryt | 原生 indirect 的 `gl_BaseVertex` 从前端影子取(单进程臂 `ResolveIndirectCommandBytes` 只 `SyncPersistentMappedRange`) | `DirectGLES.cpp:521`、`:8640` | 几何对、颜色红 |
|
||||
| Espryt | fp64 收窄的 handle 臂在 monolith 下读前端影子(P3a M-3 声明的偏差,monolith 半) | `Managers.cpp:6675` | 画在屏外 |
|
||||
| Magma | `MultiDrawArraysIndirectCount` 的 CPU 臂不调 `SyncGpuWrites` | `MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp:749` | count 读 0 |
|
||||
| Magma | draw 录制中途调 `SyncGpuWrites`(restart 重写、GL_DOUBLE 顶点转换):提交并等待结束了当前帧命令缓冲,draw 接着往已结束的缓冲里录 | `MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp:4513`、`:4179` | SIGSEGV(lavapipe 工作线程 / `vkCmdBindVertexBuffers`);校验层 `VUID-vkCmdBindIndexBuffer-commandBuffer-recording` |
|
||||
|
||||
- skip 只在 `transportName == "monolith"` 的对应后端生效,理由串带出处。
|
||||
|
||||
## 7. 未做 / 已知边界
|
||||
|
||||
- T0 与常驻写那一半主机上无法 red(主机无 T0,split 下采纳档钉在 T2);代码按 `Ops_H_Readback` 的持久映射臂写,设备验证留给有设备的包。
|
||||
- 标记是过近似:窗口内每个绑定的 SSBO 每次 draw 都标记;留着 SSBO 绑定、又拿同一 buffer 做任意 restart 索引的 EBO 时,每 draw 回读一次。
|
||||
- bit 13 关(`BindingPointsComeFromRecords()` 为 false)的 A/B 配置下 SSBO / 原子不打标。
|
||||
- `Ops_H_Readback`(client 发起的回读)没有顺带刷新 server 影子(可省一次回读,未做)。
|
||||
- 同一 draw 既写 X(SSBO)又拿 X 当 EBO:标记在 `SyncNeccessaryBuffers` 里打,restart / rebase 读者在 draw 执行前就刷新并清标记,写发生在清之后,X 留成未标记。monolith 同形(`MarkShaderStorageBuffersGpuWritten` 先标,`SyncGpuWrites` 在 draw 前清),是对齐不是倒退。
|
||||
- DEBTS 的 P11 B2 行(handle 臂读采纳 / T0 映射前不落常驻写):split 半由 `SplitHostBytesForCpuRead` 的 T0 臂做了、主机不可验证;单进程半归 dev。
|
||||
- Magma 的 `VulkanRenderer.cpp:3686`(最大索引扫描)与 §6 最后一行同模式,未验证。
|
||||
@@ -0,0 +1,83 @@
|
||||
# P8-D:Magma wire 臂原生 indirect draw
|
||||
|
||||
> 2026-09-29,分支 `p8/d`(基线 `8d3e2317`)。计划:[`PLAN-P8.md`](PLAN-P8.md) 包 D;审计 §4、§6 风险 3。主机 lavapipe,只动 Magma(Espryt 作对照)。
|
||||
|
||||
## 1. 结论
|
||||
|
||||
- wire 臂的 `glDraw*Indirect` / `glMultiDraw*Indirect[Count]` 改为从 wire store 自己的 `VkBuffer` 发 `vkCmdDraw[Indexed]Indirect[Count]`:`VulkanRenderer::DrawWireIndirectNative`(`MobileGL/MG_Backend/DirectVulkan/Renderer/WireDraw.inc:627`)。
|
||||
- `DrawWireIndirect`(`MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp:381`)先走原生;CPU 展开只留给设备发不出的 COUNT 形态(与 monolith 同条件,§3)。
|
||||
- create-indirect × Magma × split:indirect 引起的 host 等待 321 → 0,等待时间 8.07 s → 0.013 s(剩下 6 次是应用回读,§2);SSIM 各臂不变。
|
||||
- 新增 barrier:着色器写过的 store 在下一次 indirect 读前补一个 `INDIRECT_COMMAND_READ` barrier,每次写一次(`WireDraw.inc:693-705`)。create-indirect 的 322 次 cull→draw 里 320 次没有 `glMemoryBarrier`,旧 CPU 路径靠整 GPU 等待碰巧有序,原生路径靠这个 barrier。
|
||||
|
||||
## 2. 测量(主机,`MOBILEGL_PIPE_STATS=1 MOBILEGL_PIPE_STATS_PERIOD=1`,server 日志 `windr[...]` 求和)
|
||||
|
||||
两个 fixture 都只有 1 帧(frames=1),所以"每帧"= 每次重放。主机上同时有 7 个包在跑,毫秒只看量级。
|
||||
|
||||
| fixture | 臂 | draws | wind | wixp | wibar | whw | whwi | whwus | SSIM |
|
||||
|---|---|---:|---:|---:|---:|---:|---:|---:|---|
|
||||
| create-indirect | monolith(前后相同) | 13172 | 0 | 0 | 0 | 0 | 0 | 0 | 0.999956667 |
|
||||
| create-indirect | inproc,改前 | 13172 | 0 | 321 | 0 | 327 | 321 | 8065617 | 0.999956667 |
|
||||
| create-indirect | inproc,改后 | 13172 | 321 | 0 | 321 | 6 | 0 | 12540 | 0.999956667 |
|
||||
| create-indirect | spawn,改前 | 13202 | 0 | 322 | 0 | 328 | 322 | 8360015 | 0.999956667 |
|
||||
| create-indirect | spawn,改后 | 13202 | 322 | 0 | 322 | 6 | 0 | 15769 | 0.999956667 |
|
||||
| create-instancing | 三臂,前后相同 | 14158 / 14194 | 0 | 0 | 0 | 0 | 0 | 0 | 0.999952470 |
|
||||
|
||||
- 字段:`wind` 原生 indirect 调用、`wixp` CPU 展开、`wibar` 补的 barrier、`whw` / `whwus` 真正等了的 `WaitForWireBufferHostAccess` 次数 / 微秒(`MobileGL/MG_Backend/DirectVulkan/Renderer/VkBufferManager.cpp:321`)、`whwi` 其中由 indirect 读引起的。定义在 `MobileGL/MG_Util/Metrics/PipeStats.h:280-285`,打印在 `MobileGL/MG_Util/Metrics/PipeStats.cpp:697`。
|
||||
- 改后剩下的 6 次等待全部来自 `ReadbackWireBuffer`(`VkBufferManager.cpp:574`,临时探针取调用方地址 + `addr2line`,未提交):应用对 6 个 store 的回读,改前也是这 6 次(327 − 321)。
|
||||
- 同一 trace(apitrace dump 到 target call):322 次 `glMultiDrawElementsIndirect`、2901 次 `glDispatchCompute`、9 次 `glMemoryBarrier`;前 320 次 draw 与其 cull dispatch 之间没有应用 barrier,只有最后 2 次前有 `GL_COMMAND_BARRIER_BIT`。每次 draw 前都有 compute 写它的命令 store,所以 `wibar` = draw 数。
|
||||
- create-instancing 没有 indirect draw,也没有等待:它的 p99 差异不归 D。
|
||||
|
||||
## 3. monolith 何时在 CPU 上读 indirect 字(D 只在同样的场合保留 CPU 路径)
|
||||
|
||||
| monolith 场合 | 位置 | wire 臂(本包后) |
|
||||
|---|---|---|
|
||||
| 没绑 `GL_DRAW_INDIRECT_BUFFER`:命令在 client 内存 | `DirectVulkan.cpp:684`、`:825`、`:884` | client 在兼容档拒绝(`MobileGL/MG_Remote/Client/EmitTables.cpp:730` `CLIENT_COMMANDS`);store 为空则具名拒绝 `IndirectBufferUnbound` |
|
||||
| `glMultiDrawArraysIndirectCount`:总在 CPU 读 count 字 | `DirectVulkan.cpp:720-757` | 原生 `vkCmdDrawIndirectCount`(`MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp:15942` 加载,只在 disaggregated 构建) |
|
||||
| `glMultiDrawElementsIndirectCount`:无 `VK_KHR_draw_indirect_count`,或 maxdrawcount > 1 且无 `multiDrawIndirect` → CPU 循环 | `VulkanRenderer.cpp:13421-13444` | 同条件(`WireDraw.inc:630-635`)返回 false,走原 CPU 展开(`DirectVulkan.cpp:390-413`,计入 `wixp`) |
|
||||
| 无 `multiDrawIndirect` 或 stride 不是 4 的倍数:逐条原生 indirect,仍由 GPU 读 | `VulkanRenderer.cpp:13510`、`:13615` | 同(`WireDraw.inc:732-740`);stride 非 4 倍数在 GL 是 INVALID_VALUE,wire 上具名拒绝 `IndirectCommandRange` |
|
||||
| client 顶点数组 + arrays indirect:CPU 读命令定上传范围,draw 仍原生 | `VulkanRenderer.cpp:13576` | 不可达:client 把 client 数组拷成自有 buffer |
|
||||
| `GL_LINE_LOOP`:indirect 不改写,退化为 LINE_STRIP | `MobileGL/MG_Util/Converters/MGToVk/RenderStateEnumConverter.cpp:27` | 同 |
|
||||
| uint8 索引无扩展 / 非固定 restart 索引 / 非对齐偏移:整段索引在 CPU 改写,命令仍 GPU 读 | 两臂都在各自的索引上传里 | `WireDraw.inc:398`,索引视图是整个 EBO(`WireDraw.inc:681`,同 monolith) |
|
||||
| baseInstance / gl_DrawID | 原生(monolith 不查 `drawIndirectFirstInstance`) | 原生;旧 CPU 展开的第 3 档把 gl_DrawID 全给 0(`VulkanRenderer.cpp:13154`),原生反而更对 |
|
||||
|
||||
## 4. 设计
|
||||
|
||||
| 项 | 内容 |
|
||||
|---|---|
|
||||
| 入口 | `DrawWireIndirect`(`DirectVulkan.cpp:381`)→ `DrawWireIndirectNative`;false 才走 CPU 展开 |
|
||||
| store | `AcquireWireSlice` 取 indirect / count / 元素 store(打 `lastUseSerial`,之后的 `glBufferSubData` 会排在这次读之后);范围、4 字节对齐、count 字越界都是具名拒绝(`MobileGL/MG_Backend/DirectVulkan/Renderer/WireDeclines.def:115-118`) |
|
||||
| draw 准备 | 复用 `SetupDraw` → `SetupWireDraw`,带 `IndirectDrawBuffer`;该 aspect 原来是 `buffer-legacy-arm` Fatal,现只对 monolith 入口仍 Fatal(`WireDraw.inc:213`,`m_wireNativeIndirectDraw`);顶点流转换不再按 first+count 截断(`WireDraw.inc:326`) |
|
||||
| 发射 | 同 monolith 的三档:COUNT 原生、`multiDrawIndirect` 一次发、否则逐条;另按 `maxDrawIndirectCount` 分块(`WireDraw.inc:719-740`) |
|
||||
| barrier | `MarkWireBufferGpuWritten` 置 `indirectReadBarrierPending`(`VkBufferManager.cpp:611`),`TakeWireIndirectReadBarrier`(`VkBufferManager.cpp:624`)取走;有则结束 render pass 并记 `ALL_COMMANDS/MEMORY_WRITE → DRAW_INDIRECT/INDIRECT_COMMAND_READ`。transfer 写已有 `MEMORY_READ` 后置 barrier(`VkBufferManager.cpp:514`、`:1437`),不置位。应用自己的 `glMemoryBarrier(GL_COMMAND_BARRIER_BIT)` 仍走 `BuildMemoryBarrierForGlBarriers`(`VulkanRenderer.cpp:7873`),与 monolith 一样 |
|
||||
| G1 | 全部在 `MOBILEGL_BUILD_DISAGGREGATED` / `MOBILEGL_PIPE_PUSH` 下;pull 构建 `added=0 removed=0` |
|
||||
|
||||
## 5. 门与 red-once
|
||||
|
||||
用例 `WireIndirectDrawScenario`(`MobileGL/MG_IntegrationTest/Scenarios/WireIndirectDrawScenario.cpp:225`、`:274`、`:304`、`:343`),读数经 `MobileGL/MG_IntegrationTest/Harness/WireIndirectPeek.cpp:22`(进程内 PipeStats,只在 inproc 臂看得到 server)。登记:`MobileGL/MG_IntegrationTest/CMakeLists.txt:4831-4864`——Magma 门控三臂 `DirectVulkan.{Split,Spawn,Tcp}.Indirect.`、DirectGLES 三臂(经宏,含 Magma 信息层)、两后端 monolith(环境发现)。
|
||||
|
||||
| 用例 | 断言 | 两后端 / 各臂 |
|
||||
|---|---|---|
|
||||
| `EveryIndirectFormIsIssuedNativelyFromItsStore` | 6 种 indirect 形态像素;inproc Magma:wind=6、wixp=0、whw=0、wibar=0 | 两后端全臂 |
|
||||
| `ComputeWrittenCommandsDrawWithoutAHostWait` | compute 写命令(初值毒化为别的条带)+ 应用 barrier,像素;inproc Magma:wind=2、wixp=0、whw=0、wibar=2 | 两后端全臂 |
|
||||
| `ComputeWrittenCountWordIsTheOneTheGpuReads` | compute 写 count 字,像素;inproc Magma 计数 | Magma;Espryt 跳过(count 字读 server 影子,OQ15 / P8-C);Magma monolith 跳过 arrays-count 半(§6) |
|
||||
| `ShaderWrittenCommandsWithoutAnApplicationBarrierAreOrdered` | Flywheel 形状(无应用 barrier);inproc Magma:每次写恰好 1 个 barrier(wibar=2 / 3 次 draw) | Magma split 三臂;monolith 与 Espryt 跳过 |
|
||||
|
||||
| red-once | 变异 | 载体 | 观察 |
|
||||
|---|---|---|---|
|
||||
| 1 | `DrawWireIndirectNative` 开头 `return false`(强制 CPU 路径) | 4 用例 × 3 个 inproc 登记(`.Split.Indirect.` 门控、`.Split.` 信息层、`.Split.Full.`) | 12 红;`ComputeWrittenCommandsDrawWithoutAHostWait`:nativeDraws 0、cpuExpansions 2、indirectWaits 2、hostWaits 2;spawn/tcp 只断言像素,保持绿(CPU 路径像素是对的) |
|
||||
| 2 | 去掉 barrier(`if (false && ...)`) | 同上 | 3 个 compute 写用例 × 3 个 inproc 登记 = 9 红,全部是 `delta.barriers` 0 ≠ 2;**像素在 llvmpipe 上不红**(lavapipe 按序执行),spawn/tcp 绿 |
|
||||
| 3 | 去掉 Magma monolith 的 arrays-count 跳过 | `DirectVulkan.WireIndirectDrawScenario.ComputeWrittenCountWordIsTheOneTheGpuReads` | 红:compute 写的 count=2,条带 1、2 未画(monolith 读到陈旧影子 count 0) |
|
||||
| fixture 门 | 改前 = 旧 CPU 路径 | create-indirect × Magma × {inproc, spawn} | whwi 321 / 322 > 0(§2 改前行);改后 0 |
|
||||
|
||||
## 6. monolith 缺陷(记给 dev,ID-P8-3,本包不修)
|
||||
|
||||
| 缺陷 | 位置 | 证据 |
|
||||
|---|---|---|
|
||||
| Magma monolith `glMultiDrawArraysIndirectCount` 从前端影子读 count 字,不 `SyncGpuWrites`:着色器写的 count 读成旧值 | `DirectVulkan.cpp:749-757` | red-once 3(主机 lavapipe 红) |
|
||||
| Magma monolith 对"compute 写 → indirect 读"没有任何依赖:不补 barrier,render pass 的外部依赖也不含 `COMPUTE_SHADER` / `DRAW_INDIRECT`(`MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderPassManager.cpp:1413-1419`)。create-indirect 的 320 次 cull→draw 不发 `glMemoryBarrier`(GL 未定义),真 GPU 上 cull 结果与 indirect 读竞争 | `VulkanRenderer.cpp:7727-7787`(dispatch 后无 barrier) | 推断:主机 lavapipe 按序执行,red 不出;可能与 ID-P7-4(红米上 create-indirect monolith 坏)有关,需设备验证 |
|
||||
|
||||
## 7. 找到但未做
|
||||
|
||||
- `DispatchComputeIndirect` 的 wire 臂同样经 `ReadWireBuffer` 在 CPU 读 group 数(`DirectVulkan.cpp:938-947`),GPU 写过则整 GPU 等待;create fixtures 里没有 `glDispatchComputeIndirect`,本包未改(monolith 是原生 `vkCmdDispatchIndirect`)。
|
||||
- 补的 barrier 只覆盖 indirect 读;同一批 cull 写的实例 SSBO 被顶点着色器读时,两臂都没有 compute→vertex 的依赖(应用没发 barrier 时),不在 D 范围。
|
||||
- 同一 store 既作 indirect 又作本 draw 的 SSBO 时,SetupWireDraw 解析描述符会再次置位,下一次 indirect draw 会多一个 barrier(保守,不影响正确性)。
|
||||
@@ -0,0 +1,119 @@
|
||||
# P8-E:CopyImageSubData 由 server 的 staged store 跟随;死闩清理
|
||||
|
||||
> 2026-09-29,分支 `p8/e`(基线 `8d3e2317`)。简报 `~/w7/notes/p8/BRIEF-E.md`;证据 `~/w7/notes/p8/e-evidence/`。只在 Espryt;Magma 无代码改动,作对照。
|
||||
|
||||
## 1. 结论
|
||||
|
||||
- 审计的推断「split 下 copy 后 `glGetTexImage` 读到陈旧影子」不成立:split 的 `glGetTexImage` 不进 `DirectGLES::GetTexImage`,也不读任何影子。
|
||||
- split 路径:client `EmitGetTexImage`(`MG_Remote/Client/TextureReadbackEmit.inc:158`)→ server `OnGetTextureImage`(`MG_Remote/Server/PipeApplier.cpp:443`)→ `ReadTextureImageWire`(`DirectGLES/WireTextureReadback.inc:422`)→ `ReadTextureLevelTight`(`DirectGLES/WireTextureReadback.inc:217`),只读 GPU(R32UI 字腿或 FBO)。
|
||||
- 真实缺口:驱动不能 attach 的格式(Adreno:RGB16、16 位 SNORM)FBO 不完整(`DirectGLES/WireTextureReadback.inc:269`)→ `kStatusError`(`PipeApplier.cpp:462`)→ client `Fatal{ReplyError, "ReadPixels"}`(`EmitTables.cpp:903`)。与有没有 copy 无关,只上传过的层也结束会话。
|
||||
- 主机 llvmpipe 能 attach 这些格式:不加旋钮时 split / spawn / tcp 与 monolith 全绿,所以要旋钮才能在主机上走到这条路(§4 R1)。
|
||||
- 修法全在 server,不搬到 client:驱动拒绝时由 staged store 回答(store 路由),store 跟随 copy 做同一次 texel 块搬移(`FollowCopy`)。选「正确字节」,理由见 §2。
|
||||
- monolith 同一缺陷(影子不随 copy 更新)记给 dev(§6)。
|
||||
|
||||
## 2. 设计
|
||||
|
||||
| 部件 | 位置 | 内容 |
|
||||
|---|---|---|
|
||||
| store 路由 | `DirectGLES/WireTextureReadback.inc:352` | 驱动拒绝回读时,store 仅在「整层覆盖、尺寸一致、纹理从未被驱动写过」时回答;转换同 `GetTexImageViaShadowConversion`(打包格式按字原样,其余解成宽 RGBA 逐行转) |
|
||||
| 具名拒绝 / 武装标记 | `DirectGLES/WireTextureReadback.inc:411`,`:416` | 拒绝:`MGLOG_E_ONCE` `texture-readback-store-declined`,回复 error,client Fatal。回答:`MGLOG_W_ONCE` `texture-readback-from-store` |
|
||||
| 驱动写标记 | `MG_Remote/Server/StagedTextureStore.h:479-514` | 按纹理、粘性;只有 `Drop` / `DropAll` 清,`ResetLevels` 不清(附件在重定义后照样写) |
|
||||
| 标记来源 | `DirectGLES/Managers.cpp:10991` | `NoteDriverSideTextureWriteByHandle` 同时标 store:附件、可写 image、`CopyTexSubImage`、生成 mip 都经过它 |
|
||||
| store 跟随 copy | `StagedTextureStore.h:519`,`DirectGLES/Managers.cpp:11014`,调用点 `DirectGLES/DirectGLES.cpp:13670-13688` | 两端同一内部格式(`DirectGLES/Managers.cpp:11036`)、单 upload target(非 cube / 1D array)、源整层覆盖且未被驱动写、目标整层覆盖或 copy 覆盖整层 → store 做同一搬移;否则给目标标驱动写 |
|
||||
| copy 失败 | `DirectGLES/DirectGLES.cpp:13763` | 驱动拒绝 copy 时 store 已搬,补标驱动写 |
|
||||
| 跟随后的 client 上传 | `DirectGLES/Managers.cpp:3197`,`StagedTextureStore.h:573` | client run 是 client 影子(没见过 copy),只落 record 声明写过的盒(regions,无 region 时 union box);放不下则照常收养并标驱动写;`AdoptRun` 兜底同样标(`StagedTextureStore.h:353`) |
|
||||
| 测试旋钮 | `DirectGLES/WireTextureReadback.inc:328` | `MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT=<w>x<h>`,server 读;该尺寸颜色层的 FBO 腿视为驱动拒绝,R32UI 字腿不动 |
|
||||
|
||||
不选「标 GPU 脏」:
|
||||
|
||||
- Espryt 的 `GpuDirty` 语义是「需要从 store 重传」(`DirectGLES/Managers.cpp:8550`),标了会把 store 旧字节传回去盖掉 GPU 上的 copy。
|
||||
- 跟随后其他整层读 store 的路径也拿到对的字节:重铸回读被拒时的 W2-b 重放(`DirectGLES/Managers.cpp:6978`)、整层重传。
|
||||
- 跟随不了的形状(跨格式、renderbuffer 源、被驱动写过的源、cube / 1D array、视图)降为具名拒绝,不给旧字节。
|
||||
|
||||
旋钮按尺寸定界:
|
||||
|
||||
- tcp 的 server 是整条 lane 共用的 `TcpServer.Start` fixture,旋钮只能放进它的 ENVIRONMENT(`MG_IntegrationTest/CMakeLists.txt:3268`)。
|
||||
- 场景只有自身环境里有旋钮时才建 13x7 的纹理,否则 12x6(`CopyImageStoreReadbackScenario.cpp:66`),所以 lane 级旋钮只碰 StoreRead 条目。
|
||||
- 实测:tcp 上无旋钮条目的 server 日志没有 `texture-readback-from-store`,StoreRead 条目有。
|
||||
|
||||
## 3. 场景与登记
|
||||
|
||||
`CopyImageStoreReadbackScenario`(`MG_IntegrationTest/Scenarios/CopyImageStoreReadbackScenario.cpp:251-337`);格式 RGB16、RGBA16_SNORM、RGB16_SNORM、RGBA16,RGB9_E5 为正对照(R32UI 字腿)。
|
||||
|
||||
| 例 | 内容 |
|
||||
|---|---|
|
||||
| `AnUploadedLevelReadsBackExactly` | 上传后读回(对照) |
|
||||
| `ACopiedWindowReadsBackOverTheUpload` | 可变纹理,5x3 窗口 copy 后读目标与源 |
|
||||
| `ACopiedWindowReadsBackFromAnImmutableLevel` | 同上,`glTexStorage2D` |
|
||||
| `APartialUploadAfterTheCopyKeepsTheCopiedWindow` | copy 后在同层别处 `glTexSubImage2D` |
|
||||
| `ARenderbufferSourceLandsInTheTexture` | RGBA16 renderbuffer → 纹理(handle 臂,证明 `+RENDERBUFFER` 闩已死) |
|
||||
|
||||
| 条目 | 臂 | 登记 |
|
||||
|---|---|---|
|
||||
| `DirectGLES.*` / `DirectVulkan.*` | monolith | 整体发现 |
|
||||
| `DirectGLES.{Split,Spawn,Tcp}.*` | 三臂,无旋钮 | `mgl_itest_register_split_arms`(`MG_IntegrationTest/CMakeLists.txt:3252`) |
|
||||
| `DirectGLES.{Split,Spawn,Tcp}.StoreRead.*` | 三臂,旋钮 13x7,前 4 例 | `MG_IntegrationTest/CMakeLists.txt:3270-3296`,带 `integration-gpu` |
|
||||
| `DirectVulkan.{Split,Spawn,Tcp}.CopyStore.*` | Magma 门控三臂 | `MG_IntegrationTest/CMakeLists.txt:3304`;另有 tier 2 信息层 |
|
||||
|
||||
- 三臂对称,`spawn_lane_parity.py` 不需例外行(`StoreRead.` 尾不被 Espryt 的 `CASE` 解析,`scripts/ci/spawn_lane_parity.py:39`)。
|
||||
- store 单元用例 6 个:`MG_Test/Wire/StagedTextureStoreTest.cpp:330-475`。
|
||||
|
||||
## 4. red-once
|
||||
|
||||
| # | 变异 | 载体 | 红 |
|
||||
|---|---|---|---|
|
||||
| R1 | 基线代码 + 旋钮(无 store 路由) | StoreRead 12 条 | 12/12 `Fatal{ReplyError, "ReadPixels"}`,只上传的对照也死 |
|
||||
| M0 | server 跳过 copy | 无旋钮 Espryt 三臂 15 条 | 12 红(4 例 × 3 臂),读到 copy 前字节;上传对照绿 |
|
||||
| M1 | store 既不跟随也不标记 | StoreRead | 9/12 红,读到 copy 前字节(简报的「去掉即陈旧字节」) |
|
||||
| M2 | 不跟随但标记 | StoreRead | 9/12 红,`Fatal{ReplyError}`(具名拒绝) |
|
||||
| M3 | 关掉盒合并与 `AdoptRun` 兜底 | StoreRead 部分上传例 + 单元 | 3 条读到旧 copy 窗口 + `AWholeRunOverAFollowedCopyMarksTheTextureDriverWritten` 红 |
|
||||
| M4 | store 路由忽略驱动写标记 | renderbuffer 例 + 旋钮 12x6(手动) | 旧字节;未变异时是 `texture-readback-store-declined` |
|
||||
| U1 | `FollowCopy` 信任被驱动写过的源 | `ACopyTheStoreCannotVouchForIsNotFollowed` | 红 |
|
||||
| U2 | `ResetLevels` 清驱动写标记 | `TheDriverWrittenMarkOutlivesAResetAndDiesWithTheKey` | 红 |
|
||||
| U3 | `AdoptClientBoxes` 落整条 run | `AClientRunOverAFollowedCopyLandsOnlyItsBoxes` | 红 |
|
||||
| MV | Magma 跳过 copy | Magma 35 条 | 28 红(4 例 × 7 条目),上传对照绿 |
|
||||
| MONO | monolith `GetTexImage` 强制走影子(临时探针,不提交) | `DirectGLES.CopyImageStoreReadbackScenario.*` | 4 个 copy 例 × 4 个 16 位格式读到 copy 前字节;RGB9_E5 与上传对照绿 |
|
||||
|
||||
每次变异后按字节复制还原、`touch`、`cmp` 一致;日志在证据目录(`redonce-*.log`、`red1-head-knob-all.log`、`monolith-probe-shadow.log`)。
|
||||
|
||||
## 5. 死闩清理(无行为变化)
|
||||
|
||||
- `CopyImageSubData+RENDERBUFFER`:原在 `SyncRenderbufferObjectToBackend` 内,条件是 transport≠monolith;唯一调用点只在 monolith 臂(split 臂按句柄处理,`DirectGLES/DirectGLES.cpp:13461-13482`),删去并改写注释(`DirectGLES/DirectGLES.cpp:13437-13444`)。
|
||||
- 镜像函数里过时的「client 侧镜像留给 P8」「由两个 Fatal 兜底」注释改写(`DirectGLES/DirectGLES.cpp:13566-13579`)。
|
||||
- Fatal 普查:abort 点 79 → 78(`DirectGLES.cpp` 15 → 14),族 45 不变;基线用 `fatal_census.py --write-baseline` 重写。
|
||||
|
||||
## 6. monolith 缺陷(ID-P8-3,记给 dev,不在此修)
|
||||
|
||||
- `MirrorCopyImageIntoDestinationShadow` 只对 `HasRedundantPackedEncoding`(仅 RGB9_E5)调用(`DirectGLES/DirectGLES.cpp:13773`);其他格式 copy 后 CPU 影子不变。
|
||||
- 驱动 attach 不了目标格式时 `GetTexImage` 退到影子(`DirectGLES/DirectGLES.cpp:16071`)→ 返回 copy 前字节。设备(Adreno:RGB16 / 16 位 SNORM / 无 norm16 时的 RGBA16)可达。
|
||||
- red-once 见 §4 MONO;修法建议:镜像对所有非压缩同格式 copy 都做,或像 split 一样按纹理记「驱动写过」后拒绝。
|
||||
|
||||
## 7. 未做 / 发现未修
|
||||
|
||||
- `copy-image-shadow-mirror` 的 `MGPipeUnmigratedEmulation` 调用在 transport 下不可达(`DirectGLES/DirectGLES.cpp:13580` 先返回),本包未删;P8-SE 已删调用与名(`DirectGLES/DirectGLES.cpp:13582-13585`、`PipeCatalogueTest.cpp:1448-1450`,[`SE.md`](SE.md))。
|
||||
- `MGPipeTypes.h:1535` 的 P5b 历史注释仍提 `+RENDERBUFFER` 拒绝;是 wire 头注释,未动。
|
||||
- 跨格式 copy 不跟随(store 存规范影子,16 位打包、RGB10 / RGB12 的规范表示不是 GL 位),降为具名拒绝。
|
||||
- 具名拒绝仍是会话 Fatal(client 的 `RequireReadbackReplyComplete`);改成 `GL_INVALID_OPERATION` 需要协议变更,不在本包。
|
||||
- 深度格式经 `BlitDepthTexture2D` 的 copy 由 store 按原样搬移;若该仿真非逐位,store 与 GPU 可能有精度差,只影响驱动拒绝深度回读的情形。
|
||||
- 未上设备验证(简报:只有 S 包用手机)。
|
||||
|
||||
- tcp 的 lane 级旋钮今后会碰到任何读回 13x7x1 颜色层的 tcp 条目;现有场景无 13x7 纹理(grep),现有 357 个 tcp 条目在它下面全过。
|
||||
- 设备上走 store 路由时,`ReadTextureLevelTight` 先打一行 `MGLOG_E_ONCE` `framebuffer status=`(`DirectGLES/WireTextureReadback.inc:269`),随后才是成功的 `texture-readback-from-store`;日志里会有一行 ERROR 在正常路径上。
|
||||
|
||||
## 8. 门
|
||||
|
||||
`gate.sh ~/w7/p8-e p8e`,头 `00d6c248`,dirty 0(`~/w7/notes/p8/e-evidence/gate-p8e.log`)。
|
||||
|
||||
| 项 | 读数 |
|
||||
|---|---|
|
||||
| G1 | `added=0 removed=0`;`.text` a5ba13 与基线相同 |
|
||||
| Fatal 普查 | 78 abort 点 / 20 文件 / 45 族 / 0 未标记(79 → 78,§5) |
|
||||
| link ratchet | 172 不变 |
|
||||
| parity errors | 0 |
|
||||
| protocol pin / wire-declines | revision 5 / 53 行 53 处 0 未记 |
|
||||
| hygiene | 12/12 OK |
|
||||
| unit | 2720 / 2720 |
|
||||
| integration-split / spawn / tcp | 436 / 355 / 357,全过 |
|
||||
| magma split / spawn / tcp / full-split | 256 / 233 / 202 / 641,全过 |
|
||||
| integration-gpu[monolith] / [inproc] | 2725 / 2725 |
|
||||
| retrace(`-L retrace`,236) | 230 过;6 红 = 已知 `iterationrp-in-world` llvmpipe JIT 崩溃(monolith 两后端 + split / spawn 两后端);split 76、spawn 76 条全过(`retrace-p8e.log`) |
|
||||
@@ -0,0 +1,58 @@
|
||||
# P8-F 重分类与死闩清理
|
||||
|
||||
> 包说明:`~/w7/notes/p8/BRIEF-F.md`(树外)。基线 `8d3e2317`,分支 `p8/f`。我们自己的 client 行为不变:四项都是它发不出的形状,或只改注释。
|
||||
|
||||
## 结论
|
||||
|
||||
| 项 | 改动 | 位置 | 之前 | 之后 |
|
||||
|---|---|---|---|---|
|
||||
| 1 | multi-draw 的两个 server 闩改族 | `PipeApplier.cpp:779-784`、`:976-981` | `Fatal{UnmigratedVerb, "MultiDraw{Arrays,Elements}+{CLIENT_INDICES,INSTANCED}"}` | `Fatal{ProtocolCorruption, <同名>}`,仍按名闩住外来 peer |
|
||||
| 2 | `Magma:client-vertex-array` 去掉 P8 阶段标签,改为协议不变量 | `WireDraw.inc:300-307` | `MagmaWireFatal`(UnmigratedVerb 族,名字带 `@P8`) | `MGPipeSessionFail(ProtocolCorruption)`,名字 `Magma:client-vertex-array` 加 location |
|
||||
| 3 | Magma 生成 mip 的"无着色器臂形状"改为具名拒绝 | `WireFramebuffer.inc:1405-1459`(判定)、`:1456`、`:1500`(两个拒绝点) | wire 臂三处 Fatal(旧 `:1427`、`:1452`、`:1489-1493`) | `WireDeclines.def:112` 的 `MipmapShaderFormatOrShape`;判定在 `GrowWireTextureMipChain`(`:1460`)之前,拒绝时不增长 mip 链 |
|
||||
| 4 | `kCapViewportArray`、`kCapNeedsHostIndexBytes`、`kCapNeedsHostUboBytes` 与 index-mirror 哨兵标为保留位 | `MGPipeTypes.h:110`、`:117-123`、`:315-320`、`:332-335`、`:994-999`、`:1007-1009`;`MGPipeHostSpan.h:16-26`;`VertexInputEmit.h:266-267`;`ShaderBufferEmit.h:250-253`;`MG_Backend/Init.cpp:189-191` | 注释说"P5 期间为 0"或"arms the index host mirror" | 注释说 RESERVED、从不发布、位不复用不重编号;只改注释 |
|
||||
|
||||
## 各项依据
|
||||
|
||||
| 项 | 事实 | 出处 |
|
||||
|---|---|---|
|
||||
| 1 | client 把 multi-draw 的 client 索引拼成一个自有 EBO | `EmitTables.cpp:688-709` |
|
||||
| 1 | 自有 EBO 生效时清掉 `kDrawHasUserIndices` | `OwnedDrawInputs.h:45-57` |
|
||||
| 1 | multi-draw 计划的实例数恒为 1、base instance 恒为 0 | `EmitTables.cpp:686` |
|
||||
| 1 | 四个名共用一个 `SessionLatch` 格式串,`PeerLatchTest` 的一行覆盖整组 | `PipeApplier.cpp:779-784`、`PeerLatchTest.cpp:1162-1165` |
|
||||
| 1 | 族选 `ProtocolCorruption`:它的桶就是"peer 发了协议不承载的东西" | `FatalFamilies.def:26-29` |
|
||||
| 2 | client 把每个启用的 client 内存数组转成自有 buffer,指针为空就拒绝整个 draw | `OwnedDrawInputs.h:102-131` |
|
||||
| 2 | `fatal_census.py` 只数 `Fatal{Word` 族词与 abort 点,不按 `@P` 字面计数 | `fatal_census.py:165-167` |
|
||||
| 2 | 普查前后:79 个 abort 点、20 个文件、45 个族词,均不变;不重写基线 | 本包门禁读数 |
|
||||
| 2 | 树内 `@P8` 字面:1(`WireDraw.inc:300`,基线)→ 0 | `git grep '@P8' -- MobileGL scripts tools` |
|
||||
| 3 | monolith 臂对无 BLIT 的格式一直是拒绝(跳过、链不写) | `VulkanRenderer.cpp:12228-12232` |
|
||||
| 3 | 增长前后格式、特性、knob 档位、aspect、view 类型、usage、层窗口都不变 | `VkTextureManager.cpp:2884-2995` |
|
||||
| 3 | 深度 pass 对本函数交给它的图像只会因"格式不能同时采样和作深度附件"拒绝 | `WireDepthMipmap.inc:58-81` |
|
||||
| 3 | 深度 pass 若仍拒绝(两份清单漂移),走同一行拒绝,不结束会话 | `WireFramebuffer.inc:1491-1502` |
|
||||
| 4 | 生产者 0:唯一的 `SetCapabilityBits` 只置 XFB、query、resident、run-ahead 位 | `MG_Backend/Init.cpp:202-255` |
|
||||
| 4 | 消费者 0:`kCapViewportArray` 在树内只有枚举定义;`kMGPipeBindElementArray` 只在 bind mask 表里被置 | `MGPipeTypes.h:110`、`ResourceTracker.h:95` |
|
||||
| 4 | `0xFFFFFFFF` 哨兵无编码方;`SegmentTable::Resolve` 把它当未知段 | `MGPipeHostSpan.h:26`、`PipeWireCodec.cpp:458-465` |
|
||||
| 4 | pull 构建只改注释,逐文件行数不变;G1 `added=0 removed=0`,`.text` 与基线同为 `a5ba13` | 本包门禁读数 |
|
||||
|
||||
## 新门与 red-once
|
||||
|
||||
| 项 | 门 | 变异 | 载体 | 观测到的红 |
|
||||
|---|---|---|---|---|
|
||||
| 1 | `PeerLatchTest` 行 `MultiDrawInstanced` 期望 `Fatal{ProtocolCorruption, "MultiDrawArrays+INSTANCED"}` | 闩的族改回 `UnmigratedVerb` | `FuzzArm2/PeerLatchSite.*/MultiDrawInstanced`、`PeerLatch.SiteMap` | 两例红:首行 `Fatal{UnmigratedVerb, ...}` 不含期望标记;站点图报该站点未映射 |
|
||||
| 3 | `F1WireScenario.GenerateMipmapWithoutAShaderArmShapeDeclinesAndKeepsTheSession`(3D RGBA8,`MGITEST_MAGMA_FORCE_SHADER_MIPMAP=1`) | 拒绝改回 `MagmaWireFatal` | `DirectVulkan.{Split,Spawn}.ShaderMipDecline.` 两例(当时前缀为 `.ShaderMip1.`,后改名,见下) | 两例 `Subprocess aborted`,server 日志 `Fatal{UnmigratedVerb, "Magma:mipmap-shader-format-or-shape format=37 extent=4x4x4 ..."}` |
|
||||
| 3 | 同上(前提) | 无(新用例落在未改的基线代码上) | 同上 | 同样两例 abort:前提成立 |
|
||||
| 3 | `spawn_lane_parity.py` 的 `.ShaderMipDecline.` 例外行 | 删掉该行 | `spawn_lane_parity.py build-split` | rc 1:`the tcp arm does not match the split arm: missing=['DirectVulkan.ShaderMipDecline.F1WireScenario.GenerateMipmapWithoutAShaderArmShapeDeclinesAndKeepsTheSession']` |
|
||||
| 2 | 普查读数 | — | `fatal_census.py` | 无变化:该脚本不计阶段标签(见上) |
|
||||
|
||||
- 新用例只登记 split + spawn:knob 由 server 读,tcp fixture 带不过去。登记在 `MobileGL/MG_IntegrationTest/CMakeLists.txt:3484-3502`,前缀 `.ShaderMipDecline.`。
|
||||
- 该尾自成一行加进 `MAGMA_SERVER_ENV_KNOB_NO_TCP`(`spawn_lane_parity.py:141-143`):脚本要求每个尾恰好命中一个用例,借用 `.ShaderMip1.` 会命中两个,门禁时 parity 报 1 个错,已改。
|
||||
- Espryt 不涉及第 2、3 项(Magma 专属);新用例在 DirectGLES 上按后端名跳过。第 1 项在后端无关的 applier 里。
|
||||
|
||||
## 发现但未修
|
||||
|
||||
| 发现 | 证据 | 影响 |
|
||||
|---|---|---|
|
||||
| Magma wire 原生 blit 生成 3D mip 时把 depth 当层数传给 `vkCmdBlitImage`(layerCount=4,图像 arrayLayers=1) | `WireFramebuffer.inc:1612`、`VkTextureManager.cpp:2738-2741`;验证层报 `VUID-vkCmdBlitImage-srcImage-00240`、`-srcSubresource-01707`、`-dstSubresource-01708`(临时探针,未提交) | 只在 split;lavapipe 容忍;其他驱动上 3D 生成 mip 行为未定义 |
|
||||
| 深度/模板生成 mip 的拒绝只记日志,不计入 `WireDeclineTally` | `WireFramebuffer.inc:1397-1404` | `MGWIRE-DECLINES` 看不到这类拒绝 |
|
||||
| `GenerateWireDepthMipLevel` 的注释说会拒绝 1D,代码只拒绝 `is3D`,而调用方从不设置它 | `WireDepthMipmap.inc:66`、`WireFramebuffer.inc:1495` | 无原生 blit 的 1D 深度链会进入 pass(推断,未测) |
|
||||
|
||||
- monolith 缺陷:无。
|
||||
@@ -1,10 +1,2 @@
|
||||
# P8 集成者裁定日志(server 侧仿真缺口与 split 覆盖)
|
||||
|
||||
> 形式沿用 [`../p11/INTEGRATOR-DECISIONS-P11.md`](../p11/INTEGRATOR-DECISIONS-P11.md):一条裁定一个 ID,只记「定了什么、为什么、影响哪些文件」。计划见 [`PLAN-P8.md`](PLAN-P8.md)。
|
||||
|
||||
| ID | 日期 | 裁定 | 理由 | 影响 |
|
||||
|---|---|---|---|---|
|
||||
| ID-P8-1 | 2026-09-29 | **重定界**(用户批准):原范围在 `README.md` 与路线图行里划掉保留;方向改为补 server 侧缺口与 split 覆盖;原 10 项里 6 项与 2 个门、开放问题 9 关闭(`PLAN-P8.md`「已关闭」表)。 | 只读核查逐项对代码:split 可达的仿真拒绝只剩 Espryt 生成 mip 两名;client 侧工作已由 P5b–P9 完成。 | `ROADMAP.md`、`notes/p8/` |
|
||||
| ID-P8-2 | 2026-09-29 | 门改写:覆盖门 = 归一化后 split ⊆ monolith ∪ 豁免表;create-indirect 往返门 = 多帧设备 trace 加载帧非 `ResourceCreate` 等待 = 0。 | 原两门按字面不可达 / 是空的(trace 只 1 帧)。 | A 包、P8-0 |
|
||||
| ID-P8-3 | 2026-09-29 | G1 不变;各包 split 半边放在 `MOBILEGL_BUILD_DISAGGREGATED` 下。monolith 半边(例如 B2 的 CPU 滤波读陈旧影子)若 red-once 证实,在 dev 上单独修再合并(用户同意)。 | 沿用 P9 / P11 做法。 | B、C、E |
|
||||
| ID-P8-4 | 2026-09-29 | 第一波七包并行(P8-0、A、B、C、D、E、F,树 `~/w7/p8-<包>`,分支 `p8/<包>`,集成树 `~/w7/p9-main` 分支 `p8/main`);G 等 P8-0 的测量;C、D 为 P13 前置。设备只由 P8-0 使用(红米,约半天,用户同意)。 | 各包改动区域不重叠(`DirectGLES.cpp` 按行段分开)。 | 全部 |
|
||||
| ID-P8-19 | 2026-09-30 | **P8 收官**(候选头 `49430538`)。出口设备检查(红米,两后端 × monolith / spawn,77 格 / 臂):66 行与 P8-0 基线在 1e-6 内一致,**无一格变差**;create-instancing × Espryt × monolith 0.870 → 0.99998;低于 0.99 的只有已知集合(create-indirect 不适用、1.21.11-main-menu、derivative-main Espryt、photon)。P12 跨机门 (b) 复跑:DirectGLES openra 1.0 / rd12 0.999883010(与 P12 记录一致),DirectVulkan openra 1.0 / rd12 0.999884191;server 自有窗口上 openra 两后端 1.0,Espryt 第一次发出 640×480 尺寸事件(SE 的副作用),转屏会话存活。trace split 双后端 SSIM 门(主机 230/236,仅已知 6 例)成立。收官不派 agent 审:契约 `CONTRACT-P8.md` 各条对代码逐条核对,G1 整阶段符号 0 / 0。 | create-indirect × Magma × spawn 由 0.84 变为每次丢设备(该 fixture 的 indirect 命令本身是乱的;推断 D 原生化后乱命令直达 GPU,monolith 臂一直如此且基线上也偶发丢设备),入债。 | `CONTRACT-P8.md`;树外 `~/w7/notes/p8/x-report.md` |
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
# P8-MF:dev 的 Adreno 830 部分冲刷修复镜像到 push 梯子
|
||||
|
||||
> 2026-09-30,分支 `p8/mf`(基线 `37174242` = `p8/main` 合入 dev `f973008c`)。简报 `~/w7/notes/p8/BRIEF-MF.md`;全文 `~/w7/notes/p8/mf-report.md`;证据(设备归档、探针日志、脚本、APK 哈希)`~/w7/notes/p8/mf-evidence/`(树外)。只动 Espryt:Magma 没有这条梯子,create-instancing × Magma 本来就是 0.999983725(MD)。
|
||||
|
||||
## 1. 改动
|
||||
|
||||
| 提交 | 位置 | 内容 |
|
||||
|---|---|---|
|
||||
| `ac9ab078` | `MobileGL/MG_Backend/DirectGLES/Managers.cpp:1520` | `FlushPendingRangesFrom` 的 ring 档每次 `glCopyBufferSubData` 后盖 `ringCopyRetireSerial = CurrentFrameSerial() + 1`(同 pull 臂 `Managers.cpp:1808`) |
|
||||
| `ac9ab078` | `MobileGL/MG_Backend/DirectGLES/Managers.cpp:1496` | 逐 range 读 `ringCopyRetireSerial > CompletedFrameSerial()`(同 pull 臂 `:1785`),传给 `InvalidateFlushAccessFor` |
|
||||
| `ac9ab078` | `MobileGL/MG_Backend/DirectGLES/Managers.h:1222` | 纯函数 `InvalidateFlushAccessFor` 新参数 `ringCopyInFlight`:部分范围且拷贝未退役 → 0(走 ring,GPU 序排在拷贝后);整 buffer 孤立映射豁免 |
|
||||
| `ac9ab078` | `MobileGL/MG_Test/Buffer/SplitBufferTest.cpp:865` | `EsprytFlushLadder.APartialRangeDoesNotOvertakeAQueuedRingCopy`(pull 构建同名 skip 桩 `:886`);原 5 例补 `false` |
|
||||
| `9c24a14d` | `scripts/p3a_untouched_regions.sh`、`scripts/p4a_untouched_regions.sh` | G5 第十行 `FlushPendingRangesNow` 也改为钉住行;两条梯子一起重钉在审过的修后正文:Now `c40cae66…`、From `33bc4cb8…`,提交 `ac9ab078`,裁定 ID-P8-14 |
|
||||
|
||||
- pull 臂 `FlushPendingRangesNow` 未动:`37174242` 的正文 = `37da3c3a` 正文 + 恰好 `f973008c` 的那一块(dev 自己的正文另缺 feat 既有的 PipeStats 块,所以 `f973008c` 处哈希是 `c85443ce…`,不是钉值)。
|
||||
- 不盖 `DrainResidentWritesNow` 的 ring 拷贝:目标是收养的不可变 store,永不走范围失效映射(dev 同样不盖)。
|
||||
|
||||
## 2. 设备(红米 2f7cbe2e,create-instancing × Espryt,SSIM)
|
||||
|
||||
| APK(lib sha256 前 8) | monolith ×3 | spawn ×3(pbuffer) |
|
||||
|---|---|---|
|
||||
| 基线 `37174242`(`5ed6d6dc`) | 0.870389049 ×3 | 0.999984504 ×3 |
|
||||
| 修复 `9c24a14d`(`34d826c7`) | **0.999984504 ×3** | 0.999984504 ×3 |
|
||||
| red-once:守卫关(`7938ff89`) | 0.870389049 ×3 | — |
|
||||
|
||||
回归(Espryt monolith ×1,基线 → 修复):sodium 0.999993736 → 0.999993736;common-mods 0.999869638 → 0.999869638;improved-transparency-26.3 0.999683991 → 0.999683991。
|
||||
|
||||
## 3. 为什么 spawn 不受影响:同样撞上,但拷贝在映射前已提交
|
||||
|
||||
探针 APK(守卫关 = 基线行为,`FlushPendingRangesFrom` 每个 range 一行日志,未提交;`04e09442`),monolith / spawn 各 1 次;主机 llvmpipe 三臂同一探针数字完全一致。
|
||||
|
||||
| 量 | monolith | spawn(server) |
|
||||
|---|---|---|
|
||||
| SSIM | 0.870389049 | 0.999984504 |
|
||||
| 冲刷的 range / store | 3340 / 11 | 12956 / 26 |
|
||||
| ring 拷贝 | 3337 | 3337 |
|
||||
| **部分失效映射且该 store 仍有未退役 ring 拷贝** | **2**(store 38、63,`[3518480,+217120)`、`[3279760,+209360)`) | **2**(同偏移、同大小的两个 arena) |
|
||||
| 整 buffer 孤立映射 | 1 | 9617(158 MB;24 B–307 KB 的小 store,monolith 下它们不进这条梯子) |
|
||||
| 该 arena 上次 ring 拷贝与部分映射之间,其他 store 的 range | 4,其中整 buffer 映射 0 | 32 / 34,其中整 buffer 映射 28 / 30 |
|
||||
|
||||
- server 走的是同一条梯子:客户端的 `glCopyBufferSubData` 是 CPU 拷贝(`MobileGL/MG_State/GLState/BufferState/BufferObject.cpp:809-831`),以 `resource_subdata` 到 server,`Ops_H_SubData` 排队(`MobileGL/MG_Backend/DirectGLES/Managers.cpp:2469`),draw 时 `EnsureBufferResourceForHandle` 冲刷(`Managers.cpp:4247`)。
|
||||
- T0 只收养了 16 MiB 持久暂存 buffer(server 日志 `T0 imported store {slot=1, gen=1} - 16777216 bytes`),3.8 MiB arena 不是 T0,不走 `Managers.cpp:2412` 的 resident 分支。
|
||||
- 机理探针(守卫关 + 每次 ring 拷贝后 `glFlush`,未提交;`754c5d64`):monolith 0.999984504。拷贝只在部分映射到来时仍未提交才会丢。
|
||||
- 结论:spawn 以同样的 tier 组合撞上同样两处,但 server 在拷贝与映射之间多做了 28–30 次其他 store 的整 buffer 孤立映射,拷贝在映射前已被提交(推断:具体是哪一步触发提交未单独验证)。spawn 是碰巧躲过;修复后 spawn 不变(0.999984504 ×3)。
|
||||
|
||||
## 4. red-once
|
||||
|
||||
| 门 | 变异 | 载体 | 红 |
|
||||
|---|---|---|---|
|
||||
| 设备修复 | `Managers.h:1222` 守卫改 `false && …`(盖戳保留),APK `7938ff89` | create-instancing × Espryt × monolith ×3 | 0.870389049 ×3 |
|
||||
| 新单测(守卫) | 同上,主机 | `EsprytFlushLadder.APartialRangeDoesNotOvertakeAQueuedRingCopy` | `SplitBufferTest.cpp:868`:得 6(WRITE\|INVALIDATE_RANGE),期望 0 |
|
||||
| 新单测(整 buffer 豁免) | 守卫去掉 `!wholeBuffer &&` | 同上 | `SplitBufferTest.cpp:871`:得 0,期望 10(WRITE\|INVALIDATE_BUFFER) |
|
||||
| G5 重钉 | 提交 `ac9ab078` 对旧脚本(`HEAD:` 版本) | `p3a`/`p4a` `37da3c3a HEAD` | 两脚本 rc=1:首个移动 `FlushPendingRangesNow`,另移动 `FlushPendingRangesFrom` |
|
||||
| G5 From 钉值 | 新脚本对基线提交 | `p3a`/`p4a` `37da3c3a 37174242` | rc=1:首个移动 `FlushPendingRangesFrom`,并报 "IS A PINNED ROW (ID-P8-14)" |
|
||||
|
||||
- 每个探针都以拷回 + 比对 + `touch` 恢复(`restored identical: True`、`git diff` 干净)。
|
||||
- G5 `--self-test`:p3a 两条梯子各有 pin-precedence 控制与一 token 变异控制,全过;p4a 10 个负控制全触发且点名。
|
||||
|
||||
## 5. 门(`gate.sh ~/w7/p8-mf p8mf`,头 `9c24a14d`)
|
||||
|
||||
| 项 | 结果 |
|
||||
|---|---|
|
||||
| G1 | 符号增 0 减 0(clang 22.1.6);`.text` `0xa5ba43`,与本树基线构建相同 |
|
||||
| fatal census / link ratchet / parity / 协议修订 | 78 / 172 不变 / 0 / 5 |
|
||||
| wire-declines | 58 行,59 站点 |
|
||||
| 卫生 | 14/14 OK(含 `g5_p3a`、`g5_p4a`) |
|
||||
| unit | 2722 / 2722(+1 新单测) |
|
||||
| split / spawn / tcp | 738 / 652 / 664 全过 |
|
||||
| Magma split / spawn / tcp / full-split | 271 / 248 / 216 / 671 全过 |
|
||||
| gpu monolith / inproc | 两臂各 3695 / 3699,同 4 例:`DirectGLES.Tcp.UnlocatedIoBlocks.*` 3 例 + 其 fixture `TcpServer.Start.P8aUnlocatedIoBlocks`(负载下);单独重跑两臂各 31/31 过 |
|
||||
| retrace(`ctest -L retrace`,monolith + .SPLIT + .SPAWN,两后端) | 230 / 236,失败只有已知 6 例 iterationrp(主机 llvmpipe JIT) |
|
||||
|
||||
## 6. 未做 / 遗留
|
||||
|
||||
| 项 | 原因 |
|
||||
|---|---|
|
||||
| server 对小 store 反复整 buffer 孤立映射(create-instancing 一次重放 9617 次 / 158 MB,monolith 1 次) | 性能项,不是本包;它恰好让 spawn 躲过本缺陷 |
|
||||
| 其他 GPU 写(SSBO、xfb)后接部分失效映射是否同样丢 | 未观察到;守卫只覆盖 ring 拷贝(同 MD) |
|
||||
| 两臂之间的注释仍写 pull 臂冻结于 `5cb826b0`、From 钉于 `3e298c9a`(`MobileGL/MG_Backend/DirectGLES/Managers.cpp:1376`、`:1535`、`:1553`;`MobileGL/MG_Test/Buffer/SplitBufferTest.cpp:877`) | ID-41 起就过时,ID-P8-14 后 pull 行也改为钉住;都在哈希正文之外,留给下次改这段的人 |
|
||||
@@ -42,3 +42,31 @@
|
||||
- **trace split 双后端 SSIM ≥ 0.99**(含两个 `coherent_as_flush` fixture),出口再跑。
|
||||
- **P13 前置**:C、D 先于 P13 落地,否则删掉 monolith 臂后继承 split 臂的缺陷。
|
||||
- **G1**:pull 构建不变;split 半边在 `MOBILEGL_BUILD_DISAGGREGATED` 下。monolith 半边若 red-once 证实有缺陷,在 dev 上单独修再合并(ID-P8-3)。
|
||||
|
||||
## 第二波(2026-09-30,ID-P8-13)
|
||||
|
||||
| 包 | 树 / 分支 | 内容 |
|
||||
|---|---|---|
|
||||
| SE(split,Espryt + 文档) | `~/w7/p8-se` / `p8/se` | 默认帧缓冲深度在 Espryt spawn / tcp 读 0(A 的 pending-fix 豁免);B2 的 CPU mip 回退看 E 的 driver-written 标;D 的 case 3 在 Espryt split 臂放开(C 已落地);`PipeCatalogueTest` 名单去死名 `copy-image-shadow-mirror` 并加"名单 = 调用点"的门;B / C / D / E 包说明的行号漂移 |
|
||||
| SV(split,Magma) | `~/w7/p8-sv` / `p8/sv` | 3D 纹理原生 mip blit 把 depth 当 `layerCount`(VUID-vkCmdBlitImage-srcImage-00240);深度模板 mip 拒绝补 `WireDeclineTally` 行;`GenerateWireDepthMipLevel` 拒 1D;wire 臂 `DispatchComputeIndirect` 原生化 |
|
||||
| MD(dev,设备) | `~/w7/dev-p8-md` / `devfix/p8-md` | create-* 在 Adreno 830 上的三条:Espryt create-instancing monolith SSIM 0.870;Espryt 每次 indirect draw 整 buffer 同步回读(设备上挂死 > 10 分钟);Magma 计算写与 indirect 读之间无依赖(可能就是 ID-P7-4)。先在 dev 构建上复现,复现才在 dev 上修;只在 feat 构建上出现的交回集成者 |
|
||||
|
||||
### monolith 缺陷(ID-P8-3)的取舍
|
||||
|
||||
12 条(13 条报告,C、D 重复一条)都在 monolith 专属臂里;P13 把 monolith 换到第一波已修好的记录臂上,它们随之消失。按 P8-0 的真实内容命中取舍:
|
||||
|
||||
| 缺陷 | 来源 | 真实内容命中 | 做法 |
|
||||
|---|---|---|---|
|
||||
| Espryt create-instancing monolith 画面错(0.870) | S | Create(Adreno) | **MD 修(dev)** |
|
||||
| Espryt indirect draw 整 buffer 同步回读、设备挂死 | S | Create(Adreno) | **MD 修(dev)** |
|
||||
| Magma 计算写 → indirect 读无依赖 | D | Create(推断,ID-P7-4) | **MD 修(dev)** |
|
||||
| Espryt `*IndirectCount` / 原生 indirect `gl_BaseVertex` / fp64 收窄读未同步影子 | C | 0 | 留给 P13 |
|
||||
| Magma `glMultiDrawArraysIndirectCount` CPU 臂读未同步影子 | C、D | 0 | 留给 P13 |
|
||||
| Magma 录制中途 `SyncGpuWrites` → SIGSEGV | C | 0 | 留给 P13 |
|
||||
| Espryt RGB16F / RGB32F CPU 滤波读陈旧影子;R11F / 深度链无视 BASE / MAX | B | 0 | 留给 P13 |
|
||||
| Magma 无 BLIT 颜色格式缺着色器 mip 臂 | B | 0 | 留给 P13 |
|
||||
| Espryt 拷贝后 `glGetTexImage` 读拷贝前影子 | E | 0 | 留给 P13 |
|
||||
|
||||
## 收官(2026-09-30,ID-P8-19)
|
||||
|
||||
两波全部合入;第二波另加 MF(feat 的 push 阶梯镜像 dev 修复)与出口设备检查 X。结果见 [`README.md`](README.md)。
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
# P8 — ~~emulation 下放 + 索引宿主镜像 + 协议广度~~ → server 侧仿真缺口与 split 覆盖(进行中,2026-09-29 起)
|
||||
# P8 — ~~emulation 下放 + 索引宿主镜像 + 协议广度~~ → server 侧仿真缺口与 split 覆盖(已收官,2026-09-30)
|
||||
|
||||
> **2026-09-29 重定界**(用户批准):只读核查发现原范围 10 项里 6 项已由前序阶段完成,剩下的缺口都在 server 侧,不是"搬到 client"。计划 [`PLAN-P8.md`](PLAN-P8.md);裁定 [`INTEGRATOR-DECISIONS-P8.md`](INTEGRATOR-DECISIONS-P8.md)。下面原范围照录并划掉,不删。
|
||||
|
||||
## 重定界后的包
|
||||
|
||||
| 包 | 内容 |
|
||||
|---|---|
|
||||
| P8-0 | 普查:设备与主机 trace 语料上各拒绝点 / 仿真谓词的命中数;split 日志与逐 op 等待 |
|
||||
| A | 覆盖对齐:monolith 用例登记到 split / spawn / tcp,豁免表 + 归一化名单门 |
|
||||
| B | Espryt 生成 mip:存储检查读计划窗口(B1);RGB16F / RGB32F 在 server 完成(B2) |
|
||||
| C | Espryt server 暂存影子与 GPU 写对账 |
|
||||
| D | Magma wire 臂原生 indirect(不再 CPU 展开 + 等 GPU 空闲) |
|
||||
| E | CopyImage 在 server store 上处理 |
|
||||
| F | 死闩清理与重分类(无行为变化) |
|
||||
| G | 大 blob 分片:按 P8-0 的测量决定做不做 |
|
||||
| 包 | 内容 | 结果 |
|
||||
|---|---|---|
|
||||
| P8-0 | 普查:设备与主机的 trace 语料上各拒绝点 / 仿真谓词的命中数 | ✅ 真实内容只 D 命中;G 不做;create-indirect 门在多帧 trace 上成立([`S.md`](S.md),ID-P8-5) |
|
||||
| A | 覆盖对齐 | ✅ 246 例登上三臂,`split_coverage.py` 进门([`A.md`](A.md),ID-P8-7) |
|
||||
| B | Espryt 生成 mip | ✅ 生成窗口 + RGB16F / RGB32F 在 server 完成,两个 split 名退役([`B.md`](B.md),ID-P8-8) |
|
||||
| C | Espryt server 暂存影子与 GPU 写 | ✅ 基线 21/21 红 → 绿([`C.md`](C.md),ID-P8-9) |
|
||||
| D | Magma wire 臂原生 indirect | ✅ create-indirect 每次整 GPU 等待 321 → 0([`D.md`](D.md),ID-P8-10) |
|
||||
| E | CopyImage / 驱动拒读 | ✅ 前提改正:真实缺口是驱动拒读时会话 Fatal,改由 server store 作答([`E.md`](E.md),ID-P8-11) |
|
||||
| F | 死闩清理与重分类 | ✅([`F.md`](F.md),ID-P8-6) |
|
||||
| G | 大 blob 分片 | 不做(ID-P8-5) |
|
||||
|
||||
第一波集成头 `39cd8fb7` 整套门全绿(ID-P8-12)。
|
||||
|
||||
| 第二波 | 内容 | 结果 |
|
||||
|---|---|---|
|
||||
| SE | Espryt split 余项 + 文档行号 | ✅ spawn / tcp 默认帧缓冲发布 surface;CPU mip 拒读时具名拒绝;名单对调用点的门([`SE.md`](SE.md),ID-P8-15) |
|
||||
| SV | Magma split 余项 | ✅ 3D mip blit 1 层、深度 mip 拒绝入账、1D 深度拒绝、`glDispatchComputeIndirect` 原生([`SV.md`](SV.md),ID-P8-16) |
|
||||
| MD + MF | Create 在 Adreno 830 上 | ✅ dev `f973008c` + push 阶梯镜像:create-instancing × Espryt × monolith 0.870 → 0.99998;create-indirect 坏在 fixture(对齐 16 vs 64),不是 MobileGL([`MF.md`](MF.md),ID-P8-14) |
|
||||
|
||||
契约 `MobileGL/MG_Remote/CONTRACT-P8.md`;收官 ID-P8-19(出口设备检查无一格变差,P12 跨机门复跑一致)。
|
||||
|
||||
## 摘要(原文,已划掉)
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# P8-0 普查(S 包)
|
||||
|
||||
> 插桩不提交(树外 `~/w7/notes/p8/s/instrument.diff`);全文 `~/w7/notes/p8/s-report.md`。裁定 ID-P8-5。设备计数是下限(Android 不跑退出 dump,按 10 / 600 帧周期 dump)。
|
||||
|
||||
## 覆盖
|
||||
|
||||
| 语料 | 臂 | 数 |
|
||||
|---|---|---|
|
||||
| 主机 trace | monolith / inproc,两后端 | 80 / 78 次重放 |
|
||||
| 红米 trace APK(插桩) | monolith / spawn `--matrix` | 77 / 77,达 0.99:68 / 70 |
|
||||
| 红米未插桩对照 | create-indirect、create-instancing | 7 次,区分设备缺陷与插桩 |
|
||||
| FCL 实机 | 原版 26.3-rc-3,两后端 | 约 15,000 帧;无 Iris / Complementary / Create(未下载) |
|
||||
|
||||
## 命中(真实内容)
|
||||
|
||||
| 谓词 | 主机 | 设备 trace | FCL | 结论 |
|
||||
|---|---|---|---|---|
|
||||
| Magma wire indirect CPU 展开(D) | create-indirect 322 次调用 | create-indirect 321 次 | Magma inproc 44,768 次调用 / 13,028,030 draw | **唯一真实命中** |
|
||||
| B1 split 存储检查会失败 | 0 / 1375 次生成(R11F 1357、D16 18) | 0 / 391 | 0 | 路径热、失败形状 0 |
|
||||
| B2 RGB16F / RGB32F 生成 mip | 0 | 0 | 0 | 未见(两条 Complementary trace 只有 R11F 与 RGBA8) |
|
||||
| C GPU 写过的字节被 CPU 读 | 0(只有指针解析 322/322) | 0 | 0 | 未见 |
|
||||
| E 拷贝后经影子 `glGetTexImage` | 0(1,288 次拷进 DEPTH / R32F,无一回读) | 0 | 0 | 未见 |
|
||||
| Magma 生成 mip 着色器形状 | 0 | 0 | 0 | 未见 |
|
||||
|
||||
## G(大 blob)
|
||||
|
||||
| 量 | 最大值 | arena / 4 | 比例 |
|
||||
|---|---|---|---|
|
||||
| program archive | 354,846 B(complementary-unbound) | 8 MiB(SEG_STAGE 32 MiB) | 4.2 % |
|
||||
| `draw_vbo` 记录 | 1,936 B(156 段) | 2 MiB(SEG_CMD / 4) | 0.1 % |
|
||||
|
||||
结论:不做分片。
|
||||
|
||||
## create-indirect 门(ID-P8-2)
|
||||
|
||||
| trace | 帧 | 加载帧非 `ResourceCreate` 等待 |
|
||||
|---|---|---|
|
||||
| rd12 odinlite(设备 spawn,两后端) | 250 | 0 |
|
||||
| improved-transparency-26.3(设备 spawn,两后端) | 1210 | 0 |
|
||||
| create-indirect(1 帧) | 1 | 8(设备)/ 10(主机):`ResourceReadback` 6 + `MapPersistent` |
|
||||
| FCL 原版 26.3(实机 inproc) | ~15,250 | 16(`MapPersistent`) |
|
||||
|
||||
## 设备上基线就有的问题(两臂都有,不归 P8)
|
||||
|
||||
- create-indirect 在 Adreno 830 上 kgsl `Preemption Fault`(两后端两臂;ID-P7-4)——**原因已查明**(ID-P8-14):fixture 在桌面上抓,SSBO 偏移对齐 16,Adreno 要求 64,被拒的绑定让 indirect 命令写乱;不是 MobileGL 缺陷。
|
||||
- 1.21.11-main-menu(Espryt 0.890、Magma 0.165)、derivative-main(Espryt 0.851)SSIM < 0.99。
|
||||
- create-instancing × Espryt × monolith 0.870(spawn 0.99998)——monolith 缺陷,进第二波 dev。
|
||||
@@ -0,0 +1,131 @@
|
||||
# P8-SE:Espryt split 残项与 P8 包说明的行号漂移
|
||||
|
||||
> 2026-09-30,分支 `p8/se`(基线 `cbbaf77f`)。简报 `~/w7/notes/p8/BRIEF-SE.md`;证据 `~/w7/notes/p8/se-evidence/`(树外)。第二波,ID-P8-13。
|
||||
|
||||
## 1. 结论
|
||||
|
||||
| 项 | 结果 | 位置 |
|
||||
|---|---|---|
|
||||
| 1 默认帧缓冲深度 / 模板在 Espryt spawn / tcp 读 0 | 修;A 的 pending-fix 豁免行删去,用例登上三臂(含 `ForcedDs.` 三臂) | `MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp:16239` |
|
||||
| 2 B2 的 server CPU mip 臂 × E 的驱动写标 | 修;驱动读回被拒且纹理被驱动写过时具名拒绝 `generate-mipmap-store-declined`,不读 store | `DirectGLES.cpp:13066`、`:13134` |
|
||||
| 3 D 的 case 3 在 Espryt split 臂放开 | 放开,三臂 + inproc A/B 绿;Espryt monolith 跳过保留(证红) | `MobileGL/MG_IntegrationTest/Scenarios/WireIndirectDrawScenario.cpp:306` |
|
||||
| 4 `PipeCatalogueTest` 名单 = 调用点 | 删 `copy-image-shadow-mirror` 调用与名(G1 不变);新 lint 进 CI 与 unit 车道 | `scripts/ci/unmigrated_emulation_sites.py` |
|
||||
| 5 A–F、S 包说明行号漂移 | 213 处引用逐条对内容;87 处按内容重定位 + E.md 一行改写;S.md 无引用 | §7 |
|
||||
|
||||
- monolith 缺陷:本包未发现新的(case 3 的 Espryt monolith 红是 C 已记的 OQ15 一条)。
|
||||
|
||||
## 2. 项 1:根因与修法
|
||||
|
||||
| 事实 | 出处 |
|
||||
|---|---|
|
||||
| 发布函数原 guard `!defaultFBOInfo \|\| ...` 在 `OnSurfaceChanged` post 之前 return | `DirectGLES.cpp:16229`(函数)、`:16360`(post) |
|
||||
| spawn / tcp 的 server 进程没有前端,`pDefaultFramebufferInfo` 为空(临时探针:spawn `(nil)`,inproc 非空) | 探针未提交 |
|
||||
| 结果:client 的默认帧缓冲 depth / stencil 留在占位格式 `Depth32FStencil8` | `MobileGL/MG_Impl/Init.cpp:33`、`:37` |
|
||||
| 探针:spawn client 报 depth 32 / `GL_FLOAT`;inproc 报 24 / `GL_UNSIGNED_NORMALIZED`(pbuffer 是 D24S8) | `DirectGLES.cpp:16498` |
|
||||
| 用例按报告分配 D32F_S8,server 驱动拒绝 D24S8→D32F_S8 的深度 / 模板 blit,只打 `the depth/stencil aspect was dropped`;颜色照过,client 无 GL 错误 | `DirectGLES.cpp:10926` |
|
||||
| inproc 绿是巧合:client 与 server 同进程共用该指针 | — |
|
||||
| Magma 的发布从不看该指针(callback 臂直接 post),三臂一直绿 | `MobileGL/MG_Backend/DirectVulkan/Renderer/SwapchainObject.cpp:346` |
|
||||
| 修:`MOBILEGL_PIPE_PUSH` 下 callback 在场即发布,只有 monolith 臂写占位;pull 构建保留原句(`#else`) | `DirectGLES.cpp:16239`、`:16325` |
|
||||
| 登记:`mgl_itest_register_split_arms` 三臂;`ForcedDs.` 过滤器不再减掉该例 | `MobileGL/MG_IntegrationTest/CMakeLists.txt:4866`;`MobileGL/MG_IntegrationTest/P8Coverage.cmake:177-178` |
|
||||
| 豁免表 pending-fix 类清空 | `scripts/data/split_coverage_exemptions.txt:64-65` |
|
||||
|
||||
- 顺带生效:P12 服务器自有窗口在 spawn 下的 extent 发布(`g_publishWindowExtent`,`DirectGLES.cpp:16656`)被同一 guard 挡住、从未发出过;现在会发出,client 走 `ApplySurfaceChangedToClient` 的带 extent 臂(`MobileGL/MG_Remote/Client/ClientSession.cpp:325`)。主机无覆盖,需设备确认。
|
||||
|
||||
## 3. 项 2:CPU mip 臂的 store 路由
|
||||
|
||||
| 事实 | 出处 |
|
||||
|---|---|
|
||||
| E 的驱动写标按纹理、粘性 | `MobileGL/MG_Remote/Server/StagedTextureStore.h:496-502` |
|
||||
| split 的 `GenerateMipmap` 在进 `GenerateMipmapByRecord` 前无条件记驱动写:CPU 臂读 store 时标恒为真 | `DirectGLES.cpp:13296` |
|
||||
| 所以在记写之前快照 `driverWrittenBefore` 并下传;否则 store 路由(B 为不可附着存储设计的)永远拒绝 | `DirectGLES.cpp:13291`、`:13305` |
|
||||
| store 路由拒绝条件:view、无 store、驱动写过、未整层覆盖、尺寸不符 → `MGLOG_E_ONCE` `generate-mipmap-store-declined`,层不动,不 Fatal | `DirectGLES.cpp:13066`、`:13134` |
|
||||
| E 的旋钮原只在 `ReadTextureImageWire` 查,CPU 臂直接调 `ReadTextureLevelTight`,主机到不了 store 路由;现在 CPU 臂也查(前向声明) | `MobileGL/MG_Backend/DirectGLES/WireTextureReadback.inc:445`;`DirectGLES.cpp:13026`、`:13045` |
|
||||
| 粒度:标按纹理不按层,纹理被生成过一次或任一层被画过,之后读回被拒的生成一律拒绝(保守,不给旧字节) | — |
|
||||
|
||||
| 用例(`GenerateMipmapServerScenario`) | 形状 | 断言 | 行 |
|
||||
|---|---|---|---|
|
||||
| `Rgb16fDrawnBaseWithARefusedReadbackDeclinesByName` | level 0 上传哨兵色后当渲染目标画上下两半 | server 日志有 `generate-mipmap-store-declined`、无 store 滤波行;level 1..3 不是哨兵色 | `MobileGL/MG_IntegrationTest/Scenarios/GenerateMipmapServerScenario.cpp:408`、`:546` |
|
||||
| `Rgb16fUploadedBaseWithARefusedReadbackIsFilteredFromTheStore`(对照) | 只上传 level 0 | 日志有 `filtering the staged store's copy`、无拒绝;level 1..3 正确 | `GenerateMipmapServerScenario.cpp:439`、`:550` |
|
||||
|
||||
| 条目 | 臂 | 登记 |
|
||||
|---|---|---|
|
||||
| `DirectGLES.{Split,Spawn}.CpuMipRefused.*` | 旋钮 `MGITEST_ESPRYT_FORCE_CPU_MIPMAP=1` + `MGITEST_ESPRYT_REFUSE_TEXTURE_READBACK_EXTENT=16x16`,标签 `integration-gpu`、`integration-cpu-mip-<arm>` | `MobileGL/MG_IntegrationTest/CMakeLists.txt:4883` |
|
||||
| 其他臂(monolith、无旋钮 split 三臂、Magma) | 两例按旋钮缺席跳过 | 环境发现 / `GenerateMipmapServerScenario.*` |
|
||||
|
||||
- 不上 tcp:server 是共享 `TcpServer.Start`,16x16 拒绝会碰到整条 lane 的 16x16 颜色读回;与 B 的 `CpuMip.` 同形,parity 无需例外行(实测 0 错)。
|
||||
|
||||
## 4. 项 3:D 的 case 3
|
||||
|
||||
- 跳过条件由「非 Magma」改为「非 Magma 且 monolith」(`WireIndirectDrawScenario.cpp:306`);Espryt split 的 count 字由 C 的 `SplitHostBytesForCpuRead` 刷新(`DirectGLES.cpp:9632`、`:9798`)。
|
||||
- 计数断言只在 Magma inproc(`CountersReadable`),Espryt 只断言像素。
|
||||
|
||||
## 5. 项 4:名单与调用点
|
||||
|
||||
| 事实 | 出处 |
|
||||
|---|---|
|
||||
| `copy-image-shadow-mirror` 调用在镜像函数自己的 transport return 之后,且在 `#if MOBILEGL_PIPE_PUSH` 内:任何 transport 到不了,pull 构建不编译它 | `DirectGLES.cpp:13580`、`:13582-13585` |
|
||||
| 删调用与名:G1 符号 +0 / −0,`.text` `a5ba13` 不变 | §8 |
|
||||
| 名单现 3 名,一名一处调用 | `MobileGL/MG_Test/Pipe/PipeCatalogueTest.cpp:1448-1455` |
|
||||
| lint 规则(全是 error):名单每名恰一处产品调用;每处调用名在名单;名单无重复;调用须是字符串字面量。产品源 = `MobileGL/` 去掉 `MG_Test/`、`MG_IntegrationTest/`;先掩码注释 | `scripts/ci/unmigrated_emulation_sites.py` |
|
||||
| CI:`test.yml` 在 `split_coverage.py` 之后一步 | `.github/workflows/test.yml:1475` |
|
||||
| unit 车道:`PipeCatalogue.UnmigratedEmulationSites{SelfTest,MatchTheList}` | `MobileGL/MG_IntegrationTest/CMakeLists.txt:4895-4901` |
|
||||
| 门命令:`python3 scripts/ci/unmigrated_emulation_sites.py --self-test && python3 scripts/ci/unmigrated_emulation_sites.py` | — |
|
||||
| 回看:lint 在 `8d3e2317`(B 之前)红 2 条:`generate-mipmap-storage` 4 处调用、`generate-mipmap-cpu-filter` 不在名单;在 `cbbaf77f` 绿(4 名 4 处) | 证据 `r4b-lint-*.log` |
|
||||
|
||||
## 6. red-once
|
||||
|
||||
| # | 变异 | 载体 | 观察到的红 |
|
||||
|---|---|---|---|
|
||||
| R1 | 发布 guard 改回 `if (!defaultFBOInfo) return;`(= 基线) | `DirectGLES.{Split,Spawn,Tcp}.DepthStencilReadbackAttachmentShapeScenario.DefaultFramebuffer…` | Spawn、Tcp 红(depth 0、stencil 0),Split 绿 |
|
||||
| R1′ | 同上 | 三个 `ForcedDs.` 条目 | Spawn、Tcp 红,Split 绿 |
|
||||
| R2a | 去掉 `driverWrittenBefore` 判定 | `DirectGLES.{Split,Spawn}.CpuMipRefused.*` | 画过的例两臂红:level 1..3 = 哨兵 `rgba(255,0,255,255)`、无拒绝行、有 store 滤波行;对照绿 |
|
||||
| R2b | 快照挪到自身记写之后 | 同上 | 对照两臂红:store 路由拒绝、level 1..3 `rgba(0,0,0,255)`;画过的例绿 |
|
||||
| R2c | CPU 臂不查拒绝旋钮 | 同上 | 4/4 红:拒绝行与 store 滤波行都没有(原生读回路径) |
|
||||
| R3 | 两处 `*IndirectCount` 参数读改回 `SplitHostBytes`(去 C 的刷新) | `DirectGLES.{Split,Spawn,Tcp}.WireIndirectDrawScenario.ComputeWrittenCount…` | 三臂红:两处 count 画错条带 |
|
||||
| R3m | 去掉 Espryt monolith 跳过 | `DirectGLES.WireIndirectDrawScenario.ComputeWrittenCount…`(monolith) | 红:count 1 却画了条带 2、3(OQ15,跳过须保留) |
|
||||
| R4a | `kNames` 加回 `copy-image-shadow-mirror` | lint;`PipeCatalogue.UnmigratedEmulationSitesMatchTheList` | rc 1:「listed and has no call site」;ctest 红 |
|
||||
| R4b | `--self-test` 六例(多名、漏名、同名两处、名单重复、非字面量、匹配) | lint | 各规则按预期 rc;匹配树 rc 0 |
|
||||
|
||||
还原一律复制比对 + `touch`(`cmp` 一致)后重建再跑绿。
|
||||
|
||||
## 7. 项 5:行号漂移
|
||||
|
||||
- 方法:每份说明从最后写它的提交(A `06f28b0a`、B `b9feb9d7`、C `e815ce8d`、D `d639e546`、E `c00f5eab`、F `c7a14ed7`)经 `git diff -U0` 把每处 `file:line` 与同行 `:line` 简写映射到 HEAD;映射到的行与原行内容逐字相同。工具未提交。
|
||||
|
||||
| 说明 | 引用 | 未动 | 重定位 | 备注 |
|
||||
|---|---|---|---|---|
|
||||
| A | 21 | 7 | 14 | — |
|
||||
| B | 31 | 2 | 29 | — |
|
||||
| C | 30 | 20 | 10 | — |
|
||||
| D | 44 | 32 | 12 | `WireDraw.inc` +7(F)、`WireDeclines.def` +6、`CMakeLists` D 块 `:4831-4864` |
|
||||
| E | 41 | 21 | 18 + 1 行改写 | 第 93 行:调用与名已由本包删,改指删除注释与名单 |
|
||||
| F | 46 | 42 | 4 | 第 11 行「旧 `:1427`…」是 F 之前的位置,按原意不动;`:1460` 属 `WireFramebuffer.inc`,未变 |
|
||||
| S | 0 | — | — | — |
|
||||
|
||||
- 集成方简报里的几处量值是中间合并点的:B 的 `CMakeLists` `:3355` 在 HEAD 是 `:3442`(非 `:3375`),`:4059` 是 `:4174`,`:2154`(`TcpServer.Start` 的 fixture 属性)是 `:2168`;D 的 `:4651` 是 `:4831`(非 `:4764`);按内容为准。
|
||||
- 只改行号,不改历史陈述:B.md 的「名单保持 4 名」是 B 当时的读数,现为 3 名(§5)。
|
||||
|
||||
## 8. 门
|
||||
|
||||
`gate.sh ~/w7/p8-se p8se`,头 `edcb9328`,dirty 0(`~/w7/notes/p8/se-evidence/gate-p8se.log`);与第一波集成头(ID-P8-12)对比。
|
||||
|
||||
| 项 | 读数 | 变化 |
|
||||
|---|---|---|
|
||||
| G1 | 符号 `added=0 removed=0`(clang 22.1.6);`.text` `a5ba13` | 不变 |
|
||||
| fatal census / link ratchet | 78 abort 点 / 20 文件 / 45 族;172 | 不变(`MGPipeUnmigratedEmulation` 调用不是 abort 点) |
|
||||
| parity / protocol pin / wire-declines | 0 错;revision 5;58 行 59 处 0 未记 | 不变 |
|
||||
| hygiene | 13/13 OK(含 `split_coverage`、`doc_citations`) | — |
|
||||
| split_coverage | DirectGLES monolith 703 = 门控 615 + 豁免 88,missing 0;DirectVulkan 703 = 门控 222 + 信息层 449 + 豁免 32 | monolith +2(两个新例);Espryt 门控 +3,豁免 −1(pending-fix) |
|
||||
| unit | 2723 | +2(lint 两条 ctest) |
|
||||
| integration-split / spawn / tcp | 739 / 653 / 665 | 各 +4:默认帧缓冲例、其 `ForcedDs.` 条目、两个新例(无旋钮臂跳过) |
|
||||
| magma split / spawn / tcp / full-split | 271 / 248 / 216 / 670 | full-split +2(两个新例经 tier 3 回放) |
|
||||
| integration-gpu[monolith] / [inproc] | 3704 / 3704 | +20:默认帧缓冲例的 Espryt 三臂与 `ForcedDs.` 三臂 6;两个新例 14(两后端 monolith 4、Espryt 三臂 6、`CpuMipRefused.` 4) |
|
||||
| retrace(`MOBILEGL_BUILD_TRACE_REPLAY=ON`,236 条) | 230 过;6 红 = 已知 `iris-iterationrp-in-world`(两后端 × monolith / SPLIT / SPAWN,主机 llvmpipe JIT `Cannot select`) | 与第一波相同(`retrace-p8se.log`) |
|
||||
|
||||
## 9. 发现未修
|
||||
|
||||
| 项 | 说明 |
|
||||
|---|---|
|
||||
| P12 extent 发布在 spawn 下首次生效 | §2 末条;需设备(红米 FCL→render server)确认 |
|
||||
| store 路由粒度 | 驱动写标按纹理;按层的标需要改 E 的 store 接口 |
|
||||
| B.md / E.md 的历史陈述 | 名单数、`copy-image-shadow-mirror` 的去向以本说明为准 |
|
||||
@@ -0,0 +1,75 @@
|
||||
# P8-SV:Magma split 残项
|
||||
|
||||
> 2026-09-30,分支 `p8/sv`(基线 `cbbaf77f`,第一波集成头)。计划:[`PLAN-P8.md`](PLAN-P8.md) 第二波 SV;来源:[`F.md`](F.md)「发现但未修」三条、[`D.md`](D.md) §7 第一条。主机 lavapipe,只动 Magma(Espryt 作对照)。
|
||||
|
||||
## 1. 结论
|
||||
|
||||
| 项 | 改动 | 位置 | 之前 | 之后 |
|
||||
|---|---|---|---|---|
|
||||
| 1 | 3D 原生 mip blit 的子资源 `layerCount` 改为 1,深度只走 z 偏移(逐级减半,原本就对) | `WireFramebuffer.inc:1626-1636` | `layerCount = Depth >> level`(`VkTextureManager.cpp:2738-2740` 的切片寻址)当层数,图像 `arrayLayers = 1`;验证层报 `VUID-vkCmdBlitImage-srcImage-00240`、`-srcSubresource-01707`、`-dstSubresource-01708` | 与 monolith 同形(`VulkanRenderer.cpp:12303`、`:12403`);验证层 0 条 |
|
||||
| 2 | 深度模板 mip 拒绝补 `WireDeclineTally` 行 | `WireDeclines.def:124`;站点 `WireFramebuffer.inc:1401` | 只有 `MGLOG_E_ONCE`,`MGWIRE-DECLINES` 看不到 | `MGL_WIRE_DECLINE_AT(MipmapDepthStencilAspect, …)`,日志原文保留 |
|
||||
| 3 | 深度着色器 mip 拒 1D / 1D 数组 / 3D | 生长前判定 `WireFramebuffer.inc:1426`、`:1437`;pass 自身 `WireDepthMipmap.inc:67-74`;调用方传 view 类型 `WireFramebuffer.inc:1491` | 只拒 `is3D`,调用方从不设置;1D 深度链进 pass,对 1D 图像建 2D view(`WireDepthMipmap.inc:244`) | 生长前具名拒绝 `MipmapShaderFormatOrShape`(`WireFramebuffer.inc:1465`);pass 的拒绝是漂移保护(`:1508-1513`) |
|
||||
| 4 | wire 臂 `glDispatchComputeIndirect` 原生化 | `DispatchWireComputeIndirect`(`WireDraw.inc:789`),入口 `VulkanRenderer.cpp:7790-7797`,`DirectVulkan.cpp:938-945` | `ReadWireBuffer` 在 CPU 读 3 个字,shader 写过则整 GPU 等待 | `vkCmdDispatchIndirect`(`WireDraw.inc:844`);不再有 CPU 路径 |
|
||||
|
||||
## 2. 设计
|
||||
|
||||
| 项 | 内容 |
|
||||
|---|---|
|
||||
| 1 | `ResolveWireTextureStorage` 不动:Tex3D 的 `layers` 是附件、描述符、回读共用的切片寻址;只在 blit 处按 `resource->viewType == 3D` 改用 `{层 0, 1 层}` |
|
||||
| 2 | 行追加在 `WireDeclines.def` 末尾(只追加);宏同时计数与 `_ONCE` 日志 |
|
||||
| 3 | 两层:生长前 `depthArmTakesShape` 加 `planar`(与颜色臂同一谓词,决定在 `GrowWireTextureMipChain` 之前,`WireFramebuffer.inc:1469`);pass 按 `WireImage::viewType` 再拒一次。monolith 调用方(`VulkanRenderer.cpp:4866`、`:4905`)不设 viewType,行为不变 |
|
||||
| 4 | 形状同 monolith(`VulkanRenderer.cpp:7862`),store 取自 `VerbDispatchIndirectBuffer`(`AcquireWireSlice` 打 `lastUseSerial`) |
|
||||
| 4 屏障 | P8-D 规则:store 被标 shader 写过(`VkBufferManager.cpp:603`)则首个 indirect 读前录一次 `ALL_COMMANDS/MEMORY_WRITE → DRAW_INDIRECT/INDIRECT_COMMAND_READ`(`WireDraw.inc:808`);在绑定本次 dispatch 的 SSBO **之前** 取标,否则本次 dispatch 若把参数 store 也当输出,会吃掉下一个读者的标 |
|
||||
| 4 拒绝 | store 缺失 `DispatchIndirectBufferUnbound`、越界 / 未 4 对齐 / 负偏移 `DispatchIndirectRange`(`WireDeclines.def:127-128`);程序、纹理、管线、绑定四处拒绝复用 `DispatchWireCompute` 的行 |
|
||||
| 4 计数 | 新 `wdsp`(`PipeStats.h:289`、`PipeStats.cpp:706`),屏障计入 D 的 `wibar`,等待仍是 `whw`;`WireIndirectCounters::nativeDispatches` 追加在结构末尾 |
|
||||
| G1 | 全部在 `MOBILEGL_BUILD_DISAGGREGATED` / `MOBILEGL_PIPE_PUSH` 下 |
|
||||
|
||||
## 3. 门
|
||||
|
||||
| 用例 | 断言 | 登记 |
|
||||
|---|---|---|
|
||||
| `WireMipShapeScenario.VolumeChainIsGeneratedAlongItsDepth`(`WireMipShapeScenario.cpp:82`) | 8³ RGBA8,层 0 按切片对着色;1..3 级每片等于上一级两片均值;`GL_TEXTURE_DEPTH` 逐级 | 两后端 monolith + 各 split 臂;Magma 门控 `.Mip3D.` 三臂 |
|
||||
| 同上,`.Mip3DValidation.` | `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`,输出含 `VUID-vkCmdBlitImage-` 即红(`FAIL_REGULAR_EXPRESSION`);用例从 `/proc/self/maps` 证实层已加载(`WireMipShapeScenario.cpp:51`、`:156`) | 只 inproc(`MobileGL/MG_IntegrationTest/CMakeLists.txt:4931-4937`),`spawn_lane_parity.py:67-72` 的 `MAGMA_INPROC_ONLY`;CI 跑 `integration-magma-split` 的作业装了验证层(`.github/workflows/test.yml:1700`、`:1986`) |
|
||||
| `WireMipShapeScenario.Depth1DChainWithoutANativeBlitDeclinesByName`(`WireMipShapeScenario.cpp:167`) | 1D `DEPTH_COMPONENT32F`,`MGITEST_MAGMA_FORCE_SHADER_MIPMAP=1`:无 GL 错误、两次回读、层 1 仍是哨兵;inproc 上 `MipmapShaderFormatOrShape` +1 | Magma `.ShaderMipDepth1D.` split + spawn(server 读旋钮),`spawn_lane_parity.py:150` |
|
||||
| `F1WireScenario.GenerateMipmapDepthStencilDeclinesAndKeepsTheSession` | 原像素断言 + inproc 上 `MipmapDepthStencilAspect` +1(`F1WireScenario.cpp:663-683`,经 `WireDeclinePeek.cpp:23`) | 原登记不变 |
|
||||
| `WireIndirectDispatchScenario` 三例(`WireIndirectDispatchScenario.cpp:219`、`:239`、`:267`) | 网格逐 work group 标记;inproc Magma:`wdsp` = 调用数、`whw` = 0、`wibar` = 写次数(读数在结果回读之前取) | 两后端各臂;Magma 门控 `.IndirectDispatch.` 三臂;第三例(无应用屏障)只 Magma split 臂 |
|
||||
|
||||
## 4. red-once(全部执行并还原:拷贝比对 + touch)
|
||||
|
||||
| # | 变异 | 载体 | 观察到的红 |
|
||||
|---|---|---|---|
|
||||
| R1 | blit 改回 `{baseLayer, layerCount}` | `.Mip3D.` 三臂、`.Mip3DValidation.`、两后端 monolith / 各臂 | `.Mip3DValidation.` 红:`Error regular expression found`,三条 VUID 各 6 次;像素用例全绿(lavapipe 3D blit 按 z 偏移、不看 layerCount) |
|
||||
| R2 | 站点改回裸 `MGLOG_E_ONCE` | `F1WireScenario.GenerateMipmapDepthStencilDeclines*` 各臂 | inproc 两例红(`.Split.Fm.`、`.Split.Full.`):计数差 0 ≠ 1;spawn / tcp 绿 |
|
||||
| R2b | 同上,静态 | `wire_declines_audit.py` | rc 1:`row MipmapDepthStencilAspect has NO SITE` |
|
||||
| R3 | 生长前 `planar` 与 pass 的 view 类型拒绝都去掉 | `.ShaderMipDepth1D.` split、spawn | 两例红:层 1 被写成 0.25(哨兵 0.75),无拒绝计数;pass 在 1D 图像上建 2D view 仍产出像素 |
|
||||
| R3b | 只去生长前判定 | 同上 | 绿:pass 拒绝兜住(`the depth pass refused level 1`,计数 1),漂移保护有效 |
|
||||
| R4 | wire 分支恢复 `ReadWireBuffer` + CPU dispatch | `WireIndirectDispatchScenario` 各臂 | inproc 9 例红(3 例 × `.Split.IndirectDispatch.` / `.Split.` / `.Split.Full.`):`wdsp` 0、GPU 写过的 `whw` 2、`wibar` 0;spawn / tcp / monolith 绿(CPU 路径网格正确) |
|
||||
| R5 | 去屏障(`if (false && …)`) | 同上 | inproc 6 例红(两个 shader 写用例 × 3 登记):`wibar` 0 ≠ 2;网格在 lavapipe 上不红(按序执行),spawn / tcp 绿 |
|
||||
| R6 | `wdsp=` 改成 `wds=` | `PipeStatsTest.WireIndirectCountersPrintInTheirOwnBracket` | 红 |
|
||||
| R7a | 删 `.ShaderMipDepth1D.` 例外行 | `spawn_lane_parity.py build-split` | rc 1:tcp 臂缺该例 |
|
||||
| R7b | 删 `.Mip3DValidation.` 例外行 | 同上 | rc 1:spawn、tcp 两臂缺该例 |
|
||||
|
||||
验证层后验:`.Split.IndirectDispatch.` 三例、`.Split.ShaderMipDepth1D.`、`.Split.Mip3D.`、`.Split.Fm.` 深度模板例在层下全绿,VUID 0 条。
|
||||
|
||||
## 5. 整套门(`~/w7/notes/p8/gate.sh`,树外)
|
||||
|
||||
| 项 | 读数 | 相对第一波集成头(ID-P8-12) |
|
||||
|---|---|---|
|
||||
| G1 | 符号增 0 减 0,`.text` `a5ba13` | 不变 |
|
||||
| census / ratchet / parity / 修订 | 78 / 20 / 45;172;0;5 | 不变 |
|
||||
| wire-declines | 61 行、66 站点、0 未记日志 | +3 行(`MipmapDepthStencilAspect`、`DispatchIndirect{BufferUnbound,Range}`),+7 站点(新派发函数另复用 4 个 `Compute*` 行) |
|
||||
| split_coverage | Espryt monolith 706 = 门控 617 + 豁免 89;Magma 706:门控 227、只在信息层 447、豁免 32;missing 0 | +5 例(2 mip + 3 派发),无新豁免行 |
|
||||
| 车道 | unit 2721;split / spawn / tcp 740 / 654 / 666;Magma 277 / 253 / 220 / 673;gpu monolith / inproc 3709 / 3709,全部 100 % | +5 / +5 / +5;Magma +6 / +5 / +4 / +5;gpu +25 |
|
||||
| retrace(`2edb2aa8`,只改测试的提交之前) | 230 / 236,只挂已知 6 例 iterationrp | 同第一波 |
|
||||
|
||||
## 6. monolith 观察(记给 dev / P13,本包不修)
|
||||
|
||||
| 观察 | 位置 | 证据 |
|
||||
|---|---|---|
|
||||
| split 构建的 monolith 臂深度着色器 mip 同样不传 view 类型:设备无深度 BLIT_DST 时,1D 深度链会对 1D 图像建 2D view;Release 下 `MOBILEGL_ASSERT` 是空的 | `VulkanRenderer.cpp:4905`、`:12321` | 推断:lavapipe 原生 blit 深度,主机红不出;monolith 不读 `MGITEST_MAGMA_FORCE_SHADER_MIPMAP` |
|
||||
|
||||
## 7. 发现但未修
|
||||
|
||||
- `mipmap-shader-format-or-shape` 的明细对深度形状也打印 `missing=COLOR_ATTACHMENT`(1D 深度的真实原因是 `view=0`);是 F 的 `MagmaWireShapeDetail` 口径,未改。
|
||||
- create 系列 fixture 没有 `glDispatchComputeIndirect`([`D.md`](D.md) §7),item 4 的真实负载收益未测。
|
||||
- `gen_pipe_dirty_surface.py` 的「根外写者」扫描读整个 `MobileGL/`(`gen_pipe_dirty_surface.py:394`),集成测试源也在内:派发用例的 fixture 成员曾叫 `m_parameters`,让 NEW_PATCH_STATE 的 shutter 看起来在根外被写,自检否定对照 16(`gen_pipe_dirty_surface.py:1770-1778`)不再触发、门红。本包把成员改名 `m_groupCounts`;扫描口径未改,任何新测试 fixture 用到 GLContext 的成员名都会再撞上。
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"abort_sites": 79,
|
||||
"abort_sites": 78,
|
||||
"abort_sites_by_file": {
|
||||
"MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp": 15,
|
||||
"MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp": 14,
|
||||
"MobileGL/MG_Backend/DirectGLES/Managers.cpp": 12,
|
||||
"MobileGL/MG_Backend/DirectGLES/MultiDraw.cpp": 2,
|
||||
"MobileGL/MG_Backend/DirectGLES/Utils.cpp": 1,
|
||||
|
||||
@@ -64,7 +64,12 @@ FIXTURE_ENTRIES = {"TcpServer.Start", "TcpServer.Stop"}
|
||||
# answers unavailable, so a copy there checks pixels under a name claiming
|
||||
# the pools. The pixels do run on every arm: the Espryt entries and the
|
||||
# Magma informational and full-suite tiers.
|
||||
MAGMA_INPROC_ONLY = ("MagmaRunAheadScenario.", "MagmaWireCacheScenario.", "DescriptorPoolGrowthScenario.")
|
||||
# `.Mip3DValidation.` (P8-SV, a TAIL): WireMipShapeScenario's 3D chain under the Khronos validation
|
||||
# layer, red on a vkCmdBlitImage VUID in the entry's own output and proving the
|
||||
# layer loaded from /proc/self/maps - both need the server's Vulkan instance
|
||||
# in this process. The knob-free `.Mip3D.` entries keep all three arms.
|
||||
MAGMA_INPROC_ONLY = ("MagmaRunAheadScenario.", "MagmaWireCacheScenario.", "DescriptorPoolGrowthScenario.",
|
||||
".Mip3DValidation.")
|
||||
|
||||
# P7 wave 2-B2: THE SANCTIONED ASYMMETRY THAT IS NOT INPROC-ONLY - these exist on split AND
|
||||
# spawn and cannot exist on tcp. Every MGITEST_MAGMA_FORCE_* knob is read BY THE SERVER
|
||||
@@ -138,7 +143,11 @@ MAGMA_SERVER_ENV_KNOB_NO_TCP = (".ShaderMip1.", ".ShaderMip2.", ".DepthMip.",
|
||||
".Reclaim.MagmaWireReclaimScenario.ADrawAfterTheEarlyReclaimFollowsTheNewStoreNotTheMemoizedHandle",
|
||||
".Reclaim.MagmaWireReclaimScenario.DescriptorSetsRewindInsideOneLongFrameAfterTheirSubmitRetires") + tuple(
|
||||
f".PrimGenReroute.PrimitivesGeneratedNoXfbScenario.{case}" for case in PRIMGEN_REROUTE_CASES) + tuple(
|
||||
f".SplitRecording64.OversizedRecordingSplitScenario.{case}" for case in SPLIT_RECORDING_CASES)
|
||||
f".SplitRecording64.OversizedRecordingSplitScenario.{case}" for case in SPLIT_RECORDING_CASES) + (
|
||||
# P8-F: the mip shader-shape decline, forced by MGITEST_MAGMA_FORCE_SHADER_MIPMAP (server-read).
|
||||
".ShaderMipDecline.",
|
||||
# P8-SV: the 1D depth chain's decline, forced by the same server-read knob.
|
||||
".ShaderMipDepth1D.",)
|
||||
|
||||
|
||||
# THE MIRROR SHAPE - entries that exist on tcp ALONE, by construction. Each tail must match at least
|
||||
|
||||
Executable
+328
@@ -0,0 +1,328 @@
|
||||
#!/usr/bin/env python3
|
||||
"""P8-A (ID-P8-2): every monolith integration case runs on a split arm or is exempt BY NAME.
|
||||
|
||||
THE QUESTION. The monolith registrations (`DirectGLES.<case>`, `DirectVulkan.<case>`, plus their
|
||||
knob-pinned lanes such as `DirectGLES.ForcedDepthStencilEmulation.<case>`) define what the suite
|
||||
tests. A case that exists there and on no split arm is a case the disaggregated runtime was never
|
||||
asked about - and nothing about a green split lane says so. This asserts, per backend:
|
||||
|
||||
monolith cases ⊆ split cases ∪ exempt cases
|
||||
|
||||
after the arm and tail segments come off both sides: an entry name is `<Backend>.[<Arm>.][<tail>.]
|
||||
<Suite>.<Case>`, and only the last two segments (the gtest name) are compared. `Split.F1.`,
|
||||
`Spawn.ForcedDs.`, `Tcp.MultiDrawTierBaseVertex.` and the monolith's
|
||||
`ForcedDepthStencilEmulation.` all normalise away.
|
||||
|
||||
WHAT COUNTS AS A SPLIT CASE differs by backend, on purpose:
|
||||
* DirectGLES - an entry with an arm segment (Split/Spawn/Tcp/TcpDevice) that carries a GATED
|
||||
label. The one informational spelling family is `integration-magma-{all,full}-<arm>`
|
||||
(MG_IntegrationTest/CMakeLists.txt, P7 package L tiers 2 and 3), and an entry carrying only
|
||||
those labels is not coverage.
|
||||
* DirectVulkan - any split-arm entry, the informational tiers included. Magma's split arms are
|
||||
informational by ruling (ID-P8-2): cases move from tier 2/3 into the gated Magma tier with the
|
||||
commit that retires their blocker. The report prints how many are gated and how many are
|
||||
informational-only, so the number is visible without being a gate.
|
||||
|
||||
WHAT COUNTS AS A MONOLITH CASE: an entry with no arm segment carrying `integration-gpu` - the label
|
||||
the monolith registrations and the monolith-control mechanism entries share. That puts
|
||||
`DirectGLES.PushMonolithArm.<case>` (labelled integration-split, but no arm) on the monolith side,
|
||||
where it belongs, and leaves build-verify's `DirectGLES.VerifySplit.<case>` (no integration-gpu)
|
||||
out of both sides.
|
||||
|
||||
THE EXEMPTION TABLE (scripts/data/split_coverage_exemptions.txt), one row per pattern:
|
||||
|
||||
[<Backend>:]<gtest pattern> <reason-class> <one-line reason>
|
||||
|
||||
with reason classes mechanism / single-backend / no-records / inproc-peek / pending-fix. The table
|
||||
keeps itself honest the way spawn_lane_parity.py's exception lists do - every one of these is an
|
||||
error, not a warning:
|
||||
* a pattern that matches no monolith case (an exemption about nothing);
|
||||
* a pattern every case of which is already on a split arm (stale: a pending-fix that landed must
|
||||
take its row with it, or the next regression of that case is silently exempt);
|
||||
* a `pending-fix` row that names neither a package (`P8-B`) nor a DEBTS.md row;
|
||||
* a `single-backend` row with no `<Backend>:` scope (it exempts the backend the case does NOT
|
||||
belong to, and unscoped it would also hide a gap on the one it does);
|
||||
* an unknown reason class, a missing reason, a duplicated pattern.
|
||||
|
||||
This script does not compare the arms with each other - spawn_lane_parity.py owns that.
|
||||
"""
|
||||
import argparse
|
||||
import fnmatch
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
BACKENDS = ("DirectGLES", "DirectVulkan")
|
||||
ARMS = ("Split", "Spawn", "Tcp", "TcpDevice")
|
||||
REASON_CLASSES = ("mechanism", "single-backend", "no-records", "inproc-peek", "pending-fix")
|
||||
MONOLITH_LABEL = "integration-gpu"
|
||||
INFORMATIONAL_LABEL = re.compile(r"^integration-magma-(all|full)-(split|spawn|tcp)$")
|
||||
GTEST_NAME = re.compile(r"^[A-Za-z0-9_]+\.[A-Za-z0-9_]+$")
|
||||
PATTERN = re.compile(r"^(?:(DirectGLES|DirectVulkan):)?([A-Za-z0-9_*?]+\.[A-Za-z0-9_*?]+)$")
|
||||
OWNER = re.compile(r"\bP\d+[a-z]?-[0-9A-Z]+\b|DEBTS\.md")
|
||||
DEFAULT_EXEMPTIONS = Path(__file__).resolve().parents[2] / "scripts/data/split_coverage_exemptions.txt"
|
||||
|
||||
|
||||
def labels_of(test):
|
||||
for prop in test.get("properties", []):
|
||||
if prop.get("name") == "LABELS":
|
||||
value = prop.get("value") or []
|
||||
return [value] if isinstance(value, str) else list(value)
|
||||
return []
|
||||
|
||||
|
||||
def classify(document, errors):
|
||||
"""{backend: {"mono": set, "gated": set, "info": set, "arms": {arm: set}}} from a
|
||||
`ctest --show-only=json-v1` document. Names under a backend that do not parse are errors."""
|
||||
out = {b: {"mono": set(), "gated": set(), "info": set(), "arms": {a: set() for a in ARMS}}
|
||||
for b in BACKENDS}
|
||||
for test in document.get("tests", []):
|
||||
name = test.get("name", "")
|
||||
parts = name.split(".")
|
||||
if parts[0] not in BACKENDS:
|
||||
continue
|
||||
backend = parts[0]
|
||||
labels = labels_of(test)
|
||||
arm = parts[1] if len(parts) > 1 and parts[1] in ARMS else None
|
||||
gtest = ".".join(parts[-2:])
|
||||
rest = parts[2:] if arm else parts[1:]
|
||||
if len(rest) < 2 or not GTEST_NAME.match(gtest):
|
||||
errors.append(f"{name}: does not parse as <Backend>.[<Arm>.][<tail>.]<Suite>.<Case>, so "
|
||||
f"this gate would silently drop it")
|
||||
continue
|
||||
side = out[backend]
|
||||
if arm is None:
|
||||
if MONOLITH_LABEL in labels:
|
||||
side["mono"].add(gtest)
|
||||
continue
|
||||
if labels and not all(INFORMATIONAL_LABEL.match(label) for label in labels):
|
||||
side["gated"].add(gtest)
|
||||
side["arms"][arm].add(gtest)
|
||||
else:
|
||||
side["info"].add(gtest)
|
||||
return out
|
||||
|
||||
|
||||
def parse_exemptions(text, errors):
|
||||
rows = []
|
||||
seen = set()
|
||||
for number, raw in enumerate(text.splitlines(), 1):
|
||||
line = raw.strip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
fields = line.split(None, 2)
|
||||
where = f"exemptions:{number}"
|
||||
if len(fields) < 3 or not fields[2].strip():
|
||||
errors.append(f"{where}: `{line}` needs <pattern> <reason-class> <reason>")
|
||||
continue
|
||||
pattern, reason_class, reason = fields
|
||||
match = PATTERN.match(pattern)
|
||||
if not match:
|
||||
errors.append(f"{where}: `{pattern}` is not [<Backend>:]<Suite>.<Case> (globs * and ? allowed)")
|
||||
continue
|
||||
if reason_class not in REASON_CLASSES:
|
||||
errors.append(f"{where}: reason class `{reason_class}` is not one of {', '.join(REASON_CLASSES)}")
|
||||
continue
|
||||
if reason_class == "pending-fix" and not OWNER.search(reason):
|
||||
errors.append(f"{where}: pending-fix `{pattern}` names no owner - a package (P8-B) or a "
|
||||
f"DEBTS.md row must be in the reason, or the row outlives everyone's memory of it")
|
||||
continue
|
||||
if reason_class == "single-backend" and match.group(1) is None:
|
||||
errors.append(f"{where}: single-backend `{pattern}` must be scoped `<Backend>:` to the backend "
|
||||
f"it exempts; unscoped it would also hide a gap on the backend the case belongs to")
|
||||
continue
|
||||
if pattern in seen:
|
||||
errors.append(f"{where}: `{pattern}` is listed twice")
|
||||
continue
|
||||
seen.add(pattern)
|
||||
backends = (match.group(1),) if match.group(1) else BACKENDS
|
||||
rows.append({"where": where, "pattern": pattern, "glob": match.group(2), "backends": backends,
|
||||
"class": reason_class, "reason": reason.strip()})
|
||||
return rows
|
||||
|
||||
|
||||
def check(document, exemption_text, out=print):
|
||||
"""Returns the exit code; every finding goes through `out`."""
|
||||
errors = []
|
||||
sides = classify(document, errors)
|
||||
rows = parse_exemptions(exemption_text, errors)
|
||||
covered = {"DirectGLES": sides["DirectGLES"]["gated"],
|
||||
"DirectVulkan": sides["DirectVulkan"]["gated"] | sides["DirectVulkan"]["info"]}
|
||||
exempt = {b: {} for b in BACKENDS}
|
||||
for row in rows:
|
||||
matched = needed = 0
|
||||
for backend in row["backends"]:
|
||||
for case in sorted(sides[backend]["mono"]):
|
||||
if not fnmatch.fnmatchcase(case, row["glob"]):
|
||||
continue
|
||||
matched += 1
|
||||
if case not in covered[backend]:
|
||||
needed += 1
|
||||
exempt[backend].setdefault(case, row)
|
||||
if matched == 0:
|
||||
errors.append(f"{row['where']}: `{row['pattern']}` matches no monolith case - an exemption "
|
||||
f"about nothing (renamed or deleted case?)")
|
||||
elif needed == 0:
|
||||
errors.append(f"{row['where']}: `{row['pattern']}` is STALE - every monolith case it names is "
|
||||
f"on a split arm now; delete the row so the next regression is not exempt")
|
||||
for backend in BACKENDS:
|
||||
side = sides[backend]
|
||||
mono = side["mono"]
|
||||
if not mono:
|
||||
errors.append(f"{backend}: no monolith cases in this build - an empty set is covered by "
|
||||
f"anything, which is the one way this gate could stop meaning something")
|
||||
continue
|
||||
missing = sorted(mono - covered[backend] - set(exempt[backend]))
|
||||
by_class = {}
|
||||
for row in exempt[backend].values():
|
||||
by_class[row["class"]] = by_class.get(row["class"], 0) + 1
|
||||
per_arm = ", ".join(f"{arm.lower()} {len(mono & cases)}" for arm, cases in side["arms"].items() if cases)
|
||||
classes = ", ".join(f"{name} {count}" for name, count in sorted(by_class.items())) or "none"
|
||||
if backend == "DirectGLES":
|
||||
out(f"split coverage {backend}: monolith {len(mono)}, on a gated split arm "
|
||||
f"{len(mono & side['gated'])} ({per_arm}), exempt {len(exempt[backend])} ({classes}), "
|
||||
f"missing {len(missing)}")
|
||||
else:
|
||||
gated = mono & side["gated"]
|
||||
out(f"split coverage {backend}: monolith {len(mono)}, on a gated split arm {len(gated)} "
|
||||
f"({per_arm}), informational tiers only {len(mono & side['info'] - side['gated'])}, "
|
||||
f"exempt {len(exempt[backend])} ({classes}), missing {len(missing)}")
|
||||
for case in missing:
|
||||
errors.append(f"{backend}.{case} is registered on monolith and on no "
|
||||
f"{'gated ' if backend == 'DirectGLES' else ''}split arm, and no exemption "
|
||||
f"names it: register it (MG_IntegrationTest/P8Coverage.cmake) or add a row "
|
||||
f"to scripts/data/split_coverage_exemptions.txt with its reason class")
|
||||
for message in errors:
|
||||
out(f"::error::{message}")
|
||||
return 1 if errors else 0
|
||||
|
||||
|
||||
def ctest_document(build_dir):
|
||||
text = subprocess.run(["ctest", "--show-only=json-v1"], cwd=build_dir, capture_output=True,
|
||||
text=True, check=True).stdout
|
||||
return json.loads(text)
|
||||
|
||||
|
||||
# ---- self-test -------------------------------------------------------------------------------
|
||||
|
||||
def _entry(name, *labels):
|
||||
return {"name": name, "properties": [{"name": "LABELS", "value": list(labels)}]}
|
||||
|
||||
|
||||
def _doc(*entries):
|
||||
return {"tests": list(entries)}
|
||||
|
||||
|
||||
BASE = [
|
||||
_entry("DirectGLES.AScenario.One", "integration-gpu"),
|
||||
_entry("DirectGLES.AScenario.Two", "integration-gpu"),
|
||||
_entry("DirectGLES.ForcedDepthStencilEmulation.BScenario.Three", "integration-gpu"),
|
||||
_entry("DirectGLES.Split.AScenario.One", "integration-gpu", "integration-split"),
|
||||
_entry("DirectGLES.Spawn.F1.AScenario.Two", "integration-gpu", "integration-spawn"),
|
||||
_entry("DirectGLES.Tcp.ForcedDs.BScenario.Three", "integration-gpu", "integration-tcp"),
|
||||
_entry("DirectVulkan.AScenario.One", "integration-gpu"),
|
||||
_entry("DirectVulkan.MagmaOnlyScenario.Four", "integration-gpu"),
|
||||
_entry("DirectVulkan.Split.AScenario.One", "integration-magma-all-split"),
|
||||
_entry("DirectVulkan.Tcp.Fm.MagmaOnlyScenario.Four", "integration-magma-tcp"),
|
||||
_entry("TcpServer.Start"),
|
||||
]
|
||||
|
||||
|
||||
def _run(document, exemptions):
|
||||
lines = []
|
||||
rc = check(document, exemptions, out=lines.append)
|
||||
return rc, "\n".join(lines)
|
||||
|
||||
|
||||
def self_test():
|
||||
failures = []
|
||||
ran = []
|
||||
|
||||
def expect(label, document, exemptions, rc, *needles, absent=()):
|
||||
ran.append(label)
|
||||
got, text = _run(document, exemptions)
|
||||
if got != rc or any(n not in text for n in needles) or any(n in text for n in absent):
|
||||
failures.append(f"{label}: rc {got} (want {rc}); output:\n{text}")
|
||||
|
||||
expect("tails normalise on both sides", _doc(*BASE), "", 0,
|
||||
"DirectGLES: monolith 3, on a gated split arm 3", "missing 0")
|
||||
expect("a monolith case on no arm reds BY NAME",
|
||||
_doc(*BASE, _entry("DirectGLES.CScenario.Five", "integration-gpu")), "", 1,
|
||||
"DirectGLES.CScenario.Five is registered on monolith")
|
||||
expect("an informational-only arm is not DirectGLES coverage",
|
||||
_doc(*BASE, _entry("DirectGLES.CScenario.Five", "integration-gpu"),
|
||||
_entry("DirectGLES.Split.CScenario.Five", "integration-magma-full-split")), "", 1,
|
||||
"DirectGLES.CScenario.Five is registered on monolith")
|
||||
expect("an informational tier IS DirectVulkan coverage, and is reported as such", _doc(*BASE), "", 0,
|
||||
"DirectVulkan: monolith 2, on a gated split arm 1", "informational tiers only 1")
|
||||
expect("an arm-less entry without integration-gpu is on neither side",
|
||||
_doc(*BASE, _entry("DirectGLES.VerifySplit.CScenario.Five", "integration-verify-split")), "", 0)
|
||||
expect("PushMonolithArm (integration-split, no arm) is a MONOLITH case",
|
||||
_doc(*BASE, _entry("DirectGLES.PushMonolithArm.CScenario.Five", "integration-gpu",
|
||||
"integration-split")), "", 1,
|
||||
"DirectGLES.CScenario.Five is registered on monolith")
|
||||
expect("an exemption covers a missing case",
|
||||
_doc(*BASE, _entry("DirectGLES.CScenario.Five", "integration-gpu")),
|
||||
"CScenario.* mechanism toggles a process-local mask", 0, "exempt 1 (mechanism 1)")
|
||||
expect("a stale exemption reds",
|
||||
_doc(*BASE), "AScenario.One no-records query only", 1, "is STALE")
|
||||
expect("an exemption about nothing reds",
|
||||
_doc(*BASE), "ZScenario.* mechanism gone", 1, "matches no monolith case")
|
||||
expect("pending-fix without an owner reds",
|
||||
_doc(*BASE, _entry("DirectGLES.CScenario.Five", "integration-gpu")),
|
||||
"CScenario.Five pending-fix red on spawn", 1, "names no owner")
|
||||
expect("pending-fix owned by a package passes",
|
||||
_doc(*BASE, _entry("DirectGLES.CScenario.Five", "integration-gpu")),
|
||||
"CScenario.Five pending-fix red on spawn until P8-B lands", 0)
|
||||
expect("pending-fix owned by a DEBTS.md row passes",
|
||||
_doc(*BASE, _entry("DirectGLES.CScenario.Five", "integration-gpu")),
|
||||
"CScenario.Five pending-fix red on spawn (DEBTS.md row: default framebuffer)", 0)
|
||||
expect("an unknown reason class reds",
|
||||
_doc(*BASE, _entry("DirectGLES.CScenario.Five", "integration-gpu")),
|
||||
"CScenario.Five flaky it is slow", 1, "is not one of")
|
||||
expect("an unscoped single-backend row reds",
|
||||
_doc(*BASE, _entry("DirectGLES.MagmaOnlyScenario.Four", "integration-gpu")),
|
||||
"MagmaOnlyScenario.* single-backend Magma's lane", 1, "must be scoped")
|
||||
expect("a scoped single-backend row exempts only its backend",
|
||||
_doc(*BASE, _entry("DirectGLES.MagmaOnlyScenario.Four", "integration-gpu")),
|
||||
"DirectGLES:MagmaOnlyScenario.* single-backend Magma's lane", 0)
|
||||
expect("a duplicated pattern reds",
|
||||
_doc(*BASE, _entry("DirectGLES.CScenario.Five", "integration-gpu")),
|
||||
"CScenario.* mechanism a\nCScenario.* mechanism b", 1, "listed twice")
|
||||
expect("an unparseable backend entry reds", _doc(*BASE, _entry("DirectGLES.Split.Oops", "integration-split")),
|
||||
"", 1, "does not parse")
|
||||
expect("an empty monolith side reds", _doc(*[e for e in BASE if e["name"].startswith("DirectVulkan")]),
|
||||
"", 1, "DirectGLES: no monolith cases")
|
||||
expect("a row with no reason reds", _doc(*BASE), "AScenario.Two mechanism", 1, "needs <pattern>")
|
||||
# The real table must at least parse (its coverage needs a build; the gate run checks that).
|
||||
if DEFAULT_EXEMPTIONS.exists():
|
||||
errors = []
|
||||
parse_exemptions(DEFAULT_EXEMPTIONS.read_text(), errors)
|
||||
if errors:
|
||||
failures.append("the checked-in exemption table does not parse:\n" + "\n".join(errors))
|
||||
for failure in failures:
|
||||
print(f"::error::self-test: {failure}", file=sys.stderr)
|
||||
print(f"split_coverage self-test: {len(ran)} cases + the checked-in table's parse, "
|
||||
f"{len(failures)} failure(s), {'OK' if not failures else 'FAILED'}")
|
||||
return 1 if failures else 0
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.split("\n", 1)[0])
|
||||
parser.add_argument("build_dir", nargs="?", help="a configured build (runs ctest --show-only=json-v1)")
|
||||
parser.add_argument("--json", help="a saved `ctest --show-only=json-v1` document instead of a build")
|
||||
parser.add_argument("--exemptions", default=str(DEFAULT_EXEMPTIONS))
|
||||
parser.add_argument("--self-test", action="store_true")
|
||||
args = parser.parse_args()
|
||||
if args.self_test:
|
||||
return self_test()
|
||||
if bool(args.build_dir) == bool(args.json):
|
||||
parser.error("give exactly one of build_dir or --json")
|
||||
document = json.loads(Path(args.json).read_text()) if args.json else ctest_document(args.build_dir)
|
||||
return check(document, Path(args.exemptions).read_text())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+217
@@ -0,0 +1,217 @@
|
||||
#!/usr/bin/env python3
|
||||
"""P8-SE: PipeCatalogueTest's unmigrated-emulation list IS the set of call sites in the tree.
|
||||
|
||||
THE QUESTION. `MGPipeUnmigratedEmulation("<name>")` (MG_Pipe/PipeApply.h) names one emulation
|
||||
that reaches into client memory; a split server aborts on it, a monolith arm runs past it. The
|
||||
test `PipeCatalogue.EveryUnmigratedEmulationIsNamedOnce` (MG_Test/Pipe/PipeCatalogueTest.cpp)
|
||||
pins the LIST of names, and nothing compared that list with the tree: it drifted twice without a
|
||||
red (P8-B found a name the list never had; P8-SE a name whose only call site no transport could
|
||||
reach). This asserts, every one an error:
|
||||
|
||||
* every name in the test's `kNames[]` has EXACTLY ONE call site in the product sources;
|
||||
* every call site's name is in `kNames[]`;
|
||||
* `kNames[]` has no duplicate;
|
||||
* every call is spelled with a string literal (a computed name cannot be checked).
|
||||
|
||||
PRODUCT SOURCES are MobileGL/ minus MG_Test/ and MG_IntegrationTest/ (tests call the function
|
||||
with literals of their own), in C/C++ files (.c .cc .cpp .h .hpp .inc .mm). Comments are masked
|
||||
before matching, string literals are kept, so a name quoted in a comment is not a call site.
|
||||
|
||||
Usage: unmigrated_emulation_sites.py [repo-root] (default: this script's repository)
|
||||
unmigrated_emulation_sites.py --self-test
|
||||
"""
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
LIST_FILE = Path("MobileGL/MG_Test/Pipe/PipeCatalogueTest.cpp")
|
||||
TEST_NAME = "EveryUnmigratedEmulationIsNamedOnce"
|
||||
SOURCE_ROOT = Path("MobileGL")
|
||||
EXCLUDED = (Path("MobileGL/MG_Test"), Path("MobileGL/MG_IntegrationTest"))
|
||||
SUFFIXES = {".c", ".cc", ".cpp", ".h", ".hpp", ".inc", ".mm"}
|
||||
CALL = re.compile(r"\bMGPipeUnmigratedEmulation\s*\(")
|
||||
LITERAL_CALL = re.compile(r'\bMGPipeUnmigratedEmulation\s*\(\s*"((?:[^"\\]|\\.)*)"\s*\)')
|
||||
# The declaration and the definition: the return type (and any qualifier) right before the name
|
||||
# on its line.
|
||||
DECLARATION = re.compile(r"\bvoid\s+(?:[A-Za-z_]\w*::)*$")
|
||||
|
||||
|
||||
def mask_comments(text):
|
||||
"""`text` with every comment character replaced by a space (newlines kept, so offsets and line
|
||||
numbers survive); string and character literals are left as they are."""
|
||||
out = list(text)
|
||||
i, n = 0, len(text)
|
||||
while i < n:
|
||||
c = text[i]
|
||||
if c == "/" and i + 1 < n and text[i + 1] == "/":
|
||||
while i < n and text[i] != "\n":
|
||||
out[i] = " "
|
||||
i += 1
|
||||
elif c == "/" and i + 1 < n and text[i + 1] == "*":
|
||||
end = text.find("*/", i + 2)
|
||||
end = n if end < 0 else end + 2
|
||||
for k in range(i, end):
|
||||
if text[k] != "\n":
|
||||
out[k] = " "
|
||||
i = end
|
||||
elif c in "\"'":
|
||||
# R"(...)" raw strings: skip to the matching delimiter.
|
||||
if c == '"' and i > 0 and text[i - 1] == "R":
|
||||
close = text.find("(", i)
|
||||
delim = text[i + 1:close]
|
||||
end = text.find(")" + delim + '"', close)
|
||||
i = n if end < 0 else end + len(delim) + 2
|
||||
continue
|
||||
i += 1
|
||||
while i < n and text[i] != c:
|
||||
i += 2 if text[i] == "\\" else 1
|
||||
i += 1
|
||||
else:
|
||||
i += 1
|
||||
return "".join(out)
|
||||
|
||||
|
||||
def list_names(root, errors):
|
||||
path = root / LIST_FILE
|
||||
try:
|
||||
text = mask_comments(path.read_text(encoding="utf-8"))
|
||||
except OSError as exc:
|
||||
errors.append(f"{LIST_FILE}: cannot read ({exc})")
|
||||
return []
|
||||
test = text.find(TEST_NAME)
|
||||
block = re.search(r"kNames\s*\[\s*\]\s*=\s*\{(.*?)\};", text[test:], re.S) if test >= 0 else None
|
||||
if block is None:
|
||||
errors.append(f"{LIST_FILE}: no `kNames[] = {{ ... }};` in {TEST_NAME}")
|
||||
return []
|
||||
return re.findall(r'"((?:[^"\\]|\\.)*)"', block.group(1))
|
||||
|
||||
|
||||
def call_sites(root, errors):
|
||||
"""{name: [file:line, ...]} over the product sources."""
|
||||
sites = {}
|
||||
base = root / SOURCE_ROOT
|
||||
for path in sorted(base.rglob("*")):
|
||||
if path.suffix not in SUFFIXES or not path.is_file():
|
||||
continue
|
||||
rel = path.relative_to(root)
|
||||
if any(rel.is_relative_to(ex) for ex in EXCLUDED):
|
||||
continue
|
||||
text = mask_comments(path.read_text(encoding="utf-8", errors="replace"))
|
||||
if "MGPipeUnmigratedEmulation" not in text:
|
||||
continue
|
||||
literal_starts = set()
|
||||
for match in LITERAL_CALL.finditer(text):
|
||||
line = text.count("\n", 0, match.start()) + 1
|
||||
sites.setdefault(match.group(1), []).append(f"{rel.as_posix()}:{line}")
|
||||
literal_starts.add(match.start())
|
||||
for match in CALL.finditer(text):
|
||||
if match.start() in literal_starts:
|
||||
continue
|
||||
prefix = text[text.rfind("\n", 0, match.start()) + 1:match.start()]
|
||||
if DECLARATION.search(prefix):
|
||||
continue
|
||||
line = text.count("\n", 0, match.start()) + 1
|
||||
errors.append(f"{rel.as_posix()}:{line}: MGPipeUnmigratedEmulation called without a string "
|
||||
f"literal - the name cannot be checked against {LIST_FILE.name}")
|
||||
return sites
|
||||
|
||||
|
||||
def check(root):
|
||||
errors = []
|
||||
names = list_names(root, errors)
|
||||
sites = call_sites(root, errors)
|
||||
seen = set()
|
||||
for name in names:
|
||||
if name in seen:
|
||||
errors.append(f"{LIST_FILE}: \"{name}\" is listed twice")
|
||||
seen.add(name)
|
||||
for name in sorted(seen):
|
||||
where = sites.get(name, [])
|
||||
if not where:
|
||||
errors.append(f"\"{name}\" is in {LIST_FILE.name}'s list and has no call site in the tree "
|
||||
f"(retired? take it out of the list)")
|
||||
elif len(where) > 1:
|
||||
errors.append(f"\"{name}\" has {len(where)} call sites ({', '.join(where)}); one site per name")
|
||||
for name in sorted(set(sites) - seen):
|
||||
errors.append(f"\"{name}\" is called at {', '.join(sites[name])} and is not in {LIST_FILE.name}'s "
|
||||
f"list")
|
||||
return names, sites, errors
|
||||
|
||||
|
||||
def run(root):
|
||||
names, sites, errors = check(root)
|
||||
for err in errors:
|
||||
print(f"error: {err}")
|
||||
total = sum(len(v) for v in sites.values())
|
||||
state = "OK" if not errors else f"{len(errors)} error(s)"
|
||||
print(f"unmigrated emulation sites: {len(names)} listed, {total} call sites - {state}")
|
||||
return 1 if errors else 0
|
||||
|
||||
|
||||
def self_test():
|
||||
"""Each rule reds on a synthetic tree and a matching tree is green."""
|
||||
listing = """
|
||||
TEST(PipeCatalogue, EveryUnmigratedEmulationIsNamedOnce) {
|
||||
// "commented-out-name" is not in the list
|
||||
const char* const kNames[] = {
|
||||
%s
|
||||
};
|
||||
}
|
||||
"""
|
||||
product = """
|
||||
void MGPipeUnmigratedEmulation(const char* name);
|
||||
void Site() {
|
||||
// MGPipeUnmigratedEmulation("in-a-comment");
|
||||
/* MGPipeUnmigratedEmulation("in-a-block-comment"); */
|
||||
%s
|
||||
}
|
||||
"""
|
||||
cases = [
|
||||
("a matching tree", ['"a",', '"b",'], ['MGPipeUnmigratedEmulation("a");',
|
||||
'MG_Pipe::MGPipeUnmigratedEmulation( "b" );'], 0),
|
||||
("a stray listed name", ['"a",', '"b",', '"stray",'], ['MGPipeUnmigratedEmulation("a");',
|
||||
'MGPipeUnmigratedEmulation("b");'], 1),
|
||||
("an unlisted call site", ['"a",'], ['MGPipeUnmigratedEmulation("a");',
|
||||
'MGPipeUnmigratedEmulation("b");'], 1),
|
||||
("two sites for one name", ['"a",'], ['MGPipeUnmigratedEmulation("a");',
|
||||
'MGPipeUnmigratedEmulation("a");'], 1),
|
||||
("a duplicated list entry", ['"a",', '"a",'], ['MGPipeUnmigratedEmulation("a");'], 1),
|
||||
("a computed name", ['"a",'], ['MGPipeUnmigratedEmulation("a");',
|
||||
'MGPipeUnmigratedEmulation(name);'], 1),
|
||||
]
|
||||
failures = 0
|
||||
for label, listed, calls, want in cases:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
(root / LIST_FILE).parent.mkdir(parents=True)
|
||||
(root / LIST_FILE).write_text(listing % "\n".join(" " + s for s in listed))
|
||||
src = root / "MobileGL/MG_Backend/Site.cpp"
|
||||
src.parent.mkdir(parents=True)
|
||||
src.write_text(product % "\n".join(" " + c for c in calls))
|
||||
# A test's own literal call is not a product call site.
|
||||
other = root / "MobileGL/MG_Test/Other/OtherTest.cpp"
|
||||
other.parent.mkdir(parents=True)
|
||||
other.write_text('void T() { MGPipeUnmigratedEmulation("only-in-a-test"); }\n')
|
||||
_, _, errors = check(root)
|
||||
got = 1 if errors else 0
|
||||
if got != want:
|
||||
failures += 1
|
||||
print(f"self-test FAILED: {label}: rc {got} (want {want}); errors: {errors}")
|
||||
print("self-test " + ("OK" if failures == 0 else f"FAILED ({failures})") + f": {len(cases)} cases")
|
||||
return 1 if failures else 0
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("root", nargs="?", default=str(Path(__file__).resolve().parents[2]))
|
||||
parser.add_argument("--self-test", action="store_true")
|
||||
args = parser.parse_args()
|
||||
if args.self_test:
|
||||
return self_test()
|
||||
return run(Path(args.root))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,65 @@
|
||||
# Monolith integration cases that are on NO split arm, and why (P8-A, ID-P8-2).
|
||||
# Read by scripts/ci/split_coverage.py; its docstring states every rule a row must keep.
|
||||
#
|
||||
# [<Backend>:]<gtest pattern> <reason-class> <one-line reason>
|
||||
#
|
||||
# Reason classes:
|
||||
# mechanism the case asserts a process-local mechanism or pins one arm by design
|
||||
# (MGL_ITEST_MONOLITH_MECHANISM_FILTER in MG_IntegrationTest/CMakeLists.txt)
|
||||
# single-backend the case belongs to the OTHER backend and skips on this one; scoped to this one
|
||||
# no-records the workload never reaches a verb (answered from the caps mirror or the
|
||||
# client's own error surface), so ScenarioFixture's armed split assertion
|
||||
# (EmitSeq must advance) is red by construction
|
||||
# inproc-peek reads server state through an in-process peek only an inproc arm can answer
|
||||
# pending-fix red on a split arm today; the reason names the package or DEBTS.md row that
|
||||
# fixes it, and the row goes when the case is registered (a stale row is an error)
|
||||
#
|
||||
# Evidence for every row: docs/Disaggregated/notes/p8/A.md (per-arm census, junit per case).
|
||||
|
||||
# ---- mechanism: MGL_ITEST_MONOLITH_MECHANISM_FILTER, pinned to monolith by construction -------
|
||||
HandleRecycleScenario.* mechanism pointer-key ABA / slot recycling inside one process (integration-monolith-control)
|
||||
CsoContentAddressingScenario.* mechanism toggles the process-local CSO content-addressing switch
|
||||
ResourceSubsystemControlScenario.* mechanism toggles the process-local P3a push mask
|
||||
ObjectSubsystemControlScenario.* mechanism toggles the process-local P4a push mask
|
||||
PipeVerifyArmingScenario.* mechanism same-address-space verify comparator; its split arm is build-verify's integration-verify-split
|
||||
PoisonOmissionScenario.* mechanism withheld-stamp oracle; its split arm is build-verify's VerifySplitPoisonOmitted entries
|
||||
StorageBufferRegrowScenario.NStorageDefinitionsCostNMapPersistentRoundtripsNotOnePerDraw mechanism counts synchronous stats-slot roundtrips of direct persistent adoption
|
||||
DirectGLES:MonolithAttachmentClearScenario.* mechanism pins the push-monolith arm (DirectGLES.PushMonolithArm., ID-107); the split clear-attachment path is F1WireScenario's
|
||||
DirectVulkan:DualBlockScenario.* mechanism needs MOBILEGL_IPC_ROLE_SPLIT_STATE=1; its lane is integration-dualblock-split (Espryt) and the Magma census filters it out
|
||||
|
||||
# ---- single-backend: Magma's cases, skipping on Espryt ----------------------------------------
|
||||
DirectGLES:MagmaRunAheadScenario.* single-backend Magma run-ahead lane only (integration-magma-runahead)
|
||||
DirectGLES:MagmaWireCacheScenario.* single-backend Magma wire-cache lane only (integration-magma-caches)
|
||||
DirectGLES:MagmaWireReclaimScenario.* single-backend Magma wire-arm store reclaim
|
||||
DirectGLES:MagmaVertexLayoutScenario.* single-backend Magma's vertex format map (Espryt hands GL_FIXED to the driver)
|
||||
DirectGLES:PrimitivesGeneratedNoXfbScenario.* single-backend the stream-query defect and its reroute are DirectVulkan's
|
||||
DirectGLES:ImageLoadStoreSsoScenario.AnImageArrayAlongsideAnotherDescriptorKeepsBothBindings single-backend DirectVulkan's descriptor binding remap
|
||||
DirectGLES:UnwrittenPositionOutputScenario.CapturingAnUnwrittenPositionStillDraws single-backend pins DirectVulkan's gl_Position injection (Espryt gap noted in the case)
|
||||
DirectGLES:F1WireScenario.CopyImageInPlaceOverlapDeclinesAndLeavesTheLevelAlone single-backend Magma wire-arm decline (CONTRACT-P7 3.2 copy-image-in-place)
|
||||
DirectGLES:F1WireScenario.GenerateMipmapDepthStencilDeclinesAndKeepsTheSession single-backend Magma wire-arm decline (depth-stencil-mipmap)
|
||||
DirectGLES:F1WireScenario.MultisampleBlitFromASingleSampleSourceDeclinesAndKeepsTheSession single-backend Magma wire-arm decline (multisample-blit-aspect)
|
||||
DirectGLES:F1WireScenario.MultisampleBlitOntoAMultisampleDestinationDeclinesAndKeepsTheSession single-backend Magma wire-arm decline (multisample-blit-shape)
|
||||
DirectGLES:F1WireScenario.ShortUniformBufferRangePadsMissingBytes single-backend Magma short-UBO compatibility policy
|
||||
DirectGLES:F1WireScenario.SubWordUniformBufferRangePadsMissingBytes single-backend Magma short-UBO compatibility policy
|
||||
DirectGLES:F1WireScenario.UnalignedAtomicCounterRangeDeclinesAndTheSessionLives single-backend Magma descriptor-alignment decline
|
||||
DirectGLES:F1WireScenario.GenerateMipmapWithoutNativeBlitPixels single-backend Magma shader-mip arm (MGITEST_MAGMA_FORCE_SHADER_MIPMAP, Magma Fm lane)
|
||||
DirectGLES:F1WireScenario.GenerateMipmapDepthWithoutNativeBlitPixels single-backend Magma depth shader-mip arm (MGITEST_MAGMA_FORCE_SHADER_MIPMAP, Magma Fm lane)
|
||||
DirectGLES:F1WireScenario.GenerateMipmapWithoutAShaderArmShapeDeclinesAndKeepsTheSession single-backend Magma wire-arm decline (mipmap-shader-format-or-shape, P8-F; its split arms are DirectVulkan.{Split,Spawn}.ShaderMipDecline.)
|
||||
|
||||
# ---- no-records: EmitSeq does not move, so the armed split assertion is red by construction ----
|
||||
AdvertisedLimitsScenario.ComputeLocalSizeComesFromTheLinkedProgram no-records limits query answered from the client's CapsMirror
|
||||
AdvertisedLimitsScenario.ComputeUniformBlocksIsAnAmountAnApplicationCouldActuallyAllocate no-records limits query answered from the client's CapsMirror
|
||||
AdvertisedLimitsScenario.ComputeWorkGroupLimitsAreTheCapsBlocksAnswer no-records limits query answered from the client's CapsMirror
|
||||
AdvertisedLimitsScenario.EveryBufferLimitIsWithinItsAdvertisedRange no-records limits query answered from the client's CapsMirror
|
||||
AdvertisedLimitsScenario.EveryGL45CoreMinimumIsMet no-records limits query answered from the client's CapsMirror
|
||||
AdvertisedLimitsScenario.IndexedTargetSizeSurvivesDivisionByItsBindingCount no-records limits query answered from the client's CapsMirror
|
||||
AdvertisedLimitsScenario.PerStageBlockCountsFitInTheirBindingPoints no-records limits query answered from the client's CapsMirror
|
||||
AdvertisedLimitsScenario.ViewportArrayLimitsMeetTheirGL43Floors no-records limits query answered from the client's CapsMirror
|
||||
SpirvShaderBinaryScenario.AnUnsupportedBinaryFormatIsRejectedInsteadOfSilentlyAccepted no-records shader-binary error surface stays on the client
|
||||
SpirvShaderBinaryScenario.CompileShaderOnASpirvShaderIsInvalidOperationAndShaderSourceTakesItBack no-records shader-binary error surface stays on the client
|
||||
SpirvShaderBinaryScenario.ShaderBinaryFormatIsAdvertisedExactlyOnce no-records extension-string query answered from the client's CapsMirror
|
||||
SpirvShaderBinaryScenario.SpecializeShaderErrorSurfaceMatchesTheExtension no-records shader-binary error surface stays on the client
|
||||
ProgramPipelineScenario.AReservedNameTakesStateBeforeItIsAProgramPipeline no-records a reserved pipeline name's state is client-side and draws nothing
|
||||
|
||||
# ---- pending-fix -------------------------------------------------------------------------------
|
||||
# (none: P8-SE fixed the default-framebuffer depth/stencil case and registered it, notes/p8/SE.md)
|
||||
@@ -24,9 +24,19 @@
|
||||
# RingAllocate the fast path on the hot upload route
|
||||
# FlushPendingRangesNow the three-tier drain: tier 1 is an INVALIDATE_BUFFER map + memcpy
|
||||
# for a whole-buffer flush or a range >= 128 KiB, tier 2 the upload
|
||||
# ring + glCopyBufferSubData, tier 3 UploadRangeNow
|
||||
# ring + glCopyBufferSubData, tier 3 UploadRangeNow. PINNED since
|
||||
# ID-P8-14 (see below)
|
||||
# FlushPendingRangesFrom the SAME three-tier drain, on the arm that ships. Born in P3a
|
||||
#
|
||||
# ID-P8-14 PINS THE TENTH TOO. dev f973008c changed FlushPendingRangesNow on purpose: on Adreno 830 a
|
||||
# partial range-invalidating map of a store that still has an upload-ring glCopyBufferSubData queued
|
||||
# loses the copy (create-instancing drew whole terrain sections empty, SSIM 0.870), so the ring tier
|
||||
# stamps ringCopyRetireSerial and a partial range waits behind an unretired copy. P8 merged dev
|
||||
# (37174242) and P8-MF mirrored the rule into FlushPendingRangesFrom (via InvalidateFlushAccessFor).
|
||||
# The base ref CI passes (37da3c3a) predates the fix, so the tenth row can no longer be compared
|
||||
# against <ref-a>; both ladders are now PINNED rows, re-pinned together on the reviewed post-fix
|
||||
# bodies, and still compared on every run.
|
||||
#
|
||||
# THE ELEVENTH IS HERE BY INTEGRATOR DECISION ID-15, and it is the whole reason the row about the
|
||||
# tenth is not decorative. On this tree Managers.cpp has TWO arms: `#if MOBILEGL_PIPE_PUSH` holds
|
||||
# FlushPendingRangesFrom, `#else` holds FlushPendingRangesNow byte-identically, and BOTH of a push
|
||||
@@ -36,9 +46,10 @@
|
||||
# would exit 2 rather than run). The consequence, and what ID-15 closes: a push build compiles no
|
||||
# FlushPendingRangesNow at all, so a gate that hashed only that name protected text the shipping
|
||||
# build never sees, and a tier-threshold edit made in the ladder that DOES ship would pass it. So
|
||||
# both names are hashed. The pull build's ladder is compared against the base ref; the push build's
|
||||
# is compared, ALWAYS AND WHETHER OR NOT <ref-a> DEFINES IT, against a sha pinned at the commit
|
||||
# where that body was reviewed - see PINNED_FUNCTIONS.
|
||||
# both names are hashed. The push build's ladder is compared, ALWAYS AND WHETHER OR NOT <ref-a>
|
||||
# DEFINES IT, against a sha pinned at the commit where that body was reviewed - see
|
||||
# PINNED_FUNCTIONS. The pull build's ladder was compared against the base ref until ID-P8-14 pinned
|
||||
# it the same way (see the note under the list above).
|
||||
#
|
||||
# "ALWAYS" IS INTEGRATOR DECISION ID-41 AND IT IS A CHANGE. Until P5 this text said "pinned" while
|
||||
# the implementation consulted the pin only as a FALLBACK, when <ref-a> did not define the function
|
||||
@@ -50,7 +61,8 @@
|
||||
# InvalidateFlushAccessFor, the pull arm (FlushPendingRangesNow) is byte-identical across that
|
||||
# change and G1 reports .text +0, so it is the intended change to the eleventh row rather than
|
||||
# drift - and the answer is to RE-PIN it, not to revert it and not to let the row stop being
|
||||
# compared. The OTHER TEN stay ref-a-vs-ref-b: nothing about them moved.
|
||||
# compared. The other nine stay ref-a-vs-ref-b: nothing about them moved (the tenth moved at
|
||||
# ID-P8-14 and was pinned then).
|
||||
#
|
||||
# THE TENTH IS HERE BY INTEGRATOR DECISION ID-11, resolving a contradiction inside the brief.
|
||||
# D-F's "Decision: nine functions" table omits FlushPendingRangesNow, but BRIEF-P3A.md:420 calls it
|
||||
@@ -99,24 +111,33 @@
|
||||
set -u -o pipefail
|
||||
|
||||
SOURCE_PATH=MobileGL/MG_Backend/DirectGLES/Managers.cpp
|
||||
# The ten that exist at the P3a base ref, so their baseline is read out of <ref-a>.
|
||||
FUNCTIONS="IsPoolable EnrollIntoPool AcquireFromPool TrimBufferPool ClearBufferPool ProcessDeferredBufferReleases CreateRingStorage RingAvailable RingAllocate FlushPendingRangesNow"
|
||||
# The ELEVENTH (ID-15), and it is a different kind of row: it was BORN in P3a, so there was no
|
||||
# body at the base ref to compare it with, and its baseline is PINNED below and consulted
|
||||
# UNCONDITIONALLY (ID-41 - see the long note at the top of this file).
|
||||
# The nine unpinned rows: they exist at the P3a base ref, so their baseline is read out of <ref-a>.
|
||||
FUNCTIONS="IsPoolable EnrollIntoPool AcquireFromPool TrimBufferPool ClearBufferPool ProcessDeferredBufferReleases CreateRingStorage RingAvailable RingAllocate"
|
||||
# The TENTH and the ELEVENTH, and they are a different kind of row: their baseline is PINNED below
|
||||
# and consulted UNCONDITIONALLY (ID-41 - see the long note at the top of this file). The eleventh
|
||||
# (ID-15) was BORN in P3a, so there was no body at the base ref to compare it with; the tenth joined
|
||||
# it at ID-P8-14, when a reviewed fix moved it past the base ref. PINNED_FUNCTIONS is in the fixed
|
||||
# order, because apply_pinned_shas appends the pinned rows in that order.
|
||||
#
|
||||
# THE PIN, AND WHAT RE-PINS IT. Whoever moves this body deliberately replaces BOTH lines and
|
||||
# writes the decision beside them; a pin with no commit and no decision next to it is a number
|
||||
# nobody can audit.
|
||||
# 3e298c9a 37fc94ff... ID-15, P3a: the two-arm shape, reviewed and accepted
|
||||
# 3dadd4c1 172b0222... ID-41, P5 (b1): [Fix] (DirectGLES): make the extent hostBase is good
|
||||
# for a parameter of the flush ladder, so tier 1's widening refusal is
|
||||
# live code the moment a SEG_STAGE snapshot is narrower than the queued
|
||||
# range. <- CURRENT
|
||||
PINNED_FUNCTIONS="FlushPendingRangesFrom"
|
||||
PINNED_BASELINE_REF=3dadd4c1
|
||||
PINNED_BASELINE_DECISION=ID-41
|
||||
PINNED_SHA_FlushPendingRangesFrom=172b022273db01b16e772d15b269ffcd797fe38c767f7354d83ce113a66040d0
|
||||
# THE PIN, AND WHAT RE-PINS IT. Whoever moves one of these bodies deliberately replaces the shas
|
||||
# AND the commit AND the decision, and writes a line here; a pin with no commit and no decision
|
||||
# next to it is a number nobody can audit.
|
||||
# 3e298c9a From 37fc94ff... ID-15, P3a: the two-arm shape, reviewed and accepted
|
||||
# 3dadd4c1 From 172b0222... ID-41, P5 (b1): [Fix] (DirectGLES): make the extent hostBase is
|
||||
# good for a parameter of the flush ladder, so tier 1's widening
|
||||
# refusal is live code the moment a SEG_STAGE snapshot is narrower
|
||||
# than the queued range.
|
||||
# ac9ab078 Now c40cae66... ID-P8-14, P8-MF: dev f973008c (merged at 37174242) keeps a partial
|
||||
# From 33bc4cb8... range-invalidating map behind an upload-ring copy still queued on the
|
||||
# store - Adreno 830 loses the queued copy - in FlushPendingRangesNow;
|
||||
# ac9ab078 mirrors it into FlushPendingRangesFrom (the stamp on
|
||||
# the ring tier, the guard in InvalidateFlushAccessFor, the
|
||||
# whole-buffer exemption kept). <- CURRENT
|
||||
PINNED_FUNCTIONS="FlushPendingRangesNow FlushPendingRangesFrom"
|
||||
PINNED_BASELINE_REF=ac9ab078
|
||||
PINNED_BASELINE_DECISION=ID-P8-14
|
||||
PINNED_SHA_FlushPendingRangesNow=c40cae66f021160478ef9af6bcf5e8ef0bf26721486173695d5257263c97723f
|
||||
PINNED_SHA_FlushPendingRangesFrom=33bc4cb855b932ed4fb0de44a4cfa7a9be8aca34da267ccd2fc9fedfad4d3328
|
||||
ALL_FUNCTIONS="$FUNCTIONS $PINNED_FUNCTIONS"
|
||||
EXPECTED_FUNCTION_COUNT=11
|
||||
# The functions the self-test perturbs, one control each. ClearBufferPool is small, has no forward
|
||||
@@ -353,21 +374,22 @@ apply_pinned_shas() {
|
||||
for name in $PINNED_FUNCTIONS; do
|
||||
eval "pinned=\$PINNED_SHA_$name"
|
||||
if [ -z "$pinned" ] || [ "$pinned" = "PLACEHOLDER_SHA" ]; then
|
||||
say "$name has no pinned baseline sha; the eleventh row cannot be compared"
|
||||
say "$name has no pinned baseline sha; that row cannot be compared"
|
||||
return 2
|
||||
fi
|
||||
grep -v " $name\$" "$file" > "$file.unpinned" || true
|
||||
mv -f "$file.unpinned" "$file" || return 2
|
||||
# Appended LAST, which is also its position in the fixed order (it is the eleventh of eleven),
|
||||
# so the header's "stdout is always the sha list in the fixed order" stays true and a baseline
|
||||
# captured by redirect still diffs cleanly against a two-ref run.
|
||||
# Appended LAST, in PINNED_FUNCTIONS order, which is also their position in the fixed order
|
||||
# (the tenth and the eleventh of eleven), so the header's "stdout is always the sha list in the
|
||||
# fixed order" stays true and a baseline captured by redirect still diffs cleanly against a
|
||||
# two-ref run.
|
||||
printf '%s %s\n' "$pinned" "$name" >> "$file"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
# The BASELINE side (<ref-a>). The TEN are extracted strictly, so a rename of one of THOSE is
|
||||
# exit 2 rather than a silently short list. FlushPendingRangesFrom then takes the PINNED sha
|
||||
# The BASELINE side (<ref-a>). The NINE are extracted strictly, so a rename of one of THOSE is
|
||||
# exit 2 rather than a silently short list. Each pinned row then takes the PINNED sha
|
||||
# WHETHER OR NOT <ref-a> defines it (ID-41), and a <ref-a> that defines it DIFFERENTLY is
|
||||
# reported - loudly - because the two answers disagreeing is itself a finding rather than a
|
||||
# reason to prefer the ref.
|
||||
@@ -379,7 +401,7 @@ extract_baseline() {
|
||||
return 2
|
||||
fi
|
||||
if ! python3 "$PY" extract "$blob" "$FUNCTIONS" > "$WORK_DIR/$out.sha" 2>"$WORK_DIR/$out.err"; then
|
||||
say "the baseline ref '$ref' does not define the pre-P3a ten exactly once each:"
|
||||
say "the baseline ref '$ref' does not define the nine unpinned rows exactly once each:"
|
||||
sed 's/^/[p3a-untouched] /' "$WORK_DIR/$out.err" >&2
|
||||
return 2
|
||||
fi
|
||||
@@ -387,7 +409,7 @@ extract_baseline() {
|
||||
eval "pinned=\$PINNED_SHA_$name"
|
||||
atRef=$(python3 "$PY" extract "$blob" "$name" 2>/dev/null | awk -v n="$name" '$2 == n { print $1 }')
|
||||
if [ -z "$atRef" ]; then
|
||||
say "$name is not defined at '$ref' (it was born in P3a): its baseline is the sha PINNED in"
|
||||
say "$name is not defined at '$ref' (a pinned row): its baseline is the sha PINNED in"
|
||||
say " this script, captured at $PINNED_BASELINE_REF ($PINNED_BASELINE_DECISION)"
|
||||
elif [ "$atRef" != "$pinned" ]; then
|
||||
say "NOTE: $name IS defined at '$ref' and hashes"
|
||||
@@ -517,14 +539,16 @@ if [ "${1:-}" = "--self-test" ]; then
|
||||
# --- THE PINNED ROW (ID-41) -----------------------------------------------------------------
|
||||
# TWO more controls, and they exist because none of the five above can see the pin at all: every
|
||||
# one of them compares one extraction of the working tree against another, so they would all be
|
||||
# green on a build of this script in which PINNED_SHA_* was never read by anything. The eleventh
|
||||
# row's whole claim is "the baseline is the PIN, not <ref-a>", and that claim needs its own two.
|
||||
# green on a build of this script in which PINNED_SHA_* was never read by anything. A pinned
|
||||
# row's whole claim is "the baseline is the PIN, not <ref-a>", and that claim needs its own two -
|
||||
# per pinned row (both ladders since ID-P8-14).
|
||||
for target in $PINNED_FUNCTIONS; do
|
||||
eval "pinned=\$PINNED_SHA_$target"
|
||||
|
||||
# (1) PIN PRECEDENCE, positive. A baseline that carries some OTHER sha for the pinned row -
|
||||
# which is the shape of every <ref-a> CI passes today, since ff2994d9 and 37da3c3a both DEFINE
|
||||
# FlushPendingRangesFrom - must come out of apply_pinned_shas carrying the PIN. This is the
|
||||
# FlushPendingRangesFrom and both predate ID-P8-14's FlushPendingRangesNow - must come out of
|
||||
# apply_pinned_shas carrying the PIN. This is the
|
||||
# control that would have caught the ID-41 defect itself: before it, the pin was consulted
|
||||
# only when <ref-a> lacked the function, so the row silently reverted to ref-a-vs-ref-b the
|
||||
# moment a base ref had one.
|
||||
@@ -537,7 +561,7 @@ if [ "${1:-}" = "--self-test" ]; then
|
||||
got=$(awk -v n="$target" '$2 == n { print $1 }' "$WORK_DIR/pinprec.sha")
|
||||
if [ "$got" != "$pinned" ]; then
|
||||
say "PIN CONTROL FAILED: a baseline that carried a DIFFERENT sha for $target came out as"
|
||||
say " '${got:-<absent>}' and not as the pin ($pinned). The eleventh row would be compared"
|
||||
say " '${got:-<absent>}' and not as the pin ($pinned). That pinned row would be compared"
|
||||
say " against <ref-a> again, which is exactly the defect $PINNED_BASELINE_DECISION closed."
|
||||
exit 2
|
||||
fi
|
||||
@@ -545,7 +569,7 @@ if [ "${1:-}" = "--self-test" ]; then
|
||||
|
||||
# (2) A ONE-TOKEN EDIT TO THE PINNED LADDER, negative, AGAINST THE PIN. The comparison must go
|
||||
# red, must name the row, and must say that the row is PINNED - R-16's "a control asserts its
|
||||
# OWN failure string": the pinned row and the ten ref-a rows are fixed differently, and a
|
||||
# OWN failure string": the pinned rows and the nine ref-a rows are fixed differently, and a
|
||||
# reader who gets only the generic paragraph goes looking for a diff against <ref-a> that does
|
||||
# not exist.
|
||||
python3 "$PY" perturb-token "$WORK_DIR/pristine.cpp" "$WORK_DIR/pinperturbed.cpp" \
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
# CreateRingStorage glBufferStorageEXT + persistent|coherent, retires at serial + 1
|
||||
# RingAvailable self-heals a stale context generation
|
||||
# RingAllocate the fast path on the hot upload route
|
||||
# FlushPendingRangesNow the three-tier drain, pull arm
|
||||
# FlushPendingRangesNow the three-tier drain, pull arm. PINNED since ID-P8-14: dev
|
||||
# f973008c moved it past <ref-a> on purpose (the parent's note)
|
||||
# FlushPendingRangesFrom the SAME three-tier drain, on the arm that ships (ID-15). Born
|
||||
# in P3a, so its baseline is PINNED, not read from <ref-a>
|
||||
#
|
||||
@@ -125,6 +126,11 @@
|
||||
# be RE-PINNED on the reviewed P5 body rather than reverted or quietly left comparing
|
||||
# against <ref-a>. This script says so on stderr, in both directions, and keeps the PIN -
|
||||
# because the pin is the reviewed text.
|
||||
#
|
||||
# ID-P8-14 extends the same treatment to FlushPendingRangesNow: dev f973008c changed it
|
||||
# past every <ref-a> CI passes (the Adreno 830 queued-ring-copy guard), P8-MF mirrored the
|
||||
# rule into FlushPendingRangesFrom, and both ladders were re-pinned together on the
|
||||
# reviewed post-fix bodies.
|
||||
set -u -o pipefail
|
||||
|
||||
# One row per region: <name>@<kind>@<path>. The ORDER is the fixed order the sha list is printed
|
||||
@@ -151,21 +157,32 @@ ShouldUseCaveatTextureFormat@function@MobileGL/MG_Backend/DirectGLES/Utils.cpp"
|
||||
|
||||
EXPECTED_FUNCTION_COUNT=17
|
||||
|
||||
# The one region born in P3a, so there is no body at P4a's base ref that this phase reviewed: its
|
||||
# baseline is PINNED and consulted UNCONDITIONALLY (DEVIATIONS D-N/2, and ID-41 for the parent).
|
||||
# The two flush ladders. FlushPendingRangesFrom was born in P3a, so there is no body at P4a's base
|
||||
# ref that this phase reviewed; FlushPendingRangesNow was moved past the base ref by a reviewed fix
|
||||
# (ID-P8-14, dev f973008c: a partial range-invalidating map must not overtake an upload-ring copy
|
||||
# still queued on the store - Adreno 830 loses the copy). Both baselines are PINNED and consulted
|
||||
# UNCONDITIONALLY (DEVIATIONS D-N/2, and ID-41 for the parent).
|
||||
#
|
||||
# THE PIN, AND WHAT RE-PINS IT. Whoever moves this body deliberately replaces BOTH lines and
|
||||
# writes the decision beside them; a pin with no commit and no decision next to it is a number
|
||||
# nobody can audit. The parent script carries the identical table and the two must not drift.
|
||||
# 3e298c9a 37fc94ff... ID-15, P3a: the two-arm shape, reviewed and accepted
|
||||
# 3dadd4c1 172b0222... ID-41, P5 (b1): [Fix] (DirectGLES): make the extent hostBase is good
|
||||
# for a parameter of the flush ladder, so tier 1's widening refusal is
|
||||
# live code the moment a SEG_STAGE snapshot is narrower than the queued
|
||||
# range. <- CURRENT
|
||||
PINNED_FUNCTIONS="FlushPendingRangesFrom"
|
||||
PINNED_BASELINE_REF=3dadd4c1
|
||||
PINNED_BASELINE_DECISION=ID-41
|
||||
PINNED_SHA_FlushPendingRangesFrom=172b022273db01b16e772d15b269ffcd797fe38c767f7354d83ce113a66040d0
|
||||
# THE PIN, AND WHAT RE-PINS IT. Whoever moves one of these bodies deliberately replaces the shas
|
||||
# AND the commit AND the decision, and writes a line here; a pin with no commit and no decision
|
||||
# next to it is a number nobody can audit. The parent script carries the identical table and the
|
||||
# two must not drift.
|
||||
# 3e298c9a From 37fc94ff... ID-15, P3a: the two-arm shape, reviewed and accepted
|
||||
# 3dadd4c1 From 172b0222... ID-41, P5 (b1): [Fix] (DirectGLES): make the extent hostBase is
|
||||
# good for a parameter of the flush ladder, so tier 1's widening
|
||||
# refusal is live code the moment a SEG_STAGE snapshot is narrower
|
||||
# than the queued range.
|
||||
# ac9ab078 Now c40cae66... ID-P8-14, P8-MF: dev f973008c (merged at 37174242) keeps a partial
|
||||
# From 33bc4cb8... range-invalidating map behind an upload-ring copy still queued on the
|
||||
# store - Adreno 830 loses the queued copy - in FlushPendingRangesNow;
|
||||
# ac9ab078 mirrors it into FlushPendingRangesFrom (the stamp on
|
||||
# the ring tier, the guard in InvalidateFlushAccessFor, the
|
||||
# whole-buffer exemption kept). <- CURRENT
|
||||
PINNED_FUNCTIONS="FlushPendingRangesNow FlushPendingRangesFrom"
|
||||
PINNED_BASELINE_REF=ac9ab078
|
||||
PINNED_BASELINE_DECISION=ID-P8-14
|
||||
PINNED_SHA_FlushPendingRangesNow=c40cae66f021160478ef9af6bcf5e8ef0bf26721486173695d5257263c97723f
|
||||
PINNED_SHA_FlushPendingRangesFrom=33bc4cb855b932ed4fb0de44a4cfa7a9be8aca34da267ccd2fc9fedfad4d3328
|
||||
|
||||
# The regions the self-test perturbs, one negative control each. FOUR, exactly as D-N requires, and
|
||||
# each is a different shape so that a control which only ever perturbed the easy one cannot leave
|
||||
@@ -502,8 +519,8 @@ extract_ref() {
|
||||
return $?
|
||||
}
|
||||
|
||||
# The BASELINE side (<ref-a>). The sixteen ordinary regions are extracted strictly, so a rename of
|
||||
# one of THOSE is exit 2 rather than a silently short list. FlushPendingRangesFrom then takes the
|
||||
# The BASELINE side (<ref-a>). The fifteen ordinary regions are extracted strictly, so a rename of
|
||||
# one of THOSE is exit 2 rather than a silently short list. Each pinned row then takes the
|
||||
# PINNED sha (DEVIATIONS D-N/2) whether or not <ref-a> defines it, and a <ref-a> that defines it
|
||||
# DIFFERENTLY is reported - loudly - because the two answers disagreeing is itself a finding.
|
||||
extract_baseline() {
|
||||
@@ -517,7 +534,7 @@ extract_baseline() {
|
||||
mv -f "$WORK_DIR/$out.spec.tmp" "$WORK_DIR/$out.spec" || return 2
|
||||
done
|
||||
if ! python3 "$PY" extract "$WORK_DIR/$out.spec" > "$WORK_DIR/$out.sha" 2>"$WORK_DIR/$out.err"; then
|
||||
say "the baseline ref '$ref' does not define the sixteen unpinned regions exactly once each:"
|
||||
say "the baseline ref '$ref' does not define the fifteen unpinned regions exactly once each:"
|
||||
sed 's/^/[p4a-untouched] /' "$WORK_DIR/$out.err" >&2
|
||||
return 2
|
||||
fi
|
||||
@@ -608,8 +625,8 @@ compare_lists() {
|
||||
say " $labelA ${shaA:-<not found>}"
|
||||
say " $labelB ${shaB:-<not found>}"
|
||||
if is_pinned_row "$name"; then
|
||||
# ITS OWN MESSAGE, and that is R-16 rather than decoration: the pinned row and the
|
||||
# sixteen ref-a rows fail differently and are fixed differently, so a reader who sees
|
||||
# ITS OWN MESSAGE, and that is R-16 rather than decoration: the pinned rows and the
|
||||
# fifteen ref-a rows fail differently and are fixed differently, so a reader who sees
|
||||
# only the generic paragraph below goes looking for a diff against <ref-a> that does not
|
||||
# exist.
|
||||
say " $name IS A PINNED ROW ($PINNED_BASELINE_DECISION): its baseline is ALWAYS the sha"
|
||||
@@ -640,10 +657,10 @@ compare_lists() {
|
||||
# A gate that always says "identical" and a gate that is working produce the same green, so the
|
||||
# comparison has to be shown failing. Both controls run: the POSITIVE ones (an untouched copy
|
||||
# compares equal; an edit OUTSIDE the regions is invisible; a baseline that names another sha for
|
||||
# the PINNED row is overridden by the pin) rule out a comparison that reports every region as
|
||||
# moved, and the NINE NEGATIVE ones - D-N's four regions, each perturbed at the HEAD of its body
|
||||
# and again at its TAIL, plus a ONE-TOKEN edit to the pinned ladder compared AGAINST THE PIN
|
||||
# (ID-41) - rule out the comparison that never reports any, the extraction whose extent stops
|
||||
# a PINNED row is overridden by the pin) rule out a comparison that reports every region as
|
||||
# moved, and the TEN NEGATIVE ones - D-N's four regions, each perturbed at the HEAD of its body
|
||||
# and again at its TAIL, plus a ONE-TOKEN edit to each pinned ladder compared AGAINST THE PIN
|
||||
# (ID-41; two pinned rows since ID-P8-14) - rule out the comparison that never reports any, the extraction whose extent stops
|
||||
# before the closing brace (F-m2), and a pin that nothing consults.
|
||||
if [ "${1:-}" = "--self-test" ]; then
|
||||
[ $# -eq 1 ] || { say "--self-test takes no other arguments"; exit 2; }
|
||||
@@ -750,18 +767,17 @@ if [ "${1:-}" = "--self-test" ]; then
|
||||
# --- THE PINNED ROW (ID-41) -----------------------------------------------------------------
|
||||
# TWO more controls, and they exist because none of the ten above can see the pin at all: every
|
||||
# one of them compares one extraction of the working tree against another, so they would all be
|
||||
# green on a build of this script in which PINNED_SHA_* was never read by anything. The pinned
|
||||
# green on a build of this script in which PINNED_SHA_* was never read by anything. A pinned
|
||||
# row's whole claim is "the baseline is the PIN, not <ref-a>" (D-N/2, ID-41), and that claim
|
||||
# needs its own two.
|
||||
# needs its own two - per pinned row (both ladders since ID-P8-14).
|
||||
for target in $PINNED_FUNCTIONS; do
|
||||
eval "pinned=\$PINNED_SHA_$target"
|
||||
targetSource=$(printf '%s\n' "$REGIONS" | awk -F@ -v n="$target" '$1 == n { print $3 }')
|
||||
[ -n "$targetSource" ] || { say "$target is not one of the regions"; exit 2; }
|
||||
|
||||
# (1) PIN PRECEDENCE, positive. A baseline that carries some OTHER sha for the pinned row -
|
||||
# which is the shape of every <ref-a> CI passes, since 37da3c3a DOES define
|
||||
# FlushPendingRangesFrom and no longer hashes the pin - must come out of apply_pinned_shas
|
||||
# carrying the PIN.
|
||||
# which is the shape of every <ref-a> CI passes, since 37da3c3a DOES define both ladders and
|
||||
# hashes neither pin - must come out of apply_pinned_shas carrying the PIN.
|
||||
grep -v " $target\$" "$WORK_DIR/pristine.sha" > "$WORK_DIR/pinprec.sha" || true
|
||||
printf '%s %s\n' \
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" "$target" \
|
||||
@@ -779,7 +795,7 @@ if [ "${1:-}" = "--self-test" ]; then
|
||||
|
||||
# (2) A ONE-TOKEN EDIT TO THE PINNED LADDER, negative, AGAINST THE PIN. The comparison must go
|
||||
# red, must name the region, and must say the region is PINNED - R-16's "a control asserts its
|
||||
# OWN failure string": the pinned row and the sixteen ref-a rows are fixed differently, and a
|
||||
# OWN failure string": the pinned rows and the fifteen ref-a rows are fixed differently, and a
|
||||
# reader who gets only the generic paragraph goes looking for a diff against <ref-a> that does
|
||||
# not exist.
|
||||
rm -rf "$WORK_DIR/pinperturbed"
|
||||
|
||||
Reference in New Issue
Block a user