[MG_Pipe, MG_Remote, MG_Test] (P7): bound create-render-state CSO slots

This commit is contained in:
2026-09-23 13:43:43 -04:00
parent 1997fd8878
commit 54a8e3fadb
5 changed files with 185 additions and 3 deletions
+15 -3
View File
@@ -1667,10 +1667,22 @@ namespace MobileGL::MG_Pipe {
void MGPipeApplyCreateRenderState(const MGPRenderStateDesc& desc, const void* chunkBytes) {
MOBILEGL_ASSERT(desc.Cso.Slot >= kMGPipeFirstAllocatableSlot,
"create_render_state named the reserved slot 0");
if (desc.Cso.Slot >= g_applier.RenderStateCsos.size()) {
g_applier.RenderStateCsos.resize(desc.Cso.Slot + 1);
MGPipeRenderStateCsoRecord* recordAt =
RecordAt(g_applier.RenderStateCsos, desc.Cso.Slot, kMGPipeMaxRenderStateCsoSlots);
if (recordAt == nullptr) {
#if MOBILEGL_BUILD_DISAGGREGATED
MGPipeSessionFail(MGPipeFatalFamily::ProtocolCorruption,
"MGPipe: Fatal{ProtocolCorruption, \"CreateRenderState.Cso.Slot\"} - "
"create_render_state {slot=%u, gen=%u} is outside the record table bound (%u)",
desc.Cso.Slot, desc.Cso.Gen, kMGPipeMaxRenderStateCsoSlots);
#else
MGP_TRIP_WIRE_REPORT("MGPipe: " MGP_TRIP_WIRE_TAG("ProtocolCorruption")
" create_render_state {slot=%u, gen=%u} is outside the record table bound (%u)",
desc.Cso.Slot, desc.Cso.Gen, kMGPipeMaxRenderStateCsoSlots);
#endif
return;
}
MGPipeRenderStateCsoRecord& record = g_applier.RenderStateCsos[desc.Cso.Slot];
MGPipeRenderStateCsoRecord& record = *recordAt;
// NEITHER BRANCH MAY LEAVE ITS BAD CASE TO MOBILEGL_ASSERT. The slot the client is
// naming may be a RECYCLED one whose record still holds the previous occupant's 396
+3
View File
@@ -162,6 +162,9 @@ namespace MobileGL::MG_Pipe {
// bounded by kMGPipeMaxResourceSlots and each grows only to its own dense high-water mark.
inline constexpr Uint32 kMGPipeMaxResourceSlots = 1u << 20;
inline constexpr Uint32 kMGPipeMaxVertexElementsSlots = 1u << 16;
// create_render_state records retain one 396-byte pipeline half each. Keep their
// slot-indexed table bounded independently so a peer cannot request a huge resize.
inline constexpr Uint32 kMGPipeMaxRenderStateCsoSlots = 1u << 16;
// P4a's three, and the argument is written out for each because the records differ in
// size. None is ever allocated by being named: the tables grow to the client's own dense
// high-water mark and no further, so the bound costs nothing until a record is corrupt.
+4
View File
@@ -54,6 +54,10 @@ namespace MobileGL::MG_Pipe {
UnmigratedVerb,
// A call that reached an arm this build did not compile, or ran on the wrong role.
RoleViolation,
#if MOBILEGL_BUILD_DISAGGREGATED
// A malformed peer record rejected by the server-side applier.
ProtocolCorruption,
#endif
};
// What the layer above installs. `line` is the FULLY FORMATTED message, so the hook forwards