mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-16 14:33:24 +09:00
[MGPipe, MG_Remote] cut a texture level's staged run at the stage chunk
ONE RECORD'S BLOB IS STAGED WHOLE IN SEG_STAGE, a linear arena, so a texture
level larger than the segment's chunk budget was Fatal{RingOverrun, "SEG_STAGE"}
at the encoder rather than a split - and the CI traces hit it: the texture half of
resource_subdata stages the whole level shadow regardless of how little of it
changed, and a 512x128x33 GL_RGBA32F level is 34,603,008 bytes while a 192-cube
GL_RGBA16 level is 56,623,104, both against the default 32 MiB segment. Three
retrace cases aborted there: iterationt-in-world and iterationt-nodsa-in-world in
both backends, and iterationrp-in-world in DirectVulkan.
THE CLIENT now cuts such a level into WHOLE-WIDTH SLABS, one resource_subdata
each (TextureEmit.h's MGPipeForEachTextureSlab, driven at MGPipeStageChunkBytes -
the same cap PipeFill.cpp's buffer walks are cut at). A piece is a set of
consecutive rows of the level shadow, so its box names both its texels and its
byte run; whole slices are the coarsest cut, a slice bigger than the cap falls
back to whole rows and a row bigger than the cap to whole texels inside one row.
Every piece is emitted, dirty or not: the server assembles one level image out of
the runs, so a piece left out would leave a hole no texel read can answer. Each
piece carries at least one region (its clipped dirty rects, or its own box when
none reaches it) because RegionCount == 0 remains the whole-level spelling, and
each region's SrcOffset is rebased onto its own piece's run - MGPipeTypes.h has
always said SrcOffset is "into the blob" - while the strides stay the level's. A
level that FITS keeps the single whole-level record, field for field what it has
always been, which is what every existing gate is written against.
THE SERVER now assembles levels from those runs. StagedTextureStore::AdoptRun
places one run at an image offset, its coverage set is exactly the runs it has
adopted (StagedShadowStore's CoverageAdd, the buffer half's helpers), and only a
FULLY covered level satisfies IsCovered / RequireLevelBytes - a level with one
piece missing is as unreadable as one that never arrived, and it is the same
Fatal{StageSnapshotTooNarrow}. The whole-level spelling survives as Adopt, its
offset-0 replacement, and the two are told apart by the run's own LENGTH: the
whole-level run is the level's complete shadow whatever its box says, a piece's
run is exactly its box's byte extent. Both adoption call sites -
Ops_H_TextureSubData and PipeApply.cpp's hookless fallback, which is what Magma
takes - read the offset that way.
THE PROTOCOL IS UNCHANGED: no field moved, no caps bit was added. The one
compatibility statement is that a split level now crosses as several records of
one apply batch, so an OLD server (which replaces the level on every record) would
keep only the last piece - inproc runs both roles out of one library, so the
constraint is noted here rather than armed with a gate.
Tests. TextureEmit.ALevelTooLargeForTheStageChunkIsCutIntoSlabs drives the split
at MGPipeStageChunkBytesFor's clamp with both trace shapes (5 and 7 slabs), the
row-granularity and texel-granularity fallbacks, the three shapes that refuse to
cut, the region clipping/rebasing, and the piece no rect reaches.
StagedTextureStoreTest gains the multi-run assembly, the gap that must not read as
coverage, the partial-level Fatal by name, the run-offset discriminator, and two
production cases - the applier's hookless arm and DirectGLES's real TextureSubData
hook - that would put both halves at the front of the image if the offset were
dropped.
This commit is contained in:
@@ -1018,14 +1018,25 @@ namespace MobileGL::MG_Pipe {
|
||||
// Their staged bytes still belong to the server before SEG_STAGE retires. Keep the
|
||||
// existing backend hooks authoritative when present, and use this fallback otherwise.
|
||||
void AdoptTextureWithoutBackendHook(const MGPipeResourceRecord& stored, const MGPSubData& upload,
|
||||
const void* bytes) {
|
||||
const void* bytes, const MGPSubRegion* regions) {
|
||||
if (MG_Config::Transport == MG_Config::TransportMode::Monolith || !bytes || upload.Blob.Size == 0) return;
|
||||
auto& store = MG_Remote::Server::ServerStagedTexture();
|
||||
const auto& desc = stored.Desc;
|
||||
store.Adopt(MG_Remote::Server::StagedTextureStore::KeyForHandle(upload.Res),
|
||||
MGPipeSubDataUploadTargetOf(upload.Target), upload.Level,
|
||||
MG_Remote::Server::StagedTextureUploadExtent(desc, upload),
|
||||
bytes, static_cast<SizeT>(upload.Blob.Size));
|
||||
const Uint64 key = MG_Remote::Server::StagedTextureStore::KeyForHandle(upload.Res);
|
||||
const Uint16 target = MGPipeSubDataUploadTargetOf(upload.Target);
|
||||
const IntVec3 extent = MG_Remote::Server::StagedTextureUploadExtent(desc, upload);
|
||||
// RegionCount == 0 IS the whole-level spelling - "the run is the level shadow" - so it
|
||||
// is adopted with the spelling that replaces the level; every other record names a RUN
|
||||
// of the level by its own box (fix A2: a level too large to stage whole crosses as
|
||||
// slabs, one record each, and the first of them is at the level's first byte).
|
||||
if (upload.RegionCount == 0) {
|
||||
store.Adopt(key, target, upload.Level, extent, bytes,
|
||||
static_cast<SizeT>(upload.Blob.Size));
|
||||
return;
|
||||
}
|
||||
store.AdoptRun(key, target, upload.Level, extent,
|
||||
MG_Remote::Server::StagedTextureRunImageOffset(upload, regions), bytes,
|
||||
static_cast<SizeT>(upload.Blob.Size));
|
||||
}
|
||||
|
||||
void DefineTextureWithoutBackendHook(const MGPResourceDesc& desc, const MGPRespecifiedLevel* level) {
|
||||
@@ -1120,10 +1131,13 @@ namespace MobileGL::MG_Pipe {
|
||||
// deliberately holds no byte pointer). The hook copies the run into the server's
|
||||
// staged-texture store keyed by this record's own handle; it is a no-op in
|
||||
// monolith, so the monolith shape keeps P5's pointer-dropping expression exactly.
|
||||
// The REGIONS travel with it because a record may carry a RUN of its level rather
|
||||
// than the whole of it (fix A2): they are what places that run in the level image,
|
||||
// and the applier's pending set - which already has them - is not the store's.
|
||||
if (g_resourceOps != nullptr && g_resourceOps->TextureSubData != nullptr) {
|
||||
g_resourceOps->TextureSubData(record.Res, record, bytes, regions);
|
||||
} else {
|
||||
AdoptTextureWithoutBackendHook(*stored, record, bytes);
|
||||
AdoptTextureWithoutBackendHook(*stored, record, bytes, regions);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user