[MG_Remote, MG_Pipe, MG_Backend, MG_Test] (P7): repair F2 ID-49, byteless-level and R8 lane regressions

This commit is contained in:
2026-09-23 13:44:37 -04:00
parent 10c5168be2
commit caaedd7abe
7 changed files with 197 additions and 12 deletions
+19 -1
View File
@@ -429,10 +429,28 @@ namespace MobileGL::MG_Remote::Server {
const Uint64 pixels = width * height;
if (pixels > kUint64Max / bpp) return rejectReadback();
const Uint64 tight = pixels * bpp;
if (tight != info.DstSize || tight > m_maxReplyBytes ||
// PH-3's bound is the SERVER's answer size: w*h*bpp against its own maxReplyBytes,
// checked before the scratch grows. It is not a rule about DstSize.
if (tight > m_maxReplyBytes ||
tight > static_cast<Uint64>(std::numeric_limits<SizeT>::max())) {
return rejectReadback();
}
// ID-49: THE REPLY CROSSES TIGHT, WHATEVER DstSize THE CLIENT SENT. The server reads with
// neutral pack state into a w*h*bpp extent that IS the reply payload and the client
// scatters it per its own GL_PACK_* state, so a DstSize that disagrees with the tight
// extent (a client that sized its destination with pack padding) is logged and the tight
// extent this side owns is read and posted - never the client's number, so a wrong
// DstSize cannot make this a short read into uninitialised scratch. F2's first PH-3 draft
// refused the mismatch instead, which broke the ID-49 control
// (ServerLoopEglTest.AReadPixelsReplyIsTheTightExtentWhateverDstSizeTheClientSent); the
// bound above is what PH-3 needs and it does not depend on DstSize.
if (tight != info.DstSize) {
MGLOG_E_ONCE("MG_Remote server: read_pixels DstSize %llu != tight w*h*bpp %llu "
"(%ux%u, bpp %llu); reading the tight extent (ID-49)",
static_cast<unsigned long long>(info.DstSize),
static_cast<unsigned long long>(tight), info.Box.W, info.Box.H,
static_cast<unsigned long long>(bpp));
}
const MG_Backend::GlobalBackendFunctionsTable* table = Table("read_pixels");
if (table == nullptr || table->GL.ReadPixels == nullptr) {
+30 -7
View File
@@ -385,6 +385,16 @@ namespace MobileGL::MG_Remote::Server {
// a resource_subdata against it is RequireDeclaredLevel's refusal rather than a write
// into storage that has no texels. Only a NEGATIVE component (a 32-bit carrier word past
// INT_MAX) is malformed.
//
// SO IS A LEVEL WHOSE FORMAT HAS NO UNCOMPRESSED SIZE HERE (F2 lane repair). A declared
// TextureInternalFormat::Unknown level - the TextureView, TextureViewAlias and
// TextureUploadShape split lanes all declare one, a 1x1x1 level of an Unknown-format
// texture, before any upload - is legal and byteless in exactly the empty level's sense:
// declared with a zero byte bound, so any run into it is refused by name
// (StagedTextureStore.LevelBound) and the declaration itself is not a session Fatal. What
// stays a named refusal here is a declaration this server cannot bound: a negative
// component, or a known-format level past the server's own device limits (or whose byte
// count overflows).
void NoteLevelDefined(Uint64 key, Uint16 uploadTarget, Uint16 level, const IntVec3& extent,
Uint8 resourceTarget = static_cast<Uint8>(MG_Pipe::MGPipeResourceTarget::Tex2D),
Uint32 internalFormat = static_cast<Uint32>(TextureInternalFormat::RGBA8)) {
@@ -394,9 +404,10 @@ namespace MobileGL::MG_Remote::Server {
const Bool supportsSubData = StagedTextureTargetSupportsSubData(resourceTarget);
const Bool validExtent = extent.x() >= 0 && extent.y() >= 0 && extent.z() >= 0;
const Bool emptyExtent = validExtent && (extent.x() == 0 || extent.y() == 0 || extent.z() == 0);
if (MG_Util::GetSizedInternalFormatSizeInBytes(
static_cast<TextureInternalFormat>(internalFormat)) == 0 || !validExtent ||
(supportsSubData && !emptyExtent && !StagedTextureDeclaredLevelByteBound(
const Bool sizedFormat = MG_Util::GetSizedInternalFormatSizeInBytes(
static_cast<TextureInternalFormat>(internalFormat)) != 0;
if (!validExtent ||
(supportsSubData && sizedFormat && !emptyExtent && !StagedTextureDeclaredLevelByteBound(
resourceTarget, internalFormat, extent, m_deviceLimits, &byteBound))) {
SessionFail(MGFatalFamily::ProtocolCorruption,
"MGPipe: Fatal{ProtocolCorruption, \"StagedTextureStore.NoteLevelDefined\"} - "
@@ -589,22 +600,34 @@ namespace MobileGL::MG_Remote::Server {
// coverage answer for such a level, not an error.
void RequireDeclaredLevel(LevelShadow& shadow, Uint64 key, Uint16 uploadTarget,
Uint16 level, const IntVec3& extent) {
if (!shadow.Defined || shadow.InternalFormat == 0) {
// `Defined` alone, which only NoteLevelDefined sets. The first draft also refused
// `InternalFormat == 0`, but 0 is TextureInternalFormat::R8, so every R8 upload read
// as "arrived before the level was declared".
if (!shadow.Defined) {
SessionFail(MGFatalFamily::ProtocolCorruption,
"MGPipe: Fatal{ProtocolCorruption, \"StagedTextureStore.LevelExtent\"} - "
"resource_subdata arrived before the server declared texture level "
"(key=%llu, uploadTarget=%u, level=%u)",
static_cast<unsigned long long>(key), uploadTarget, level);
}
if (!StagedTextureTargetSupportsSubData(shadow.ResourceTarget) ||
shadow.DeclaredByteBound == 0) {
if (!StagedTextureTargetSupportsSubData(shadow.ResourceTarget)) {
SessionFail(MGFatalFamily::ProtocolCorruption,
"MGPipe: Fatal{ProtocolCorruption, \"StagedTextureStore.Target\"} - "
"resource_subdata is not legal for the server-declared texture target "
"or empty level (key=%llu, uploadTarget=%u, level=%u, target=%u)",
"(key=%llu, uploadTarget=%u, level=%u, target=%u)",
static_cast<unsigned long long>(key), uploadTarget, level,
static_cast<Uint32>(shadow.ResourceTarget));
}
if (shadow.DeclaredByteBound == 0) {
SessionFail(MGFatalFamily::ProtocolCorruption,
"MGPipe: Fatal{ProtocolCorruption, \"StagedTextureStore.LevelBound\"} - "
"resource_subdata into a byteless declared level: its extent is empty or "
"its format has no uncompressed size on this server "
"(key=%llu, uploadTarget=%u, level=%u, extent=%d,%d,%d, internalFormat=%u)",
static_cast<unsigned long long>(key), uploadTarget, level,
shadow.Extent.x(), shadow.Extent.y(), shadow.Extent.z(),
shadow.InternalFormat);
}
if (shadow.Extent == extent) return;
SessionFail(MGFatalFamily::ProtocolCorruption,
"MGPipe: Fatal{ProtocolCorruption, \"StagedTextureStore.LevelExtent\"} - "