mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-18 15:33:22 +09:00
[Feat] (MG_Remote): a read into a pixel pack buffer crosses as read_pixels_to_buffer / get_texture_image_to_buffer and waits for nothing - the server lands the rows through the buffer-write gate on both backends, the client marks the buffer GPU-written, and a device lost with the write still owed ends in Fatal{ReadbackDeclined, "buffer-writeback"}
This commit is contained in:
@@ -301,12 +301,14 @@ constexpr MGPipeVerb MGPipeVerbForWireOp(MGPWireOp op) {
|
||||
case MGPWireOp::QueryCounter: return MGPipeVerb::QueryCounterTimestamp;
|
||||
case MGPWireOp::QueryTimestamp: return MGPipeVerb::GetGpuTimestampNs;
|
||||
case MGPWireOp::DeleteStreamOutput: return MGPipeVerb::DeleteTransformFeedback;
|
||||
case MGPWireOp::ReadPixelsToBuffer: return MGPipeVerb::ReadPixels;
|
||||
case MGPWireOp::GetTextureImageToBuffer: return MGPipeVerb::GetTextureImage;
|
||||
default:
|
||||
return MGPipeVerb::kVerbCount;
|
||||
}
|
||||
}
|
||||
|
||||
inline constexpr SizeT kMGPipeVerbBoundaryOpCount = 32;
|
||||
inline constexpr SizeT kMGPipeVerbBoundaryOpCount = 34;
|
||||
inline constexpr SizeT kMGPipeVerbBoundaryExemptCount = 3;
|
||||
|
||||
// ---- THE §7 ALLOWLIST, DERIVED RATHER THAN WRITTEN (ID-116) --------------------------
|
||||
|
||||
@@ -29,7 +29,7 @@ struct MGPipeScreen {
|
||||
void (*ApplierReset)(const MGPApplierReset* payload);
|
||||
};
|
||||
|
||||
// context: 69 calls. A null entry means the backend does not implement this
|
||||
// context: 71 calls. A null entry means the backend does not implement this
|
||||
// call and the frontend keeps its own path (plan B section 4.1).
|
||||
struct MGPipeContext {
|
||||
void (*QueryCreate)(const MGPQueryDesc* payload);
|
||||
@@ -101,11 +101,13 @@ struct MGPipeContext {
|
||||
void (*SetContextValues)(const MGPContextValues* payload);
|
||||
void (*SetProgramBindings)(const MGPProgramBindings* payload, const void* varTail, Uint32 varTailCount);
|
||||
void (*DeleteStreamOutput)(const MGPStreamOutputBind* payload);
|
||||
void (*ReadPixelsToBuffer)(const MGPReadbackToBuffer* payload);
|
||||
void (*GetTextureImageToBuffer)(const MGPReadbackToBuffer* payload);
|
||||
};
|
||||
|
||||
inline constexpr SizeT kMGPipeScreenCallCount = 12;
|
||||
inline constexpr SizeT kMGPipeContextCallCount = 69;
|
||||
inline constexpr SizeT kMGPipeCallCount = 81;
|
||||
inline constexpr SizeT kMGPipeContextCallCount = 71;
|
||||
inline constexpr SizeT kMGPipeCallCount = 83;
|
||||
|
||||
// A table that is not exactly its call count of function pointers has grown a
|
||||
// member that no generator knows about.
|
||||
|
||||
@@ -340,3 +340,11 @@ inline void MGP_SetProgramBindings(const MGPProgramBindings* payload, const void
|
||||
inline void MGP_DeleteStreamOutput(const MGPStreamOutputBind* payload) {
|
||||
gMGPipeContext.DeleteStreamOutput(payload);
|
||||
}
|
||||
|
||||
inline void MGP_ReadPixelsToBuffer(const MGPReadbackToBuffer* payload) {
|
||||
gMGPipeContext.ReadPixelsToBuffer(payload);
|
||||
}
|
||||
|
||||
inline void MGP_GetTextureImageToBuffer(const MGPReadbackToBuffer* payload) {
|
||||
gMGPipeContext.GetTextureImageToBuffer(payload);
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ inline Bool MGPipeVerify(const MGPBlit& a, const MGPBlit& b, const char** outFie
|
||||
inline Bool MGPipeVerify(const MGPClear& a, const MGPClear& b, const char** outField);
|
||||
inline Bool MGPipeVerify(const MGPMipPlan& a, const MGPMipPlan& b, const char** outField);
|
||||
inline Bool MGPipeVerify(const MGPReadbackInfo& a, const MGPReadbackInfo& b, const char** outField);
|
||||
inline Bool MGPipeVerify(const MGPReadbackToBuffer& a, const MGPReadbackToBuffer& b, const char** outField);
|
||||
inline Bool MGPipeVerify(const MGPDrawInfo& a, const MGPDrawInfo& b, const char** outField);
|
||||
inline Bool MGPipeVerify(const MGPDrawRange& a, const MGPDrawRange& b, const char** outField);
|
||||
inline Bool MGPipeVerify(const MGPDrawIndirect& a, const MGPDrawIndirect& b, const char** outField);
|
||||
@@ -230,6 +231,8 @@ struct MGPipeHasFieldVerifier<MGPMipPlan> : std::true_type {};
|
||||
template <>
|
||||
struct MGPipeHasFieldVerifier<MGPReadbackInfo> : std::true_type {};
|
||||
template <>
|
||||
struct MGPipeHasFieldVerifier<MGPReadbackToBuffer> : std::true_type {};
|
||||
template <>
|
||||
struct MGPipeHasFieldVerifier<MGPDrawInfo> : std::true_type {};
|
||||
template <>
|
||||
struct MGPipeHasFieldVerifier<MGPDrawRange> : std::true_type {};
|
||||
@@ -592,6 +595,11 @@ inline Bool MGPipeVerify(const MGPReadbackInfo& a, const MGPReadbackInfo& b, con
|
||||
return true;
|
||||
}
|
||||
|
||||
inline Bool MGPipeVerify(const MGPReadbackToBuffer& a, const MGPReadbackToBuffer& b, const char** outField) {
|
||||
MGP_FIELDS_MGPReadbackToBuffer(MGP_VERIFY_FIELD)
|
||||
return true;
|
||||
}
|
||||
|
||||
inline Bool MGPipeVerify(const MGPDrawInfo& a, const MGPDrawInfo& b, const char** outField) {
|
||||
MGP_FIELDS_MGPDrawInfo(MGP_VERIFY_FIELD)
|
||||
return true;
|
||||
@@ -749,4 +757,4 @@ inline Bool MGPipeVerify(const MGPVertexBindingPointWire& a, const MGPVertexBind
|
||||
|
||||
#undef MGP_VERIFY_FIELD
|
||||
|
||||
inline constexpr SizeT kMGPipeVerifiedPayloadCount = 82;
|
||||
inline constexpr SizeT kMGPipeVerifiedPayloadCount = 83;
|
||||
|
||||
@@ -151,7 +151,9 @@ enum class MGPWireOp : Uint16 {
|
||||
SetContextValues = 79,
|
||||
SetProgramBindings = 80,
|
||||
DeleteStreamOutput = 81,
|
||||
kOpCount = 82,
|
||||
ReadPixelsToBuffer = 82,
|
||||
GetTextureImageToBuffer = 83,
|
||||
kOpCount = 84,
|
||||
};
|
||||
|
||||
// THE FLAGS, EXPORTED ONCE, INDEXED BY OPCODE (P5 R-13.4). MGPWireRecHeader::Flags is
|
||||
@@ -254,6 +256,8 @@ inline constexpr Uint32 kMGPipeCallFlags[static_cast<SizeT>(MGPWireOp::kOpCount)
|
||||
/* 79 SetContextValues */ static_cast<Uint32>(kNone),
|
||||
/* 80 SetProgramBindings */ static_cast<Uint32>(kVarTail | kHostSpan),
|
||||
/* 81 DeleteStreamOutput */ static_cast<Uint32>(kNone),
|
||||
/* 82 ReadPixelsToBuffer */ static_cast<Uint32>(kNone),
|
||||
/* 83 GetTextureImageToBuffer */ static_cast<Uint32>(kNone),
|
||||
};
|
||||
static_assert(sizeof(kMGPipeCallFlags) / sizeof(kMGPipeCallFlags[0]) ==
|
||||
static_cast<SizeT>(MGPWireOp::kOpCount),
|
||||
@@ -355,6 +359,8 @@ inline constexpr Uint8 kMGPipeCallClasses[static_cast<SizeT>(MGPWireOp::kOpCount
|
||||
/* 79 SetContextValues */ static_cast<Uint8>(kCtxState),
|
||||
/* 80 SetProgramBindings */ static_cast<Uint8>(kCtxState),
|
||||
/* 81 DeleteStreamOutput */ static_cast<Uint8>(kCtxVerb),
|
||||
/* 82 ReadPixelsToBuffer */ static_cast<Uint8>(kCtxVerb),
|
||||
/* 83 GetTextureImageToBuffer */ static_cast<Uint8>(kCtxObject),
|
||||
};
|
||||
static_assert(sizeof(kMGPipeCallClasses) / sizeof(kMGPipeCallClasses[0]) ==
|
||||
static_cast<SizeT>(MGPWireOp::kOpCount),
|
||||
@@ -460,6 +466,8 @@ inline constexpr Uint8 kMGPipeWaitClasses[static_cast<SizeT>(MGPWireOp::kOpCount
|
||||
/* 79 SetContextValues */ static_cast<Uint8>(kWaitNone),
|
||||
/* 80 SetProgramBindings */ static_cast<Uint8>(kWaitNone),
|
||||
/* 81 DeleteStreamOutput */ static_cast<Uint8>(kWaitNone),
|
||||
/* 82 ReadPixelsToBuffer */ static_cast<Uint8>(kWaitNone),
|
||||
/* 83 GetTextureImageToBuffer */ static_cast<Uint8>(kWaitNone),
|
||||
};
|
||||
static_assert(sizeof(kMGPipeWaitClasses) / sizeof(kMGPipeWaitClasses[0]) ==
|
||||
static_cast<SizeT>(MGPWireOp::kOpCount),
|
||||
@@ -1174,6 +1182,22 @@ static_assert(sizeof(MGPWireRec_DeleteStreamOutput) ==
|
||||
((sizeof(MGPWireRecHeader) + sizeof(MGPStreamOutputBind) + 7u) & ~SizeT(7u)),
|
||||
"MGPWireRec_DeleteStreamOutput gained padding; the wire format moved");
|
||||
|
||||
struct alignas(8) MGPWireRec_ReadPixelsToBuffer {
|
||||
MGPWireRecHeader Header;
|
||||
MGPReadbackToBuffer Payload;
|
||||
};
|
||||
static_assert(sizeof(MGPWireRec_ReadPixelsToBuffer) ==
|
||||
((sizeof(MGPWireRecHeader) + sizeof(MGPReadbackToBuffer) + 7u) & ~SizeT(7u)),
|
||||
"MGPWireRec_ReadPixelsToBuffer gained padding; the wire format moved");
|
||||
|
||||
struct alignas(8) MGPWireRec_GetTextureImageToBuffer {
|
||||
MGPWireRecHeader Header;
|
||||
MGPReadbackToBuffer Payload;
|
||||
};
|
||||
static_assert(sizeof(MGPWireRec_GetTextureImageToBuffer) ==
|
||||
((sizeof(MGPWireRecHeader) + sizeof(MGPReadbackToBuffer) + 7u) & ~SizeT(7u)),
|
||||
"MGPWireRec_GetTextureImageToBuffer gained padding; the wire format moved");
|
||||
|
||||
[[noreturn]] inline void MGPipeWireProtocolFatal(const char* call, Uint64 size, Uint64 remaining) {
|
||||
MGLOG_F("MGPipe: protocol corruption applying %s: size=%llu remaining=%llu", call,
|
||||
static_cast<unsigned long long>(size), static_cast<unsigned long long>(remaining));
|
||||
@@ -1466,6 +1490,12 @@ inline Bool MGPipeApplyWireRecord(MGPWireOp op, const void* record, Uint64 size,
|
||||
case MGPWireOp::DeleteStreamOutput:
|
||||
MGP_WIRE_CHECK_BOUNDS(MGPWireRec_DeleteStreamOutput, "DeleteStreamOutput");
|
||||
break;
|
||||
case MGPWireOp::ReadPixelsToBuffer:
|
||||
MGP_WIRE_CHECK_BOUNDS(MGPWireRec_ReadPixelsToBuffer, "ReadPixelsToBuffer");
|
||||
break;
|
||||
case MGPWireOp::GetTextureImageToBuffer:
|
||||
MGP_WIRE_CHECK_BOUNDS(MGPWireRec_GetTextureImageToBuffer, "GetTextureImageToBuffer");
|
||||
break;
|
||||
case MGPWireOp::kInvalid:
|
||||
case MGPWireOp::kOpCount:
|
||||
default:
|
||||
|
||||
@@ -329,6 +329,13 @@ inline constexpr WireLayoutMember kMGPipeWireLayoutMembers[] = {
|
||||
{"MGPReadbackInfo.Level", offsetof(MGPReadbackInfo, Level), sizeof(((MGPReadbackInfo*)nullptr)->Level)},
|
||||
{"MGPReadbackInfo.DstOffset", offsetof(MGPReadbackInfo, DstOffset), sizeof(((MGPReadbackInfo*)nullptr)->DstOffset)},
|
||||
{"MGPReadbackInfo.DstSize", offsetof(MGPReadbackInfo, DstSize), sizeof(((MGPReadbackInfo*)nullptr)->DstSize)},
|
||||
{"MGPReadbackToBuffer", 0, sizeof(MGPReadbackToBuffer)},
|
||||
{"MGPReadbackToBuffer.Src", offsetof(MGPReadbackToBuffer, Src), sizeof(((MGPReadbackToBuffer*)nullptr)->Src)},
|
||||
{"MGPReadbackToBuffer.Dst", offsetof(MGPReadbackToBuffer, Dst), sizeof(((MGPReadbackToBuffer*)nullptr)->Dst)},
|
||||
{"MGPReadbackToBuffer.DstBase", offsetof(MGPReadbackToBuffer, DstBase), sizeof(((MGPReadbackToBuffer*)nullptr)->DstBase)},
|
||||
{"MGPReadbackToBuffer.RowStride", offsetof(MGPReadbackToBuffer, RowStride), sizeof(((MGPReadbackToBuffer*)nullptr)->RowStride)},
|
||||
{"MGPReadbackToBuffer.ImageStride", offsetof(MGPReadbackToBuffer, ImageStride), sizeof(((MGPReadbackToBuffer*)nullptr)->ImageStride)},
|
||||
{"MGPReadbackToBuffer.SwapGroup", offsetof(MGPReadbackToBuffer, SwapGroup), sizeof(((MGPReadbackToBuffer*)nullptr)->SwapGroup)},
|
||||
{"MGPDrawInfo", 0, sizeof(MGPDrawInfo)},
|
||||
{"MGPDrawInfo.Mode", offsetof(MGPDrawInfo, Mode), sizeof(((MGPDrawInfo*)nullptr)->Mode)},
|
||||
{"MGPDrawInfo.IndexSize", offsetof(MGPDrawInfo, IndexSize), sizeof(((MGPDrawInfo*)nullptr)->IndexSize)},
|
||||
@@ -753,4 +760,6 @@ inline constexpr WireCallLayout kMGPipeWireCallLayouts[] = {
|
||||
{"SetContextValues", "MGPContextValues", static_cast<Uint64>(MGPWireOp::SetContextValues), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetProgramBindings", "MGPProgramBindings", static_cast<Uint64>(MGPWireOp::SetProgramBindings), static_cast<Uint64>(kVarTail | kHostSpan), static_cast<Uint64>(kWaitNone)},
|
||||
{"DeleteStreamOutput", "MGPStreamOutputBind", static_cast<Uint64>(MGPWireOp::DeleteStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"ReadPixelsToBuffer", "MGPReadbackToBuffer", static_cast<Uint64>(MGPWireOp::ReadPixelsToBuffer), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"GetTextureImageToBuffer", "MGPReadbackToBuffer", static_cast<Uint64>(MGPWireOp::GetTextureImageToBuffer), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user