mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-20 16:31:57 +09:00
Compare commits
37
Commits
cleanup
...
c5e1e59048
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5e1e59048 | ||
|
|
78b7d6beac | ||
|
|
a96875bf3f | ||
|
|
fe27380ab8 | ||
|
|
52ffc6a7f2 | ||
|
|
810b9b7a9f | ||
|
|
e6c51d0711 | ||
|
|
2ec8e7f4a1 | ||
|
|
bf3e6f8ad3 | ||
|
|
2bd86664ec | ||
|
|
2d86e07ab6 | ||
|
|
71aa995128 | ||
|
|
98d0b96cbe | ||
|
|
16bfab1032 | ||
|
|
91d0cb78c7 | ||
|
|
5968863fb9 | ||
|
|
f98f2067db | ||
|
|
b3155525e8 | ||
|
|
8cd00f42fd | ||
|
|
e50463dc5c | ||
|
|
743d1facba | ||
|
|
570ebde9bc | ||
|
|
e766351299 | ||
|
|
15bd9a676c | ||
|
|
2afa000295 | ||
|
|
f6a0bd3024 | ||
|
|
1039502ee6 | ||
|
|
94e2f2e0d8 | ||
|
|
ea9fc7fa71 | ||
|
|
b0f4f8b744 | ||
|
|
207c31f6db | ||
|
|
e156ea5f7a | ||
|
|
a351836154 | ||
|
|
f4cbaa8945 | ||
|
|
a54ae47ab9 | ||
|
|
0bbe41c291 | ||
|
|
785fed0b00 |
@@ -469,6 +469,23 @@ jobs:
|
|||||||
--env "MOBILEGL_TRANSPORT=inproc;MOBILEGL_IPC_ROLE_SPLIT_STATE=1;MOBILEGL_IPC_STRICT_ERRORS=1;MOBILEGL_IPC_RUN_AHEAD=1"
|
--env "MOBILEGL_TRANSPORT=inproc;MOBILEGL_IPC_ROLE_SPLIT_STATE=1;MOBILEGL_IPC_STRICT_ERRORS=1;MOBILEGL_IPC_RUN_AHEAD=1"
|
||||||
--require-inproc
|
--require-inproc
|
||||||
)
|
)
|
||||||
|
elif [ "${MOBILEGL_CI_TRANSPORT}" = "spawn" ]; then
|
||||||
|
# THE SAME CLIENT KNOBS AS inproc, so the two acceptance lanes differ in exactly one
|
||||||
|
# thing: which PROCESS the server role runs in. They are scrubbed out of the CHILD's
|
||||||
|
# environment by the launcher and read by the client, which is where they belong.
|
||||||
|
#
|
||||||
|
# MOBILEGL_IPC_SERVER_PATH IS DELIBERATELY ABSENT. nativeLibraryDir carries an
|
||||||
|
# install-time hash, so nothing off the device can spell it; TraceReplayActivity
|
||||||
|
# resolves it from getApplicationInfo() when the env asks for spawn, and an explicit
|
||||||
|
# value would override that. --use-pbuffer is NOT optional here: until P12 a spawned
|
||||||
|
# server cannot be handed a window at all, because an ANativeWindow* is a pointer
|
||||||
|
# into the CLIENT's process and SetWindowHandle is refused on the way across with
|
||||||
|
# Fatal{UnmigratedSurface, "AndroidNativeWindow@P12"} (Rule H).
|
||||||
|
extra_retrace_args+=(
|
||||||
|
--env "MOBILEGL_TRANSPORT=spawn;MOBILEGL_IPC_ROLE_SPLIT_STATE=1;MOBILEGL_IPC_STRICT_ERRORS=1;MOBILEGL_IPC_RUN_AHEAD=1"
|
||||||
|
--use-pbuffer
|
||||||
|
--require-spawn
|
||||||
|
)
|
||||||
else
|
else
|
||||||
extra_retrace_args+=(--env "MOBILEGL_TRANSPORT=monolith")
|
extra_retrace_args+=(--env "MOBILEGL_TRANSPORT=monolith")
|
||||||
fi
|
fi
|
||||||
@@ -633,6 +650,13 @@ jobs:
|
|||||||
pattern: MobileGL-android-retrace-result-inproc-acceptance-inproc-*
|
pattern: MobileGL-android-retrace-result-inproc-acceptance-inproc-*
|
||||||
path: retrace-artifacts/inproc-acceptance
|
path: retrace-artifacts/inproc-acceptance
|
||||||
|
|
||||||
|
- name: Download Android spawn acceptance results
|
||||||
|
if: env.MOBILEGL_CI_DISAGGREGATED == 'ON'
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
pattern: MobileGL-android-retrace-result-spawn-acceptance-spawn-*
|
||||||
|
path: retrace-artifacts/spawn-acceptance
|
||||||
|
|
||||||
- name: Render monolith control summary
|
- name: Render monolith control summary
|
||||||
run: |
|
run: |
|
||||||
node tools/trace_replay/render_retrace_summary.mjs \
|
node tools/trace_replay/render_retrace_summary.mjs \
|
||||||
@@ -652,6 +676,11 @@ jobs:
|
|||||||
--group-label "Android Emulator / inproc acceptance" \
|
--group-label "Android Emulator / inproc acceptance" \
|
||||||
--html mobilegl-android-inproc-acceptance.html
|
--html mobilegl-android-inproc-acceptance.html
|
||||||
|
|
||||||
|
- name: Render spawn acceptance summary
|
||||||
|
if: env.MOBILEGL_CI_DISAGGREGATED == 'ON'
|
||||||
|
run: |
|
||||||
|
node tools/trace_replay/render_retrace_summary.mjs --input retrace-artifacts/spawn-acceptance --output-dir android-retrace-summary/spawn-acceptance --title "MobileGL Android spawn acceptance" --group-label "Android Emulator / spawn acceptance" --html mobilegl-android-spawn-acceptance.html
|
||||||
|
|
||||||
- name: Upload Android monolith control summary
|
- name: Upload Android monolith control summary
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
@@ -669,6 +698,15 @@ jobs:
|
|||||||
archive: false
|
archive: false
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Upload Android spawn acceptance summary
|
||||||
|
if: env.MOBILEGL_CI_DISAGGREGATED == 'ON'
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: MobileGL-android-spawn-acceptance-summary-${{ github.sha }}
|
||||||
|
path: android-retrace-summary/spawn-acceptance/mobilegl-android-spawn-acceptance.html
|
||||||
|
archive: false
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
remove-artifact-clutter:
|
remove-artifact-clutter:
|
||||||
name: remove artifact clutter
|
name: remove artifact clutter
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
+98
-21
@@ -1076,6 +1076,13 @@ jobs:
|
|||||||
# ProtocolSmoke and FdPassing - are registered only under MOBILEGL_BUILD_DISAGGREGATED
|
# ProtocolSmoke and FdPassing - are registered only under MOBILEGL_BUILD_DISAGGREGATED
|
||||||
# (MG_Test/CMakeLists.txt), and before this job existed NO cmake invocation anywhere in this
|
# (MG_Test/CMakeLists.txt), and before this job existed NO cmake invocation anywhere in this
|
||||||
# workflow passed that option. They had never been compiled by CI, let alone run.
|
# workflow passed that option. They had never been compiled by CI, let alone run.
|
||||||
|
# Exit gate 9.2. BEFORE the lanes run, because it costs a `ctest -N` and answers the one
|
||||||
|
# question a green lane cannot: did the spawn arm cover the same cases the split arm did?
|
||||||
|
# A spawn lane registered with fewer cases goes green while proving less, and nothing about
|
||||||
|
# a smaller green lane looks wrong.
|
||||||
|
- name: integration-spawn covers integration-split (9.2)
|
||||||
|
run: python3 scripts/ci/spawn_lane_parity.py build-split
|
||||||
|
|
||||||
- name: Unit tests on the split runtime
|
- name: Unit tests on the split runtime
|
||||||
working-directory: build-split
|
working-directory: build-split
|
||||||
env:
|
env:
|
||||||
@@ -1099,6 +1106,14 @@ jobs:
|
|||||||
sudo sysctl -w kernel.core_pattern='/tmp/core.%e.%p'
|
sudo sysctl -w kernel.core_pattern='/tmp/core.%e.%p'
|
||||||
ctest --output-on-failure -L integration-split --no-tests=error -j 4 --output-junit "${RUNNER_TEMP}/split-baseline.xml"
|
ctest --output-on-failure -L integration-split --no-tests=error -j 4 --output-junit "${RUNNER_TEMP}/split-baseline.xml"
|
||||||
python3 ../scripts/ci/junit_tally.py "${RUNNER_TEMP}/split-baseline.xml" --require-split-ran
|
python3 ../scripts/ci/junit_tally.py "${RUNNER_TEMP}/split-baseline.xml" --require-split-ran
|
||||||
|
# Exit gate 9.3: the spawn arm green at the same count. It runs the same cases through a
|
||||||
|
# SECOND PROCESS, so a failure here that the line above did not see is a transport fact
|
||||||
|
# and not a phase one - which is the whole reason both lanes exist.
|
||||||
|
ctest --output-on-failure -L integration-spawn --no-tests=error -j 4 --output-junit "${RUNNER_TEMP}/spawn-baseline.xml"
|
||||||
|
python3 ../scripts/ci/junit_tally.py "${RUNNER_TEMP}/spawn-baseline.xml" --require-spawn-ran
|
||||||
|
ctest --show-only=json-v1 -L '^integration-tcp$' > "${RUNNER_TEMP}/tcp-discovery.json"
|
||||||
|
ctest --output-on-failure -L '^integration-tcp$' --no-tests=error -j 4 --output-junit "${RUNNER_TEMP}/tcp-baseline.xml"
|
||||||
|
python3 ../scripts/ci/junit_tally.py "${RUNNER_TEMP}/tcp-baseline.xml" --require-tcp-ran --require-run-ahead --discovery "${RUNNER_TEMP}/tcp-discovery.json"
|
||||||
|
|
||||||
# Both full transport runs are hard gates. The per-case comparison below
|
# Both full transport runs are hard gates. The per-case comparison below
|
||||||
# remains diagnostic because explicit mechanism controls retain their own mode.
|
# remains diagnostic because explicit mechanism controls retain their own mode.
|
||||||
@@ -1157,9 +1172,12 @@ jobs:
|
|||||||
- name: The split lane really resolved the transport
|
- name: The split lane really resolved the transport
|
||||||
working-directory: build-split
|
working-directory: build-split
|
||||||
run: |
|
run: |
|
||||||
log=MobileGL/MG_IntegrationTest/persistent-map-arm-split-DirectGLES.log
|
# P6: the sink writes one file per ROLE from the base MOBILEGL_LOG_FILE_PATH; the
|
||||||
|
# transport-resolution line is ConfigLoader's, on the CLIENT thread, so it is in the
|
||||||
|
# .client half. The base name itself names no file now.
|
||||||
|
log=MobileGL/MG_IntegrationTest/persistent-map-arm-split-DirectGLES.client.log
|
||||||
if [ ! -f "${log}" ]; then
|
if [ ! -f "${log}" ]; then
|
||||||
echo "::error::${log} does not exist: the DirectGLES.Split.PersistentMapArm. entry never ran, so nothing in this job establishes that MOBILEGL_TRANSPORT ever resolved to inproc in a live process"
|
echo "::error::${log} does not exist: the DirectGLES.Split.PersistentMapArm. entry never ran (or the per-role split renamed it), so nothing in this job establishes that MOBILEGL_TRANSPORT ever resolved to inproc in a live process"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# THE DISTINCTIVE PART OF THE INFO LINE, not the bare KEY=VALUE (review finding M-5):
|
# THE DISTINCTIVE PART OF THE INFO LINE, not the bare KEY=VALUE (review finding M-5):
|
||||||
@@ -1984,6 +2002,14 @@ jobs:
|
|||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
# `dl` / exit gate S7. CHEAP AND EARLY, on a job that only reads the tree: it needs no
|
||||||
|
# build, so a death that names no family is reported in seconds rather than after the
|
||||||
|
# matrix. What it refuses is a std::abort() under MG_Remote/ with no Fatal{Family} marker,
|
||||||
|
# and a family word that appeared without being recorded - the vocabulary drifts on
|
||||||
|
# purpose or not at all (CONTRACT-P6 5.2's D2 ruling).
|
||||||
|
- name: Fatal census (S7)
|
||||||
|
run: python3 scripts/ci/fatal_census.py
|
||||||
|
|
||||||
- name: Load trace cases
|
- name: Load trace cases
|
||||||
id: trace-cases
|
id: trace-cases
|
||||||
run: |
|
run: |
|
||||||
@@ -1995,17 +2021,19 @@ jobs:
|
|||||||
# The subset the verify build retraces ("verify": true in trace_cases.json). It is a
|
# The subset the verify build retraces ("verify": true in trace_cases.json). It is a
|
||||||
# SUBSET of the matrix above, so retrace-verify needs no fixtures of its own.
|
# SUBSET of the matrix above, so retrace-verify needs no fixtures of its own.
|
||||||
echo "verify-matrix=$(python3 tools/trace_replay/trace_cases.py --ci --format github-verify-matrix)" >> "$GITHUB_OUTPUT"
|
echo "verify-matrix=$(python3 tools/trace_replay/trace_cases.py --ci --format github-verify-matrix)" >> "$GITHUB_OUTPUT"
|
||||||
# P5's split subset ("split": true, DirectGLES only). Also a SUBSET of the matrix above,
|
# The split subset: {backend, case, transport} over inproc AND spawn, both backends, for
|
||||||
# so retrace-split needs no fixtures of its own either. It is one case today - OpenRA,
|
# every CI case that has not said `"split": false`. Still a SUBSET of the matrix above,
|
||||||
# which is what the phase gate names - and trace_cases.py refuses a `split` case that is
|
# so retrace-split needs no fixtures of its own. P5 shipped it as one case (OpenRA, which
|
||||||
# not in CI or does not run DirectGLES, so the subset cannot silently become empty.
|
# the phase gate names); P6 widened it to the whole CI matrix, because every bug the
|
||||||
|
# spawn work found was a question about the SERVER's process rather than about one trace.
|
||||||
|
# trace_cases.py refuses a `split` case that is not in CI, so the subset stays a subset.
|
||||||
SPLIT_MATRIX=$(python3 tools/trace_replay/trace_cases.py --ci --format github-split-matrix)
|
SPLIT_MATRIX=$(python3 tools/trace_replay/trace_cases.py --ci --format github-split-matrix)
|
||||||
# AND IT MUST NOT BE EMPTY. An empty `include` is not an error to GitHub - it skips the
|
# AND IT MUST NOT BE EMPTY. An empty `include` is not an error to GitHub - it skips the
|
||||||
# whole retrace-split job with no red anywhere - so the one way this subset can vanish
|
# whole retrace-split job with no red anywhere - so the one way this subset can vanish
|
||||||
# silently is guarded here. trace_cases.py now also rejects an unknown manifest key, which
|
# silently is guarded here. trace_cases.py now also rejects an unknown manifest key, which
|
||||||
# was the hole: `"splitt": true` loaded clean and emptied the subset (review N-4).
|
# was the hole: `"splitt": true` loaded clean and emptied the subset (review N-4).
|
||||||
if [ "$(printf '%s' "${SPLIT_MATRIX}" | python3 -c 'import json,sys; print(len(json.load(sys.stdin)["include"]))')" -lt 1 ]; then
|
if [ "$(printf '%s' "${SPLIT_MATRIX}" | python3 -c 'import json,sys; print(len(json.load(sys.stdin)["include"]))')" -lt 1 ]; then
|
||||||
echo "::error::the split retrace subset is EMPTY. No case in trace_cases.json carries \"split\": true, so retrace-split would be skipped with no red. Exit gate E2 names OpenRA."
|
echo "::error::the split retrace subset is EMPTY. `split` is an OPT-OUT as of P6 - a CI case is in this subset unless it carries \"split\": false - so an empty subset means either every case opted out or the CI matrix itself is empty. Either way retrace-split would be skipped with no red, and exit gate E2 names OpenRA."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "split-matrix=${SPLIT_MATRIX}" >> "$GITHUB_OUTPUT"
|
echo "split-matrix=${SPLIT_MATRIX}" >> "$GITHUB_OUTPUT"
|
||||||
@@ -2415,10 +2443,15 @@ jobs:
|
|||||||
build-retrace/tools/trace_replay/${{ matrix.case }}/${{ matrix.backend }}/output/**
|
build-retrace/tools/trace_replay/${{ matrix.case }}/${{ matrix.backend }}/output/**
|
||||||
if-no-files-found: warn
|
if-no-files-found: warn
|
||||||
|
|
||||||
# P5's retrace arm: retrace-verify with MOBILEGL_PIPE_VERIFY=1 swapped for
|
# The retrace arm of the split shape: retrace-verify with MOBILEGL_PIPE_VERIFY=1 swapped for
|
||||||
# MOBILEGL_TRANSPORT=inproc and the comparator's symbol swapped for an MG_Remote one. Exit gate
|
# MOBILEGL_TRANSPORT and the comparator's symbol swapped for an MG_Remote one. Exit gate E2 is
|
||||||
# E2 is one row - OpenRA at SSIM >= 0.99 - and trace_cases.json's `split: true` is where that
|
# one row - OpenRA at SSIM >= 0.99 - but the lane is no longer one row: as of P6 it is
|
||||||
# subset lives.
|
# {backend, case, transport} over the whole CI matrix, both backends, inproc AND spawn.
|
||||||
|
#
|
||||||
|
# inproc IS THE CONTROL AND SPAWN IS THE CLAIM. Same library, same codec, same applier, same
|
||||||
|
# picture; the only difference is which PROCESS the server role runs in. Running only spawn
|
||||||
|
# would leave "did the transport break it?" and "did the phase break it?" answerable only
|
||||||
|
# together, which is the question every failure in this phase turned out to hinge on.
|
||||||
#
|
#
|
||||||
# IT RUNS THE UNCHANGED CTEST NAMES with the transport exported in the JOB environment, rather
|
# IT RUNS THE UNCHANGED CTEST NAMES with the transport exported in the JOB environment, rather
|
||||||
# than the SPLIT-suffixed variant entries. build-retrace configures without
|
# than the SPLIT-suffixed variant entries. build-retrace configures without
|
||||||
@@ -2434,7 +2467,7 @@ jobs:
|
|||||||
# SSIM is neither of them: the nm check below (this library carries MG_Remote) and the
|
# SSIM is neither of them: the nm check below (this library carries MG_Remote) and the
|
||||||
# transport-resolution line in the library's own log (this PROCESS resolved inproc).
|
# transport-resolution line in the library's own log (this PROCESS resolved inproc).
|
||||||
retrace-split:
|
retrace-split:
|
||||||
name: retrace split (${{ matrix.backend }}, ${{ matrix.case }})
|
name: retrace split (${{ matrix.backend }} / ${{ matrix.transport }}, ${{ matrix.case }})
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 240
|
timeout-minutes: 240
|
||||||
needs:
|
needs:
|
||||||
@@ -2522,7 +2555,24 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
echo "the library at build-linux/libMobileGL.so is the split build"
|
echo "the library at build-linux/libMobileGL.so is the split build"
|
||||||
|
|
||||||
- name: Retrace and validate under MOBILEGL_TRANSPORT=inproc
|
# THE SPAWN ARM NEEDS A SECOND BINARY and the inproc arm needs none, which is the whole
|
||||||
|
# difference between the two at this level: inproc's server role is a thread in the replay
|
||||||
|
# process, spawn's is a PROCESS the client launches from this image. It is packaged by
|
||||||
|
# build-linux-split's `find -name '*.so'` sweep - libMobileGLServer.so is an executable that
|
||||||
|
# wears a .so name so an APK will install it somewhere exec-able - and a missing one must be
|
||||||
|
# a NAMED failure here rather than a LaunchServer refusal 78 jobs deep.
|
||||||
|
- name: Place the server image (spawn arm only)
|
||||||
|
if: ${{ matrix.transport == 'spawn' }}
|
||||||
|
run: |
|
||||||
|
if [ ! -f build-split/libMobileGLServer.so ]; then
|
||||||
|
echo "::error::the split runtime carries no libMobileGLServer.so, so transport=spawn has no server to launch. ConfigLoader would resolve Spawn, LaunchServer would refuse BY NAME, and this job would red on a message about an unresolvable image rather than about a packaging gap."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cp build-split/libMobileGLServer.so build-linux/libMobileGLServer.so
|
||||||
|
chmod +x build-linux/libMobileGLServer.so
|
||||||
|
echo "server image: $(readlink -f build-linux/libMobileGLServer.so)"
|
||||||
|
|
||||||
|
- name: Retrace and validate under MOBILEGL_TRANSPORT=${{ matrix.transport }}
|
||||||
working-directory: build-retrace/tools/trace_replay
|
working-directory: build-retrace/tools/trace_replay
|
||||||
# run_trace_case.cmake turns MOBILEGL_TRANSPORT into assertions of its own - the library
|
# run_trace_case.cmake turns MOBILEGL_TRANSPORT into assertions of its own - the library
|
||||||
# must have RESOLVED the transport in this process, and its log must carry no Fatal{ - so a
|
# must have RESOLVED the transport in this process, and its log must carry no Fatal{ - so a
|
||||||
@@ -2532,7 +2582,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
ulimit -c unlimited
|
ulimit -c unlimited
|
||||||
sudo sysctl -w kernel.core_pattern='/tmp/core.%e.%p'
|
sudo sysctl -w kernel.core_pattern='/tmp/core.%e.%p'
|
||||||
export MOBILEGL_TRANSPORT=inproc
|
export MOBILEGL_TRANSPORT='${{ matrix.transport }}'
|
||||||
|
# Absolute, because the replay's working directory is not this one and LaunchServer
|
||||||
|
# resolves the image relative to nothing. Harmless on the inproc arm, which reads it
|
||||||
|
# only to decide it does not need it.
|
||||||
|
export MOBILEGL_IPC_SERVER_PATH="${GITHUB_WORKSPACE}/build-linux/libMobileGLServer.so"
|
||||||
ctest -V --no-tests=error --timeout 10800 \
|
ctest -V --no-tests=error --timeout 10800 \
|
||||||
-R '^MobileGLTraceReplay\.${{ matrix.case }}\.${{ matrix.backend }}$'
|
-R '^MobileGLTraceReplay\.${{ matrix.case }}\.${{ matrix.backend }}$'
|
||||||
|
|
||||||
@@ -2572,6 +2626,10 @@ jobs:
|
|||||||
CONTROL_TMPDIR: ${{ runner.temp }}
|
CONTROL_TMPDIR: ${{ runner.temp }}
|
||||||
PULL_LIBRARY: ${{ github.workspace }}/pull-runtime/build-monolith-control/libMobileGL.so
|
PULL_LIBRARY: ${{ github.workspace }}/pull-runtime/build-monolith-control/libMobileGL.so
|
||||||
FROZEN_LIBRARY: ${{ github.workspace }}/build-linux/libMobileGL.so
|
FROZEN_LIBRARY: ${{ github.workspace }}/build-linux/libMobileGL.so
|
||||||
|
# The control has to run the arm it is a control FOR. Hard-coded inproc, it would go on
|
||||||
|
# proving something about the other arm while spawn ran unguarded.
|
||||||
|
SPLIT_TRANSPORT: ${{ matrix.transport }}
|
||||||
|
MOBILEGL_IPC_SERVER_PATH: ${{ github.workspace }}/build-linux/libMobileGLServer.so
|
||||||
run: >-
|
run: >-
|
||||||
bash "${GITHUB_WORKSPACE}/scripts/ci/retrace_pull_library_control.sh"
|
bash "${GITHUB_WORKSPACE}/scripts/ci/retrace_pull_library_control.sh"
|
||||||
'${{ matrix.case }}' '${{ matrix.backend }}'
|
'${{ matrix.case }}' '${{ matrix.backend }}'
|
||||||
@@ -2597,8 +2655,12 @@ jobs:
|
|||||||
working-directory: build-retrace/tools/trace_replay
|
working-directory: build-retrace/tools/trace_replay
|
||||||
env:
|
env:
|
||||||
CONTROL_TMPDIR: ${{ runner.temp }}
|
CONTROL_TMPDIR: ${{ runner.temp }}
|
||||||
LIBRARY_LOG: ${{ matrix.case }}/${{ matrix.backend }}/output/mobilegl.log
|
LIBRARY_LOG: ${{ matrix.case }}/${{ matrix.backend }}/output/mobilegl.client.log
|
||||||
FROZEN_LIBRARY: ${{ github.workspace }}/build-linux/libMobileGL.so
|
FROZEN_LIBRARY: ${{ github.workspace }}/build-linux/libMobileGL.so
|
||||||
|
# The control has to run the arm it is a control FOR. Hard-coded inproc, it would go on
|
||||||
|
# proving something about the other arm while spawn ran unguarded.
|
||||||
|
SPLIT_TRANSPORT: ${{ matrix.transport }}
|
||||||
|
MOBILEGL_IPC_SERVER_PATH: ${{ github.workspace }}/build-linux/libMobileGLServer.so
|
||||||
run: >-
|
run: >-
|
||||||
bash "${GITHUB_WORKSPACE}/scripts/ci/retrace_drop_draw_control.sh"
|
bash "${GITHUB_WORKSPACE}/scripts/ci/retrace_drop_draw_control.sh"
|
||||||
'${{ matrix.case }}' '${{ matrix.backend }}'
|
'${{ matrix.case }}' '${{ matrix.backend }}'
|
||||||
@@ -2611,20 +2673,29 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
working-directory: build-retrace/tools/trace_replay
|
working-directory: build-retrace/tools/trace_replay
|
||||||
run: |
|
run: |
|
||||||
log="${{ matrix.case }}/${{ matrix.backend }}/output/mobilegl.log"
|
# BOTH ROLES, because under spawn every applier refusal is raised in the SERVER's
|
||||||
|
# process and a census reading only the client's file reports a confident zero for the
|
||||||
|
# half it cannot see.
|
||||||
|
log="${{ matrix.case }}/${{ matrix.backend }}/output/mobilegl.client.log"
|
||||||
|
server_log="${{ matrix.case }}/${{ matrix.backend }}/output/mobilegl.server.log"
|
||||||
if [ ! -f "${log}" ]; then
|
if [ ! -f "${log}" ]; then
|
||||||
echo "no ${log} - the replay wrote no library log"
|
echo "no ${log} - the replay wrote no library log"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "Fatal{ lines: $(grep -c 'Fatal{' "${log}" || true)"
|
census_files="${log}"
|
||||||
grep -o 'Fatal{[A-Za-z]*, "[^"]*"' "${log}" | sort | uniq -c | sort -rn | head -20 || true
|
if [ -f "${server_log}" ]; then census_files="${census_files} ${server_log}"; fi
|
||||||
|
echo "census over: ${census_files}"
|
||||||
|
echo "Fatal{ lines: $(cat ${census_files} | grep -c 'Fatal{' || true)"
|
||||||
|
cat ${census_files} | grep -o 'Fatal{[A-Za-z]*, "[^"]*"' | sort | uniq -c | sort -rn | head -20 || true
|
||||||
|
# The transport line is the CLIENT's: ConfigLoader resolves it there, and under spawn
|
||||||
|
# the server states its own separately.
|
||||||
grep -m1 "MOBILEGL_TRANSPORT=" "${log}" || echo "no transport line in ${log}"
|
grep -m1 "MOBILEGL_TRANSPORT=" "${log}" || echo "no transport line in ${log}"
|
||||||
|
|
||||||
- name: Upload core dumps
|
- name: Upload core dumps
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: retrace-split-core-dumps-${{ matrix.backend }}-${{ matrix.case }}
|
name: retrace-split-core-dumps-${{ matrix.transport }}-${{ matrix.backend }}-${{ matrix.case }}
|
||||||
path: /tmp/core.*
|
path: /tmp/core.*
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
|
|
||||||
@@ -2632,7 +2703,7 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: retrace-split-result-${{ matrix.backend }}-${{ matrix.case }}
|
name: retrace-split-result-${{ matrix.transport }}-${{ matrix.backend }}-${{ matrix.case }}
|
||||||
path: |
|
path: |
|
||||||
build-retrace/tools/trace_replay/${{ matrix.case }}/actual-images/**
|
build-retrace/tools/trace_replay/${{ matrix.case }}/actual-images/**
|
||||||
build-retrace/tools/trace_replay/${{ matrix.case }}/${{ matrix.backend }}/output/**
|
build-retrace/tools/trace_replay/${{ matrix.case }}/${{ matrix.backend }}/output/**
|
||||||
@@ -2872,6 +2943,9 @@ jobs:
|
|||||||
- name: The MGPipe generators' checks can still fail
|
- name: The MGPipe generators' checks can still fail
|
||||||
run: python3 scripts/gen_pipe.py --self-test
|
run: python3 scripts/gen_pipe.py --self-test
|
||||||
|
|
||||||
|
- name: The link seam owns physical storage and keeps link dispatch out of callers
|
||||||
|
run: python3 scripts/ci/link_seam_purity.py --self-test
|
||||||
|
|
||||||
# The same question for the symbol tool the P1 gate is written in terms of.
|
# The same question for the symbol tool the P1 gate is written in terms of.
|
||||||
- name: The symbol report's buckets and gates can still fail
|
- name: The symbol report's buckets and gates can still fail
|
||||||
run: python3 scripts/symbol_report.py --self-test
|
run: python3 scripts/symbol_report.py --self-test
|
||||||
@@ -2947,7 +3021,10 @@ jobs:
|
|||||||
# feat/disaggregated trigger at the top of this file. It costs a couple of seconds and needs
|
# feat/disaggregated trigger at the top of this file. It costs a couple of seconds and needs
|
||||||
# no build.
|
# no build.
|
||||||
- name: The split and retrace negative controls still reject a red that is not theirs (R-16)
|
- name: The split and retrace negative controls still reject a red that is not theirs (R-16)
|
||||||
run: bash scripts/ci/control_smoke_test.sh
|
run: |
|
||||||
|
bash scripts/ci/control_smoke_test.sh
|
||||||
|
python3 scripts/ci/test_trace_infrastructure.py
|
||||||
|
python3 scripts/ci/tcp_lane_tools_test.py
|
||||||
|
|
||||||
# A GATE as of P3a (G5). "pool 与延迟释放原样搬" (ROADMAP.md:19) is meant literally: the
|
# A GATE as of P3a (G5). "pool 与延迟释放原样搬" (ROADMAP.md:19) is meant literally: the
|
||||||
# buffer pool, the deferred-release drain and the three persistently mapped rings move
|
# buffer pool, the deferred-release drain and the three persistently mapped rings move
|
||||||
|
|||||||
+131
-6
@@ -185,15 +185,61 @@ if (MSVC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Generate MGGitHash.h
|
# Generate MGGitHash.h
|
||||||
|
#
|
||||||
|
# RESULT_VARIABLE, WHICH THIS CALL DID NOT HAVE (CONTRACT-P6 4.2). Without it a failed
|
||||||
|
# `git rev-parse` yields "" and nothing says so. Verified live: building this worktree from WSL
|
||||||
|
# produces an EMPTY hash, because the worktree's `.git` is a file holding a WINDOWS path that
|
||||||
|
# WSL's git cannot resolve - so two builds from different commits got IDENTICAL ABI
|
||||||
|
# fingerprints and the stamp silently stopped doing its documented job.
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND git rev-parse HEAD
|
COMMAND git rev-parse HEAD
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
OUTPUT_VARIABLE GIT_COMMIT_HASH_FULL
|
OUTPUT_VARIABLE GIT_COMMIT_HASH_FULL
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
RESULT_VARIABLE MOBILEGL_GIT_STAMP_RESULT
|
||||||
|
ERROR_QUIET
|
||||||
)
|
)
|
||||||
|
|
||||||
string(SUBSTRING "${GIT_COMMIT_HASH_FULL}" 0 7 GIT_COMMIT_HASH_SHORT)
|
string(SUBSTRING "${GIT_COMMIT_HASH_FULL}" 0 7 GIT_COMMIT_HASH_SHORT)
|
||||||
|
|
||||||
|
# --- the BUILD STAMP, and why it is a second pair rather than a fix to the first -------------
|
||||||
|
#
|
||||||
|
# GIT_COMMIT_HASH_SHORT MAY NOT MOVE. It is baked into glGetString(GL_VERSION)
|
||||||
|
# (MG_Impl/GLImpl/Getter/GL_Getter.cpp), so redefining it changes an APPLICATION-VISIBLE GL
|
||||||
|
# string and the pull build's .rodata - a behaviour leak and a G1 break at once. The handshake
|
||||||
|
# gets its own pair instead, consumed only by the ABI fingerprint, which no pull build compiles.
|
||||||
|
#
|
||||||
|
# PRESENT IS A FIRST-CLASS INPUT, not the emptiness of VALUE. "this build has no stamp" and
|
||||||
|
# "this build's stamp is the empty string" are different claims, and a fingerprint that could
|
||||||
|
# not tell them apart is how two unrelated builds agreed in the first place.
|
||||||
|
#
|
||||||
|
# -DMOBILEGL_BUILD_STAMP=<anything> (or the environment variable) overrides, because a tree git
|
||||||
|
# cannot read is not always a tree whose commit is unknown - CI has ${GITHUB_SHA} in hand.
|
||||||
|
set(MOBILEGL_BUILD_STAMP "" CACHE STRING "Explicit ABI-fingerprint build stamp when git cannot be read")
|
||||||
|
set(MOBILEGL_BUILD_STAMP_VALUE "")
|
||||||
|
if(NOT "${MOBILEGL_BUILD_STAMP}" STREQUAL "")
|
||||||
|
set(MOBILEGL_BUILD_STAMP_VALUE "${MOBILEGL_BUILD_STAMP}")
|
||||||
|
elseif(NOT "$ENV{MOBILEGL_BUILD_STAMP}" STREQUAL "")
|
||||||
|
set(MOBILEGL_BUILD_STAMP_VALUE "$ENV{MOBILEGL_BUILD_STAMP}")
|
||||||
|
elseif(MOBILEGL_GIT_STAMP_RESULT EQUAL 0 AND NOT "${GIT_COMMIT_HASH_FULL}" STREQUAL "")
|
||||||
|
set(MOBILEGL_BUILD_STAMP_VALUE "${GIT_COMMIT_HASH_FULL}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${MOBILEGL_BUILD_STAMP_VALUE}" STREQUAL "")
|
||||||
|
set(MOBILEGL_BUILD_STAMP_PRESENT 0)
|
||||||
|
# A WARNING AND NOT A FATAL: a build with no stamp is still a usable build, it just cannot
|
||||||
|
# prove that a peer was built from the same tree. Saying so once at configure time is the
|
||||||
|
# difference between a known limitation and the silent one 4.2 found.
|
||||||
|
message(WARNING
|
||||||
|
"MobileGL: no build stamp. `git rev-parse HEAD` failed (result "
|
||||||
|
"'${MOBILEGL_GIT_STAMP_RESULT}') and MOBILEGL_BUILD_STAMP was not set, so the ABI "
|
||||||
|
"fingerprint cannot distinguish two builds of the same sizes from different commits - "
|
||||||
|
"which is exactly what a stale MOBILEGL_IPC_SERVER_PATH looks like. Pass "
|
||||||
|
"-DMOBILEGL_BUILD_STAMP=<commit> to restore it.")
|
||||||
|
else()
|
||||||
|
set(MOBILEGL_BUILD_STAMP_PRESENT 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
${CMAKE_SOURCE_DIR}/MobileGL/MG_Util/Miscellany/MGGitHash.h.in
|
${CMAKE_SOURCE_DIR}/MobileGL/MG_Util/Miscellany/MGGitHash.h.in
|
||||||
${CMAKE_BINARY_DIR}/generated/MGGitHash.h
|
${CMAKE_BINARY_DIR}/generated/MGGitHash.h
|
||||||
@@ -546,6 +592,9 @@ endif()
|
|||||||
if (MOBILEGL_BUILD_DISAGGREGATED)
|
if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||||
message(STATUS "MobileGL: disaggregated transport ON, appending MG_Remote sources")
|
message(STATUS "MobileGL: disaggregated transport ON, appending MG_Remote sources")
|
||||||
list(APPEND SOURCE_FILES
|
list(APPEND SOURCE_FILES
|
||||||
|
MobileGL/MG_Remote/Transport/ShmLink.cpp
|
||||||
|
MobileGL/MG_Remote/Transport/LinkMetrics.cpp
|
||||||
|
MobileGL/MG_Remote/Transport/StreamLink.cpp
|
||||||
MobileGL/MG_Remote/Transport/Ring.cpp
|
MobileGL/MG_Remote/Transport/Ring.cpp
|
||||||
MobileGL/MG_Remote/Transport/Doorbell.cpp
|
MobileGL/MG_Remote/Transport/Doorbell.cpp
|
||||||
MobileGL/MG_Remote/Transport/ShmSegment.cpp
|
MobileGL/MG_Remote/Transport/ShmSegment.cpp
|
||||||
@@ -556,6 +605,8 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
|||||||
MobileGL/MG_Remote/Transport/ShmSegmentWin32.cpp
|
MobileGL/MG_Remote/Transport/ShmSegmentWin32.cpp
|
||||||
MobileGL/MG_Remote/Transport/FdPassing.cpp
|
MobileGL/MG_Remote/Transport/FdPassing.cpp
|
||||||
MobileGL/MG_Remote/Transport/InProcessTransport.cpp
|
MobileGL/MG_Remote/Transport/InProcessTransport.cpp
|
||||||
|
MobileGL/MG_Remote/Transport/SocketTransport.cpp
|
||||||
|
MobileGL/MG_Remote/Transport/ControlInbox.cpp
|
||||||
# Keeps MG_Util/Debug/Log.h - and through it the GL frontend's
|
# Keeps MG_Util/Debug/Log.h - and through it the GL frontend's
|
||||||
# umbrella header - out of the header-only wire code (WireLog.h).
|
# umbrella header - out of the header-only wire code (WireLog.h).
|
||||||
MobileGL/MG_Remote/Transport/WireLog.cpp
|
MobileGL/MG_Remote/Transport/WireLog.cpp
|
||||||
@@ -574,6 +625,9 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
|||||||
# emitter that returns quietly is how a split lane runs monolith and
|
# emitter that returns quietly is how a split lane runs monolith and
|
||||||
# goes green (ARCHITECTURE.md 10.3).
|
# goes green (ARCHITECTURE.md 10.3).
|
||||||
MobileGL/MG_Remote/CapsCodec.cpp
|
MobileGL/MG_Remote/CapsCodec.cpp
|
||||||
|
# P6 dl: the one place a session dies - Session::Fail's funnel (Fatal-family aware,
|
||||||
|
# publishes SessionFault, one telemetry point).
|
||||||
|
MobileGL/MG_Remote/FatalFunnel.cpp
|
||||||
MobileGL/MG_Remote/Wire/PipeWireCodec.cpp
|
MobileGL/MG_Remote/Wire/PipeWireCodec.cpp
|
||||||
MobileGL/MG_Remote/Client/ClientSession.cpp
|
MobileGL/MG_Remote/Client/ClientSession.cpp
|
||||||
MobileGL/MG_Remote/Client/EmitTables.cpp
|
MobileGL/MG_Remote/Client/EmitTables.cpp
|
||||||
@@ -595,6 +649,8 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
|||||||
MobileGL/MG_Remote/Server/ServerSession.cpp
|
MobileGL/MG_Remote/Server/ServerSession.cpp
|
||||||
MobileGL/MG_Remote/Server/PipeApplier.cpp
|
MobileGL/MG_Remote/Server/PipeApplier.cpp
|
||||||
MobileGL/MG_Remote/Server/ServerLoop.cpp
|
MobileGL/MG_Remote/Server/ServerLoop.cpp
|
||||||
|
MobileGL/MG_Remote/Server/ServerMain.cpp
|
||||||
|
MobileGL/MG_Remote/Server/ServerSpawn.cpp
|
||||||
# P5f fc: the value frame that replaced the control mailbox's function-pointer payload,
|
# P5f fc: the value frame that replaced the control mailbox's function-pointer payload,
|
||||||
# and its codec against protocol.fbs's SurfaceOp/SurfaceReply (the spawn arm's seam).
|
# and its codec against protocol.fbs's SurfaceOp/SurfaceReply (the spawn arm's seam).
|
||||||
MobileGL/MG_Remote/Server/SurfaceControlFrame.cpp
|
MobileGL/MG_Remote/Server/SurfaceControlFrame.cpp
|
||||||
@@ -923,20 +979,89 @@ endif()
|
|||||||
# Off by default and ANDROID-only, so no shipping configuration builds it. The
|
# Off by default and ANDROID-only, so no shipping configuration builds it. The
|
||||||
# trace flavour of the plugin APK turns it on (android-plugin/build.gradle).
|
# trace flavour of the plugin APK turns it on (android-plugin/build.gradle).
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
if (ANDROID AND MOBILEGL_BUILD_SERVER_SPIKE)
|
# ---------------------------------------------------------------------------
|
||||||
|
# P6 `sm`: the REAL server image. Unlike MOBILEGL_BUILD_SERVER_SPIKE below - the
|
||||||
|
# P0 spike, which links no MobileGL library and exists only to prove the Android
|
||||||
|
# delivery chain - this one links the library and runs mobilegl_server_main.
|
||||||
|
#
|
||||||
|
# ARCHITECTURE.md:496 called for a ~30-line stub that dlopen's libMobileGL.so and
|
||||||
|
# dlsym's the entry point, so one shared library serves both roles. On a desktop
|
||||||
|
# configure we link it directly instead: there is no APK packaging rule to satisfy
|
||||||
|
# and a direct link is what makes an undefined symbol a BUILD error rather than a
|
||||||
|
# runtime dlsym failure in a child whose stderr is /dev/null.
|
||||||
|
#
|
||||||
|
# Android keeps the lib*.so naming and the nativeLibraryDir output the spike
|
||||||
|
# proved is the only exec-able location in an APK.
|
||||||
|
if (MOBILEGL_BUILD_DISAGGREGATED AND NOT WIN32)
|
||||||
add_executable(MobileGLServer
|
add_executable(MobileGLServer
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/MobileGL/MG_Remote/Server/ServerEntry.cpp)
|
||||||
|
|
||||||
|
target_include_directories(MobileGLServer PRIVATE
|
||||||
|
${MOBILEGL_INCLUDE_DIR})
|
||||||
|
|
||||||
|
target_link_libraries(MobileGLServer PRIVATE ${CMAKE_PROJECT_NAME})
|
||||||
|
|
||||||
|
set_target_properties(MobileGLServer PROPERTIES
|
||||||
|
POSITION_INDEPENDENT_CODE ON)
|
||||||
|
target_compile_options(MobileGLServer PRIVATE -fPIE)
|
||||||
|
target_link_options(MobileGLServer PRIVATE -pie)
|
||||||
|
|
||||||
|
# $ORIGIN, OR THE SERVER CANNOT START AT ALL ON ANDROID.
|
||||||
|
#
|
||||||
|
# This executable links libMobileGL.so, and it is EXEC'd rather than dlopen'd - so it gets a
|
||||||
|
# fresh linker namespace with the default search path, not the app's. An APK's lib/<abi>/ is
|
||||||
|
# not on that path, and the failure is the bluntest one there is:
|
||||||
|
#
|
||||||
|
# F linker: CANNOT LINK EXECUTABLE ".../lib/arm64/libMobileGLServer.so":
|
||||||
|
# library "libMobileGL.so" not found: needed by main executable
|
||||||
|
#
|
||||||
|
# It cost a device run to find because it is invisible on desktop: CMake gives build-tree
|
||||||
|
# targets an absolute RPATH automatically, so the WSL server resolved its dependency through a
|
||||||
|
# path that does not exist on a phone. $ORIGIN says "beside me", which is true in the APK, true
|
||||||
|
# in the build tree, and true wherever somebody copies the pair - and it is what makes a
|
||||||
|
# deployment that is NOT a build tree work at all, which the end state is.
|
||||||
|
# THE PROPERTIES, NOT target_link_options. A raw `-Wl,-rpath,$ORIGIN` reaches the generator
|
||||||
|
# unquoted and the SHELL expands $ORIGIN to nothing - measured on device, where the linker
|
||||||
|
# said `normalize_path - invalid input: "$"` and then failed to find libMobileGL.so anyway.
|
||||||
|
# BUILD_RPATH / INSTALL_RPATH are the supported spelling and CMake escapes them correctly.
|
||||||
|
set_target_properties(MobileGLServer PROPERTIES
|
||||||
|
BUILD_RPATH "$ORIGIN"
|
||||||
|
INSTALL_RPATH "$ORIGIN"
|
||||||
|
BUILD_WITH_INSTALL_RPATH TRUE)
|
||||||
|
|
||||||
|
if (ANDROID)
|
||||||
|
# An APK's only exec-able install location is lib/<abi>/, and the packager
|
||||||
|
# only puts a file there if it is named lib*.so. P0 spike A proved this
|
||||||
|
# works from the app's own untrusted_app domain on two devices.
|
||||||
|
set_target_properties(MobileGLServer PROPERTIES
|
||||||
|
PREFIX "lib" SUFFIX ".so" OUTPUT_NAME "MobileGLServer")
|
||||||
|
if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||||
|
set_target_properties(MobileGLServer PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# Desktop: the name the dladdr fallback looks for beside libMobileGL.so.
|
||||||
|
set_target_properties(MobileGLServer PROPERTIES
|
||||||
|
PREFIX "lib" SUFFIX ".so" OUTPUT_NAME "MobileGLServer"
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (ANDROID AND MOBILEGL_BUILD_SERVER_SPIKE)
|
||||||
|
# Renamed by P6 sm: the real server took the name it had been holding.
|
||||||
|
add_executable(MobileGLServerSpike
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/spikes/server_stub/main.cpp)
|
${CMAKE_CURRENT_SOURCE_DIR}/tools/spikes/server_stub/main.cpp)
|
||||||
|
|
||||||
# An executable that is named like a shared library still has to be a real
|
# An executable that is named like a shared library still has to be a real
|
||||||
# PIE executable: Android has refused non-PIE executables since API 21, and
|
# PIE executable: Android has refused non-PIE executables since API 21, and
|
||||||
# the name alone does not change what the loader demands of the file.
|
# the name alone does not change what the loader demands of the file.
|
||||||
set_target_properties(MobileGLServer PROPERTIES
|
set_target_properties(MobileGLServerSpike PROPERTIES
|
||||||
PREFIX "lib"
|
PREFIX "lib"
|
||||||
SUFFIX ".so"
|
SUFFIX ".so"
|
||||||
OUTPUT_NAME "MobileGLServer"
|
OUTPUT_NAME "MobileGLServerSpike"
|
||||||
POSITION_INDEPENDENT_CODE ON)
|
POSITION_INDEPENDENT_CODE ON)
|
||||||
target_compile_options(MobileGLServer PRIVATE -fPIE)
|
target_compile_options(MobileGLServerSpike PRIVATE -fPIE)
|
||||||
target_link_options(MobileGLServer PRIVATE -pie)
|
target_link_options(MobileGLServerSpike PRIVATE -pie)
|
||||||
|
|
||||||
# AGP packages what the external native build drops into the per-ABI output
|
# AGP packages what the external native build drops into the per-ABI output
|
||||||
# directory, and it selects by the .so extension. CMake puts executables in
|
# directory, and it selects by the .so extension. CMake puts executables in
|
||||||
@@ -944,7 +1069,7 @@ if (ANDROID AND MOBILEGL_BUILD_SERVER_SPIKE)
|
|||||||
# CMAKE_LIBRARY_OUTPUT_DIRECTORY, so point this target's runtime output at
|
# CMAKE_LIBRARY_OUTPUT_DIRECTORY, so point this target's runtime output at
|
||||||
# the library directory when the generator gave us one.
|
# the library directory when the generator gave us one.
|
||||||
if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||||
set_target_properties(MobileGLServer PROPERTIES
|
set_target_properties(MobileGLServerSpike PROPERTIES
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -471,6 +471,9 @@ namespace MobileGL::MG_Config {
|
|||||||
// SPLIT variant already carry it, and an environment variable that nothing parses is
|
// SPLIT variant already carry it, and an environment variable that nothing parses is
|
||||||
// indistinguishable from one that is parsed and ignored.
|
// indistinguishable from one that is parsed and ignored.
|
||||||
String ServerPath;
|
String ServerPath;
|
||||||
|
// Control endpoint and data-plane selection are independent of topology.
|
||||||
|
String Control = "fork"; // fork | unix:<path> | tcp://host:port
|
||||||
|
String Data = "auto"; // auto | shm | stream
|
||||||
// MOBILEGL_IPC_RING_MB: SEG_CMD size. A RECORD MAY BE AT MOST HALF OF THIS
|
// MOBILEGL_IPC_RING_MB: SEG_CMD size. A RECORD MAY BE AT MOST HALF OF THIS
|
||||||
// (RingProducer::MaxRecordBytes), so 8 MiB caps one record at 4 MiB; R-10 makes the
|
// (RingProducer::MaxRecordBytes), so 8 MiB caps one record at 4 MiB; R-10 makes the
|
||||||
// codec publish a max-record-bytes counter rather than assume that is enough.
|
// codec publish a max-record-bytes counter rather than assume that is enough.
|
||||||
|
|||||||
@@ -336,10 +336,32 @@ namespace MobileGL::MG_ConfigLoader {
|
|||||||
}
|
}
|
||||||
// The three P6 forms. Recognised precisely, so the diagnostic can say "not yet"
|
// The three P6 forms. Recognised precisely, so the diagnostic can say "not yet"
|
||||||
// rather than "unknown", which are different bugs on the operator's side.
|
// rather than "unknown", which are different bugs on the operator's side.
|
||||||
if (lowered == "spawn" || lowered.compare(0, 5, "unix:") == 0 ||
|
// P6 `sm`/`cp`: spawn is IMPLEMENTED. It launches a server process on a
|
||||||
lowered.compare(0, 5, "pipe:") == 0) {
|
// rendezvous of its own and connects to it - the two processes are
|
||||||
MGLOG_E("Config: MOBILEGL_TRANSPORT='%s' names a transport P6 implements and P5 does "
|
// independent, so this is `Dial = Connect` with a launcher attached
|
||||||
"not; staying on monolith. This run is NOT a split run.",
|
// rather than the fork-coupled shape ARCHITECTURE.md:488 described.
|
||||||
|
if (lowered == "spawn") {
|
||||||
|
MG_Config::Transport = MG_Config::TransportMode::Spawn;
|
||||||
|
// THE SAME SHAPE AS THE inproc LINE ABOVE, AND FOR THE SAME REASON.
|
||||||
|
// run_trace_case.cmake asserts on a distinctive sentence from this
|
||||||
|
// function rather than on `MOBILEGL_TRANSPORT=spawn` alone, because
|
||||||
|
// ConfigLoader logs an `Accepted env variable: KEY=VALUE` line for
|
||||||
|
// every MOBILEGL_* in EVERY build including the pull one - so the
|
||||||
|
// bare KEY=VALUE is satisfied by a monolith library that parsed
|
||||||
|
// nothing (review M-5). A spawn arm with no line of its own could
|
||||||
|
// only have been asserted with the inproc marker, which spawn never
|
||||||
|
// emits: the arm would have been red for a missing sentence rather
|
||||||
|
// than green for a working transport.
|
||||||
|
MGLOG_I("Config: MOBILEGL_TRANSPORT=spawn - the MGPipe record stream crosses a real "
|
||||||
|
"ring to an apply thread in ANOTHER PROCESS");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lowered.compare(0, 5, "unix:") == 0 || lowered.compare(0, 5, "pipe:") == 0) {
|
||||||
|
// unix: and pipe: remain P6+ - connecting to an endpoint SOMEBODY
|
||||||
|
// ELSE is listening on needs the server lifecycle to be somebody
|
||||||
|
// else's too, which is P12's. Named, never a silent degrade.
|
||||||
|
MGLOG_E("Config: MOBILEGL_TRANSPORT='%s' names a transport P6 does not implement yet; "
|
||||||
|
"staying on monolith. This run is NOT a split run.",
|
||||||
value.c_str());
|
value.c_str());
|
||||||
MG_Config::Transport = MG_Config::TransportMode::Monolith;
|
MG_Config::Transport = MG_Config::TransportMode::Monolith;
|
||||||
return;
|
return;
|
||||||
@@ -356,6 +378,8 @@ namespace MobileGL::MG_ConfigLoader {
|
|||||||
inline void InitIpc() {
|
inline void InitIpc() {
|
||||||
auto& ipc = MG_Config::Ipc;
|
auto& ipc = MG_Config::Ipc;
|
||||||
QueryEnvVariable("MOBILEGL_IPC_SERVER_PATH", ipc.ServerPath, "");
|
QueryEnvVariable("MOBILEGL_IPC_SERVER_PATH", ipc.ServerPath, "");
|
||||||
|
QueryEnvVariable("MOBILEGL_IPC_CONTROL", ipc.Control, "fork");
|
||||||
|
QueryEnvVariable("MOBILEGL_IPC_DATA", ipc.Data, "auto");
|
||||||
// Both ring floors are 1 MiB, not 0: a ring caps ONE record at half its size, and
|
// Both ring floors are 1 MiB, not 0: a ring caps ONE record at half its size, and
|
||||||
// the catalogue's largest fixed payload (MGPFramebufferState, 304 bytes) plus a
|
// the catalogue's largest fixed payload (MGPFramebufferState, 304 bytes) plus a
|
||||||
// create_shader_state archive already needs far more than a toy ring. The ceilings
|
// create_shader_state archive already needs far more than a toy ring. The ceilings
|
||||||
@@ -405,6 +429,30 @@ namespace MobileGL::MG_ConfigLoader {
|
|||||||
ipc.RoleSplitState = false;
|
ipc.RoleSplitState = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// P6 `dl` (CONTRACT-P6 5.3): MOBILEGL_IPC_RESPAWN IS A NAMED REFUSAL, NOT A NO-OP.
|
||||||
|
//
|
||||||
|
// The device-lost latch is deliberately one-way - a session whose server died has
|
||||||
|
// nothing to recover into, because every handle the client minted names an object in a
|
||||||
|
// process that no longer exists. Re-pushing the world onto a fresh server is the work
|
||||||
|
// this knob would turn on, and no stage has written it.
|
||||||
|
//
|
||||||
|
// Refused BY NAME rather than parsed and ignored, for the reason Config.h gives about
|
||||||
|
// the whole IPC family: an environment variable nothing consumes is indistinguishable
|
||||||
|
// from one that is consumed and does nothing, and an operator who set this one would
|
||||||
|
// otherwise conclude that recovery had been tried and had not helped.
|
||||||
|
{
|
||||||
|
String respawn;
|
||||||
|
QueryEnvVariable("MOBILEGL_IPC_RESPAWN", respawn, "");
|
||||||
|
if (!respawn.empty() && respawn != "0") {
|
||||||
|
MGLOG_E("Config: MOBILEGL_IPC_RESPAWN='%s' names a recovery NO STAGE HAS "
|
||||||
|
"IMPLEMENTED. The device-lost latch is one-way on purpose: every handle "
|
||||||
|
"this client minted names an object inside the server process, so a new "
|
||||||
|
"server would have to be re-pushed the entire world before a single verb "
|
||||||
|
"could land. This run will latch device-lost and stay there.",
|
||||||
|
respawn.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) return;
|
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) return;
|
||||||
// One line, on the arm where these numbers decide behaviour, because every one of
|
// One line, on the arm where these numbers decide behaviour, because every one of
|
||||||
// them is a number a bug report has to quote.
|
// them is a number a bug report has to quote.
|
||||||
|
|||||||
@@ -332,13 +332,13 @@ namespace MobileGL {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct DynamicBackendParameters {
|
struct DynamicBackendParameters {
|
||||||
SizeT UniformBufferOffsetAlignment = 256;
|
Uint64 UniformBufferOffsetAlignment = 256;
|
||||||
// GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, which is a SEPARATE limit from the
|
// GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, which is a SEPARATE limit from the
|
||||||
// uniform one and is routinely larger: Adreno 830 reports 32 for uniform buffers and
|
// uniform one and is routinely larger: Adreno 830 reports 32 for uniform buffers and
|
||||||
// 64 for storage buffers. Answering the storage query with the uniform value let an
|
// 64 for storage buffers. Answering the storage query with the uniform value let an
|
||||||
// application bind a storage range at an offset the driver cannot address, which it
|
// application bind a storage range at an offset the driver cannot address, which it
|
||||||
// accepted without error and then wrote somewhere else entirely.
|
// accepted without error and then wrote somewhere else entirely.
|
||||||
SizeT ShaderStorageBufferOffsetAlignment = 256;
|
Uint64 ShaderStorageBufferOffsetAlignment = 256;
|
||||||
// GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT. 1.0 means the backend cannot filter anisotropically,
|
// GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT. 1.0 means the backend cannot filter anisotropically,
|
||||||
// which is also why the extension is not advertised in that case.
|
// which is also why the extension is not advertised in that case.
|
||||||
Float MaxTextureMaxAnisotropy = 1.0f;
|
Float MaxTextureMaxAnisotropy = 1.0f;
|
||||||
@@ -460,8 +460,8 @@ namespace MobileGL {
|
|||||||
// VulkanRenderer::SelectProvokingVertexMode out of VK_EXT_provoking_vertex,
|
// VulkanRenderer::SelectProvokingVertexMode out of VK_EXT_provoking_vertex,
|
||||||
// provokingVertexModePerPipeline and the topology, so no single convention is true
|
// provokingVertexModePerPipeline and the topology, so no single convention is true
|
||||||
// of the backend.
|
// of the backend.
|
||||||
GLenum LayerProvokingVertex = GL_UNDEFINED_VERTEX;
|
Uint32 LayerProvokingVertex = GL_UNDEFINED_VERTEX;
|
||||||
GLenum ViewportIndexProvokingVertex = GL_UNDEFINED_VERTEX;
|
Uint32 ViewportIndexProvokingVertex = GL_UNDEFINED_VERTEX;
|
||||||
Int MaxViewportWidth = 16384;
|
Int MaxViewportWidth = 16384;
|
||||||
Int MaxViewportHeight = 16384;
|
Int MaxViewportHeight = 16384;
|
||||||
Float ViewportBoundsRangeMin = 0.0f;
|
Float ViewportBoundsRangeMin = 0.0f;
|
||||||
@@ -558,7 +558,7 @@ namespace MobileGL {
|
|||||||
Bool SupportsTessellationPointSize = true;
|
Bool SupportsTessellationPointSize = true;
|
||||||
// The geometry-stage twin (OpCapability GeometryPointSize).
|
// The geometry-stage twin (OpCapability GeometryPointSize).
|
||||||
Bool SupportsGeometryPointSize = true;
|
Bool SupportsGeometryPointSize = true;
|
||||||
SizeT MaxShaderStorageBlockSize = 128 * 1024 * 1024;
|
Uint64 MaxShaderStorageBlockSize = 128 * 1024 * 1024;
|
||||||
Uint32 SubgroupSize = 0;
|
Uint32 SubgroupSize = 0;
|
||||||
Uint32 SubgroupSupportedStages = 0;
|
Uint32 SubgroupSupportedStages = 0;
|
||||||
Uint32 SubgroupSupportedFeatures = 0;
|
Uint32 SubgroupSupportedFeatures = 0;
|
||||||
|
|||||||
@@ -199,6 +199,34 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#endif
|
#endif
|
||||||
#if !MOBILEGL_PIPE_PUSH || MOBILEGL_PIPE_LEGACY_MEMOS
|
#if !MOBILEGL_PIPE_PUSH || MOBILEGL_PIPE_LEGACY_MEMOS
|
||||||
const void* ctx = MGB_CTX_IDENTITY;
|
const void* ctx = MGB_CTX_IDENTITY;
|
||||||
|
#if MOBILEGL_PIPE_PUSH
|
||||||
|
// `st` (CONTRACT-P6 3.4): THE NAMED FATAL PipeInputs.h ALREADY ASKED FOR.
|
||||||
|
//
|
||||||
|
// This memo compares the identity FIRST and with NO GENERATION, and its cache variable
|
||||||
|
// starts at nullptr - so an identity that is ALSO nullptr reads as a CACHE HIT and the
|
||||||
|
// function returns `*g_fbSlotCache[target]`, a pointer nothing ever filled. The crash
|
||||||
|
// that follows names neither the memo nor the identity.
|
||||||
|
//
|
||||||
|
// It is reachable exactly when a process runs this legacy arm with an unset identity,
|
||||||
|
// which is what a spawn server used to be: MGPipeServerBlockNoteIdentity early-returned
|
||||||
|
// on the REHEARSAL knob, so the server's block carried nullptr for the life of the
|
||||||
|
// process. `sm` widened that gate to MGPipeBlocksAreDistinct() and closed the hole; this
|
||||||
|
// says so out loud if it ever reopens, because a silent wrong answer here is
|
||||||
|
// indistinguishable from memory corruption three frames later.
|
||||||
|
//
|
||||||
|
// Under MOBILEGL_PIPE_PUSH only: in a pull build MGB_CTX_IDENTITY is the live
|
||||||
|
// GLContext's address, which is non-null on every path that reaches here, so the test
|
||||||
|
// would be dead code and G1 measures dead code.
|
||||||
|
if (ctx == nullptr) {
|
||||||
|
MGLOG_F("MGPipe: Fatal{UnnamedIdentity, \"FbSlotMemo\"} - the framebuffer binding-slot "
|
||||||
|
"memo was consulted with a NULL context identity. Its cache starts null too, "
|
||||||
|
"so this would have read as a hit and returned a slot pointer that was never "
|
||||||
|
"filled. The identity is set by MGPipeServerBlockNoteIdentity, which arms on "
|
||||||
|
"MGPipeBlocksAreDistinct(); a null here means this process runs the legacy "
|
||||||
|
"memo arm with a block nobody claimed (CONTRACT-P6 3.4).");
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (ctx != g_fbSlotCacheContext) {
|
if (ctx != g_fbSlotCacheContext) {
|
||||||
auto& live = *MGB_CTX;
|
auto& live = *MGB_CTX;
|
||||||
for (SizeT i = 0; i < g_fbSlotCache.size(); ++i) {
|
for (SizeT i = 0; i < g_fbSlotCache.size(); ++i) {
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
#include <MG_Remote/Client/BackendObject_Remote.h>
|
#include <MG_Remote/Client/BackendObject_Remote.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "ServerRole.h"
|
||||||
|
|
||||||
namespace MobileGL::MG_Backend {
|
namespace MobileGL::MG_Backend {
|
||||||
void LogBackendInfo() {
|
void LogBackendInfo() {
|
||||||
if (!pActiveBackendObject) {
|
if (!pActiveBackendObject) {
|
||||||
@@ -148,7 +150,13 @@ namespace MobileGL::MG_Backend {
|
|||||||
// The single hook (ARCHITECTURE.md:29). Returns false when the split could not be
|
// The single hook (ARCHITECTURE.md:29). Returns false when the split could not be
|
||||||
// brought up, and the caller then REFUSES TO CONTINUE rather than falling back to the
|
// brought up, and the caller then REFUSES TO CONTINUE rather than falling back to the
|
||||||
// switch below - a fallback here is "the split lane ran monolith and went green".
|
// switch below - a fallback here is "the split lane ran monolith and went green".
|
||||||
Bool InitSplitRoles() {
|
// Steps 1 and 2 of the split bring-up: the server role's private backend
|
||||||
|
// object and the two CallMask halves. EXTRACTED so the spawn server
|
||||||
|
// process runs the SAME code the inproc server role runs - a second copy
|
||||||
|
// is how the two roles end up disagreeing about a capability bit that
|
||||||
|
// only one of them ever computes. ServerMain calls this and then does
|
||||||
|
// its own Accept; InitSplitRoles calls it and then starts the client.
|
||||||
|
Bool InitServerRoleCommon() {
|
||||||
using namespace MobileGL::MG_Remote;
|
using namespace MobileGL::MG_Remote;
|
||||||
|
|
||||||
// 1. the SERVER role's private backend object, on the app thread, with no GL and no
|
// 1. the SERVER role's private backend object, on the app thread, with no GL and no
|
||||||
@@ -210,6 +218,37 @@ namespace MobileGL::MG_Backend {
|
|||||||
capBits |= MG_Pipe::MGPipeRunAheadCapBitsFor(MG_Config::ActiveBackendType, runAheadReady);
|
capBits |= MG_Pipe::MGPipeRunAheadCapBitsFor(MG_Config::ActiveBackendType, runAheadReady);
|
||||||
session.SetCapabilityBits(capBits);
|
session.SetCapabilityBits(capBits);
|
||||||
session.SetBackend(loop.Backend());
|
session.SetBackend(loop.Backend());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The single hook (ARCHITECTURE.md:29) for the INPROC shape: both roles in
|
||||||
|
// this process. The spawn shape runs InitServerRoleCommon in the child and
|
||||||
|
// the client half here.
|
||||||
|
Bool InitSplitRoles() {
|
||||||
|
using namespace MobileGL::MG_Remote;
|
||||||
|
|
||||||
|
// SPAWN: THE SERVER ROLE IS NOT IN THIS PROCESS. Steps 1 and 2 -
|
||||||
|
// the backend and the two CallMask halves - happen in the server,
|
||||||
|
// which ran InitServerRoleForSpawn before it accepted us. Running
|
||||||
|
// them here as well would build a second BackendObject in the one
|
||||||
|
// process that must not have one, and would publish a capability
|
||||||
|
// mask computed from the WRONG backend's function table.
|
||||||
|
if (MG_Config::Transport == MG_Config::TransportMode::Spawn) {
|
||||||
|
const MobileGLResult started = Client::ClientSessionInstance().StartSpawned();
|
||||||
|
if (started != MOBILEGL_OK) {
|
||||||
|
MGLOG_E("MG_Remote: the spawn session failed to start (rc=%d); MobileGL will "
|
||||||
|
"NOT fall back to monolith - a lane named split that ran monolith is "
|
||||||
|
"the one failure this phase is built to make impossible",
|
||||||
|
static_cast<int>(started));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
pActiveBackendObject = MakeUnique<MG_Remote::Client::BackendObject_Remote>();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!InitServerRoleCommon()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// 3. the handshake, the four segments, and - at its end - the apply thread.
|
// 3. the handshake, the four segments, and - at its end - the apply thread.
|
||||||
const MobileGLResult started =
|
const MobileGLResult started =
|
||||||
@@ -256,6 +295,19 @@ namespace MobileGL::MG_Backend {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
// The spawn server's entry into the SAME bring-up the inproc server role
|
||||||
|
// runs (ServerRole.h). A thin forwarder on purpose: the body stays in the
|
||||||
|
// anonymous namespace beside InitSplitRoles so the two cannot drift.
|
||||||
|
//
|
||||||
|
// THE WHOLE FUNCTION IS INSIDE THE GUARD, not just its body. A version with
|
||||||
|
// the guard inside still DEFINES the symbol in a pull build, and G1 caught
|
||||||
|
// it: 2 symbols added, 1 removed, .text +16 bytes. The pull build's identity
|
||||||
|
// is byte-for-byte, and "it returns false there" is not the same as "it is
|
||||||
|
// not there".
|
||||||
|
Bool InitServerRoleForSpawn() { return InitServerRoleCommon(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
void Init() {
|
void Init() {
|
||||||
MGLOG_D("Initializing MobileGL Backend...");
|
MGLOG_D("Initializing MobileGL Backend...");
|
||||||
|
|
||||||
@@ -276,6 +328,19 @@ namespace MobileGL::MG_Backend {
|
|||||||
MGLOG_W("Failed to initialize MobileGL backend libraries for the remote object");
|
MGLOG_W("Failed to initialize MobileGL backend libraries for the remote object");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// P6: BOTH CHECKS BELOW ARE STATEMENTS ABOUT THE SERVER'S PROCESS, and under
|
||||||
|
// spawn that is not this one. Their own wording says so - "a mask is a
|
||||||
|
// statement about THIS BACKEND", "the table the SERVER'S BACKEND registered at
|
||||||
|
// step 1" - and in a spawn client there is no backend and never was a table, so
|
||||||
|
// MGPipeGetResourceOps() is null by construction and the first check fires on a
|
||||||
|
// correct session. It did, on the first spawn retrace ever run.
|
||||||
|
//
|
||||||
|
// The checks are NOT weakened: the server runs the step-2 one itself, inside
|
||||||
|
// InitServerRoleForSpawn, against its own freshly registered table - which is the
|
||||||
|
// process where the question has an answer. What is lost under spawn is the
|
||||||
|
// step-5 re-run's ability to catch a table REPLACED between accept and here, and
|
||||||
|
// that is a question about one address space; it cannot be asked across two.
|
||||||
|
if (MG_Config::Transport != MG_Config::TransportMode::Spawn) {
|
||||||
// m-6, re-worded per review v2 N-8. The honesty cross-check runs a SECOND time, now
|
// m-6, re-worded per review v2 N-8. The honesty cross-check runs a SECOND time, now
|
||||||
// that step 4's pActiveBackendObject (the client's BackendObject_Remote) exists and
|
// that step 4's pActiveBackendObject (the client's BackendObject_Remote) exists and
|
||||||
// its Initialize() has run inside InitSpecificBackendLibs. What the re-run CAN catch
|
// its Initialize() has run inside InitSpecificBackendLibs. What the re-run CAN catch
|
||||||
@@ -297,6 +362,7 @@ namespace MobileGL::MG_Backend {
|
|||||||
static_cast<const void*>(g_resourceOpsAtStep2));
|
static_cast<const void*>(g_resourceOpsAtStep2));
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
LogBackendInfo();
|
LogBackendInfo();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,10 @@ namespace MobileGL::MG_Pipe {
|
|||||||
// crash exactly where the rehearsal exists to produce a named one. The red is the
|
// crash exactly where the rehearsal exists to produce a named one. The red is the
|
||||||
// census (Harness/dualblock-expected-fatals.txt), so the marker keeps the strict
|
// census (Harness/dualblock-expected-fatals.txt), so the marker keeps the strict
|
||||||
// grammar with the knob's own name as the reason.
|
// grammar with the knob's own name as the reason.
|
||||||
if (MGPipeRoleSplitActive()) {
|
// D10: rides MGPipeBlocksAreDistinct() - under spawn the two blocks are distinct
|
||||||
|
// whatever the rehearsal knob says, and a barrier pull across a real process
|
||||||
|
// boundary is exactly the thing this Fatal exists to name.
|
||||||
|
if (MGPipeBlocksAreDistinct()) {
|
||||||
StrictBarrierPullFatal(field, verb, "MOBILEGL_IPC_ROLE_SPLIT_STATE=1");
|
StrictBarrierPullFatal(field, verb, "MOBILEGL_IPC_ROLE_SPLIT_STATE=1");
|
||||||
}
|
}
|
||||||
if (!MGPipeApplierCurrentRecordIsBarriered()) {
|
if (!MGPipeApplierCurrentRecordIsBarriered()) {
|
||||||
@@ -286,16 +289,54 @@ namespace MobileGL::MG_Pipe {
|
|||||||
|
|
||||||
// ---- P5f (f1): the dual-block rehearsal's selection functions (PipeInputs.h) -----------
|
// ---- P5f (f1): the dual-block rehearsal's selection functions (PipeInputs.h) -----------
|
||||||
//
|
//
|
||||||
// MGPipeRoleSplitActive is deliberately NOT latched: it is two global loads, asked once per
|
// MGPipeRoleSplitRehearsalActive is deliberately NOT latched: it is two global loads, asked once per
|
||||||
// verb on the fill side and once per verb boundary on the stamp side, and a latch is a
|
// verb on the fill side and once per verb boundary on the stamp side, and a latch is a
|
||||||
// second thing a test that flips the knob mid-process would have to know about.
|
// second thing a test that flips the knob mid-process would have to know about.
|
||||||
Bool MGPipeRoleSplitActive() {
|
Bool MGPipeRoleSplitRehearsalActive() {
|
||||||
return MG_Config::Ipc.RoleSplitState &&
|
return MG_Config::Ipc.RoleSplitState &&
|
||||||
MG_Config::Transport != MG_Config::TransportMode::Monolith;
|
MG_Config::Transport != MG_Config::TransportMode::Monolith;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
// ---- D1c's predicates (CONTRACT-P6 3.2) -------------------------------------------------
|
||||||
|
namespace {
|
||||||
|
// Set once by ServerMain, before any GL work. A spawn server is the server for the whole
|
||||||
|
// life of the process; there is no thread in it that is not.
|
||||||
|
Bool g_serverProcessRole = false;
|
||||||
|
// MG_Remote's "is the calling thread inside the applier". Null until a session installs
|
||||||
|
// it, which is the honest answer for a process that has no applier.
|
||||||
|
Bool (*g_applyThreadProbe)() = nullptr;
|
||||||
|
Bool g_sessionLive = false;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void MGPipeSetServerProcessRole(Bool isServerProcess) { g_serverProcessRole = isServerProcess; }
|
||||||
|
void MGPipeSetApplyThreadProbe(Bool (*probe)()) { g_applyThreadProbe = probe; }
|
||||||
|
void MGPipeSetSessionLive(Bool live) { g_sessionLive = live; }
|
||||||
|
|
||||||
|
Bool MGPipeServerArm() {
|
||||||
|
// THE PROCESS FACT FIRST, and it short-circuits: in a spawn server every thread is a
|
||||||
|
// server thread, and asking the probe would be asking MG_Remote a question it answers
|
||||||
|
// only about the applier.
|
||||||
|
if (g_serverProcessRole) return true;
|
||||||
|
return g_applyThreadProbe != nullptr && g_applyThreadProbe();
|
||||||
|
}
|
||||||
|
|
||||||
|
Bool MGPipeSessionLive() { return g_sessionLive; }
|
||||||
|
|
||||||
|
Bool MGPipeBlocksAreDistinct() {
|
||||||
|
// TWO DIFFERENT REASONS, ONE ANSWER. The rehearsal makes two blocks in one process;
|
||||||
|
// spawn makes them two blocks in two ADDRESS SPACES, where no knob is involved and the
|
||||||
|
// distinctness is a fact about the machine. The guards that used to ask only the first
|
||||||
|
// question were therefore disarmed in the one shape where the answer matters most - a
|
||||||
|
// spawn server's block is never the client's, whatever MOBILEGL_IPC_ROLE_SPLIT_STATE
|
||||||
|
// says.
|
||||||
|
return MGPipeRoleSplitRehearsalActive() ||
|
||||||
|
MG_Config::Transport == MG_Config::TransportMode::Spawn;
|
||||||
|
}
|
||||||
|
#endif // MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
|
||||||
PipeInputs& MGPipeClientInputs() {
|
PipeInputs& MGPipeClientInputs() {
|
||||||
return MGPipeRoleSplitActive() ? gPipeInputsClientBlock : gPipeInputs;
|
return MGPipeRoleSplitRehearsalActive() ? gPipeInputsClientBlock : gPipeInputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MGPipeClientClearVerbBoundary() {
|
void MGPipeClientClearVerbBoundary() {
|
||||||
@@ -312,7 +353,15 @@ namespace MobileGL::MG_Pipe {
|
|||||||
Bool MGPipeServerContextIsLive() { return g_serverContextLive; }
|
Bool MGPipeServerContextIsLive() { return g_serverContextLive; }
|
||||||
|
|
||||||
void MGPipeServerBlockNoteIdentity() {
|
void MGPipeServerBlockNoteIdentity() {
|
||||||
if (!MGPipeRoleSplitActive()) return;
|
// D10: THE WIDER PREDICATE, and the narrow one was a latent crash rather than a missing
|
||||||
|
// optimisation. Gated on the REHEARSAL, this early-returned for the whole life of a
|
||||||
|
// spawn server - because that knob is off by default and nothing in the spawn shape
|
||||||
|
// turns it on - so the server's gPipeInputs.ContextIdentity() stayed nullptr forever.
|
||||||
|
// DirectGLES' fb-slot memo compares that identity FIRST and with no generation, so a
|
||||||
|
// nullptr against its own nullptr initialiser reads as a CACHE HIT and hands out a slot
|
||||||
|
// that was never filled. `st` lands the named Fatal at that site; this is the gate that
|
||||||
|
// stops it being reachable in the first place.
|
||||||
|
if (!MGPipeBlocksAreDistinct()) return;
|
||||||
// The server cannot name the client's GLContext - under a real transport it is in
|
// The server cannot name the client's GLContext - under a real transport it is in
|
||||||
// another process - so the identity the server block carries is the server's OWN
|
// another process - so the identity the server block carries is the server's OWN
|
||||||
// served-context clock: MGPipeApplierContextSerial moves exactly when the served
|
// served-context clock: MGPipeApplierContextSerial moves exactly when the served
|
||||||
|
|||||||
@@ -860,9 +860,60 @@ namespace MobileGL::MG_Pipe {
|
|||||||
// Same leak-at-exit storage as gPipeInputs above, for the same reason.
|
// Same leak-at-exit storage as gPipeInputs above, for the same reason.
|
||||||
inline PipeInputs& gPipeInputsClientBlock = *new PipeInputs();
|
inline PipeInputs& gPipeInputsClientBlock = *new PipeInputs();
|
||||||
|
|
||||||
// PipeInputs.cpp. Whether the rehearsal is armed: the knob AND a real transport (and not
|
// PipeInputs.cpp. Whether the REHEARSAL is armed: the knob AND a real transport (and not
|
||||||
// the verify build, which ConfigLoader forces off). Constant for the life of the process.
|
// the verify build, which ConfigLoader forces off). Constant for the life of the process.
|
||||||
Bool MGPipeRoleSplitActive();
|
//
|
||||||
|
// D13 RENAMED THIS FROM MGPipeRoleSplitActive, which is what it has always meant. The old
|
||||||
|
// name read like "the roles are split", and the widening D1c needed would have made a
|
||||||
|
// narrow name lie - so the rename came FIRST and the wider predicate was introduced beside
|
||||||
|
// it rather than by quietly changing what this one answers.
|
||||||
|
Bool MGPipeRoleSplitRehearsalActive();
|
||||||
|
|
||||||
|
// ---- D1c: the role predicates (CONTRACT-P6 3.2) ---------------------------------------
|
||||||
|
//
|
||||||
|
// ONE QUESTION EACH, and the reason they are separate functions rather than one `split`
|
||||||
|
// flag is that the tree asks genuinely different things. a6 proposed three; three do not
|
||||||
|
// cover it.
|
||||||
|
//
|
||||||
|
// D14: IN A NON-DISAGGREGATED BUILD THESE GET A DIFFERENT DEFINITION, not a runtime-false
|
||||||
|
// one. The `#else` arm is `constexpr`, so every consult folds at compile time and the pull
|
||||||
|
// build gains no symbol, no branch and no byte - which G1 measures rather than assumes.
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
// Am I executing as the SERVER right now? A thread-scoped question in the inproc shape,
|
||||||
|
// where both roles live in one process, and a process-scoped one under spawn.
|
||||||
|
Bool MGPipeServerArm();
|
||||||
|
|
||||||
|
// Is a peer session live? Distinct from "is the transport split": a spawn SERVER has no
|
||||||
|
// ClientSession at all, so a guard that asked for one was permanently disarmed there.
|
||||||
|
Bool MGPipeSessionLive();
|
||||||
|
|
||||||
|
// Do the two roles use DIFFERENT PipeInputs storage objects?
|
||||||
|
//
|
||||||
|
// TRUE FOR TWO DIFFERENT REASONS, which is the whole point of the predicate. Under the
|
||||||
|
// rehearsal the two blocks are distinct objects in one process; under SPAWN they are
|
||||||
|
// distinct because they are in different address spaces, and no knob is involved. The
|
||||||
|
// guards below used to ask the rehearsal question and were therefore silently off in the
|
||||||
|
// one shape where the answer matters most.
|
||||||
|
Bool MGPipeBlocksAreDistinct();
|
||||||
|
|
||||||
|
// The two facts the predicates above are built from, stated ONCE by the code that knows
|
||||||
|
// them. Neither is discoverable from MG_Backend: "this process is the server" is something
|
||||||
|
// only ServerMain can say, and "am I on the apply thread" is MG_Remote's thread-local.
|
||||||
|
//
|
||||||
|
// A PROBE RATHER THAN A FLAG for the thread half, because it is a question about the
|
||||||
|
// CALLING thread and a flag would answer for whichever thread wrote it last.
|
||||||
|
void MGPipeSetServerProcessRole(Bool isServerProcess);
|
||||||
|
void MGPipeSetApplyThreadProbe(Bool (*probe)());
|
||||||
|
void MGPipeSetSessionLive(Bool live);
|
||||||
|
#else
|
||||||
|
inline constexpr Bool MGPipeServerArm() { return false; }
|
||||||
|
inline constexpr Bool MGPipeSessionLive() { return false; }
|
||||||
|
inline constexpr Bool MGPipeBlocksAreDistinct() { return false; }
|
||||||
|
// Setters too: a caller guarded only at its own site would still need these to LINK.
|
||||||
|
inline void MGPipeSetServerProcessRole(Bool) {}
|
||||||
|
inline void MGPipeSetApplyThreadProbe(Bool (*)()) {}
|
||||||
|
inline void MGPipeSetSessionLive(Bool) {}
|
||||||
|
#endif
|
||||||
// PipeInputs.cpp. THE FILL SIDE'S ONE NEW SPELLING: the client block when the rehearsal is
|
// PipeInputs.cpp. THE FILL SIDE'S ONE NEW SPELLING: the client block when the rehearsal is
|
||||||
// armed, gPipeInputs otherwise. Everything in MG_Impl/Pipe/PipeFill.cpp that used to spell
|
// armed, gPipeInputs otherwise. Everything in MG_Impl/Pipe/PipeFill.cpp that used to spell
|
||||||
// gPipeInputs spells this instead.
|
// gPipeInputs spells this instead.
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Backend/ServerRole.h
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// The server role's bring-up, as one entry point two shapes share.
|
||||||
|
//
|
||||||
|
// Steps 1 and 2 of Init.cpp's split bring-up - the server's private
|
||||||
|
// BackendObject, and the two CallMask halves computed from THAT backend's own
|
||||||
|
// function table. Under `inproc` InitSplitRoles calls it and then starts the
|
||||||
|
// client in the same process; under `spawn` the child's ServerMain calls it and
|
||||||
|
// then accepts a connection instead.
|
||||||
|
//
|
||||||
|
// ONE ENTRY POINT, not two, because the capability bits are a statement about
|
||||||
|
// the server's backend and only the server can compute them. A second copy in
|
||||||
|
// ServerMain would be a second answer to "does this backend own the XFB
|
||||||
|
// capture", diverging silently the first time a backend registers a slot.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Includes.h>
|
||||||
|
|
||||||
|
// DECLARED ONLY IN A DISAGGREGATED BUILD. G1 requires the pull build's symbol
|
||||||
|
// set and .text to be byte-identical, and a definition guarded only on the
|
||||||
|
// inside still emits a symbol - measured, not assumed.
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Backend {
|
||||||
|
|
||||||
|
// Creates the server's BackendObject and publishes the consumed-subsystem
|
||||||
|
// mask and the capability bits onto ServerSessionInstance(). Does NOT create
|
||||||
|
// an EGL context: that happens later, on the apply thread, when the client's
|
||||||
|
// first eglMakeCurrent crosses as a blocking control request.
|
||||||
|
//
|
||||||
|
// Returns false when the backend could not be created, and the caller must
|
||||||
|
// then REFUSE TO CONTINUE rather than fall back - a server process that came
|
||||||
|
// up without a backend would accept a session it can never apply.
|
||||||
|
Bool InitServerRoleForSpawn();
|
||||||
|
|
||||||
|
} // namespace MobileGL::MG_Backend
|
||||||
|
|
||||||
|
#endif // MOBILEGL_BUILD_DISAGGREGATED
|
||||||
@@ -120,7 +120,12 @@ MOBILEGL_GL_API void glFinish() {
|
|||||||
MobileGL::MG_Pipe::MGPipeClientFinish();
|
MobileGL::MG_Pipe::MGPipeClientFinish();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
MOBILEGL_GL_API void glFlush() { MGLOG_D("Implementing function: %s(...)", __FUNCTION__); }
|
MOBILEGL_GL_API void glFlush() {
|
||||||
|
MGLOG_D("Implementing function: %s(...)", __FUNCTION__);
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
MobileGL::MG_Pipe::MGPipeClientFlush();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
DECLARE_GL_FUNCTION_HEAD(void, FramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FramebufferRenderbuffer, target, attachment, renderbuffertarget, renderbuffer)
|
DECLARE_GL_FUNCTION_HEAD(void, FramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FramebufferRenderbuffer, target, attachment, renderbuffertarget, renderbuffer)
|
||||||
DECLARE_GL_FUNCTION_HEAD(void, FramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FramebufferTexture2D, target, attachment, textarget, texture, level)
|
DECLARE_GL_FUNCTION_HEAD(void, FramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FramebufferTexture2D, target, attachment, textarget, texture, level)
|
||||||
DECLARE_GL_FUNCTION_HEAD(void, FrontFace, GLenum mode) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FrontFace, mode)
|
DECLARE_GL_FUNCTION_HEAD(void, FrontFace, GLenum mode) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FrontFace, mode)
|
||||||
|
|||||||
@@ -18,6 +18,13 @@
|
|||||||
#include <MG_State/GLState/Core.h>
|
#include <MG_State/GLState/Core.h>
|
||||||
#include <MG_State/GLState/ErrorState/ErrorInfo.h>
|
#include <MG_State/GLState/ErrorState/ErrorInfo.h>
|
||||||
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
||||||
|
|
||||||
|
// GUARDED AT THE INCLUDE, not just around the call. This file compiles in the PULL build too,
|
||||||
|
// and G1 requires that build's symbol set and .text to be byte-identical - a header that drags
|
||||||
|
// in MG_Remote would change it whether or not any code path reaches the session.
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
#include <MG_Remote/Client/ClientSession.h>
|
||||||
|
#endif
|
||||||
#include <MG_Util/Converters/GLToMG/BufferEnumConverter.h>
|
#include <MG_Util/Converters/GLToMG/BufferEnumConverter.h>
|
||||||
#include <MG_Util/Converters/GLToMG/RenderStateEnumConverter.h>
|
#include <MG_Util/Converters/GLToMG/RenderStateEnumConverter.h>
|
||||||
#include <MG_Util/Converters/MGToGL/FramebufferEnumConverter.h>
|
#include <MG_Util/Converters/MGToGL/FramebufferEnumConverter.h>
|
||||||
@@ -2853,6 +2860,27 @@ namespace MobileGL::MG_Impl::GLImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLenum GetGraphicsResetStatus() {
|
GLenum GetGraphicsResetStatus() {
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
// P6 `dl` (CONTRACT-P6 5.3): THE ONE GL-VISIBLE CONSEQUENCE OF A DEAD SERVER.
|
||||||
|
//
|
||||||
|
// Before this, "a dead server leaves the client silently DECLINE-ing every verb forever
|
||||||
|
// with glGetError clean" - the contract's own words, and the reason the latch is a
|
||||||
|
// package rather than carriage. An application that asks the robustness question has no
|
||||||
|
// other way to find out, because a DECLINE is indistinguishable from a verb that
|
||||||
|
// happened.
|
||||||
|
//
|
||||||
|
// GL_UNKNOWN_CONTEXT_RESET, not GUILTY or INNOCENT. Those two assign BLAME - guilty
|
||||||
|
// means this context's commands caused the reset, innocent means another context's did -
|
||||||
|
// and neither is knowable here: the server died for a reason that never crossed the
|
||||||
|
// wire, and it could as easily have been a driver fault as this client's draw. UNKNOWN is
|
||||||
|
// the spec's answer for exactly that, and it is the one that does not lie.
|
||||||
|
//
|
||||||
|
// WHOLLY INSIDE THE GUARD, including the include above. In a pull build this function is
|
||||||
|
// byte-for-byte what it was, which is what G1 measures.
|
||||||
|
if (MG_Remote::Client::ClientSession::DeviceLost()) {
|
||||||
|
return GL_UNKNOWN_CONTEXT_RESET;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// MobileGL does not implement robustness reset notification, so report GL_NO_ERROR
|
// MobileGL does not implement robustness reset notification, so report GL_NO_ERROR
|
||||||
// ("no reset detected"). Returning the generic stub's (GLenum)1 makes dEQP read a lost
|
// ("no reset detected"). Returning the generic stub's (GLenum)1 makes dEQP read a lost
|
||||||
// device after every case (gl3cTestPackages.cpp:121) and, under the default
|
// device after every case (gl3cTestPackages.cpp:121) and, under the default
|
||||||
|
|||||||
@@ -1251,6 +1251,14 @@ namespace MobileGL::MG_Pipe {
|
|||||||
|
|
||||||
// P5e (ra), CONTRACT-P5E §2.5. Declared in PipeMutation.h; see there for why it is not a
|
// P5e (ra), CONTRACT-P5E §2.5. Declared in PipeMutation.h; see there for why it is not a
|
||||||
// ClientSession call at the GL entry point.
|
// ClientSession call at the GL entry point.
|
||||||
|
void MGPipeClientFlush() {
|
||||||
|
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) return;
|
||||||
|
if (MG_Remote::Client::RunsAsTheServerRole()) return;
|
||||||
|
if (MG_Remote::Client::ClientSession* session = MG_Remote::Client::ClientSession::Active()) {
|
||||||
|
session->Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MGPipeClientFinish() {
|
void MGPipeClientFinish() {
|
||||||
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) return;
|
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) return;
|
||||||
if (MG_Remote::Client::RunsAsTheServerRole()) return;
|
if (MG_Remote::Client::RunsAsTheServerRole()) return;
|
||||||
|
|||||||
@@ -600,11 +600,11 @@ namespace MobileGL::MG_Pipe {
|
|||||||
// so only a non-empty run goes through the bounds-checked resolve.
|
// so only a non-empty run goes through the bounds-checked resolve.
|
||||||
if (bytes.Size != 0) {
|
if (bytes.Size != 0) {
|
||||||
auto* session = MG_Remote::Client::ClientSession::Active();
|
auto* session = MG_Remote::Client::ClientSession::Active();
|
||||||
const void* resolved =
|
const void* resolved = nullptr;
|
||||||
session == nullptr
|
if (session && session->DataLink()) {
|
||||||
? nullptr
|
session->DataLink()->ResolveSpan(MG_Remote::Transport::LinkSegment::Event,
|
||||||
: session->Segments().Resolve(MG_Remote::Wire::kSegEvent, bytes.Offset,
|
{bytes.Offset, bytes.Size}, &resolved);
|
||||||
bytes.Size);
|
}
|
||||||
if (resolved == nullptr) {
|
if (resolved == nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"OnBufferWriteback.Offset\"} - "
|
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"OnBufferWriteback.Offset\"} - "
|
||||||
"the writeback blobref's {%llu + %llu} does not resolve inside the "
|
"the writeback blobref's {%llu + %llu} does not resolve inside the "
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
|
#include <MG_Backend/MGPipe/PipeInputs.h> // D1c: MGPipeServerArm()
|
||||||
#include <MG_Pipe/PipeApply.h>
|
#include <MG_Pipe/PipeApply.h>
|
||||||
#include <MG_Remote/Server/ServerLoop.h>
|
#include <MG_Remote/Server/ServerLoop.h>
|
||||||
#include <MG_Util/Debug/Log.h>
|
#include <MG_Util/Debug/Log.h>
|
||||||
@@ -28,7 +29,13 @@ namespace MobileGL::MG_Pipe {
|
|||||||
|
|
||||||
void MGPipeRefuseAllocatorFromApplyThread(const char* entry) {
|
void MGPipeRefuseAllocatorFromApplyThread(const char* entry) {
|
||||||
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) return;
|
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) return;
|
||||||
if (!MG_Remote::Server::ServerLoop::OnApplyThread()) return;
|
// D10: OR'd with the PROCESS-ROLE fact, not replaced by it. OnApplyThread() answers
|
||||||
|
// about the INPROC applier thread and is the only fact a ServerLoop fixture with no
|
||||||
|
// client session has; MGPipeServerArm() adds the spawn case, where EVERY thread is a
|
||||||
|
// server thread. Replacing the first with the second disarmed the refusal in every unit
|
||||||
|
// test that drives the apply thread directly - measured, 14 RemoteGuards cases went
|
||||||
|
// green-by-omission before this was put back as a disjunction.
|
||||||
|
if (!MG_Remote::Server::ServerLoop::OnApplyThread() && !MG_Pipe::MGPipeServerArm()) return;
|
||||||
// P5f (fr): all named allocator exemptions are retired. A barrier can
|
// P5f (fr): all named allocator exemptions are retired. A barrier can
|
||||||
// stabilize a client allocator but cannot make it server-owned memory.
|
// stabilize a client allocator but cannot make it server-owned memory.
|
||||||
MGLOG_F("MGPipe: Fatal{RoleViolation, \"MGPipeSlots\"} - the apply thread called "
|
MGLOG_F("MGPipe: Fatal{RoleViolation, \"MGPipeSlots\"} - the apply thread called "
|
||||||
@@ -47,7 +54,13 @@ namespace MobileGL::MG_Pipe {
|
|||||||
// make a frontend SharedPtr exist in a separate server process.
|
// make a frontend SharedPtr exist in a separate server process.
|
||||||
void MGPipeRefuseFrontendKeyedRegistryFromApplyThread(const char* entry) {
|
void MGPipeRefuseFrontendKeyedRegistryFromApplyThread(const char* entry) {
|
||||||
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) return;
|
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) return;
|
||||||
if (!MG_Remote::Server::ServerLoop::OnApplyThread()) return;
|
// D10: OR'd with the PROCESS-ROLE fact, not replaced by it. OnApplyThread() answers
|
||||||
|
// about the INPROC applier thread and is the only fact a ServerLoop fixture with no
|
||||||
|
// client session has; MGPipeServerArm() adds the spawn case, where EVERY thread is a
|
||||||
|
// server thread. Replacing the first with the second disarmed the refusal in every unit
|
||||||
|
// test that drives the apply thread directly - measured, 14 RemoteGuards cases went
|
||||||
|
// green-by-omission before this was put back as a disjunction.
|
||||||
|
if (!MG_Remote::Server::ServerLoop::OnApplyThread() && !MG_Pipe::MGPipeServerArm()) return;
|
||||||
MGLOG_F("MGPipe: Fatal{RoleViolation, \"MGPipeSlots\"} - the apply thread reached "
|
MGLOG_F("MGPipe: Fatal{RoleViolation, \"MGPipeSlots\"} - the apply thread reached "
|
||||||
"BackendSlotTable::%s. Frontend-identity registry operations are monolith-only, "
|
"BackendSlotTable::%s. Frontend-identity registry operations are monolith-only, "
|
||||||
"including barriered records; resolve the twin from the record's handle instead",
|
"including barriered records; resolve the twin from the record's handle instead",
|
||||||
|
|||||||
@@ -1983,36 +1983,119 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
|||||||
#
|
#
|
||||||
# ClearThenReadPixelsScenario is target A of the reduced path and already existed; Triangle is
|
# ClearThenReadPixelsScenario is target A of the reduced path and already existed; Triangle is
|
||||||
# target B and PersistentCoherentMap is target C, both new in P5.
|
# target B and PersistentCoherentMap is target C, both new in P5.
|
||||||
gtest_discover_tests(MobileGLIntegrationTest
|
# ---- P6 `t6`: THE SPAWN ARM, beside the inproc one and never instead of it --------------
|
||||||
TEST_PREFIX "DirectGLES.Split."
|
#
|
||||||
TEST_LIST MGL_SPLIT_CLEAR_TESTS
|
# EXIT GATES 9.2 AND 9.3: `integration-spawn`'s case-name set must be IDENTICAL to
|
||||||
TEST_FILTER "ClearThenReadPixelsScenario.*"
|
# `integration-split`'s, and it must be green at the same count.
|
||||||
DISCOVERY_TIMEOUT 30
|
#
|
||||||
PROPERTIES
|
# THAT IDENTITY IS MADE STRUCTURAL RATHER THAN MAINTAINED. Registering the spawn arm as a
|
||||||
LABELS "integration-gpu\;integration-split"
|
# second copy of each block would make the two sets agree today and drift the first time
|
||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
# somebody adds a scenario to one of them - and a spawn lane covering LESS than the split
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_ENVIRONMENT}"
|
# lane goes green while proving less, with nothing to say so. One macro emits both arms from
|
||||||
)
|
# one filter, so a case added to either is added to both or to neither.
|
||||||
gtest_discover_tests(MobileGLIntegrationTest
|
#
|
||||||
TEST_PREFIX "DirectGLES.Split."
|
# ONE ENVIRONMENT DIFFERENCE, AND IT IS THE SUBJECT OF THE LANE. MOBILEGL_TRANSPORT=spawn
|
||||||
TEST_LIST MGL_SPLIT_TRIANGLE_TESTS
|
# makes the test process the CLIENT and has it launch a server from MOBILEGL_IPC_SERVER_PATH
|
||||||
TEST_FILTER "TriangleScenario.*"
|
# - the same path the inproc arm already carries, because under inproc the library reads it
|
||||||
DISCOVERY_TIMEOUT 30
|
# and decides it does not need one.
|
||||||
PROPERTIES
|
mgl_itest_join_environment(MGL_ITEST_GLES_SPAWN_ENVIRONMENT
|
||||||
LABELS "integration-gpu\;integration-split"
|
"MOBILEGL_BACKEND_TYPE=DirectGLES" "MOBILEGL_TRANSPORT=spawn"
|
||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
"MOBILEGL_IPC_SERVER_PATH=${MGL_ITEST_SPLIT_SERVER_PATH}" "MGITEST_SPLIT_LANE=1"
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_ENVIRONMENT}"
|
${MGL_ITEST_CAPABILITY_ENV} ${MGL_ITEST_COMMON_ENV})
|
||||||
)
|
|
||||||
gtest_discover_tests(MobileGLIntegrationTest
|
# A single supervisor serves one session at a time. Fixture teardown also reaps a
|
||||||
TEST_PREFIX "DirectGLES.Split."
|
# child left behind by a failed client; the resource lock serializes this lane.
|
||||||
TEST_LIST MGL_SPLIT_PMAP_TESTS
|
set(MOBILEGL_ITEST_TCP_ENDPOINT "tcp://127.0.0.1:40613" CACHE STRING "Loopback TCP integration endpoint")
|
||||||
TEST_FILTER "PersistentCoherentMapScenario.*"
|
set(MOBILEGL_ITEST_TCP_DEVICE_ENDPOINT "" CACHE STRING "Optional device TCP integration endpoint")
|
||||||
DISCOVERY_TIMEOUT 30
|
set(MOBILEGL_ITEST_TCP_DEVICE_TOKEN "" CACHE STRING "Token for the device TCP integration endpoint")
|
||||||
PROPERTIES
|
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||||
LABELS "integration-gpu\;integration-split"
|
set(MGL_TCP_FIXTURE "${CMAKE_SOURCE_DIR}/scripts/ci/tcp_server_fixture.py")
|
||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
set(MGL_TCP_STATE "${CMAKE_CURRENT_BINARY_DIR}/tcp-server.json")
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_ENVIRONMENT}"
|
add_test(NAME TcpServer.Start COMMAND "${Python3_EXECUTABLE}" "${MGL_TCP_FIXTURE}"
|
||||||
)
|
start --server "${MGL_ITEST_SPLIT_SERVER_PATH}" --endpoint "${MOBILEGL_ITEST_TCP_ENDPOINT}"
|
||||||
|
--state "${MGL_TCP_STATE}")
|
||||||
|
add_test(NAME TcpServer.Stop COMMAND "${Python3_EXECUTABLE}" "${MGL_TCP_FIXTURE}"
|
||||||
|
stop --state "${MGL_TCP_STATE}")
|
||||||
|
set_tests_properties(TcpServer.Start PROPERTIES FIXTURES_SETUP mobilegl-tcp TIMEOUT 20)
|
||||||
|
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")
|
||||||
|
set_tests_properties(TcpLane.AccountingControls PROPERTIES LABELS unit TIMEOUT 20)
|
||||||
|
mgl_itest_join_environment(MGL_ITEST_GLES_TCP_ENVIRONMENT
|
||||||
|
"MOBILEGL_BACKEND_TYPE=DirectGLES" "MOBILEGL_TRANSPORT=spawn"
|
||||||
|
"MOBILEGL_IPC_CONTROL=${MOBILEGL_ITEST_TCP_ENDPOINT}" "MOBILEGL_IPC_DATA=stream"
|
||||||
|
"MOBILEGL_IPC_REQUIRE_SAME_BUILD=1" "MOBILEGL_IPC_LOG_FORWARD=1" "MOBILEGL_IPC_TOKEN="
|
||||||
|
"MGITEST_SPLIT_LANE=1" "MGITEST_TCP_LANE=1" "MOBILEGL_ITEST_REQUIRE_GPU=1"
|
||||||
|
${MGL_ITEST_CAPABILITY_ENV} ${MGL_ITEST_COMMON_ENV})
|
||||||
|
mgl_itest_join_environment(MGL_ITEST_GLES_TCPDEVICE_ENVIRONMENT
|
||||||
|
"MOBILEGL_BACKEND_TYPE=DirectGLES" "MOBILEGL_TRANSPORT=spawn"
|
||||||
|
"MOBILEGL_IPC_CONTROL=${MOBILEGL_ITEST_TCP_DEVICE_ENDPOINT}" "MOBILEGL_IPC_DATA=stream"
|
||||||
|
"MOBILEGL_IPC_REQUIRE_SAME_BUILD=1" "MOBILEGL_IPC_LOG_FORWARD=1"
|
||||||
|
"MOBILEGL_IPC_TOKEN=${MOBILEGL_ITEST_TCP_DEVICE_TOKEN}"
|
||||||
|
"MGITEST_SPLIT_LANE=1" "MGITEST_TCP_LANE=1" "MOBILEGL_ITEST_REQUIRE_GPU=1"
|
||||||
|
${MGL_ITEST_CAPABILITY_ENV} ${MGL_ITEST_COMMON_ENV})
|
||||||
|
|
||||||
|
# scenarioFilter, a PREFIX TAIL (empty for most; "F1." and "Ct." for the two per-slot loops,
|
||||||
|
# which name their sub-lane in the test name), then zero or more EXTRA LABEL STEMS. A stem is
|
||||||
|
# suffixed with the arm's own name (`integration-clientarrays` becomes `-split` on one arm and
|
||||||
|
# `-spawn` on the other), so a lane-scoped label cannot accidentally name both lanes at once.
|
||||||
|
# A UNIQUE LIST VARIABLE PER CALL, and the names collected for SplitLogPaths to walk.
|
||||||
|
#
|
||||||
|
# gtest_discover_tests' TEST_LIST is not a configure-time value: the generated include file
|
||||||
|
# sets it when CTEST runs. So one shared variable would hold only the LAST block's entries -
|
||||||
|
# measured, and it is why the first version of this macro silently unhooked every private log
|
||||||
|
# path but one. The counter gives each call its own name; the names are what get walked.
|
||||||
|
set(MGL_SPLIT_ARM_TESTS "")
|
||||||
|
set(MGL_SPLIT_ARM_TEST_LISTS "")
|
||||||
|
set(MGL_SPLIT_ARM_INDEX 0)
|
||||||
|
macro(mgl_itest_register_split_arms scenarioFilter prefixTail)
|
||||||
|
set(mglItestArms Split Spawn Tcp)
|
||||||
|
if(MOBILEGL_ITEST_TCP_DEVICE_ENDPOINT)
|
||||||
|
list(APPEND mglItestArms TcpDevice)
|
||||||
|
endif()
|
||||||
|
foreach(mglItestArm IN LISTS mglItestArms)
|
||||||
|
string(TOLOWER "${mglItestArm}" mglItestArmLower)
|
||||||
|
string(TOUPPER "${mglItestArm}" mglItestArmUpper)
|
||||||
|
set(mglItestArmProperties)
|
||||||
|
if(mglItestArm STREQUAL "Tcp")
|
||||||
|
set(mglItestArmProperties FIXTURES_REQUIRED mobilegl-tcp RESOURCE_LOCK mobilegl-tcp)
|
||||||
|
elseif(mglItestArm STREQUAL "TcpDevice")
|
||||||
|
set(mglItestArmLower tcp-device)
|
||||||
|
set(mglItestArmProperties RESOURCE_LOCK mobilegl-tcp-device)
|
||||||
|
endif()
|
||||||
|
set(mglItestArmLabels "integration-gpu\\;integration-${mglItestArmLower}")
|
||||||
|
foreach(mglItestExtra IN ITEMS ${ARGN})
|
||||||
|
set(mglItestArmLabels "${mglItestArmLabels}\\;${mglItestExtra}-${mglItestArmLower}")
|
||||||
|
endforeach()
|
||||||
|
# ONE ACCUMULATED LIST FOR BOTH ARMS, and it is not bookkeeping: SplitLogPaths gives
|
||||||
|
# every entry a PRIVATE MOBILEGL_LOG_FILE_PATH, and SplitLogPaths.PrivateAndDistinct
|
||||||
|
# reds if one is missing or shared. The per-block TEST_LIST variables this macro
|
||||||
|
# replaced were what fed it - dropping them silently unhooked the whole mechanism,
|
||||||
|
# which that gate caught. Accumulating here means a block added later is covered
|
||||||
|
# without anyone remembering to add its variable to the list.
|
||||||
|
#
|
||||||
|
# IT MATTERS MORE ON THE SPAWN ARM: there TWO PROCESSES append to the path, so two
|
||||||
|
# entries sharing one file is not merely ambiguous, it interleaves two sessions.
|
||||||
|
gtest_discover_tests(MobileGLIntegrationTest
|
||||||
|
TEST_PREFIX "DirectGLES.${mglItestArm}.${prefixTail}"
|
||||||
|
TEST_LIST "MGL_SPLIT_ARM_TESTS_${MGL_SPLIT_ARM_INDEX}"
|
||||||
|
TEST_FILTER "${scenarioFilter}"
|
||||||
|
DISCOVERY_TIMEOUT 30
|
||||||
|
PROPERTIES
|
||||||
|
LABELS "${mglItestArmLabels}"
|
||||||
|
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||||
|
ENVIRONMENT "${MGL_ITEST_GLES_${mglItestArmUpper}_ENVIRONMENT}"
|
||||||
|
${mglItestArmProperties}
|
||||||
|
)
|
||||||
|
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()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
mgl_itest_register_split_arms("ClearThenReadPixelsScenario.*" "")
|
||||||
|
mgl_itest_register_split_arms("TriangleScenario.*" "")
|
||||||
|
mgl_itest_register_split_arms("PersistentCoherentMapScenario.*" "")
|
||||||
|
|
||||||
|
|
||||||
# ---- P5e fix1: THE PUSH-MONOLITH ARM, INSIDE THE GATED SET (ID-107) ----------------------
|
# ---- P5e fix1: THE PUSH-MONOLITH ARM, INSIDE THE GATED SET (ID-107) ----------------------
|
||||||
#
|
#
|
||||||
@@ -2077,16 +2160,7 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
|||||||
set(MGL_SPLIT_D1_FILTER_DrawParametersScenario "DrawParametersScenario.*")
|
set(MGL_SPLIT_D1_FILTER_DrawParametersScenario "DrawParametersScenario.*")
|
||||||
set(MGL_SPLIT_D1_FILTER_PrimitiveRestartScenario "PrimitiveRestartScenario.*")
|
set(MGL_SPLIT_D1_FILTER_PrimitiveRestartScenario "PrimitiveRestartScenario.*")
|
||||||
foreach(mglItestD1Scenario IN LISTS MGL_SPLIT_D1_SCENARIOS)
|
foreach(mglItestD1Scenario IN LISTS MGL_SPLIT_D1_SCENARIOS)
|
||||||
gtest_discover_tests(MobileGLIntegrationTest
|
mgl_itest_register_split_arms("${MGL_SPLIT_D1_FILTER_${mglItestD1Scenario}}" "")
|
||||||
TEST_PREFIX "DirectGLES.Split."
|
|
||||||
TEST_LIST "MGL_SPLIT_D1_${mglItestD1Scenario}_TESTS"
|
|
||||||
TEST_FILTER "${MGL_SPLIT_D1_FILTER_${mglItestD1Scenario}}"
|
|
||||||
DISCOVERY_TIMEOUT 30
|
|
||||||
PROPERTIES
|
|
||||||
LABELS "integration-gpu\;integration-split"
|
|
||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_ENVIRONMENT}"
|
|
||||||
)
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# ---- P5e mv: THE MULTI-DRAW TIERS, INSIDE THE GATED SET (ID-109's rule, one level down) --
|
# ---- P5e mv: THE MULTI-DRAW TIERS, INSIDE THE GATED SET (ID-109's rule, one level down) --
|
||||||
@@ -2199,16 +2273,7 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
|||||||
set(MGL_SPLIT_I1_FILTER_AtomicCounterScenario "AtomicCounterScenario.*")
|
set(MGL_SPLIT_I1_FILTER_AtomicCounterScenario "AtomicCounterScenario.*")
|
||||||
set(MGL_SPLIT_I1_FILTER_ProgramPipelineScenario "ProgramPipelineScenario.*StorageBlock*")
|
set(MGL_SPLIT_I1_FILTER_ProgramPipelineScenario "ProgramPipelineScenario.*StorageBlock*")
|
||||||
foreach(mglItestI1Scenario IN LISTS MGL_SPLIT_I1_SCENARIOS)
|
foreach(mglItestI1Scenario IN LISTS MGL_SPLIT_I1_SCENARIOS)
|
||||||
gtest_discover_tests(MobileGLIntegrationTest
|
mgl_itest_register_split_arms("${MGL_SPLIT_I1_FILTER_${mglItestI1Scenario}}" "")
|
||||||
TEST_PREFIX "DirectGLES.Split."
|
|
||||||
TEST_LIST "MGL_SPLIT_I1_${mglItestI1Scenario}_TESTS"
|
|
||||||
TEST_FILTER "${MGL_SPLIT_I1_FILTER_${mglItestI1Scenario}}"
|
|
||||||
DISCOVERY_TIMEOUT 30
|
|
||||||
PROPERTIES
|
|
||||||
LABELS "integration-gpu\;integration-split"
|
|
||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_ENVIRONMENT}"
|
|
||||||
)
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# ---- P5b t2: the transform-feedback spans, the XFB object bind, the patch parameter -------
|
# ---- P5b t2: the transform-feedback spans, the XFB object bind, the patch parameter -------
|
||||||
@@ -2237,53 +2302,17 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
|||||||
# Every DirectVulkan XFB capture entry in the inproc census fails on exactly that (t2-v1.md
|
# Every DirectVulkan XFB capture entry in the inproc census fails on exactly that (t2-v1.md
|
||||||
# §"the 51"), and it retires with P7 (Magma's resource family) / P9 (the readback carrier) -
|
# §"the 51"), and it retires with P7 (Magma's resource family) / P9 (the readback carrier) -
|
||||||
# not here. A DirectVulkan arm of this lane would be red for a reason t2 cannot fix.
|
# not here. A DirectVulkan arm of this lane would be red for a reason t2 cannot fix.
|
||||||
gtest_discover_tests(MobileGLIntegrationTest
|
mgl_itest_register_split_arms("TessellationXfbCaptureScenario.*" "")
|
||||||
TEST_PREFIX "DirectGLES.Split."
|
mgl_itest_register_split_arms("XfbCaptureBufferReuseScenario.*" "")
|
||||||
TEST_LIST MGL_SPLIT_T2_TESS_TESTS
|
|
||||||
TEST_FILTER "TessellationXfbCaptureScenario.*"
|
|
||||||
DISCOVERY_TIMEOUT 30
|
|
||||||
PROPERTIES
|
|
||||||
LABELS "integration-gpu\;integration-split"
|
|
||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_ENVIRONMENT}"
|
|
||||||
)
|
|
||||||
gtest_discover_tests(MobileGLIntegrationTest
|
|
||||||
TEST_PREFIX "DirectGLES.Split."
|
|
||||||
TEST_LIST MGL_SPLIT_T2_XFB_TESTS
|
|
||||||
TEST_FILTER "XfbCaptureBufferReuseScenario.*"
|
|
||||||
DISCOVERY_TIMEOUT 30
|
|
||||||
PROPERTIES
|
|
||||||
LABELS "integration-gpu\;integration-split"
|
|
||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_ENVIRONMENT}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# ---- P5e package vi (MG_Remote/CONTRACT-P5E.md §5.1, ID-82 / ruling 2) --------------------
|
# ---- P5e package vi (MG_Remote/CONTRACT-P5E.md §5.1, ID-82 / ruling 2) --------------------
|
||||||
#
|
#
|
||||||
# Client-memory vertices and indices now cross as owned ordinary buffers.
|
# Client-memory vertices and indices now cross as owned ordinary buffers.
|
||||||
# Keep the original names and private logs; all six scenarios join the full
|
# Keep the original names and private logs; all six scenarios join the full
|
||||||
# GPU and split acceptance labels as well as their focused regression label.
|
# GPU and split acceptance labels as well as their focused regression label.
|
||||||
gtest_discover_tests(MobileGLIntegrationTest
|
mgl_itest_register_split_arms("ClientVertexArrayScenario.*" "" integration-clientarrays)
|
||||||
TEST_PREFIX "DirectGLES.Split."
|
|
||||||
TEST_LIST MGL_SPLIT_VI_CLIENT_ARRAY_TESTS
|
|
||||||
TEST_FILTER "ClientVertexArrayScenario.*"
|
|
||||||
DISCOVERY_TIMEOUT 30
|
|
||||||
PROPERTIES
|
|
||||||
LABELS "integration-gpu\;integration-split\;integration-clientarrays-split"
|
|
||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_ENVIRONMENT}"
|
|
||||||
)
|
|
||||||
|
|
||||||
gtest_discover_tests(MobileGLIntegrationTest
|
mgl_itest_register_split_arms("SyncWireScenario.*" "")
|
||||||
TEST_PREFIX "DirectGLES.Split."
|
|
||||||
TEST_LIST MGL_SPLIT_SYNC_TESTS
|
|
||||||
TEST_FILTER "SyncWireScenario.*"
|
|
||||||
DISCOVERY_TIMEOUT 30
|
|
||||||
PROPERTIES
|
|
||||||
LABELS "integration-gpu\;integration-split"
|
|
||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_ENVIRONMENT}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# The split half of the counting pair. MGITEST_PERSISTENT_MAP_ARM=emulated is R-6: under split
|
# 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
|
# the adopt tier is pinned at T2, the resource owner declines every acquisition and the client
|
||||||
@@ -2400,10 +2429,12 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
|||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_STRICT_ENVIRONMENT}"
|
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_STRICT_ENVIRONMENT}"
|
||||||
)
|
)
|
||||||
# Apply per-entry paths after GoogleTest discovery has populated the TEST_LISTs.
|
# The configure_file that used to sit here MOVED TO THE END OF THIS FILE (P6 `t6`).
|
||||||
configure_file(Harness/SplitLogPaths.cmake.in SplitLogPaths.cmake @ONLY)
|
#
|
||||||
set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES
|
# It substitutes @MGL_SPLIT_ARM_TEST_LISTS@, which the registration macro appends to - so
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/SplitLogPaths.cmake")
|
# running it here captured only the calls made ABOVE this line and silently dropped the F1
|
||||||
|
# and Ct blocks below it. SplitLogPaths.PrivateAndDistinct is what caught that, naming
|
||||||
|
# F1WireScenario.ClearBufferfiPixels; the generated file now sees every call.
|
||||||
# Python is mandatory for this split integration gate (also used by the CI controls).
|
# Python is mandatory for this split integration gate (also used by the CI controls).
|
||||||
# Do not silently omit the ownership check when the interpreter is unavailable.
|
# Do not silently omit the ownership check when the interpreter is unavailable.
|
||||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||||
@@ -2418,15 +2449,7 @@ endif()
|
|||||||
if (MOBILEGL_BUILD_DISAGGREGATED)
|
if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||||
target_sources(MobileGLIntegrationTest PRIVATE Scenarios/F1WireScenario.cpp)
|
target_sources(MobileGLIntegrationTest PRIVATE Scenarios/F1WireScenario.cpp)
|
||||||
foreach(f1Slot ClearBufferfi ClearBufferfv ClearBufferiv ClearBufferuiv ClearNamedFramebufferfi ClearNamedFramebufferfv ClearNamedFramebufferiv ClearNamedFramebufferuiv CopyTexImage2D CopyTexSubImage2D GenerateMipmap GenerateMipmapPackedFloat GenerateMipmapDepth)
|
foreach(f1Slot ClearBufferfi ClearBufferfv ClearBufferiv ClearBufferuiv ClearNamedFramebufferfi ClearNamedFramebufferfv ClearNamedFramebufferiv ClearNamedFramebufferuiv CopyTexImage2D CopyTexSubImage2D GenerateMipmap GenerateMipmapPackedFloat GenerateMipmapDepth)
|
||||||
gtest_discover_tests(MobileGLIntegrationTest
|
mgl_itest_register_split_arms("F1WireScenario.${f1Slot}Pixels" "F1.")
|
||||||
TEST_PREFIX "DirectGLES.Split.F1."
|
|
||||||
TEST_FILTER "F1WireScenario.${f1Slot}Pixels"
|
|
||||||
DISCOVERY_TIMEOUT 30
|
|
||||||
PROPERTIES
|
|
||||||
LABELS "integration-split"
|
|
||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_ENVIRONMENT}\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/p5b-f1-${f1Slot}.log"
|
|
||||||
)
|
|
||||||
endforeach()
|
endforeach()
|
||||||
# P5f fm: the framebuffer/copy/mipmap verbs now consume server records on Magma too.
|
# P5f fm: the framebuffer/copy/mipmap verbs now consume server records on Magma too.
|
||||||
mgl_itest_join_environment(MGL_ITEST_MAGMA_WIRE_ENVIRONMENT
|
mgl_itest_join_environment(MGL_ITEST_MAGMA_WIRE_ENVIRONMENT
|
||||||
@@ -2579,15 +2602,7 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
|||||||
TextureDeathCrossesAndTheRecycledSlotAnswersTheNewObject
|
TextureDeathCrossesAndTheRecycledSlotAnswersTheNewObject
|
||||||
FramebufferDeathCrossesAndTheRecycledSlotAnswersTheNewObject
|
FramebufferDeathCrossesAndTheRecycledSlotAnswersTheNewObject
|
||||||
TheDirectApplierResetCallOnTheGLThreadIsRoleViolation)
|
TheDirectApplierResetCallOnTheGLThreadIsRoleViolation)
|
||||||
gtest_discover_tests(MobileGLIntegrationTest
|
mgl_itest_register_split_arms("CtWireScenario.${ctCase}" "Ct.")
|
||||||
TEST_PREFIX "DirectGLES.Split.Ct."
|
|
||||||
TEST_FILTER "CtWireScenario.${ctCase}"
|
|
||||||
DISCOVERY_TIMEOUT 30
|
|
||||||
PROPERTIES
|
|
||||||
LABELS "integration-gpu\;integration-split"
|
|
||||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
|
||||||
ENVIRONMENT "${MGL_ITEST_GLES_SPLIT_ENVIRONMENT}\;MOBILEGL_LOG_FILE_PATH=${CMAKE_CURRENT_BINARY_DIR}/p5c-ct-${ctCase}.log"
|
|
||||||
)
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -2754,6 +2769,12 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MOBILEGL_BUILD_DISAGGREGATED)
|
if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||||
|
# LAST, so every mgl_itest_register_split_arms call above has already contributed its list
|
||||||
|
# name. Apply per-entry paths after GoogleTest discovery has populated the TEST_LISTs.
|
||||||
|
configure_file(Harness/SplitLogPaths.cmake.in SplitLogPaths.cmake @ONLY)
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/SplitLogPaths.cmake")
|
||||||
|
|
||||||
add_test(NAME SplitLogPaths.ResultAccountingControls
|
add_test(NAME SplitLogPaths.ResultAccountingControls
|
||||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Harness/test_split_log_paths.py)
|
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Harness/test_split_log_paths.py)
|
||||||
set_tests_properties(SplitLogPaths.ResultAccountingControls PROPERTIES LABELS "unit")
|
set_tests_properties(SplitLogPaths.ResultAccountingControls PROPERTIES LABELS "unit")
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace MGITest {
|
|||||||
if (out == nullptr) return false;
|
if (out == nullptr) return false;
|
||||||
namespace MGP = MobileGL::MG_Pipe;
|
namespace MGP = MobileGL::MG_Pipe;
|
||||||
out->peekAvailable = true;
|
out->peekAvailable = true;
|
||||||
out->roleSplitActive = MGP::MGPipeRoleSplitActive();
|
out->roleSplitActive = MGP::MGPipeRoleSplitRehearsalActive();
|
||||||
MGP::PipeInputs& client = MGP::MGPipeClientInputs();
|
MGP::PipeInputs& client = MGP::MGPipeClientInputs();
|
||||||
out->blocksDistinct = &client != &MGP::gPipeInputs;
|
out->blocksDistinct = &client != &MGP::gPipeInputs;
|
||||||
out->clientSerial = client.FilledState().CurrentVerbSerial;
|
out->clientSerial = client.FilledState().CurrentVerbSerial;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace MGITest {
|
|||||||
// False wherever the peek cannot look (see the header above). Everything else is
|
// False wherever the peek cannot look (see the header above). Everything else is
|
||||||
// meaningful only when this is true.
|
// meaningful only when this is true.
|
||||||
bool peekAvailable = false;
|
bool peekAvailable = false;
|
||||||
// MGPipeRoleSplitActive(): the knob AND a real transport. The control's red half turns
|
// MGPipeRoleSplitRehearsalActive(): the knob AND a real transport. The control's red half turns
|
||||||
// on this answer alone.
|
// on this answer alone.
|
||||||
bool roleSplitActive = false;
|
bool roleSplitActive = false;
|
||||||
// &MGPipeClientInputs() != &gPipeInputs - the fill side and the read side are two
|
// &MGPipeClientInputs() != &gPipeInputs - the fill side and the read side are two
|
||||||
|
|||||||
@@ -327,7 +327,18 @@ namespace MGITest {
|
|||||||
// has thought of. Only then does the parent do the real bring-up.
|
// has thought of. Only then does the parent do the real bring-up.
|
||||||
//
|
//
|
||||||
// Returns an empty string when the platform survived a full bring-up.
|
// Returns an empty string when the platform survived a full bring-up.
|
||||||
|
bool RemoteConnectRequested() {
|
||||||
|
const char* control = std::getenv("MOBILEGL_IPC_CONTROL");
|
||||||
|
return control != nullptr && std::strncmp(control, "tcp://", 6) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::string PreflightBringUp() {
|
std::string PreflightBringUp() {
|
||||||
|
// Connect already isolates driver setup in the server's session
|
||||||
|
// child. A local pre-flight would consume a remote session, then
|
||||||
|
// race its teardown and make the actual test receive Refuse{Busy}.
|
||||||
|
if (RemoteConnectRequested()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
#if !MGITEST_HAVE_FORK_PREFLIGHT
|
#if !MGITEST_HAVE_FORK_PREFLIGHT
|
||||||
// No fork(): let the in-process bring-up speak for itself, which is
|
// No fork(): let the in-process bring-up speak for itself, which is
|
||||||
// what this module did before. Windows/macOS are not CI targets for
|
// what this module did before. Windows/macOS are not CI targets for
|
||||||
@@ -585,7 +596,9 @@ namespace MGITest {
|
|||||||
// That is a real result, not a machine without a GPU, so say so: it
|
// That is a real result, not a machine without a GPU, so say so: it
|
||||||
// means something is different between the two attempts (a leaked
|
// means something is different between the two attempts (a leaked
|
||||||
// exclusive device, an environment the child did not have).
|
// exclusive device, an environment the child did not have).
|
||||||
m_skipReason = reason + " - although an identical bring-up in a forked pre-flight child succeeded";
|
m_skipReason = reason + (RemoteConnectRequested()
|
||||||
|
? " - remote TCP bring-up failed"
|
||||||
|
: " - although an identical bring-up in a forked pre-flight child succeeded");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
#if !defined(__ANDROID__)
|
#if !defined(__ANDROID__)
|
||||||
#include <MG_State/GLState/BufferState/BufferObject.h>
|
#include <MG_State/GLState/BufferState/BufferObject.h>
|
||||||
#include <MG_State/GLState/Core.h>
|
#include <MG_State/GLState/Core.h>
|
||||||
|
#include <MG_Util/Metrics/PipeStats.h>
|
||||||
|
#include <Config.h>
|
||||||
#define MGITEST_PERSISTENT_MAP_PEEK_LIVE 1
|
#define MGITEST_PERSISTENT_MAP_PEEK_LIVE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -27,6 +29,19 @@
|
|||||||
|
|
||||||
namespace MGITest {
|
namespace MGITest {
|
||||||
|
|
||||||
|
bool PeekSeparateClientMapStats(unsigned long long* acquisitions, unsigned long long* pushedBytes) {
|
||||||
|
#if defined(MGITEST_PERSISTENT_MAP_PEEK_LIVE) && MOBILEGL_BUILD_DISAGGREGATED && MOBILEGL_PIPE_PUSH
|
||||||
|
if (MobileGL::MG_Config::Transport != MobileGL::MG_Config::TransportMode::Spawn) return false;
|
||||||
|
namespace Stats = MobileGL::MG_Util::PipeStats;
|
||||||
|
*acquisitions = Stats::TotalCalls(Stats::CallClass::MapPersistentRoundtrips);
|
||||||
|
*pushedBytes = Stats::TotalBytes(Stats::ByteClass::PersistentMapPush);
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
(void)acquisitions; (void)pushedBytes;
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool PersistentMapPeekAvailable() {
|
bool PersistentMapPeekAvailable() {
|
||||||
#if defined(MGITEST_PERSISTENT_MAP_PEEK_LIVE)
|
#if defined(MGITEST_PERSISTENT_MAP_PEEK_LIVE)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -58,4 +58,8 @@ namespace MGITest {
|
|||||||
// Same contract as above: false means "could not look".
|
// Same contract as above: false means "could not look".
|
||||||
bool PeekBufferIsLivePersistentMap(unsigned int bufferName, bool* outLive);
|
bool PeekBufferIsLivePersistentMap(unsigned int bufferName, bool* outLive);
|
||||||
|
|
||||||
|
// Separate-process clients own these counters; the remote Present window
|
||||||
|
// belongs to the server and cannot report client map acquisitions or bytes.
|
||||||
|
bool PeekSeparateClientMapStats(unsigned long long* acquisitions, unsigned long long* pushedBytes);
|
||||||
|
|
||||||
} // namespace MGITest
|
} // namespace MGITest
|
||||||
|
|||||||
@@ -29,18 +29,64 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
extern "C" void MGPipeSyncPeerLog();
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace MGITest::PipeStatsWindow {
|
namespace MGITest::PipeStatsWindow {
|
||||||
|
|
||||||
// The lane's private log path, or empty when the lane configured none.
|
// P6: MOBILEGL_LOG_FILE_PATH IS A BASE NAME, NOT A FILE. The library writes one log per
|
||||||
inline std::string LibraryLogPath() {
|
// ROLE - `<stem>.client<ext>` and `<stem>.server<ext>` - because under inproc both roles are
|
||||||
const char* path = std::getenv("MOBILEGL_LOG_FILE_PATH");
|
// threads of one process and a single file made every per-side assertion a search.
|
||||||
return (path != nullptr && *path != '\0') ? std::string(path) : std::string();
|
//
|
||||||
|
// THE RULE IS COPIED HERE AND IT HAS TO BE, which is worth stating because the obvious fix is
|
||||||
|
// to call the library's own MG_Util::Debug::RoleLogPath and delete this. That does not link:
|
||||||
|
// this module links the SHIPPING libMobileGL.so, built -fvisibility=hidden, and the role-path
|
||||||
|
// helpers are `t` (local) in it - only MG_Test, which links the static archive, may call them.
|
||||||
|
//
|
||||||
|
// SO THE COPY IS FLAVOUR-AWARE INSTEAD. That is the part the first copy got wrong: it derived
|
||||||
|
// `.client` in BOTH flavours, while the pull build has one role and writes
|
||||||
|
// MOBILEGL_LOG_FILE_PATH unchanged. In the verify lane it therefore opened a file that never
|
||||||
|
// existed and every reader reported "the library never logged" - a product failure that had
|
||||||
|
// not happened. Keep this `#if` and Log.cpp's RoleLogPath in step.
|
||||||
|
inline std::string RoleLogPath(const char* roleSuffix) {
|
||||||
|
const char* base = std::getenv("MOBILEGL_LOG_FILE_PATH");
|
||||||
|
if (base == nullptr || *base == '\0') return {};
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
std::string path(base);
|
||||||
|
const std::string::size_type slash = path.find_last_of("/\\");
|
||||||
|
const std::string::size_type dot = path.find_last_of('.');
|
||||||
|
if (dot == std::string::npos || (slash != std::string::npos && dot < slash)) {
|
||||||
|
return path + "." + roleSuffix;
|
||||||
|
}
|
||||||
|
return path.substr(0, dot) + "." + roleSuffix + path.substr(dot);
|
||||||
|
#else
|
||||||
|
(void)roleSuffix;
|
||||||
|
return std::string(base);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// The lane's private CLIENT log path, or empty when the lane configured none. In the pull
|
||||||
|
// build this IS the whole log.
|
||||||
|
inline std::string LibraryLogPath() { return RoleLogPath("client"); }
|
||||||
|
|
||||||
|
// The server role's half, or EMPTY when this build has no separate server half. Empty rather
|
||||||
|
// than "the same path again": every caller below concatenates the two, and a pull build that
|
||||||
|
// named one file twice would show each line twice - which reads as a doubled counter or a
|
||||||
|
// repeated diagnostic rather than as a path mistake.
|
||||||
|
inline std::string ServerLibraryLogPath() {
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
return RoleLogPath("server");
|
||||||
|
#else
|
||||||
|
return {};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string ReadWholeFile(const std::string& path) {
|
inline std::string ReadWholeFile(const std::string& path) {
|
||||||
@@ -50,6 +96,57 @@ namespace MGITest::PipeStatsWindow {
|
|||||||
return std::string((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
return std::string((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string ReadFileSince(const std::string& path, std::uintmax_t offset) {
|
||||||
|
if (path.empty()) return {};
|
||||||
|
std::ifstream file(path, std::ios::binary);
|
||||||
|
if (!file.good()) return {};
|
||||||
|
file.seekg(static_cast<std::streamoff>(offset));
|
||||||
|
return std::string((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
||||||
|
}
|
||||||
|
|
||||||
|
// A "the log is this long right now" snapshot, ONE OFFSET PER ROLE.
|
||||||
|
//
|
||||||
|
// The scenarios that assert on arming take a mark before the workload and read what was
|
||||||
|
// appended after it, so that only bytes this case caused can satisfy - or refute - the claim.
|
||||||
|
// The roles are separate files, so this cannot be one scalar: a single offset applied to the
|
||||||
|
// concatenation would slide by however much the OTHER role happened to write, and the read
|
||||||
|
// would start mid-line in the wrong file.
|
||||||
|
struct LogMark {
|
||||||
|
std::uintmax_t client = 0;
|
||||||
|
std::uintmax_t server = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline std::uintmax_t FileSizeOrZero(const std::string& path) {
|
||||||
|
if (path.empty()) return 0;
|
||||||
|
std::ifstream file(path, std::ios::binary | std::ios::ate);
|
||||||
|
if (!file.good()) return 0;
|
||||||
|
const std::streamoff size = file.tellg();
|
||||||
|
return size < 0 ? 0 : static_cast<std::uintmax_t>(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline LogMark MarkLaneLog() {
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
MGPipeSyncPeerLog();
|
||||||
|
#endif
|
||||||
|
return LogMark{FileSizeOrZero(LibraryLogPath()), FileSizeOrZero(ServerLibraryLogPath())};
|
||||||
|
}
|
||||||
|
|
||||||
|
// BOTH ROLES, and for the arming diagnostics the SERVER's is the one that matters. Those lines
|
||||||
|
// are emitted by the BACKEND - "demoted to an ordinary varying", the reroute and emulation
|
||||||
|
// banners - and under inproc the backend runs on the apply thread, which is the server role.
|
||||||
|
// Reading only the client's half finds nothing and reports "the emulation is not armed",
|
||||||
|
// which is the most expensive possible way to be wrong: it accuses the product of a defect
|
||||||
|
// that the reader itself invented.
|
||||||
|
inline std::string ReadLaneLogSince(const LogMark& mark) {
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
MGPipeSyncPeerLog();
|
||||||
|
#endif
|
||||||
|
return ReadFileSince(LibraryLogPath(), mark.client)
|
||||||
|
+ ReadFileSince(ServerLibraryLogPath(), mark.server);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string ReadLaneLog() { return ReadLaneLogSince(LogMark{}); }
|
||||||
|
|
||||||
// The last summary line in the log, verbatim. `found` is false when the library never emitted
|
// The last summary line in the log, verbatim. `found` is false when the library never emitted
|
||||||
// one, which is a different failure from "the counter read zero" and has to be reported as
|
// one, which is a different failure from "the counter read zero" and has to be reported as
|
||||||
// one: it means the stats channel never reached the process, not that the workload did
|
// one: it means the stats channel never reached the process, not that the workload did
|
||||||
@@ -70,7 +167,15 @@ namespace MGITest::PipeStatsWindow {
|
|||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Window LastFromLaneLog() { return Last(ReadWholeFile(LibraryLogPath())); }
|
// BOTH ROLES, and the server's is where the numbers are. The `draws` / `vbs` counters
|
||||||
|
// increment in the backend's PrepareForDraw, which runs on the APPLY THREAD - the server
|
||||||
|
// role - so under inproc split the summary line lands in the server's log. Reading only the
|
||||||
|
// client's would find the "counters ON" banner (client-side) but no window, which reads as
|
||||||
|
// "the stats channel never reached the process". Concatenated, Last() takes whichever role
|
||||||
|
// emitted the final summary.
|
||||||
|
inline Window LastFromLaneLog() {
|
||||||
|
return Last(ReadLaneLog());
|
||||||
|
}
|
||||||
|
|
||||||
// One counter out of that line, by its short name ("mpr", "draws", "csom"), or -1 when the
|
// One counter out of that line, by its short name ("mpr", "draws", "csom"), or -1 when the
|
||||||
// line does not carry it. The search includes the SEPARATOR before the name and the `=` after
|
// line does not carry it. The search includes the SEPARATOR before the name and the `=` after
|
||||||
|
|||||||
@@ -23,7 +23,11 @@
|
|||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#if defined(__linux__)
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
@@ -152,6 +156,18 @@ namespace MGITest {
|
|||||||
RecordProperty("split_transport", state.transportName);
|
RecordProperty("split_transport", state.transportName);
|
||||||
RecordProperty("split_implemented_verbs", static_cast<int>(state.implementedVerbs));
|
RecordProperty("split_implemented_verbs", static_cast<int>(state.implementedVerbs));
|
||||||
RecordProperty("split_emit_seq_at_setup", static_cast<int>(state.emitSeq));
|
RecordProperty("split_emit_seq_at_setup", static_cast<int>(state.emitSeq));
|
||||||
|
#if defined(__linux__)
|
||||||
|
if (std::getenv("MGITEST_TCP_LANE")) {
|
||||||
|
// Connect must never silently launch a local server. The
|
||||||
|
// companion log gate proves the remote Welcome pid/endpoint.
|
||||||
|
std::ifstream children("/proc/self/task/" + std::to_string(::getpid()) + "/children");
|
||||||
|
ASSERT_TRUE(children.good()) << "TCP topology proof cannot read /proc children";
|
||||||
|
int child = 0;
|
||||||
|
ASSERT_FALSE(static_cast<bool>(children >> child))
|
||||||
|
<< "Dial=Connect created a local server child: " << child;
|
||||||
|
RecordProperty("tcp_local_children", 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
// A scenario starts from a clean slate but shares the context (and so
|
// A scenario starts from a clean slate but shares the context (and so
|
||||||
// the renderer's memos) with every other scenario in this process -
|
// the renderer's memos) with every other scenario in this process -
|
||||||
|
|||||||
@@ -8,10 +8,28 @@ file(MAKE_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/split-logs")
|
|||||||
# the caps bit, and a shared log file is a marker nobody can attribute.
|
# the caps bit, and a shared log file is a marker nobody can attribute.
|
||||||
# P5e pa's strict lane joins it for the same reason as vi's: its four entries exist to CARRY a
|
# P5e pa's strict lane joins it for the same reason as vi's: its four entries exist to CARRY a
|
||||||
# Fatal marker (the two program rows), and a shared log file is a marker nobody can attribute.
|
# Fatal marker (the two program rows), and a shared log file is a marker nobody can attribute.
|
||||||
foreach(entry IN LISTS MGL_SPLIT_CLEAR_TESTS MGL_SPLIT_TRIANGLE_TESTS MGL_SPLIT_PMAP_TESTS
|
# P6 `t6`: ONE LIST FOR EVERY ENTRY THE SHARED REGISTRATION MACRO EMITS, on BOTH arms. The
|
||||||
MGL_SPLIT_T2_TESS_TESTS MGL_SPLIT_T2_XFB_TESTS MGL_SPLIT_SYNC_TESTS
|
# per-block TEST_LIST variables this replaces were a list somebody had to remember to extend;
|
||||||
MGL_SPLIT_VI_CLIENT_ARRAY_TESTS
|
# a block added without its variable got no private log and nothing said so until
|
||||||
MGL_SPLIT_PA_STRICT_DRAW_TESTS MGL_SPLIT_PA_STRICT_DISPATCH_TESTS)
|
# PrivateAndDistinct happened to notice. The macro accumulates instead.
|
||||||
|
# The macro's per-call lists, walked by NAME: gtest_discover_tests populates each of them when
|
||||||
|
# ctest runs, which is also when this file is included.
|
||||||
|
foreach(listName IN ITEMS @MGL_SPLIT_ARM_TEST_LISTS@)
|
||||||
|
foreach(entry IN LISTS ${listName})
|
||||||
|
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||||
|
"MOBILEGL_LOG_FILE_PATH=@CMAKE_CURRENT_BINARY_DIR@/split-logs/${entry}.log")
|
||||||
|
if(entry MATCHES "TriangleScenario.TheServerStampedAVerbBoundaryOnThisDrawingFrame$")
|
||||||
|
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||||
|
"MGITEST_STRICT_ARMING_LANE=1;MOBILEGL_PIPE_STATS=1;MOBILEGL_PIPE_STATS_PERIOD=1")
|
||||||
|
elseif(entry MATCHES "PersistentCoherentMapScenario.TheMapLandsInTheArmItsLaneDeclares$")
|
||||||
|
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||||
|
"MGITEST_PMAP_LANE=1;MGITEST_PERSISTENT_MAP_ARM=emulated;MOBILEGL_PIPE_STATS=1;MOBILEGL_PIPE_STATS_PERIOD=1")
|
||||||
|
elseif(entry MATCHES "CtWireScenario\\.")
|
||||||
|
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT "MOBILEGL_TEST_SERVER_COUNTERS=1")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
foreach(entry IN LISTS MGL_SPLIT_PA_STRICT_DRAW_TESTS MGL_SPLIT_PA_STRICT_DISPATCH_TESTS)
|
||||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||||
"MOBILEGL_LOG_FILE_PATH=@CMAKE_CURRENT_BINARY_DIR@/split-logs/${entry}.log")
|
"MOBILEGL_LOG_FILE_PATH=@CMAKE_CURRENT_BINARY_DIR@/split-logs/${entry}.log")
|
||||||
endforeach()
|
endforeach()
|
||||||
@@ -19,15 +37,16 @@ foreach(scenario @MGL_SPLIT_SMALL_RING_SCENARIOS@)
|
|||||||
foreach(entry IN LISTS MGL_SPLIT_SMALL_${scenario}_TESTS)
|
foreach(entry IN LISTS MGL_SPLIT_SMALL_${scenario}_TESTS)
|
||||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||||
"MOBILEGL_LOG_FILE_PATH=@CMAKE_CURRENT_BINARY_DIR@/split-logs/${entry}.log")
|
"MOBILEGL_LOG_FILE_PATH=@CMAKE_CURRENT_BINARY_DIR@/split-logs/${entry}.log")
|
||||||
|
if(entry MATCHES "TriangleScenario.TheServerStampedAVerbBoundaryOnThisDrawingFrame$")
|
||||||
|
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||||
|
"MGITEST_STRICT_ARMING_LANE=1;MOBILEGL_PIPE_STATS=1;MOBILEGL_PIPE_STATS_PERIOD=1")
|
||||||
|
elseif(entry MATCHES "PersistentCoherentMapScenario.TheMapLandsInTheArmItsLaneDeclares$")
|
||||||
|
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||||
|
"MGITEST_PMAP_LANE=1;MGITEST_PERSISTENT_MAP_ARM=emulated;MOBILEGL_PIPE_STATS=1;MOBILEGL_PIPE_STATS_PERIOD=1")
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endforeach()
|
endforeach()
|
||||||
# P5b d1's split entries: the same private, distinct log per entry.
|
# d1's entries are covered by MGL_SPLIT_ARM_TESTS above (P6 `t6`).
|
||||||
foreach(scenario @MGL_SPLIT_D1_SCENARIOS@)
|
|
||||||
foreach(entry IN LISTS MGL_SPLIT_D1_${scenario}_TESTS)
|
|
||||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
|
||||||
"MOBILEGL_LOG_FILE_PATH=@CMAKE_CURRENT_BINARY_DIR@/split-logs/${entry}.log")
|
|
||||||
endforeach()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# P5e mv's five tier-pinned lanes, the same rule for the same reason - and here it also repairs
|
# P5e mv's five tier-pinned lanes, the same rule for the same reason - and here it also repairs
|
||||||
# the addendum §4 blind spot for them: these entries carry a third name segment, so the strict
|
# the addendum §4 blind spot for them: these entries carry a third name segment, so the strict
|
||||||
@@ -43,7 +62,9 @@ endforeach()
|
|||||||
# P5b package i1's four scenarios, the same shape as the small-ring loop above: every
|
# P5b package i1's four scenarios, the same shape as the small-ring loop above: every
|
||||||
# DirectGLES.Split. entry owns exactly one absolute log path and shares it with nobody, which
|
# DirectGLES.Split. entry owns exactly one absolute log path and shares it with nobody, which
|
||||||
# is what SplitLogPaths.PrivateAndDistinct checks over the discovered set.
|
# is what SplitLogPaths.PrivateAndDistinct checks over the discovered set.
|
||||||
foreach(scenario @MGL_SPLIT_I1_SCENARIOS@)
|
# i1's entries are covered by MGL_SPLIT_ARM_TESTS above (P6 `t6`); the loop is kept as a no-op
|
||||||
|
# shell only so the surrounding prose still reads against a structure.
|
||||||
|
foreach(scenario "")
|
||||||
foreach(entry IN LISTS MGL_SPLIT_I1_${scenario}_TESTS)
|
foreach(entry IN LISTS MGL_SPLIT_I1_${scenario}_TESTS)
|
||||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||||
"MOBILEGL_LOG_FILE_PATH=@CMAKE_CURRENT_BINARY_DIR@/split-logs/${entry}.log")
|
"MOBILEGL_LOG_FILE_PATH=@CMAKE_CURRENT_BINARY_DIR@/split-logs/${entry}.log")
|
||||||
|
|||||||
@@ -96,10 +96,10 @@ namespace MGITest {
|
|||||||
if (!control) return false;
|
if (!control) return false;
|
||||||
const auto until = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeoutMs);
|
const auto until = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeoutMs);
|
||||||
do {
|
do {
|
||||||
if (control->appliedSeq.load(std::memory_order_acquire) >= seq) return true;
|
if (control->Progress.appliedSeq.load(std::memory_order_acquire) >= seq) return true;
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||||
} while (std::chrono::steady_clock::now() < until);
|
} while (std::chrono::steady_clock::now() < until);
|
||||||
return control->appliedSeq.load(std::memory_order_acquire) >= seq;
|
return control->Progress.appliedSeq.load(std::memory_order_acquire) >= seq;
|
||||||
#else
|
#else
|
||||||
(void)seq; (void)timeoutMs;
|
(void)seq; (void)timeoutMs;
|
||||||
return false;
|
return false;
|
||||||
@@ -143,9 +143,9 @@ namespace MGITest {
|
|||||||
state.presentCredit = MobileGL::MG_Config::Ipc.PresentCredit;
|
state.presentCredit = MobileGL::MG_Config::Ipc.PresentCredit;
|
||||||
state.presentCreditWaits = session->PresentCreditWaits();
|
state.presentCreditWaits = session->PresentCreditWaits();
|
||||||
if (const auto* control = session->Control()) {
|
if (const auto* control = session->Control()) {
|
||||||
state.appliedSeq = control->appliedSeq.load(std::memory_order_acquire);
|
state.appliedSeq = control->Progress.appliedSeq.load(std::memory_order_acquire);
|
||||||
state.retiredSeq = control->retiredSeq.load(std::memory_order_acquire);
|
state.retiredSeq = control->Progress.retiredSeq.load(std::memory_order_acquire);
|
||||||
state.presentAckSerial = control->presentAckSerial.load(std::memory_order_acquire);
|
state.presentAckSerial = control->Progress.presentAckSerial.load(std::memory_order_acquire);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The producer's ledger. Every one of these is a plain member read on the encoder
|
// The producer's ledger. Every one of these is a plain member read on the encoder
|
||||||
|
|||||||
@@ -9,6 +9,38 @@ import sys
|
|||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
|
||||||
|
# P6: THE SINK WRITES ONE FILE PER ROLE, so MOBILEGL_LOG_FILE_PATH is a BASE NAME and no file
|
||||||
|
# of that literal name exists. The derivation matches MG_Util/Debug/Log.cpp's RoleLogPath: the
|
||||||
|
# role goes before the extension. A census that read the base would find nothing and report a
|
||||||
|
# confident zero for every marker the run actually raised - which under split is most of them,
|
||||||
|
# because the applier's refusals are on the server side.
|
||||||
|
def role_paths(base):
|
||||||
|
text = str(base)
|
||||||
|
slash = max(text.rfind("/"), text.rfind("\\"))
|
||||||
|
dot = text.rfind(".")
|
||||||
|
out = []
|
||||||
|
for role in ("client", "server"):
|
||||||
|
if dot == -1 or dot < slash:
|
||||||
|
out.append(text + "." + role)
|
||||||
|
else:
|
||||||
|
out.append(text[:dot] + "." + role + text[dot:])
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def read_role_logs(base):
|
||||||
|
"""Concatenated text of every role file that exists for this base, or '' if none do."""
|
||||||
|
chunks = []
|
||||||
|
for path in role_paths(base):
|
||||||
|
p = Path(path)
|
||||||
|
if p.is_file():
|
||||||
|
chunks.append(p.read_text(errors="replace"))
|
||||||
|
return "".join(chunks)
|
||||||
|
|
||||||
|
|
||||||
|
def any_role_file(base):
|
||||||
|
return any(Path(p).is_file() for p in role_paths(base))
|
||||||
|
|
||||||
|
|
||||||
def paths(document):
|
def paths(document):
|
||||||
owners = {}
|
owners = {}
|
||||||
split = {}
|
split = {}
|
||||||
@@ -16,7 +48,8 @@ def paths(document):
|
|||||||
props = {p["name"]: p["value"] for p in test.get("properties", [])}
|
props = {p["name"]: p["value"] for p in test.get("properties", [])}
|
||||||
values = [v.split("=", 1)[1] for v in props.get("ENVIRONMENT", [])
|
values = [v.split("=", 1)[1] for v in props.get("ENVIRONMENT", [])
|
||||||
if v.startswith("MOBILEGL_LOG_FILE_PATH=")]
|
if v.startswith("MOBILEGL_LOG_FILE_PATH=")]
|
||||||
is_split = test["name"].startswith(("DirectGLES.Split.", "DirectVulkan.Split."))
|
is_split = test["name"].startswith(("DirectGLES.Split.", "DirectVulkan.Split.",
|
||||||
|
"DirectGLES.Spawn.", "DirectGLES.Tcp.", "DirectGLES.TcpDevice."))
|
||||||
if is_split and (len(values) != 1 or not values[0]):
|
if is_split and (len(values) != 1 or not values[0]):
|
||||||
raise ValueError(f"{test['name']}: requires exactly one nonempty MOBILEGL_LOG_FILE_PATH")
|
raise ValueError(f"{test['name']}: requires exactly one nonempty MOBILEGL_LOG_FILE_PATH")
|
||||||
for value in values:
|
for value in values:
|
||||||
@@ -89,10 +122,10 @@ def classify_markers(logs):
|
|||||||
scanned = []
|
scanned = []
|
||||||
for name in sorted(logs):
|
for name in sorted(logs):
|
||||||
path = logs[name]
|
path = logs[name]
|
||||||
if not Path(path).is_file():
|
if not any_role_file(path):
|
||||||
continue
|
continue
|
||||||
scanned.append(name)
|
scanned.append(name)
|
||||||
text = Path(path).read_text(errors="replace")
|
text = read_role_logs(path)
|
||||||
for tag, field, verb, why in MARKER_RE.findall(text):
|
for tag, field, verb, why in MARKER_RE.findall(text):
|
||||||
pair = f"{field}@{verb}"
|
pair = f"{field}@{verb}"
|
||||||
if tag == "Fatal":
|
if tag == "Fatal":
|
||||||
@@ -204,12 +237,12 @@ def expect_fatal(document, junit_path, expected_path):
|
|||||||
if failed:
|
if failed:
|
||||||
problems.append(f"{name} is RED and declares no private log")
|
problems.append(f"{name} is RED and declares no private log")
|
||||||
continue # metadata/monolith-arm entries have no marker channel
|
continue # metadata/monolith-arm entries have no marker channel
|
||||||
if not Path(path).is_file():
|
if not any_role_file(path):
|
||||||
problems.append(f"{name}: declared private log {path} does not exist")
|
problems.append(f"{name}: declared private log {path} has no role file (.client/.server)")
|
||||||
continue
|
continue
|
||||||
scanned += 1
|
scanned += 1
|
||||||
entry_fatal = set()
|
entry_fatal = set()
|
||||||
for tag, field, verb, why in MARKER_RE.findall(Path(path).read_text(errors="replace")):
|
for tag, field, verb, why in MARKER_RE.findall(read_role_logs(path)):
|
||||||
pair = f"{field}@{verb}"
|
pair = f"{field}@{verb}"
|
||||||
if tag == "Fatal":
|
if tag == "Fatal":
|
||||||
entry_fatal.add(pair)
|
entry_fatal.add(pair)
|
||||||
@@ -380,7 +413,7 @@ def main():
|
|||||||
missing = []
|
missing = []
|
||||||
label = sys.argv[5] if len(sys.argv) > 5 else ""
|
label = sys.argv[5] if len(sys.argv) > 5 else ""
|
||||||
for name, path in selected.items():
|
for name, path in selected.items():
|
||||||
if Path(path).is_file() and re.search(sys.argv[4], Path(path).read_text(errors="replace")):
|
if any_role_file(path) and re.search(sys.argv[4], read_role_logs(path)):
|
||||||
print(f"private-log evidence: {name}: {path}")
|
print(f"private-log evidence: {name}: {path}")
|
||||||
else:
|
else:
|
||||||
missing.append(f"{name} ({path})")
|
missing.append(f"{name} ({path})")
|
||||||
|
|||||||
@@ -31,12 +31,15 @@ class ResultAccountingTest(unittest.TestCase):
|
|||||||
self.temp.cleanup()
|
self.temp.cleanup()
|
||||||
|
|
||||||
def discovery(self, names):
|
def discovery(self, names):
|
||||||
|
# P6: the ENV path is a BASE NAME and the library writes <base>.client.log /
|
||||||
|
# <base>.server.log. The fixture writes the CLIENT role file - what a real run leaves on
|
||||||
|
# disk - while the XML carries the base, exactly as the lane does.
|
||||||
tests = []
|
tests = []
|
||||||
for i, name in enumerate(names):
|
for i, name in enumerate(names):
|
||||||
log = self.root / (str(i) + ".log")
|
base = self.root / (str(i) + ".log")
|
||||||
log.write_text("")
|
(self.root / (str(i) + ".client.log")).write_text("")
|
||||||
tests.append({"name": name, "properties": [{"name": "ENVIRONMENT", "value": [
|
tests.append({"name": name, "properties": [{"name": "ENVIRONMENT", "value": [
|
||||||
"MOBILEGL_LOG_FILE_PATH=" + str(log)]}]})
|
"MOBILEGL_LOG_FILE_PATH=" + str(base)]}]})
|
||||||
return {"tests": tests}
|
return {"tests": tests}
|
||||||
|
|
||||||
def results(self, rows):
|
def results(self, rows):
|
||||||
@@ -97,7 +100,7 @@ class ResultAccountingTest(unittest.TestCase):
|
|||||||
def test_admitted_or_fatal_on_passed_case_is_not_hidden(self):
|
def test_admitted_or_fatal_on_passed_case_is_not_hidden(self):
|
||||||
for marker in ['Admitted{UnmigratedPipeInput, "GetProgramObject@Clear"}',
|
for marker in ['Admitted{UnmigratedPipeInput, "GetProgramObject@Clear"}',
|
||||||
'Fatal{UnmigratedPipeInput, "GetProgramObject@Clear"}']:
|
'Fatal{UnmigratedPipeInput, "GetProgramObject@Clear"}']:
|
||||||
(self.root / "0.log").write_text(marker)
|
(self.root / "0.client.log").write_text(marker)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
self.census()
|
self.census()
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../Harness/PipeStatsWindow.h"
|
||||||
#include "../Harness/HeadlessGL.h"
|
#include "../Harness/HeadlessGL.h"
|
||||||
#include "../Harness/ScenarioFixture.h"
|
#include "../Harness/ScenarioFixture.h"
|
||||||
|
|
||||||
@@ -124,8 +125,9 @@ void main() { oColor = vec4(0.0, 1.0, 0.0, 1.0); }
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string LibraryLogPath() {
|
std::string LibraryLogPath() {
|
||||||
const char* path = std::getenv("MOBILEGL_LOG_FILE_PATH");
|
// P6: the path is a BASE NAME and the library writes one log per role; PipeStatsWindow
|
||||||
return (path != nullptr && *path != '\0') ? std::string(path) : std::string();
|
// derives the suffix, so the rule lives in one place.
|
||||||
|
return MGITest::PipeStatsWindow::LibraryLogPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ReadWholeFile(const std::string& path) {
|
std::string ReadWholeFile(const std::string& path) {
|
||||||
|
|||||||
@@ -25,10 +25,12 @@
|
|||||||
// half of that control is TheDirectApplierResetCallOnTheGLThreadIsRoleViolation below, and
|
// half of that control is TheDirectApplierResetCallOnTheGLThreadIsRoleViolation below, and
|
||||||
// the guard's two non-Fatal arms are pinned in PipeWireCodecTest's CtWireFatals suite.
|
// the guard's two non-Fatal arms are pinned in PipeWireCodecTest's CtWireFatals suite.
|
||||||
|
|
||||||
|
#include "../Harness/PipeStatsWindow.h"
|
||||||
#include "../Harness/ScenarioFixture.h"
|
#include "../Harness/ScenarioFixture.h"
|
||||||
#include "../Harness/SplitRuntimePeek.h"
|
#include "../Harness/SplitRuntimePeek.h"
|
||||||
|
|
||||||
#include <MG_Pipe/PipeApply.h>
|
#include <MG_Pipe/PipeApply.h>
|
||||||
|
#include <Config.h> // `t6`: the spawn arm cannot observe the server process's counters
|
||||||
#include <MG_Remote/Server/ServerSession.h>
|
#include <MG_Remote/Server/ServerSession.h>
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
@@ -53,6 +55,32 @@ namespace {
|
|||||||
return MobileGL::MG_Remote::Server::ServerSessionInstance().Applier().Verbs();
|
return MobileGL::MG_Remote::Server::ServerSessionInstance().Applier().Verbs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inproc reads its local sink. A separate-process session snapshots that
|
||||||
|
// same sink on LogFlush, after the client fences its complete command prefix.
|
||||||
|
// TCP forwards the server log; unix+shm reads the server's local role file.
|
||||||
|
struct CounterSnapshot {
|
||||||
|
bool valid = false;
|
||||||
|
MobileGL::Uint64 resets = 0, serial = 0, deaths = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
CounterSnapshot ServerCounters() {
|
||||||
|
if (MobileGL::MG_Config::Transport != MobileGL::MG_Config::TransportMode::Spawn) {
|
||||||
|
return {true, ServerVerbs().ApplierResets(), ServerVerbs().ExpectedApplierResetSerial(),
|
||||||
|
ServerVerbs().ObjectDeaths()};
|
||||||
|
}
|
||||||
|
MGPipeSyncPeerLog();
|
||||||
|
const std::string log = PipeStatsWindow::ReadWholeFile(PipeStatsWindow::ServerLibraryLogPath());
|
||||||
|
const auto at = log.rfind("MGPipe server counters:");
|
||||||
|
if (at == std::string::npos) return {};
|
||||||
|
const PipeStatsWindow::Window window{true, log.substr(at, log.find('\n', at) - at)};
|
||||||
|
const auto resets = PipeStatsWindow::CounterOrAbsent(window, "resets");
|
||||||
|
const auto serial = PipeStatsWindow::CounterOrAbsent(window, "reset-serial");
|
||||||
|
const auto deaths = PipeStatsWindow::CounterOrAbsent(window, "deaths");
|
||||||
|
if (resets < 0 || serial < 0 || deaths < 0) return {};
|
||||||
|
return {true, static_cast<MobileGL::Uint64>(resets), static_cast<MobileGL::Uint64>(serial),
|
||||||
|
static_cast<MobileGL::Uint64>(deaths)};
|
||||||
|
}
|
||||||
|
|
||||||
class CtWireScenario : public ScenarioTest {
|
class CtWireScenario : public ScenarioTest {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
@@ -99,13 +127,15 @@ namespace {
|
|||||||
// (here and in the fixture's emit-ordinal rule).
|
// (here and in the fixture's emit-ordinal rule).
|
||||||
glClearColor(0.2f, 0.4f, 0.6f, 1.0f);
|
glClearColor(0.2f, 0.4f, 0.6f, 1.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
EXPECT_GE(ServerVerbs().ApplierResets(), 1u)
|
const auto counters = ServerCounters();
|
||||||
|
ASSERT_TRUE(counters.valid) << "server control-record telemetry missing";
|
||||||
|
EXPECT_GE(counters.resets, 1u)
|
||||||
<< "the FreshlyPrimed edge emitted no applier_reset; the server's g_applier was "
|
<< "the FreshlyPrimed edge emitted no applier_reset; the server's g_applier was "
|
||||||
"never reset for this session";
|
"never reset for this session";
|
||||||
// The serial sequence is the session's own count (§1: asserted, never dispatched
|
// The serial sequence is the session's own count (§1: asserted, never dispatched
|
||||||
// on): every record the sink accepted carried the serial it expected, or the counter
|
// on): every record the sink accepted carried the serial it expected, or the counter
|
||||||
// and the accepted tally would disagree.
|
// and the accepted tally would disagree.
|
||||||
EXPECT_EQ(ServerVerbs().ExpectedApplierResetSerial(), ServerVerbs().ApplierResets())
|
EXPECT_EQ(counters.serial, counters.resets)
|
||||||
<< "an applier_reset record was dropped or replayed on the wire";
|
<< "an applier_reset record was dropped or replayed on the wire";
|
||||||
|
|
||||||
GLubyte pixel[4]{};
|
GLubyte pixel[4]{};
|
||||||
@@ -141,7 +171,9 @@ namespace {
|
|||||||
// The object dies unbound so the destructor - and the death record - fire at the
|
// The object dies unbound so the destructor - and the death record - fire at the
|
||||||
// delete, and the tally is read AFTER the EmitAndWait the delete blocked on.
|
// delete, and the tally is read AFTER the EmitAndWait the delete blocked on.
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
const MobileGL::Uint64 deathsBefore = ServerVerbs().ObjectDeaths();
|
const auto beforeCounters = ServerCounters();
|
||||||
|
ASSERT_TRUE(beforeCounters.valid) << "server object-death telemetry missing";
|
||||||
|
const MobileGL::Uint64 deathsBefore = beforeCounters.deaths;
|
||||||
glDeleteTextures(1, &texture);
|
glDeleteTextures(1, &texture);
|
||||||
// THE FENCE, the framebuffer case's exactly (MOBILEGL_IPC_BATCH_WAITS, default on):
|
// THE FENCE, the framebuffer case's exactly (MOBILEGL_IPC_BATCH_WAITS, default on):
|
||||||
// object_death is a kCtxObject value-class record, published WITHOUT waiting for its
|
// object_death is a kCtxObject value-class record, published WITHOUT waiting for its
|
||||||
@@ -150,7 +182,9 @@ namespace {
|
|||||||
// clock-free spin changed that timing, then failed 1 in 5. A clear is kCtxVerb and
|
// clock-free spin changed that timing, then failed 1 in 5. A clear is kCtxVerb and
|
||||||
// still waits, and its wait covers the death.
|
// still waits, and its wait covers the death.
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
EXPECT_GT(ServerVerbs().ObjectDeaths(), deathsBefore)
|
const auto afterCounters = ServerCounters();
|
||||||
|
ASSERT_TRUE(afterCounters.valid) << "server object-death telemetry missing";
|
||||||
|
EXPECT_GT(afterCounters.deaths, deathsBefore)
|
||||||
<< "the texture's death produced no object_death record; the server's twin was "
|
<< "the texture's death produced no object_death record; the server's twin was "
|
||||||
"never told to let go";
|
"never told to let go";
|
||||||
|
|
||||||
@@ -197,7 +231,9 @@ namespace {
|
|||||||
// Die unbound, framebuffer first so the attachment's own death is a separate record.
|
// Die unbound, framebuffer first so the attachment's own death is a separate record.
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||||
const MobileGL::Uint64 deathsBefore = ServerVerbs().ObjectDeaths();
|
const auto beforeCounters = ServerCounters();
|
||||||
|
ASSERT_TRUE(beforeCounters.valid) << "server object-death telemetry missing";
|
||||||
|
const MobileGL::Uint64 deathsBefore = beforeCounters.deaths;
|
||||||
glDeleteFramebuffers(1, &fbo);
|
glDeleteFramebuffers(1, &fbo);
|
||||||
// THE FENCE (MOBILEGL_IPC_BATCH_WAITS, default on): object_death is a kCtxObject
|
// THE FENCE (MOBILEGL_IPC_BATCH_WAITS, default on): object_death is a kCtxObject
|
||||||
// value-class record - published WITHOUT waiting for its own apply (production-safe:
|
// value-class record - published WITHOUT waiting for its own apply (production-safe:
|
||||||
@@ -205,7 +241,9 @@ namespace {
|
|||||||
// server-side counter this assertion reads only moves at apply time, so it needs a
|
// server-side counter this assertion reads only moves at apply time, so it needs a
|
||||||
// wait boundary: a clear is kCtxVerb and still waits, and its wait covers the death.
|
// wait boundary: a clear is kCtxVerb and still waits, and its wait covers the death.
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
EXPECT_GT(ServerVerbs().ObjectDeaths(), deathsBefore)
|
const auto afterCounters = ServerCounters();
|
||||||
|
ASSERT_TRUE(afterCounters.valid) << "server object-death telemetry missing";
|
||||||
|
EXPECT_GT(afterCounters.deaths, deathsBefore)
|
||||||
<< "the framebuffer's death produced no object_death record - and no other "
|
<< "the framebuffer's death produced no object_death record - and no other "
|
||||||
"opcode can carry it";
|
"opcode can carry it";
|
||||||
glDeleteRenderbuffers(1, &renderbuffer);
|
glDeleteRenderbuffers(1, &renderbuffer);
|
||||||
@@ -255,7 +293,10 @@ namespace {
|
|||||||
// same); the NAME is asserted from the log below, which the child truncated and
|
// same); the NAME is asserted from the log below, which the child truncated and
|
||||||
// wrote before it died.
|
// wrote before it died.
|
||||||
EXPECT_EXIT(MobileGL::MG_Pipe::MGPipeApplierReset(), ::testing::KilledBySignal(SIGABRT), ".*");
|
EXPECT_EXIT(MobileGL::MG_Pipe::MGPipeApplierReset(), ::testing::KilledBySignal(SIGABRT), ".*");
|
||||||
if (const char* logPath = std::getenv("MOBILEGL_LOG_FILE_PATH"); logPath != nullptr) {
|
// THE CLIENT'S LOG: MGPipeApplierReset is called here, on the GL thread, so the guard's
|
||||||
|
// line is written under the client role. P6 splits the lane's log per role and the
|
||||||
|
// suffix rule lives in PipeStatsWindow.
|
||||||
|
if (const std::string logPath = MGITest::PipeStatsWindow::LibraryLogPath(); !logPath.empty()) {
|
||||||
std::ifstream in(logPath, std::ios::binary);
|
std::ifstream in(logPath, std::ios::binary);
|
||||||
std::ostringstream log;
|
std::ostringstream log;
|
||||||
log << in.rdbuf();
|
log << in.rdbuf();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
// proves nothing if no case can tell one block from two, so this scenario asserts exactly that,
|
// proves nothing if no case can tell one block from two, so this scenario asserts exactly that,
|
||||||
// from inside the process:
|
// from inside the process:
|
||||||
//
|
//
|
||||||
// 1. MGPipeRoleSplitActive() - the knob is armed AND the transport is real;
|
// 1. MGPipeRoleSplitRehearsalActive() - the knob is armed AND the transport is real;
|
||||||
// 2. &MGPipeClientInputs() != &gPipeInputs - two distinct objects;
|
// 2. &MGPipeClientInputs() != &gPipeInputs - two distinct objects;
|
||||||
// 3. a client verb boundary moves the CLIENT block's serial and leaves the SERVER block's
|
// 3. a client verb boundary moves the CLIENT block's serial and leaves the SERVER block's
|
||||||
// serial alone - the fill side's writes no longer reach the read side.
|
// serial alone - the fill side's writes no longer reach the read side.
|
||||||
@@ -61,7 +61,7 @@ TEST_F(DualBlockScenario, TheTwoRolesHaveDistinctBlocks) {
|
|||||||
<< "the dual-block peek is compiled out: this entry is only ever registered in a "
|
<< "the dual-block peek is compiled out: this entry is only ever registered in a "
|
||||||
"disaggregated build, so a false here means the registration and the build disagree";
|
"disaggregated build, so a false here means the registration and the build disagree";
|
||||||
ASSERT_TRUE(before.roleSplitActive)
|
ASSERT_TRUE(before.roleSplitActive)
|
||||||
<< "dual-block control: MGPipeRoleSplitActive() is false - MOBILEGL_IPC_ROLE_SPLIT_STATE "
|
<< "dual-block control: MGPipeRoleSplitRehearsalActive() is false - MOBILEGL_IPC_ROLE_SPLIT_STATE "
|
||||||
"is not armed in this process (or the transport is monolith), so the two roles share "
|
"is not armed in this process (or the transport is monolith), so the two roles share "
|
||||||
"one PipeInputs block and this case is the knob's negative control";
|
"one PipeInputs block and this case is the knob's negative control";
|
||||||
EXPECT_TRUE(before.blocksDistinct)
|
EXPECT_TRUE(before.blocksDistinct)
|
||||||
|
|||||||
@@ -466,6 +466,8 @@ void main() { oColor = vec4(vColor, 1.0); }
|
|||||||
}
|
}
|
||||||
|
|
||||||
Gl().EndFrame(); // close the setup window; SetUp's own store and map go in it
|
Gl().EndFrame(); // close the setup window; SetUp's own store and map go in it
|
||||||
|
unsigned long long acquisitionsBefore = 0, pushedBefore = 0;
|
||||||
|
const bool separateClientStats = PeekSeparateClientMapStats(&acquisitionsBefore, &pushedBefore);
|
||||||
|
|
||||||
// One acquisition inside the counted window: one fresh immutable store, mapped once.
|
// One acquisition inside the counted window: one fresh immutable store, mapped once.
|
||||||
const CoherentStore store = MakeCoherentlyMappedQuadStore();
|
const CoherentStore store = MakeCoherentlyMappedQuadStore();
|
||||||
@@ -500,7 +502,16 @@ void main() { oColor = vec4(vColor, 1.0); }
|
|||||||
"not reach the process, or nothing reached PipeStats::OnPresent.";
|
"not reach the process, or nothing reached PipeStats::OnPresent.";
|
||||||
RecordProperty("stats_line", window.line.c_str());
|
RecordProperty("stats_line", window.line.c_str());
|
||||||
|
|
||||||
const long long roundtrips = PipeStatsWindow::CounterOrAbsent(window, "mpr");
|
unsigned long long acquisitionsAfter = 0, pushedAfter = 0;
|
||||||
|
if (separateClientStats) {
|
||||||
|
ASSERT_TRUE(PeekSeparateClientMapStats(&acquisitionsAfter, &pushedAfter));
|
||||||
|
ASSERT_GE(acquisitionsAfter, acquisitionsBefore);
|
||||||
|
ASSERT_GE(pushedAfter, pushedBefore);
|
||||||
|
RecordProperty("stats_counter_owner", "client process totals over the counted workload");
|
||||||
|
}
|
||||||
|
const long long roundtrips = separateClientStats
|
||||||
|
? static_cast<long long>(acquisitionsAfter - acquisitionsBefore)
|
||||||
|
: PipeStatsWindow::CounterOrAbsent(window, "mpr");
|
||||||
ASSERT_GE(roundtrips, 0) << "the summary line carries no mpr= field: " << window.line;
|
ASSERT_GE(roundtrips, 0) << "the summary line carries no mpr= field: " << window.line;
|
||||||
EXPECT_EQ(roundtrips, kExpectedRoundtrips)
|
EXPECT_EQ(roundtrips, kExpectedRoundtrips)
|
||||||
<< "one PERSISTENT|WRITE|COHERENT map of one freshly defined store is ONE acquisition "
|
<< "one PERSISTENT|WRITE|COHERENT map of one freshly defined store is ONE acquisition "
|
||||||
@@ -523,7 +534,9 @@ void main() { oColor = vec4(vColor, 1.0); }
|
|||||||
// cross-check. Deriving the arm from pmap would have made "the push was never wired" and
|
// cross-check. Deriving the arm from pmap would have made "the push was never wired" and
|
||||||
// "the store was adopted" the same reading, and they are different defects with different
|
// "the store was adopted" the same reading, and they are different defects with different
|
||||||
// owners.
|
// owners.
|
||||||
const double pushedBytes = PipeStatsWindow::CounterAsDoubleOrAbsent(window, "pmap");
|
const double pushedBytes = separateClientStats
|
||||||
|
? static_cast<double>(pushedAfter - pushedBefore)
|
||||||
|
: PipeStatsWindow::CounterAsDoubleOrAbsent(window, "pmap");
|
||||||
ASSERT_GE(pushedBytes, 0.0) << "the summary line carries no pmap= field: " << window.line;
|
ASSERT_GE(pushedBytes, 0.0) << "the summary line carries no pmap= field: " << window.line;
|
||||||
RecordProperty("persistent_map_push_bytes_per_frame", std::to_string(pushedBytes).c_str());
|
RecordProperty("persistent_map_push_bytes_per_frame", std::to_string(pushedBytes).c_str());
|
||||||
RecordProperty("map_persistent_roundtrips", std::to_string(roundtrips).c_str());
|
RecordProperty("map_persistent_roundtrips", std::to_string(roundtrips).c_str());
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "../Harness/PipeStatsWindow.h"
|
||||||
#include "../Harness/HeadlessGL.h"
|
#include "../Harness/HeadlessGL.h"
|
||||||
#include "../Harness/ScenarioFixture.h"
|
#include "../Harness/ScenarioFixture.h"
|
||||||
|
|
||||||
@@ -105,29 +106,28 @@ void main() { o_color = vec4(0.25, 0.5, 0.75, 1.0); }
|
|||||||
protected:
|
protected:
|
||||||
// The library log this process is writing, or an empty path when none was configured.
|
// The library log this process is writing, or an empty path when none was configured.
|
||||||
static std::filesystem::path LibraryLogPath() {
|
static std::filesystem::path LibraryLogPath() {
|
||||||
const char* path = std::getenv("MOBILEGL_LOG_FILE_PATH");
|
// P6: the path is a BASE NAME and the library writes one log per role; PipeStatsWindow
|
||||||
return (path != nullptr && *path != '\0') ? std::filesystem::path(path)
|
// derives the suffix, so the rule lives in one place.
|
||||||
: std::filesystem::path();
|
return std::filesystem::path(MGITest::PipeStatsWindow::LibraryLogPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::uintmax_t LibraryLogSize() {
|
// ONE MARK PER ROLE. The library writes a log per role, so "how long is the log
|
||||||
std::error_code ec;
|
// right now" is two numbers; a single scalar applied to the concatenation would slide
|
||||||
const std::filesystem::path path = LibraryLogPath();
|
// by whatever the other role wrote in between and start the read mid-line.
|
||||||
if (path.empty()) return 0;
|
static MGITest::PipeStatsWindow::LogMark LibraryLogMark() {
|
||||||
const std::uintmax_t size = std::filesystem::file_size(path, ec);
|
return MGITest::PipeStatsWindow::MarkLaneLog();
|
||||||
return ec ? 0 : size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string LibraryLogSince(std::uintmax_t offset) {
|
// BOTH ROLES. The arming diagnostics this case looks for are emitted by the
|
||||||
const std::filesystem::path path = LibraryLogPath();
|
// BACKEND, and under inproc the backend runs on the apply thread - the server role -
|
||||||
if (path.empty()) return {};
|
// so the line lands in the server's log. Reading only the client's found nothing and
|
||||||
std::ifstream file(path, std::ios::binary);
|
// reported the emulation unarmed, which accused the product of a defect the reader
|
||||||
if (!file.good()) return {};
|
// had invented.
|
||||||
file.seekg(static_cast<std::streamoff>(offset));
|
static std::string LibraryLogSince(const MGITest::PipeStatsWindow::LogMark& mark) {
|
||||||
return std::string((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
return MGITest::PipeStatsWindow::ReadLaneLogSince(mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string LibraryLog() { return LibraryLogSince(0); }
|
static std::string LibraryLog() { return MGITest::PipeStatsWindow::ReadLaneLog(); }
|
||||||
|
|
||||||
// One frame that crosses several verb boundaries: a clear (kClear), a draw (kDraw) and
|
// One frame that crosses several verb boundaries: a clear (kClear), a draw (kDraw) and
|
||||||
// a readback (kReadback). Three of the nine fill classes, so an entry compare that only
|
// a readback (kReadback). Three of the nine fill classes, so an entry compare that only
|
||||||
@@ -200,7 +200,7 @@ void main() { o_color = vec4(0.25, 0.5, 0.75, 1.0); }
|
|||||||
"backwards; the VerifyCorrupted. lane owns that half";
|
"backwards; the VerifyCorrupted. lane owns that half";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::uintmax_t before = LibraryLogSize();
|
const MGITest::PipeStatsWindow::LogMark before = LibraryLogMark();
|
||||||
ASSERT_NO_FATAL_FAILURE(DrawOneFrame());
|
ASSERT_NO_FATAL_FAILURE(DrawOneFrame());
|
||||||
EXPECT_EQ(FirstGLError(), 0u);
|
EXPECT_EQ(FirstGLError(), 0u);
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ void main() { o_color = vec4(0.25, 0.5, 0.75, 1.0); }
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::string knob = std::getenv("MOBILEGL_PIPE_VERIFY_CORRUPT");
|
const std::string knob = std::getenv("MOBILEGL_PIPE_VERIFY_CORRUPT");
|
||||||
const std::uintmax_t before = LibraryLogSize();
|
const MGITest::PipeStatsWindow::LogMark before = LibraryLogMark();
|
||||||
ASSERT_NO_FATAL_FAILURE(DrawOneFrame());
|
ASSERT_NO_FATAL_FAILURE(DrawOneFrame());
|
||||||
|
|
||||||
const std::string appended = LibraryLogSince(before);
|
const std::string appended = LibraryLogSince(before);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../Harness/PipeStatsWindow.h"
|
||||||
#include "../Harness/HeadlessGL.h"
|
#include "../Harness/HeadlessGL.h"
|
||||||
#include "../Harness/ScenarioFixture.h"
|
#include "../Harness/ScenarioFixture.h"
|
||||||
|
|
||||||
@@ -305,27 +306,25 @@ void main()
|
|||||||
// is appended to by every process in the lane, and only bytes appended after the
|
// is appended to by every process in the lane, and only bytes appended after the
|
||||||
// snapshot may satisfy an assertion.
|
// snapshot may satisfy an assertion.
|
||||||
static std::filesystem::path LibraryLogPath() {
|
static std::filesystem::path LibraryLogPath() {
|
||||||
const char* path = std::getenv("MOBILEGL_LOG_FILE_PATH");
|
// P6: the path is a BASE NAME and the library writes one log per role; PipeStatsWindow
|
||||||
return (path != nullptr && *path != '\0') ? std::filesystem::path(path)
|
// derives the suffix, so the rule lives in one place.
|
||||||
: std::filesystem::path();
|
return std::filesystem::path(MGITest::PipeStatsWindow::LibraryLogPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::uintmax_t LibraryLogSize() {
|
// ONE MARK PER ROLE. The library writes a log per role, so "how long is the log
|
||||||
std::error_code ec;
|
// right now" is two numbers; a single scalar applied to the concatenation would slide
|
||||||
const std::filesystem::path path = LibraryLogPath();
|
// by whatever the other role wrote in between and start the read mid-line.
|
||||||
if (path.empty()) return 0;
|
static MGITest::PipeStatsWindow::LogMark LibraryLogMark() {
|
||||||
const std::uintmax_t size = std::filesystem::file_size(path, ec);
|
return MGITest::PipeStatsWindow::MarkLaneLog();
|
||||||
return ec ? 0 : size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string LibraryLogSince(std::uintmax_t offset) {
|
// BOTH ROLES. The arming diagnostics this case looks for are emitted by the
|
||||||
const std::filesystem::path path = LibraryLogPath();
|
// BACKEND, and under inproc the backend runs on the apply thread - the server role -
|
||||||
if (path.empty()) return {};
|
// so the line lands in the server's log. Reading only the client's found nothing and
|
||||||
std::ifstream file(path, std::ios::binary);
|
// reported the emulation unarmed, which accused the product of a defect the reader
|
||||||
if (!file.good()) return {};
|
// had invented.
|
||||||
file.seekg(static_cast<std::streamoff>(offset));
|
static std::string LibraryLogSince(const MGITest::PipeStatsWindow::LogMark& mark) {
|
||||||
return std::string((std::istreambuf_iterator<char>(file)),
|
return MGITest::PipeStatsWindow::ReadLaneLogSince(mark);
|
||||||
std::istreambuf_iterator<char>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string m_buildLog;
|
std::string m_buildLog;
|
||||||
@@ -493,7 +492,7 @@ void main()
|
|||||||
|
|
||||||
// Taken BEFORE the program is built, so the line this looks for can only be one
|
// Taken BEFORE the program is built, so the line this looks for can only be one
|
||||||
// this process wrote.
|
// this process wrote.
|
||||||
const std::uintmax_t before = LibraryLogSize();
|
const MGITest::PipeStatsWindow::LogMark before = LibraryLogMark();
|
||||||
|
|
||||||
const GLuint program = BuildCaptureProgram({{GL_VERTEX_SHADER, kPointVertexSource},
|
const GLuint program = BuildCaptureProgram({{GL_VERTEX_SHADER, kPointVertexSource},
|
||||||
{GL_GEOMETRY_SHADER, kPointGeometrySource},
|
{GL_GEOMETRY_SHADER, kPointGeometrySource},
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../Harness/PipeStatsWindow.h"
|
||||||
#include "../Harness/HeadlessGL.h"
|
#include "../Harness/HeadlessGL.h"
|
||||||
#include "../Harness/ScenarioFixture.h"
|
#include "../Harness/ScenarioFixture.h"
|
||||||
|
|
||||||
@@ -109,9 +110,9 @@ void main() { o_color = vec4(0.25, 0.5, 0.75, 1.0); }
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path LibraryLogPath() {
|
std::filesystem::path LibraryLogPath() {
|
||||||
const char* path = std::getenv("MOBILEGL_LOG_FILE_PATH");
|
// P6: the path is a BASE NAME and the library writes one log per role; PipeStatsWindow
|
||||||
return (path != nullptr && *path != '\0') ? std::filesystem::path(path)
|
// derives the suffix, so the rule lives in one place.
|
||||||
: std::filesystem::path();
|
return std::filesystem::path(MGITest::PipeStatsWindow::LibraryLogPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Where the child is told to write ITS log. Empty when the lane configured no log path at
|
// Where the child is told to write ITS log. Empty when the lane configured no log path at
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../Harness/PipeStatsWindow.h"
|
||||||
#include "../Harness/HeadlessGL.h"
|
#include "../Harness/HeadlessGL.h"
|
||||||
#include "../Harness/ScenarioFixture.h"
|
#include "../Harness/ScenarioFixture.h"
|
||||||
|
|
||||||
@@ -250,27 +251,25 @@ void main() {
|
|||||||
const std::string& BuildLog() const { return m_buildLog; }
|
const std::string& BuildLog() const { return m_buildLog; }
|
||||||
|
|
||||||
static std::filesystem::path LibraryLogPath() {
|
static std::filesystem::path LibraryLogPath() {
|
||||||
const char* path = std::getenv("MOBILEGL_LOG_FILE_PATH");
|
// P6: the path is a BASE NAME and the library writes one log per role; PipeStatsWindow
|
||||||
return (path != nullptr && *path != '\0') ? std::filesystem::path(path)
|
// derives the suffix, so the rule lives in one place.
|
||||||
: std::filesystem::path();
|
return std::filesystem::path(MGITest::PipeStatsWindow::LibraryLogPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::uintmax_t LibraryLogSize() {
|
// ONE MARK PER ROLE. The library writes a log per role, so "how long is the log
|
||||||
std::error_code ec;
|
// right now" is two numbers; a single scalar applied to the concatenation would slide
|
||||||
const std::filesystem::path path = LibraryLogPath();
|
// by whatever the other role wrote in between and start the read mid-line.
|
||||||
if (path.empty()) return 0;
|
static MGITest::PipeStatsWindow::LogMark LibraryLogMark() {
|
||||||
const std::uintmax_t size = std::filesystem::file_size(path, ec);
|
return MGITest::PipeStatsWindow::MarkLaneLog();
|
||||||
return ec ? 0 : size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string LibraryLogSince(std::uintmax_t offset) {
|
// BOTH ROLES. The arming diagnostics this case looks for are emitted by the
|
||||||
const std::filesystem::path path = LibraryLogPath();
|
// BACKEND, and under inproc the backend runs on the apply thread - the server role -
|
||||||
if (path.empty()) return {};
|
// so the line lands in the server's log. Reading only the client's found nothing and
|
||||||
std::ifstream file(path, std::ios::binary);
|
// reported the emulation unarmed, which accused the product of a defect the reader
|
||||||
if (!file.good()) return {};
|
// had invented.
|
||||||
file.seekg(static_cast<std::streamoff>(offset));
|
static std::string LibraryLogSince(const MGITest::PipeStatsWindow::LogMark& mark) {
|
||||||
return std::string((std::istreambuf_iterator<char>(file)),
|
return MGITest::PipeStatsWindow::ReadLaneLogSince(mark);
|
||||||
std::istreambuf_iterator<char>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint m_vao = 0;
|
GLuint m_vao = 0;
|
||||||
@@ -535,7 +534,7 @@ void main() {
|
|||||||
// Taken BEFORE the draw, so the line this looks for can only be one this
|
// Taken BEFORE the draw, so the line this looks for can only be one this
|
||||||
// process wrote for this span. The latch fires on the FIRST rerouted
|
// process wrote for this span. The latch fires on the FIRST rerouted
|
||||||
// draw, which is inside the query below.
|
// draw, which is inside the query below.
|
||||||
const std::uintmax_t before = LibraryLogSize();
|
const MGITest::PipeStatsWindow::LogMark before = LibraryLogMark();
|
||||||
const GLuint generated = QueryGenerated([]() { glDrawArrays(GL_TRIANGLES, 0, 3); });
|
const GLuint generated = QueryGenerated([]() { glDrawArrays(GL_TRIANGLES, 0, 3); });
|
||||||
EXPECT_EQ(DrainGLErrors(), 0u);
|
EXPECT_EQ(DrainGLErrors(), 0u);
|
||||||
EXPECT_EQ(generated, 1u) << "the pinned-on lane did not even count correctly";
|
EXPECT_EQ(generated, 1u) << "the pinned-on lane did not even count correctly";
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../Harness/PipeStatsWindow.h"
|
||||||
#include "../Harness/HeadlessGL.h"
|
#include "../Harness/HeadlessGL.h"
|
||||||
#include "../Harness/ScenarioFixture.h"
|
#include "../Harness/ScenarioFixture.h"
|
||||||
|
|
||||||
@@ -354,31 +355,29 @@ void main()
|
|||||||
// configured. MOBILEGL_LOG_FILE_PATH is read at log-init, before anything this
|
// configured. MOBILEGL_LOG_FILE_PATH is read at log-init, before anything this
|
||||||
// fixture can reach, so the ctest entry sets it and this only reads it back.
|
// fixture can reach, so the ctest entry sets it and this only reads it back.
|
||||||
static std::filesystem::path LibraryLogPath() {
|
static std::filesystem::path LibraryLogPath() {
|
||||||
const char* path = std::getenv("MOBILEGL_LOG_FILE_PATH");
|
// P6: the path is a BASE NAME and the library writes one log per role; PipeStatsWindow
|
||||||
return (path != nullptr && *path != '\0') ? std::filesystem::path(path)
|
// derives the suffix, so the rule lives in one place.
|
||||||
: std::filesystem::path();
|
return std::filesystem::path(MGITest::PipeStatsWindow::LibraryLogPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
// How many bytes the library log already holds. Everything this fixture asserts on
|
// How many bytes the library log already holds. Everything this fixture asserts on
|
||||||
// is searched from here forward, because the file is APPENDED to by every process
|
// is searched from here forward, because the file is APPENDED to by every process
|
||||||
// in the lane and a line left behind by an earlier one would otherwise satisfy the
|
// in the lane and a line left behind by an earlier one would otherwise satisfy the
|
||||||
// assertion without this process having done anything at all.
|
// assertion without this process having done anything at all.
|
||||||
static std::uintmax_t LibraryLogSize() {
|
// ONE MARK PER ROLE. The library writes a log per role, so "how long is the log
|
||||||
std::error_code ec;
|
// right now" is two numbers; a single scalar applied to the concatenation would slide
|
||||||
const std::filesystem::path path = LibraryLogPath();
|
// by whatever the other role wrote in between and start the read mid-line.
|
||||||
if (path.empty()) return 0;
|
static MGITest::PipeStatsWindow::LogMark LibraryLogMark() {
|
||||||
const std::uintmax_t size = std::filesystem::file_size(path, ec);
|
return MGITest::PipeStatsWindow::MarkLaneLog();
|
||||||
return ec ? 0 : size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string LibraryLogSince(std::uintmax_t offset) {
|
// BOTH ROLES. The arming diagnostics this case looks for are emitted by the
|
||||||
const std::filesystem::path path = LibraryLogPath();
|
// BACKEND, and under inproc the backend runs on the apply thread - the server role -
|
||||||
if (path.empty()) return {};
|
// so the line lands in the server's log. Reading only the client's found nothing and
|
||||||
std::ifstream file(path, std::ios::binary);
|
// reported the emulation unarmed, which accused the product of a defect the reader
|
||||||
if (!file.good()) return {};
|
// had invented.
|
||||||
file.seekg(static_cast<std::streamoff>(offset));
|
static std::string LibraryLogSince(const MGITest::PipeStatsWindow::LogMark& mark) {
|
||||||
return std::string((std::istreambuf_iterator<char>(file)),
|
return MGITest::PipeStatsWindow::ReadLaneLogSince(mark);
|
||||||
std::istreambuf_iterator<char>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLenum FirstGLError() {
|
static GLenum FirstGLError() {
|
||||||
@@ -499,7 +498,7 @@ void main()
|
|||||||
// Taken BEFORE the program is built, so the line this looks for can only be one
|
// Taken BEFORE the program is built, so the line this looks for can only be one
|
||||||
// this process wrote. The latch means it is emitted at the FIRST stage of the
|
// this process wrote. The latch means it is emitted at the FIRST stage of the
|
||||||
// FIRST affected program, which is inside the build below.
|
// FIRST affected program, which is inside the build below.
|
||||||
const std::uintmax_t before = LibraryLogSize();
|
const MGITest::PipeStatsWindow::LogMark before = LibraryLogMark();
|
||||||
|
|
||||||
const GLuint program = BuildPipeline(kDistinctTessEvalSource, kDistinctGeometrySource);
|
const GLuint program = BuildPipeline(kDistinctTessEvalSource, kDistinctGeometrySource);
|
||||||
if (program == 0) {
|
if (program == 0) {
|
||||||
|
|||||||
@@ -175,10 +175,8 @@ namespace MobileGL::MG_Pipe {
|
|||||||
MGPBlobRef RendererInfo;
|
MGPBlobRef RendererInfo;
|
||||||
};
|
};
|
||||||
static_assert(std::is_trivially_copyable_v<MGPCaps>, "MGPCaps must be trivially copyable");
|
static_assert(std::is_trivially_copyable_v<MGPCaps>, "MGPCaps must be trivially copyable");
|
||||||
// Stated as a COMPOSITION rather than a literal: DynamicBackendParameters still carries
|
// Stated as a composition to catch padding between the wire members.
|
||||||
// SizeT fields, so its literal size is ABI-dependent until P0.5 moves the caps block
|
// P6.5: all dynamic scalar widths are explicit; member offsets are in the wire digest.
|
||||||
// into MGPipeValueTypes.h with fixed-width members. The assertion still fires on any
|
|
||||||
// padding introduced between the members below.
|
|
||||||
static_assert(sizeof(MGPCaps) == sizeof(DynamicBackendParameters) + 8 + 24 + 24,
|
static_assert(sizeof(MGPCaps) == sizeof(DynamicBackendParameters) + 8 + 24 + 24,
|
||||||
"MGPCaps gained padding or a member; update the wire format");
|
"MGPCaps gained padding or a member; update the wire format");
|
||||||
|
|
||||||
|
|||||||
@@ -1350,9 +1350,18 @@ namespace MobileGL::MG_Pipe {
|
|||||||
// documented bring-up exception), and a ServerLoop fixture with no client at all has
|
// documented bring-up exception), and a ServerLoop fixture with no client at all has
|
||||||
// none either - there this call is the only reset that exists. Monolith keeps the
|
// none either - there this call is the only reset that exists. Monolith keeps the
|
||||||
// direct call, byte for byte (G1); in a pull build none of this is compiled at all.
|
// direct call, byte for byte (G1); in a pull build none of this is compiled at all.
|
||||||
|
// D10: THE MIDDLE CONJUNCT WAS ClientSession::Active() != nullptr ALONE, WHICH IS
|
||||||
|
// PERMANENTLY NULL IN A SERVER PROCESS - so this guard could not arm at all under
|
||||||
|
// spawn, in the shape where calling the reset off the apply thread is most likely and
|
||||||
|
// least recoverable. MGPipeSessionLive() is the same question asked in a way both roles
|
||||||
|
// can answer, and MGPipeServerArm() is the process-scoped half of "am I the server".
|
||||||
|
//
|
||||||
|
// BOTH ARE ADDED AS DISJUNCTS, not substituted. The originals are the only facts a
|
||||||
|
// fixture without a full session has, and swapping them out silently disarms every such
|
||||||
|
// test - measured.
|
||||||
if (MG_Config::Transport != MG_Config::TransportMode::Monolith &&
|
if (MG_Config::Transport != MG_Config::TransportMode::Monolith &&
|
||||||
MG_Remote::Client::ClientSession::Active() != nullptr &&
|
(MG_Remote::Client::ClientSession::Active() != nullptr || MG_Pipe::MGPipeSessionLive()) &&
|
||||||
!MG_Remote::Server::ServerLoop::OnApplyThread()) {
|
!MG_Remote::Server::ServerLoop::OnApplyThread() && !MG_Pipe::MGPipeServerArm()) {
|
||||||
MGLOG_F("MGPipe: Fatal{RoleViolation, \"g_applier\"} - MGPipeApplierReset() called "
|
MGLOG_F("MGPipe: Fatal{RoleViolation, \"g_applier\"} - MGPipeApplierReset() called "
|
||||||
"off the apply thread with an active transport; under split the reset "
|
"off the apply thread with an active transport; under split the reset "
|
||||||
"crosses as the applier_reset record (CONTRACT-P5C.md §5.1)");
|
"crosses as the applier_reset record (CONTRACT-P5C.md §5.1)");
|
||||||
|
|||||||
@@ -263,6 +263,8 @@ namespace MobileGL::MG_Pipe {
|
|||||||
// monolith transport, and on a lockstep one (there the client waited out every command it
|
// monolith transport, and on a lockstep one (there the client waited out every command it
|
||||||
// issued before it could reach the call).
|
// issued before it could reach the call).
|
||||||
void MGPipeClientFinish();
|
void MGPipeClientFinish();
|
||||||
|
// Submit a stream link's published prefix; never wait for appliedSeq.
|
||||||
|
void MGPipeClientFlush();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void MGPipeEmitResourceCreate(MG_State::GLState::BufferObject& buffer);
|
void MGPipeEmitResourceCreate(MG_State::GLState::BufferObject& buffer);
|
||||||
|
|||||||
@@ -321,6 +321,10 @@ namespace MobileGL::MG_Pipe {
|
|||||||
MGPReplySlot reply = MGPipeMintReplySlot();
|
MGPReplySlot reply = MGPipeMintReplySlot();
|
||||||
MGP_ResourceSubData(&record, bytes, byteCount, regions, record.RegionCount, &reply);
|
MGP_ResourceSubData(&record, bytes, byteCount, regions, record.RegionCount, &reply);
|
||||||
const Bool accepted = MGPipeTakeReplyBool(reply, "resource_subdata");
|
const Bool accepted = MGPipeTakeReplyBool(reply, "resource_subdata");
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
// A cancelled wire upload is declined even when no server reply was requested.
|
||||||
|
if (MGPipeInstalledArm() == MGPipeRouteArm::kClientWire) return accepted;
|
||||||
|
#endif
|
||||||
return MGPipeSubDataWantsItsReply(record) ? accepted : true;
|
return MGPipeSubDataWantsItsReply(record) ? accepted : true;
|
||||||
}
|
}
|
||||||
inline void MGPipeRouteBufferSubDataResident(const MGPSubData& record, const void* bytes,
|
inline void MGPipeRouteBufferSubDataResident(const MGPSubData& record, const void* bytes,
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// MobileGL - P6.5 wire compatibility facts. Generated member coverage is checked by gen_pipe.py.
|
||||||
|
#pragma once
|
||||||
|
#include "MGPipe.h"
|
||||||
|
#include "MGPipeRenderStateSpans.h"
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Pipe {
|
||||||
|
#include "generated/PipeWireLayout.inc"
|
||||||
|
|
||||||
|
static_assert(sizeof(Bool) == 1 && sizeof(Float) == 4 && sizeof(Int32) == 4,
|
||||||
|
"wire scalar representation is unsupported");
|
||||||
|
static_assert(sizeof(RenderStateParameters) == 1168, "render-state wire blob changed");
|
||||||
|
|
||||||
|
constexpr void WireMixNumber(Uint64& hash, Uint64 value) {
|
||||||
|
for (unsigned i = 0; i < 8; ++i) {
|
||||||
|
hash ^= (value >> (i * 8)) & 255;
|
||||||
|
hash *= 1099511628211ull;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
constexpr void WireMixName(Uint64& hash, const char* name) {
|
||||||
|
do {
|
||||||
|
hash ^= static_cast<unsigned char>(*name);
|
||||||
|
hash *= 1099511628211ull;
|
||||||
|
} while (*name++ != '\0');
|
||||||
|
}
|
||||||
|
constexpr Uint64 WireMemberLayoutDigest(const WireLayoutMember* fields, SizeT count) {
|
||||||
|
Uint64 hash = 1469598103934665603ull;
|
||||||
|
for (SizeT i = 0; i < count; ++i) {
|
||||||
|
WireMixName(hash, fields[i].Name);
|
||||||
|
WireMixNumber(hash, fields[i].Offset);
|
||||||
|
WireMixNumber(hash, fields[i].Size);
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
inline constexpr Uint64 kMGPipeWireMemberLayoutDigest = WireMemberLayoutDigest(
|
||||||
|
kMGPipeWireLayoutMembers, sizeof(kMGPipeWireLayoutMembers) / sizeof(WireLayoutMember));
|
||||||
|
|
||||||
|
constexpr Uint64 WireCatalogueDigest() {
|
||||||
|
Uint64 hash = 1469598103934665603ull;
|
||||||
|
for (const auto& call : kMGPipeWireCallLayouts) {
|
||||||
|
WireMixName(hash, call.Name);
|
||||||
|
WireMixName(hash, call.Payload);
|
||||||
|
WireMixNumber(hash, call.Op);
|
||||||
|
WireMixNumber(hash, call.Flags);
|
||||||
|
WireMixNumber(hash, call.Wait);
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
inline constexpr Uint64 kMGPipeWireCatalogueDigest = WireCatalogueDigest();
|
||||||
|
constexpr Uint64 WireRenderStateDigest() {
|
||||||
|
Uint64 hash = 1469598103934665603ull;
|
||||||
|
WireMixNumber(hash, kMGPipeRenderStateChunkTableVersion);
|
||||||
|
for (SizeT boundary : kMGPipeRenderStateChunkBoundaries) WireMixNumber(hash, boundary);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
} // namespace MobileGL::MG_Pipe
|
||||||
@@ -0,0 +1,756 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Pipe/generated/PipeWireLayout.inc
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// P6.5: wire layout and ordered catalogue.
|
||||||
|
//
|
||||||
|
// GENERATED by scripts/gen_pipe.py from PipeFields.def and PipeCalls.def - DO NOT EDIT.
|
||||||
|
// Regenerate with `python3 scripts/gen_pipe.py`; CI runs it and diffs the result.
|
||||||
|
// This file is included from MG_Pipe/MGPipe.h inside namespace MobileGL::MG_Pipe.
|
||||||
|
|
||||||
|
struct WireLayoutMember { const char* Name; Uint64 Offset; Uint64 Size; };
|
||||||
|
inline constexpr WireLayoutMember kMGPipeWireLayoutMembers[] = {
|
||||||
|
{"MGPBlobRef", 0, sizeof(MGPBlobRef)},
|
||||||
|
{"MGPBlobRef.Offset", offsetof(MGPBlobRef, Offset), sizeof(((MGPBlobRef*)nullptr)->Offset)},
|
||||||
|
{"MGPBlobRef.Size", offsetof(MGPBlobRef, Size), sizeof(((MGPBlobRef*)nullptr)->Size)},
|
||||||
|
{"MGPBlobRef.Seg", offsetof(MGPBlobRef, Seg), sizeof(((MGPBlobRef*)nullptr)->Seg)},
|
||||||
|
{"MGPRange", 0, sizeof(MGPRange)},
|
||||||
|
{"MGPRange.Offset", offsetof(MGPRange, Offset), sizeof(((MGPRange*)nullptr)->Offset)},
|
||||||
|
{"MGPRange.Size", offsetof(MGPRange, Size), sizeof(((MGPRange*)nullptr)->Size)},
|
||||||
|
{"MGPBox", 0, sizeof(MGPBox)},
|
||||||
|
{"MGPBox.X", offsetof(MGPBox, X), sizeof(((MGPBox*)nullptr)->X)},
|
||||||
|
{"MGPBox.Y", offsetof(MGPBox, Y), sizeof(((MGPBox*)nullptr)->Y)},
|
||||||
|
{"MGPBox.Z", offsetof(MGPBox, Z), sizeof(((MGPBox*)nullptr)->Z)},
|
||||||
|
{"MGPBox.W", offsetof(MGPBox, W), sizeof(((MGPBox*)nullptr)->W)},
|
||||||
|
{"MGPBox.H", offsetof(MGPBox, H), sizeof(((MGPBox*)nullptr)->H)},
|
||||||
|
{"MGPBox.D", offsetof(MGPBox, D), sizeof(((MGPBox*)nullptr)->D)},
|
||||||
|
{"MGPReplySlot", 0, sizeof(MGPReplySlot)},
|
||||||
|
{"MGPReplySlot.Id", offsetof(MGPReplySlot, Id), sizeof(((MGPReplySlot*)nullptr)->Id)},
|
||||||
|
{"MGPStateChunk", 0, sizeof(MGPStateChunk)},
|
||||||
|
{"MGPStateChunk.Offset", offsetof(MGPStateChunk, Offset), sizeof(((MGPStateChunk*)nullptr)->Offset)},
|
||||||
|
{"MGPStateChunk.Length", offsetof(MGPStateChunk, Length), sizeof(((MGPStateChunk*)nullptr)->Length)},
|
||||||
|
{"MGPHandleOnly", 0, sizeof(MGPHandleOnly)},
|
||||||
|
{"MGPHandleOnly.Handle", offsetof(MGPHandleOnly, Handle), sizeof(((MGPHandleOnly*)nullptr)->Handle)},
|
||||||
|
{"MGPHandleOnly.Kind", offsetof(MGPHandleOnly, Kind), sizeof(((MGPHandleOnly*)nullptr)->Kind)},
|
||||||
|
{"MGPCaps", 0, sizeof(MGPCaps)},
|
||||||
|
{"MGPCaps.Dynamic", offsetof(MGPCaps, Dynamic), sizeof(((MGPCaps*)nullptr)->Dynamic)},
|
||||||
|
{"MGPCaps.CallMask", offsetof(MGPCaps, CallMask), sizeof(((MGPCaps*)nullptr)->CallMask)},
|
||||||
|
{"MGPCaps.FormatCapabilities", offsetof(MGPCaps, FormatCapabilities), sizeof(((MGPCaps*)nullptr)->FormatCapabilities)},
|
||||||
|
{"MGPCaps.RendererInfo", offsetof(MGPCaps, RendererInfo), sizeof(((MGPCaps*)nullptr)->RendererInfo)},
|
||||||
|
{"MGPResourceDesc", 0, sizeof(MGPResourceDesc)},
|
||||||
|
{"MGPResourceDesc.Resource", offsetof(MGPResourceDesc, Resource), sizeof(((MGPResourceDesc*)nullptr)->Resource)},
|
||||||
|
{"MGPResourceDesc.Target", offsetof(MGPResourceDesc, Target), sizeof(((MGPResourceDesc*)nullptr)->Target)},
|
||||||
|
{"MGPResourceDesc.StorageKind", offsetof(MGPResourceDesc, StorageKind), sizeof(((MGPResourceDesc*)nullptr)->StorageKind)},
|
||||||
|
{"MGPResourceDesc.BindMask", offsetof(MGPResourceDesc, BindMask), sizeof(((MGPResourceDesc*)nullptr)->BindMask)},
|
||||||
|
{"MGPResourceDesc.InternalFormat", offsetof(MGPResourceDesc, InternalFormat), sizeof(((MGPResourceDesc*)nullptr)->InternalFormat)},
|
||||||
|
{"MGPResourceDesc.Width", offsetof(MGPResourceDesc, Width), sizeof(((MGPResourceDesc*)nullptr)->Width)},
|
||||||
|
{"MGPResourceDesc.Height", offsetof(MGPResourceDesc, Height), sizeof(((MGPResourceDesc*)nullptr)->Height)},
|
||||||
|
{"MGPResourceDesc.Depth", offsetof(MGPResourceDesc, Depth), sizeof(((MGPResourceDesc*)nullptr)->Depth)},
|
||||||
|
{"MGPResourceDesc.ArrayLayers", offsetof(MGPResourceDesc, ArrayLayers), sizeof(((MGPResourceDesc*)nullptr)->ArrayLayers)},
|
||||||
|
{"MGPResourceDesc.Levels", offsetof(MGPResourceDesc, Levels), sizeof(((MGPResourceDesc*)nullptr)->Levels)},
|
||||||
|
{"MGPResourceDesc.Samples", offsetof(MGPResourceDesc, Samples), sizeof(((MGPResourceDesc*)nullptr)->Samples)},
|
||||||
|
{"MGPResourceDesc.FixedSampleLocations", offsetof(MGPResourceDesc, FixedSampleLocations), sizeof(((MGPResourceDesc*)nullptr)->FixedSampleLocations)},
|
||||||
|
{"MGPResourceDesc.Immutable", offsetof(MGPResourceDesc, Immutable), sizeof(((MGPResourceDesc*)nullptr)->Immutable)},
|
||||||
|
{"MGPResourceDesc.Usage", offsetof(MGPResourceDesc, Usage), sizeof(((MGPResourceDesc*)nullptr)->Usage)},
|
||||||
|
{"MGPResourceDesc.StorageFlags", offsetof(MGPResourceDesc, StorageFlags), sizeof(((MGPResourceDesc*)nullptr)->StorageFlags)},
|
||||||
|
{"MGPResourceDesc.HasDefinedContent", offsetof(MGPResourceDesc, HasDefinedContent), sizeof(((MGPResourceDesc*)nullptr)->HasDefinedContent)},
|
||||||
|
{"MGPResourceDesc.ImageBindableHint", offsetof(MGPResourceDesc, ImageBindableHint), sizeof(((MGPResourceDesc*)nullptr)->ImageBindableHint)},
|
||||||
|
{"MGPResourceDesc.HasRespecifiedLevel", offsetof(MGPResourceDesc, HasRespecifiedLevel), sizeof(((MGPResourceDesc*)nullptr)->HasRespecifiedLevel)},
|
||||||
|
{"MGPResourceDesc.GlNameForDiag", offsetof(MGPResourceDesc, GlNameForDiag), sizeof(((MGPResourceDesc*)nullptr)->GlNameForDiag)},
|
||||||
|
{"MGPResourceDesc.RespecifiedUploadTarget", offsetof(MGPResourceDesc, RespecifiedUploadTarget), sizeof(((MGPResourceDesc*)nullptr)->RespecifiedUploadTarget)},
|
||||||
|
{"MGPResourceDesc.RespecifiedLevel", offsetof(MGPResourceDesc, RespecifiedLevel), sizeof(((MGPResourceDesc*)nullptr)->RespecifiedLevel)},
|
||||||
|
{"MGPResourceDesc.ViewOf", offsetof(MGPResourceDesc, ViewOf), sizeof(((MGPResourceDesc*)nullptr)->ViewOf)},
|
||||||
|
{"MGPResourceDesc.BufferForTexBuffer", offsetof(MGPResourceDesc, BufferForTexBuffer), sizeof(((MGPResourceDesc*)nullptr)->BufferForTexBuffer)},
|
||||||
|
{"MGPResourceDesc.BufOffset", offsetof(MGPResourceDesc, BufOffset), sizeof(((MGPResourceDesc*)nullptr)->BufOffset)},
|
||||||
|
{"MGPResourceDesc.BufSize", offsetof(MGPResourceDesc, BufSize), sizeof(((MGPResourceDesc*)nullptr)->BufSize)},
|
||||||
|
{"MGPFenceWait", 0, sizeof(MGPFenceWait)},
|
||||||
|
{"MGPFenceWait.Fence", offsetof(MGPFenceWait, Fence), sizeof(((MGPFenceWait*)nullptr)->Fence)},
|
||||||
|
{"MGPFenceWait.TimeoutNs", offsetof(MGPFenceWait, TimeoutNs), sizeof(((MGPFenceWait*)nullptr)->TimeoutNs)},
|
||||||
|
{"MGPFenceWait.Flags", offsetof(MGPFenceWait, Flags), sizeof(((MGPFenceWait*)nullptr)->Flags)},
|
||||||
|
{"MGPQueryDesc", 0, sizeof(MGPQueryDesc)},
|
||||||
|
{"MGPQueryDesc.Query", offsetof(MGPQueryDesc, Query), sizeof(((MGPQueryDesc*)nullptr)->Query)},
|
||||||
|
{"MGPQueryDesc.Kind", offsetof(MGPQueryDesc, Kind), sizeof(((MGPQueryDesc*)nullptr)->Kind)},
|
||||||
|
{"MGPQueryDesc.Stream", offsetof(MGPQueryDesc, Stream), sizeof(((MGPQueryDesc*)nullptr)->Stream)},
|
||||||
|
{"MGPQueryResultRequest", 0, sizeof(MGPQueryResultRequest)},
|
||||||
|
{"MGPQueryResultRequest.Query", offsetof(MGPQueryResultRequest, Query), sizeof(((MGPQueryResultRequest*)nullptr)->Query)},
|
||||||
|
{"MGPQueryResultRequest.Wait", offsetof(MGPQueryResultRequest, Wait), sizeof(((MGPQueryResultRequest*)nullptr)->Wait)},
|
||||||
|
{"MGPTimestampRequest", 0, sizeof(MGPTimestampRequest)},
|
||||||
|
{"MGPTimestampRequest.Reserved", offsetof(MGPTimestampRequest, Reserved), sizeof(((MGPTimestampRequest*)nullptr)->Reserved)},
|
||||||
|
{"MGPRenderStateDesc", 0, sizeof(MGPRenderStateDesc)},
|
||||||
|
{"MGPRenderStateDesc.Cso", offsetof(MGPRenderStateDesc, Cso), sizeof(((MGPRenderStateDesc*)nullptr)->Cso)},
|
||||||
|
{"MGPRenderStateDesc.BaseCso", offsetof(MGPRenderStateDesc, BaseCso), sizeof(((MGPRenderStateDesc*)nullptr)->BaseCso)},
|
||||||
|
{"MGPRenderStateDesc.ChunkMask", offsetof(MGPRenderStateDesc, ChunkMask), sizeof(((MGPRenderStateDesc*)nullptr)->ChunkMask)},
|
||||||
|
{"MGPRenderStateDesc.Blob", offsetof(MGPRenderStateDesc, Blob), sizeof(((MGPRenderStateDesc*)nullptr)->Blob)},
|
||||||
|
{"MGPBindRenderState", 0, sizeof(MGPBindRenderState)},
|
||||||
|
{"MGPBindRenderState.Cso", offsetof(MGPBindRenderState, Cso), sizeof(((MGPBindRenderState*)nullptr)->Cso)},
|
||||||
|
{"MGPBindRenderState.Version", offsetof(MGPBindRenderState, Version), sizeof(((MGPBindRenderState*)nullptr)->Version)},
|
||||||
|
{"MGPBindRenderState.PipelineVersion", offsetof(MGPBindRenderState, PipelineVersion), sizeof(((MGPBindRenderState*)nullptr)->PipelineVersion)},
|
||||||
|
{"MGPDynamicState", 0, sizeof(MGPDynamicState)},
|
||||||
|
{"MGPDynamicState.ChunkMask", offsetof(MGPDynamicState, ChunkMask), sizeof(((MGPDynamicState*)nullptr)->ChunkMask)},
|
||||||
|
{"MGPDynamicState.Version", offsetof(MGPDynamicState, Version), sizeof(((MGPDynamicState*)nullptr)->Version)},
|
||||||
|
{"MGPDynamicState.Blob", offsetof(MGPDynamicState, Blob), sizeof(((MGPDynamicState*)nullptr)->Blob)},
|
||||||
|
{"MGPVertexElements", 0, sizeof(MGPVertexElements)},
|
||||||
|
{"MGPVertexElements.Cso", offsetof(MGPVertexElements, Cso), sizeof(((MGPVertexElements*)nullptr)->Cso)},
|
||||||
|
{"MGPVertexElements.AttributeCount", offsetof(MGPVertexElements, AttributeCount), sizeof(((MGPVertexElements*)nullptr)->AttributeCount)},
|
||||||
|
{"MGPVertexElements.BindingPointCount", offsetof(MGPVertexElements, BindingPointCount), sizeof(((MGPVertexElements*)nullptr)->BindingPointCount)},
|
||||||
|
{"MGPVertexElements.Blob", offsetof(MGPVertexElements, Blob), sizeof(((MGPVertexElements*)nullptr)->Blob)},
|
||||||
|
{"MGPSamplerDesc", 0, sizeof(MGPSamplerDesc)},
|
||||||
|
{"MGPSamplerDesc.Cso", offsetof(MGPSamplerDesc, Cso), sizeof(((MGPSamplerDesc*)nullptr)->Cso)},
|
||||||
|
{"MGPSamplerDesc.Parameters", offsetof(MGPSamplerDesc, Parameters), sizeof(((MGPSamplerDesc*)nullptr)->Parameters)},
|
||||||
|
{"MGPSamplerView", 0, sizeof(MGPSamplerView)},
|
||||||
|
{"MGPSamplerView.Cso", offsetof(MGPSamplerView, Cso), sizeof(((MGPSamplerView*)nullptr)->Cso)},
|
||||||
|
{"MGPSamplerView.Texture", offsetof(MGPSamplerView, Texture), sizeof(((MGPSamplerView*)nullptr)->Texture)},
|
||||||
|
{"MGPSamplerView.InternalFormat", offsetof(MGPSamplerView, InternalFormat), sizeof(((MGPSamplerView*)nullptr)->InternalFormat)},
|
||||||
|
{"MGPSamplerView.Target", offsetof(MGPSamplerView, Target), sizeof(((MGPSamplerView*)nullptr)->Target)},
|
||||||
|
{"MGPSamplerView.MinLevel", offsetof(MGPSamplerView, MinLevel), sizeof(((MGPSamplerView*)nullptr)->MinLevel)},
|
||||||
|
{"MGPSamplerView.NumLevels", offsetof(MGPSamplerView, NumLevels), sizeof(((MGPSamplerView*)nullptr)->NumLevels)},
|
||||||
|
{"MGPSamplerView.MinLayer", offsetof(MGPSamplerView, MinLayer), sizeof(((MGPSamplerView*)nullptr)->MinLayer)},
|
||||||
|
{"MGPSamplerView.NumLayers", offsetof(MGPSamplerView, NumLayers), sizeof(((MGPSamplerView*)nullptr)->NumLayers)},
|
||||||
|
{"MGPSamplerView.Samples", offsetof(MGPSamplerView, Samples), sizeof(((MGPSamplerView*)nullptr)->Samples)},
|
||||||
|
{"MGPSamplerView.FixedSampleLocations", offsetof(MGPSamplerView, FixedSampleLocations), sizeof(((MGPSamplerView*)nullptr)->FixedSampleLocations)},
|
||||||
|
{"MGPTextureParams", 0, sizeof(MGPTextureParams)},
|
||||||
|
{"MGPTextureParams.Res", offsetof(MGPTextureParams, Res), sizeof(((MGPTextureParams*)nullptr)->Res)},
|
||||||
|
{"MGPTextureParams.BuiltinSampler", offsetof(MGPTextureParams, BuiltinSampler), sizeof(((MGPTextureParams*)nullptr)->BuiltinSampler)},
|
||||||
|
{"MGPTextureParams.BaseLevel", offsetof(MGPTextureParams, BaseLevel), sizeof(((MGPTextureParams*)nullptr)->BaseLevel)},
|
||||||
|
{"MGPTextureParams.MaxLevel", offsetof(MGPTextureParams, MaxLevel), sizeof(((MGPTextureParams*)nullptr)->MaxLevel)},
|
||||||
|
{"MGPTextureParams.Swizzle", offsetof(MGPTextureParams, Swizzle), sizeof(((MGPTextureParams*)nullptr)->Swizzle)},
|
||||||
|
{"MGPTextureParams.DepthStencilMode", offsetof(MGPTextureParams, DepthStencilMode), sizeof(((MGPTextureParams*)nullptr)->DepthStencilMode)},
|
||||||
|
{"MGPTextureParams.ForceResync", offsetof(MGPTextureParams, ForceResync), sizeof(((MGPTextureParams*)nullptr)->ForceResync)},
|
||||||
|
{"MGPTextureParams.SamplerResync", offsetof(MGPTextureParams, SamplerResync), sizeof(((MGPTextureParams*)nullptr)->SamplerResync)},
|
||||||
|
{"MGPTextureParams.MinLod", offsetof(MGPTextureParams, MinLod), sizeof(((MGPTextureParams*)nullptr)->MinLod)},
|
||||||
|
{"MGPTextureParams.MaxLod", offsetof(MGPTextureParams, MaxLod), sizeof(((MGPTextureParams*)nullptr)->MaxLod)},
|
||||||
|
{"MGPTextureParams.LodBias", offsetof(MGPTextureParams, LodBias), sizeof(((MGPTextureParams*)nullptr)->LodBias)},
|
||||||
|
{"MGPProgramDesc", 0, sizeof(MGPProgramDesc)},
|
||||||
|
{"MGPProgramDesc.Cso", offsetof(MGPProgramDesc, Cso), sizeof(((MGPProgramDesc*)nullptr)->Cso)},
|
||||||
|
{"MGPProgramDesc.StageMask", offsetof(MGPProgramDesc, StageMask), sizeof(((MGPProgramDesc*)nullptr)->StageMask)},
|
||||||
|
{"MGPProgramDesc.GlobalUboSize", offsetof(MGPProgramDesc, GlobalUboSize), sizeof(((MGPProgramDesc*)nullptr)->GlobalUboSize)},
|
||||||
|
{"MGPProgramDesc.ReservedNumSamplesOffset", offsetof(MGPProgramDesc, ReservedNumSamplesOffset), sizeof(((MGPProgramDesc*)nullptr)->ReservedNumSamplesOffset)},
|
||||||
|
{"MGPProgramDesc.SpirvStatus", offsetof(MGPProgramDesc, SpirvStatus), sizeof(((MGPProgramDesc*)nullptr)->SpirvStatus)},
|
||||||
|
{"MGPProgramDesc.NativeFloat64", offsetof(MGPProgramDesc, NativeFloat64), sizeof(((MGPProgramDesc*)nullptr)->NativeFloat64)},
|
||||||
|
{"MGPProgramDesc.PointSizeDemoted", offsetof(MGPProgramDesc, PointSizeDemoted), sizeof(((MGPProgramDesc*)nullptr)->PointSizeDemoted)},
|
||||||
|
{"MGPProgramDesc.EnableSpirvValidation", offsetof(MGPProgramDesc, EnableSpirvValidation), sizeof(((MGPProgramDesc*)nullptr)->EnableSpirvValidation)},
|
||||||
|
{"MGPProgramDesc.LinkStatus", offsetof(MGPProgramDesc, LinkStatus), sizeof(((MGPProgramDesc*)nullptr)->LinkStatus)},
|
||||||
|
{"MGPProgramDesc.Spirv", offsetof(MGPProgramDesc, Spirv), sizeof(((MGPProgramDesc*)nullptr)->Spirv)},
|
||||||
|
{"MGPProgramDesc.Reflection", offsetof(MGPProgramDesc, Reflection), sizeof(((MGPProgramDesc*)nullptr)->Reflection)},
|
||||||
|
{"MGPSurface", 0, sizeof(MGPSurface)},
|
||||||
|
{"MGPSurface.Res", offsetof(MGPSurface, Res), sizeof(((MGPSurface*)nullptr)->Res)},
|
||||||
|
{"MGPSurface.InternalFormat", offsetof(MGPSurface, InternalFormat), sizeof(((MGPSurface*)nullptr)->InternalFormat)},
|
||||||
|
{"MGPSurface.Kind", offsetof(MGPSurface, Kind), sizeof(((MGPSurface*)nullptr)->Kind)},
|
||||||
|
{"MGPSurface.Layered", offsetof(MGPSurface, Layered), sizeof(((MGPSurface*)nullptr)->Layered)},
|
||||||
|
{"MGPSurface.Level", offsetof(MGPSurface, Level), sizeof(((MGPSurface*)nullptr)->Level)},
|
||||||
|
{"MGPSurface.Layer", offsetof(MGPSurface, Layer), sizeof(((MGPSurface*)nullptr)->Layer)},
|
||||||
|
{"MGPSurface.UploadTarget", offsetof(MGPSurface, UploadTarget), sizeof(((MGPSurface*)nullptr)->UploadTarget)},
|
||||||
|
{"MGPSurface.TextureTarget", offsetof(MGPSurface, TextureTarget), sizeof(((MGPSurface*)nullptr)->TextureTarget)},
|
||||||
|
{"MGPFramebufferState", 0, sizeof(MGPFramebufferState)},
|
||||||
|
{"MGPFramebufferState.Fbo", offsetof(MGPFramebufferState, Fbo), sizeof(((MGPFramebufferState*)nullptr)->Fbo)},
|
||||||
|
{"MGPFramebufferState.Color", offsetof(MGPFramebufferState, Color), sizeof(((MGPFramebufferState*)nullptr)->Color)},
|
||||||
|
{"MGPFramebufferState.Depth", offsetof(MGPFramebufferState, Depth), sizeof(((MGPFramebufferState*)nullptr)->Depth)},
|
||||||
|
{"MGPFramebufferState.Stencil", offsetof(MGPFramebufferState, Stencil), sizeof(((MGPFramebufferState*)nullptr)->Stencil)},
|
||||||
|
{"MGPFramebufferState.ReadSurface", offsetof(MGPFramebufferState, ReadSurface), sizeof(((MGPFramebufferState*)nullptr)->ReadSurface)},
|
||||||
|
{"MGPFramebufferState.DrawBuffers", offsetof(MGPFramebufferState, DrawBuffers), sizeof(((MGPFramebufferState*)nullptr)->DrawBuffers)},
|
||||||
|
{"MGPFramebufferState.Width", offsetof(MGPFramebufferState, Width), sizeof(((MGPFramebufferState*)nullptr)->Width)},
|
||||||
|
{"MGPFramebufferState.Height", offsetof(MGPFramebufferState, Height), sizeof(((MGPFramebufferState*)nullptr)->Height)},
|
||||||
|
{"MGPFramebufferState.Layers", offsetof(MGPFramebufferState, Layers), sizeof(((MGPFramebufferState*)nullptr)->Layers)},
|
||||||
|
{"MGPFramebufferState.Samples", offsetof(MGPFramebufferState, Samples), sizeof(((MGPFramebufferState*)nullptr)->Samples)},
|
||||||
|
{"MGPFramebufferState.FixedSampleLocations", offsetof(MGPFramebufferState, FixedSampleLocations), sizeof(((MGPFramebufferState*)nullptr)->FixedSampleLocations)},
|
||||||
|
{"MGPFramebufferState.IsDefault", offsetof(MGPFramebufferState, IsDefault), sizeof(((MGPFramebufferState*)nullptr)->IsDefault)},
|
||||||
|
{"MGPFramebufferState.Complete", offsetof(MGPFramebufferState, Complete), sizeof(((MGPFramebufferState*)nullptr)->Complete)},
|
||||||
|
{"MGPFramebufferState.Target", offsetof(MGPFramebufferState, Target), sizeof(((MGPFramebufferState*)nullptr)->Target)},
|
||||||
|
{"MGPFramebufferState.ContentHash", offsetof(MGPFramebufferState, ContentHash), sizeof(((MGPFramebufferState*)nullptr)->ContentHash)},
|
||||||
|
{"MGPVertexBuffer", 0, sizeof(MGPVertexBuffer)},
|
||||||
|
{"MGPVertexBuffer.Res", offsetof(MGPVertexBuffer, Res), sizeof(((MGPVertexBuffer*)nullptr)->Res)},
|
||||||
|
{"MGPVertexBuffer.Offset", offsetof(MGPVertexBuffer, Offset), sizeof(((MGPVertexBuffer*)nullptr)->Offset)},
|
||||||
|
{"MGPVertexBuffer.Stride", offsetof(MGPVertexBuffer, Stride), sizeof(((MGPVertexBuffer*)nullptr)->Stride)},
|
||||||
|
{"MGPVertexBuffer.Divisor", offsetof(MGPVertexBuffer, Divisor), sizeof(((MGPVertexBuffer*)nullptr)->Divisor)},
|
||||||
|
{"MGPVertexBuffer.BindingIndex", offsetof(MGPVertexBuffer, BindingIndex), sizeof(((MGPVertexBuffer*)nullptr)->BindingIndex)},
|
||||||
|
{"MGPVertexBuffers", 0, sizeof(MGPVertexBuffers)},
|
||||||
|
{"MGPVertexBuffers.Start", offsetof(MGPVertexBuffers, Start), sizeof(((MGPVertexBuffers*)nullptr)->Start)},
|
||||||
|
{"MGPVertexBuffers.Count", offsetof(MGPVertexBuffers, Count), sizeof(((MGPVertexBuffers*)nullptr)->Count)},
|
||||||
|
{"MGPVertexBuffers.BaseInstance", offsetof(MGPVertexBuffers, BaseInstance), sizeof(((MGPVertexBuffers*)nullptr)->BaseInstance)},
|
||||||
|
{"MGPVertexBuffers.ContentHash", offsetof(MGPVertexBuffers, ContentHash), sizeof(((MGPVertexBuffers*)nullptr)->ContentHash)},
|
||||||
|
{"MGPIndexBuffer", 0, sizeof(MGPIndexBuffer)},
|
||||||
|
{"MGPIndexBuffer.Res", offsetof(MGPIndexBuffer, Res), sizeof(((MGPIndexBuffer*)nullptr)->Res)},
|
||||||
|
{"MGPIndexBuffer.Offset", offsetof(MGPIndexBuffer, Offset), sizeof(((MGPIndexBuffer*)nullptr)->Offset)},
|
||||||
|
{"MGPIndexBuffer.IndexSize", offsetof(MGPIndexBuffer, IndexSize), sizeof(((MGPIndexBuffer*)nullptr)->IndexSize)},
|
||||||
|
{"MGPIndirectBuffers", 0, sizeof(MGPIndirectBuffers)},
|
||||||
|
{"MGPIndirectBuffers.DrawIndirect", offsetof(MGPIndirectBuffers, DrawIndirect), sizeof(((MGPIndirectBuffers*)nullptr)->DrawIndirect)},
|
||||||
|
{"MGPIndirectBuffers.Parameter", offsetof(MGPIndirectBuffers, Parameter), sizeof(((MGPIndirectBuffers*)nullptr)->Parameter)},
|
||||||
|
{"MGPBoundView", 0, sizeof(MGPBoundView)},
|
||||||
|
{"MGPBoundView.View", offsetof(MGPBoundView, View), sizeof(((MGPBoundView*)nullptr)->View)},
|
||||||
|
{"MGPBoundView.Texture", offsetof(MGPBoundView, Texture), sizeof(((MGPBoundView*)nullptr)->Texture)},
|
||||||
|
{"MGPBoundView.Unit", offsetof(MGPBoundView, Unit), sizeof(((MGPBoundView*)nullptr)->Unit)},
|
||||||
|
{"MGPSamplerViews", 0, sizeof(MGPSamplerViews)},
|
||||||
|
{"MGPSamplerViews.Start", offsetof(MGPSamplerViews, Start), sizeof(((MGPSamplerViews*)nullptr)->Start)},
|
||||||
|
{"MGPSamplerViews.Count", offsetof(MGPSamplerViews, Count), sizeof(((MGPSamplerViews*)nullptr)->Count)},
|
||||||
|
{"MGPSamplerViews.ContentHash", offsetof(MGPSamplerViews, ContentHash), sizeof(((MGPSamplerViews*)nullptr)->ContentHash)},
|
||||||
|
{"MGPSamplerStates", 0, sizeof(MGPSamplerStates)},
|
||||||
|
{"MGPSamplerStates.Start", offsetof(MGPSamplerStates, Start), sizeof(((MGPSamplerStates*)nullptr)->Start)},
|
||||||
|
{"MGPSamplerStates.Count", offsetof(MGPSamplerStates, Count), sizeof(((MGPSamplerStates*)nullptr)->Count)},
|
||||||
|
{"MGPSamplerStates.ContentHash", offsetof(MGPSamplerStates, ContentHash), sizeof(((MGPSamplerStates*)nullptr)->ContentHash)},
|
||||||
|
{"MGPImageView", 0, sizeof(MGPImageView)},
|
||||||
|
{"MGPImageView.Res", offsetof(MGPImageView, Res), sizeof(((MGPImageView*)nullptr)->Res)},
|
||||||
|
{"MGPImageView.Unit", offsetof(MGPImageView, Unit), sizeof(((MGPImageView*)nullptr)->Unit)},
|
||||||
|
{"MGPImageView.InternalFormat", offsetof(MGPImageView, InternalFormat), sizeof(((MGPImageView*)nullptr)->InternalFormat)},
|
||||||
|
{"MGPImageView.Layer", offsetof(MGPImageView, Layer), sizeof(((MGPImageView*)nullptr)->Layer)},
|
||||||
|
{"MGPImageView.Level", offsetof(MGPImageView, Level), sizeof(((MGPImageView*)nullptr)->Level)},
|
||||||
|
{"MGPImageView.Layered", offsetof(MGPImageView, Layered), sizeof(((MGPImageView*)nullptr)->Layered)},
|
||||||
|
{"MGPImageView.Access", offsetof(MGPImageView, Access), sizeof(((MGPImageView*)nullptr)->Access)},
|
||||||
|
{"MGPShaderImages", 0, sizeof(MGPShaderImages)},
|
||||||
|
{"MGPShaderImages.Start", offsetof(MGPShaderImages, Start), sizeof(((MGPShaderImages*)nullptr)->Start)},
|
||||||
|
{"MGPShaderImages.Count", offsetof(MGPShaderImages, Count), sizeof(((MGPShaderImages*)nullptr)->Count)},
|
||||||
|
{"MGPShaderImages.ContentHash", offsetof(MGPShaderImages, ContentHash), sizeof(((MGPShaderImages*)nullptr)->ContentHash)},
|
||||||
|
{"MGPBufferRange", 0, sizeof(MGPBufferRange)},
|
||||||
|
{"MGPBufferRange.Res", offsetof(MGPBufferRange, Res), sizeof(((MGPBufferRange*)nullptr)->Res)},
|
||||||
|
{"MGPBufferRange.Offset", offsetof(MGPBufferRange, Offset), sizeof(((MGPBufferRange*)nullptr)->Offset)},
|
||||||
|
{"MGPBufferRange.Size", offsetof(MGPBufferRange, Size), sizeof(((MGPBufferRange*)nullptr)->Size)},
|
||||||
|
{"MGPShaderBuffers", 0, sizeof(MGPShaderBuffers)},
|
||||||
|
{"MGPShaderBuffers.Class", offsetof(MGPShaderBuffers, Class), sizeof(((MGPShaderBuffers*)nullptr)->Class)},
|
||||||
|
{"MGPShaderBuffers.Start", offsetof(MGPShaderBuffers, Start), sizeof(((MGPShaderBuffers*)nullptr)->Start)},
|
||||||
|
{"MGPShaderBuffers.Count", offsetof(MGPShaderBuffers, Count), sizeof(((MGPShaderBuffers*)nullptr)->Count)},
|
||||||
|
{"MGPShaderBuffers.WritableMask", offsetof(MGPShaderBuffers, WritableMask), sizeof(((MGPShaderBuffers*)nullptr)->WritableMask)},
|
||||||
|
{"MGPShaderBuffers.HostSpanCount", offsetof(MGPShaderBuffers, HostSpanCount), sizeof(((MGPShaderBuffers*)nullptr)->HostSpanCount)},
|
||||||
|
{"MGPShaderBuffers.ContentHash", offsetof(MGPShaderBuffers, ContentHash), sizeof(((MGPShaderBuffers*)nullptr)->ContentHash)},
|
||||||
|
{"MGPStreamOutputTargets", 0, sizeof(MGPStreamOutputTargets)},
|
||||||
|
{"MGPStreamOutputTargets.Count", offsetof(MGPStreamOutputTargets, Count), sizeof(((MGPStreamOutputTargets*)nullptr)->Count)},
|
||||||
|
{"MGPStreamOutputTargets.Generation", offsetof(MGPStreamOutputTargets, Generation), sizeof(((MGPStreamOutputTargets*)nullptr)->Generation)},
|
||||||
|
{"MGPStreamOutputTargets.ContentHash", offsetof(MGPStreamOutputTargets, ContentHash), sizeof(((MGPStreamOutputTargets*)nullptr)->ContentHash)},
|
||||||
|
{"MGPGlobalConstants", 0, sizeof(MGPGlobalConstants)},
|
||||||
|
{"MGPGlobalConstants.ShaderCso", offsetof(MGPGlobalConstants, ShaderCso), sizeof(((MGPGlobalConstants*)nullptr)->ShaderCso)},
|
||||||
|
{"MGPGlobalConstants.Version", offsetof(MGPGlobalConstants, Version), sizeof(((MGPGlobalConstants*)nullptr)->Version)},
|
||||||
|
{"MGPGlobalConstants.Blob", offsetof(MGPGlobalConstants, Blob), sizeof(((MGPGlobalConstants*)nullptr)->Blob)},
|
||||||
|
{"MGPAttribValue", 0, sizeof(MGPAttribValue)},
|
||||||
|
{"MGPAttribValue.Location", offsetof(MGPAttribValue, Location), sizeof(((MGPAttribValue*)nullptr)->Location)},
|
||||||
|
{"MGPAttribValue.ValueClass", offsetof(MGPAttribValue, ValueClass), sizeof(((MGPAttribValue*)nullptr)->ValueClass)},
|
||||||
|
{"MGPAttribValue.FloatView", offsetof(MGPAttribValue, FloatView), sizeof(((MGPAttribValue*)nullptr)->FloatView)},
|
||||||
|
{"MGPAttribValue.IntView", offsetof(MGPAttribValue, IntView), sizeof(((MGPAttribValue*)nullptr)->IntView)},
|
||||||
|
{"MGPAttribValue.UintView", offsetof(MGPAttribValue, UintView), sizeof(((MGPAttribValue*)nullptr)->UintView)},
|
||||||
|
{"MGPVertexAttribDefaults", 0, sizeof(MGPVertexAttribDefaults)},
|
||||||
|
{"MGPVertexAttribDefaults.Mask", offsetof(MGPVertexAttribDefaults, Mask), sizeof(((MGPVertexAttribDefaults*)nullptr)->Mask)},
|
||||||
|
{"MGPVertexAttribDefaults.Count", offsetof(MGPVertexAttribDefaults, Count), sizeof(((MGPVertexAttribDefaults*)nullptr)->Count)},
|
||||||
|
{"MGPPixelPackState", 0, sizeof(MGPPixelPackState)},
|
||||||
|
{"MGPPixelPackState.Pack", offsetof(MGPPixelPackState, Pack), sizeof(((MGPPixelPackState*)nullptr)->Pack)},
|
||||||
|
{"MGPPatchState", 0, sizeof(MGPPatchState)},
|
||||||
|
{"MGPPatchState.Vertices", offsetof(MGPPatchState, Vertices), sizeof(((MGPPatchState*)nullptr)->Vertices)},
|
||||||
|
{"MGPPatchState.Outer", offsetof(MGPPatchState, Outer), sizeof(((MGPPatchState*)nullptr)->Outer)},
|
||||||
|
{"MGPPatchState.Inner", offsetof(MGPPatchState, Inner), sizeof(((MGPPatchState*)nullptr)->Inner)},
|
||||||
|
{"ResidualValueBlock", 0, sizeof(ResidualValueBlock)},
|
||||||
|
{"ResidualValueBlock.CapabilityBits", offsetof(ResidualValueBlock, CapabilityBits), sizeof(((ResidualValueBlock*)nullptr)->CapabilityBits)},
|
||||||
|
{"MGPResidualValueState", 0, sizeof(MGPResidualValueState)},
|
||||||
|
{"MGPResidualValueState.Version", offsetof(MGPResidualValueState, Version), sizeof(((MGPResidualValueState*)nullptr)->Version)},
|
||||||
|
{"MGPResidualValueState.Blob", offsetof(MGPResidualValueState, Blob), sizeof(((MGPResidualValueState*)nullptr)->Blob)},
|
||||||
|
{"MGPSubRegion", 0, sizeof(MGPSubRegion)},
|
||||||
|
{"MGPSubRegion.X", offsetof(MGPSubRegion, X), sizeof(((MGPSubRegion*)nullptr)->X)},
|
||||||
|
{"MGPSubRegion.Y", offsetof(MGPSubRegion, Y), sizeof(((MGPSubRegion*)nullptr)->Y)},
|
||||||
|
{"MGPSubRegion.Z", offsetof(MGPSubRegion, Z), sizeof(((MGPSubRegion*)nullptr)->Z)},
|
||||||
|
{"MGPSubRegion.W", offsetof(MGPSubRegion, W), sizeof(((MGPSubRegion*)nullptr)->W)},
|
||||||
|
{"MGPSubRegion.H", offsetof(MGPSubRegion, H), sizeof(((MGPSubRegion*)nullptr)->H)},
|
||||||
|
{"MGPSubRegion.D", offsetof(MGPSubRegion, D), sizeof(((MGPSubRegion*)nullptr)->D)},
|
||||||
|
{"MGPSubRegion.SrcOffset", offsetof(MGPSubRegion, SrcOffset), sizeof(((MGPSubRegion*)nullptr)->SrcOffset)},
|
||||||
|
{"MGPSubRegion.SrcRowStride", offsetof(MGPSubRegion, SrcRowStride), sizeof(((MGPSubRegion*)nullptr)->SrcRowStride)},
|
||||||
|
{"MGPSubRegion.SrcSliceStride", offsetof(MGPSubRegion, SrcSliceStride), sizeof(((MGPSubRegion*)nullptr)->SrcSliceStride)},
|
||||||
|
{"MGPSubData", 0, sizeof(MGPSubData)},
|
||||||
|
{"MGPSubData.Res", offsetof(MGPSubData, Res), sizeof(((MGPSubData*)nullptr)->Res)},
|
||||||
|
{"MGPSubData.Target", offsetof(MGPSubData, Target), sizeof(((MGPSubData*)nullptr)->Target)},
|
||||||
|
{"MGPSubData.Level", offsetof(MGPSubData, Level), sizeof(((MGPSubData*)nullptr)->Level)},
|
||||||
|
{"MGPSubData.SourceIsVerbatimLevelShadow", offsetof(MGPSubData, SourceIsVerbatimLevelShadow), sizeof(((MGPSubData*)nullptr)->SourceIsVerbatimLevelShadow)},
|
||||||
|
{"MGPSubData.HasLiveHostWrites", offsetof(MGPSubData, HasLiveHostWrites), sizeof(((MGPSubData*)nullptr)->HasLiveHostWrites)},
|
||||||
|
{"MGPSubData.UnionBox", offsetof(MGPSubData, UnionBox), sizeof(((MGPSubData*)nullptr)->UnionBox)},
|
||||||
|
{"MGPSubData.RegionCount", offsetof(MGPSubData, RegionCount), sizeof(((MGPSubData*)nullptr)->RegionCount)},
|
||||||
|
{"MGPSubData.Blob", offsetof(MGPSubData, Blob), sizeof(((MGPSubData*)nullptr)->Blob)},
|
||||||
|
{"MGPSubData.LevelWidth", offsetof(MGPSubData, LevelWidth), sizeof(((MGPSubData*)nullptr)->LevelWidth)},
|
||||||
|
{"MGPSubData.LevelHeight", offsetof(MGPSubData, LevelHeight), sizeof(((MGPSubData*)nullptr)->LevelHeight)},
|
||||||
|
{"MGPSubData.LevelDepth", offsetof(MGPSubData, LevelDepth), sizeof(((MGPSubData*)nullptr)->LevelDepth)},
|
||||||
|
{"MGPSubData.LevelPad", offsetof(MGPSubData, LevelPad), sizeof(((MGPSubData*)nullptr)->LevelPad)},
|
||||||
|
{"MGPSubDataComplete", 0, sizeof(MGPSubDataComplete)},
|
||||||
|
{"MGPSubDataComplete.Res", offsetof(MGPSubDataComplete, Res), sizeof(((MGPSubDataComplete*)nullptr)->Res)},
|
||||||
|
{"MGPSubDataComplete.Target", offsetof(MGPSubDataComplete, Target), sizeof(((MGPSubDataComplete*)nullptr)->Target)},
|
||||||
|
{"MGPSubDataComplete.FirstLevel", offsetof(MGPSubDataComplete, FirstLevel), sizeof(((MGPSubDataComplete*)nullptr)->FirstLevel)},
|
||||||
|
{"MGPSubDataComplete.LevelCount", offsetof(MGPSubDataComplete, LevelCount), sizeof(((MGPSubDataComplete*)nullptr)->LevelCount)},
|
||||||
|
{"MGPSubDataComplete.PullSerial", offsetof(MGPSubDataComplete, PullSerial), sizeof(((MGPSubDataComplete*)nullptr)->PullSerial)},
|
||||||
|
{"MGPFlushRange", 0, sizeof(MGPFlushRange)},
|
||||||
|
{"MGPFlushRange.Res", offsetof(MGPFlushRange, Res), sizeof(((MGPFlushRange*)nullptr)->Res)},
|
||||||
|
{"MGPFlushRange.Offset", offsetof(MGPFlushRange, Offset), sizeof(((MGPFlushRange*)nullptr)->Offset)},
|
||||||
|
{"MGPFlushRange.Size", offsetof(MGPFlushRange, Size), sizeof(((MGPFlushRange*)nullptr)->Size)},
|
||||||
|
{"MGPFlushRange.AccessFlags", offsetof(MGPFlushRange, AccessFlags), sizeof(((MGPFlushRange*)nullptr)->AccessFlags)},
|
||||||
|
{"MGPReadback", 0, sizeof(MGPReadback)},
|
||||||
|
{"MGPReadback.Res", offsetof(MGPReadback, Res), sizeof(((MGPReadback*)nullptr)->Res)},
|
||||||
|
{"MGPReadback.Offset", offsetof(MGPReadback, Offset), sizeof(((MGPReadback*)nullptr)->Offset)},
|
||||||
|
{"MGPReadback.Size", offsetof(MGPReadback, Size), sizeof(((MGPReadback*)nullptr)->Size)},
|
||||||
|
{"MGPCopyRegion", 0, sizeof(MGPCopyRegion)},
|
||||||
|
{"MGPCopyRegion.Src", offsetof(MGPCopyRegion, Src), sizeof(((MGPCopyRegion*)nullptr)->Src)},
|
||||||
|
{"MGPCopyRegion.Dst", offsetof(MGPCopyRegion, Dst), sizeof(((MGPCopyRegion*)nullptr)->Dst)},
|
||||||
|
{"MGPCopyRegion.SrcBox", offsetof(MGPCopyRegion, SrcBox), sizeof(((MGPCopyRegion*)nullptr)->SrcBox)},
|
||||||
|
{"MGPCopyRegion.DstX", offsetof(MGPCopyRegion, DstX), sizeof(((MGPCopyRegion*)nullptr)->DstX)},
|
||||||
|
{"MGPCopyRegion.DstY", offsetof(MGPCopyRegion, DstY), sizeof(((MGPCopyRegion*)nullptr)->DstY)},
|
||||||
|
{"MGPCopyRegion.DstZ", offsetof(MGPCopyRegion, DstZ), sizeof(((MGPCopyRegion*)nullptr)->DstZ)},
|
||||||
|
{"MGPCopyRegion.SrcTarget", offsetof(MGPCopyRegion, SrcTarget), sizeof(((MGPCopyRegion*)nullptr)->SrcTarget)},
|
||||||
|
{"MGPCopyRegion.DstTarget", offsetof(MGPCopyRegion, DstTarget), sizeof(((MGPCopyRegion*)nullptr)->DstTarget)},
|
||||||
|
{"MGPCopyRegion.SrcLevel", offsetof(MGPCopyRegion, SrcLevel), sizeof(((MGPCopyRegion*)nullptr)->SrcLevel)},
|
||||||
|
{"MGPCopyRegion.DstLevel", offsetof(MGPCopyRegion, DstLevel), sizeof(((MGPCopyRegion*)nullptr)->DstLevel)},
|
||||||
|
{"MGPCopyRegion.SrcGlName", offsetof(MGPCopyRegion, SrcGlName), sizeof(((MGPCopyRegion*)nullptr)->SrcGlName)},
|
||||||
|
{"MGPCopyRegion.DstGlName", offsetof(MGPCopyRegion, DstGlName), sizeof(((MGPCopyRegion*)nullptr)->DstGlName)},
|
||||||
|
{"MGPBlit", 0, sizeof(MGPBlit)},
|
||||||
|
{"MGPBlit.ReadFbo", offsetof(MGPBlit, ReadFbo), sizeof(((MGPBlit*)nullptr)->ReadFbo)},
|
||||||
|
{"MGPBlit.DrawFbo", offsetof(MGPBlit, DrawFbo), sizeof(((MGPBlit*)nullptr)->DrawFbo)},
|
||||||
|
{"MGPBlit.SrcX0", offsetof(MGPBlit, SrcX0), sizeof(((MGPBlit*)nullptr)->SrcX0)},
|
||||||
|
{"MGPBlit.SrcY0", offsetof(MGPBlit, SrcY0), sizeof(((MGPBlit*)nullptr)->SrcY0)},
|
||||||
|
{"MGPBlit.SrcX1", offsetof(MGPBlit, SrcX1), sizeof(((MGPBlit*)nullptr)->SrcX1)},
|
||||||
|
{"MGPBlit.SrcY1", offsetof(MGPBlit, SrcY1), sizeof(((MGPBlit*)nullptr)->SrcY1)},
|
||||||
|
{"MGPBlit.DstX0", offsetof(MGPBlit, DstX0), sizeof(((MGPBlit*)nullptr)->DstX0)},
|
||||||
|
{"MGPBlit.DstY0", offsetof(MGPBlit, DstY0), sizeof(((MGPBlit*)nullptr)->DstY0)},
|
||||||
|
{"MGPBlit.DstX1", offsetof(MGPBlit, DstX1), sizeof(((MGPBlit*)nullptr)->DstX1)},
|
||||||
|
{"MGPBlit.DstY1", offsetof(MGPBlit, DstY1), sizeof(((MGPBlit*)nullptr)->DstY1)},
|
||||||
|
{"MGPBlit.Mask", offsetof(MGPBlit, Mask), sizeof(((MGPBlit*)nullptr)->Mask)},
|
||||||
|
{"MGPBlit.Filter", offsetof(MGPBlit, Filter), sizeof(((MGPBlit*)nullptr)->Filter)},
|
||||||
|
{"MGPClear", 0, sizeof(MGPClear)},
|
||||||
|
{"MGPClear.Fbo", offsetof(MGPClear, Fbo), sizeof(((MGPClear*)nullptr)->Fbo)},
|
||||||
|
{"MGPClear.Kind", offsetof(MGPClear, Kind), sizeof(((MGPClear*)nullptr)->Kind)},
|
||||||
|
{"MGPClear.DrawBufferIndex", offsetof(MGPClear, DrawBufferIndex), sizeof(((MGPClear*)nullptr)->DrawBufferIndex)},
|
||||||
|
{"MGPClear.BufferMask", offsetof(MGPClear, BufferMask), sizeof(((MGPClear*)nullptr)->BufferMask)},
|
||||||
|
{"MGPClear.ValueClass", offsetof(MGPClear, ValueClass), sizeof(((MGPClear*)nullptr)->ValueClass)},
|
||||||
|
{"MGPClear.ColorValue", offsetof(MGPClear, ColorValue), sizeof(((MGPClear*)nullptr)->ColorValue)},
|
||||||
|
{"MGPClear.DepthValue", offsetof(MGPClear, DepthValue), sizeof(((MGPClear*)nullptr)->DepthValue)},
|
||||||
|
{"MGPClear.StencilValue", offsetof(MGPClear, StencilValue), sizeof(((MGPClear*)nullptr)->StencilValue)},
|
||||||
|
{"MGPMipPlan", 0, sizeof(MGPMipPlan)},
|
||||||
|
{"MGPMipPlan.Res", offsetof(MGPMipPlan, Res), sizeof(((MGPMipPlan*)nullptr)->Res)},
|
||||||
|
{"MGPMipPlan.Target", offsetof(MGPMipPlan, Target), sizeof(((MGPMipPlan*)nullptr)->Target)},
|
||||||
|
{"MGPMipPlan.BaseLevel", offsetof(MGPMipPlan, BaseLevel), sizeof(((MGPMipPlan*)nullptr)->BaseLevel)},
|
||||||
|
{"MGPMipPlan.LevelCount", offsetof(MGPMipPlan, LevelCount), sizeof(((MGPMipPlan*)nullptr)->LevelCount)},
|
||||||
|
{"MGPReadbackInfo", 0, sizeof(MGPReadbackInfo)},
|
||||||
|
{"MGPReadbackInfo.Res", offsetof(MGPReadbackInfo, Res), sizeof(((MGPReadbackInfo*)nullptr)->Res)},
|
||||||
|
{"MGPReadbackInfo.Box", offsetof(MGPReadbackInfo, Box), sizeof(((MGPReadbackInfo*)nullptr)->Box)},
|
||||||
|
{"MGPReadbackInfo.Format", offsetof(MGPReadbackInfo, Format), sizeof(((MGPReadbackInfo*)nullptr)->Format)},
|
||||||
|
{"MGPReadbackInfo.Type", offsetof(MGPReadbackInfo, Type), sizeof(((MGPReadbackInfo*)nullptr)->Type)},
|
||||||
|
{"MGPReadbackInfo.Target", offsetof(MGPReadbackInfo, Target), sizeof(((MGPReadbackInfo*)nullptr)->Target)},
|
||||||
|
{"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)},
|
||||||
|
{"MGPDrawInfo", 0, sizeof(MGPDrawInfo)},
|
||||||
|
{"MGPDrawInfo.Mode", offsetof(MGPDrawInfo, Mode), sizeof(((MGPDrawInfo*)nullptr)->Mode)},
|
||||||
|
{"MGPDrawInfo.IndexSize", offsetof(MGPDrawInfo, IndexSize), sizeof(((MGPDrawInfo*)nullptr)->IndexSize)},
|
||||||
|
{"MGPDrawInfo.Flags", offsetof(MGPDrawInfo, Flags), sizeof(((MGPDrawInfo*)nullptr)->Flags)},
|
||||||
|
{"MGPDrawInfo.InstanceCount", offsetof(MGPDrawInfo, InstanceCount), sizeof(((MGPDrawInfo*)nullptr)->InstanceCount)},
|
||||||
|
{"MGPDrawInfo.StartInstance", offsetof(MGPDrawInfo, StartInstance), sizeof(((MGPDrawInfo*)nullptr)->StartInstance)},
|
||||||
|
{"MGPDrawInfo.RestartIndex", offsetof(MGPDrawInfo, RestartIndex), sizeof(((MGPDrawInfo*)nullptr)->RestartIndex)},
|
||||||
|
{"MGPDrawInfo.DrawIdOffset", offsetof(MGPDrawInfo, DrawIdOffset), sizeof(((MGPDrawInfo*)nullptr)->DrawIdOffset)},
|
||||||
|
{"MGPDrawInfo.IndexResource", offsetof(MGPDrawInfo, IndexResource), sizeof(((MGPDrawInfo*)nullptr)->IndexResource)},
|
||||||
|
{"MGPDrawInfo.MinIndex", offsetof(MGPDrawInfo, MinIndex), sizeof(((MGPDrawInfo*)nullptr)->MinIndex)},
|
||||||
|
{"MGPDrawInfo.MaxIndex", offsetof(MGPDrawInfo, MaxIndex), sizeof(((MGPDrawInfo*)nullptr)->MaxIndex)},
|
||||||
|
{"MGPDrawInfo.XfbCpuCapturedVertices", offsetof(MGPDrawInfo, XfbCpuCapturedVertices), sizeof(((MGPDrawInfo*)nullptr)->XfbCpuCapturedVertices)},
|
||||||
|
{"MGPDrawInfo.NumDraws", offsetof(MGPDrawInfo, NumDraws), sizeof(((MGPDrawInfo*)nullptr)->NumDraws)},
|
||||||
|
{"MGPDrawRange", 0, sizeof(MGPDrawRange)},
|
||||||
|
{"MGPDrawRange.Start", offsetof(MGPDrawRange, Start), sizeof(((MGPDrawRange*)nullptr)->Start)},
|
||||||
|
{"MGPDrawRange.Count", offsetof(MGPDrawRange, Count), sizeof(((MGPDrawRange*)nullptr)->Count)},
|
||||||
|
{"MGPDrawRange.IndexBias", offsetof(MGPDrawRange, IndexBias), sizeof(((MGPDrawRange*)nullptr)->IndexBias)},
|
||||||
|
{"MGPDrawIndirect", 0, sizeof(MGPDrawIndirect)},
|
||||||
|
{"MGPDrawIndirect.Buffer", offsetof(MGPDrawIndirect, Buffer), sizeof(((MGPDrawIndirect*)nullptr)->Buffer)},
|
||||||
|
{"MGPDrawIndirect.ParameterBuffer", offsetof(MGPDrawIndirect, ParameterBuffer), sizeof(((MGPDrawIndirect*)nullptr)->ParameterBuffer)},
|
||||||
|
{"MGPDrawIndirect.Offset", offsetof(MGPDrawIndirect, Offset), sizeof(((MGPDrawIndirect*)nullptr)->Offset)},
|
||||||
|
{"MGPDrawIndirect.ParameterOffset", offsetof(MGPDrawIndirect, ParameterOffset), sizeof(((MGPDrawIndirect*)nullptr)->ParameterOffset)},
|
||||||
|
{"MGPDrawIndirect.Stride", offsetof(MGPDrawIndirect, Stride), sizeof(((MGPDrawIndirect*)nullptr)->Stride)},
|
||||||
|
{"MGPDrawIndirect.DrawCount", offsetof(MGPDrawIndirect, DrawCount), sizeof(((MGPDrawIndirect*)nullptr)->DrawCount)},
|
||||||
|
{"MGPGridInfo", 0, sizeof(MGPGridInfo)},
|
||||||
|
{"MGPGridInfo.GridX", offsetof(MGPGridInfo, GridX), sizeof(((MGPGridInfo*)nullptr)->GridX)},
|
||||||
|
{"MGPGridInfo.GridY", offsetof(MGPGridInfo, GridY), sizeof(((MGPGridInfo*)nullptr)->GridY)},
|
||||||
|
{"MGPGridInfo.GridZ", offsetof(MGPGridInfo, GridZ), sizeof(((MGPGridInfo*)nullptr)->GridZ)},
|
||||||
|
{"MGPGridInfo.BlockX", offsetof(MGPGridInfo, BlockX), sizeof(((MGPGridInfo*)nullptr)->BlockX)},
|
||||||
|
{"MGPGridInfo.BlockY", offsetof(MGPGridInfo, BlockY), sizeof(((MGPGridInfo*)nullptr)->BlockY)},
|
||||||
|
{"MGPGridInfo.BlockZ", offsetof(MGPGridInfo, BlockZ), sizeof(((MGPGridInfo*)nullptr)->BlockZ)},
|
||||||
|
{"MGPGridInfo.IndirectBuffer", offsetof(MGPGridInfo, IndirectBuffer), sizeof(((MGPGridInfo*)nullptr)->IndirectBuffer)},
|
||||||
|
{"MGPGridInfo.IndirectOffset", offsetof(MGPGridInfo, IndirectOffset), sizeof(((MGPGridInfo*)nullptr)->IndirectOffset)},
|
||||||
|
{"MGPGridInfo.IsIndirect", offsetof(MGPGridInfo, IsIndirect), sizeof(((MGPGridInfo*)nullptr)->IsIndirect)},
|
||||||
|
{"MGPMemoryBarrier", 0, sizeof(MGPMemoryBarrier)},
|
||||||
|
{"MGPMemoryBarrier.Bits", offsetof(MGPMemoryBarrier, Bits), sizeof(((MGPMemoryBarrier*)nullptr)->Bits)},
|
||||||
|
{"MGPMemoryBarrier.ByRegion", offsetof(MGPMemoryBarrier, ByRegion), sizeof(((MGPMemoryBarrier*)nullptr)->ByRegion)},
|
||||||
|
{"MGPStreamOutputBegin", 0, sizeof(MGPStreamOutputBegin)},
|
||||||
|
{"MGPStreamOutputBegin.PrimitiveMode", offsetof(MGPStreamOutputBegin, PrimitiveMode), sizeof(((MGPStreamOutputBegin*)nullptr)->PrimitiveMode)},
|
||||||
|
{"MGPStreamOutputBegin.CaptureProgram", offsetof(MGPStreamOutputBegin, CaptureProgram), sizeof(((MGPStreamOutputBegin*)nullptr)->CaptureProgram)},
|
||||||
|
{"MGPStreamOutputBegin.LifetimeId", offsetof(MGPStreamOutputBegin, LifetimeId), sizeof(((MGPStreamOutputBegin*)nullptr)->LifetimeId)},
|
||||||
|
{"MGPStreamOutputBegin.Targets", offsetof(MGPStreamOutputBegin, Targets), sizeof(((MGPStreamOutputBegin*)nullptr)->Targets)},
|
||||||
|
{"MGPXfbAccounting", 0, sizeof(MGPXfbAccounting)},
|
||||||
|
{"MGPXfbAccounting.CapturedVertices", offsetof(MGPXfbAccounting, CapturedVertices), sizeof(((MGPXfbAccounting*)nullptr)->CapturedVertices)},
|
||||||
|
{"MGPXfbAccounting.PrimitivesWritten", offsetof(MGPXfbAccounting, PrimitivesWritten), sizeof(((MGPXfbAccounting*)nullptr)->PrimitivesWritten)},
|
||||||
|
{"MGPXfbAccounting.PrimitiveMode", offsetof(MGPXfbAccounting, PrimitiveMode), sizeof(((MGPXfbAccounting*)nullptr)->PrimitiveMode)},
|
||||||
|
{"MGPStreamOutputControl", 0, sizeof(MGPStreamOutputControl)},
|
||||||
|
{"MGPStreamOutputControl.Reserved", offsetof(MGPStreamOutputControl, Reserved), sizeof(((MGPStreamOutputControl*)nullptr)->Reserved)},
|
||||||
|
{"MGPFlush", 0, sizeof(MGPFlush)},
|
||||||
|
{"MGPFlush.Flags", offsetof(MGPFlush, Flags), sizeof(((MGPFlush*)nullptr)->Flags)},
|
||||||
|
{"MGPPresent", 0, sizeof(MGPPresent)},
|
||||||
|
{"MGPPresent.FrameSerial", offsetof(MGPPresent, FrameSerial), sizeof(((MGPPresent*)nullptr)->FrameSerial)},
|
||||||
|
{"MGPSwapInterval", 0, sizeof(MGPSwapInterval)},
|
||||||
|
{"MGPSwapInterval.Interval", offsetof(MGPSwapInterval, Interval), sizeof(((MGPSwapInterval*)nullptr)->Interval)},
|
||||||
|
{"MGPSurfaceInfo", 0, sizeof(MGPSurfaceInfo)},
|
||||||
|
{"MGPSurfaceInfo.Width", offsetof(MGPSurfaceInfo, Width), sizeof(((MGPSurfaceInfo*)nullptr)->Width)},
|
||||||
|
{"MGPSurfaceInfo.Height", offsetof(MGPSurfaceInfo, Height), sizeof(((MGPSurfaceInfo*)nullptr)->Height)},
|
||||||
|
{"MGPSurfaceInfo.InternalFormat", offsetof(MGPSurfaceInfo, InternalFormat), sizeof(((MGPSurfaceInfo*)nullptr)->InternalFormat)},
|
||||||
|
{"MGPSurfaceInfo.Samples", offsetof(MGPSurfaceInfo, Samples), sizeof(((MGPSurfaceInfo*)nullptr)->Samples)},
|
||||||
|
{"MGPSurfaceInfo.Layers", offsetof(MGPSurfaceInfo, Layers), sizeof(((MGPSurfaceInfo*)nullptr)->Layers)},
|
||||||
|
{"MGPSurfaceInfo.IsDefault", offsetof(MGPSurfaceInfo, IsDefault), sizeof(((MGPSurfaceInfo*)nullptr)->IsDefault)},
|
||||||
|
{"MGPImageBind", 0, sizeof(MGPImageBind)},
|
||||||
|
{"MGPImageBind.Res", offsetof(MGPImageBind, Res), sizeof(((MGPImageBind*)nullptr)->Res)},
|
||||||
|
{"MGPImageBind.Unit", offsetof(MGPImageBind, Unit), sizeof(((MGPImageBind*)nullptr)->Unit)},
|
||||||
|
{"MGPImageBind.GlName", offsetof(MGPImageBind, GlName), sizeof(((MGPImageBind*)nullptr)->GlName)},
|
||||||
|
{"MGPImageBind.Level", offsetof(MGPImageBind, Level), sizeof(((MGPImageBind*)nullptr)->Level)},
|
||||||
|
{"MGPImageBind.Layer", offsetof(MGPImageBind, Layer), sizeof(((MGPImageBind*)nullptr)->Layer)},
|
||||||
|
{"MGPImageBind.Access", offsetof(MGPImageBind, Access), sizeof(((MGPImageBind*)nullptr)->Access)},
|
||||||
|
{"MGPImageBind.Format", offsetof(MGPImageBind, Format), sizeof(((MGPImageBind*)nullptr)->Format)},
|
||||||
|
{"MGPImageBind.Layered", offsetof(MGPImageBind, Layered), sizeof(((MGPImageBind*)nullptr)->Layered)},
|
||||||
|
{"MGPPatchParameter", 0, sizeof(MGPPatchParameter)},
|
||||||
|
{"MGPPatchParameter.Pname", offsetof(MGPPatchParameter, Pname), sizeof(((MGPPatchParameter*)nullptr)->Pname)},
|
||||||
|
{"MGPPatchParameter.Value", offsetof(MGPPatchParameter, Value), sizeof(((MGPPatchParameter*)nullptr)->Value)},
|
||||||
|
{"MGPStreamOutputBind", 0, sizeof(MGPStreamOutputBind)},
|
||||||
|
{"MGPStreamOutputBind.GlName", offsetof(MGPStreamOutputBind, GlName), sizeof(((MGPStreamOutputBind*)nullptr)->GlName)},
|
||||||
|
{"MGPStreamOutputBind.LifetimeId", offsetof(MGPStreamOutputBind, LifetimeId), sizeof(((MGPStreamOutputBind*)nullptr)->LifetimeId)},
|
||||||
|
{"MGPStorageBlockBinding", 0, sizeof(MGPStorageBlockBinding)},
|
||||||
|
{"MGPStorageBlockBinding.ShaderCso", offsetof(MGPStorageBlockBinding, ShaderCso), sizeof(((MGPStorageBlockBinding*)nullptr)->ShaderCso)},
|
||||||
|
{"MGPStorageBlockBinding.GlName", offsetof(MGPStorageBlockBinding, GlName), sizeof(((MGPStorageBlockBinding*)nullptr)->GlName)},
|
||||||
|
{"MGPStorageBlockBinding.Binding", offsetof(MGPStorageBlockBinding, Binding), sizeof(((MGPStorageBlockBinding*)nullptr)->Binding)},
|
||||||
|
{"MGPStorageBlockBinding.Name", offsetof(MGPStorageBlockBinding, Name), sizeof(((MGPStorageBlockBinding*)nullptr)->Name)},
|
||||||
|
{"MGPCopyFromFramebuffer", 0, sizeof(MGPCopyFromFramebuffer)},
|
||||||
|
{"MGPCopyFromFramebuffer.Dst", offsetof(MGPCopyFromFramebuffer, Dst), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Dst)},
|
||||||
|
{"MGPCopyFromFramebuffer.Target", offsetof(MGPCopyFromFramebuffer, Target), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Target)},
|
||||||
|
{"MGPCopyFromFramebuffer.Level", offsetof(MGPCopyFromFramebuffer, Level), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Level)},
|
||||||
|
{"MGPCopyFromFramebuffer.InternalFormat", offsetof(MGPCopyFromFramebuffer, InternalFormat), sizeof(((MGPCopyFromFramebuffer*)nullptr)->InternalFormat)},
|
||||||
|
{"MGPCopyFromFramebuffer.X", offsetof(MGPCopyFromFramebuffer, X), sizeof(((MGPCopyFromFramebuffer*)nullptr)->X)},
|
||||||
|
{"MGPCopyFromFramebuffer.Y", offsetof(MGPCopyFromFramebuffer, Y), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Y)},
|
||||||
|
{"MGPCopyFromFramebuffer.Width", offsetof(MGPCopyFromFramebuffer, Width), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Width)},
|
||||||
|
{"MGPCopyFromFramebuffer.Height", offsetof(MGPCopyFromFramebuffer, Height), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Height)},
|
||||||
|
{"MGPCopyFromFramebuffer.XOffset", offsetof(MGPCopyFromFramebuffer, XOffset), sizeof(((MGPCopyFromFramebuffer*)nullptr)->XOffset)},
|
||||||
|
{"MGPCopyFromFramebuffer.YOffset", offsetof(MGPCopyFromFramebuffer, YOffset), sizeof(((MGPCopyFromFramebuffer*)nullptr)->YOffset)},
|
||||||
|
{"MGPCopyFromFramebuffer.SubImage", offsetof(MGPCopyFromFramebuffer, SubImage), sizeof(((MGPCopyFromFramebuffer*)nullptr)->SubImage)},
|
||||||
|
{"MGPApplierReset", 0, sizeof(MGPApplierReset)},
|
||||||
|
{"MGPApplierReset.ContextSerial", offsetof(MGPApplierReset, ContextSerial), sizeof(((MGPApplierReset*)nullptr)->ContextSerial)},
|
||||||
|
{"MGPContextValues", 0, sizeof(MGPContextValues)},
|
||||||
|
{"MGPContextValues.ActiveTextureUnit", offsetof(MGPContextValues, ActiveTextureUnit), sizeof(((MGPContextValues*)nullptr)->ActiveTextureUnit)},
|
||||||
|
{"MGPContextValues.MaxTouchedTextureUnit", offsetof(MGPContextValues, MaxTouchedTextureUnit), sizeof(((MGPContextValues*)nullptr)->MaxTouchedTextureUnit)},
|
||||||
|
{"MGPContextValues.TouchedBufferBindingPointCount", offsetof(MGPContextValues, TouchedBufferBindingPointCount), sizeof(((MGPContextValues*)nullptr)->TouchedBufferBindingPointCount)},
|
||||||
|
{"MGPContextValues.IsTransformFeedbackActive", offsetof(MGPContextValues, IsTransformFeedbackActive), sizeof(((MGPContextValues*)nullptr)->IsTransformFeedbackActive)},
|
||||||
|
{"MGPContextValues.IsTransformFeedbackPaused", offsetof(MGPContextValues, IsTransformFeedbackPaused), sizeof(((MGPContextValues*)nullptr)->IsTransformFeedbackPaused)},
|
||||||
|
{"MGPContextValues.TransformFeedbackGeneration", offsetof(MGPContextValues, TransformFeedbackGeneration), sizeof(((MGPContextValues*)nullptr)->TransformFeedbackGeneration)},
|
||||||
|
{"MGPContextValues.BoundTransformFeedbackLifetimeId", offsetof(MGPContextValues, BoundTransformFeedbackLifetimeId), sizeof(((MGPContextValues*)nullptr)->BoundTransformFeedbackLifetimeId)},
|
||||||
|
{"MGPContextValues.TransformFeedbackCapturedVertices", offsetof(MGPContextValues, TransformFeedbackCapturedVertices), sizeof(((MGPContextValues*)nullptr)->TransformFeedbackCapturedVertices)},
|
||||||
|
{"MGPProgramBindings", 0, sizeof(MGPProgramBindings)},
|
||||||
|
{"MGPProgramBindings.Cso", offsetof(MGPProgramBindings, Cso), sizeof(((MGPProgramBindings*)nullptr)->Cso)},
|
||||||
|
{"MGPProgramBindings.Signature", offsetof(MGPProgramBindings, Signature), sizeof(((MGPProgramBindings*)nullptr)->Signature)},
|
||||||
|
{"MGPProgramBindings.BlockBindingCount", offsetof(MGPProgramBindings, BlockBindingCount), sizeof(((MGPProgramBindings*)nullptr)->BlockBindingCount)},
|
||||||
|
{"MGPProgramBindings.SamplerUnitCount", offsetof(MGPProgramBindings, SamplerUnitCount), sizeof(((MGPProgramBindings*)nullptr)->SamplerUnitCount)},
|
||||||
|
{"MGPProgramBindings.StorageOverrideCount", offsetof(MGPProgramBindings, StorageOverrideCount), sizeof(((MGPProgramBindings*)nullptr)->StorageOverrideCount)},
|
||||||
|
{"MGPProgramSamplerUnit", 0, sizeof(MGPProgramSamplerUnit)},
|
||||||
|
{"MGPProgramSamplerUnit.Location", offsetof(MGPProgramSamplerUnit, Location), sizeof(((MGPProgramSamplerUnit*)nullptr)->Location)},
|
||||||
|
{"MGPProgramSamplerUnit.Unit", offsetof(MGPProgramSamplerUnit, Unit), sizeof(((MGPProgramSamplerUnit*)nullptr)->Unit)},
|
||||||
|
{"MGPProgramStorageOverride", 0, sizeof(MGPProgramStorageOverride)},
|
||||||
|
{"MGPProgramStorageOverride.Name", offsetof(MGPProgramStorageOverride, Name), sizeof(((MGPProgramStorageOverride*)nullptr)->Name)},
|
||||||
|
{"MGPProgramStorageOverride.Binding", offsetof(MGPProgramStorageOverride, Binding), sizeof(((MGPProgramStorageOverride*)nullptr)->Binding)},
|
||||||
|
{"RenderStateParameters", 0, sizeof(RenderStateParameters)},
|
||||||
|
{"RenderStateParameters.Viewports", offsetof(RenderStateParameters, Viewports), sizeof(((RenderStateParameters*)nullptr)->Viewports)},
|
||||||
|
{"RenderStateParameters.LineWidth", offsetof(RenderStateParameters, LineWidth), sizeof(((RenderStateParameters*)nullptr)->LineWidth)},
|
||||||
|
{"RenderStateParameters.PointSize", offsetof(RenderStateParameters, PointSize), sizeof(((RenderStateParameters*)nullptr)->PointSize)},
|
||||||
|
{"RenderStateParameters.PatchVertices", offsetof(RenderStateParameters, PatchVertices), sizeof(((RenderStateParameters*)nullptr)->PatchVertices)},
|
||||||
|
{"RenderStateParameters.PatchDefaultOuterLevel", offsetof(RenderStateParameters, PatchDefaultOuterLevel), sizeof(((RenderStateParameters*)nullptr)->PatchDefaultOuterLevel)},
|
||||||
|
{"RenderStateParameters.PatchDefaultInnerLevel", offsetof(RenderStateParameters, PatchDefaultInnerLevel), sizeof(((RenderStateParameters*)nullptr)->PatchDefaultInnerLevel)},
|
||||||
|
{"RenderStateParameters.PolygonOffsetFactor", offsetof(RenderStateParameters, PolygonOffsetFactor), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetFactor)},
|
||||||
|
{"RenderStateParameters.PolygonOffsetUnits", offsetof(RenderStateParameters, PolygonOffsetUnits), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetUnits)},
|
||||||
|
{"RenderStateParameters.PolygonOffsetClamp", offsetof(RenderStateParameters, PolygonOffsetClamp), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetClamp)},
|
||||||
|
{"RenderStateParameters.ClipOrigin", offsetof(RenderStateParameters, ClipOrigin), sizeof(((RenderStateParameters*)nullptr)->ClipOrigin)},
|
||||||
|
{"RenderStateParameters.ClipDepthMode", offsetof(RenderStateParameters, ClipDepthMode), sizeof(((RenderStateParameters*)nullptr)->ClipDepthMode)},
|
||||||
|
{"RenderStateParameters.BlendStates", offsetof(RenderStateParameters, BlendStates), sizeof(((RenderStateParameters*)nullptr)->BlendStates)},
|
||||||
|
{"RenderStateParameters.LogicOp", offsetof(RenderStateParameters, LogicOp), sizeof(((RenderStateParameters*)nullptr)->LogicOp)},
|
||||||
|
{"RenderStateParameters.DepthTestEnabled", offsetof(RenderStateParameters, DepthTestEnabled), sizeof(((RenderStateParameters*)nullptr)->DepthTestEnabled)},
|
||||||
|
{"RenderStateParameters.DepthFunc", offsetof(RenderStateParameters, DepthFunc), sizeof(((RenderStateParameters*)nullptr)->DepthFunc)},
|
||||||
|
{"RenderStateParameters.DepthMask", offsetof(RenderStateParameters, DepthMask), sizeof(((RenderStateParameters*)nullptr)->DepthMask)},
|
||||||
|
{"RenderStateParameters.ColorMasks", offsetof(RenderStateParameters, ColorMasks), sizeof(((RenderStateParameters*)nullptr)->ColorMasks)},
|
||||||
|
{"RenderStateParameters.FramebufferSrgbEnabled", offsetof(RenderStateParameters, FramebufferSrgbEnabled), sizeof(((RenderStateParameters*)nullptr)->FramebufferSrgbEnabled)},
|
||||||
|
{"RenderStateParameters.DepthClampEnabled", offsetof(RenderStateParameters, DepthClampEnabled), sizeof(((RenderStateParameters*)nullptr)->DepthClampEnabled)},
|
||||||
|
{"RenderStateParameters.TextureCubeMapSeamlessEnabled", offsetof(RenderStateParameters, TextureCubeMapSeamlessEnabled), sizeof(((RenderStateParameters*)nullptr)->TextureCubeMapSeamlessEnabled)},
|
||||||
|
{"RenderStateParameters.ClearColor", offsetof(RenderStateParameters, ClearColor), sizeof(((RenderStateParameters*)nullptr)->ClearColor)},
|
||||||
|
{"RenderStateParameters.ClearDepth", offsetof(RenderStateParameters, ClearDepth), sizeof(((RenderStateParameters*)nullptr)->ClearDepth)},
|
||||||
|
{"RenderStateParameters.ClearStencil", offsetof(RenderStateParameters, ClearStencil), sizeof(((RenderStateParameters*)nullptr)->ClearStencil)},
|
||||||
|
{"RenderStateParameters.BlendColor", offsetof(RenderStateParameters, BlendColor), sizeof(((RenderStateParameters*)nullptr)->BlendColor)},
|
||||||
|
{"RenderStateParameters.DepthRanges", offsetof(RenderStateParameters, DepthRanges), sizeof(((RenderStateParameters*)nullptr)->DepthRanges)},
|
||||||
|
{"RenderStateParameters.SampleCoverageValue", offsetof(RenderStateParameters, SampleCoverageValue), sizeof(((RenderStateParameters*)nullptr)->SampleCoverageValue)},
|
||||||
|
{"RenderStateParameters.SampleCoverageInvert", offsetof(RenderStateParameters, SampleCoverageInvert), sizeof(((RenderStateParameters*)nullptr)->SampleCoverageInvert)},
|
||||||
|
{"RenderStateParameters.SampleMaskValue", offsetof(RenderStateParameters, SampleMaskValue), sizeof(((RenderStateParameters*)nullptr)->SampleMaskValue)},
|
||||||
|
{"RenderStateParameters.MinSampleShadingValue", offsetof(RenderStateParameters, MinSampleShadingValue), sizeof(((RenderStateParameters*)nullptr)->MinSampleShadingValue)},
|
||||||
|
{"RenderStateParameters.StencilStates", offsetof(RenderStateParameters, StencilStates), sizeof(((RenderStateParameters*)nullptr)->StencilStates)},
|
||||||
|
{"RenderStateParameters.CullFaceEnabled", offsetof(RenderStateParameters, CullFaceEnabled), sizeof(((RenderStateParameters*)nullptr)->CullFaceEnabled)},
|
||||||
|
{"RenderStateParameters.CullFaceModeSetting", offsetof(RenderStateParameters, CullFaceModeSetting), sizeof(((RenderStateParameters*)nullptr)->CullFaceModeSetting)},
|
||||||
|
{"RenderStateParameters.FrontFaceModeSetting", offsetof(RenderStateParameters, FrontFaceModeSetting), sizeof(((RenderStateParameters*)nullptr)->FrontFaceModeSetting)},
|
||||||
|
{"RenderStateParameters.ProvokingVertexModeSetting", offsetof(RenderStateParameters, ProvokingVertexModeSetting), sizeof(((RenderStateParameters*)nullptr)->ProvokingVertexModeSetting)},
|
||||||
|
{"RenderStateParameters.LineSmoothHint", offsetof(RenderStateParameters, LineSmoothHint), sizeof(((RenderStateParameters*)nullptr)->LineSmoothHint)},
|
||||||
|
{"RenderStateParameters.PolygonSmoothHint", offsetof(RenderStateParameters, PolygonSmoothHint), sizeof(((RenderStateParameters*)nullptr)->PolygonSmoothHint)},
|
||||||
|
{"RenderStateParameters.TextureCompressionHint", offsetof(RenderStateParameters, TextureCompressionHint), sizeof(((RenderStateParameters*)nullptr)->TextureCompressionHint)},
|
||||||
|
{"RenderStateParameters.FragmentShaderDerivativeHint", offsetof(RenderStateParameters, FragmentShaderDerivativeHint), sizeof(((RenderStateParameters*)nullptr)->FragmentShaderDerivativeHint)},
|
||||||
|
{"RenderStateParameters.PointFadeThresholdSize", offsetof(RenderStateParameters, PointFadeThresholdSize), sizeof(((RenderStateParameters*)nullptr)->PointFadeThresholdSize)},
|
||||||
|
{"RenderStateParameters.PointSpriteCoordOrigin", offsetof(RenderStateParameters, PointSpriteCoordOrigin), sizeof(((RenderStateParameters*)nullptr)->PointSpriteCoordOrigin)},
|
||||||
|
{"RenderStateParameters.ClampReadColor", offsetof(RenderStateParameters, ClampReadColor), sizeof(((RenderStateParameters*)nullptr)->ClampReadColor)},
|
||||||
|
{"RenderStateParameters.PolygonModeFront", offsetof(RenderStateParameters, PolygonModeFront), sizeof(((RenderStateParameters*)nullptr)->PolygonModeFront)},
|
||||||
|
{"RenderStateParameters.PolygonModeBack", offsetof(RenderStateParameters, PolygonModeBack), sizeof(((RenderStateParameters*)nullptr)->PolygonModeBack)},
|
||||||
|
{"RenderStateParameters.PrimitiveRestartIndex", offsetof(RenderStateParameters, PrimitiveRestartIndex), sizeof(((RenderStateParameters*)nullptr)->PrimitiveRestartIndex)},
|
||||||
|
{"RenderStateParameters.ColorLogicOpEnabled", offsetof(RenderStateParameters, ColorLogicOpEnabled), sizeof(((RenderStateParameters*)nullptr)->ColorLogicOpEnabled)},
|
||||||
|
{"RenderStateParameters.DebugOutputEnabled", offsetof(RenderStateParameters, DebugOutputEnabled), sizeof(((RenderStateParameters*)nullptr)->DebugOutputEnabled)},
|
||||||
|
{"RenderStateParameters.DebugOutputSynchronousEnabled", offsetof(RenderStateParameters, DebugOutputSynchronousEnabled), sizeof(((RenderStateParameters*)nullptr)->DebugOutputSynchronousEnabled)},
|
||||||
|
{"RenderStateParameters.DitherEnabled", offsetof(RenderStateParameters, DitherEnabled), sizeof(((RenderStateParameters*)nullptr)->DitherEnabled)},
|
||||||
|
{"RenderStateParameters.LineSmoothEnabled", offsetof(RenderStateParameters, LineSmoothEnabled), sizeof(((RenderStateParameters*)nullptr)->LineSmoothEnabled)},
|
||||||
|
{"RenderStateParameters.MultisampleEnabled", offsetof(RenderStateParameters, MultisampleEnabled), sizeof(((RenderStateParameters*)nullptr)->MultisampleEnabled)},
|
||||||
|
{"RenderStateParameters.PolygonOffsetFillEnabled", offsetof(RenderStateParameters, PolygonOffsetFillEnabled), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetFillEnabled)},
|
||||||
|
{"RenderStateParameters.PolygonOffsetLineEnabled", offsetof(RenderStateParameters, PolygonOffsetLineEnabled), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetLineEnabled)},
|
||||||
|
{"RenderStateParameters.PolygonOffsetPointEnabled", offsetof(RenderStateParameters, PolygonOffsetPointEnabled), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetPointEnabled)},
|
||||||
|
{"RenderStateParameters.PolygonSmoothEnabled", offsetof(RenderStateParameters, PolygonSmoothEnabled), sizeof(((RenderStateParameters*)nullptr)->PolygonSmoothEnabled)},
|
||||||
|
{"RenderStateParameters.PrimitiveRestartEnabled", offsetof(RenderStateParameters, PrimitiveRestartEnabled), sizeof(((RenderStateParameters*)nullptr)->PrimitiveRestartEnabled)},
|
||||||
|
{"RenderStateParameters.PrimitiveRestartFixedIndexEnabled", offsetof(RenderStateParameters, PrimitiveRestartFixedIndexEnabled), sizeof(((RenderStateParameters*)nullptr)->PrimitiveRestartFixedIndexEnabled)},
|
||||||
|
{"RenderStateParameters.RasterizerDiscardEnabled", offsetof(RenderStateParameters, RasterizerDiscardEnabled), sizeof(((RenderStateParameters*)nullptr)->RasterizerDiscardEnabled)},
|
||||||
|
{"RenderStateParameters.SampleAlphaToCoverageEnabled", offsetof(RenderStateParameters, SampleAlphaToCoverageEnabled), sizeof(((RenderStateParameters*)nullptr)->SampleAlphaToCoverageEnabled)},
|
||||||
|
{"RenderStateParameters.SampleAlphaToOneEnabled", offsetof(RenderStateParameters, SampleAlphaToOneEnabled), sizeof(((RenderStateParameters*)nullptr)->SampleAlphaToOneEnabled)},
|
||||||
|
{"RenderStateParameters.SampleCoverageEnabled", offsetof(RenderStateParameters, SampleCoverageEnabled), sizeof(((RenderStateParameters*)nullptr)->SampleCoverageEnabled)},
|
||||||
|
{"RenderStateParameters.SampleMaskEnabled", offsetof(RenderStateParameters, SampleMaskEnabled), sizeof(((RenderStateParameters*)nullptr)->SampleMaskEnabled)},
|
||||||
|
{"RenderStateParameters.SampleShadingEnabled", offsetof(RenderStateParameters, SampleShadingEnabled), sizeof(((RenderStateParameters*)nullptr)->SampleShadingEnabled)},
|
||||||
|
{"RenderStateParameters.StencilTestEnabled", offsetof(RenderStateParameters, StencilTestEnabled), sizeof(((RenderStateParameters*)nullptr)->StencilTestEnabled)},
|
||||||
|
{"RenderStateParameters.ProgramPointSizeEnabled", offsetof(RenderStateParameters, ProgramPointSizeEnabled), sizeof(((RenderStateParameters*)nullptr)->ProgramPointSizeEnabled)},
|
||||||
|
{"RenderStateParameters.ScissorTestEnabledMask", offsetof(RenderStateParameters, ScissorTestEnabledMask), sizeof(((RenderStateParameters*)nullptr)->ScissorTestEnabledMask)},
|
||||||
|
{"RenderStateParameters.ScissorBoxes", offsetof(RenderStateParameters, ScissorBoxes), sizeof(((RenderStateParameters*)nullptr)->ScissorBoxes)},
|
||||||
|
{"RenderStateParameters.ScissorBoxWrittenMask", offsetof(RenderStateParameters, ScissorBoxWrittenMask), sizeof(((RenderStateParameters*)nullptr)->ScissorBoxWrittenMask)},
|
||||||
|
{"RenderStateParameters.ClipDistanceEnabledMask", offsetof(RenderStateParameters, ClipDistanceEnabledMask), sizeof(((RenderStateParameters*)nullptr)->ClipDistanceEnabledMask)},
|
||||||
|
{"PixelStoreParameters", 0, sizeof(PixelStoreParameters)},
|
||||||
|
{"PixelStoreParameters.SwapBytes", offsetof(PixelStoreParameters, SwapBytes), sizeof(((PixelStoreParameters*)nullptr)->SwapBytes)},
|
||||||
|
{"PixelStoreParameters.LSBFirst", offsetof(PixelStoreParameters, LSBFirst), sizeof(((PixelStoreParameters*)nullptr)->LSBFirst)},
|
||||||
|
{"PixelStoreParameters.RowLength", offsetof(PixelStoreParameters, RowLength), sizeof(((PixelStoreParameters*)nullptr)->RowLength)},
|
||||||
|
{"PixelStoreParameters.ImageHeight", offsetof(PixelStoreParameters, ImageHeight), sizeof(((PixelStoreParameters*)nullptr)->ImageHeight)},
|
||||||
|
{"PixelStoreParameters.SkipPixels", offsetof(PixelStoreParameters, SkipPixels), sizeof(((PixelStoreParameters*)nullptr)->SkipPixels)},
|
||||||
|
{"PixelStoreParameters.SkipRows", offsetof(PixelStoreParameters, SkipRows), sizeof(((PixelStoreParameters*)nullptr)->SkipRows)},
|
||||||
|
{"PixelStoreParameters.SkipImages", offsetof(PixelStoreParameters, SkipImages), sizeof(((PixelStoreParameters*)nullptr)->SkipImages)},
|
||||||
|
{"PixelStoreParameters.Alignment", offsetof(PixelStoreParameters, Alignment), sizeof(((PixelStoreParameters*)nullptr)->Alignment)},
|
||||||
|
{"SamplerParameters", 0, sizeof(SamplerParameters)},
|
||||||
|
{"SamplerParameters.wrapS", offsetof(SamplerParameters, wrapS), sizeof(((SamplerParameters*)nullptr)->wrapS)},
|
||||||
|
{"SamplerParameters.wrapT", offsetof(SamplerParameters, wrapT), sizeof(((SamplerParameters*)nullptr)->wrapT)},
|
||||||
|
{"SamplerParameters.wrapR", offsetof(SamplerParameters, wrapR), sizeof(((SamplerParameters*)nullptr)->wrapR)},
|
||||||
|
{"SamplerParameters.minFilter", offsetof(SamplerParameters, minFilter), sizeof(((SamplerParameters*)nullptr)->minFilter)},
|
||||||
|
{"SamplerParameters.magFilter", offsetof(SamplerParameters, magFilter), sizeof(((SamplerParameters*)nullptr)->magFilter)},
|
||||||
|
{"SamplerParameters.mipmapMode", offsetof(SamplerParameters, mipmapMode), sizeof(((SamplerParameters*)nullptr)->mipmapMode)},
|
||||||
|
{"SamplerParameters.minLod", offsetof(SamplerParameters, minLod), sizeof(((SamplerParameters*)nullptr)->minLod)},
|
||||||
|
{"SamplerParameters.maxLod", offsetof(SamplerParameters, maxLod), sizeof(((SamplerParameters*)nullptr)->maxLod)},
|
||||||
|
{"SamplerParameters.lodBias", offsetof(SamplerParameters, lodBias), sizeof(((SamplerParameters*)nullptr)->lodBias)},
|
||||||
|
{"SamplerParameters.maxAnisotropy", offsetof(SamplerParameters, maxAnisotropy), sizeof(((SamplerParameters*)nullptr)->maxAnisotropy)},
|
||||||
|
{"SamplerParameters.compareFunc", offsetof(SamplerParameters, compareFunc), sizeof(((SamplerParameters*)nullptr)->compareFunc)},
|
||||||
|
{"SamplerParameters.compareMode", offsetof(SamplerParameters, compareMode), sizeof(((SamplerParameters*)nullptr)->compareMode)},
|
||||||
|
{"SamplerParameters.borderColor", offsetof(SamplerParameters, borderColor), sizeof(((SamplerParameters*)nullptr)->borderColor)},
|
||||||
|
{"SamplerParameters.borderColorI", offsetof(SamplerParameters, borderColorI), sizeof(((SamplerParameters*)nullptr)->borderColorI)},
|
||||||
|
{"SamplerParameters.borderColorUI", offsetof(SamplerParameters, borderColorUI), sizeof(((SamplerParameters*)nullptr)->borderColorUI)},
|
||||||
|
{"SamplerParameters.borderColorForm", offsetof(SamplerParameters, borderColorForm), sizeof(((SamplerParameters*)nullptr)->borderColorForm)},
|
||||||
|
{"PerBufferBlendState", 0, sizeof(PerBufferBlendState)},
|
||||||
|
{"PerBufferBlendState.Enabled", offsetof(PerBufferBlendState, Enabled), sizeof(((PerBufferBlendState*)nullptr)->Enabled)},
|
||||||
|
{"PerBufferBlendState.SrcFactorRGB", offsetof(PerBufferBlendState, SrcFactorRGB), sizeof(((PerBufferBlendState*)nullptr)->SrcFactorRGB)},
|
||||||
|
{"PerBufferBlendState.DstFactorRGB", offsetof(PerBufferBlendState, DstFactorRGB), sizeof(((PerBufferBlendState*)nullptr)->DstFactorRGB)},
|
||||||
|
{"PerBufferBlendState.SrcFactorAlpha", offsetof(PerBufferBlendState, SrcFactorAlpha), sizeof(((PerBufferBlendState*)nullptr)->SrcFactorAlpha)},
|
||||||
|
{"PerBufferBlendState.DstFactorAlpha", offsetof(PerBufferBlendState, DstFactorAlpha), sizeof(((PerBufferBlendState*)nullptr)->DstFactorAlpha)},
|
||||||
|
{"PerBufferBlendState.ColorEquation", offsetof(PerBufferBlendState, ColorEquation), sizeof(((PerBufferBlendState*)nullptr)->ColorEquation)},
|
||||||
|
{"PerBufferBlendState.AlphaEquation", offsetof(PerBufferBlendState, AlphaEquation), sizeof(((PerBufferBlendState*)nullptr)->AlphaEquation)},
|
||||||
|
{"StencilFaceState", 0, sizeof(StencilFaceState)},
|
||||||
|
{"StencilFaceState.Func", offsetof(StencilFaceState, Func), sizeof(((StencilFaceState*)nullptr)->Func)},
|
||||||
|
{"StencilFaceState.Ref", offsetof(StencilFaceState, Ref), sizeof(((StencilFaceState*)nullptr)->Ref)},
|
||||||
|
{"StencilFaceState.ValueMask", offsetof(StencilFaceState, ValueMask), sizeof(((StencilFaceState*)nullptr)->ValueMask)},
|
||||||
|
{"StencilFaceState.WriteMask", offsetof(StencilFaceState, WriteMask), sizeof(((StencilFaceState*)nullptr)->WriteMask)},
|
||||||
|
{"StencilFaceState.FailOp", offsetof(StencilFaceState, FailOp), sizeof(((StencilFaceState*)nullptr)->FailOp)},
|
||||||
|
{"StencilFaceState.PassDepthFailOp", offsetof(StencilFaceState, PassDepthFailOp), sizeof(((StencilFaceState*)nullptr)->PassDepthFailOp)},
|
||||||
|
{"StencilFaceState.PassDepthPassOp", offsetof(StencilFaceState, PassDepthPassOp), sizeof(((StencilFaceState*)nullptr)->PassDepthPassOp)},
|
||||||
|
{"DynamicBackendParameters", 0, sizeof(DynamicBackendParameters)},
|
||||||
|
{"DynamicBackendParameters.UniformBufferOffsetAlignment", offsetof(DynamicBackendParameters, UniformBufferOffsetAlignment), sizeof(((DynamicBackendParameters*)nullptr)->UniformBufferOffsetAlignment)},
|
||||||
|
{"DynamicBackendParameters.ShaderStorageBufferOffsetAlignment", offsetof(DynamicBackendParameters, ShaderStorageBufferOffsetAlignment), sizeof(((DynamicBackendParameters*)nullptr)->ShaderStorageBufferOffsetAlignment)},
|
||||||
|
{"DynamicBackendParameters.MaxTextureMaxAnisotropy", offsetof(DynamicBackendParameters, MaxTextureMaxAnisotropy), sizeof(((DynamicBackendParameters*)nullptr)->MaxTextureMaxAnisotropy)},
|
||||||
|
{"DynamicBackendParameters.AliasedLineWidthRangeMin", offsetof(DynamicBackendParameters, AliasedLineWidthRangeMin), sizeof(((DynamicBackendParameters*)nullptr)->AliasedLineWidthRangeMin)},
|
||||||
|
{"DynamicBackendParameters.AliasedLineWidthRangeMax", offsetof(DynamicBackendParameters, AliasedLineWidthRangeMax), sizeof(((DynamicBackendParameters*)nullptr)->AliasedLineWidthRangeMax)},
|
||||||
|
{"DynamicBackendParameters.SmoothLineWidthRangeMin", offsetof(DynamicBackendParameters, SmoothLineWidthRangeMin), sizeof(((DynamicBackendParameters*)nullptr)->SmoothLineWidthRangeMin)},
|
||||||
|
{"DynamicBackendParameters.SmoothLineWidthRangeMax", offsetof(DynamicBackendParameters, SmoothLineWidthRangeMax), sizeof(((DynamicBackendParameters*)nullptr)->SmoothLineWidthRangeMax)},
|
||||||
|
{"DynamicBackendParameters.SmoothLineWidthGranularity", offsetof(DynamicBackendParameters, SmoothLineWidthGranularity), sizeof(((DynamicBackendParameters*)nullptr)->SmoothLineWidthGranularity)},
|
||||||
|
{"DynamicBackendParameters.PointSizeRangeMin", offsetof(DynamicBackendParameters, PointSizeRangeMin), sizeof(((DynamicBackendParameters*)nullptr)->PointSizeRangeMin)},
|
||||||
|
{"DynamicBackendParameters.PointSizeRangeMax", offsetof(DynamicBackendParameters, PointSizeRangeMax), sizeof(((DynamicBackendParameters*)nullptr)->PointSizeRangeMax)},
|
||||||
|
{"DynamicBackendParameters.PointSizeGranularity", offsetof(DynamicBackendParameters, PointSizeGranularity), sizeof(((DynamicBackendParameters*)nullptr)->PointSizeGranularity)},
|
||||||
|
{"DynamicBackendParameters.Max3DTextureSize", offsetof(DynamicBackendParameters, Max3DTextureSize), sizeof(((DynamicBackendParameters*)nullptr)->Max3DTextureSize)},
|
||||||
|
{"DynamicBackendParameters.MaxArrayTextureLayers", offsetof(DynamicBackendParameters, MaxArrayTextureLayers), sizeof(((DynamicBackendParameters*)nullptr)->MaxArrayTextureLayers)},
|
||||||
|
{"DynamicBackendParameters.MaxCubeMapTextureSize", offsetof(DynamicBackendParameters, MaxCubeMapTextureSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxCubeMapTextureSize)},
|
||||||
|
{"DynamicBackendParameters.MaxFramebufferWidth", offsetof(DynamicBackendParameters, MaxFramebufferWidth), sizeof(((DynamicBackendParameters*)nullptr)->MaxFramebufferWidth)},
|
||||||
|
{"DynamicBackendParameters.MaxFramebufferHeight", offsetof(DynamicBackendParameters, MaxFramebufferHeight), sizeof(((DynamicBackendParameters*)nullptr)->MaxFramebufferHeight)},
|
||||||
|
{"DynamicBackendParameters.MaxFramebufferLayers", offsetof(DynamicBackendParameters, MaxFramebufferLayers), sizeof(((DynamicBackendParameters*)nullptr)->MaxFramebufferLayers)},
|
||||||
|
{"DynamicBackendParameters.MaxRenderbufferSize", offsetof(DynamicBackendParameters, MaxRenderbufferSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxRenderbufferSize)},
|
||||||
|
{"DynamicBackendParameters.MaxTextureSize", offsetof(DynamicBackendParameters, MaxTextureSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxTextureSize)},
|
||||||
|
{"DynamicBackendParameters.MaxColorTextureSamples", offsetof(DynamicBackendParameters, MaxColorTextureSamples), sizeof(((DynamicBackendParameters*)nullptr)->MaxColorTextureSamples)},
|
||||||
|
{"DynamicBackendParameters.MaxDepthTextureSamples", offsetof(DynamicBackendParameters, MaxDepthTextureSamples), sizeof(((DynamicBackendParameters*)nullptr)->MaxDepthTextureSamples)},
|
||||||
|
{"DynamicBackendParameters.MaxFramebufferSamples", offsetof(DynamicBackendParameters, MaxFramebufferSamples), sizeof(((DynamicBackendParameters*)nullptr)->MaxFramebufferSamples)},
|
||||||
|
{"DynamicBackendParameters.MaxIntegerSamples", offsetof(DynamicBackendParameters, MaxIntegerSamples), sizeof(((DynamicBackendParameters*)nullptr)->MaxIntegerSamples)},
|
||||||
|
{"DynamicBackendParameters.MaxSamples", offsetof(DynamicBackendParameters, MaxSamples), sizeof(((DynamicBackendParameters*)nullptr)->MaxSamples)},
|
||||||
|
{"DynamicBackendParameters.MaxSampleMaskWords", offsetof(DynamicBackendParameters, MaxSampleMaskWords), sizeof(((DynamicBackendParameters*)nullptr)->MaxSampleMaskWords)},
|
||||||
|
{"DynamicBackendParameters.MaxPatchVertices", offsetof(DynamicBackendParameters, MaxPatchVertices), sizeof(((DynamicBackendParameters*)nullptr)->MaxPatchVertices)},
|
||||||
|
{"DynamicBackendParameters.MaxTessGenLevel", offsetof(DynamicBackendParameters, MaxTessGenLevel), sizeof(((DynamicBackendParameters*)nullptr)->MaxTessGenLevel)},
|
||||||
|
{"DynamicBackendParameters.MinProgramTextureGatherOffset", offsetof(DynamicBackendParameters, MinProgramTextureGatherOffset), sizeof(((DynamicBackendParameters*)nullptr)->MinProgramTextureGatherOffset)},
|
||||||
|
{"DynamicBackendParameters.MaxProgramTextureGatherOffset", offsetof(DynamicBackendParameters, MaxProgramTextureGatherOffset), sizeof(((DynamicBackendParameters*)nullptr)->MaxProgramTextureGatherOffset)},
|
||||||
|
{"DynamicBackendParameters.MaxTextureImageUnits", offsetof(DynamicBackendParameters, MaxTextureImageUnits), sizeof(((DynamicBackendParameters*)nullptr)->MaxTextureImageUnits)},
|
||||||
|
{"DynamicBackendParameters.MaxVertexTextureImageUnits", offsetof(DynamicBackendParameters, MaxVertexTextureImageUnits), sizeof(((DynamicBackendParameters*)nullptr)->MaxVertexTextureImageUnits)},
|
||||||
|
{"DynamicBackendParameters.MaxComputeTextureImageUnits", offsetof(DynamicBackendParameters, MaxComputeTextureImageUnits), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeTextureImageUnits)},
|
||||||
|
{"DynamicBackendParameters.MaxCombinedTextureImageUnits", offsetof(DynamicBackendParameters, MaxCombinedTextureImageUnits), sizeof(((DynamicBackendParameters*)nullptr)->MaxCombinedTextureImageUnits)},
|
||||||
|
{"DynamicBackendParameters.MaxVertexAttribs", offsetof(DynamicBackendParameters, MaxVertexAttribs), sizeof(((DynamicBackendParameters*)nullptr)->MaxVertexAttribs)},
|
||||||
|
{"DynamicBackendParameters.MaxComputeShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxComputeShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeShaderStorageBlocks)},
|
||||||
|
{"DynamicBackendParameters.MaxCombinedShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxCombinedShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxCombinedShaderStorageBlocks)},
|
||||||
|
{"DynamicBackendParameters.MaxVertexShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxVertexShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxVertexShaderStorageBlocks)},
|
||||||
|
{"DynamicBackendParameters.MaxTessControlShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxTessControlShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxTessControlShaderStorageBlocks)},
|
||||||
|
{"DynamicBackendParameters.MaxTessEvaluationShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxTessEvaluationShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxTessEvaluationShaderStorageBlocks)},
|
||||||
|
{"DynamicBackendParameters.MaxGeometryShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxGeometryShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxGeometryShaderStorageBlocks)},
|
||||||
|
{"DynamicBackendParameters.MaxFragmentShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxFragmentShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxFragmentShaderStorageBlocks)},
|
||||||
|
{"DynamicBackendParameters.MaxComputeUniformBlocks", offsetof(DynamicBackendParameters, MaxComputeUniformBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeUniformBlocks)},
|
||||||
|
{"DynamicBackendParameters.MaxComputeWorkGroupInvocations", offsetof(DynamicBackendParameters, MaxComputeWorkGroupInvocations), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeWorkGroupInvocations)},
|
||||||
|
{"DynamicBackendParameters.MaxComputeWorkGroupCount", offsetof(DynamicBackendParameters, MaxComputeWorkGroupCount), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeWorkGroupCount)},
|
||||||
|
{"DynamicBackendParameters.MaxComputeWorkGroupSize", offsetof(DynamicBackendParameters, MaxComputeWorkGroupSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeWorkGroupSize)},
|
||||||
|
{"DynamicBackendParameters.MaxShaderStorageBufferBindings", offsetof(DynamicBackendParameters, MaxShaderStorageBufferBindings), sizeof(((DynamicBackendParameters*)nullptr)->MaxShaderStorageBufferBindings)},
|
||||||
|
{"DynamicBackendParameters.MaxTextureBufferSize", offsetof(DynamicBackendParameters, MaxTextureBufferSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxTextureBufferSize)},
|
||||||
|
{"DynamicBackendParameters.TextureBufferOffsetAlignment", offsetof(DynamicBackendParameters, TextureBufferOffsetAlignment), sizeof(((DynamicBackendParameters*)nullptr)->TextureBufferOffsetAlignment)},
|
||||||
|
{"DynamicBackendParameters.MaxUniformBufferBindings", offsetof(DynamicBackendParameters, MaxUniformBufferBindings), sizeof(((DynamicBackendParameters*)nullptr)->MaxUniformBufferBindings)},
|
||||||
|
{"DynamicBackendParameters.MaxUniformBlockSize", offsetof(DynamicBackendParameters, MaxUniformBlockSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxUniformBlockSize)},
|
||||||
|
{"DynamicBackendParameters.MaxImageUnits", offsetof(DynamicBackendParameters, MaxImageUnits), sizeof(((DynamicBackendParameters*)nullptr)->MaxImageUnits)},
|
||||||
|
{"DynamicBackendParameters.MaxCombinedImageUniforms", offsetof(DynamicBackendParameters, MaxCombinedImageUniforms), sizeof(((DynamicBackendParameters*)nullptr)->MaxCombinedImageUniforms)},
|
||||||
|
{"DynamicBackendParameters.MaxVertexImageUniforms", offsetof(DynamicBackendParameters, MaxVertexImageUniforms), sizeof(((DynamicBackendParameters*)nullptr)->MaxVertexImageUniforms)},
|
||||||
|
{"DynamicBackendParameters.MaxGeometryImageUniforms", offsetof(DynamicBackendParameters, MaxGeometryImageUniforms), sizeof(((DynamicBackendParameters*)nullptr)->MaxGeometryImageUniforms)},
|
||||||
|
{"DynamicBackendParameters.MaxFragmentImageUniforms", offsetof(DynamicBackendParameters, MaxFragmentImageUniforms), sizeof(((DynamicBackendParameters*)nullptr)->MaxFragmentImageUniforms)},
|
||||||
|
{"DynamicBackendParameters.MaxComputeImageUniforms", offsetof(DynamicBackendParameters, MaxComputeImageUniforms), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeImageUniforms)},
|
||||||
|
{"DynamicBackendParameters.MaxDrawBuffers", offsetof(DynamicBackendParameters, MaxDrawBuffers), sizeof(((DynamicBackendParameters*)nullptr)->MaxDrawBuffers)},
|
||||||
|
{"DynamicBackendParameters.MaxColorAttachments", offsetof(DynamicBackendParameters, MaxColorAttachments), sizeof(((DynamicBackendParameters*)nullptr)->MaxColorAttachments)},
|
||||||
|
{"DynamicBackendParameters.MaxClipDistances", offsetof(DynamicBackendParameters, MaxClipDistances), sizeof(((DynamicBackendParameters*)nullptr)->MaxClipDistances)},
|
||||||
|
{"DynamicBackendParameters.MaxCullDistances", offsetof(DynamicBackendParameters, MaxCullDistances), sizeof(((DynamicBackendParameters*)nullptr)->MaxCullDistances)},
|
||||||
|
{"DynamicBackendParameters.MaxCombinedClipAndCullDistances", offsetof(DynamicBackendParameters, MaxCombinedClipAndCullDistances), sizeof(((DynamicBackendParameters*)nullptr)->MaxCombinedClipAndCullDistances)},
|
||||||
|
{"DynamicBackendParameters.MaxViewports", offsetof(DynamicBackendParameters, MaxViewports), sizeof(((DynamicBackendParameters*)nullptr)->MaxViewports)},
|
||||||
|
{"DynamicBackendParameters.LayerProvokingVertex", offsetof(DynamicBackendParameters, LayerProvokingVertex), sizeof(((DynamicBackendParameters*)nullptr)->LayerProvokingVertex)},
|
||||||
|
{"DynamicBackendParameters.ViewportIndexProvokingVertex", offsetof(DynamicBackendParameters, ViewportIndexProvokingVertex), sizeof(((DynamicBackendParameters*)nullptr)->ViewportIndexProvokingVertex)},
|
||||||
|
{"DynamicBackendParameters.MaxViewportWidth", offsetof(DynamicBackendParameters, MaxViewportWidth), sizeof(((DynamicBackendParameters*)nullptr)->MaxViewportWidth)},
|
||||||
|
{"DynamicBackendParameters.MaxViewportHeight", offsetof(DynamicBackendParameters, MaxViewportHeight), sizeof(((DynamicBackendParameters*)nullptr)->MaxViewportHeight)},
|
||||||
|
{"DynamicBackendParameters.ViewportBoundsRangeMin", offsetof(DynamicBackendParameters, ViewportBoundsRangeMin), sizeof(((DynamicBackendParameters*)nullptr)->ViewportBoundsRangeMin)},
|
||||||
|
{"DynamicBackendParameters.ViewportBoundsRangeMax", offsetof(DynamicBackendParameters, ViewportBoundsRangeMax), sizeof(((DynamicBackendParameters*)nullptr)->ViewportBoundsRangeMax)},
|
||||||
|
{"DynamicBackendParameters.ViewportSubpixelBits", offsetof(DynamicBackendParameters, ViewportSubpixelBits), sizeof(((DynamicBackendParameters*)nullptr)->ViewportSubpixelBits)},
|
||||||
|
{"DynamicBackendParameters.MinFragmentInterpolationOffset", offsetof(DynamicBackendParameters, MinFragmentInterpolationOffset), sizeof(((DynamicBackendParameters*)nullptr)->MinFragmentInterpolationOffset)},
|
||||||
|
{"DynamicBackendParameters.MaxFragmentInterpolationOffset", offsetof(DynamicBackendParameters, MaxFragmentInterpolationOffset), sizeof(((DynamicBackendParameters*)nullptr)->MaxFragmentInterpolationOffset)},
|
||||||
|
{"DynamicBackendParameters.FragmentInterpolationOffsetBits", offsetof(DynamicBackendParameters, FragmentInterpolationOffsetBits), sizeof(((DynamicBackendParameters*)nullptr)->FragmentInterpolationOffsetBits)},
|
||||||
|
{"DynamicBackendParameters.SupportsWideLines", offsetof(DynamicBackendParameters, SupportsWideLines), sizeof(((DynamicBackendParameters*)nullptr)->SupportsWideLines)},
|
||||||
|
{"DynamicBackendParameters.SupportsDistinctDepthStencilAttachments", offsetof(DynamicBackendParameters, SupportsDistinctDepthStencilAttachments), sizeof(((DynamicBackendParameters*)nullptr)->SupportsDistinctDepthStencilAttachments)},
|
||||||
|
{"DynamicBackendParameters.PerLayerFramebufferAttachmentTargets", offsetof(DynamicBackendParameters, PerLayerFramebufferAttachmentTargets), sizeof(((DynamicBackendParameters*)nullptr)->PerLayerFramebufferAttachmentTargets)},
|
||||||
|
{"DynamicBackendParameters.SupportsShaderFloat64", offsetof(DynamicBackendParameters, SupportsShaderFloat64), sizeof(((DynamicBackendParameters*)nullptr)->SupportsShaderFloat64)},
|
||||||
|
{"DynamicBackendParameters.SupportsFloat64VertexAttributes", offsetof(DynamicBackendParameters, SupportsFloat64VertexAttributes), sizeof(((DynamicBackendParameters*)nullptr)->SupportsFloat64VertexAttributes)},
|
||||||
|
{"DynamicBackendParameters.SupportsTessellationPointSize", offsetof(DynamicBackendParameters, SupportsTessellationPointSize), sizeof(((DynamicBackendParameters*)nullptr)->SupportsTessellationPointSize)},
|
||||||
|
{"DynamicBackendParameters.SupportsGeometryPointSize", offsetof(DynamicBackendParameters, SupportsGeometryPointSize), sizeof(((DynamicBackendParameters*)nullptr)->SupportsGeometryPointSize)},
|
||||||
|
{"DynamicBackendParameters.MaxShaderStorageBlockSize", offsetof(DynamicBackendParameters, MaxShaderStorageBlockSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxShaderStorageBlockSize)},
|
||||||
|
{"DynamicBackendParameters.SubgroupSize", offsetof(DynamicBackendParameters, SubgroupSize), sizeof(((DynamicBackendParameters*)nullptr)->SubgroupSize)},
|
||||||
|
{"DynamicBackendParameters.SubgroupSupportedStages", offsetof(DynamicBackendParameters, SubgroupSupportedStages), sizeof(((DynamicBackendParameters*)nullptr)->SubgroupSupportedStages)},
|
||||||
|
{"DynamicBackendParameters.SubgroupSupportedFeatures", offsetof(DynamicBackendParameters, SubgroupSupportedFeatures), sizeof(((DynamicBackendParameters*)nullptr)->SubgroupSupportedFeatures)},
|
||||||
|
{"DynamicBackendParameters.SubgroupQuadOperationsInAllStages", offsetof(DynamicBackendParameters, SubgroupQuadOperationsInAllStages), sizeof(((DynamicBackendParameters*)nullptr)->SubgroupQuadOperationsInAllStages)},
|
||||||
|
{"DynamicBackendParameters.GpuVendor", offsetof(DynamicBackendParameters, GpuVendor), sizeof(((DynamicBackendParameters*)nullptr)->GpuVendor)},
|
||||||
|
{"MGHostSpan", 0, sizeof(MGHostSpan)},
|
||||||
|
{"MGHostSpan.Ptr", offsetof(MGHostSpan, Ptr), sizeof(((MGHostSpan*)nullptr)->Ptr)},
|
||||||
|
{"MGHostSpan.Seg", offsetof(MGHostSpan, Seg), sizeof(((MGHostSpan*)nullptr)->Seg)},
|
||||||
|
{"MGHostSpan.Size", offsetof(MGHostSpan, Size), sizeof(((MGHostSpan*)nullptr)->Size)},
|
||||||
|
{"MGHostSpan.Offset", offsetof(MGHostSpan, Offset), sizeof(((MGHostSpan*)nullptr)->Offset)},
|
||||||
|
{"MGPVertexAttribWire", 0, sizeof(MGPVertexAttribWire)},
|
||||||
|
{"MGPVertexAttribWire.Offset", offsetof(MGPVertexAttribWire, Offset), sizeof(((MGPVertexAttribWire*)nullptr)->Offset)},
|
||||||
|
{"MGPVertexAttribWire.Stride", offsetof(MGPVertexAttribWire, Stride), sizeof(((MGPVertexAttribWire*)nullptr)->Stride)},
|
||||||
|
{"MGPVertexAttribWire.Type", offsetof(MGPVertexAttribWire, Type), sizeof(((MGPVertexAttribWire*)nullptr)->Type)},
|
||||||
|
{"MGPVertexAttribWire.Size", offsetof(MGPVertexAttribWire, Size), sizeof(((MGPVertexAttribWire*)nullptr)->Size)},
|
||||||
|
{"MGPVertexAttribWire.Enabled", offsetof(MGPVertexAttribWire, Enabled), sizeof(((MGPVertexAttribWire*)nullptr)->Enabled)},
|
||||||
|
{"MGPVertexAttribWire.Normalized", offsetof(MGPVertexAttribWire, Normalized), sizeof(((MGPVertexAttribWire*)nullptr)->Normalized)},
|
||||||
|
{"MGPVertexAttribWire.IsInteger", offsetof(MGPVertexAttribWire, IsInteger), sizeof(((MGPVertexAttribWire*)nullptr)->IsInteger)},
|
||||||
|
{"MGPVertexAttribWire.IsLong", offsetof(MGPVertexAttribWire, IsLong), sizeof(((MGPVertexAttribWire*)nullptr)->IsLong)},
|
||||||
|
{"MGPVertexAttribWire.IsBgra", offsetof(MGPVertexAttribWire, IsBgra), sizeof(((MGPVertexAttribWire*)nullptr)->IsBgra)},
|
||||||
|
{"MGPVertexAttribWire.BindingIndex", offsetof(MGPVertexAttribWire, BindingIndex), sizeof(((MGPVertexAttribWire*)nullptr)->BindingIndex)},
|
||||||
|
{"MGPVertexBindingPointWire", 0, sizeof(MGPVertexBindingPointWire)},
|
||||||
|
{"MGPVertexBindingPointWire.Offset", offsetof(MGPVertexBindingPointWire, Offset), sizeof(((MGPVertexBindingPointWire*)nullptr)->Offset)},
|
||||||
|
{"MGPVertexBindingPointWire.Stride", offsetof(MGPVertexBindingPointWire, Stride), sizeof(((MGPVertexBindingPointWire*)nullptr)->Stride)},
|
||||||
|
{"MGPVertexBindingPointWire.Divisor", offsetof(MGPVertexBindingPointWire, Divisor), sizeof(((MGPVertexBindingPointWire*)nullptr)->Divisor)},
|
||||||
|
{"MGPipeHandle", 0, sizeof(MGPipeHandle)},
|
||||||
|
{"MGPipeHandle.Slot", offsetof(MGPipeHandle, Slot), sizeof(((MGPipeHandle*)nullptr)->Slot)},
|
||||||
|
{"MGPipeHandle.Gen", offsetof(MGPipeHandle, Gen), sizeof(((MGPipeHandle*)nullptr)->Gen)},
|
||||||
|
{"MGPWireRecHeader", 0, sizeof(MGPWireRecHeader)},
|
||||||
|
{"MGPWireRecHeader.Op", offsetof(MGPWireRecHeader, Op), sizeof(((MGPWireRecHeader*)nullptr)->Op)},
|
||||||
|
{"MGPWireRecHeader.Flags", offsetof(MGPWireRecHeader, Flags), sizeof(((MGPWireRecHeader*)nullptr)->Flags)},
|
||||||
|
{"MGPWireRecHeader.Size", offsetof(MGPWireRecHeader, Size), sizeof(((MGPWireRecHeader*)nullptr)->Size)},
|
||||||
|
};
|
||||||
|
struct WireCallLayout { const char* Name; const char* Payload; Uint64 Op; Uint64 Flags; Uint64 Wait; };
|
||||||
|
inline constexpr WireCallLayout kMGPipeWireCallLayouts[] = {
|
||||||
|
{"GetCaps", "MGPCaps", static_cast<Uint64>(MGPWireOp::GetCaps), static_cast<Uint64>(kReplySlot | kHasBlob), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"ResourceCreate", "MGPResourceDesc", static_cast<Uint64>(MGPWireOp::ResourceCreate), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"ResourceRespecify", "MGPResourceDesc", static_cast<Uint64>(MGPWireOp::ResourceRespecify), static_cast<Uint64>(kNeedsAck | kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"ResourceDestroy", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::ResourceDestroy), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"MapPersistent", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::MapPersistent), static_cast<Uint64>(kReplySlot | kOptional), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"UnmapPersistent", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::UnmapPersistent), static_cast<Uint64>(kOptional), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"FenceCreate", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::FenceCreate), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"FenceStatus", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::FenceStatus), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"FenceWait", "MGPFenceWait", static_cast<Uint64>(MGPWireOp::FenceWait), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"FenceDestroy", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::FenceDestroy), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"QueryCreate", "MGPQueryDesc", static_cast<Uint64>(MGPWireOp::QueryCreate), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"QueryBegin", "MGPQueryDesc", static_cast<Uint64>(MGPWireOp::QueryBegin), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"QueryEnd", "MGPQueryDesc", static_cast<Uint64>(MGPWireOp::QueryEnd), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"QueryAvailable", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::QueryAvailable), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"QueryResult", "MGPQueryResultRequest", static_cast<Uint64>(MGPWireOp::QueryResult), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"QueryDestroy", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::QueryDestroy), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"CreateRenderState", "MGPRenderStateDesc", static_cast<Uint64>(MGPWireOp::CreateRenderState), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"BindRenderState", "MGPBindRenderState", static_cast<Uint64>(MGPWireOp::BindRenderState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"DeleteRenderState", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::DeleteRenderState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"CreateVertexElements", "MGPVertexElements", static_cast<Uint64>(MGPWireOp::CreateVertexElements), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"BindVertexElements", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::BindVertexElements), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"DeleteVertexElements", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::DeleteVertexElements), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"CreateSamplerState", "MGPSamplerDesc", static_cast<Uint64>(MGPWireOp::CreateSamplerState), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"DeleteSamplerState", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::DeleteSamplerState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"CreateSamplerView", "MGPSamplerView", static_cast<Uint64>(MGPWireOp::CreateSamplerView), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"DeleteSamplerView", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::DeleteSamplerView), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"CreateShaderState", "MGPProgramDesc", static_cast<Uint64>(MGPWireOp::CreateShaderState), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"BindShaderState", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::BindShaderState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"DeleteShaderState", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::DeleteShaderState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetDynamicState", "MGPDynamicState", static_cast<Uint64>(MGPWireOp::SetDynamicState), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetFramebufferState", "MGPFramebufferState", static_cast<Uint64>(MGPWireOp::SetFramebufferState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetVertexBuffers", "MGPVertexBuffers", static_cast<Uint64>(MGPWireOp::SetVertexBuffers), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetIndexBuffer", "MGPIndexBuffer", static_cast<Uint64>(MGPWireOp::SetIndexBuffer), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetIndirectBuffers", "MGPIndirectBuffers", static_cast<Uint64>(MGPWireOp::SetIndirectBuffers), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetSamplerViews", "MGPSamplerViews", static_cast<Uint64>(MGPWireOp::SetSamplerViews), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"BindSamplerStates", "MGPSamplerStates", static_cast<Uint64>(MGPWireOp::BindSamplerStates), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetShaderImages", "MGPShaderImages", static_cast<Uint64>(MGPWireOp::SetShaderImages), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetShaderBuffers", "MGPShaderBuffers", static_cast<Uint64>(MGPWireOp::SetShaderBuffers), static_cast<Uint64>(kVarTail | kHostSpan), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetStreamOutputTargets", "MGPStreamOutputTargets", static_cast<Uint64>(MGPWireOp::SetStreamOutputTargets), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetGlobalConstants", "MGPGlobalConstants", static_cast<Uint64>(MGPWireOp::SetGlobalConstants), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetVertexAttribDefaults", "MGPVertexAttribDefaults", static_cast<Uint64>(MGPWireOp::SetVertexAttribDefaults), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetPixelPackState", "MGPPixelPackState", static_cast<Uint64>(MGPWireOp::SetPixelPackState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetPatchState", "MGPPatchState", static_cast<Uint64>(MGPWireOp::SetPatchState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetDrawProgram", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::SetDrawProgram), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetDispatchProgram", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::SetDispatchProgram), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetResidualValueState", "MGPResidualValueState", static_cast<Uint64>(MGPWireOp::SetResidualValueState), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"SetTextureParams", "MGPTextureParams", static_cast<Uint64>(MGPWireOp::SetTextureParams), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"ResourceSubData", "MGPSubData", static_cast<Uint64>(MGPWireOp::ResourceSubData), static_cast<Uint64>(kHasBlob | kVarTail | kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"BufferSubDataResident", "MGPSubData", static_cast<Uint64>(MGPWireOp::BufferSubDataResident), static_cast<Uint64>(kHasBlob | kOptional), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"ResourceSubDataComplete", "MGPSubDataComplete", static_cast<Uint64>(MGPWireOp::ResourceSubDataComplete), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"ResourceFlushRange", "MGPFlushRange", static_cast<Uint64>(MGPWireOp::ResourceFlushRange), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"ResourceReadback", "MGPReadback", static_cast<Uint64>(MGPWireOp::ResourceReadback), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"ResourceCopyRegion", "MGPCopyRegion", static_cast<Uint64>(MGPWireOp::ResourceCopyRegion), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||||
|
{"GenerateMipmap", "MGPMipPlan", static_cast<Uint64>(MGPWireOp::GenerateMipmap), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||||
|
{"GetTextureImage", "MGPReadbackInfo", static_cast<Uint64>(MGPWireOp::GetTextureImage), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"Blit", "MGPBlit", static_cast<Uint64>(MGPWireOp::Blit), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"Clear", "MGPClear", static_cast<Uint64>(MGPWireOp::Clear), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"ReadPixels", "MGPReadbackInfo", static_cast<Uint64>(MGPWireOp::ReadPixels), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"DrawVbo", "MGPDrawInfo", static_cast<Uint64>(MGPWireOp::DrawVbo), static_cast<Uint64>(kHostSpan | kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"LaunchGrid", "MGPGridInfo", static_cast<Uint64>(MGPWireOp::LaunchGrid), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"MemoryBarrier", "MGPMemoryBarrier", static_cast<Uint64>(MGPWireOp::MemoryBarrier), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"BeginStreamOutput", "MGPStreamOutputBegin", static_cast<Uint64>(MGPWireOp::BeginStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||||
|
{"EndStreamOutput", "MGPXfbAccounting", static_cast<Uint64>(MGPWireOp::EndStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||||
|
{"PauseStreamOutput", "MGPStreamOutputControl", static_cast<Uint64>(MGPWireOp::PauseStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||||
|
{"ResumeStreamOutput", "MGPStreamOutputControl", static_cast<Uint64>(MGPWireOp::ResumeStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||||
|
{"Flush", "MGPFlush", static_cast<Uint64>(MGPWireOp::Flush), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"Present", "MGPPresent", static_cast<Uint64>(MGPWireOp::Present), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitPresent)},
|
||||||
|
{"SetSwapInterval", "MGPSwapInterval", static_cast<Uint64>(MGPWireOp::SetSwapInterval), static_cast<Uint64>(kOptional), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"QueryTimestamp", "MGPTimestampRequest", static_cast<Uint64>(MGPWireOp::QueryTimestamp), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||||
|
{"QueryCounter", "MGPQueryDesc", static_cast<Uint64>(MGPWireOp::QueryCounter), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"FenceWaitServer", "MGPFenceWait", static_cast<Uint64>(MGPWireOp::FenceWaitServer), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"BindShaderImage", "MGPImageBind", static_cast<Uint64>(MGPWireOp::BindShaderImage), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"PatchParameter", "MGPPatchParameter", static_cast<Uint64>(MGPWireOp::PatchParameter), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"BindStreamOutput", "MGPStreamOutputBind", static_cast<Uint64>(MGPWireOp::BindStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||||
|
{"SetStorageBlockBinding", "MGPStorageBlockBinding", static_cast<Uint64>(MGPWireOp::SetStorageBlockBinding), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitApplied)},
|
||||||
|
{"CopyFramebufferToTexture", "MGPCopyFromFramebuffer", static_cast<Uint64>(MGPWireOp::CopyFramebufferToTexture), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||||
|
{"ApplierReset", "MGPApplierReset", static_cast<Uint64>(MGPWireOp::ApplierReset), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||||
|
{"ObjectDeath", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::ObjectDeath), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||||
|
{"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)},
|
||||||
|
};
|
||||||
@@ -0,0 +1,746 @@
|
|||||||
|
# CONTRACT-P6 — the backend runs in a second process
|
||||||
|
|
||||||
|
Authority: this file, beside `CONTRACT-P5.md` (table 0, byte carriers, field ownership, R-1…R-17),
|
||||||
|
`CONTRACT-P5B.md` (the class-C slots), `CONTRACT-P5C.md` (rule E, the two named exemptions, SEG_EVENT,
|
||||||
|
the guards), `CONTRACT-P5E.md` (rule F, the barriered predicate, the wait rule) and
|
||||||
|
`CONTRACT-MAGMA-RUNAHEAD.md`. Where it disagrees with any of them this file is newer and wins; §10
|
||||||
|
lists every such place. Base: `feat/disaggregated @ 785fed0b`. Every `file:line` was read at that
|
||||||
|
commit; paths are under `MobileGL/` unless they start with `docs/`.
|
||||||
|
|
||||||
|
**How to change it.** Package `c6`'s file, edited by the integrator first. A P6 package
|
||||||
|
(`lk` / `hs` / `so` / `sm` / `cp` / `dl` / `st` / `t6`) that needs a row changed goes through the
|
||||||
|
integrator; the packages compile against the rows below from day one.
|
||||||
|
|
||||||
|
**What this file is written from.** [`a6-audit-v1.md`](../../docs/Disaggregated/notes/p6/a6-audit-v1.md)
|
||||||
|
(198 rows, seven items, each adversarially re-resolved) and
|
||||||
|
[`a6-link-experiment.md`](../../docs/Disaggregated/notes/p6/a6-link-experiment.md) (the 184 symbols).
|
||||||
|
It supersedes [`P6-CONTRACT-DRAFT.md`](../../docs/Disaggregated/P6-CONTRACT-DRAFT.md), which was
|
||||||
|
written before its own audit and is **wrong in four places** (§10.1). The re-scoping against the
|
||||||
|
eventual client-in-a-VM end state is
|
||||||
|
[`P6-ENDSTATE-REVIEW.md`](../../docs/Disaggregated/P6-ENDSTATE-REVIEW.md); this file takes from it
|
||||||
|
only what P6 must not preclude, and §11 says what P6 explicitly does not take on.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §0 What c6 is, and the rule above every row
|
||||||
|
|
||||||
|
`c6` lands **this file and two headers**. It changes no behaviour, adds no caller, and moves no
|
||||||
|
byte on any wire. Every rule below that describes an action names the package that implements it.
|
||||||
|
A rule with no package named is a statement about the tree as it already is.
|
||||||
|
|
||||||
|
**Rule G — a role may not name a process-local handle.** Rule E forbade naming the other role's
|
||||||
|
*memory*; rule G extends it to *identity*. A value whose meaning comes from the owning process's
|
||||||
|
kernel or loader state — `EGLDisplay`, `EGLSurface`, `EGLContext`, `ANativeWindow*`, any `void*`
|
||||||
|
window handle, an fd number, a pid, a mapped address — either crosses as a **token** defined in §2,
|
||||||
|
or does not cross. Descriptors cross only by a mechanism the transport **declares it supports**, and
|
||||||
|
where the transport declares none they do not cross at all and the bytes are transferred instead;
|
||||||
|
a transport may not invent a third answer.
|
||||||
|
|
||||||
|
> The draft hard-coded `SCM_RIGHTS` inside rule G. That is one transport's implementation of one
|
||||||
|
> clause, not the rule, and writing it into the rule is what would make the rule wrong the first
|
||||||
|
> time a transport has no descriptor passing at all.
|
||||||
|
|
||||||
|
**Rule H — a value whose meaning comes from the peer's window system never crosses. Permanently.**
|
||||||
|
Not "until P12". P12 gives the *server* its own display; it does not give the client's window a way
|
||||||
|
across. §6 is rule H's whole enforcement.
|
||||||
|
|
||||||
|
**Rule G's teeth** are §9's arm-proof gate: a spawn lane that silently ran monolith satisfies every
|
||||||
|
other gate in this file.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §1 The one fact that makes c6 possible: `Spawn` is unreachable today
|
||||||
|
|
||||||
|
`ConfigLoader.cpp:339-346` is the only writer of `MG_Config::Transport` for the string `spawn`, and
|
||||||
|
it writes **`TransportMode::Monolith`** at `:344`, with a log line saying P5 does not implement it.
|
||||||
|
|
||||||
|
Two consequences, and the second is why this file can exist without changing behaviour:
|
||||||
|
|
||||||
|
1. **`ConfigLoader`'s named refusal cannot falsify itself.** It lands on the same value a server's
|
||||||
|
resting state would have, so "the child was forced to monolith" and "the parent fell back" are
|
||||||
|
one state. `sm` fixes this; until then, no lane can prove it ran spawn (§9.5).
|
||||||
|
2. **Every rule in this file conditioned on `Transport == Spawn` is vacuous in c6's own tree.** It
|
||||||
|
constrains a state no process can enter. That is how D1 (§3.1) is stated normatively while
|
||||||
|
changing nothing, and `c6`'s gate pins the vacuity so the `ConfigLoader` change cannot land early.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §2 Table 0 additions
|
||||||
|
|
||||||
|
| row | encoding | invalid | consumer | package |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `DisplayToken` / `SurfaceToken` / `ContextToken` | `Uint64`, minted by the client, dense from 1, never reused in a session. Server keeps token → native handle; it never sees the client's EGL values. `protocol.fbs`'s `display` / `surface` / `context` are already `ulong` and are these. **The client already mints them** (`MG_State/EGLState/Core.h`'s `EncodeHandle`), contrary to `Server/SurfaceControlFrame.h:26-29`, which says inproc bit-casts the handle — that comment is corrected by `cp`. | `0` on any op but `ReleaseCurrent` → `Fatal{ProtocolCorruption}` | the server's surface map | `cp` |
|
||||||
|
| `SurfaceOpKind::InitCapabilities = 11` | **Appended.** The draft claimed `ServerInitCapabilities` needs no wire form because "`CapsSnapshot` answers it". The *answer* is a `CapsSnapshot`; the **request** has a live client caller (`Client/BackendObject_Remote.cpp:126`) and the codec **refuses to encode it** (`Protocol/SurfaceOpCodec.cpp:119-122`, `InprocOnlyOpOnTheWire`). A spawn client cannot ask. | unknown tag → `Fatal{ProtocolCorruption}`, never ignored | the server's control pump | `cp` |
|
||||||
|
| `SurfaceReply.result: int` | **Appended, id 5.** Carries the `MobileGLResult` that `ServerApplyWireSurfaceOp` already computes and drops. Without it a client cannot tell a server that died mid-op from a legitimate refusal, and therefore cannot choose between arming the device-lost latch and returning `EGL_FALSE`. | — | the client's control demultiplexer | `hs` |
|
||||||
|
| `SurfaceReply.defaultFb` | **`(deprecated)`.** The encoder passes a literal `0` offset (`SurfaceOpCodec.cpp:184`) and the decoder never reads it; `kEventSurfaceChanged` is the landed carrier (P5f `fc`). The slot is **burned, never deleted** — a deleted field frees its vtable slot for the next append. | — | nobody, by construction | `hs` |
|
||||||
|
> **asio was considered for the byte stream and declined (2026-09-21).** It is already vendored
|
||||||
|
> and on the include path, so the question is a fair one. But spawn needs five platform
|
||||||
|
> mechanisms and asio covers one: its own `socketpair` returns `operation_not_supported` on
|
||||||
|
> Windows (`3rdparty/asio/include/asio/detail/impl/socket_ops.ipp:683`), it has no descriptor
|
||||||
|
> passing at all, segment delivery is POSIX-only by design, and there is no `fork`. So adopting
|
||||||
|
> it would not make Windows work; it would only put asio headers inside `Transport/`, which
|
||||||
|
> `ITransport.h` keeps dependency-light on purpose. **Revisit at P6.5**, where
|
||||||
|
> `asio::generic::stream_protocol` carries a raw (family, type, protocol) triple and therefore
|
||||||
|
> gives AF_VSOCK from the same implementation (2026-09-22: the end state's link is TCP, not
|
||||||
|
> AF_VSOCK - §10.3 - and the argument is the same for `asio::ip::tcp`) - and where `ITransport` lets an `AsioTransport`
|
||||||
|
> land beside `SocketTransport` without touching a caller.
|
||||||
|
|
||||||
|
| `LinkTerms{dataPlane, wireForm, maxReplyBytes, cmdWindowBytes, stageWindowBytes}` | Appended to `Hello`/`Welcome`. `dataPlane` has exactly **one** legal value in P6, `SharedSegments`; `wireForm` exactly one, `StructImage`. Anything else is refused **by name**. The four sizes are **stated by the SERVER**. | any other value → `Refuse{ProtocolMismatch}` | the handshake | `hs` → **not landed** (verified 2026-09-22: `protocol.fbs` has no `LinkTerms`); re-homed to P6.5 `nd`, §10.3 |
|
||||||
|
| `Refuse{code, detail, peer values}` | Appended `CtrlMsg` union tag. A handshake disagreement is an **answer**, not an abort (§5.1). | — | both sides | `hs` → **not landed** (no `Refuse` in `union CtrlMsg`); re-homed to P6.5 `wf`, §10.3 |
|
||||||
|
| `wireFingerprint` / `buildFingerprint` | The single `abiFingerprint` splits. §4. | mismatch → `Refuse`, never `Fatal` | the handshake | `hs` → **partially landed** (explicit build stamp, `abiMajor`/`abiMinor` checked, real pids; the split itself and the `PipeFields.def` layout digest are not); re-homed to P6.5 `wf`, §10.3 |
|
||||||
|
| `FatalCode` | **Unchanged**, 7 values (`protocol.fbs:248-256`). `table Fatal` appends `family: string`. §5.2. | — | — | `dl` |
|
||||||
|
|
||||||
|
All schema edits are **append-only**. A FlatBuffers table field's id is its vtable slot and an enum
|
||||||
|
value **is** the wire value; retired fields become `(deprecated)`, never disappear. `CapsSnapshot`'s
|
||||||
|
four deprecated fields are the worked precedent and their reasoning is in `protocol.fbs` itself.
|
||||||
|
|
||||||
|
> **`hs` implementation note, from c6's review.** `flatc` drops deprecated fields from the generated
|
||||||
|
> `Create*` helper. Deprecating `defaultFb` while appending `result` therefore changes
|
||||||
|
> `CreateSurfaceReply`'s arity, and the existing 6-argument call at `SurfaceOpCodec.cpp:183-184`
|
||||||
|
> would **silently bind its `/*defaultFb=*/0` to `result`**. `hs` converts that call site to
|
||||||
|
> `SurfaceReplyBuilder` with explicit `add_*` in the same commit, so a positional mistake is
|
||||||
|
> impossible rather than merely unlikely.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §3 Role, Dial, and the six predicates
|
||||||
|
|
||||||
|
### 3.1 D1 — what `Transport` reads as in the server process
|
||||||
|
|
||||||
|
**`TransportMode::Spawn`. The child does not force `Monolith`.**
|
||||||
|
|
||||||
|
`ARCHITECTURE.md:488`'s literal instruction ("`mobilegl_server_main` hard-sets `MG_Config::Transport`
|
||||||
|
to `Monolith` before reaching `Init()`") is **amended by this file**. a6 measured why: 226 live lines
|
||||||
|
test `Transport != Monolith` to select the **server** arm, 148 of them in `MG_Backend`. Forcing
|
||||||
|
`Monolith` flips all of them to frontend glue in the one process with no frontend. The sharpest
|
||||||
|
instance is `PipeInputs::IsLive()` (`MG_Impl/Pipe/PipeFill.cpp:2135`): forced monolith, it reads
|
||||||
|
`MG_State::pGLContext`, which is null there, so **58 `MGB_CTX_LIVE` guards all answer "not live"**.
|
||||||
|
|
||||||
|
Anti-recursion moves to a **separate, non-inherited axis**: `MG_Config::Dial == DialMode::No` in the
|
||||||
|
child. The envp scrub stays as the second, independent catch, and S3 (§9) still falsifies it —
|
||||||
|
and the diagnostic must **name which of the two fired**, or the double safety is untestable as two
|
||||||
|
things. Package: `sm`.
|
||||||
|
|
||||||
|
### 3.2 D1c — there are six predicates, not three
|
||||||
|
|
||||||
|
a6 proposed three. Three do not cover the tree.
|
||||||
|
|
||||||
|
| predicate | asks | pull-build shape |
|
||||||
|
|---|---|---|
|
||||||
|
| `MGPipeSplitActive()` | do records cross a role boundary at all | `#else` returns `false` |
|
||||||
|
| `MGPipeServerArm()` | am I executing as the server **right now** | `#else` returns `false` |
|
||||||
|
| `MGPipeShouldDial()` | should this process connect out | `#else` returns `false` |
|
||||||
|
| `MGPipeSessionLive()` | is a peer session live | role-defined; `#else` `false` |
|
||||||
|
| `MGPipeBlocksAreDistinct()` | do the two roles share one storage object | `#else` `false` |
|
||||||
|
| `MGPipeBackendIsLocal()` | is the backend in **this** process | `#else` `true` |
|
||||||
|
|
||||||
|
`ContextEpoch::Server` and `ActiveXfbState`'s role index are **`MGPipeSplitActive()`** sites, not
|
||||||
|
`MGPipeServerArm()` sites: they are partition keys, and the `ServerArm` disjunct would make a
|
||||||
|
partition key thread-dependent.
|
||||||
|
|
||||||
|
**D14 — all six must fold away in the pull build**, and the required shape is `SlotCaps.h`'s: the
|
||||||
|
non-disaggregated build gets a **different definition** under `#else`, not a runtime-false predicate.
|
||||||
|
`MGPipeSplitActive()` must additionally remain exactly one load of a process global and must never
|
||||||
|
be latched into a `static Bool`. G1 is 0/0/0/0 and `.text` unchanged; anything else is a c6 defect.
|
||||||
|
Package: `sm`.
|
||||||
|
|
||||||
|
### 3.3 D13 — rename before introducing
|
||||||
|
|
||||||
|
`MGPipeRoleSplitActive()` (`MG_Backend/MGPipe/PipeInputs.cpp:292`) means
|
||||||
|
`Ipc.RoleSplitState && Transport != Monolith` — the **rehearsal knob**, default off. It is renamed
|
||||||
|
to **`MGPipeRoleSplitRehearsalActive()`**, which is what it has always meant, and
|
||||||
|
`MGPipeBlocksAreDistinct()` is introduced beside it as the wider predicate. a6's shape — rename, then
|
||||||
|
widen the same function — is **overturned**: a widened function under a narrow name is a name that lies.
|
||||||
|
|
||||||
|
Blast radius, measured at this head: **12 sites**, of which `DualBlockScenario.cpp`'s assertion
|
||||||
|
*message* embeds the old name and must be updated with it. Package: `sm`.
|
||||||
|
|
||||||
|
### 3.4 D10 — the four guards that cannot arm in a server-only process
|
||||||
|
|
||||||
|
| guard | today | becomes | package |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `MGPipeApplierReset` layer 2 (`MG_Pipe/PipeApply.cpp:1353-1355`) | needs `ClientSession::Active() != nullptr`, permanently null in a server process | middle conjunct → `MGPipeSessionLive()`; third → `!MGPipeServerArm()` | `sm` |
|
||||||
|
| `MGPipeServerBlockNoteIdentity` (`PipeInputs.cpp:314`) | early-returns unless the rehearsal knob is on | gate → `MGPipeBlocksAreDistinct()` | `sm` |
|
||||||
|
| `CountBarrierPull`'s unconditional Fatal arm (`PipeInputs.cpp:174`) | knob-gated | rides `MGPipeBlocksAreDistinct()` | `sm` |
|
||||||
|
| the two `RefuseFromApplyThread` helpers (`MG_Impl/Pipe/SlotAllocator.cpp:29-57`) | `ServerLoop::OnApplyThread()` | OR'd with a process-role fact set once by `ServerMain` | `sm` |
|
||||||
|
|
||||||
|
**The one that crashes rather than merely failing to arm.** With `MGPipeServerBlockNoteIdentity`
|
||||||
|
early-returning, a spawn server's `gPipeInputs.ContextIdentity()` stays `nullptr` for the life of the
|
||||||
|
process, and `DirectGLES.cpp:199-213`'s fb-slot memo does a **raw pointer compare with no generation**
|
||||||
|
against it — so `nullptr == nullptr` reads as a **cache hit** and the first call uses an
|
||||||
|
uninitialised slot. `PipeInputs.h:878-884`'s own comment says a named Fatal was intended there.
|
||||||
|
`sm` lands the gate change; `st` lands the named Fatal.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §4 The handshake (`hs`)
|
||||||
|
|
||||||
|
### 4.1 One equality test answers three different questions today
|
||||||
|
|
||||||
|
`AbiFingerprintInputs` (`Transport/SessionRings.h:544-566`) mixes wire properties, struct-layout
|
||||||
|
properties and pure build identity into one `Uint64`. It splits:
|
||||||
|
|
||||||
|
**`wireFingerprint` — always compared.** Inputs, in order:
|
||||||
|
an ordered **catalogue digest** over `PipeCalls.def`'s `(opcode, payload struct name, call-flag row,
|
||||||
|
WaitClass)`; a **payload layout digest** derived from `PipeFields.def` (per member: name, `offsetof`,
|
||||||
|
`sizeof`); the record-header layout; both blob-codec version stamps; the format-capability table's
|
||||||
|
two extents; `kOpCount`; `MOBILEGL_ABI_VERSION`; endianness; pointer width; **and**
|
||||||
|
`sizeof(MGPCaps)` and `sizeof(DynamicBackendParameters)`.
|
||||||
|
|
||||||
|
Those last two **stay compared** because they are wire facts, not build facts: `MGPWireRec_GetCaps`
|
||||||
|
is composed from `sizeof(MGPCaps)` (`MG_Pipe/generated/PipeWire.inc`). `sizeof(GLFunctionsTable)` is
|
||||||
|
**deleted** from the mix: it never crosses the wire, so adding one backend slot today invalidates
|
||||||
|
every peer for no wire reason.
|
||||||
|
|
||||||
|
> **Why the layout digest is not optional.** `SessionRings.h:561-565`'s own comment says the git
|
||||||
|
> stamp is in the mix because *two builds of the same sizes can still disagree about a FIELD ORDER,
|
||||||
|
> which no sizeof can see*. A catalogue digest over `(opcode, struct name, flags, WaitClass)` sees
|
||||||
|
> neither a member reorder inside a payload struct nor a width change. So the widely-proposed "drop
|
||||||
|
> the git stamp, add a catalogue hash" is **wrong as usually stated** — it removes a guard and does
|
||||||
|
> not replace it. The layout digest is the replacement, and `gen_pipe.py` already CI-enforces that
|
||||||
|
> `PipeFields.def` names every member, so it is a generator addition and not a toolchain.
|
||||||
|
|
||||||
|
**`buildFingerprint` — compared only while `Dial == Fork`.** Under fork the child *is* the same
|
||||||
|
binary, so comparing it catches a stale `MOBILEGL_IPC_SERVER_PATH` pointing at an old
|
||||||
|
`libMobileGLServer.so` — a real P6 failure mode. **P6's policy is therefore strictly stronger than
|
||||||
|
today's, not looser**; the end state is a policy flip, not a redesign.
|
||||||
|
|
||||||
|
### 4.2 The missing build stamp
|
||||||
|
|
||||||
|
a6 found `CMakeLists.txt:188-195` takes the git hash with **no `RESULT_VARIABLE` and no fallback**, so
|
||||||
|
a failed `git rev-parse` silently yields `""`. Verified live: building this worktree from WSL
|
||||||
|
produces `GIT_COMMIT_HASH_SHORT ""`, because the worktree's `.git` file holds a Windows path WSL's
|
||||||
|
git cannot resolve. Two builds from different commits then get **identical** fingerprints and the
|
||||||
|
stamp silently stops doing its documented job.
|
||||||
|
|
||||||
|
**The fix may not touch `GIT_COMMIT_HASH_SHORT`.** That macro is baked into
|
||||||
|
`glGetString(GL_VERSION)` (`MG_Impl/GLImpl/Getter/GL_Getter.cpp:614`), so redefining it changes an
|
||||||
|
**application-visible GL string** and the pull build's `.rodata` — a behaviour leak and a G1 break
|
||||||
|
at once. Instead `MGGitHash.h.in` gains a **second** pair, `MOBILEGL_BUILD_STAMP_VALUE` and
|
||||||
|
`MOBILEGL_BUILD_STAMP_PRESENT`, consumed only by the fingerprint, and the CMake step gains a
|
||||||
|
`RESULT_VARIABLE`. A build with no stamp sets `PRESENT` to 0, and a `Dial == Fork` handshake whose
|
||||||
|
peer reports `PRESENT == 0` is a **named refusal**: under fork the two peers are supposed to be the
|
||||||
|
same binary, and without a stamp that premise cannot be checked at all. Package: `hs`.
|
||||||
|
|
||||||
|
### 4.3 Two verified asymmetries `hs` also fixes
|
||||||
|
|
||||||
|
- The client checks only `abiFingerprint` and **never `abiMajor`/`abiMinor`** (`ClientSession.cpp:566-568`).
|
||||||
|
- `Hello::pid` is hard-coded `0` and `Welcome::serverPid` echoes the client's, so it is always 0
|
||||||
|
(`ClientSession.cpp:519-521`, `ServerSession.cpp:532-534`). §9.5's arm-proof gate wants the child
|
||||||
|
pid; `serverPid` is its natural carrier and must start carrying it.
|
||||||
|
|
||||||
|
### 4.4 Segment geometry (D-size)
|
||||||
|
|
||||||
|
`MOBILEGL_IPC_RING_MB` / `STAGE_MB` are read from the **client** process's env with ceilings of
|
||||||
|
1024 / 4096 MiB (`ConfigLoader.cpp:363-364`), while the **server** creates the segments. Under spawn
|
||||||
|
that is a guest environment variable sizing an allocation inside the renderer process. The four sizes
|
||||||
|
become **server-stated** `LinkTerms` fields; the client's values become a *request* the server may
|
||||||
|
clamp, and the clamped values are reported in `Welcome`.
|
||||||
|
|
||||||
|
`ShmSegment::Adopt`'s `fstat` "do not trust the peer's declared size" check
|
||||||
|
(`Transport/ShmSegmentPosix.cpp:127-133`) is today the **only** bound, and it has no analogue on a
|
||||||
|
link with no fd. The compile-time ceiling that refuses an oversized announcement by name is
|
||||||
|
**P6.5's** to define; P6 does not pretend to have answered it.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §5 Death, refusal, and what P5e changed
|
||||||
|
|
||||||
|
### 5.1 The handshake never aborts
|
||||||
|
|
||||||
|
A version or terms disagreement is a `Refuse{code, detail, peer values}` control message plus
|
||||||
|
`MOBILEGL_ERR_PROTOCOL_MISMATCH` on **both** sides: the server sends `Refuse` and exits 0, the client
|
||||||
|
reaps the child and refuses **by name**, never falling back to monolith. Both `FatalAbiMismatch` call
|
||||||
|
sites go (`ServerSession.cpp:471-483`, `ClientSession.cpp:565-568`). The worked shape is eight lines
|
||||||
|
away in the same function: `ServerSession.cpp:456-466` already returns
|
||||||
|
`MOBILEGL_ERR_PROTOCOL_MISMATCH` for a malformed frame, with the correct `msg_as_Hello() != nullptr`
|
||||||
|
guard. Package: `hs`.
|
||||||
|
|
||||||
|
### 5.2 `Fatal{}` keeps aborting in P6, and gains one funnel
|
||||||
|
|
||||||
|
a6 censused **92 abort sites** under `MG_Remote/` carrying **30 distinct family words**, against a
|
||||||
|
**7-value** wire `FatalCode`. So `Session::Fail(FatalCode, detail)` as usually proposed **cannot carry
|
||||||
|
today's vocabulary in its first argument**.
|
||||||
|
|
||||||
|
**D2 ruling.** The first argument is an internal `MGFatalFamily`, generated from a new
|
||||||
|
`MG_Remote/FatalFamilies.def` — one row per family word, each row carrying its `FatalCode`
|
||||||
|
projection. The **wire** keeps `FatalCode` unchanged; `table Fatal` appends `family: string`. The
|
||||||
|
projection is a **total table**, not a switch with a `default:` arm — this build has **no `-Werror`
|
||||||
|
anywhere** (verified: `CMakeLists.txt`, every `*.cmake`, both workflows), so a gate premised on
|
||||||
|
`-Wswitch` failing the build is fiction.
|
||||||
|
|
||||||
|
`Session::Fail` stays `[[noreturn]]` in P6 and still ends in `abort()`. Log lines, CI greps and every
|
||||||
|
red-once are byte-identical. What the funnel buys, and what makes it worth `dl`'s two days:
|
||||||
|
|
||||||
|
- **one** place that publishes a `SessionFault{family, detail, seq, op}` frame to the peer **before**
|
||||||
|
dying, so the guest's log names which record killed the session instead of reading a bare EOF;
|
||||||
|
- one telemetry point;
|
||||||
|
- a CI census gate refusing any **new** bare abort outside the funnel.
|
||||||
|
|
||||||
|
> **LANDED, in three steps.** (1) `FatalFamilies.def` + `FatalFamily.h` generate `MGFatalFamily`,
|
||||||
|
> its total projection `FatalCodeForFamily` and `FatalFamilyName`; 32 rows, tested. (2) `SessionFail`
|
||||||
|
> (`FatalFunnel.{h,cpp}`) is the funnel: the ~90 scattered `MGLOG_F("...Fatal{...}"); abort();` pairs
|
||||||
|
> under `MG_Remote/` become one call each, the message string passed **verbatim** so every line and
|
||||||
|
> grep is byte-identical, the family enum riding alongside for the coarse code. `SessionFaultCount()`
|
||||||
|
> is the telemetry point. The census now also requires every `SessionFail`/`WireLogFatal` call's
|
||||||
|
> string to carry a `Fatal{` word, and its baseline drops from 93 bare aborts to 4 (both funnels).
|
||||||
|
> (3) `table Fatal` gains `family: string`; `SessionFail` publishes the frame on whichever session
|
||||||
|
> control plane is active before aborting, and the client's control-reply loop recognizes it, names
|
||||||
|
> the family and latches device-lost. **seq/op are NOT threaded** through the 90 sites — the message
|
||||||
|
> already names the op — so the frame carries `code`, `family` and `message`, not a field always 0.
|
||||||
|
> A `kill -9` bypasses `abort()` and is caught by `dl`'s hangup witness instead; the self-detected
|
||||||
|
> fatal is the one that publishes.
|
||||||
|
|
||||||
|
**The policy flip is not P6's.** Making `Fail` return needs a real return path invented at every site
|
||||||
|
whose callers rely on `[[noreturn]]`, and a6 counted how many do. That is `Ph`'s (§11).
|
||||||
|
|
||||||
|
Two sites carry **no `Fatal{` marker at all** (`Client/PersistentMapTracker.cpp:1052-1058`,
|
||||||
|
`Transport/WireLog.cpp:41-50`), so "the log stays verbatim" is not true of them and the family grep
|
||||||
|
cannot see them. `dl` gives each a family tag.
|
||||||
|
|
||||||
|
### 5.3 The device-lost latch does not exist, and P6 writes it
|
||||||
|
|
||||||
|
`P6-CONTRACT-DRAFT §5.1` says the latch "is implemented unchanged". It is not implemented at all:
|
||||||
|
`FatalCode::DeviceLost`/`ServerCrashed` have zero producers and zero consumers,
|
||||||
|
`glGetGraphicsResetStatus` returns `GL_NO_ERROR` unconditionally
|
||||||
|
(`MG_Impl/GLImpl/Getter/GL_Getter.cpp:2855-2861`), and `MOBILEGL_IPC_RESPAWN` / `IDLE_EXIT_S` are
|
||||||
|
parsed **nowhere** (only a comment at `Config.h:466`). Today a dead server leaves the client
|
||||||
|
silently `DECLINE`-ing every verb forever with `glGetError` clean.
|
||||||
|
|
||||||
|
**It is a package (`dl`), not carriage.** The latch is session-scoped and set from
|
||||||
|
`Doorbell::PeerHungUp()` — D5c amends "`Dead()`" here, and §5.4's block says why — **never from a
|
||||||
|
timeout**. `MOBILEGL_IPC_RESPAWN=1` is a named refusal until some stage implements the re-push.
|
||||||
|
|
||||||
|
**LANDED.** `ClientSession::DeviceLost()` / `LatchDeviceLost()`, armed at the verb barrier, at the
|
||||||
|
forced run-ahead wait and at the control-reply wait, and read by `GetGraphicsResetStatus`, which
|
||||||
|
now answers **`GL_UNKNOWN_CONTEXT_RESET`**. Not `GUILTY` or `INNOCENT`: those assign blame, and the
|
||||||
|
server died for a reason that never crossed the wire — it could as easily have been a driver fault
|
||||||
|
as this client's draw. The consult and its include sit wholly inside `MOBILEGL_BUILD_DISAGGREGATED`;
|
||||||
|
G1 re-measured after it, **0 symbol diff and `.text` unchanged at `0xa52203`**. That measurement
|
||||||
|
also caught an unrelated 16-byte drift the guards did not: P6's O_APPEND log-sink fix was compiled
|
||||||
|
into the pull build too, and is now guarded for the same reason.
|
||||||
|
|
||||||
|
### 5.4 Slow, dead, and frozen are three states
|
||||||
|
|
||||||
|
- A published, never-applied record is **discarded at the latch, not waited on**.
|
||||||
|
- **Slow and dead are distinguished without a timeout threshold.** A server one frame behind is
|
||||||
|
P5e's intended steady state; a server that is gone is `Fatal{ServerCrashed}`. `SocketDoorbell`
|
||||||
|
already latches `m_dead` on EOF — take the fact from there.
|
||||||
|
- **A frozen peer produces no hangup**, and a6 found the tree has no defence: the control-reply wait
|
||||||
|
`m_controlDone.wait(lock, pred)` (`Server/ServerLoop.cpp:724`) has **no deadline**, while the ring
|
||||||
|
side has `kBarrierTimeoutMs`. A SIGSTOP'd or freezer'd server wedges the GL thread inside
|
||||||
|
`eglMakeCurrent` with no diagnostic.
|
||||||
|
|
||||||
|
**D5 ruling — two waits, two answers.** (a) The server's *in-process* mailbox wait gains a bound and
|
||||||
|
its expiry is `Fatal{ControlReplyTimeout, "<op>@<seq>"}`. (b) The client's *cross-process* reply wait
|
||||||
|
is bounded by `MOBILEGL_IPC_CONTROL_TIMEOUT_MS` (default 5000) and its expiry is **not** fatal: the
|
||||||
|
client consults the doorbell's death latch — dead latches device-lost, alive-but-silent is a named
|
||||||
|
diagnostic. Packages: `cp` (a), `dl` (b).
|
||||||
|
|
||||||
|
> **D5c — the client's self-bell CANNOT witness the server's death, and `sm` is why.** Measured, not
|
||||||
|
> predicted: `minecraft-1.21.4-fabric-iris-iterationrp-in-world` kills the *server* process outright
|
||||||
|
> on this machine (llvmpipe: `LLVM ERROR: Cannot select: intrinsic %llvm.x86.vcvtps2ph.256`, SIGABRT
|
||||||
|
> at call 159429), and the client did **not** take the `SessionWait::ShutDown` path that already
|
||||||
|
> exists and is already correct. It sat out the full 120 s and reported
|
||||||
|
> `Fatal{BarrierTimeout, "ResourceRespecify"}` — the wrong diagnosis, at 120 s a case, for a server
|
||||||
|
> that had been gone since the first second. Under monolith the same trace fails in 3 s.
|
||||||
|
>
|
||||||
|
> The cause is structural and is the price of the two-fd bell: the client parks on `clientBell[0]`
|
||||||
|
> (slot 5) and rings *itself* through `clientBell[1]` (slot 6), so it holds **both ends** of that
|
||||||
|
> socketpair. EOF arrives only when every writer closes, and the client is one of them — so that
|
||||||
|
> descriptor can never hang up, no matter what happens to the peer. A bell that can wake itself is
|
||||||
|
> a bell that cannot hear a death.
|
||||||
|
>
|
||||||
|
> **`dl` therefore needs a witness descriptor whose far end only the SERVER holds**, polled beside
|
||||||
|
> the park fd and never read from, whose `POLLHUP`/EOF latches `Dead()`. The control socket is
|
||||||
|
> already exactly that and needs no new descriptor. The fix does not belong to `sm`: holding both
|
||||||
|
> ends is required for self-notification and is not the defect — assuming one descriptor could
|
||||||
|
> answer both questions is.
|
||||||
|
>
|
||||||
|
> **LANDED.** `SocketDoorbell::SetDeathWitness(fd)`; the client hands it
|
||||||
|
> `SocketTransport::StreamFd()`. The witness enters the poll set with `events = POLLRDHUP` **and
|
||||||
|
> nothing else**, which is what lets it watch a socket it must never read: `POLLHUP`/`POLLERR`/
|
||||||
|
> `POLLNVAL` arrive in `revents` unrequested, so the hangup is seen while `POLLIN` never is — a
|
||||||
|
> control reply queued on that descriptor can neither wake the bell nor be consumed from under
|
||||||
|
> `SocketTransport`'s reassembler. Measured: `kill -9` on the server is noticed in **0.01 s**
|
||||||
|
> against a 120 000 ms barrier, and with the witness removed the same test takes the full 2 s
|
||||||
|
> retry budget and fails naming this paragraph.
|
||||||
|
>
|
||||||
|
> **`Dead()` AND `PeerHungUp()` ARE TWO FACTS, and only the second may arm the latch.** `Park`
|
||||||
|
> sets `m_dead` for `POLLERR`, `POLLNVAL` and unrecognised `revents` as well — each a fault in
|
||||||
|
> *this* process's descriptor — and `CondVarDoorbell::Kill()` sets it on every orderly `Stop()`.
|
||||||
|
> A latch taken from `Dead()` would report a lost GPU for a local fd bug and a context reset for
|
||||||
|
> every clean exit. `ADeadBellIsNotAlwaysAHungUpPeer` is the red-once for the distinction;
|
||||||
|
> `AnOrderlyStopIsNotADeviceLoss` is **not** — it stays green under the collapse, because under
|
||||||
|
> spawn the self bell is a `SocketDoorbell` and `Stop()` never kills one. That was found by
|
||||||
|
> running the falsification rather than by reading the code.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §6 The control plane (`cp`)
|
||||||
|
|
||||||
|
### 6.1 What `fc` landed, and what is left
|
||||||
|
|
||||||
|
P5f package `fc` framed the twelve `Server*` forwarders as value-only `SurfaceControlFrame`s and
|
||||||
|
landed the wire codec. The draft concluded `cp` is "transport only". **Three things are not
|
||||||
|
transport**, and a6 found all three:
|
||||||
|
|
||||||
|
1. The `InitCapabilities` **request** has no wire form (§2).
|
||||||
|
2. `SurfaceReply` cannot carry a `MobileGLResult` (§2).
|
||||||
|
3. **Neither side of the control plane is wired to a socket.** The apply thread's `ready` predicate
|
||||||
|
has exactly three terms — stop, `ControlIsPending()`, `cmdHead != LocalTail()` — and a socket is
|
||||||
|
not among them (`ServerLoop.cpp:398-402`), so a `SurfaceOp` arriving on the wire is read by
|
||||||
|
**nobody**. The client's pump consumes only `CapsSnapshot` and drops everything else with a WARN
|
||||||
|
(`ClientSession.cpp:1425-1432`).
|
||||||
|
|
||||||
|
### 6.2 D4 — who reads the control socket
|
||||||
|
|
||||||
|
A dedicated **`mgl-srv-io` thread**: `ReceiveFrame` → `DecodeWireSurfaceOp` → post into the
|
||||||
|
**existing** one-slot mailbox as an ordinary non-apply-thread poster. `ServerLoop.cpp:673-727` is not
|
||||||
|
changed. The io thread is additionally the server's **only** sender on the control transport:
|
||||||
|
`PublishCapsSnapshot` enqueues and the io thread drains one outbound FIFO — which is what fixes the
|
||||||
|
ordering hazard that `CapsSnapshot` is pushed from **inside the dispatch, on the apply thread,
|
||||||
|
mid-op** (`ServerLoop.cpp:959-969`).
|
||||||
|
|
||||||
|
Rejected: adding a fourth term to the apply thread's `ready` predicate. That puts frame decode on the
|
||||||
|
thread holding the native context and makes every control arrival a wake of the applier.
|
||||||
|
|
||||||
|
### 6.3 D7 — `seq`
|
||||||
|
|
||||||
|
The **client** mints, always, dense from 1, never reused in a session. `seq == 0` arriving on the
|
||||||
|
wire is `Fatal{ProtocolCorruption, "SurfaceOp.seq"}` at the **decoder**, not at
|
||||||
|
`RunSurfaceControlFrame`, whose local mint (`ServerLoop.cpp:659-662`) stays and becomes reachable only
|
||||||
|
for a local, non-wire post. Correlation lives in the client's control demultiplexer;
|
||||||
|
`DecodeWireSurfaceReply` keeps its void signature and stops being the place correlation was expected.
|
||||||
|
|
||||||
|
### 6.4 `ForgetCurrentTuple`
|
||||||
|
|
||||||
|
The N-3 rule holds identically on the frame path: the forgetting calls are inside the dispatch
|
||||||
|
(`ApplySurfaceControlFrame`) and `ServerLoopTest`'s C7/N-3 controls drive them through framed posts
|
||||||
|
unchanged. No change.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §7 Windows — rule H's enforcement (`cp`)
|
||||||
|
|
||||||
|
### 7.1 The blacklist is open, and the end state's first guest walks through it
|
||||||
|
|
||||||
|
`WindowBackendForWireWindowKind` (`Protocol/SurfaceOpCodec.cpp:104-113`) **accepts**
|
||||||
|
`WindowKind::X11 → WindowBackend::X11` and `Win32Hwnd → Win32`. `DecodeWireSurfaceOp` (`:141-179`)
|
||||||
|
refuses only `AndroidNativeWindow` and `MetalLayer`. An accepted kind's `nativeToken` is copied
|
||||||
|
through and `UnpackWindowHandle` (`Server/ServerLoop.cpp:875-882`) casts it to `void*`
|
||||||
|
**unconditionally**, whence it reaches `eglCreateWindowSurface` in the server process.
|
||||||
|
`DetectWindowBackend()` is a compile-time `#if` chain (`MG_Impl/EGLImpl/EGLImpl.cpp:59-70`), so a
|
||||||
|
guest cannot avoid announcing its own window system.
|
||||||
|
|
||||||
|
### 7.2 D8 — whitelist, and in P6 the accept set for a window op is empty
|
||||||
|
|
||||||
|
- `X11` → `Fatal{UnmigratedSurface, "X11@P12"}`; `Win32Hwnd` → `"Win32Hwnd@P12"`.
|
||||||
|
- `None` on a **window** op → `Fatal{ProtocolCorruption, "SurfaceOp.windowKind"}`. Today it is
|
||||||
|
accepted, maps to `WindowBackend::Unknown`, and the raw token is copied through anyway.
|
||||||
|
- Separately and independently: `nativeToken != 0` on **any** op →
|
||||||
|
`Fatal{ProtocolCorruption, "SurfaceOp.nativeToken"}`.
|
||||||
|
- `Pbuffer` / `Surfaceless` are surface **shapes**, not window backends, and remain the only things
|
||||||
|
P6 lands.
|
||||||
|
|
||||||
|
**Do not append `WindowKind::ServerOwned` in P6.** The schema is append-only, so an enumerator
|
||||||
|
appended now and re-meant later is a wire value burned; P6 has no consumer for it. P12 appends it.
|
||||||
|
|
||||||
|
### 7.3 The client emits unconditionally, and P6 must decide what that costs
|
||||||
|
|
||||||
|
`Client/BackendObject_Remote.cpp:214-216` posts `SetWindowHandle` with no split-arm check, so on a
|
||||||
|
real Android app the **first `eglCreateWindowSurface` aborts the server process** and the client sees
|
||||||
|
only a dead peer. `cp` mirrors the refusal on the **client** side, so the diagnostic names the cause
|
||||||
|
in the process that caused it. This is P6's, not P12's, because P6's device lanes run on a phone.
|
||||||
|
|
||||||
|
### 7.4 `m_windowHandle` has four stores, not one
|
||||||
|
|
||||||
|
a6's precise shape, correcting the corpus (and `P6-ENDSTATE-REVIEW §2.5`): four stores
|
||||||
|
(`MG_Backend/BackendObject.cpp:475`, `:365`, `:206`, `:207`), five reads, and `:283` is a **call**,
|
||||||
|
not a store. `.Width`/`.Height` have **no readers**. The smallest latch point for a server-owned
|
||||||
|
window is `RegisterEGLWindowSurface` (`:232-238`), and the non-obvious fourth edit is the
|
||||||
|
`sameHandle` dedup key (`BackendObject_DirectGLES.cpp:962-967`), which under server ownership never
|
||||||
|
matches and would rebuild the native context on every `eglCreateWindowSurface`. Recorded here for
|
||||||
|
P12; P6 changes none of it.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §8 The data plane (`lk` implements, `c6` declares)
|
||||||
|
|
||||||
|
### 8.1 Why a seam at all
|
||||||
|
|
||||||
|
`ITransport.h:16-20` says in its own header that the hot path bypasses it: it is the **control**
|
||||||
|
plane, and that scope is already correct for a socket. Below it there is **no interface of any kind** —
|
||||||
|
`Ring.h`, `ReplySlot.h` and `EventRing.h` take raw `void* base + capacity`. So "swap the transport"
|
||||||
|
has nothing to swap.
|
||||||
|
|
||||||
|
`c6` declares `Transport/ILink.h` and `Transport/StreamLink.h`. `lk` implements `ShmLink` by moving
|
||||||
|
today's `SessionSegments` / `Ring` / `ReplySlotPool` / `EventRing` behind the interface, line for
|
||||||
|
line, with **zero behaviour change**.
|
||||||
|
|
||||||
|
### 8.2 The seam is a setup-time interface, not a hot-path one
|
||||||
|
|
||||||
|
`ILink` hands out POD handles **once at attach** and then stays out of the way. No `ILink` virtual is
|
||||||
|
called per record, per publish, or inside any spin predicate. Three grounds, and the second is
|
||||||
|
decisive:
|
||||||
|
|
||||||
|
1. Two virtuals per record at the 4000 records/frame that `SEG_CMD` is sized against is ~8000
|
||||||
|
indirect calls/frame — about 0.5% of the measured 15.72 ms client frame. Affordable, but the only
|
||||||
|
lane that could measure it has ±4% run-to-run dispersion, **eight times the effect**, so the gate
|
||||||
|
`P6-ENDSTATE-REVIEW` demands could only ever print "within noise" — a green that proves nothing.
|
||||||
|
2. **The spin predicate forbids it outright.** `Doorbell::Wait` is a non-virtual template whose spin
|
||||||
|
loop calls `ready()` up to `SpinItersPerUs() * spinUs` times; at 916 waits/frame with 99.8%
|
||||||
|
resolved inside the spin, the predicate runs 10⁵–10⁶ times per frame and reads the watermarks
|
||||||
|
straight off the page. That is the 31.58%-of-the-GL-thread path. A virtual there is not a rounding
|
||||||
|
question.
|
||||||
|
3. The encode path already depends on four inline accessors around its single `Reserve`, and
|
||||||
|
virtualising `Reserve` alone would force either four more virtuals or moving R-10's wrap counters
|
||||||
|
behind the seam — and those are deliberately encoder-owned.
|
||||||
|
|
||||||
|
**The gate is therefore an `objdump` call-count of the encode path, not a wall clock**: after `lk` the
|
||||||
|
path must have no more out-of-line calls than today. That is falsifiable; "within noise" is not.
|
||||||
|
|
||||||
|
### 8.3 `RingControl`'s regroup is `lk`'s, and it is a wire break the day a second build exists
|
||||||
|
|
||||||
|
The watermark cache line is `{appliedSeq, submittedSeq, retiredSeq, completedFrameSerial,
|
||||||
|
presentAckSerial}`; `eventRingFull`/`eventDropped` sit in a **separate** `alignas(64)` group with
|
||||||
|
`serverEpoch`/`ringGeneration`/the two park flags. And `submittedSeq` is **producer-written**
|
||||||
|
(`Ring.h`'s "THE FIVE WATERMARKS" block) while the other four are consumer-written — so the group has **mixed writers**, and any
|
||||||
|
"single-writer progress block aliased over the watermark line" is unsound.
|
||||||
|
|
||||||
|
`lk` therefore **regroups**: `submittedSeq` moves to the producer's own line, beside `cmdHead`,
|
||||||
|
which is the other thing the producer writes; what is left — the four consumer-written watermarks —
|
||||||
|
becomes a named `LinkProgress` member with per-field `offsetof` static_asserts.
|
||||||
|
|
||||||
|
> **Correction, found while `lk` was measuring its own blast radius.** An earlier revision of this
|
||||||
|
> section, and of `ILink.h`, also promoted `eventRingFull`/`eventDropped` into the watermark group
|
||||||
|
> and called the result single-writer. **Both were wrong.** `eventRingFull` has two writers: the
|
||||||
|
> server latches it with `store(1)` when `SEG_EVENT` fills (`Transport/EventRing.h:140`) and the
|
||||||
|
> **client clears it with an `exchange(0)` on every drain** (`:200`). Promoting it would put a
|
||||||
|
> per-drain RMW by the client on the same cache line as `appliedSeq` — which the server
|
||||||
|
> release-stores every 64 records and the client's spin predicate reads 10⁵–10⁶ times per frame.
|
||||||
|
> That is new false sharing on the hottest line in the system, and it would land in exactly the
|
||||||
|
> numbers this package's gate has to hold constant. The two flags stay in the doorbell/generation
|
||||||
|
> group, where mixed writers already live beside `consumerParked`/`producerParked`, and cross the
|
||||||
|
> seam through a separate `EventFlags()` accessor. *Accessor*, not line: they share
|
||||||
|
> `serverEpoch`'s line, which is where mixed writers already live.
|
||||||
|
|
||||||
|
It is free **today** — both peers are the same binary, enforced by the fingerprint — and a wire break
|
||||||
|
the day a second build exists. It is **`lk`'s and not `c6`'s** because the rename blast radius is
|
||||||
|
**109 sites in production alone**, not the 39 an earlier draft assumed, and because five of them sit
|
||||||
|
behind `#if defined(MGITEST_SPLIT_RUNTIME_PEEK) && !defined(__ANDROID__)` — an Android configure
|
||||||
|
compiles them out, so a missed rename is green on device and red only on a desktop split-peek build.
|
||||||
|
`lk` publishes the per-file itemisation before it starts.
|
||||||
|
|
||||||
|
### 8.4 What `StreamLink` is for
|
||||||
|
|
||||||
|
Every method is a named refusal, `Fatal{UnmigratedDataPlane, "StreamLink@P6.5"}`. It exists so the
|
||||||
|
seam's adequacy is a **compile**, not an argument: if `ILink` cannot name what a byte stream needs,
|
||||||
|
`StreamLink` cannot be declared against it. Writing it is what revealed that the seam needs
|
||||||
|
`FlushProgress()`, `ResolveSpan()` and a reply pair — three methods the brief's own list
|
||||||
|
(progress transmission, send window, flush) did not name.
|
||||||
|
|
||||||
|
`c6`'s red-once: delete one `ILink` method `StreamLink` declares and the build goes red.
|
||||||
|
|
||||||
|
### 8.5 The purity gate (`lk`)
|
||||||
|
|
||||||
|
After `lk`, the identifiers `RingControl`, `RingProducer`, `RingConsumer`, `ReplySlotPool` and
|
||||||
|
`EventRingConsumer`, and any `m_shm.` expression, appear **only** inside `Transport/ShmLink.*` and
|
||||||
|
the transport's own tests. Same shape as the existing A/B/C purity gates. The baseline is recomputed
|
||||||
|
mechanically at `lk`'s head and published per file — the earlier draft's ratchet number was wrong by
|
||||||
|
a factor of three, and a ratchet installed at the wrong number is red on day one for reasons that
|
||||||
|
have nothing to do with a leak.
|
||||||
|
|
||||||
|
### 8.6 `SEG_STAGE`'s cursors are deliberately dead
|
||||||
|
|
||||||
|
`Ring.h`'s "DEAD IN P5, DELIBERATELY" states it and a test pins it: `SEG_STAGE` is **not a ring**; staging is an
|
||||||
|
encoder-local linear allocator reclaiming on `retiredSeq`, and all three stage cursors stay zero for
|
||||||
|
the whole of P5. A stream link's send window either revives them **completely** or does not use them;
|
||||||
|
the header names the middle state as *a guaranteed hang rather than a slow path*. P6.5's, recorded
|
||||||
|
here so it is not rediscovered.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §9 The gate
|
||||||
|
|
||||||
|
Beyond the five-part gate (`docs/Disaggregated/ARCHITECTURE.md` §13.2):
|
||||||
|
|
||||||
|
1. **G1** — pull build 0/0/0/0, `.text` unchanged. Every predicate in §3.2 folds away.
|
||||||
|
2. **G2/G14** — `integration-spawn`'s case-name set identical to `integration-split`'s.
|
||||||
|
3. `integration-spawn` green at the same count as `integration-split`.
|
||||||
|
4. **Process tree, mechanical** — exactly one extra child while running, zero after; `HeadlessGL`'s
|
||||||
|
fork pre-check leaves no orphan.
|
||||||
|
5. **Arm proof (ID-124)** — every spawn entry records the child pid and `transport=spawn` in its own
|
||||||
|
private log. A spawn lane that fell back to monolith passes items 1–4. §1 is why this gate is not
|
||||||
|
optional: today the fallback and the intended state are **the same value**.
|
||||||
|
6. **Red-once per package (R-16)**, one named pair each.
|
||||||
|
7. **Device** — Redmi `2f7cbe2e`, reboot-clean, paired A/B in one thermal window.
|
||||||
|
8. **Performance recorded, not gated**, but three numbers are mandatory: the socket doorbell's cost
|
||||||
|
against `inproc`'s condvar; `SEG_STAGE` bytes/frame; and records/frame **post-chunking**. The last
|
||||||
|
two are takeable on the existing inproc lane today and `MEASUREMENTS.md:342` says in as many words
|
||||||
|
that no post-chunking distribution exists.
|
||||||
|
|
||||||
|
> Item 8's wording must be able to **accept a negative regression without looking suspicious**: today
|
||||||
|
> the client spins ~1600 times/frame on a shared cache line with 99.8% of waits resolved there, and a
|
||||||
|
> socket link has no such line. Converting that into ~4 blocking reads/frame may be **cheaper**.
|
||||||
|
|
||||||
|
Negative controls, each run red once:
|
||||||
|
|
||||||
|
| # | knob | what it must falsify | package |
|
||||||
|
|---|---|---|---|
|
||||||
|
| S1 | `MOBILEGL_IPC_SERVER_PATH=/nonexistent` | named refusal, not a silent monolith fallback | `sm` |
|
||||||
|
| S2 | `kill -9` the server mid-frame | the latch; the client never hangs and never keeps submitting. Red-once the **wrong implementation** too: set the latch from a timeout and the paired control "a server one frame behind is the normal state" must go red | `dl` |
|
||||||
|
| S3 | child envp not scrubbed | `Dial = No` catches it **and the diagnostic names which of the two catches fired** | `sm` |
|
||||||
|
| S4 | inherited P5f epoch invalidation disabled | a replaced context inherits stale synced state; a still-live XFB lifetime retains its paused span | `st` |
|
||||||
|
| S5 | `WindowKind::X11` with a plausible XID reaches the server | named Fatal, **and the gate falsifies that the token reached `UnpackWindowHandle`**. Today's S5 tests only `AndroidNativeWindow` and stays green with §7.1's hole open | `cp` |
|
||||||
|
| S6 | a peer offers `LinkTerms.dataPlane = StreamOnly` | refused by name, **and the server survives to serve the next connection** | `hs` |
|
||||||
|
| S7 | a bare `abort()` added outside `Session::Fail` | the census gate goes red | `dl` |
|
||||||
|
| S8 | — | `integration-spawn` asserts `SessionFaultCount() == 0` over a whole run: the **good-path** assertion E1/ID-122 wanted and could not express, and which S5/S6 can falsify | `t6` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §10 Amendments
|
||||||
|
|
||||||
|
### 10.1 To `P6-CONTRACT-DRAFT.md`, which this file supersedes
|
||||||
|
|
||||||
|
1. §1's "ABI fingerprint | Unchanged … same-machine, same-binary" → §4.
|
||||||
|
2. §5.1's "The latch … is implemented unchanged" → **false**; §5.3.
|
||||||
|
3. §4's "P6's remainder is TRANSPORT ONLY" → **false in three ways**; §6.1.
|
||||||
|
4. §7's "a transport swap and nothing else" → **no longer true**. This file adds `lk`, `hs` and `dl`
|
||||||
|
to the package list and says so here rather than smuggling it.
|
||||||
|
|
||||||
|
### 10.2 To the earlier contracts
|
||||||
|
|
||||||
|
1. `CONTRACT-P5C.md:537-539` — EGL value framing was discharged by P5f `fc`, the unpack/render-state
|
||||||
|
epoch work by P5f `fs`. P6 carries the existing frames over the socket and verifies the inherited
|
||||||
|
lifecycle rules in the second process.
|
||||||
|
2. `CONTRACT-P5C.md:56` — P6's multi-context shape. **Declined**: P6 stays single-context. §11.
|
||||||
|
3. `Transport/ReplySlot.h`'s "P6 debt" for the 2 MiB reply cap and chunked readback. **Declined**:
|
||||||
|
P9's. Note `P6-SPAWN-PLAN §8.5` already reassigned it and the header was never updated — two
|
||||||
|
documents in the tree disagreed; this file settles it.
|
||||||
|
4. `Ring.h`'s "BATCHING MAY ONLY MAKE A WATERMARK LATE" — `appliedSeq` is excluded from lazy publication **by name**. P6 does not change
|
||||||
|
the behaviour; it records that any future stream link **amends** this rule rather than inferring
|
||||||
|
around it. Several designs have argued the late-never-early invariant licenses lazy `appliedSeq`;
|
||||||
|
it explicitly carves `appliedSeq` out.
|
||||||
|
5. `ARCHITECTURE.md:488` — the child-forces-monolith rule. **Amended**; §3.1.
|
||||||
|
6. `ARCHITECTURE.md:9` and `MG_Backend/MGPipe/PipeInputs.h:281`, `:744`, `:957`, and
|
||||||
|
`P5F-WIRE-COMPLETENESS §1.4` — "the server does not link `MG_Impl`". **False at this head.** §12.
|
||||||
|
|
||||||
|
### 10.3 Amendments of 2026-09-22 — the end state re-ruled
|
||||||
|
|
||||||
|
1. **The end state is TCP across machines, OSes and architectures**, not an AVF pVM over
|
||||||
|
`AF_VSOCK`. `docs/Disaggregated/P6-ENDSTATE-REVIEW.md` carries the retraction at its head; its
|
||||||
|
§3 gains form **D**. Same-machine `spawn` (AF_UNIX + shared segments) stays as the local form.
|
||||||
|
2. **The transport stack has two independent axes.** The control plane (`ITransport`: `fork`
|
||||||
|
inherited fds / `unix:<path>` / `tcp://host:port`) and the data plane (`ILink`: `ShmLink` /
|
||||||
|
`StreamLink`) are chosen separately, negotiated in the handshake, and may be mixed — on one
|
||||||
|
machine, control over TCP with data over shared segments is a legal pair. Callers above
|
||||||
|
`Transport/` see `ITransport` + `ILink` and nothing else; branching on the link kind above that
|
||||||
|
line is a purity-gate failure (the `lk` grep gate, widened). Design: `ARCHITECTURE.md` §11.9.
|
||||||
|
3. **§8.2's "`ITransport` is not extended" is amended in one respect**: descriptor passing leaves
|
||||||
|
the control plane and becomes the shared-segment data plane's *delivery*. `ShmLink` brings its
|
||||||
|
own AF_UNIX aux rendezvous, named in `Welcome`, and `SCM_RIGHTS` travels on that and nowhere
|
||||||
|
else. Rule G is unchanged: a transport that declares no descriptor passing (TCP) passes none,
|
||||||
|
and the data plane that needs it must bring its own channel or not be selected. `auto`
|
||||||
|
selection is decided by a **successful delivery**, never by inspecting addresses, and a
|
||||||
|
fall-back to `Stream` is named in the log and the stats line.
|
||||||
|
4. **§2's three `hs` rows** (`LinkTerms`, `Refuse`, the fingerprint split) did not land in `hs`;
|
||||||
|
`protocol.fbs` carries neither `LinkTerms` nor a `Refuse` member of `CtrlMsg`. They are P6.5's
|
||||||
|
(`nd`, `wf`), and S6 in §9 moves with them. `CURRENT_STAGE_PROGRESS.md`'s earlier claim that
|
||||||
|
S6 had been run red is withdrawn.
|
||||||
|
5. **Fixed-width wire form is no longer negotiable-later.** Two different binaries from two
|
||||||
|
compilers are the end state, so the `PipeFields.def`-derived layout digest, the fixed-width
|
||||||
|
rewrite of `DynamicBackendParameters` / `MGPCaps` / the `RenderStateParameters` blob, and the
|
||||||
|
`buildFingerprint`-only-under-`Dial == Fork` policy are P6.5 `wf`, taken off P7.
|
||||||
|
6. **`Ph` gains pairing/authentication**: a `Hello` without a pairing token is refused on any
|
||||||
|
non-loopback listener. `Ph` precedes P12's non-loopback listen.
|
||||||
|
7. **"The 511 class-C entries" in §11** is the P5-joint census
|
||||||
|
(`docs/Disaggregated/notes/p6/census-classC.md`). At this head the `MGR_UNMIGRATED_*` lists are
|
||||||
|
empty; `SetSwapInterval` (P10) and `DeleteTransformFeedback` (P9) are the two that remain.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §11 Not P6
|
||||||
|
|
||||||
|
Real window arrival and the `android:process=":mgl"` Service (P12); multi-context (P12); chunked
|
||||||
|
readback and the reply-slot pool (P9); `DynamicBackendParameters`' fixed-width rewrite (P7);
|
||||||
|
`MOBILEGL_IPC_POLL_ESCALATE` (P10); remaining monolith-only frontend-object / twin-registry glue
|
||||||
|
(P3b/P4b) and the named P7 functionality debts; Windows `pipe:` / `unix:`; the 511 class-C entries.
|
||||||
|
|
||||||
|
**The two-axis transport stack — control × data, TCP-capable, cross-build — is P6.5** and is the
|
||||||
|
IPC track's next stage (§10.3). P9 builds its reply semantics on P6.5's message replies rather than
|
||||||
|
on a slot pool, and P11's T0/T1 are refused by name on a stream data plane.
|
||||||
|
**Untrusted-guest hardening is `Ph`**, and it must land before any shipping server app accepts a
|
||||||
|
connection from a guest it did not produce — including the `Fatal`-policy flip (§5.2), the
|
||||||
|
handle-slot budget, and the caps in §12.
|
||||||
|
|
||||||
|
E1's re-specification (ID-122) is **not** discharged by P6 and does not become P6's because P6 starts.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §12 Recorded debt
|
||||||
|
|
||||||
|
### 12.1 The server image links `MG_Impl` in P6 (D12)
|
||||||
|
|
||||||
|
**P6's server image is the whole `libMobileGL.so`** — which is what `ARCHITECTURE.md:496`'s "one
|
||||||
|
shared library, two roles" always meant. The assertions that the server does not link `MG_Impl` are
|
||||||
|
false and become debt with named owners.
|
||||||
|
|
||||||
|
Measured: **184 symbols**, 177 of them real function calls, that the server set needs and only
|
||||||
|
`MG_Impl` / `MG_State` / `MG_Remote/Client` define. Owners: **P7 101**, **P3b/P4b 14**, both backends
|
||||||
|
**60**, **P6's own 6**. There is additionally **no module target to link** — `SOURCE_FILES` is one
|
||||||
|
flat list feeding both library targets — so establishing module boundaries is itself named work,
|
||||||
|
owed to P13. Method and full symbol list:
|
||||||
|
[`a6-link-experiment.md`](../../docs/Disaggregated/notes/p6/a6-link-experiment.md).
|
||||||
|
|
||||||
|
**P6's own six** are not P7's and are `sm`/`lk`'s to clear: `Server/PipeApplier.cpp` calls
|
||||||
|
`Client::ClientSession::NoteApplyThreadEnteredApplier()` / `NoteApplyThreadLeftApplier()`;
|
||||||
|
`Wire/PipeWireCodec.cpp` needs `MG_State::GLState::DecodeProgramArchive` and
|
||||||
|
`Client::AdoptTierIsEmulate()`; `MG_Pipe/PipeApply.cpp` needs `Client::ClientSession::Active()` and
|
||||||
|
`AdoptTierIsEmulate()`.
|
||||||
|
|
||||||
|
**Gate**: a ratchet recomputes the 184 in CI and asserts it only ever falls.
|
||||||
|
|
||||||
|
### 12.2 D11 — five unbounded peer-driven allocations, capped, with no `try`/`catch`
|
||||||
|
|
||||||
|
Every peer-declared count is bounded **before** it reaches an allocator and the bound is a named
|
||||||
|
refusal. `MG_Remote` gets no `try`/`catch`: a cap that is checked is better than an exception that is
|
||||||
|
caught, and the funnel (§5.2) is where the diagnostic lives.
|
||||||
|
|
||||||
|
| site | today | package |
|
||||||
|
|---|---|---|
|
||||||
|
| `MG_Pipe/PipeApply.cpp:1563-1569` | resizes to a peer-supplied `Cso.Slot + 1` with **no slot limit**; every sibling create-family goes through `RecordAt`'s bounded path. `Slot = 0xFFFFFFFE` asks for ~1.7 TB | `dl` |
|
||||||
|
| `Server/PipeApplier.cpp:416-441` | readback scratch resized from `Box.W * Box.H * bpp` **before** any size gate. 65535² RGBA8 asks for ~17 GB | `dl` |
|
||||||
|
| `MG_State/.../ProgramArtifactsCodec.cpp:166-175`, `:216-223` | count bounded by remaining **bytes**, then multiplied by `sizeof(element)` | `dl` |
|
||||||
|
| `Server/StagedTextureStore.h` | resize not bounded against the level's declared extent | `Ph` |
|
||||||
|
| `SEG_EVENT` overflow | a guest that merely stops draining kills the host renderer in 60 s | `Ph` |
|
||||||
|
|
||||||
|
### 12.3 One guest per server process (D9)
|
||||||
|
|
||||||
|
For the whole of P6, one server process serves exactly one client session, and it is a **structural
|
||||||
|
fact, not a preference**: `g_Display`/`g_Context`/`g_Surface`/`g_Config` are per-process file-statics
|
||||||
|
and `InitDisplayAndContext` opens with an unconditional `DestroyEGLContext()` whose last act is
|
||||||
|
`eglTerminate` — a **process-wide** EGL teardown. `ServerSession::Accept`'s same-object arm
|
||||||
|
(`ServerSession.cpp:425`) returns `MOBILEGL_ERR_INVALID_ARGUMENT` **with no log line at all**; `sm`
|
||||||
|
gives it one. Under `Dial == Fork` a second guest is unreachable by construction, so the invariant
|
||||||
|
becomes falsifiable only under `Dial == Connect`, which P6 does not land.
|
||||||
|
|
||||||
|
### 12.4 Settled by ruling rather than by experiment
|
||||||
|
|
||||||
|
- **Who runs the applier in the server process**: `ServerMain` **must** drive it through
|
||||||
|
`ServerLoop::Start()`, so `g_applyThreadKey` is published and the dozen `OnApplyThread()` guards
|
||||||
|
keep meaning what they mean. Owner `sm`; red-once drives the applier without `Start()`.
|
||||||
|
- **The server's exit primitive**: `_exit`, after an explicit log flush. It decides whether
|
||||||
|
`g_processTeardown` is set and therefore whether seven twin destructors take their early-out.
|
||||||
|
Owner `sm`.
|
||||||
|
- **The handshake asserts the resolved subsystem mask**; a mismatch is `Refuse`, not `Fatal`. The
|
||||||
|
envp scrub list does **not** include `MOBILEGL_PIPE_*`, so the two processes can resolve different
|
||||||
|
masks from their own environments. Owner `hs`.
|
||||||
|
- **P6 maps no segment read-only.** `ShmSegment.h:62-63`'s stated design — the peer gets
|
||||||
|
`SEG_CMD`/`SEG_STAGE` read-only on the server side — **cannot be implemented as written**, and the
|
||||||
|
comment is corrected rather than left to mislead. Owner `lk`.
|
||||||
|
- **`DualBlockScenario`'s `serverIdentity != nullptr`** is an in-process fact, and G2/G14 requires
|
||||||
|
the spawn lane to keep the case name. Its assertions are **re-homed**, not weakened: `DualBlockPeek`
|
||||||
|
becomes a control-plane query answered by the server process. The declared fallback — assert
|
||||||
|
`MGPipeBlocksAreDistinct()` on the client side and carry the identity half by §3.4's server-side
|
||||||
|
Fatal — must be **declared here** if taken, not discovered in review. Owner `t6`.
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# P6.5 第一波:TCP 控制与 stream 数据
|
||||||
|
|
||||||
|
2026-09-22。依据 `docs/Disaggregated/ROADMAP.md` 的「立即的下一项」。本文件记录实现所需的协议细节;验收结果单独记入阶段报告,不能用本文件代替运行证据。
|
||||||
|
|
||||||
|
## 范围与配置
|
||||||
|
|
||||||
|
本波实现 POSIX client/server 的全 TCP 连接;主验收形态是 WSL x86_64 client 与 Redmi aarch64 server。保留 inproc 与 fork/UNIX 的共享段路径。Windows client、TCP 控制加共享段、压缩、内容去重、异步 reply、真实窗口均不在本波。
|
||||||
|
|
||||||
|
`MOBILEGL_TRANSPORT=spawn` 表示两进程拓扑。`MOBILEGL_IPC_CONTROL` 选择 `fork`(默认)、`unix:<path>` 或 `tcp://host:port`,`MOBILEGL_IPC_DATA=auto|shm|stream` 选择数据面。本波 TCP 只接受 stream,fork/UNIX 只接受 shm;不支持的显式组合具名拒绝。Connect 不启动本地子进程,实际 server pid 来自 Welcome。
|
||||||
|
|
||||||
|
TCP 两条连接依次为控制和数据。每条均设置 NODELAY、KEEPALIVE,Linux/Android 另设置 KEEPIDLE=2、KEEPINTVL=1、KEEPCNT=3、USER_TIMEOUT=5000。网络错误和 EOF 才触发 peer-hung-up;apply 超时不是 device loss。无 `MOBILEGL_IPC_TOKEN` 的 listener 仅能绑定 loopback;错令牌返回 Refuse,不打印令牌值。
|
||||||
|
|
||||||
|
## 握手与布局
|
||||||
|
|
||||||
|
Hello/Welcome 追加 `wireFingerprint`、`LinkTerms`,Hello 带 dial 与 token,Welcome 带实际 backend。原 union 标签不重排;Refuse 与 LogFlush 追加。Refuse 是正常的拒绝结果,不能改成 ABI mismatch abort。
|
||||||
|
|
||||||
|
wire 指纹覆盖 PipeFields 逐成员名称/offset/size、按序 opcode/payload/flags/WaitClass、记录头、句柄、render-state 字段表、blob codec 版本、协议版本、字节序、指针宽度与 caps/dynamic-parameters 布局。build stamp 单独比较:Fork 必须相同,Connect 不同只警告,`MOBILEGL_IPC_REQUIRE_SAME_BUILD=1` 则拒绝。窗口尺寸由 server 陈述,不进入布局指纹。DynamicBackendParameters 使用定宽整数;没有借机改 GLFunctionsTable ABI。
|
||||||
|
|
||||||
|
启动必须收到并采用真实的首个 CapsSnapshot,之后才能锁存 run-ahead 并宣布 session started。
|
||||||
|
后台控制 reader 尚未把 caps 放入 inbox,不能解释成 server 不支持能力;也不能先用 placeholder
|
||||||
|
永久锁成 lockstep,再期待后来的快照自动提升。后续快照仍只允许 demotion,缺少首 caps 是有界启动失败。
|
||||||
|
|
||||||
|
program archive 在 split 构建使用 v2,头中校验真实序列化 schema 摘要,且版本和摘要进入握手指纹。v1 的宿主对象大小 echo 在 Linux 是 1056,在 Android 是 0,不能用于跨端兼容判定;libstdc++ 与 libc++ 的字符串/容器布局不相同,即使两端都是 LP64。payload 按字段序列化,schema 递归覆盖字段名、次序和类型,不包含容器宿主 sizeof/offsetof。宿主大小编译绊线保留为本地维护检查;非 split 路径保留 v1,G1 不因此让步。
|
||||||
|
|
||||||
|
## 数据面与生命周期
|
||||||
|
|
||||||
|
ILink 拥有数据面存储与端点。ShmLink 保留映射、reply slot pool 和现有 ring 实现;StreamLink 拥有私有镜像。session 只缓存端点/进度指针;reserve/pop 仍使用原有非虚 ring 操作。测试兼容的原始 ring 构造入口和启动时的 descriptor 交付不作为生产链路选择入口。
|
||||||
|
|
||||||
|
数据帧含 MGLD magic、长度、kind、两个 64-bit 字段及 payload。Stage 在引用它的 Cmd 之前发送;Cmd/Event 按逻辑 cursor 严格顺序接收并检查容量。接收线程先写数据,再 release 发布 head/水位。每侧数据连接有一个独立 reader;发送在调用线程串行进行,不引入无界发送队列。
|
||||||
|
|
||||||
|
进度保留单调、`>=`、只能晚不能早的规则。Progress 必须包含 **cmdRetiredTail**:FreeBytes 依赖退役尾,只有 applied tail 不能回收 borrowed record,也不能保证环回绕。event credit 以 ClientProgress 返回。越窗、非法方向、倒退水位是 ProtocolCorruption。
|
||||||
|
|
||||||
|
server 在 park 前、Reply 之后、present/completion 变化时冲刷进度,并按 64 条记录/1 ms 合并普通进度。client 每个等待点先 Flush。Stream reply 使用 seq 标识的消息邮箱;已经观察到 applied 却没有相应 reply 必须拒绝,不能永久等待。ShmLink 保留旧 slot 语义。
|
||||||
|
|
||||||
|
Present 与 `glFlush` 也是 client 的发送边界:将已经发布的批次交给对端,保持 run-ahead,不新增 apply 等待。单靠下一次 credit wait 冲刷,会让最后一帧在 client 随后空闲时永久留在本地,credit=3 时还会把前三帧积在发送端。
|
||||||
|
|
||||||
|
已经丢失连接或在 stage/cmd 空间等待中观察到真实挂断时,编码器取消本次及后续发射:不复制新 blob、不增加 wire seq,返回 DECLINED,并保留本地 reply ticket 的合法性。只因超时不能闩 device loss;stage 空间等待使用与 barrier 一致的 120 秒上限,让传输层有时间报告半开连接的失败。
|
||||||
|
|
||||||
|
两条 TCP 连接之间没有到达顺序保证。因此 surface RPC 前先等待此前提交的命令;SurfaceReply 另携带 **eventHead**。server 冲刷事件后发回复,client 等数据 reader 收到该 head 后才完成 RPC。仅按两个 send 的先后推断 SurfaceChanged 已到达是错误的。
|
||||||
|
|
||||||
|
## 控制、日志和进程
|
||||||
|
|
||||||
|
client 的专用控制 reader 直接落盘 LogLine,其他控制消息进入有界 inbox,避免 GL 线程等数据时 server 因日志 socket 写满而停住。server 同时写本地日志并前送;client 写自己的 `<base>.server.log`。`MGPipeSyncPeerLog()` 先同步命令,再以 LogFlush/ack 对齐日志观察点。正常的无远端情形是 no-op,损坏的 ack 不能静默成功。
|
||||||
|
|
||||||
|
supervisor 接受连接后 fork,每会话独立进程,父进程不创建 backend/EGL;同时只允许一会话,第二个返回 Busy。父进程关闭自己的 socket 副本时 **不调用 shutdown**,否则会关闭 child 仍使用的连接。后端由 Hello 请求,显式 server 环境钉住的后端不匹配则拒绝。server 子进程保留 P6 的 PipeStats Init/Shutdown。
|
||||||
|
|
||||||
|
正常 client 结束请求时只先关闭控制 socket 的写半边,等 server 完成 backend 销毁、最终日志和进程退出后的 EOF,再完成本地关闭。否则连续的独立 client 会抢到前一会话仍在清理的时间窗。Busy 拒绝在读取 Hello 后发送,避免带未读请求直接 close 引发 TCP RST,丢掉已经排队的 Refuse。
|
||||||
|
|
||||||
|
trace flavour 的前台 MobileGLServerService 从 nativeLibraryDir 启动可执行 server,设置服务端角色与反递归标志,持 wake lock。`am force-stop` 终止该包的服务进程。
|
||||||
|
|
||||||
|
## 带宽和测量口径
|
||||||
|
|
||||||
|
第一波不启用压缩或内容去重。P6 gate 8 的 rd12 stage 中位/均值是 816,248 / 1,534,555 B/帧,60 fps 对应约 49 / 92 MB/s;OpenRA 短样本均值明显受加载尖峰影响。该数据已经说明 Wi-Fi 可能成为瓶颈,但没有压缩率、额外 CPU 或纹理重复率证据,不能据此选定压缩算法,也不能宣称已满足 60 fps。
|
||||||
|
|
||||||
|
`MOBILEGL_PIPE_STATS=1` 下,P65LinkMetrics 记录逐帧 reply 次数、RTT 固定桶、stage bytes、wall time 与 client thread CPU。p50/p99 为桶上界;回复的测量包含必要的发送、排队与 apply,不能冒充空载网络 ping。Stage 字节/帧除以 wall time 是负载流量;链路吞吐另用真实 TCP 64 MiB 突发测量。与 PipeStats 的同源字节计数是独立观测,不能相加。
|
||||||
|
|
||||||
|
## 验收中的两处澄清
|
||||||
|
|
||||||
|
- 车道 parity 比较 DirectGLES 的可比用例集合,而不是不同标签下的总条数;当前基线是 102 条。TCP 每条还需真实 `control=tcp data=stream server=... pid=N` 证明与本地零子进程断言。fixture 不算用例通过数,禁止用 EGL 启动失败的 SKIP 代替通过。
|
||||||
|
- lf 文档列出的四个 arming 场景中,UnlocatedIoBlock、PrimitivesGeneratedNoXfb、PointSizeDemotion 的 marker 来自 server;关闭日志前送应让对应断言变红。PipeVerifyArming 的 marker 来自 **client PipeFill**,关闭 server 前送本来就不应使它变红;它应继续通过,作为角色分离对照。不得伪造一个 server marker 来满足错误的负控预期。
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
# CONTRACT-P7 — Magma(DirectVulkan)全量走完拆分路径
|
||||||
|
|
||||||
|
权威:本文,与 `CONTRACT-P5.md`(表 0、字节载体、字段归属、R-1…R-17)、`CONTRACT-P5C.md`(规则 E、两个具名豁免、`SEG_EVENT`、守卫)、`CONTRACT-P5E.md`(规则 F、等待规则)、`CONTRACT-MAGMA-RUNAHEAD.md`、`CONTRACT-P6.md`(规则 G/H、死亡漏斗、§12 记录债)、`CONTRACT-P65.md`(两轴传输、布局指纹、`LinkTerms`)并列;与它们不一致处以本文为准,§10 逐条列出。基线:`feat/disaggregated @ 78b7d6be`。`file:line` 均在该提交上读取;路径在 `MobileGL/` 下,除非以 `docs/` 开头。
|
||||||
|
|
||||||
|
**怎么改。** 集成者的文件。wave 2 的实现包(A / B / C / D / E / F,§9)需要改行时经集成者;包从第一天起就对着下面的行编译。
|
||||||
|
|
||||||
|
**写自什么。** [`notes/p7/PLAN-PH-P34B-P7.md`](../../docs/Disaggregated/notes/p7/PLAN-PH-P34B-P7.md)(三行逐项审计,66 个代理,每个 done / unnecessary 判定两名反驳者)与 [`notes/p7/INTEGRATOR-DECISIONS-P7.md`](../../docs/Disaggregated/notes/p7/INTEGRATOR-DECISIONS-P7.md)(ID-P7-1..11)。本文只写**规范**——树必须变成什么样、门怎么判;为什么这样定在裁定日志里。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §0 P7 是什么,以及一条高于每一行的规则
|
||||||
|
|
||||||
|
P7 收官 = 五道出口门同时成立(§2–§7),而不是路线图 P7 行的交付列逐字做完。路线图行里两项**本阶段拒做**(ID-P7-5:`SetupDrawSnapshot` 探测字段塌 dirty mask、`VertexInputStateFactory` 内容寻址 CSO——它们是 monolith 路径上的性能项,`VulkanRenderer::SetupDraw` 在任何非 monolith 传输下分支到 `SetupWireDraw`,split 下不跑,且改它们动 pull `.text`),一项只做窄半(内部 shader 烘焙的 monolith 臂退役与直通 TCS 烘焙归 P13 / OQ-7 宽半)。
|
||||||
|
|
||||||
|
**规则 I — Magma 的 wire 臂上没有 `std::abort()`。** 树上每一处 `@P7` 具名拒绝今天都是 `MGLOG_F` + `std::abort()`,绕过 `Session::Fail`、不给对端 `SessionFault` 帧、普查门看不见。P7 之后,`MG_Backend/DirectVulkan` 下任何 wire 臂的拒绝只有两种形状:(a) **decline**——`MGLOG_E_ONCE` + 返回失败 + 与 monolith 臂相同的可观测(屏蔽属性、跳过 blit……);(b) **具名 Fatal**——经 `MG_Pipe` 的 `MGPipeSessionFailHook` 进 `MG_Remote::SessionFail`,带 `FatalFamilies.def` 里的家族词。`MG_Backend` 不 include `MG_Remote`(include 闭包门),hook 由 server 角色初始化安装。规则 I 的牙齿是 §3 的普查门:扩到 server 镜像后,`MG_Backend` 下裸 abort 的站点数只能下降。
|
||||||
|
|
||||||
|
**规则 J — 每个修复先在两进程臂上红一次。** wave 0 之前树上没有一条车道能让 Magma 两进程用例变红(四条 split 臂硬编码 `MOBILEGL_BACKEND_TYPE=DirectGLES`,`MG_IntegrationTest/CMakeLists.txt:2002/:2025/:2031`),所以 ID-P7-10:车道落地前不派 `@P7` 退役的活;落地后每个退役都带一条在 `integration-magma-spawn`(或 `-tcp`)上先红后绿的用例。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §1 与前序契约的关系:什么已经不是 P7 的
|
||||||
|
|
||||||
|
| 项 | 谁做了 | 证据 |
|
||||||
|
|---|---|---|
|
||||||
|
| `DynamicBackendParameters` / `MGPCaps` / `RenderStateParameters` 定宽 + 布局指纹 | P6.5 wf(`fe27380a`) | `CONTRACT-P65.md` 「握手与布局」;`CONTRACT-P6.md:666` 仍记在 P7 名下,§10 更正 |
|
||||||
|
| server buffer consumers、Android 旋转 blit | `38919d45` | `notes/p5f/magma-inproc-fix.md` |
|
||||||
|
| Magma run-ahead、GPU 延迟退休、VAO 身份碰撞 | `194382c9` | `notes/p5f/magma-runahead.md`;`MG_Backend/Init.cpp:101` `kMGPipeMagmaRunAheadReady = true` |
|
||||||
|
| packed-float mip 原生 blit、resolve、占位图像、copy-image 端点、XFB 捕获 span、纹理回读 | `ed507b1a..d56c0e83`(随 `e1bf3677` 合入) | `WirePlaceholderImages.inc`、`WireFramebuffer.inc:634-636` |
|
||||||
|
| 颜色 blit 烘焙(仅 split 臂) | P5f fv | `Renderer/WireColorBlit.{vert,frag,inc}`、`WireColorBlitSpirv.h` |
|
||||||
|
| D-B8 具名 UBO 的载体 | 直绑常驻 `VkBuffer` range 的备选已在树上 | `UniformManager.cpp:2375` 直绑分支;欠一次 `stage-ubo-named` 字节/帧测量后关 OQ-6 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §2 出口门 1:集成 + trace 在 Magma 的 push 与 split 下全绿
|
||||||
|
|
||||||
|
**2.1 车道形状(wave 0 包 L)。** `mgl_itest_register_split_arms` 获得后端维度;DirectVulkan × {Split(inproc), Spawn, Tcp} 三臂的环境为 `MGL_ITEST_VULKAN_{SPLIT,SPAWN,TCP}_ENVIRONMENT`(`MOBILEGL_BACKEND_TYPE=DirectVulkan` + monolith `DirectVulkan.` 臂已用的 ICD 钉)。两档标签:
|
||||||
|
|
||||||
|
- **gating**:`integration-magma-split`(inproc,含义不变)、`integration-magma-spawn`、`integration-magma-tcp`——今天 `integration-magma-split` 的 73 条(及 magma-buffers / magma-runahead / magma-caches 子标签)重铺三臂;三臂**同数绿**才算门 1 的集成半边成立。
|
||||||
|
- **informational**:`integration-magma-{spawn,tcp}-all`——所有经共享宏注册的场景 × DirectVulkan × 两进程。首轮红名单是 wave 2 的工作清单;不进 CI 门,直到某条目连续绿后**按名**升入 gating(`test.yml` 的 require_green 名单)。
|
||||||
|
|
||||||
|
名集合纪律不变:`scripts/ci/spawn_lane_parity.py` 规范化后 split / spawn / tcp 三集合相等;G14 只增不删;每条目私有角色日志(`SplitLogPaths.cmake.in` 由宏累积)。
|
||||||
|
|
||||||
|
**2.2 臂证明。** Magma 两进程条目必须在 client 私有日志里同时有 `transport=spawn`(或 `control=tcp data=stream`)与 `backend=DirectVulkan`(或等价的 ConfigLoader 行)——一条 Magma 车道静默跑成 GLES 会满足其它所有门。`junit_tally.py` 的 `--require-spawn` / `--require-tcp-ran` 各加后端断言。
|
||||||
|
|
||||||
|
**2.3 死亡通知前提。** `MG_Remote/Client/WireTables.cpp:740` 只在 DirectGLES 下安装对象死亡通知,Magma 两进程 client 的 `ObjectDeaths` 恒为 0。改成后端无关(wave 0 L);Magma 自己的 `StateObjectDeathOps` 表(wave 2-C)落地前,`CtWireScenario` 的死亡用例在 Magma 臂上按名 skip 并列入 §12。
|
||||||
|
|
||||||
|
**2.4 trace 半边。** `retrace-split` 已是 39 case × 2 后端 × {inproc, spawn}(`test.yml:2449/:2470`);欠 `iterationrp × DirectVulkan` 的三个旋钮在 retrace-split 作业里与 `:2183` 同样导出(wave 0 L)。门 1 的 trace 半边 = 78 条 DirectVulkan split 行全部达阈值。
|
||||||
|
|
||||||
|
**2.5 门 1 的判据。** gating 三臂同数绿(【待填:L 包首轮的 73/73 × 3】)+ parity 通过 + retrace-split 78 条 DV 行达阈值 + informational 车道的红名单为空或每条按名归入 P8 / P9 / P13 并在 `notes/p7/` 有票。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §3 `@P7` 具名拒绝:普查、退役与 decline
|
||||||
|
|
||||||
|
**3.1 普查数(钉住)。** 基线上 `grep -rn "@P7" MobileGL/ --include=*.cpp --include=*.inc --include=*.h` = **【待填:C 包实测;审计两次分别数得 14 串 / 13 语句与 15 处 / 4 文件——以 C 包的 `fatal_census.py --json` 为准】**处,全部在 `Renderer/UniformManager.cpp`、`Renderer/WireFramebuffer.inc`、`Renderer/WireDraw.inc`、`Renderer/VulkanRenderer.cpp`。另有两项 P7 归属但不带 `@P7` 字样:`Fatal{RoleViolation, "buffer-legacy-arm"}`(`WireDraw.inc:14/:204`)与「Magma 无 `StateObjectDeathOps`」(两条集成用例 skip)。
|
||||||
|
|
||||||
|
**3.2 退役表。** 「退役」= 实现该形状,与 monolith 臂同可观测;「decline」= 规则 I (a)。
|
||||||
|
|
||||||
|
| 名 | 站点 | 判定 | 形状 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `uniform-buffer-byte-tail` | `UniformManager.cpp:2391` | **退役**(真机 MC 报告 §5 的活边界) | 拷贝窗口外扩到 4 字节边界进 transient slice,再 `vkCmdCopyBuffer` 对齐内部到正确子字目的;`CopyWireBufferRangeToSlice` 扩 |
|
||||||
|
| `copy-image-in-place` | `VulkanRenderer.cpp:10383` | **退役** | `srcImage == dstImage` 时单次转 `GENERAL`、两侧布局 GENERAL、一次写回;同 mip+layer 且矩形重叠 → decline(GL 未定义) |
|
||||||
|
| `vertex-layout` | `WireDraw.inc:245`、`VertexInputStateFactory.cpp:439-500` | **拆分** | `buffer-window` 一种保留为协议错(经 hook 的具名 Fatal——它抓过 Redmi 的 VAO 哈希碰撞);其余六种形状/格式原因改 monolith 的「屏蔽该属性继续画」,`BuildWireVertexInput` 出 `unsupportedAttribMask` |
|
||||||
|
| `default-color-blit-shape` | `WireFramebuffer.inc:601` | **退役** | 恒等变换回落 `vkCmdBlitImage` 臂(`:611-624`);非恒等旋转先 resolve/copy 进 scratch 2D RGBA 再 shader blit(复用 `:560-590` 的 scratch);四旋转之外 decline |
|
||||||
|
| `multisample-blit-shape` / `-aspect` | `WireFramebuffer.inc:631/:641` | **退役** | shape:resolve 进 scratch 单采样再 `vkCmdBlitImage` 缩放/翻转;aspect:MS 深/模板 → 单采样用 `VK_KHR_depth_stencil_resolve`(`DynamicBackendParameters` 里查扩展)或 `texelFetch(sampler2DMS)` 写 `gl_FragDepth` 的 shader resolve;单采样 → MS 尺寸不同 decline |
|
||||||
|
| `depth-stencil-mipmap` | `WireFramebuffer.inc:753` | **退役**(随烘焙 (A)) | `GenerateWireMipmap` 深度分支接 `WireDepthMipmap.{vert,frag}` 烘焙程序 |
|
||||||
|
| `texel-buffer-native-format` | `UniformManager.cpp:1153` | decline | 可选:重打包回落 |
|
||||||
|
| `unaligned-{texel,storage,atomic}-buffer-range` | `:1161/:1551/:1552` | decline 或拷入对齐 transient | 可选;SSBO 可写范围的 copyback 未定 |
|
||||||
|
| `storage-buffer-native-range` / `uniform-block-native-range` | `UniformManager.cpp` | decline(钳/拆) | 可选 |
|
||||||
|
| `uniform-buffer-dynamic-offset` | `:2400` | decline | 可选(>4 GiB) |
|
||||||
|
| `vertex-format-conversion` | `WireDraw.inc:272` | decline | 可选:packed converter |
|
||||||
|
| `buffer-legacy-arm` | `WireDraw.inc:14/:204` | 具名 Fatal 经 hook(`RoleViolation`) | 已是拒绝,只换漏斗 |
|
||||||
|
|
||||||
|
**3.3 普查门(wave 0 包 C)。** `scripts/ci/fatal_census.py` 的扫描根扩到 server 镜像(`MG_Remote`、`MG_Pipe`、`MG_Backend`、`MG_Impl/Pipe`、`MG_State`,MG_Test / MG_Benchmark / MG_IntegrationTest 除外);`abort_sites` 成为**向下棘轮**;每个 `Fatal{Word` 在 `FatalFamilies.def` 有行;`Refuse{Word}` 对 `protocol.fbs` `RefuseCode` 校验。baseline 数:【待填:C 包】。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §4 出口门 4:184 符号棘轮下降 P7 的 101 个
|
||||||
|
|
||||||
|
**4.1 定义(wave 0 包 R,`scripts/link_ratchet.py`)。** 在 disaggregated 构建的对象树上:按 `notes/p6/a6-link-experiment-data.md` 的路径规则把 `MobileGL.dir` 下对象分 SERVER / FRONTEND / SHARED;集合 = (SERVER 未定义) − (SERVER 已定义) − (SHARED 已定义) ∩ (FRONTEND 已定义)。baseline 存**符号列表**(`scripts/data/link_ratchet_baseline.txt`),`--assert-monotone` 只对新增符号红,消失只提示重基线(ID-P7-7)。基线数:【待填:R 包;a6 为 184 = P7 101 / P3b-P4b 14 / 共有 60 / P6 自己 6】。
|
||||||
|
|
||||||
|
**4.2 P7 的目标。** `--bucket` 归到 DirectVulkan 引用对象的那一桶(a6 的 101)降到 **0**。唯一还在构造前端 `SamplerObject` / `ShaderObject` / `ProgramObject` 的 DirectVulkan 站点是 `VulkanRenderer.cpp:4526-4583 / 4624-4684`(monolith 臂的隐藏 blit / 深度 mip 程序),其 early-return 是运行时而非 `#if`,所以符号仍被引用。降到 0 的路径:在 **disaggregated 构建里** monolith 臂也改用烘焙模块(§5.2 的 (B')),pull 构建的代码逐语句原样——G1 不动。若 wave 3 实测某桶符号无法在不动 pull `.text` 的前提下消失,按名记入 §12 并在 baseline 里 `# P13` 标注,不算门 4 失败。
|
||||||
|
|
||||||
|
**4.3 与 P3b/P4b 的 14 个。** 不是 P7 的目标;棘轮落地后 P3b/P4b 的 Tier 1 才可调度。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §5 内部 shader、反射归档与 resident 上传(wave 2-B / 2-C 的规范)
|
||||||
|
|
||||||
|
**5.1 烘焙 (A)(D)。** `WireDepthMipmap.{vert,frag}` + 生成的 `WireDepthMipmapSpirv.h` + `WireDepthMipmap.inc`(深度附件 render pass + pipeline),`GenerateWireMipmap`(`WireFramebuffer.inc:752-769`)深度分支接入;新鲜度门 `MOBILEGL_BAKED_INTERNAL_SHADERS`:MG_Test 用树内 glslang 重编每个签进树的 SPIR-V 头并逐字节比对,**表驱动**,覆盖 `MG_Util/SelfTest/DriverPostIterationRPWitnessSpv.h` 与 `PrimitivesGeneratedNoXfbProbeSpv.h`。
|
||||||
|
**5.2 (B') disaggregated 构建的 monolith 臂改用烘焙模块**(§4.2 需要):`InitializeBlitResources` / `InitializeDepthMipmapResources` / `BlitWithShader` / `GenerateDepthMipmapWithShader` 在 `#if MOBILEGL_BUILD_DISAGGREGATED` 下走烘焙管线;`#else` 分支保留今天的代码逐语句原样。两处 `MagmaP7AllocatorDebtScope` 随之删除(先用临时断言证明它们在非 monolith 传输下从不武装)。
|
||||||
|
**5.3 OQ-8。** `LinkArtifacts` 加有序 `storageBlocks{name, binding, dataSize}`(顺序 = stage 序 → 规范化描述符名 → binding,跨 stage 去重,与 `MagmaProgramSource.h:194-195` / `DirectVulkan.cpp:220-260` 今天的资源查询序相同),进 `Visit()`,archive codec 版本 +1(`wireFingerprint` 随之变);`MagmaProgramSource::EnsureStorageBlocks` 与 `DirectVulkan.cpp` 的 `GetProgramResourceCache` 都改读它;`g_programResourceCaches` 及其 rehash 悬挂风险随之删。单测:多 stage + 数组 SSBO + atomic-counter block 的索引序与 SPIRV-Reflect 逐项相同。
|
||||||
|
**5.4 OQ-10。** `MG_Backend/Init.cpp` `InitServerRoleCommon` 按 **server 自己的 wire 资源表** 判 `SubDataResident != nullptr` 发布 `kCapResidentSubData`(不按后端枚举猜——ID-39 的教训);`RemoteClientTest.cpp:594` 改期望;integration-magma-buffers 与 integration-split 各一条白盒用例证明发出的是 `BufferSubDataResident(49)`;26.3 in-world 回归。
|
||||||
|
**5.5 Magma `StateObjectDeathOps`。** 镜像 `DirectGLES/Managers.cpp:335-474` 的表,从 DirectVulkan 后端注册处安装;删六处 Magma 特判;`PipeSlotPeek` 断言死亡后槽位回落;red-once = 卸表看槽位泄漏断言红。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §6 出口门 2:verify 零分歧
|
||||||
|
|
||||||
|
verify 今天只在 monolith 注册(`MG_IntegrationTest/CMakeLists.txt:1684-1760`)。门 2 = **verify × {monolith, split(inproc)} × Magma 零分歧**,且两条既有负控(`VERIFY_CORRUPT`、`POISON_OMIT`)在 split 臂上各红一次。前置债:verify+split 撞旧 `PipeRespecifyScope` 断言(`notes/p65/validation-status.md:118`)——放宽为「按 level 的 producer 各自覆盖其宣告范围」,正反单测各一。trace 侧:8 个 verify case × DirectVulkan × inproc 一轮,分歧计数 0。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §7 出口门 3 与 5:真机与 CTS
|
||||||
|
|
||||||
|
**7.1 门 3 分母(ID-P7-4)。** `trace_cases.json` 的 CI split 子集 × DirectVulkan × `--use-pbuffer`,排除 `minecraft-1.21.4-rd12-odinlite-in-world` 与 `create-indirect`(OQ-17:`dev@81b17c0b` 起在 Adreno 830 上就坏);`iterationrp` 带 `apk.yml:460-462` 的三个 Magma 旋钮。
|
||||||
|
**7.2 门 3 判据。** 同一 reboot-clean 会话内:monolith 对照 1.0;inproc **与** spawn(或 tcp)三遍 ≥ 各 case 现有阈值、OpenRA 1.0、三遍逐位相同(零翻转);`RUN_AHEAD=0` 对照臂一遍记录。证据目录 `docs/Disaggregated/notes/p7/device-window-<n>/`。定位实验顺序 E0–E6 见计划 §3 wave 1。
|
||||||
|
**7.3 门 5。** 块:`KHR-GL46.texture_*`、`shader_image_*`、`packed_pixels`、`direct_state_access.*`、`uniform_buffer_object*`;caselist 入库 `tools/cts/caselists/p7-*.txt`(记 suite 版本);先 monolith × DirectVulkan 基线入库 `tools/cts/baselines/`,迁移落地后 inproc × DirectVulkan 比对:每块 pass 率差 ≤ 0.5 pp(Pass/(Pass+Fail),NS 不入分母),**新增 crash = 0 单独硬红**。完整 caselist(~56k)在合 `dev` 前跑,不在关键路径。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §8 子系统分母与 40% 检查点
|
||||||
|
|
||||||
|
分母 9 项:(1) Magma 两进程车道 gating 三臂同数绿;(2) §3.2 的六个「退役」;(3) `StateObjectDeathOps`;(4) 烘焙 (A)(D);(5) OQ-8;(6) OQ-10;(7) verify×split;(8) 真机 ssim 1.0;(9) CTS 五块 ≤0.5 pp。**中点** = wave 2 的 A / B / C 三簇全部合入集成树之时;届时完成 < 4/9 → 停下重定基线(路线图唯一幸存的再基线绊线,此前没有分母、不可执行)。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §9 wave 2 的文件分区与合并规则
|
||||||
|
|
||||||
|
| 簇 | 文件 | 内容 |
|
||||||
|
|---|---|---|
|
||||||
|
| A | `Renderer/UniformManager.cpp` | §3.2 的 UBO / SSBO / texel 对齐与 native-range 行 |
|
||||||
|
| B | `Renderer/WireFramebuffer.inc`、`Renderer/VulkanRenderer.cpp`、新 `WireDepthMipmap.*` | copy-image、default-color-blit、multisample、深度 mip 烘焙 (A)(D)、(B')、AllocatorDebtScope |
|
||||||
|
| C | `Renderer/VertexInputStateFactory.cpp`、`Renderer/WireDraw.inc`、`Renderer/VkBufferManager.cpp`、`MG_Backend/Init.cpp`、`Renderer/MagmaProgramSource.h`、`MG_State/.../ProgramArtifacts.h` | vertex-layout 拆分、`StateObjectDeathOps`、OQ-10、OQ-8 |
|
||||||
|
| D | `MG_Backend/DirectGLES/*`、`MG_State/*`、`MG_Impl/Pipe/*`、`MG_IntegrationTest/*` | P3b/P4b 的 Espryt 项(与 A/B/C 零重叠) |
|
||||||
|
| E | `docs/`、契约 | 已落地项更正、OQ 关闭、`MEASUREMENTS.md` §7.2 同名重跑 |
|
||||||
|
| F | `MG_Remote/Transport/*`、`MG_Remote/Server/ServerMain.cpp`、`Handshake.h`、`Protocol/protocol.fbs` | Ph 小件(令牌、D11 五处、PH-8 单测) |
|
||||||
|
|
||||||
|
合并规则:集成者串行合并;每次合并后 gating 三臂 + `link_ratchet.py --assert-monotone` + G1 + parity;**棘轮上升的提交拒收**;每包一条 red-once 记在 `notes/p7/`;性能只记录不设门(ID-P7-9)。实现方 `opus`、审查方 `fable`(ID-P7-8)。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §10 对前序契约的更正
|
||||||
|
|
||||||
|
1. `CONTRACT-P6.md:666`(§10.3)把 `DynamicBackendParameters` 定宽记在 P7 名下——已由 P6.5 wf 落地,P7 不再持有。
|
||||||
|
2. `CONTRACT-P6.md` §12.1「棘轮在 CI 里重算 184 并断言只降」——由 wave 0 包 R 落地为 `scripts/link_ratchet.py`;「移交 P6.5」从未被 P6.5 接收,归 P7。
|
||||||
|
3. `CONTRACT-P6.md` §12.2 D11 把五行中的三行分给 P6 `dl`——树上五处全部仍在原状态(`PipeApply.cpp:1575`、`PipeApplier.cpp:444`、`ProgramArtifactsCodec.cpp:309`、`StagedTextureStore.h:440`、`SlotTables.h:347/:371`);归 Ph(计划 §1.1 D11),wave 2-F 做。
|
||||||
|
4. `CONTRACT-P6.md` §5.2「`Session::Fail` 在 P6 保持 `[[noreturn]]`」——Ph 的翻转按 ID-P7-1 重定界,不做 98 站点的字面翻转;`Server/StagedShadow.h:115`、`Server/StagedTextureStore.h:344` 两处旁路由 wave 0 包 C 收进漏斗。
|
||||||
|
5. `ARCHITECTURE.md` §8.5「XFB scatter 在 client」——树上取的是 server staged shadow + `OnBufferWriteback`(P5c/P5f);`OnXfbScatterReady` 是死声明,删除。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §11 不是 P7 的
|
||||||
|
|
||||||
|
- `SetupDrawSnapshot` dirty mask、`VertexInputStateFactory` 内容寻址 CSO(ID-P7-5)→ 优化阶段。
|
||||||
|
- 内部 shader 烘焙的 pull 构建 monolith 臂退役(动 pull `.text`)、直通 TCS 烘焙(64 模块)→ P13 / OQ-7 宽半。
|
||||||
|
- `MG_Util` 头/对象库拆分 → P13。
|
||||||
|
- Ph 的 fuzz 臂 2(对端字节可达站点逐站点闩转换)、PH-6、PH-7 (4)(5) → P7 之后(计划 wave 5)。
|
||||||
|
- P3b/P4b 的 CTS AFTER、Iris 普查的 P9 例外(`texture-remint-pull`)→ 各自阶段。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## §12 记录债
|
||||||
|
|
||||||
|
- Magma 两进程 client 在 `StateObjectDeathOps` 落地前 `ObjectDeaths=0`:`CtWireScenario` 死亡用例在 Magma 臂按名 skip(§2.3)。
|
||||||
|
- 门 3 的「不确定」在 wave 1 E0 之前无法区分「同 case 多次结果不同」与「不同 case 各自低于阈值」;两个历史点值(0.988998 / 0.976494)无 per-case 归属。
|
||||||
|
- `MEASUREMENTS.md` §7.2 的同名比对自 P5b 起未重跑;「22 → texture readback」「3 → query」两行债务的关闭以 wave 3 的重跑为准。
|
||||||
|
- Android 模拟器 retrace 车道每轮 2–6 例 flaky(含 monolith 对照):门 1 的任何模拟器证据都先过「连续 N 轮绿」再算数。
|
||||||
@@ -35,6 +35,8 @@
|
|||||||
#include "CapsCodec.h"
|
#include "CapsCodec.h"
|
||||||
|
|
||||||
#include "Protocol/mg_protocol_base.h"
|
#include "Protocol/mg_protocol_base.h"
|
||||||
|
#include <MG_Pipe/PipeWireLayout.h>
|
||||||
|
#include <MG_State/GLState/ProgramState/ProgramArtifactsCodec.h>
|
||||||
|
|
||||||
#include <MGGitHash.h>
|
#include <MGGitHash.h>
|
||||||
#include <MG_Util/Debug/Log.h>
|
#include <MG_Util/Debug/Log.h>
|
||||||
@@ -461,37 +463,33 @@ namespace MobileGL::MG_Remote {
|
|||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
Transport::AbiFingerprintInputs CapsAbiFingerprintInputs() {
|
Transport::AbiFingerprintInputs CapsAbiFingerprintInputs() {
|
||||||
// MGPCaps has only a COMPOSITIONAL size assertion (MGPipeTypes.h:145-146) because
|
|
||||||
// DynamicBackendParameters still carries SizeT and GLenum members - P0.5's fixed-width
|
|
||||||
// rewrite did not happen and P5 does not do it either (table 0's ABI row; the rewrite
|
|
||||||
// is P7's account). So the caps block's literal size IS ABI-dependent, and this
|
|
||||||
// fingerprint is what turns that from a latent hazard into a named refusal.
|
|
||||||
//
|
|
||||||
// The git stamp is in it because two builds of the same sizes can still disagree about
|
|
||||||
// a FIELD ORDER, which no sizeof can see; P6's spawn is same-machine and same-binary,
|
|
||||||
// so it inherits this unchanged rather than needing a looser rule.
|
|
||||||
Transport::AbiFingerprintInputs inputs;
|
Transport::AbiFingerprintInputs inputs;
|
||||||
inputs.DynamicParamsSize = sizeof(MG_Backend::DynamicBackendParameters);
|
inputs.DynamicParamsSize = sizeof(MG_Backend::DynamicBackendParameters);
|
||||||
inputs.CapsSize = sizeof(MG_Pipe::MGPCaps);
|
inputs.CapsSize = sizeof(MG_Pipe::MGPCaps);
|
||||||
inputs.FunctionTableSize = sizeof(MG_Backend::GLFunctionsTable);
|
inputs.MemberLayout = MG_Pipe::kMGPipeWireMemberLayoutDigest;
|
||||||
inputs.FormatCapabilityTargets = static_cast<Uint64>(MG_Backend::kFormatCapabilityTargetCount);
|
inputs.CatalogueLayout = MG_Pipe::kMGPipeWireCatalogueDigest;
|
||||||
inputs.FormatCapabilityFormats = static_cast<Uint64>(MG_Backend::kFormatCapabilityFormatCount);
|
inputs.RenderStateLayout = MG_Pipe::WireRenderStateDigest();
|
||||||
|
inputs.FormatCapabilityTargets = MG_Backend::kFormatCapabilityTargetCount;
|
||||||
|
inputs.FormatCapabilityFormats = MG_Backend::kFormatCapabilityFormatCount;
|
||||||
inputs.FormatCapabilitiesCodecVersion = kFormatCapabilitiesCodecVersion;
|
inputs.FormatCapabilitiesCodecVersion = kFormatCapabilitiesCodecVersion;
|
||||||
inputs.RendererInfoCodecVersion = kRendererInfoCodecVersion;
|
inputs.RendererInfoCodecVersion = kRendererInfoCodecVersion;
|
||||||
|
inputs.ProgramArtifactsCodecVersion = MG_State::GLState::kProgramArtifactsCodecVersion;
|
||||||
|
inputs.ProgramArtifactsSchema = MG_State::GLState::ProgramArtifactsSchemaFingerprint();
|
||||||
inputs.OpCount = static_cast<Uint64>(MG_Pipe::MGPWireOp::kOpCount);
|
inputs.OpCount = static_cast<Uint64>(MG_Pipe::MGPWireOp::kOpCount);
|
||||||
// The declared protocol ABI, carried over from s1's version of this function at
|
inputs.AbiVersion = MOBILEGL_ABI_VERSION(MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR);
|
||||||
// integration (ID-33). The sizeofs above catch a struct that changed shape; this
|
inputs.PointerBits = sizeof(void*) * 8;
|
||||||
// catches a peer that changed the PROTOCOL while every struct stayed the same size,
|
const Uint32 endian = 1;
|
||||||
// which is the one break the rest of the mix is blind to.
|
inputs.LittleEndian = *reinterpret_cast<const Uint8*>(&endian) == 1 ? 1u : 0u;
|
||||||
inputs.AbiVersion =
|
|
||||||
static_cast<Uint32>(MOBILEGL_ABI_VERSION(MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR));
|
|
||||||
inputs.BuildStamp = GIT_COMMIT_HASH_SHORT;
|
|
||||||
return inputs;
|
return inputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ONE implementation, deliberately a one-liner: the wave-1 review (ID-46 finding 6) found a
|
Uint64 WireFingerprint() {
|
||||||
// second hand-rolled FNV loop here while the mixer under Transport/ had no production caller,
|
static const Uint64 fingerprint = Transport::MixAbiFingerprint(CapsAbiFingerprintInputs());
|
||||||
// so the sensitivity test could not see this function change. Now it starts from here.
|
return fingerprint;
|
||||||
Uint64 CapsAbiFingerprint() { return Transport::MixAbiFingerprint(CapsAbiFingerprintInputs()); }
|
}
|
||||||
|
// Compatibility spelling for existing wire tests and helper peers.
|
||||||
|
Uint64 CapsAbiFingerprint() { return WireFingerprint(); }
|
||||||
|
const char* BuildFingerprint() { return MOBILEGL_BUILD_STAMP_VALUE; }
|
||||||
|
Bool BuildFingerprintPresent() { return MOBILEGL_BUILD_STAMP_PRESENT != 0; }
|
||||||
|
|
||||||
} // namespace MobileGL::MG_Remote
|
} // namespace MobileGL::MG_Remote
|
||||||
|
|||||||
@@ -20,13 +20,7 @@
|
|||||||
// RendererInfo -> RendererInfo (MG_Util/Types.h:317): three Strings, an
|
// RendererInfo -> RendererInfo (MG_Util/Types.h:317): three Strings, an
|
||||||
// Optional<String>, and a Vector<GLExtension> inside GLInfo.
|
// Optional<String>, and a Vector<GLExtension> inside GLInfo.
|
||||||
//
|
//
|
||||||
// THE ABI RULING (table 0). MGPCaps has only a COMPOSITIONAL size assertion
|
// P6.5: wire layout and build identity are independent handshake facts.
|
||||||
// (MGPipeTypes.h:145-146) because DynamicBackendParameters still carries SizeT and GLenum
|
|
||||||
// members - P0.5's fixed-width rewrite did not happen. P5 does NOT rewrite it. Instead the
|
|
||||||
// handshake asserts that both peers agree on sizeof(DynamicBackendParameters),
|
|
||||||
// sizeof(MGPCaps) and the build fingerprint, and Fatal{AbiMismatch} otherwise. P6's spawn is
|
|
||||||
// same-machine and same-binary, so it inherits this unchanged; the fixed-width rewrite is on
|
|
||||||
// P7's account.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <Includes.h>
|
#include <Includes.h>
|
||||||
@@ -90,19 +84,11 @@ namespace MobileGL::MG_Remote {
|
|||||||
Bool EncodeRendererInfo(const RendererInfo& info, Vector<Uint8>& out);
|
Bool EncodeRendererInfo(const RendererInfo& info, Vector<Uint8>& out);
|
||||||
Bool DecodeRendererInfo(const void* bytes, Uint64 size, RendererInfo& out);
|
Bool DecodeRendererInfo(const void* bytes, Uint64 size, RendererInfo& out);
|
||||||
|
|
||||||
// ---- the ABI assertion the handshake carries ----------------------------------------
|
// Wire compatibility never includes a git stamp or local function-pointer tables.
|
||||||
//
|
|
||||||
// The inputs, as this build sees them: sizeof(DynamicBackendParameters), sizeof(MGPCaps),
|
|
||||||
// sizeof(GLFunctionsTable), the format-capability table's extents, the two caps-blob codec
|
|
||||||
// versions, MGPWireOp::kOpCount, the protocol ABI version and the compile-time git stamp.
|
|
||||||
// Public so that the sensitivity control can pin every one of them to the real value AND
|
|
||||||
// perturb them one at a time through the same mixer the handshake uses.
|
|
||||||
Transport::AbiFingerprintInputs CapsAbiFingerprintInputs();
|
Transport::AbiFingerprintInputs CapsAbiFingerprintInputs();
|
||||||
|
Uint64 WireFingerprint();
|
||||||
// What Hello/Welcome carry and compare: EXACTLY Transport::MixAbiFingerprint(
|
Uint64 CapsAbiFingerprint(); // legacy spelling of WireFingerprint
|
||||||
// CapsAbiFingerprintInputs()) - one implementation, no second hash (ID-46 finding 6). A
|
const char* BuildFingerprint();
|
||||||
// mismatch is Fatal{AbiMismatch} and never a downgrade, because every alternative silently
|
Bool BuildFingerprintPresent();
|
||||||
// reads one struct as another.
|
|
||||||
Uint64 CapsAbiFingerprint();
|
|
||||||
|
|
||||||
} // namespace MobileGL::MG_Remote
|
} // namespace MobileGL::MG_Remote
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -33,11 +33,17 @@
|
|||||||
// defect P4a paid two contract corrections for, and "always accept" is ID-39's 66 lost uploads.
|
// defect P4a paid two contract corrections for, and "always accept" is ID-39's 66 lost uploads.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "../Transport/ILink.h"
|
||||||
|
#include "../Transport/ControlInbox.h"
|
||||||
#include <Includes.h>
|
#include <Includes.h>
|
||||||
|
|
||||||
|
#include <atomic> // the device-lost latch is read off the GL thread
|
||||||
|
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <MG_Pipe/MGPipe.h>
|
#include <MG_Pipe/MGPipe.h>
|
||||||
|
|
||||||
|
#include "../Server/ServerSpawn.h"
|
||||||
|
#include "../Server/SurfaceControlFrame.h"
|
||||||
#include "../Transport/Doorbell.h"
|
#include "../Transport/Doorbell.h"
|
||||||
#include "../Transport/EventRing.h"
|
#include "../Transport/EventRing.h"
|
||||||
#include "../Transport/ITransport.h"
|
#include "../Transport/ITransport.h"
|
||||||
@@ -45,6 +51,7 @@
|
|||||||
#include "../Transport/Ring.h"
|
#include "../Transport/Ring.h"
|
||||||
#include "../Transport/RoleMemory.h"
|
#include "../Transport/RoleMemory.h"
|
||||||
#include "../Transport/SessionRings.h"
|
#include "../Transport/SessionRings.h"
|
||||||
|
#include "../Transport/SocketTransport.h"
|
||||||
#include "../Wire/PipeWireCodec.h"
|
#include "../Wire/PipeWireCodec.h"
|
||||||
#include "CapsMirror.h"
|
#include "CapsMirror.h"
|
||||||
|
|
||||||
@@ -61,7 +68,43 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// Null until Start() succeeds; MG_Backend::Init() is the only caller of Start().
|
// Null until Start() succeeds; MG_Backend::Init() is the only caller of Start().
|
||||||
static ClientSession* Active();
|
static ClientSession* Active();
|
||||||
|
|
||||||
|
// P6 `dl` (CONTRACT-P6 5.3). THE DEVICE-LOST LATCH, and the two words that matter are
|
||||||
|
// SESSION-SCOPED and LATCH: it is set at most once per session and never cleared, because
|
||||||
|
// a session whose server died has nothing left to recover into. MOBILEGL_IPC_RESPAWN is
|
||||||
|
// where the recovery would go and it is a named refusal until some stage writes it.
|
||||||
|
//
|
||||||
|
// SET FROM Doorbell::PeerHungUp(), NEVER FROM A TIMEOUT. 5.4's whole point is that slow
|
||||||
|
// and dead are different states and must be told apart without a threshold: under P5e
|
||||||
|
// run-ahead a server one frame behind is the INTENDED steady state, so a latch armed by a
|
||||||
|
// deadline would fire on a healthy session under load. The descriptor answers instead.
|
||||||
|
//
|
||||||
|
// The static form answers false whenever no session is active, so monolith and the pull
|
||||||
|
// build get the honest answer with no branch of their own.
|
||||||
|
static Bool DeviceLost();
|
||||||
|
|
||||||
|
// Arms the latch and says why, once. Safe to call repeatedly and from any thread; only
|
||||||
|
// the first call logs.
|
||||||
|
void LatchDeviceLost(const char* why);
|
||||||
|
|
||||||
|
// The bell this session parks on, for the `dl` red-once ONLY. A test cannot otherwise
|
||||||
|
// ask the question the latch turns on - "did the peer hang up" is a fact about a
|
||||||
|
// descriptor, and the pair of tests that pin D5c has to be able to kill a server and
|
||||||
|
// then watch this object, not a side effect three layers up.
|
||||||
|
Transport::Doorbell* SelfDoorbellForTest() { return m_producer.SelfDoorbell(); }
|
||||||
|
|
||||||
|
// CONTRACT-P6 4.3: THE PID THE SERVER STATED IN ITS Welcome, which is not the same fact
|
||||||
|
// as the pid this session's launcher recorded - that one is local knowledge, this one
|
||||||
|
// CROSSED THE WIRE. Under spawn they must agree and neither may be ours; under inproc
|
||||||
|
// the server states its own pid, which IS ours, and that is the honest answer there.
|
||||||
|
std::uint32_t PeerServerPid() const { return m_peerServerPid; }
|
||||||
|
|
||||||
|
ClientSession();
|
||||||
~ClientSession();
|
~ClientSession();
|
||||||
|
MobileGLResult AttachStreamLink(int dataFd, const Transport::SessionSegmentSizes& sizes);
|
||||||
|
void AttachDataLink(std::unique_ptr<Transport::ILink> link);
|
||||||
|
Transport::ILink* DataLink() const { return m_link.get(); }
|
||||||
|
bool ConnectDial() const { return m_connectDial; }
|
||||||
|
void SyncPeerLog();
|
||||||
|
|
||||||
// Builds the four segments, performs Hello/Welcome, takes the first CapsSnapshot, and
|
// Builds the four segments, performs Hello/Welcome, takes the first CapsSnapshot, and
|
||||||
// - for TransportMode::InProcess - starts the server role's apply thread. Returns a
|
// - for TransportMode::InProcess - starts the server role's apply thread. Returns a
|
||||||
@@ -79,6 +122,41 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// come back as MOBILEGL_ERR_PROTOCOL_MISMATCH with the guard's own line. Not a second
|
// come back as MOBILEGL_ERR_PROTOCOL_MISMATCH with the guard's own line. Not a second
|
||||||
// way to start a session: MG_Backend::Init() calls Start(), and nothing else may call
|
// way to start a session: MG_Backend::Init() calls Start(), and nothing else may call
|
||||||
// this with a pair it did not just create.
|
// this with a pair it did not just create.
|
||||||
|
// P6 `sm`: the spawn client's half. `transport` is this process's end of
|
||||||
|
// the control socket to an already-running server process; the two bell
|
||||||
|
// fds are this side's ends of the two bell pairs (ServerSpawn.h).
|
||||||
|
//
|
||||||
|
// It is the SAME handshake StartOverTransportPair runs, with three
|
||||||
|
// differences and no others: the server half happens in another process
|
||||||
|
// so there is no local Accept to call, the four segments arrive as
|
||||||
|
// descriptors over SCM_RIGHTS instead of being dup'ed from a local
|
||||||
|
// owner, and the bells are sockets rather than condvars. Everything
|
||||||
|
// below the attach - producer, reply pool, event ring, segment table,
|
||||||
|
// encoder - is byte for byte the inproc path, which is the property
|
||||||
|
// that makes "P6 is a transport swap" true of THIS function even though
|
||||||
|
// it is not true of the phase.
|
||||||
|
// `cp`: the remote control sink ServerLoop calls when the server is
|
||||||
|
// another process. Encode, send, wait for the SurfaceReply that carries
|
||||||
|
// OUR seq back.
|
||||||
|
static MobileGLResult RemoteControlSinkThunk(void* user, Server::SurfaceControlFrame& frame);
|
||||||
|
MobileGLResult RunRemoteSurfaceControlFrame(Server::SurfaceControlFrame& frame);
|
||||||
|
|
||||||
|
MobileGLResult FinishStartup(Transport::Doorbell* peerBell,
|
||||||
|
Transport::Doorbell* selfBell,
|
||||||
|
bool startApplyThreadHere);
|
||||||
|
|
||||||
|
// `transport` is this process's end of a connection to an ALREADY
|
||||||
|
// RUNNING server process. The two bells arrive over it, with the four
|
||||||
|
// segments, as SCM_RIGHTS offers - nothing here is inherited, because
|
||||||
|
// the two processes were started independently.
|
||||||
|
// P6: launch a server process and connect to it. The two are
|
||||||
|
// INDEPENDENT - the launcher hands over a rendezvous name and nothing
|
||||||
|
// else - so this is the same code path a client would use against a
|
||||||
|
// server that was already running when it started.
|
||||||
|
MobileGLResult StartSpawned();
|
||||||
|
|
||||||
|
MobileGLResult StartOverSocket(std::unique_ptr<Transport::SocketTransport> transport);
|
||||||
|
|
||||||
MobileGLResult StartOverTransportPair(std::unique_ptr<Transport::InProcessTransport> clientEnd,
|
MobileGLResult StartOverTransportPair(std::unique_ptr<Transport::InProcessTransport> clientEnd,
|
||||||
std::unique_ptr<Transport::InProcessTransport> serverEnd);
|
std::unique_ptr<Transport::InProcessTransport> serverEnd);
|
||||||
|
|
||||||
@@ -167,6 +245,9 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// true while a run-ahead queue still holds them, so under run-ahead glFinish becomes
|
// true while a run-ahead queue still holds them, so under run-ahead glFinish becomes
|
||||||
// exactly WaitForApplyToCatchUp + the drain that comes with it.
|
// exactly WaitForApplyToCatchUp + the drain that comes with it.
|
||||||
void Finish();
|
void Finish();
|
||||||
|
// Submit published commands without waiting for application. This is
|
||||||
|
// glFlush's contract and the frame-submit boundary for Present.
|
||||||
|
void Flush();
|
||||||
|
|
||||||
// The last seq this session published, whether or not it waited for it. The forced
|
// The last seq this session published, whether or not it waited for it. The forced
|
||||||
// waits above are defined against it.
|
// waits above are defined against it.
|
||||||
@@ -337,6 +418,11 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
void LogWireLedger() const;
|
void LogWireLedger() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
MobileGLResult ReceiveControlFrame(std::vector<Uint8>& frame, Uint32 timeoutMs);
|
||||||
|
std::unique_ptr<Transport::ControlInbox> m_controlInbox;
|
||||||
|
std::unique_ptr<Transport::ILink> m_link;
|
||||||
|
bool m_connectDial = false;
|
||||||
|
std::uint64_t m_logFlushSeq = 0;
|
||||||
// P5e (ra): the latch, taken from PumpControlPlane after every adoption. Private
|
// P5e (ra): the latch, taken from PumpControlPlane after every adoption. Private
|
||||||
// because "when may run-ahead start" is this class's own rule and not a caller's.
|
// because "when may run-ahead start" is this class's own rule and not a caller's.
|
||||||
void LatchRunAheadFromCaps();
|
void LatchRunAheadFromCaps();
|
||||||
@@ -352,15 +438,34 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
Uint64 m_presentsSent = 0;
|
Uint64 m_presentsSent = 0;
|
||||||
Uint64 m_presentCreditWaits = 0;
|
Uint64 m_presentCreditWaits = 0;
|
||||||
|
|
||||||
|
// sm: the spawn client owns ONE end and two bells. Held here rather
|
||||||
|
// than in the transport because which bell is "mine" is the session's
|
||||||
|
// knowledge, not the transport's - the same ruling as inproc's
|
||||||
|
// PeerDoorbell/SelfDoorbell split.
|
||||||
|
// cp: one control op at a time, and the client's own seq space.
|
||||||
|
std::mutex m_remoteControlMutex;
|
||||||
|
Uint64 m_remoteControlSeq = 0;
|
||||||
|
|
||||||
|
// The server we launched, if we launched one. Reaped in Stop().
|
||||||
|
Server::LaunchedServer m_spawned;
|
||||||
|
|
||||||
|
std::unique_ptr<Transport::SocketTransport> m_socketTransport;
|
||||||
|
std::unique_ptr<Transport::Doorbell> m_socketSelfBell;
|
||||||
|
std::unique_ptr<Transport::Doorbell> m_socketPeerBell;
|
||||||
|
|
||||||
std::unique_ptr<Transport::InProcessTransport> m_clientTransport;
|
std::unique_ptr<Transport::InProcessTransport> m_clientTransport;
|
||||||
std::unique_ptr<Transport::InProcessTransport> m_serverTransport;
|
std::unique_ptr<Transport::InProcessTransport> m_serverTransport;
|
||||||
Transport::SessionSegments m_shm;
|
Transport::RingProducer* m_cmd = nullptr;
|
||||||
Transport::RingProducer m_cmd;
|
|
||||||
Transport::SessionProducer m_producer;
|
Transport::SessionProducer m_producer;
|
||||||
Transport::EventRingConsumer m_events;
|
Transport::EventRingConsumer* m_events = nullptr;
|
||||||
Transport::ReplySlotPool m_replies;
|
|
||||||
Transport::ITransport* m_transport = nullptr;
|
Transport::ITransport* m_transport = nullptr;
|
||||||
Bool m_started = false;
|
Bool m_started = false;
|
||||||
|
// Written by whichever thread first notices the hangup - the GL thread in the barrier,
|
||||||
|
// or the event pump - and read by glGetGraphicsResetStatus on the GL thread.
|
||||||
|
std::atomic<bool> m_deviceLost{false};
|
||||||
|
// Welcome::serverPid, kept because §9.5's arm proof wants it and because a value that is
|
||||||
|
// only ever logged cannot be asserted on.
|
||||||
|
std::uint32_t m_peerServerPid = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// One per process in P5, because P5 serves one context, and LEAKED AT EXIT like every other
|
// One per process in P5, because P5 serves one context, and LEAKED AT EXIT like every other
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
// regression re-committed at the transport layer.
|
// regression re-committed at the transport layer.
|
||||||
|
|
||||||
#include "EmitTables.h"
|
#include "EmitTables.h"
|
||||||
|
#include <MG_Remote/FatalFunnel.h>
|
||||||
|
|
||||||
#include "ClientSession.h"
|
#include "ClientSession.h"
|
||||||
#include "GpuWritePending.h"
|
#include "GpuWritePending.h"
|
||||||
@@ -87,8 +88,7 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// The same shape as MGPipeInputPoisonFatal (generated/PipeFilled.inc:407-413): names the
|
// The same shape as MGPipeInputPoisonFatal (generated/PipeFilled.inc:407-413): names the
|
||||||
// slot, live at every log level, aborts. Deliberately NOT MOBILEGL_ASSERT, which is
|
// slot, live at every log level, aborts. Deliberately NOT MOBILEGL_ASSERT, which is
|
||||||
// inert in an INFO build - and INFO is what every device lane runs.
|
// inert in an INFO build - and INFO is what every device lane runs.
|
||||||
MGLOG_F("MGPipe: Fatal{UnmigratedVerb, \"%s\"}", slot);
|
SessionFail(MGFatalFamily::UnmigratedVerb, "MGPipe: Fatal{UnmigratedVerb, \"%s\"}", slot);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -209,11 +209,10 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
RequireClientTablesInstalled(slot);
|
RequireClientTablesInstalled(slot);
|
||||||
ClientSession* session = ClientSession::Active();
|
ClientSession* session = ClientSession::Active();
|
||||||
if (session == nullptr) {
|
if (session == nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{NoClientSession, \"%s\"} - the remote emit table is "
|
SessionFail(MGFatalFamily::NoClientSession, "MGPipe: Fatal{NoClientSession, \"%s\"} - the remote emit table is "
|
||||||
"installed but no ClientSession is active. A slot may not fall through "
|
"installed but no ClientSession is active. A slot may not fall through "
|
||||||
"to a driver this role does not have",
|
"to a driver this role does not have",
|
||||||
slot);
|
slot);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
return *session;
|
return *session;
|
||||||
}
|
}
|
||||||
@@ -836,11 +835,10 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// NOT a guess and not a zero-length reply. A format this build cannot size is a
|
// NOT a guess and not a zero-length reply. A format this build cannot size is a
|
||||||
// readback whose answer would be silently truncated, which is the one failure a
|
// readback whose answer would be silently truncated, which is the one failure a
|
||||||
// picture comparison cannot see.
|
// picture comparison cannot see.
|
||||||
MGLOG_F("MGPipe: Fatal{UnsizedReadback, \"read_pixels\"} format=0x%04x type=0x%04x "
|
SessionFail(MGFatalFamily::UnsizedReadback, "MGPipe: Fatal{UnsizedReadback, \"read_pixels\"} format=0x%04x type=0x%04x "
|
||||||
"- the client must declare MGPReadbackInfo::DstSize and cannot size this "
|
"- the client must declare MGPReadbackInfo::DstSize and cannot size this "
|
||||||
"pair; P5's reduced path reads RGBA/UNSIGNED_BYTE",
|
"pair; P5's reduced path reads RGBA/UNSIGNED_BYTE",
|
||||||
static_cast<unsigned>(format), static_cast<unsigned>(type));
|
static_cast<unsigned>(format), static_cast<unsigned>(type));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
return static_cast<Uint64>(bytesPerPixel);
|
return static_cast<Uint64>(bytesPerPixel);
|
||||||
}
|
}
|
||||||
@@ -882,29 +880,25 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// an oversize reply, so the only failures left are a wrong status or a SHORT one.
|
// an oversize reply, so the only failures left are a wrong status or a SHORT one.
|
||||||
void RequireReadbackReplyComplete(Int32 status, Uint64 replySize, Uint64 expected) {
|
void RequireReadbackReplyComplete(Int32 status, Uint64 replySize, Uint64 expected) {
|
||||||
if (status == Wire::ReplySink::kStatusError) {
|
if (status == Wire::ReplySink::kStatusError) {
|
||||||
MGLOG_F("MGPipe: Fatal{ReplyError, \"ReadPixels\"} - the readback answered ERROR; "
|
SessionFail(MGFatalFamily::ReplyError, "MGPipe: Fatal{ReplyError, \"ReadPixels\"} - the readback answered ERROR; "
|
||||||
"the destination is left untouched rather than filled with stale bytes");
|
"the destination is left untouched rather than filled with stale bytes");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (status == Wire::ReplySink::kStatusDeclined) {
|
if (status == Wire::ReplySink::kStatusDeclined) {
|
||||||
MGLOG_F("MGPipe: Fatal{ReadbackDeclined, \"ReadPixels\"} - the server has no "
|
SessionFail(MGFatalFamily::ReadbackDeclined, "MGPipe: Fatal{ReadbackDeclined, \"ReadPixels\"} - the server has no "
|
||||||
"GL.ReadPixels and DECLINED; a decline is a real answer for an acceptance "
|
"GL.ReadPixels and DECLINED; a decline is a real answer for an acceptance "
|
||||||
"row (R-5) but a blocking readback has no pixels to return, so it is a "
|
"row (R-5) but a blocking readback has no pixels to return, so it is a "
|
||||||
"Fatal here rather than a buffer of stale bytes");
|
"Fatal here rather than a buffer of stale bytes");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (status != Wire::ReplySink::kStatusOk) {
|
if (status != Wire::ReplySink::kStatusOk) {
|
||||||
MGLOG_F("MGPipe: Fatal{ReplyStatusInvalid, \"ReadPixels\"} - unknown reply status %d", status);
|
SessionFail(MGFatalFamily::ReplyStatusInvalid, "MGPipe: Fatal{ReplyStatusInvalid, \"ReadPixels\"} - unknown reply status %d", status);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (replySize != expected) {
|
if (replySize != expected) {
|
||||||
MGLOG_F("MGPipe: Fatal{ReadbackReplyShort, \"ReadPixels %llu < %llu\"} - the OK "
|
SessionFail(MGFatalFamily::ReadbackReplyShort, "MGPipe: Fatal{ReadbackReplyShort, \"ReadPixels %llu < %llu\"} - the OK "
|
||||||
"reply carried fewer bytes than the read's own DstSize (CONTRACT-P5 row "
|
"reply carried fewer bytes than the read's own DstSize (CONTRACT-P5 row "
|
||||||
"23's exact extent); the missing rows would otherwise be scattered as "
|
"23's exact extent); the missing rows would otherwise be scattered as "
|
||||||
"whatever the destination held",
|
"whatever the destination held",
|
||||||
static_cast<unsigned long long>(replySize),
|
static_cast<unsigned long long>(replySize),
|
||||||
static_cast<unsigned long long>(expected));
|
static_cast<unsigned long long>(expected));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
// End of Source File Header
|
// End of Source File Header
|
||||||
|
|
||||||
#include "GpuWritePending.h"
|
#include "GpuWritePending.h"
|
||||||
|
#include <MG_Remote/FatalFunnel.h>
|
||||||
|
|
||||||
#include "ClientSession.h"
|
#include "ClientSession.h"
|
||||||
// RunsAsTheServerRole: declared beside the wire emitters that need the same predicate, so this
|
// RunsAsTheServerRole: declared beside the wire emitters that need the same predicate, so this
|
||||||
@@ -252,12 +253,11 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// UnmigratedVerbFatal), and it is what gives the hole a red spelling before the
|
// UnmigratedVerbFatal), and it is what gives the hole a red spelling before the
|
||||||
// transport arrives.
|
// transport arrives.
|
||||||
if (!buffer.HasOutstandingGpuWrite()) return;
|
if (!buffer.HasOutstandingGpuWrite()) return;
|
||||||
MGLOG_F("MGPipe: Fatal{UnimplementedWritebackWait} - a ClientSession is active and buffer %u "
|
SessionFail(MGFatalFamily::UnimplementedWritebackWait, "MGPipe: Fatal{UnimplementedWritebackWait} - a ClientSession is active and buffer %u "
|
||||||
"still has an outstanding GPU write after its readback was emitted. The wait is "
|
"still has an outstanding GPU write after its readback was emitted. The wait is "
|
||||||
"ClientSession::EmitAndWait's (R-3: the reply slot id IS the record seq); P5 package "
|
"ClientSession::EmitAndWait's (R-3: the reply slot id IS the record seq); P5 package "
|
||||||
"b1 landed the third state and s1/c1 own the wait itself.",
|
"b1 landed the third state and s1/c1 own the wait itself.",
|
||||||
buffer.GetExternalIndex());
|
buffer.GetExternalIndex());
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace MobileGL::MG_Remote::Client
|
} // namespace MobileGL::MG_Remote::Client
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
// End of Source File Header
|
// End of Source File Header
|
||||||
|
|
||||||
#include "PersistentMapTracker.h"
|
#include "PersistentMapTracker.h"
|
||||||
|
#include <MG_Remote/FatalFunnel.h>
|
||||||
|
|
||||||
#include <MG_Pipe/MGPipeTypes.h>
|
#include <MG_Pipe/MGPipeTypes.h>
|
||||||
#include <MG_State/GLState/BufferState/BufferObject.h>
|
#include <MG_State/GLState/BufferState/BufferObject.h>
|
||||||
@@ -640,9 +641,8 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
void PersistentMapTracker::PushBlocksFor(BufferObject& buffer) {
|
void PersistentMapTracker::PushBlocksFor(BufferObject& buffer) {
|
||||||
if (!PushIsArmed()) return;
|
if (!PushIsArmed()) return;
|
||||||
if (OnServerRole()) {
|
if (OnServerRole()) {
|
||||||
MGLOG_F("MGPipe: Fatal{RoleViolation, \"PushBlocksFor\"} - the persistent-map "
|
SessionFail(MGFatalFamily::RoleViolation, "MGPipe: Fatal{RoleViolation, \"PushBlocksFor\"} - the persistent-map "
|
||||||
"producer belongs to the client; the server consumes transported bytes");
|
"producer belongs to the client; the server consumes transported bytes");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
PushBlocksForChecked(buffer);
|
PushBlocksForChecked(buffer);
|
||||||
}
|
}
|
||||||
@@ -856,9 +856,8 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
void PersistentMapTracker::PushAllMembers() {
|
void PersistentMapTracker::PushAllMembers() {
|
||||||
if (!PushIsArmed()) return;
|
if (!PushIsArmed()) return;
|
||||||
if (OnServerRole()) {
|
if (OnServerRole()) {
|
||||||
MGLOG_F("MGPipe: Fatal{RoleViolation, \"PushAllMembers\"} - the persistent-map "
|
SessionFail(MGFatalFamily::RoleViolation, "MGPipe: Fatal{RoleViolation, \"PushAllMembers\"} - the persistent-map "
|
||||||
"producer belongs to the client; the server consumes transported bytes");
|
"producer belongs to the client; the server consumes transported bytes");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (m_livePersistentMaps.empty()) return;
|
if (m_livePersistentMaps.empty()) return;
|
||||||
// Copied out first: PushBlocksFor can erase its own entry (a member that stopped
|
// Copied out first: PushBlocksFor can erase its own entry (a member that stopped
|
||||||
@@ -874,9 +873,8 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
void PersistentMapTracker::PushDrawConsumers() {
|
void PersistentMapTracker::PushDrawConsumers() {
|
||||||
if (!PushIsArmed()) return;
|
if (!PushIsArmed()) return;
|
||||||
if (OnServerRole()) {
|
if (OnServerRole()) {
|
||||||
MGLOG_F("MGPipe: Fatal{RoleViolation, \"PushDrawConsumers\"} - the persistent-map "
|
SessionFail(MGFatalFamily::RoleViolation, "MGPipe: Fatal{RoleViolation, \"PushDrawConsumers\"} - the persistent-map "
|
||||||
"producer belongs to the client; the server consumes transported bytes");
|
"producer belongs to the client; the server consumes transported bytes");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (m_livePersistentMaps.empty()) return;
|
if (m_livePersistentMaps.empty()) return;
|
||||||
// THE EPOCH SKIP, AND WHAT IT RESTS ON. A page of a tracked map is marked by
|
// THE EPOCH SKIP, AND WHAT IT RESTS ON. A page of a tracked map is marked by
|
||||||
@@ -1047,16 +1045,23 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// map_persistent, so a mis-set run gets through EGL bring-up and a frame of setup
|
// map_persistent, so a mis-set run gets through EGL bring-up and a frame of setup
|
||||||
// first. Moving it to the parse means a knob-validity rule in ConfigLoader, which is
|
// first. Moving it to the parse means a knob-validity rule in ConfigLoader, which is
|
||||||
// c0's file; filed for the integrator rather than taken here.
|
// c0's file; filed for the integrator rather than taken here.
|
||||||
|
// `dl` (CONTRACT-P6 5.2): THE FAMILY WORD THIS SITE NEVER CARRIED. a6 found two aborts
|
||||||
|
// under MG_Remote/ with no Fatal{ marker at all, so "the log stays verbatim" was not true
|
||||||
|
// of them and no family grep could see them - this is one. (The other, WireLog.cpp's, is
|
||||||
|
// the sanctioned funnel: every one of its callers passes a Fatal{ string of its own.)
|
||||||
if (tier <= 1) {
|
if (tier <= 1) {
|
||||||
MGLOG_F("MGPipe: MOBILEGL_IPC_ADOPT_TIER=%u names adoption tier T%u, which P11 implements "
|
SessionFail(MGFatalFamily::UnimplementedAdoptTier,
|
||||||
"and P5 does not; P5 runs at T2 (emulate) only.",
|
"MGPipe: Fatal{UnimplementedAdoptTier, \"T%u\"} - MOBILEGL_IPC_ADOPT_TIER=%u "
|
||||||
|
"names an adoption tier P11 implements and P5 does not; P5 runs at T2 "
|
||||||
|
"(emulate) only.",
|
||||||
static_cast<unsigned>(tier), static_cast<unsigned>(tier));
|
static_cast<unsigned>(tier), static_cast<unsigned>(tier));
|
||||||
} else {
|
} else {
|
||||||
MGLOG_F("MGPipe: MOBILEGL_IPC_ADOPT_TIER=%u is not an adoption tier; the only values are 0 "
|
SessionFail(MGFatalFamily::UnimplementedAdoptTier,
|
||||||
"and 1 (P11) and 2 (emulate, the P5 default).",
|
"MGPipe: Fatal{UnimplementedAdoptTier, \"%u\"} - MOBILEGL_IPC_ADOPT_TIER=%u is "
|
||||||
static_cast<unsigned>(tier));
|
"not an adoption tier; the only values are 0 and 1 (P11) and 2 (emulate, the "
|
||||||
|
"P5 default).",
|
||||||
|
static_cast<unsigned>(tier), static_cast<unsigned>(tier));
|
||||||
}
|
}
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace MobileGL::MG_Remote::Client
|
} // namespace MobileGL::MG_Remote::Client
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
// before every `set_dynamic_state` - hundreds of times a frame, and each one a real record.
|
// before every `set_dynamic_state` - hundreds of times a frame, and each one a real record.
|
||||||
|
|
||||||
#include "WireTables.h"
|
#include "WireTables.h"
|
||||||
|
#include <MG_Remote/FatalFunnel.h>
|
||||||
|
|
||||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@
|
|||||||
// is legal under rule E (CONTRACT-P5C.md §5.2).
|
// is legal under rule E (CONTRACT-P5C.md §5.2).
|
||||||
#include <MG_Impl/Pipe/SlotAllocator.h>
|
#include <MG_Impl/Pipe/SlotAllocator.h>
|
||||||
#include <MG_State/GLState/ProgramState/ProgramArtifactsCodec.h>
|
#include <MG_State/GLState/ProgramState/ProgramArtifactsCodec.h>
|
||||||
|
#include <MG_State/GLState/StateObjectDeathNotice.h>
|
||||||
#include <MG_Util/Debug/Log.h>
|
#include <MG_Util/Debug/Log.h>
|
||||||
// P5e (pg): ID-87 asks this package for bytes-per-link measured rather than argued, and the
|
// P5e (pg): ID-87 asks this package for bytes-per-link measured rather than argued, and the
|
||||||
// archive's byte count exists exactly once - here, where it is serialised.
|
// archive's byte count exists exactly once - here, where it is serialised.
|
||||||
@@ -113,11 +115,10 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
RequireClientTablesInstalled(row);
|
RequireClientTablesInstalled(row);
|
||||||
ClientSession* session = ClientSession::Active();
|
ClientSession* session = ClientSession::Active();
|
||||||
if (session == nullptr) {
|
if (session == nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{NoClientSession, \"%s\"} - the client wire tables are "
|
SessionFail(MGFatalFamily::NoClientSession, "MGPipe: Fatal{NoClientSession, \"%s\"} - the client wire tables are "
|
||||||
"installed but no ClientSession is active. A row may not fall through to "
|
"installed but no ClientSession is active. A row may not fall through to "
|
||||||
"a driver this role does not have",
|
"a driver this role does not have",
|
||||||
row);
|
row);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
return *session;
|
return *session;
|
||||||
}
|
}
|
||||||
@@ -129,12 +130,11 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
MG_Pipe::MGPBlobRef StageRequired(ClientSession& session, const char* row,
|
MG_Pipe::MGPBlobRef StageRequired(ClientSession& session, const char* row,
|
||||||
const void* bytes, Uint64 count) {
|
const void* bytes, Uint64 count) {
|
||||||
if (bytes == nullptr || count == 0) {
|
if (bytes == nullptr || count == 0) {
|
||||||
MGLOG_F("MGPipe: Fatal{BlobMissing, \"%s\"} - the row's decoder requires a "
|
SessionFail(MGFatalFamily::BlobMissing, "MGPipe: Fatal{BlobMissing, \"%s\"} - the row's decoder requires a "
|
||||||
"declared blob and the call site handed over %llu bytes at %p. Under "
|
"declared blob and the call site handed over %llu bytes at %p. Under "
|
||||||
"monolith the companion pointer carries them; under split they have to "
|
"monolith the companion pointer carries them; under split they have to "
|
||||||
"be staged, and there is nothing to stage",
|
"be staged, and there is nothing to stage",
|
||||||
row, static_cast<unsigned long long>(count), bytes);
|
row, static_cast<unsigned long long>(count), bytes);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
return session.Encoder().StageBytes(bytes, count);
|
return session.Encoder().StageBytes(bytes, count);
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,8 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
const Uint64 seq = session.EmitAndWait(MGPWireOp::ResourceReadback, payload,
|
const Uint64 seq = session.EmitAndWait(MGPWireOp::ResourceReadback, payload,
|
||||||
sizeof(*payload), nullptr, 0, nullptr, 0,
|
sizeof(*payload), nullptr, 0, nullptr, 0,
|
||||||
&status);
|
&status);
|
||||||
reply->Id = seq;
|
// Cancellation has no wire ordinal; retain the caller's nonzero local ticket.
|
||||||
|
if (seq != Wire::kInvalidSeq) reply->Id = seq;
|
||||||
MG_Pipe::MGPipePostReply(*reply, status, 0);
|
MG_Pipe::MGPipePostReply(*reply, status, 0);
|
||||||
++g_emitted;
|
++g_emitted;
|
||||||
}
|
}
|
||||||
@@ -318,7 +319,8 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
const Uint64 seq = session.EmitAndWait(MGPWireOp::ResourceCreate, payload,
|
const Uint64 seq = session.EmitAndWait(MGPWireOp::ResourceCreate, payload,
|
||||||
sizeof(*payload), nullptr, 0, nullptr, 0,
|
sizeof(*payload), nullptr, 0, nullptr, 0,
|
||||||
&status);
|
&status);
|
||||||
reply->Id = seq;
|
// Cancellation has no wire ordinal; retain the caller's nonzero local ticket.
|
||||||
|
if (seq != Wire::kInvalidSeq) reply->Id = seq;
|
||||||
MG_Pipe::MGPipePostReply(*reply, status, status == 0 ? 1u : 0u);
|
MG_Pipe::MGPipePostReply(*reply, status, status == 0 ? 1u : 0u);
|
||||||
++g_emitted;
|
++g_emitted;
|
||||||
if (status == 1) ++g_declined;
|
if (status == 1) ++g_declined;
|
||||||
@@ -331,7 +333,8 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
const Uint64 seq = session.EmitAndWait(MGPWireOp::SetTextureParams, payload,
|
const Uint64 seq = session.EmitAndWait(MGPWireOp::SetTextureParams, payload,
|
||||||
sizeof(*payload), nullptr, 0, nullptr, 0,
|
sizeof(*payload), nullptr, 0, nullptr, 0,
|
||||||
&status);
|
&status);
|
||||||
reply->Id = seq;
|
// Cancellation has no wire ordinal; retain the caller's nonzero local ticket.
|
||||||
|
if (seq != Wire::kInvalidSeq) reply->Id = seq;
|
||||||
MG_Pipe::MGPipePostReply(*reply, status, status == 0 ? 1u : 0u);
|
MG_Pipe::MGPipePostReply(*reply, status, status == 0 ? 1u : 0u);
|
||||||
++g_emitted;
|
++g_emitted;
|
||||||
if (status == 1) ++g_declined;
|
if (status == 1) ++g_declined;
|
||||||
@@ -370,11 +373,14 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
MGPWireOp::ResourceSubData, &record, sizeof(record),
|
MGPWireOp::ResourceSubData, &record, sizeof(record),
|
||||||
varTail != nullptr ? &tail : nullptr, varTail != nullptr ? 1u : 0u, nullptr, 0,
|
varTail != nullptr ? &tail : nullptr, varTail != nullptr ? 1u : 0u, nullptr, 0,
|
||||||
&status, nullptr, wantReply);
|
&status, nullptr, wantReply);
|
||||||
reply->Id = seq;
|
// Cancellation has no wire ordinal; retain the caller's nonzero local ticket.
|
||||||
MG_Pipe::MGPipePostReply(*reply, wantReply ? status : 0,
|
if (seq != Wire::kInvalidSeq) reply->Id = seq;
|
||||||
(wantReply ? status == 0 : true) ? 1u : 0u);
|
const Int32 postedStatus = (seq == Wire::kInvalidSeq || status == Wire::ReplySink::kStatusDeclined)
|
||||||
++g_emitted;
|
? Wire::ReplySink::kStatusDeclined
|
||||||
if (wantReply && status == 1) ++g_declined;
|
: wantReply ? status : Wire::ReplySink::kStatusOk;
|
||||||
|
MG_Pipe::MGPipePostReply(*reply, postedStatus, postedStatus == Wire::ReplySink::kStatusOk ? 1u : 0u);
|
||||||
|
if (seq != Wire::kInvalidSeq) ++g_emitted;
|
||||||
|
if (postedStatus == Wire::ReplySink::kStatusDeclined) ++g_declined;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wire_BufferSubDataResident(const MG_Pipe::MGPSubData* payload, const void* blobBytes,
|
void Wire_BufferSubDataResident(const MG_Pipe::MGPSubData* payload, const void* blobBytes,
|
||||||
@@ -409,12 +415,11 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
}
|
}
|
||||||
ClientSession& session = RequireSession("ResourceRespecify");
|
ClientSession& session = RequireSession("ResourceRespecify");
|
||||||
if (initialBytes != nullptr) {
|
if (initialBytes != nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{UncarriedInitialBytes, \"resource_respecify\"} - a call "
|
SessionFail(MGFatalFamily::UncarriedInitialBytes, "MGPipe: Fatal{UncarriedInitialBytes, \"resource_respecify\"} - a call "
|
||||||
"site handed initial content to a split respecify. R-13.3 rules that "
|
"site handed initial content to a split respecify. R-13.3 rules that "
|
||||||
"initialBytes never crosses and that the content follows as "
|
"initialBytes never crosses and that the content follows as "
|
||||||
"resource_subdata; a caller that still passes it has bytes nothing will "
|
"resource_subdata; a caller that still passes it has bytes nothing will "
|
||||||
"carry");
|
"carry");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
// The scope rides in the descriptor's own pads (CONTRACT-P5 table 1 row 19b, LANDED)
|
// The scope rides in the descriptor's own pads (CONTRACT-P5 table 1 row 19b, LANDED)
|
||||||
// and is written only through MGPipeSetRespecifiedLevel - three fields are one
|
// and is written only through MGPipeSetRespecifiedLevel - three fields are one
|
||||||
@@ -438,10 +443,9 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// - the generated acceptance rows through MGPipeTakeReplyBool, and now these two
|
// - the generated acceptance rows through MGPipeTakeReplyBool, and now these two
|
||||||
// escapes - answers ERROR with the same named Fatal.
|
// escapes - answers ERROR with the same named Fatal.
|
||||||
if (status == 2) {
|
if (status == 2) {
|
||||||
MGLOG_F("MGPipe: Fatal{ReplyError, \"resource_respecify\"} - the row answered "
|
SessionFail(MGFatalFamily::ReplyError, "MGPipe: Fatal{ReplyError, \"resource_respecify\"} - the row answered "
|
||||||
"ERROR, which is not an acceptance answer; folding it into accepted or "
|
"ERROR, which is not an acceptance answer; folding it into accepted or "
|
||||||
"refused would make a transport fault look like a resource decision");
|
"refused would make a transport fault look like a resource decision");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (status == 1) ++g_declined;
|
if (status == 1) ++g_declined;
|
||||||
return status == 0;
|
return status == 0;
|
||||||
@@ -485,22 +489,20 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// the generated acceptance rows obey: status 2 is a transport fault, and returning
|
// the generated acceptance rows obey: status 2 is a transport fault, and returning
|
||||||
// nullptr for it would make it indistinguishable from R-6's legitimate decline.
|
// nullptr for it would make it indistinguishable from R-6's legitimate decline.
|
||||||
if (status == 2) {
|
if (status == 2) {
|
||||||
MGLOG_F("MGPipe: Fatal{ReplyError, \"map_persistent\"} - the row answered ERROR, "
|
SessionFail(MGFatalFamily::ReplyError, "MGPipe: Fatal{ReplyError, \"map_persistent\"} - the row answered ERROR, "
|
||||||
"which is not an acceptance answer; a transport fault is not a resource "
|
"which is not an acceptance answer; a transport fault is not a resource "
|
||||||
"decision and may not be folded into the decline R-6 predicts");
|
"decision and may not be folded into the decline R-6 predicts");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (status == 1) ++g_declined;
|
if (status == 1) ++g_declined;
|
||||||
// NOT "always nullptr": the answer is READ. R-6 says the server declines, and the
|
// NOT "always nullptr": the answer is READ. R-6 says the server declines, and the
|
||||||
// day it stops declining this returns what it actually said rather than what the
|
// day it stops declining this returns what it actually said rather than what the
|
||||||
// ruling predicted.
|
// ruling predicted.
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
MGLOG_F("MGPipe: Fatal{UnexpectedMapAccept, \"map_persistent\"} - the server "
|
SessionFail(MGFatalFamily::UnexpectedMapAccept, "MGPipe: Fatal{UnexpectedMapAccept, \"map_persistent\"} - the server "
|
||||||
"accepted a persistent map under split. R-6 makes the split answer a "
|
"accepted a persistent map under split. R-6 makes the split answer a "
|
||||||
"constant decline because there is no way to hand a host pointer across "
|
"constant decline because there is no way to hand a host pointer across "
|
||||||
"a process boundary in P5; a pointer arriving here is one this client "
|
"a process boundary in P5; a pointer arriving here is one this client "
|
||||||
"cannot dereference");
|
"cannot dereference");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -522,12 +524,11 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
}
|
}
|
||||||
ClientSession& session = RequireSession("CreateShaderState");
|
ClientSession& session = RequireSession("CreateShaderState");
|
||||||
if (link == nullptr || spirv == nullptr) {
|
if (link == nullptr || spirv == nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{ArtefactsMissing, \"create_shader_state\"} - the record's "
|
SessionFail(MGFatalFamily::ArtefactsMissing, "MGPipe: Fatal{ArtefactsMissing, \"create_shader_state\"} - the record's "
|
||||||
"two typed companions are null. Under monolith the applier reads the "
|
"two typed companions are null. Under monolith the applier reads the "
|
||||||
"modules out of spirv->generatedSpirv; under split there is nothing to "
|
"modules out of spirv->generatedSpirv; under split there is nothing to "
|
||||||
"serialise, and emitting the record anyway would create a CSO with no "
|
"serialise, and emitting the record anyway would create a CSO with no "
|
||||||
"code");
|
"code");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
// EncodeProgramArchive APPENDS and never fails - everything it walks is owned
|
// EncodeProgramArchive APPENDS and never fails - everything it walks is owned
|
||||||
// plain data - so an empty archive means the two structs themselves were empty,
|
// plain data - so an empty archive means the two structs themselves were empty,
|
||||||
@@ -547,9 +548,8 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
static_cast<Uint64>(archive.size()));
|
static_cast<Uint64>(archive.size()));
|
||||||
}
|
}
|
||||||
if (archive.empty()) {
|
if (archive.empty()) {
|
||||||
MGLOG_F("MGPipe: Fatal{ArchiveEmpty, \"create_shader_state\"} - the program's "
|
SessionFail(MGFatalFamily::ArchiveEmpty, "MGPipe: Fatal{ArchiveEmpty, \"create_shader_state\"} - the program's "
|
||||||
"artefacts serialised to nothing");
|
"artefacts serialised to nothing");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
MG_Pipe::MGPProgramDesc record = *desc;
|
MG_Pipe::MGPProgramDesc record = *desc;
|
||||||
for (Uint32 i = 0; i < 6; ++i) record.Spirv[i] = MG_Pipe::MGPBlobRef{};
|
for (Uint32 i = 0; i < 6; ++i) record.Spirv[i] = MG_Pipe::MGPBlobRef{};
|
||||||
@@ -714,15 +714,35 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
|
|
||||||
void RequireClientTablesInstalled(const char* row) {
|
void RequireClientTablesInstalled(const char* row) {
|
||||||
if (g_clientTablesUninstalled.load(std::memory_order_acquire)) {
|
if (g_clientTablesUninstalled.load(std::memory_order_acquire)) {
|
||||||
MGLOG_F("MGPipe: Fatal{ClientTablesUninstalled, \"%s\"} - the client tables are "
|
SessionFail(MGFatalFamily::ClientTablesUninstalled, "MGPipe: Fatal{ClientTablesUninstalled, \"%s\"} - the client tables are "
|
||||||
"being torn down; refusing before session or ring access", row);
|
"being torn down; refusing before session or ring access", row);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void WireStateObjectDestroyed(MG_Pipe::MGPipeKind kind, Uint64 lifetimeId) {
|
||||||
|
(void)EmitObjectDeathRecord(kind, lifetimeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const MG_State::GLState::StateObjectDeathOps kClientStateObjectDeathOps = {
|
||||||
|
.OnDestroyed = &WireStateObjectDestroyed,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void InstallClientWireTables() {
|
void InstallClientWireTables() {
|
||||||
using namespace MG_Pipe;
|
using namespace MG_Pipe;
|
||||||
|
|
||||||
|
// DirectGLES normally installs this notice while creating its handle
|
||||||
|
// backend. An independent client never creates that backend: without a
|
||||||
|
// client emitter, NotifyAndFree silently drops object_death before
|
||||||
|
// freeing the slot. Keep inproc's existing backend dispatcher, and give
|
||||||
|
// the remote client the same wire delivery without a local twin table.
|
||||||
|
if (MG_Config::Transport == MG_Config::TransportMode::Spawn &&
|
||||||
|
MG_Config::ActiveBackendType == BackendType::DirectGLES &&
|
||||||
|
MG_State::GLState::GetStateObjectDeathOps() == nullptr) {
|
||||||
|
MG_State::GLState::SetStateObjectDeathOps(&kClientStateObjectDeathOps);
|
||||||
|
}
|
||||||
|
|
||||||
// A fresh install means the routed tables are live again: a Start after a previous
|
// A fresh install means the routed tables are live again: a Start after a previous
|
||||||
// session's Stop clears the teardown-refusal flag so its own routed calls are not
|
// session's Stop clears the teardown-refusal flag so its own routed calls are not
|
||||||
// refused. (Stop already puts the monolith adapters back and clears the flag; this is
|
// refused. (Stop already puts the monolith adapters back and clears the flag; this is
|
||||||
@@ -786,6 +806,9 @@ namespace MobileGL::MG_Remote::Client {
|
|||||||
// is complete, by ReinstallMonolithAfterTeardown, for the at-exit deletes that reach a
|
// is complete, by ReinstallMonolithAfterTeardown, for the at-exit deletes that reach a
|
||||||
// process with no session at all. Idempotent: safe to call when nothing was installed.
|
// process with no session at all. Idempotent: safe to call when nothing was installed.
|
||||||
g_clientTablesUninstalled.store(true, std::memory_order_release);
|
g_clientTablesUninstalled.store(true, std::memory_order_release);
|
||||||
|
if (MG_State::GLState::GetStateObjectDeathOps() == &kClientStateObjectDeathOps) {
|
||||||
|
MG_State::GLState::SetStateObjectDeathOps(nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReinstallMonolithAfterTeardown() {
|
void ReinstallMonolithAfterTeardown() {
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Remote/FatalFamilies.def
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// P6 `dl` (CONTRACT-P6 5.2, D2 ruling). THE INTERNAL FATAL VOCABULARY, and its projection onto
|
||||||
|
// the SEVEN-value wire FatalCode.
|
||||||
|
//
|
||||||
|
// a6 censused 30 distinct family words against a 7-value wire enum, so Session::Fail(FatalCode,
|
||||||
|
// detail) cannot carry the vocabulary in its first argument - the word would collapse to one of
|
||||||
|
// seven and the log would say "ProtocolCorruption" where the code said "UnmigratedVerb". So the
|
||||||
|
// family is an INTERNAL enum, generated from this file, and the wire keeps FatalCode. Each row
|
||||||
|
// carries the coarse code the PEER is told when this family kills the session; the rich word
|
||||||
|
// stays in the local log and in the SessionFault frame's `family` string.
|
||||||
|
//
|
||||||
|
// THE PROJECTION IS A TOTAL TABLE, NOT A SWITCH WITH A DEFAULT. This build has no -Werror
|
||||||
|
// anywhere (measured: CMakeLists, every *.cmake, both workflows), so a gate premised on -Wswitch
|
||||||
|
// catching a missing arm is fiction. A row here IS the arm; a family with no row does not
|
||||||
|
// compile a call that names it.
|
||||||
|
//
|
||||||
|
// WHY EACH CODE. The wire FatalCode answers one question for the peer: what KIND of end was
|
||||||
|
// this. The buckets:
|
||||||
|
// ProtocolCorruption - the peer sent, or the session reached, something that cannot be
|
||||||
|
// honoured correctly: a malformed record, an unimplemented verb/surface,
|
||||||
|
// an invariant the roles must hold, a reply that does not fit its
|
||||||
|
// contract. The peer's takeaway is "we disagree about the protocol".
|
||||||
|
// RingOverrun - a shared ring or event channel overran. A transport-capacity fact.
|
||||||
|
// SegmentMismatch - a shared SEGMENT's geometry could not hold what a role needed to put
|
||||||
|
// in it. Distinct from a ring overrun: the segment is the wrong SIZE,
|
||||||
|
// not merely full this instant.
|
||||||
|
// AbiMismatch - the two builds do not agree on layout or protocol version.
|
||||||
|
// ServerCrashed - a liveness end the WAITING side attributes to the other: a drain that
|
||||||
|
// never completed, an apply thread that is gone or never started. The
|
||||||
|
// device-lost latch is armed from the doorbell, never from these, but the
|
||||||
|
// peer that was waiting is told the server is gone.
|
||||||
|
// DeviceLost - reserved: set by the latch (5.3), never raised as a Fatal family, so no
|
||||||
|
// row projects onto it.
|
||||||
|
//
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
|
// X(Family, WireFatalCode, Why)
|
||||||
|
#define MGL_FATAL_FAMILY_LIST(X) \
|
||||||
|
X(ProtocolCorruption, ProtocolCorruption, "a record's bounds or self-describing length was violated") \
|
||||||
|
X(UnmigratedVerb, ProtocolCorruption, "a wire verb slot P5/P6 does not implement was reached") \
|
||||||
|
X(UnmigratedSurface, ProtocolCorruption, "a surface op named a client-process handle that means nothing here (P12)") \
|
||||||
|
X(UnmigratedPipeInput, ProtocolCorruption, "a PipeInputs field with no field-ownership row was read across the boundary") \
|
||||||
|
X(RoleViolation, ProtocolCorruption, "a call ran on the wrong role/thread - an invariant the two roles must hold") \
|
||||||
|
X(UnsetCallMask, ProtocolCorruption, "the CallMask was consulted before either half was published") \
|
||||||
|
X(ClientTablesUninstalled, ProtocolCorruption, "the applier ran before the client installed its tables") \
|
||||||
|
X(NoClientSession, ProtocolCorruption, "a path that needs the client session ran without one") \
|
||||||
|
X(UnexpectedMapAccept, ProtocolCorruption, "a persistent-map accept arrived where the protocol permits none") \
|
||||||
|
X(UncarriedInitialBytes, ProtocolCorruption, "a producer's initial bytes were required on the wire and absent") \
|
||||||
|
X(ReplyStatusInvalid, ProtocolCorruption, "a reply carried a status outside the defined set") \
|
||||||
|
X(ReplyError, ProtocolCorruption, "a reply-owning verb saw an error status it cannot represent") \
|
||||||
|
X(ReplyMissing, ProtocolCorruption, "a reply slot the protocol requires was empty") \
|
||||||
|
X(ReplyTooLarge, ProtocolCorruption, "an answer exceeded the size its verb's contract allows") \
|
||||||
|
X(ReadbackDeclined, ProtocolCorruption, "a readback that cannot return without complete pixels was declined") \
|
||||||
|
X(ReadbackReplyShort, ProtocolCorruption, "a readback reply carried fewer bytes than its shape requires") \
|
||||||
|
X(UnsizedReadback, ProtocolCorruption, "a readback arrived with no declared size") \
|
||||||
|
X(BlobMissing, ProtocolCorruption, "a record named a blob that was never staged") \
|
||||||
|
X(BlobNotStaged, ProtocolCorruption, "a blob was referenced before its staging completed") \
|
||||||
|
X(ArtefactsMissing, ProtocolCorruption, "a program create arrived with no artefacts") \
|
||||||
|
X(ArchiveEmpty, ProtocolCorruption, "a create_*_state archive carried no payload") \
|
||||||
|
X(BarrierViolation, ProtocolCorruption, "a field was pulled across a verb boundary the barrier forbids") \
|
||||||
|
X(UnimplementedAdoptTier, ProtocolCorruption, "MOBILEGL_IPC_ADOPT_TIER named a tier P5 does not implement") \
|
||||||
|
X(UnimplementedWritebackWait, ProtocolCorruption, "a writeback wait shape P5 does not implement was requested") \
|
||||||
|
X(UnimplementedRemoteBackendObject, ProtocolCorruption, "a BackendObject_Remote entry point P5 does not implement was called") \
|
||||||
|
X(UnimplementedClientSession, ProtocolCorruption, "a ClientSession entry point P5 does not implement was called") \
|
||||||
|
X(RingOverrun, RingOverrun, "a shared ring refused a record after sufficient space had retired") \
|
||||||
|
X(EventRingOverflow, RingOverrun, "the reverse event ring overflowed") \
|
||||||
|
X(StageSnapshotTooNarrow, SegmentMismatch, "SEG_STAGE was too small for a snapshot a verb had to place in it") \
|
||||||
|
X(AbiMismatch, AbiMismatch, "the two builds disagree on struct layout or protocol version") \
|
||||||
|
X(BarrierTimeout, ServerCrashed, "appliedSeq did not reach the target within the bounded wait") \
|
||||||
|
X(PresentCreditTimeout, ServerCrashed, "a present credit did not return within the bounded wait") \
|
||||||
|
X(RetirementWaitFailed, ServerCrashed, "a wait for the server to retire staging did not complete") \
|
||||||
|
X(ApplyThreadJoinTimeout, ServerCrashed, "the apply thread did not join within its bound at teardown") \
|
||||||
|
X(ApplyThreadNotRunning, ServerCrashed, "an operation needed the apply thread and it was not running")
|
||||||
|
|
||||||
|
// clang-format on
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Remote/FatalFamily.h
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// P6 `dl` (CONTRACT-P6 5.2). The internal Fatal vocabulary and its total projection onto the
|
||||||
|
// wire FatalCode, both generated from FatalFamilies.def so a family, its name and its wire code
|
||||||
|
// cannot drift apart: adding a family is one row, and a row that forgets its code does not
|
||||||
|
// compile.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <MG_Remote/Protocol/generated/protocol_generated.h>
|
||||||
|
|
||||||
|
#include "FatalFamilies.def"
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote {
|
||||||
|
|
||||||
|
// One value per row of FatalFamilies.def, in file order. The names ARE the family words that
|
||||||
|
// appear in every `Fatal{...}` log line, which is what lets FatalFamilyName round-trip
|
||||||
|
// against the string a site passes.
|
||||||
|
enum class MGFatalFamily : ::std::uint32_t {
|
||||||
|
#define X(Family, WireCode, Why) Family,
|
||||||
|
MGL_FATAL_FAMILY_LIST(X)
|
||||||
|
#undef X
|
||||||
|
};
|
||||||
|
|
||||||
|
// THE PROJECTION, AS A TOTAL TABLE. Not a switch with a default arm: this build has no
|
||||||
|
// -Werror, so a default would silently swallow a family added without a code. Every family
|
||||||
|
// that exists has a row, and a family that does not exist is not a value of the enum.
|
||||||
|
inline ::MobileGL::Wire::FatalCode FatalCodeForFamily(MGFatalFamily family) {
|
||||||
|
switch (family) {
|
||||||
|
#define X(Family, WireCode, Why) \
|
||||||
|
case MGFatalFamily::Family: return ::MobileGL::Wire::FatalCode::WireCode;
|
||||||
|
MGL_FATAL_FAMILY_LIST(X)
|
||||||
|
#undef X
|
||||||
|
}
|
||||||
|
// Unreachable for any real enum value; kept so the function is total for the compiler
|
||||||
|
// without a `default:` that would mask a missing row.
|
||||||
|
return ::MobileGL::Wire::FatalCode::ProtocolCorruption;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The family's own word, byte-for-byte what appears inside `Fatal{<name>, ...}`. A death
|
||||||
|
// site passes both the enum and its full message string; a test asserts this name is present
|
||||||
|
// in that string, which is what keeps the two from diverging.
|
||||||
|
inline const char* FatalFamilyName(MGFatalFamily family) {
|
||||||
|
switch (family) {
|
||||||
|
#define X(Family, WireCode, Why) \
|
||||||
|
case MGFatalFamily::Family: return #Family;
|
||||||
|
MGL_FATAL_FAMILY_LIST(X)
|
||||||
|
#undef X
|
||||||
|
}
|
||||||
|
return "<unknown>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// The count, for a test that walks every family.
|
||||||
|
inline constexpr ::std::size_t MGFatalFamilyCount() {
|
||||||
|
::std::size_t n = 0;
|
||||||
|
#define X(Family, WireCode, Why) ++n;
|
||||||
|
MGL_FATAL_FAMILY_LIST(X)
|
||||||
|
#undef X
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace MobileGL::MG_Remote
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Remote/FatalFunnel.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
|
||||||
|
|
||||||
|
#include <MG_Remote/FatalFunnel.h>
|
||||||
|
|
||||||
|
#include "../Includes.h" // MGLOG_F and the umbrella; a .cpp may pull it, a Transport/ header may not
|
||||||
|
#include "Client/ClientSession.h"
|
||||||
|
#include "Protocol/generated/protocol_generated.h"
|
||||||
|
#include "Server/ServerSession.h"
|
||||||
|
#include "Transport/ITransport.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
#include <flatbuffers/flatbuffers.h>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// One telemetry point (5.2). Bumped exactly once per death, before the abort, so a test
|
||||||
|
// that forks a child and reads it back sees the increment even though the child is gone -
|
||||||
|
// it reads its OWN process's counter for the funnel it drove, not the child's.
|
||||||
|
std::atomic<std::uint64_t> g_sessionFaultCount{0};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
std::uint64_t SessionFaultCount() {
|
||||||
|
return g_sessionFaultCount.load(std::memory_order_relaxed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SessionFail(MGFatalFamily family, const char* fmt, ...) {
|
||||||
|
// The line, formatted exactly as the site's old MGLOG_F would have. Same buffer size and
|
||||||
|
// same fallback as WireLogFatal, so a death that used either path reads identically.
|
||||||
|
char line[512];
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
const int written = std::vsnprintf(line, sizeof(line), fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
if (written < 0) {
|
||||||
|
std::snprintf(line, sizeof(line),
|
||||||
|
"MG_Remote: unformattable Fatal diagnostic (format=%s)", fmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_sessionFaultCount.fetch_add(1, std::memory_order_relaxed);
|
||||||
|
|
||||||
|
MGLOG_F("%s", line);
|
||||||
|
// The stderr echo is the half a death test can see: Defines.h builds the logger with the
|
||||||
|
// console sink off, so an MGLOG line reaches only the file - and a gtest death matcher
|
||||||
|
// reads the child's stderr. Flushed because abort() does not flush stdio.
|
||||||
|
std::fputs(line, stderr);
|
||||||
|
std::fputc('\n', stderr);
|
||||||
|
std::fflush(stderr);
|
||||||
|
|
||||||
|
// A SessionFault frame to the peer, BEFORE the abort, so the other side's log names the
|
||||||
|
// family instead of reading a bare EOF (5.2). Best-effort by nature: this thread is about
|
||||||
|
// to die, so a send that blocks or fails changes nothing it could have changed anyway.
|
||||||
|
//
|
||||||
|
// WHICHEVER ROLE THIS PROCESS IS. Under spawn only one session is active per process -
|
||||||
|
// the client has ClientSession, the server has ServerSession - so publishing on whatever
|
||||||
|
// control plane exists reaches the far side. Under inproc both exist and the frame goes
|
||||||
|
// to an in-process transport the aborting process will never read; harmless, and not
|
||||||
|
// worth a special case that would then be the untested one.
|
||||||
|
//
|
||||||
|
// `code` is the coarse seven-value projection; `family` carries the full word; `message`
|
||||||
|
// is the same line just logged. seq/op are not threaded through the 90 call sites and the
|
||||||
|
// message already names the op where it matters, so the frame carries what it can name
|
||||||
|
// honestly rather than a field that is always zero.
|
||||||
|
Transport::ITransport* control = nullptr;
|
||||||
|
if (Client::ClientSession* client = Client::ClientSession::Active()) {
|
||||||
|
control = client->Control_Plane();
|
||||||
|
}
|
||||||
|
if (control == nullptr) {
|
||||||
|
if (Server::ServerSession* server = Server::ServerSession::Active()) {
|
||||||
|
control = server->Control_Plane();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (control != nullptr) {
|
||||||
|
::flatbuffers::FlatBufferBuilder builder(256);
|
||||||
|
const auto fatal = ::MobileGL::Wire::CreateFatalDirect(
|
||||||
|
builder, FatalCodeForFamily(family), line, FatalFamilyName(family));
|
||||||
|
const auto root = ::MobileGL::Wire::CreateCtrlEnvelope(
|
||||||
|
builder, ::MobileGL::Wire::CtrlMsg::Fatal, fatal.Union());
|
||||||
|
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, root);
|
||||||
|
(void)control->SendFrame(
|
||||||
|
MobileGLByteSpan{builder.GetBufferPointer(), builder.GetSize()});
|
||||||
|
}
|
||||||
|
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace MobileGL::MG_Remote
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Remote/FatalFunnel.h
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// P6 `dl` (CONTRACT-P6 5.2). THE ONE PLACE A SESSION DIES.
|
||||||
|
//
|
||||||
|
// Every `Fatal{...}` under MG_Remote/ used to be an MGLOG_F followed by its own std::abort().
|
||||||
|
// a6 counted ~92 of them. Scattered, they gave the funnel's three benefits to nobody: there was
|
||||||
|
// no single place to publish a SessionFault to the peer before dying, no single telemetry point,
|
||||||
|
// and no way for a census to be sure a new death was named. This is that place.
|
||||||
|
//
|
||||||
|
// THE MESSAGE STRING IS PASSED VERBATIM, family word and all. The contract requires the log
|
||||||
|
// lines, the CI greps and every red-once to be byte-identical, so SessionFail does not compose
|
||||||
|
// the line from the family - it takes the SAME string the site used to hand MGLOG_F and forwards
|
||||||
|
// it unchanged. The family enum rides ALONGSIDE, redundantly, so the funnel knows the coarse wire
|
||||||
|
// FatalCode without parsing the string; a test asserts the enum's name appears in the string, so
|
||||||
|
// the redundancy cannot rot into disagreement.
|
||||||
|
//
|
||||||
|
// NOT in WireLog.h: that header is deliberately dependency-light (ITransport.h's rule, the
|
||||||
|
// include-graph purity gate), and this needs FatalFamily.h, which pulls the protocol header. The
|
||||||
|
// header-layer sites that must stay pure keep using WireLogFatal, whose own abort routes through
|
||||||
|
// the same publisher in WireLog.cpp.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <MG_Remote/FatalFamily.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote {
|
||||||
|
|
||||||
|
// Logs the line (byte-identical to the old MGLOG_F), echoes it to stderr so a death test can
|
||||||
|
// see it, publishes a SessionFault{family, ...} to the peer if one is connected, bumps the
|
||||||
|
// telemetry counter, and aborts. `fmt` is the FULL original message, e.g.
|
||||||
|
// "MGPipe: Fatal{RingOverrun, \"SEG_CMD\"} - %s ...".
|
||||||
|
[[noreturn]]
|
||||||
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
|
__attribute__((format(printf, 2, 3)))
|
||||||
|
#endif
|
||||||
|
void SessionFail(MGFatalFamily family, const char* fmt, ...);
|
||||||
|
|
||||||
|
// How many times a session has ended through the funnel this process. Exit gate S8 asserts
|
||||||
|
// this is zero over a whole good run; a test reads it to prove the funnel was reached.
|
||||||
|
::std::uint64_t SessionFaultCount();
|
||||||
|
|
||||||
|
} // namespace MobileGL::MG_Remote
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
// P6.5 handshake policy, shared by both roles. Rejections are returned, never aborted.
|
||||||
|
#pragma once
|
||||||
|
#include "CapsCodec.h"
|
||||||
|
#include "Protocol/generated/protocol_generated.h"
|
||||||
|
#include "Transport/ITransport.h"
|
||||||
|
#include <MG_Util/Debug/Log.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote {
|
||||||
|
inline MobileGLResult RefuseHandshake(Transport::ITransport& transport,
|
||||||
|
::MobileGL::Wire::RefuseCode code,
|
||||||
|
const char* detail, Uint64 expected = 0,
|
||||||
|
Uint64 actual = 0, const char* peerValue = nullptr) {
|
||||||
|
MGLOG_E("MGPipe: Refuse{%s} %s expected=%llu actual=%llu peer=%s",
|
||||||
|
::MobileGL::Wire::EnumNameRefuseCode(code), detail,
|
||||||
|
static_cast<unsigned long long>(expected), static_cast<unsigned long long>(actual),
|
||||||
|
peerValue == nullptr ? "" : peerValue);
|
||||||
|
::flatbuffers::FlatBufferBuilder builder(256);
|
||||||
|
auto refusal = ::MobileGL::Wire::CreateRefuseDirect(builder, code, detail, expected, actual, peerValue);
|
||||||
|
auto envelope = ::MobileGL::Wire::CreateCtrlEnvelope(builder, ::MobileGL::Wire::CtrlMsg::Refuse,
|
||||||
|
refusal.Union());
|
||||||
|
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||||
|
transport.SendFrame({builder.GetBufferPointer(), builder.GetSize()});
|
||||||
|
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool LogPeerRefusal(const ::MobileGL::Wire::CtrlEnvelope* envelope) {
|
||||||
|
if (envelope == nullptr || envelope->msg_type() != ::MobileGL::Wire::CtrlMsg::Refuse) return false;
|
||||||
|
const auto* refusal = envelope->msg_as_Refuse();
|
||||||
|
if (refusal == nullptr) return false;
|
||||||
|
MGLOG_E("MGPipe: peer Refuse{%s} %s expected=%llu actual=%llu",
|
||||||
|
::MobileGL::Wire::EnumNameRefuseCode(refusal->code()),
|
||||||
|
refusal->detail() == nullptr ? "" : refusal->detail()->c_str(),
|
||||||
|
static_cast<unsigned long long>(refusal->expected()),
|
||||||
|
static_cast<unsigned long long>(refusal->actual()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MobileGLResult ValidatePeerHandshake(Transport::ITransport& transport,
|
||||||
|
Uint32 major, Uint32 minor, Uint64 fingerprint,
|
||||||
|
const char* stamp, ::MobileGL::Wire::DialMode dial) {
|
||||||
|
using ::MobileGL::Wire::RefuseCode;
|
||||||
|
if (major != MOBILEGL_PROTOCOL_ABI_MAJOR || minor != MOBILEGL_PROTOCOL_ABI_MINOR)
|
||||||
|
return RefuseHandshake(transport, RefuseCode::ProtocolVersion, "protocol version",
|
||||||
|
MOBILEGL_ABI_VERSION(MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR),
|
||||||
|
MOBILEGL_ABI_VERSION(major, minor));
|
||||||
|
if (fingerprint != WireFingerprint())
|
||||||
|
return RefuseHandshake(transport, RefuseCode::WireFingerprint, "wire layout",
|
||||||
|
WireFingerprint(), fingerprint);
|
||||||
|
const bool sameBuild = BuildFingerprintPresent() && stamp != nullptr && stamp[0] != '\0' &&
|
||||||
|
std::strcmp(stamp, BuildFingerprint()) == 0;
|
||||||
|
const char* required = std::getenv("MOBILEGL_IPC_REQUIRE_SAME_BUILD");
|
||||||
|
const bool requireSame = dial == ::MobileGL::Wire::DialMode::Fork ||
|
||||||
|
(required != nullptr && std::strcmp(required, "1") == 0);
|
||||||
|
if (!sameBuild && requireSame)
|
||||||
|
return RefuseHandshake(transport, RefuseCode::BuildFingerprint, "build identity", 0, 0,
|
||||||
|
stamp == nullptr ? "<missing>" : stamp);
|
||||||
|
if (!sameBuild && dial == ::MobileGL::Wire::DialMode::Connect)
|
||||||
|
MGLOG_W("MGPipe: compatible wire with different build: local=%s peer=%s",
|
||||||
|
BuildFingerprint(), stamp == nullptr ? "<missing>" : stamp);
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
} // namespace MobileGL::MG_Remote
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
// End of Source File Header
|
// End of Source File Header
|
||||||
|
|
||||||
#include "SurfaceOpCodec.h"
|
#include "SurfaceOpCodec.h"
|
||||||
|
#include <MG_Remote/FatalFunnel.h>
|
||||||
|
|
||||||
#include <MG_Backend/BackendObject.h>
|
#include <MG_Backend/BackendObject.h>
|
||||||
#include <MG_Remote/Protocol/generated/protocol_generated.h>
|
#include <MG_Remote/Protocol/generated/protocol_generated.h>
|
||||||
@@ -47,9 +48,13 @@ namespace MobileGL::MG_Remote {
|
|||||||
static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::ReleaseResources));
|
static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::ReleaseResources));
|
||||||
static_assert(static_cast<Uint8>(SurfaceControlOp::SetWindowHandle) ==
|
static_assert(static_cast<Uint8>(SurfaceControlOp::SetWindowHandle) ==
|
||||||
static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::SetWindowHandle));
|
static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::SetWindowHandle));
|
||||||
|
// cp's one schema addition, on the same append-only terms.
|
||||||
|
static_assert(static_cast<Uint8>(SurfaceControlOp::InitCapabilities) ==
|
||||||
|
static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::InitCapabilities));
|
||||||
static_assert(static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::SetSwapInterval) == 8 &&
|
static_assert(static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::SetSwapInterval) == 8 &&
|
||||||
static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::ReleaseResources) == 9 &&
|
static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::ReleaseResources) == 9 &&
|
||||||
static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::SetWindowHandle) == 10);
|
static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::SetWindowHandle) == 10 &&
|
||||||
|
static_cast<Uint8>(::MobileGL::Wire::SurfaceOpKind::InitCapabilities) == 11);
|
||||||
static_assert(static_cast<Uint8>(::MobileGL::Wire::WindowKind::MetalLayer) == 6);
|
static_assert(static_cast<Uint8>(::MobileGL::Wire::WindowKind::MetalLayer) == 6);
|
||||||
|
|
||||||
bool OpNeedsAWindowBackend(SurfaceControlOp op) {
|
bool OpNeedsAWindowBackend(SurfaceControlOp op) {
|
||||||
@@ -80,8 +85,12 @@ namespace MobileGL::MG_Remote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SurfaceControlOpForWireKind(::MobileGL::Wire::SurfaceOpKind kind, SurfaceControlOp* out) {
|
bool SurfaceControlOpForWireKind(::MobileGL::Wire::SurfaceOpKind kind, SurfaceControlOp* out) {
|
||||||
|
// THE UPPER BOUND IS THE LAST APPENDED KIND, and it moves with every
|
||||||
|
// append or the new tag decodes as out-of-range - which reads as
|
||||||
|
// Fatal{ProtocolCorruption} at ServerApplyWireSurfaceOp rather than as
|
||||||
|
// the missing row it is.
|
||||||
if (::flatbuffers::IsOutRange(kind, ::MobileGL::Wire::SurfaceOpKind::InitializeDisplay,
|
if (::flatbuffers::IsOutRange(kind, ::MobileGL::Wire::SurfaceOpKind::InitializeDisplay,
|
||||||
::MobileGL::Wire::SurfaceOpKind::SetWindowHandle)) {
|
::MobileGL::Wire::SurfaceOpKind::InitCapabilities)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const SurfaceControlOp op = static_cast<SurfaceControlOp>(static_cast<Uint8>(kind));
|
const SurfaceControlOp op = static_cast<SurfaceControlOp>(static_cast<Uint8>(kind));
|
||||||
@@ -181,7 +190,7 @@ namespace MobileGL::MG_Remote {
|
|||||||
void EncodeSurfaceReplyFrame(const SurfaceControlFrame& frame,
|
void EncodeSurfaceReplyFrame(const SurfaceControlFrame& frame,
|
||||||
flatbuffers::FlatBufferBuilder* builder) {
|
flatbuffers::FlatBufferBuilder* builder) {
|
||||||
const auto reply = ::MobileGL::Wire::CreateSurfaceReply(*builder, frame.seq, frame.ok, frame.eglMajor,
|
const auto reply = ::MobileGL::Wire::CreateSurfaceReply(*builder, frame.seq, frame.ok, frame.eglMajor,
|
||||||
frame.eglMinor, /*defaultFb=*/0);
|
frame.eglMinor, /*defaultFb=*/0, frame.eventHead);
|
||||||
const auto envelope =
|
const auto envelope =
|
||||||
::MobileGL::Wire::CreateCtrlEnvelope(*builder, ::MobileGL::Wire::CtrlMsg::SurfaceReply, reply.Union());
|
::MobileGL::Wire::CreateCtrlEnvelope(*builder, ::MobileGL::Wire::CtrlMsg::SurfaceReply, reply.Union());
|
||||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(*builder, envelope);
|
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(*builder, envelope);
|
||||||
@@ -192,6 +201,7 @@ namespace MobileGL::MG_Remote {
|
|||||||
frame->ok = reply.ok();
|
frame->ok = reply.ok();
|
||||||
frame->eglMajor = reply.eglMajor();
|
frame->eglMajor = reply.eglMajor();
|
||||||
frame->eglMinor = reply.eglMinor();
|
frame->eglMinor = reply.eglMinor();
|
||||||
|
frame->eventHead = reply.eventHead();
|
||||||
}
|
}
|
||||||
|
|
||||||
MobileGLResult ServerApplyWireSurfaceOp(const ::MobileGL::Wire::SurfaceOp& op, SurfaceControlFrame* replyOut) {
|
MobileGLResult ServerApplyWireSurfaceOp(const ::MobileGL::Wire::SurfaceOp& op, SurfaceControlFrame* replyOut) {
|
||||||
@@ -199,22 +209,24 @@ namespace MobileGL::MG_Remote {
|
|||||||
const SurfaceWireError error = DecodeWireSurfaceOp(op, &frame);
|
const SurfaceWireError error = DecodeWireSurfaceOp(op, &frame);
|
||||||
if (error != SurfaceWireError::None) {
|
if (error != SurfaceWireError::None) {
|
||||||
if (error == SurfaceWireError::AndroidNativeWindowArrived) {
|
if (error == SurfaceWireError::AndroidNativeWindowArrived) {
|
||||||
MGLOG_F("MGPipe: Fatal{UnmigratedSurface, \"AndroidNativeWindow@P12\"} - a wire "
|
SessionFail(MGFatalFamily::UnmigratedSurface,
|
||||||
|
"MGPipe: Fatal{UnmigratedSurface, \"AndroidNativeWindow@P12\"} - a wire "
|
||||||
"SurfaceOp (%s) named an ANativeWindow*, which is a pointer into the "
|
"SurfaceOp (%s) named an ANativeWindow*, which is a pointer into the "
|
||||||
"CLIENT's process and means nothing here. Real window arrival is P12; "
|
"CLIENT's process and means nothing here. Real window arrival is P12; "
|
||||||
"until then the spawn surface path is pbuffer/surfaceless only",
|
"until then the spawn surface path is pbuffer/surfaceless only",
|
||||||
::MobileGL::Wire::EnumNameSurfaceOpKind(op.kind()));
|
::MobileGL::Wire::EnumNameSurfaceOpKind(op.kind()));
|
||||||
} else if (error == SurfaceWireError::MetalLayerArrived) {
|
} else if (error == SurfaceWireError::MetalLayerArrived) {
|
||||||
MGLOG_F("MGPipe: Fatal{UnmigratedSurface, \"MetalLayer@P12\"} - a wire "
|
SessionFail(MGFatalFamily::UnmigratedSurface,
|
||||||
|
"MGPipe: Fatal{UnmigratedSurface, \"MetalLayer@P12\"} - a wire "
|
||||||
"SurfaceOp named a CAMetalLayer* in the CLIENT's process. "
|
"SurfaceOp named a CAMetalLayer* in the CLIENT's process. "
|
||||||
"Real window arrival is P12");
|
"Real window arrival is P12");
|
||||||
} else {
|
} else {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"SurfaceOp\"} - a wire surface op "
|
SessionFail(MGFatalFamily::ProtocolCorruption,
|
||||||
|
"MGPipe: Fatal{ProtocolCorruption, \"SurfaceOp\"} - a wire surface op "
|
||||||
"failed validation: %s (wire kind %u, window kind %u)",
|
"failed validation: %s (wire kind %u, window kind %u)",
|
||||||
SurfaceWireErrorName(error), static_cast<unsigned>(op.kind()),
|
SurfaceWireErrorName(error), static_cast<unsigned>(op.kind()),
|
||||||
static_cast<unsigned>(op.windowKind()));
|
static_cast<unsigned>(op.windowKind()));
|
||||||
}
|
}
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
const MobileGLResult rc = Server::ServerLoopInstance().RunSurfaceControlFrame(frame);
|
const MobileGLResult rc = Server::ServerLoopInstance().RunSurfaceControlFrame(frame);
|
||||||
if (replyOut != nullptr) *replyOut = frame;
|
if (replyOut != nullptr) *replyOut = frame;
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ namespace Wire {
|
|||||||
struct SegmentRef;
|
struct SegmentRef;
|
||||||
struct SegmentRefBuilder;
|
struct SegmentRefBuilder;
|
||||||
|
|
||||||
|
struct LinkTerms;
|
||||||
|
struct LinkTermsBuilder;
|
||||||
|
|
||||||
|
struct Refuse;
|
||||||
|
struct RefuseBuilder;
|
||||||
|
|
||||||
|
struct LogFlush;
|
||||||
|
struct LogFlushBuilder;
|
||||||
|
|
||||||
struct Hello;
|
struct Hello;
|
||||||
struct HelloBuilder;
|
struct HelloBuilder;
|
||||||
|
|
||||||
@@ -113,6 +122,147 @@ inline const char *EnumNameSegmentKind(SegmentKind e) {
|
|||||||
return EnumNamesSegmentKind()[index];
|
return EnumNamesSegmentKind()[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class DataPlane : uint8_t {
|
||||||
|
SharedSegments = 0,
|
||||||
|
Stream = 1,
|
||||||
|
MIN = SharedSegments,
|
||||||
|
MAX = Stream
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const DataPlane (&EnumValuesDataPlane())[2] {
|
||||||
|
static const DataPlane values[] = {
|
||||||
|
DataPlane::SharedSegments,
|
||||||
|
DataPlane::Stream
|
||||||
|
};
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char * const *EnumNamesDataPlane() {
|
||||||
|
static const char * const names[3] = {
|
||||||
|
"SharedSegments",
|
||||||
|
"Stream",
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char *EnumNameDataPlane(DataPlane e) {
|
||||||
|
if (::flatbuffers::IsOutRange(e, DataPlane::SharedSegments, DataPlane::Stream)) return "";
|
||||||
|
const size_t index = static_cast<size_t>(e);
|
||||||
|
return EnumNamesDataPlane()[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class WireForm : uint8_t {
|
||||||
|
StructImage = 0,
|
||||||
|
MIN = StructImage,
|
||||||
|
MAX = StructImage
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const WireForm (&EnumValuesWireForm())[1] {
|
||||||
|
static const WireForm values[] = {
|
||||||
|
WireForm::StructImage
|
||||||
|
};
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char * const *EnumNamesWireForm() {
|
||||||
|
static const char * const names[2] = {
|
||||||
|
"StructImage",
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char *EnumNameWireForm(WireForm e) {
|
||||||
|
if (::flatbuffers::IsOutRange(e, WireForm::StructImage, WireForm::StructImage)) return "";
|
||||||
|
const size_t index = static_cast<size_t>(e);
|
||||||
|
return EnumNamesWireForm()[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class DialMode : uint8_t {
|
||||||
|
No = 0,
|
||||||
|
Fork = 1,
|
||||||
|
Connect = 2,
|
||||||
|
MIN = No,
|
||||||
|
MAX = Connect
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const DialMode (&EnumValuesDialMode())[3] {
|
||||||
|
static const DialMode values[] = {
|
||||||
|
DialMode::No,
|
||||||
|
DialMode::Fork,
|
||||||
|
DialMode::Connect
|
||||||
|
};
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char * const *EnumNamesDialMode() {
|
||||||
|
static const char * const names[4] = {
|
||||||
|
"No",
|
||||||
|
"Fork",
|
||||||
|
"Connect",
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char *EnumNameDialMode(DialMode e) {
|
||||||
|
if (::flatbuffers::IsOutRange(e, DialMode::No, DialMode::Connect)) return "";
|
||||||
|
const size_t index = static_cast<size_t>(e);
|
||||||
|
return EnumNamesDialMode()[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class RefuseCode : uint32_t {
|
||||||
|
None = 0,
|
||||||
|
ProtocolVersion = 1,
|
||||||
|
WireFingerprint = 2,
|
||||||
|
BuildFingerprint = 3,
|
||||||
|
Authentication = 4,
|
||||||
|
LinkTerms = 5,
|
||||||
|
Backend = 6,
|
||||||
|
Busy = 7,
|
||||||
|
MalformedHello = 8,
|
||||||
|
MIN = None,
|
||||||
|
MAX = MalformedHello
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const RefuseCode (&EnumValuesRefuseCode())[9] {
|
||||||
|
static const RefuseCode values[] = {
|
||||||
|
RefuseCode::None,
|
||||||
|
RefuseCode::ProtocolVersion,
|
||||||
|
RefuseCode::WireFingerprint,
|
||||||
|
RefuseCode::BuildFingerprint,
|
||||||
|
RefuseCode::Authentication,
|
||||||
|
RefuseCode::LinkTerms,
|
||||||
|
RefuseCode::Backend,
|
||||||
|
RefuseCode::Busy,
|
||||||
|
RefuseCode::MalformedHello
|
||||||
|
};
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char * const *EnumNamesRefuseCode() {
|
||||||
|
static const char * const names[10] = {
|
||||||
|
"None",
|
||||||
|
"ProtocolVersion",
|
||||||
|
"WireFingerprint",
|
||||||
|
"BuildFingerprint",
|
||||||
|
"Authentication",
|
||||||
|
"LinkTerms",
|
||||||
|
"Backend",
|
||||||
|
"Busy",
|
||||||
|
"MalformedHello",
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char *EnumNameRefuseCode(RefuseCode e) {
|
||||||
|
if (::flatbuffers::IsOutRange(e, RefuseCode::None, RefuseCode::MalformedHello)) return "";
|
||||||
|
const size_t index = static_cast<size_t>(e);
|
||||||
|
return EnumNamesRefuseCode()[index];
|
||||||
|
}
|
||||||
|
|
||||||
enum class SurfaceOpKind : uint8_t {
|
enum class SurfaceOpKind : uint8_t {
|
||||||
None = 0,
|
None = 0,
|
||||||
InitializeDisplay = 1,
|
InitializeDisplay = 1,
|
||||||
@@ -125,11 +275,12 @@ enum class SurfaceOpKind : uint8_t {
|
|||||||
SetSwapInterval = 8,
|
SetSwapInterval = 8,
|
||||||
ReleaseResources = 9,
|
ReleaseResources = 9,
|
||||||
SetWindowHandle = 10,
|
SetWindowHandle = 10,
|
||||||
|
InitCapabilities = 11,
|
||||||
MIN = None,
|
MIN = None,
|
||||||
MAX = SetWindowHandle
|
MAX = InitCapabilities
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const SurfaceOpKind (&EnumValuesSurfaceOpKind())[11] {
|
inline const SurfaceOpKind (&EnumValuesSurfaceOpKind())[12] {
|
||||||
static const SurfaceOpKind values[] = {
|
static const SurfaceOpKind values[] = {
|
||||||
SurfaceOpKind::None,
|
SurfaceOpKind::None,
|
||||||
SurfaceOpKind::InitializeDisplay,
|
SurfaceOpKind::InitializeDisplay,
|
||||||
@@ -141,13 +292,14 @@ inline const SurfaceOpKind (&EnumValuesSurfaceOpKind())[11] {
|
|||||||
SurfaceOpKind::ReleaseCurrent,
|
SurfaceOpKind::ReleaseCurrent,
|
||||||
SurfaceOpKind::SetSwapInterval,
|
SurfaceOpKind::SetSwapInterval,
|
||||||
SurfaceOpKind::ReleaseResources,
|
SurfaceOpKind::ReleaseResources,
|
||||||
SurfaceOpKind::SetWindowHandle
|
SurfaceOpKind::SetWindowHandle,
|
||||||
|
SurfaceOpKind::InitCapabilities
|
||||||
};
|
};
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char * const *EnumNamesSurfaceOpKind() {
|
inline const char * const *EnumNamesSurfaceOpKind() {
|
||||||
static const char * const names[12] = {
|
static const char * const names[13] = {
|
||||||
"None",
|
"None",
|
||||||
"InitializeDisplay",
|
"InitializeDisplay",
|
||||||
"CreateWindowSurface",
|
"CreateWindowSurface",
|
||||||
@@ -159,13 +311,14 @@ inline const char * const *EnumNamesSurfaceOpKind() {
|
|||||||
"SetSwapInterval",
|
"SetSwapInterval",
|
||||||
"ReleaseResources",
|
"ReleaseResources",
|
||||||
"SetWindowHandle",
|
"SetWindowHandle",
|
||||||
|
"InitCapabilities",
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *EnumNameSurfaceOpKind(SurfaceOpKind e) {
|
inline const char *EnumNameSurfaceOpKind(SurfaceOpKind e) {
|
||||||
if (::flatbuffers::IsOutRange(e, SurfaceOpKind::None, SurfaceOpKind::SetWindowHandle)) return "";
|
if (::flatbuffers::IsOutRange(e, SurfaceOpKind::None, SurfaceOpKind::InitCapabilities)) return "";
|
||||||
const size_t index = static_cast<size_t>(e);
|
const size_t index = static_cast<size_t>(e);
|
||||||
return EnumNamesSurfaceOpKind()[index];
|
return EnumNamesSurfaceOpKind()[index];
|
||||||
}
|
}
|
||||||
@@ -347,11 +500,13 @@ enum class CtrlMsg : uint8_t {
|
|||||||
AuxRequest = 8,
|
AuxRequest = 8,
|
||||||
Fatal = 9,
|
Fatal = 9,
|
||||||
LogLine = 10,
|
LogLine = 10,
|
||||||
|
Refuse = 11,
|
||||||
|
LogFlush = 12,
|
||||||
MIN = NONE,
|
MIN = NONE,
|
||||||
MAX = LogLine
|
MAX = LogFlush
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const CtrlMsg (&EnumValuesCtrlMsg())[11] {
|
inline const CtrlMsg (&EnumValuesCtrlMsg())[13] {
|
||||||
static const CtrlMsg values[] = {
|
static const CtrlMsg values[] = {
|
||||||
CtrlMsg::NONE,
|
CtrlMsg::NONE,
|
||||||
CtrlMsg::Hello,
|
CtrlMsg::Hello,
|
||||||
@@ -363,13 +518,15 @@ inline const CtrlMsg (&EnumValuesCtrlMsg())[11] {
|
|||||||
CtrlMsg::ResyncDone,
|
CtrlMsg::ResyncDone,
|
||||||
CtrlMsg::AuxRequest,
|
CtrlMsg::AuxRequest,
|
||||||
CtrlMsg::Fatal,
|
CtrlMsg::Fatal,
|
||||||
CtrlMsg::LogLine
|
CtrlMsg::LogLine,
|
||||||
|
CtrlMsg::Refuse,
|
||||||
|
CtrlMsg::LogFlush
|
||||||
};
|
};
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char * const *EnumNamesCtrlMsg() {
|
inline const char * const *EnumNamesCtrlMsg() {
|
||||||
static const char * const names[12] = {
|
static const char * const names[14] = {
|
||||||
"NONE",
|
"NONE",
|
||||||
"Hello",
|
"Hello",
|
||||||
"Welcome",
|
"Welcome",
|
||||||
@@ -381,13 +538,15 @@ inline const char * const *EnumNamesCtrlMsg() {
|
|||||||
"AuxRequest",
|
"AuxRequest",
|
||||||
"Fatal",
|
"Fatal",
|
||||||
"LogLine",
|
"LogLine",
|
||||||
|
"Refuse",
|
||||||
|
"LogFlush",
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char *EnumNameCtrlMsg(CtrlMsg e) {
|
inline const char *EnumNameCtrlMsg(CtrlMsg e) {
|
||||||
if (::flatbuffers::IsOutRange(e, CtrlMsg::NONE, CtrlMsg::LogLine)) return "";
|
if (::flatbuffers::IsOutRange(e, CtrlMsg::NONE, CtrlMsg::LogFlush)) return "";
|
||||||
const size_t index = static_cast<size_t>(e);
|
const size_t index = static_cast<size_t>(e);
|
||||||
return EnumNamesCtrlMsg()[index];
|
return EnumNamesCtrlMsg()[index];
|
||||||
}
|
}
|
||||||
@@ -436,6 +595,14 @@ template<> struct CtrlMsgTraits<MobileGL::Wire::LogLine> {
|
|||||||
static const CtrlMsg enum_value = CtrlMsg::LogLine;
|
static const CtrlMsg enum_value = CtrlMsg::LogLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<> struct CtrlMsgTraits<MobileGL::Wire::Refuse> {
|
||||||
|
static const CtrlMsg enum_value = CtrlMsg::Refuse;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct CtrlMsgTraits<MobileGL::Wire::LogFlush> {
|
||||||
|
static const CtrlMsg enum_value = CtrlMsg::LogFlush;
|
||||||
|
};
|
||||||
|
|
||||||
template <bool B = false>
|
template <bool B = false>
|
||||||
bool VerifyCtrlMsg(::flatbuffers::VerifierTemplate<B> &verifier, const void *obj, CtrlMsg type);
|
bool VerifyCtrlMsg(::flatbuffers::VerifierTemplate<B> &verifier, const void *obj, CtrlMsg type);
|
||||||
template <bool B = false>
|
template <bool B = false>
|
||||||
@@ -535,6 +702,270 @@ inline ::flatbuffers::Offset<SegmentRef> CreateSegmentRefDirect(
|
|||||||
name__);
|
name__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct LinkTerms FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
typedef LinkTermsBuilder Builder;
|
||||||
|
struct Traits;
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_DATAPLANE = 4,
|
||||||
|
VT_WIREFORM = 6,
|
||||||
|
VT_MAXREPLYBYTES = 8,
|
||||||
|
VT_CMDWINDOWBYTES = 10,
|
||||||
|
VT_STAGEWINDOWBYTES = 12,
|
||||||
|
VT_EVENTWINDOWBYTES = 14
|
||||||
|
};
|
||||||
|
MobileGL::Wire::DataPlane dataPlane() const {
|
||||||
|
return static_cast<MobileGL::Wire::DataPlane>(GetField<uint8_t>(VT_DATAPLANE, 0));
|
||||||
|
}
|
||||||
|
MobileGL::Wire::WireForm wireForm() const {
|
||||||
|
return static_cast<MobileGL::Wire::WireForm>(GetField<uint8_t>(VT_WIREFORM, 0));
|
||||||
|
}
|
||||||
|
uint64_t maxReplyBytes() const {
|
||||||
|
return GetField<uint64_t>(VT_MAXREPLYBYTES, 0);
|
||||||
|
}
|
||||||
|
uint64_t cmdWindowBytes() const {
|
||||||
|
return GetField<uint64_t>(VT_CMDWINDOWBYTES, 0);
|
||||||
|
}
|
||||||
|
uint64_t stageWindowBytes() const {
|
||||||
|
return GetField<uint64_t>(VT_STAGEWINDOWBYTES, 0);
|
||||||
|
}
|
||||||
|
uint64_t eventWindowBytes() const {
|
||||||
|
return GetField<uint64_t>(VT_EVENTWINDOWBYTES, 0);
|
||||||
|
}
|
||||||
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyField<uint8_t>(verifier, VT_DATAPLANE, 1) &&
|
||||||
|
VerifyField<uint8_t>(verifier, VT_WIREFORM, 1) &&
|
||||||
|
VerifyField<uint64_t>(verifier, VT_MAXREPLYBYTES, 8) &&
|
||||||
|
VerifyField<uint64_t>(verifier, VT_CMDWINDOWBYTES, 8) &&
|
||||||
|
VerifyField<uint64_t>(verifier, VT_STAGEWINDOWBYTES, 8) &&
|
||||||
|
VerifyField<uint64_t>(verifier, VT_EVENTWINDOWBYTES, 8) &&
|
||||||
|
verifier.EndTable();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LinkTermsBuilder {
|
||||||
|
typedef LinkTerms Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_dataPlane(MobileGL::Wire::DataPlane dataPlane) {
|
||||||
|
fbb_.AddElement<uint8_t>(LinkTerms::VT_DATAPLANE, static_cast<uint8_t>(dataPlane), 0);
|
||||||
|
}
|
||||||
|
void add_wireForm(MobileGL::Wire::WireForm wireForm) {
|
||||||
|
fbb_.AddElement<uint8_t>(LinkTerms::VT_WIREFORM, static_cast<uint8_t>(wireForm), 0);
|
||||||
|
}
|
||||||
|
void add_maxReplyBytes(uint64_t maxReplyBytes) {
|
||||||
|
fbb_.AddElement<uint64_t>(LinkTerms::VT_MAXREPLYBYTES, maxReplyBytes, 0);
|
||||||
|
}
|
||||||
|
void add_cmdWindowBytes(uint64_t cmdWindowBytes) {
|
||||||
|
fbb_.AddElement<uint64_t>(LinkTerms::VT_CMDWINDOWBYTES, cmdWindowBytes, 0);
|
||||||
|
}
|
||||||
|
void add_stageWindowBytes(uint64_t stageWindowBytes) {
|
||||||
|
fbb_.AddElement<uint64_t>(LinkTerms::VT_STAGEWINDOWBYTES, stageWindowBytes, 0);
|
||||||
|
}
|
||||||
|
void add_eventWindowBytes(uint64_t eventWindowBytes) {
|
||||||
|
fbb_.AddElement<uint64_t>(LinkTerms::VT_EVENTWINDOWBYTES, eventWindowBytes, 0);
|
||||||
|
}
|
||||||
|
explicit LinkTermsBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<LinkTerms> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<LinkTerms>(end);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<LinkTerms> CreateLinkTerms(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
MobileGL::Wire::DataPlane dataPlane = MobileGL::Wire::DataPlane::SharedSegments,
|
||||||
|
MobileGL::Wire::WireForm wireForm = MobileGL::Wire::WireForm::StructImage,
|
||||||
|
uint64_t maxReplyBytes = 0,
|
||||||
|
uint64_t cmdWindowBytes = 0,
|
||||||
|
uint64_t stageWindowBytes = 0,
|
||||||
|
uint64_t eventWindowBytes = 0) {
|
||||||
|
LinkTermsBuilder builder_(_fbb);
|
||||||
|
builder_.add_eventWindowBytes(eventWindowBytes);
|
||||||
|
builder_.add_stageWindowBytes(stageWindowBytes);
|
||||||
|
builder_.add_cmdWindowBytes(cmdWindowBytes);
|
||||||
|
builder_.add_maxReplyBytes(maxReplyBytes);
|
||||||
|
builder_.add_wireForm(wireForm);
|
||||||
|
builder_.add_dataPlane(dataPlane);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LinkTerms::Traits {
|
||||||
|
using type = LinkTerms;
|
||||||
|
static auto constexpr Create = CreateLinkTerms;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Refuse FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
typedef RefuseBuilder Builder;
|
||||||
|
struct Traits;
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_CODE = 4,
|
||||||
|
VT_DETAIL = 6,
|
||||||
|
VT_EXPECTED = 8,
|
||||||
|
VT_ACTUAL = 10,
|
||||||
|
VT_PEERVALUE = 12
|
||||||
|
};
|
||||||
|
MobileGL::Wire::RefuseCode code() const {
|
||||||
|
return static_cast<MobileGL::Wire::RefuseCode>(GetField<uint32_t>(VT_CODE, 0));
|
||||||
|
}
|
||||||
|
const ::flatbuffers::String *detail() const {
|
||||||
|
return GetPointer<const ::flatbuffers::String *>(VT_DETAIL);
|
||||||
|
}
|
||||||
|
uint64_t expected() const {
|
||||||
|
return GetField<uint64_t>(VT_EXPECTED, 0);
|
||||||
|
}
|
||||||
|
uint64_t actual() const {
|
||||||
|
return GetField<uint64_t>(VT_ACTUAL, 0);
|
||||||
|
}
|
||||||
|
const ::flatbuffers::String *peerValue() const {
|
||||||
|
return GetPointer<const ::flatbuffers::String *>(VT_PEERVALUE);
|
||||||
|
}
|
||||||
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyField<uint32_t>(verifier, VT_CODE, 4) &&
|
||||||
|
VerifyOffset(verifier, VT_DETAIL) &&
|
||||||
|
verifier.VerifyString(detail()) &&
|
||||||
|
VerifyField<uint64_t>(verifier, VT_EXPECTED, 8) &&
|
||||||
|
VerifyField<uint64_t>(verifier, VT_ACTUAL, 8) &&
|
||||||
|
VerifyOffset(verifier, VT_PEERVALUE) &&
|
||||||
|
verifier.VerifyString(peerValue()) &&
|
||||||
|
verifier.EndTable();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RefuseBuilder {
|
||||||
|
typedef Refuse Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_code(MobileGL::Wire::RefuseCode code) {
|
||||||
|
fbb_.AddElement<uint32_t>(Refuse::VT_CODE, static_cast<uint32_t>(code), 0);
|
||||||
|
}
|
||||||
|
void add_detail(::flatbuffers::Offset<::flatbuffers::String> detail) {
|
||||||
|
fbb_.AddOffset(Refuse::VT_DETAIL, detail);
|
||||||
|
}
|
||||||
|
void add_expected(uint64_t expected) {
|
||||||
|
fbb_.AddElement<uint64_t>(Refuse::VT_EXPECTED, expected, 0);
|
||||||
|
}
|
||||||
|
void add_actual(uint64_t actual) {
|
||||||
|
fbb_.AddElement<uint64_t>(Refuse::VT_ACTUAL, actual, 0);
|
||||||
|
}
|
||||||
|
void add_peerValue(::flatbuffers::Offset<::flatbuffers::String> peerValue) {
|
||||||
|
fbb_.AddOffset(Refuse::VT_PEERVALUE, peerValue);
|
||||||
|
}
|
||||||
|
explicit RefuseBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<Refuse> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<Refuse>(end);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<Refuse> CreateRefuse(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
MobileGL::Wire::RefuseCode code = MobileGL::Wire::RefuseCode::None,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::String> detail = 0,
|
||||||
|
uint64_t expected = 0,
|
||||||
|
uint64_t actual = 0,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::String> peerValue = 0) {
|
||||||
|
RefuseBuilder builder_(_fbb);
|
||||||
|
builder_.add_actual(actual);
|
||||||
|
builder_.add_expected(expected);
|
||||||
|
builder_.add_peerValue(peerValue);
|
||||||
|
builder_.add_detail(detail);
|
||||||
|
builder_.add_code(code);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Refuse::Traits {
|
||||||
|
using type = Refuse;
|
||||||
|
static auto constexpr Create = CreateRefuse;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<Refuse> CreateRefuseDirect(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
MobileGL::Wire::RefuseCode code = MobileGL::Wire::RefuseCode::None,
|
||||||
|
const char *detail = nullptr,
|
||||||
|
uint64_t expected = 0,
|
||||||
|
uint64_t actual = 0,
|
||||||
|
const char *peerValue = nullptr) {
|
||||||
|
auto detail__ = detail ? _fbb.CreateString(detail) : 0;
|
||||||
|
auto peerValue__ = peerValue ? _fbb.CreateString(peerValue) : 0;
|
||||||
|
return MobileGL::Wire::CreateRefuse(
|
||||||
|
_fbb,
|
||||||
|
code,
|
||||||
|
detail__,
|
||||||
|
expected,
|
||||||
|
actual,
|
||||||
|
peerValue__);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LogFlush FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
typedef LogFlushBuilder Builder;
|
||||||
|
struct Traits;
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_SEQ = 4,
|
||||||
|
VT_ACK = 6
|
||||||
|
};
|
||||||
|
uint64_t seq() const {
|
||||||
|
return GetField<uint64_t>(VT_SEQ, 0);
|
||||||
|
}
|
||||||
|
bool ack() const {
|
||||||
|
return GetField<uint8_t>(VT_ACK, 0) != 0;
|
||||||
|
}
|
||||||
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyField<uint64_t>(verifier, VT_SEQ, 8) &&
|
||||||
|
VerifyField<uint8_t>(verifier, VT_ACK, 1) &&
|
||||||
|
verifier.EndTable();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LogFlushBuilder {
|
||||||
|
typedef LogFlush Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_seq(uint64_t seq) {
|
||||||
|
fbb_.AddElement<uint64_t>(LogFlush::VT_SEQ, seq, 0);
|
||||||
|
}
|
||||||
|
void add_ack(bool ack) {
|
||||||
|
fbb_.AddElement<uint8_t>(LogFlush::VT_ACK, static_cast<uint8_t>(ack), 0);
|
||||||
|
}
|
||||||
|
explicit LogFlushBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<LogFlush> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<LogFlush>(end);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<LogFlush> CreateLogFlush(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
uint64_t seq = 0,
|
||||||
|
bool ack = false) {
|
||||||
|
LogFlushBuilder builder_(_fbb);
|
||||||
|
builder_.add_seq(seq);
|
||||||
|
builder_.add_ack(ack);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LogFlush::Traits {
|
||||||
|
using type = LogFlush;
|
||||||
|
static auto constexpr Create = CreateLogFlush;
|
||||||
|
};
|
||||||
|
|
||||||
struct Hello FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct Hello FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
typedef HelloBuilder Builder;
|
typedef HelloBuilder Builder;
|
||||||
struct Traits;
|
struct Traits;
|
||||||
@@ -545,7 +976,11 @@ struct Hello FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
VT_BACKENDTYPE = 10,
|
VT_BACKENDTYPE = 10,
|
||||||
VT_PID = 12,
|
VT_PID = 12,
|
||||||
VT_CONFIGBLOB = 14,
|
VT_CONFIGBLOB = 14,
|
||||||
VT_ABIFINGERPRINT = 16
|
VT_ABIFINGERPRINT = 16,
|
||||||
|
VT_WIREFINGERPRINT = 18,
|
||||||
|
VT_LINKTERMS = 20,
|
||||||
|
VT_TOKEN = 22,
|
||||||
|
VT_DIALMODE = 24
|
||||||
};
|
};
|
||||||
uint32_t abiMajor() const {
|
uint32_t abiMajor() const {
|
||||||
return GetField<uint32_t>(VT_ABIMAJOR, 0);
|
return GetField<uint32_t>(VT_ABIMAJOR, 0);
|
||||||
@@ -568,6 +1003,18 @@ struct Hello FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
uint64_t abiFingerprint() const {
|
uint64_t abiFingerprint() const {
|
||||||
return GetField<uint64_t>(VT_ABIFINGERPRINT, 0);
|
return GetField<uint64_t>(VT_ABIFINGERPRINT, 0);
|
||||||
}
|
}
|
||||||
|
uint64_t wireFingerprint() const {
|
||||||
|
return GetField<uint64_t>(VT_WIREFINGERPRINT, 0);
|
||||||
|
}
|
||||||
|
const MobileGL::Wire::LinkTerms *linkTerms() const {
|
||||||
|
return GetPointer<const MobileGL::Wire::LinkTerms *>(VT_LINKTERMS);
|
||||||
|
}
|
||||||
|
const ::flatbuffers::String *token() const {
|
||||||
|
return GetPointer<const ::flatbuffers::String *>(VT_TOKEN);
|
||||||
|
}
|
||||||
|
MobileGL::Wire::DialMode dialMode() const {
|
||||||
|
return static_cast<MobileGL::Wire::DialMode>(GetField<uint8_t>(VT_DIALMODE, 0));
|
||||||
|
}
|
||||||
template <bool B = false>
|
template <bool B = false>
|
||||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
@@ -580,6 +1027,12 @@ struct Hello FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
VerifyOffset(verifier, VT_CONFIGBLOB) &&
|
VerifyOffset(verifier, VT_CONFIGBLOB) &&
|
||||||
verifier.VerifyVector(configBlob()) &&
|
verifier.VerifyVector(configBlob()) &&
|
||||||
VerifyField<uint64_t>(verifier, VT_ABIFINGERPRINT, 8) &&
|
VerifyField<uint64_t>(verifier, VT_ABIFINGERPRINT, 8) &&
|
||||||
|
VerifyField<uint64_t>(verifier, VT_WIREFINGERPRINT, 8) &&
|
||||||
|
VerifyOffset(verifier, VT_LINKTERMS) &&
|
||||||
|
verifier.VerifyTable(linkTerms()) &&
|
||||||
|
VerifyOffset(verifier, VT_TOKEN) &&
|
||||||
|
verifier.VerifyString(token()) &&
|
||||||
|
VerifyField<uint8_t>(verifier, VT_DIALMODE, 1) &&
|
||||||
verifier.EndTable();
|
verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -609,6 +1062,18 @@ struct HelloBuilder {
|
|||||||
void add_abiFingerprint(uint64_t abiFingerprint) {
|
void add_abiFingerprint(uint64_t abiFingerprint) {
|
||||||
fbb_.AddElement<uint64_t>(Hello::VT_ABIFINGERPRINT, abiFingerprint, 0);
|
fbb_.AddElement<uint64_t>(Hello::VT_ABIFINGERPRINT, abiFingerprint, 0);
|
||||||
}
|
}
|
||||||
|
void add_wireFingerprint(uint64_t wireFingerprint) {
|
||||||
|
fbb_.AddElement<uint64_t>(Hello::VT_WIREFINGERPRINT, wireFingerprint, 0);
|
||||||
|
}
|
||||||
|
void add_linkTerms(::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms) {
|
||||||
|
fbb_.AddOffset(Hello::VT_LINKTERMS, linkTerms);
|
||||||
|
}
|
||||||
|
void add_token(::flatbuffers::Offset<::flatbuffers::String> token) {
|
||||||
|
fbb_.AddOffset(Hello::VT_TOKEN, token);
|
||||||
|
}
|
||||||
|
void add_dialMode(MobileGL::Wire::DialMode dialMode) {
|
||||||
|
fbb_.AddElement<uint8_t>(Hello::VT_DIALMODE, static_cast<uint8_t>(dialMode), 0);
|
||||||
|
}
|
||||||
explicit HelloBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
explicit HelloBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
: fbb_(_fbb) {
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
@@ -628,15 +1093,23 @@ inline ::flatbuffers::Offset<Hello> CreateHello(
|
|||||||
uint32_t backendType = 0,
|
uint32_t backendType = 0,
|
||||||
uint32_t pid = 0,
|
uint32_t pid = 0,
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> configBlob = 0,
|
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> configBlob = 0,
|
||||||
uint64_t abiFingerprint = 0) {
|
uint64_t abiFingerprint = 0,
|
||||||
|
uint64_t wireFingerprint = 0,
|
||||||
|
::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms = 0,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::String> token = 0,
|
||||||
|
MobileGL::Wire::DialMode dialMode = MobileGL::Wire::DialMode::No) {
|
||||||
HelloBuilder builder_(_fbb);
|
HelloBuilder builder_(_fbb);
|
||||||
|
builder_.add_wireFingerprint(wireFingerprint);
|
||||||
builder_.add_abiFingerprint(abiFingerprint);
|
builder_.add_abiFingerprint(abiFingerprint);
|
||||||
|
builder_.add_token(token);
|
||||||
|
builder_.add_linkTerms(linkTerms);
|
||||||
builder_.add_configBlob(configBlob);
|
builder_.add_configBlob(configBlob);
|
||||||
builder_.add_pid(pid);
|
builder_.add_pid(pid);
|
||||||
builder_.add_backendType(backendType);
|
builder_.add_backendType(backendType);
|
||||||
builder_.add_buildFingerprint(buildFingerprint);
|
builder_.add_buildFingerprint(buildFingerprint);
|
||||||
builder_.add_abiMinor(abiMinor);
|
builder_.add_abiMinor(abiMinor);
|
||||||
builder_.add_abiMajor(abiMajor);
|
builder_.add_abiMajor(abiMajor);
|
||||||
|
builder_.add_dialMode(dialMode);
|
||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,9 +1126,14 @@ inline ::flatbuffers::Offset<Hello> CreateHelloDirect(
|
|||||||
uint32_t backendType = 0,
|
uint32_t backendType = 0,
|
||||||
uint32_t pid = 0,
|
uint32_t pid = 0,
|
||||||
const std::vector<uint8_t> *configBlob = nullptr,
|
const std::vector<uint8_t> *configBlob = nullptr,
|
||||||
uint64_t abiFingerprint = 0) {
|
uint64_t abiFingerprint = 0,
|
||||||
|
uint64_t wireFingerprint = 0,
|
||||||
|
::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms = 0,
|
||||||
|
const char *token = nullptr,
|
||||||
|
MobileGL::Wire::DialMode dialMode = MobileGL::Wire::DialMode::No) {
|
||||||
auto buildFingerprint__ = buildFingerprint ? _fbb.CreateString(buildFingerprint) : 0;
|
auto buildFingerprint__ = buildFingerprint ? _fbb.CreateString(buildFingerprint) : 0;
|
||||||
auto configBlob__ = configBlob ? _fbb.CreateVector<uint8_t>(*configBlob) : 0;
|
auto configBlob__ = configBlob ? _fbb.CreateVector<uint8_t>(*configBlob) : 0;
|
||||||
|
auto token__ = token ? _fbb.CreateString(token) : 0;
|
||||||
return MobileGL::Wire::CreateHello(
|
return MobileGL::Wire::CreateHello(
|
||||||
_fbb,
|
_fbb,
|
||||||
abiMajor,
|
abiMajor,
|
||||||
@@ -664,7 +1142,11 @@ inline ::flatbuffers::Offset<Hello> CreateHelloDirect(
|
|||||||
backendType,
|
backendType,
|
||||||
pid,
|
pid,
|
||||||
configBlob__,
|
configBlob__,
|
||||||
abiFingerprint);
|
abiFingerprint,
|
||||||
|
wireFingerprint,
|
||||||
|
linkTerms,
|
||||||
|
token__,
|
||||||
|
dialMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Welcome FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct Welcome FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
@@ -679,7 +1161,10 @@ struct Welcome FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
VT_REPLYPOOL = 14,
|
VT_REPLYPOOL = 14,
|
||||||
VT_EVENTRING = 16,
|
VT_EVENTRING = 16,
|
||||||
VT_BUILDFINGERPRINT = 18,
|
VT_BUILDFINGERPRINT = 18,
|
||||||
VT_ABIFINGERPRINT = 20
|
VT_ABIFINGERPRINT = 20,
|
||||||
|
VT_WIREFINGERPRINT = 22,
|
||||||
|
VT_LINKTERMS = 24,
|
||||||
|
VT_BACKENDTYPE = 26
|
||||||
};
|
};
|
||||||
uint32_t abiMajor() const {
|
uint32_t abiMajor() const {
|
||||||
return GetField<uint32_t>(VT_ABIMAJOR, 0);
|
return GetField<uint32_t>(VT_ABIMAJOR, 0);
|
||||||
@@ -708,6 +1193,15 @@ struct Welcome FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
uint64_t abiFingerprint() const {
|
uint64_t abiFingerprint() const {
|
||||||
return GetField<uint64_t>(VT_ABIFINGERPRINT, 0);
|
return GetField<uint64_t>(VT_ABIFINGERPRINT, 0);
|
||||||
}
|
}
|
||||||
|
uint64_t wireFingerprint() const {
|
||||||
|
return GetField<uint64_t>(VT_WIREFINGERPRINT, 0);
|
||||||
|
}
|
||||||
|
const MobileGL::Wire::LinkTerms *linkTerms() const {
|
||||||
|
return GetPointer<const MobileGL::Wire::LinkTerms *>(VT_LINKTERMS);
|
||||||
|
}
|
||||||
|
uint32_t backendType() const {
|
||||||
|
return GetField<uint32_t>(VT_BACKENDTYPE, 0);
|
||||||
|
}
|
||||||
template <bool B = false>
|
template <bool B = false>
|
||||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
@@ -725,6 +1219,10 @@ struct Welcome FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
VerifyOffset(verifier, VT_BUILDFINGERPRINT) &&
|
VerifyOffset(verifier, VT_BUILDFINGERPRINT) &&
|
||||||
verifier.VerifyString(buildFingerprint()) &&
|
verifier.VerifyString(buildFingerprint()) &&
|
||||||
VerifyField<uint64_t>(verifier, VT_ABIFINGERPRINT, 8) &&
|
VerifyField<uint64_t>(verifier, VT_ABIFINGERPRINT, 8) &&
|
||||||
|
VerifyField<uint64_t>(verifier, VT_WIREFINGERPRINT, 8) &&
|
||||||
|
VerifyOffset(verifier, VT_LINKTERMS) &&
|
||||||
|
verifier.VerifyTable(linkTerms()) &&
|
||||||
|
VerifyField<uint32_t>(verifier, VT_BACKENDTYPE, 4) &&
|
||||||
verifier.EndTable();
|
verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -760,6 +1258,15 @@ struct WelcomeBuilder {
|
|||||||
void add_abiFingerprint(uint64_t abiFingerprint) {
|
void add_abiFingerprint(uint64_t abiFingerprint) {
|
||||||
fbb_.AddElement<uint64_t>(Welcome::VT_ABIFINGERPRINT, abiFingerprint, 0);
|
fbb_.AddElement<uint64_t>(Welcome::VT_ABIFINGERPRINT, abiFingerprint, 0);
|
||||||
}
|
}
|
||||||
|
void add_wireFingerprint(uint64_t wireFingerprint) {
|
||||||
|
fbb_.AddElement<uint64_t>(Welcome::VT_WIREFINGERPRINT, wireFingerprint, 0);
|
||||||
|
}
|
||||||
|
void add_linkTerms(::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms) {
|
||||||
|
fbb_.AddOffset(Welcome::VT_LINKTERMS, linkTerms);
|
||||||
|
}
|
||||||
|
void add_backendType(uint32_t backendType) {
|
||||||
|
fbb_.AddElement<uint32_t>(Welcome::VT_BACKENDTYPE, backendType, 0);
|
||||||
|
}
|
||||||
explicit WelcomeBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
explicit WelcomeBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
: fbb_(_fbb) {
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
@@ -781,9 +1288,15 @@ inline ::flatbuffers::Offset<Welcome> CreateWelcome(
|
|||||||
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> replyPool = 0,
|
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> replyPool = 0,
|
||||||
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> eventRing = 0,
|
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> eventRing = 0,
|
||||||
::flatbuffers::Offset<::flatbuffers::String> buildFingerprint = 0,
|
::flatbuffers::Offset<::flatbuffers::String> buildFingerprint = 0,
|
||||||
uint64_t abiFingerprint = 0) {
|
uint64_t abiFingerprint = 0,
|
||||||
|
uint64_t wireFingerprint = 0,
|
||||||
|
::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms = 0,
|
||||||
|
uint32_t backendType = 0) {
|
||||||
WelcomeBuilder builder_(_fbb);
|
WelcomeBuilder builder_(_fbb);
|
||||||
|
builder_.add_wireFingerprint(wireFingerprint);
|
||||||
builder_.add_abiFingerprint(abiFingerprint);
|
builder_.add_abiFingerprint(abiFingerprint);
|
||||||
|
builder_.add_backendType(backendType);
|
||||||
|
builder_.add_linkTerms(linkTerms);
|
||||||
builder_.add_buildFingerprint(buildFingerprint);
|
builder_.add_buildFingerprint(buildFingerprint);
|
||||||
builder_.add_eventRing(eventRing);
|
builder_.add_eventRing(eventRing);
|
||||||
builder_.add_replyPool(replyPool);
|
builder_.add_replyPool(replyPool);
|
||||||
@@ -810,7 +1323,10 @@ inline ::flatbuffers::Offset<Welcome> CreateWelcomeDirect(
|
|||||||
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> replyPool = 0,
|
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> replyPool = 0,
|
||||||
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> eventRing = 0,
|
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> eventRing = 0,
|
||||||
const char *buildFingerprint = nullptr,
|
const char *buildFingerprint = nullptr,
|
||||||
uint64_t abiFingerprint = 0) {
|
uint64_t abiFingerprint = 0,
|
||||||
|
uint64_t wireFingerprint = 0,
|
||||||
|
::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms = 0,
|
||||||
|
uint32_t backendType = 0) {
|
||||||
auto buildFingerprint__ = buildFingerprint ? _fbb.CreateString(buildFingerprint) : 0;
|
auto buildFingerprint__ = buildFingerprint ? _fbb.CreateString(buildFingerprint) : 0;
|
||||||
return MobileGL::Wire::CreateWelcome(
|
return MobileGL::Wire::CreateWelcome(
|
||||||
_fbb,
|
_fbb,
|
||||||
@@ -822,7 +1338,10 @@ inline ::flatbuffers::Offset<Welcome> CreateWelcomeDirect(
|
|||||||
replyPool,
|
replyPool,
|
||||||
eventRing,
|
eventRing,
|
||||||
buildFingerprint__,
|
buildFingerprint__,
|
||||||
abiFingerprint);
|
abiFingerprint,
|
||||||
|
wireFingerprint,
|
||||||
|
linkTerms,
|
||||||
|
backendType);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CapsSnapshot FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct CapsSnapshot FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
@@ -1208,7 +1727,8 @@ struct SurfaceReply FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
VT_OK = 6,
|
VT_OK = 6,
|
||||||
VT_EGLMAJOR = 8,
|
VT_EGLMAJOR = 8,
|
||||||
VT_EGLMINOR = 10,
|
VT_EGLMINOR = 10,
|
||||||
VT_DEFAULTFB = 12
|
VT_DEFAULTFB = 12,
|
||||||
|
VT_EVENTHEAD = 14
|
||||||
};
|
};
|
||||||
uint64_t seq() const {
|
uint64_t seq() const {
|
||||||
return GetField<uint64_t>(VT_SEQ, 0);
|
return GetField<uint64_t>(VT_SEQ, 0);
|
||||||
@@ -1225,6 +1745,9 @@ struct SurfaceReply FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MobileGL::Wire::DefaultFramebufferInfo *defaultFb() const {
|
const MobileGL::Wire::DefaultFramebufferInfo *defaultFb() const {
|
||||||
return GetPointer<const MobileGL::Wire::DefaultFramebufferInfo *>(VT_DEFAULTFB);
|
return GetPointer<const MobileGL::Wire::DefaultFramebufferInfo *>(VT_DEFAULTFB);
|
||||||
}
|
}
|
||||||
|
uint64_t eventHead() const {
|
||||||
|
return GetField<uint64_t>(VT_EVENTHEAD, 0);
|
||||||
|
}
|
||||||
template <bool B = false>
|
template <bool B = false>
|
||||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
@@ -1234,6 +1757,7 @@ struct SurfaceReply FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
VerifyField<int32_t>(verifier, VT_EGLMINOR, 4) &&
|
VerifyField<int32_t>(verifier, VT_EGLMINOR, 4) &&
|
||||||
VerifyOffset(verifier, VT_DEFAULTFB) &&
|
VerifyOffset(verifier, VT_DEFAULTFB) &&
|
||||||
verifier.VerifyTable(defaultFb()) &&
|
verifier.VerifyTable(defaultFb()) &&
|
||||||
|
VerifyField<uint64_t>(verifier, VT_EVENTHEAD, 8) &&
|
||||||
verifier.EndTable();
|
verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1257,6 +1781,9 @@ struct SurfaceReplyBuilder {
|
|||||||
void add_defaultFb(::flatbuffers::Offset<MobileGL::Wire::DefaultFramebufferInfo> defaultFb) {
|
void add_defaultFb(::flatbuffers::Offset<MobileGL::Wire::DefaultFramebufferInfo> defaultFb) {
|
||||||
fbb_.AddOffset(SurfaceReply::VT_DEFAULTFB, defaultFb);
|
fbb_.AddOffset(SurfaceReply::VT_DEFAULTFB, defaultFb);
|
||||||
}
|
}
|
||||||
|
void add_eventHead(uint64_t eventHead) {
|
||||||
|
fbb_.AddElement<uint64_t>(SurfaceReply::VT_EVENTHEAD, eventHead, 0);
|
||||||
|
}
|
||||||
explicit SurfaceReplyBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
explicit SurfaceReplyBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
: fbb_(_fbb) {
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
@@ -1274,8 +1801,10 @@ inline ::flatbuffers::Offset<SurfaceReply> CreateSurfaceReply(
|
|||||||
bool ok = false,
|
bool ok = false,
|
||||||
int32_t eglMajor = 0,
|
int32_t eglMajor = 0,
|
||||||
int32_t eglMinor = 0,
|
int32_t eglMinor = 0,
|
||||||
::flatbuffers::Offset<MobileGL::Wire::DefaultFramebufferInfo> defaultFb = 0) {
|
::flatbuffers::Offset<MobileGL::Wire::DefaultFramebufferInfo> defaultFb = 0,
|
||||||
|
uint64_t eventHead = 0) {
|
||||||
SurfaceReplyBuilder builder_(_fbb);
|
SurfaceReplyBuilder builder_(_fbb);
|
||||||
|
builder_.add_eventHead(eventHead);
|
||||||
builder_.add_seq(seq);
|
builder_.add_seq(seq);
|
||||||
builder_.add_defaultFb(defaultFb);
|
builder_.add_defaultFb(defaultFb);
|
||||||
builder_.add_eglMinor(eglMinor);
|
builder_.add_eglMinor(eglMinor);
|
||||||
@@ -1460,7 +1989,8 @@ struct Fatal FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
struct Traits;
|
struct Traits;
|
||||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
VT_CODE = 4,
|
VT_CODE = 4,
|
||||||
VT_MESSAGE = 6
|
VT_MESSAGE = 6,
|
||||||
|
VT_FAMILY = 8
|
||||||
};
|
};
|
||||||
MobileGL::Wire::FatalCode code() const {
|
MobileGL::Wire::FatalCode code() const {
|
||||||
return static_cast<MobileGL::Wire::FatalCode>(GetField<uint32_t>(VT_CODE, 0));
|
return static_cast<MobileGL::Wire::FatalCode>(GetField<uint32_t>(VT_CODE, 0));
|
||||||
@@ -1468,12 +1998,17 @@ struct Fatal FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::String *message() const {
|
const ::flatbuffers::String *message() const {
|
||||||
return GetPointer<const ::flatbuffers::String *>(VT_MESSAGE);
|
return GetPointer<const ::flatbuffers::String *>(VT_MESSAGE);
|
||||||
}
|
}
|
||||||
|
const ::flatbuffers::String *family() const {
|
||||||
|
return GetPointer<const ::flatbuffers::String *>(VT_FAMILY);
|
||||||
|
}
|
||||||
template <bool B = false>
|
template <bool B = false>
|
||||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
VerifyField<uint32_t>(verifier, VT_CODE, 4) &&
|
VerifyField<uint32_t>(verifier, VT_CODE, 4) &&
|
||||||
VerifyOffset(verifier, VT_MESSAGE) &&
|
VerifyOffset(verifier, VT_MESSAGE) &&
|
||||||
verifier.VerifyString(message()) &&
|
verifier.VerifyString(message()) &&
|
||||||
|
VerifyOffset(verifier, VT_FAMILY) &&
|
||||||
|
verifier.VerifyString(family()) &&
|
||||||
verifier.EndTable();
|
verifier.EndTable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1488,6 +2023,9 @@ struct FatalBuilder {
|
|||||||
void add_message(::flatbuffers::Offset<::flatbuffers::String> message) {
|
void add_message(::flatbuffers::Offset<::flatbuffers::String> message) {
|
||||||
fbb_.AddOffset(Fatal::VT_MESSAGE, message);
|
fbb_.AddOffset(Fatal::VT_MESSAGE, message);
|
||||||
}
|
}
|
||||||
|
void add_family(::flatbuffers::Offset<::flatbuffers::String> family) {
|
||||||
|
fbb_.AddOffset(Fatal::VT_FAMILY, family);
|
||||||
|
}
|
||||||
explicit FatalBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
explicit FatalBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
: fbb_(_fbb) {
|
: fbb_(_fbb) {
|
||||||
start_ = fbb_.StartTable();
|
start_ = fbb_.StartTable();
|
||||||
@@ -1502,8 +2040,10 @@ struct FatalBuilder {
|
|||||||
inline ::flatbuffers::Offset<Fatal> CreateFatal(
|
inline ::flatbuffers::Offset<Fatal> CreateFatal(
|
||||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
MobileGL::Wire::FatalCode code = MobileGL::Wire::FatalCode::None,
|
MobileGL::Wire::FatalCode code = MobileGL::Wire::FatalCode::None,
|
||||||
::flatbuffers::Offset<::flatbuffers::String> message = 0) {
|
::flatbuffers::Offset<::flatbuffers::String> message = 0,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::String> family = 0) {
|
||||||
FatalBuilder builder_(_fbb);
|
FatalBuilder builder_(_fbb);
|
||||||
|
builder_.add_family(family);
|
||||||
builder_.add_message(message);
|
builder_.add_message(message);
|
||||||
builder_.add_code(code);
|
builder_.add_code(code);
|
||||||
return builder_.Finish();
|
return builder_.Finish();
|
||||||
@@ -1517,12 +2057,15 @@ struct Fatal::Traits {
|
|||||||
inline ::flatbuffers::Offset<Fatal> CreateFatalDirect(
|
inline ::flatbuffers::Offset<Fatal> CreateFatalDirect(
|
||||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
MobileGL::Wire::FatalCode code = MobileGL::Wire::FatalCode::None,
|
MobileGL::Wire::FatalCode code = MobileGL::Wire::FatalCode::None,
|
||||||
const char *message = nullptr) {
|
const char *message = nullptr,
|
||||||
|
const char *family = nullptr) {
|
||||||
auto message__ = message ? _fbb.CreateString(message) : 0;
|
auto message__ = message ? _fbb.CreateString(message) : 0;
|
||||||
|
auto family__ = family ? _fbb.CreateString(family) : 0;
|
||||||
return MobileGL::Wire::CreateFatal(
|
return MobileGL::Wire::CreateFatal(
|
||||||
_fbb,
|
_fbb,
|
||||||
code,
|
code,
|
||||||
message__);
|
message__,
|
||||||
|
family__);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LogLine FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct LogLine FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
@@ -1639,6 +2182,12 @@ struct CtrlEnvelope FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const MobileGL::Wire::LogLine *msg_as_LogLine() const {
|
const MobileGL::Wire::LogLine *msg_as_LogLine() const {
|
||||||
return msg_type() == MobileGL::Wire::CtrlMsg::LogLine ? static_cast<const MobileGL::Wire::LogLine *>(msg()) : nullptr;
|
return msg_type() == MobileGL::Wire::CtrlMsg::LogLine ? static_cast<const MobileGL::Wire::LogLine *>(msg()) : nullptr;
|
||||||
}
|
}
|
||||||
|
const MobileGL::Wire::Refuse *msg_as_Refuse() const {
|
||||||
|
return msg_type() == MobileGL::Wire::CtrlMsg::Refuse ? static_cast<const MobileGL::Wire::Refuse *>(msg()) : nullptr;
|
||||||
|
}
|
||||||
|
const MobileGL::Wire::LogFlush *msg_as_LogFlush() const {
|
||||||
|
return msg_type() == MobileGL::Wire::CtrlMsg::LogFlush ? static_cast<const MobileGL::Wire::LogFlush *>(msg()) : nullptr;
|
||||||
|
}
|
||||||
template <bool B = false>
|
template <bool B = false>
|
||||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
return VerifyTableStart(verifier) &&
|
return VerifyTableStart(verifier) &&
|
||||||
@@ -1689,6 +2238,14 @@ template<> inline const MobileGL::Wire::LogLine *CtrlEnvelope::msg_as<MobileGL::
|
|||||||
return msg_as_LogLine();
|
return msg_as_LogLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> inline const MobileGL::Wire::Refuse *CtrlEnvelope::msg_as<MobileGL::Wire::Refuse>() const {
|
||||||
|
return msg_as_Refuse();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> inline const MobileGL::Wire::LogFlush *CtrlEnvelope::msg_as<MobileGL::Wire::LogFlush>() const {
|
||||||
|
return msg_as_LogFlush();
|
||||||
|
}
|
||||||
|
|
||||||
struct CtrlEnvelopeBuilder {
|
struct CtrlEnvelopeBuilder {
|
||||||
typedef CtrlEnvelope Table;
|
typedef CtrlEnvelope Table;
|
||||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
@@ -1771,6 +2328,14 @@ inline bool VerifyCtrlMsg(::flatbuffers::VerifierTemplate<B> &verifier, const vo
|
|||||||
auto ptr = reinterpret_cast<const MobileGL::Wire::LogLine *>(obj);
|
auto ptr = reinterpret_cast<const MobileGL::Wire::LogLine *>(obj);
|
||||||
return verifier.VerifyTable(ptr);
|
return verifier.VerifyTable(ptr);
|
||||||
}
|
}
|
||||||
|
case CtrlMsg::Refuse: {
|
||||||
|
auto ptr = reinterpret_cast<const MobileGL::Wire::Refuse *>(obj);
|
||||||
|
return verifier.VerifyTable(ptr);
|
||||||
|
}
|
||||||
|
case CtrlMsg::LogFlush: {
|
||||||
|
auto ptr = reinterpret_cast<const MobileGL::Wire::LogFlush *>(obj);
|
||||||
|
return verifier.VerifyTable(ptr);
|
||||||
|
}
|
||||||
default: return true;
|
default: return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,47 @@ table SegmentRef {
|
|||||||
// Handshake
|
// Handshake
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// P6.5: independent control and data-plane choices. Values are append-only.
|
||||||
|
enum DataPlane : ubyte { SharedSegments = 0, Stream = 1 }
|
||||||
|
enum WireForm : ubyte { StructImage = 0 }
|
||||||
|
enum DialMode : ubyte { No = 0, Fork = 1, Connect = 2 }
|
||||||
|
|
||||||
|
// Window sizes are stated by the server; the client's values are proposals only.
|
||||||
|
table LinkTerms {
|
||||||
|
dataPlane: DataPlane;
|
||||||
|
wireForm: WireForm;
|
||||||
|
maxReplyBytes: ulong;
|
||||||
|
cmdWindowBytes: ulong;
|
||||||
|
stageWindowBytes: ulong;
|
||||||
|
eventWindowBytes: ulong;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum RefuseCode : uint {
|
||||||
|
None = 0,
|
||||||
|
ProtocolVersion = 1,
|
||||||
|
WireFingerprint = 2,
|
||||||
|
BuildFingerprint = 3,
|
||||||
|
Authentication = 4,
|
||||||
|
LinkTerms = 5,
|
||||||
|
Backend = 6,
|
||||||
|
Busy = 7,
|
||||||
|
MalformedHello = 8,
|
||||||
|
}
|
||||||
|
|
||||||
|
// A handshake rejection is a normal session outcome, never a process abort.
|
||||||
|
table Refuse {
|
||||||
|
code: RefuseCode;
|
||||||
|
detail: string;
|
||||||
|
expected: ulong;
|
||||||
|
actual: ulong;
|
||||||
|
peerValue: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
table LogFlush {
|
||||||
|
seq: ulong;
|
||||||
|
ack: bool;
|
||||||
|
}
|
||||||
|
|
||||||
table Hello {
|
table Hello {
|
||||||
abiMajor: uint;
|
abiMajor: uint;
|
||||||
abiMinor: uint;
|
abiMinor: uint;
|
||||||
@@ -63,15 +104,12 @@ table Hello {
|
|||||||
backendType: uint;
|
backendType: uint;
|
||||||
pid: uint;
|
pid: uint;
|
||||||
configBlob: [ubyte];
|
configBlob: [ubyte];
|
||||||
// CONTRACT-P5 table 0, "ABI agreement": MGPCaps has only a COMPOSITIONAL size
|
// Retained legacy slot. P6.5 peers compare wireFingerprint instead.
|
||||||
// assertion, because DynamicBackendParameters still carries SizeT and GLenum.
|
|
||||||
// So the two peers assert they were built from the same struct shapes instead
|
|
||||||
// of rewriting them fixed-width (that is P7's account). This is
|
|
||||||
// MG_Remote::CapsAbiFingerprint(): sizeof(DynamicBackendParameters),
|
|
||||||
// sizeof(MGPCaps), sizeof(GLFunctionsTable), the protocol ABI version and the
|
|
||||||
// build's git stamp, mixed. A mismatch is Fatal{AbiMismatch} and NEVER a
|
|
||||||
// downgrade - every alternative silently reads one struct as another.
|
|
||||||
abiFingerprint: ulong;
|
abiFingerprint: ulong;
|
||||||
|
wireFingerprint: ulong;
|
||||||
|
linkTerms: LinkTerms;
|
||||||
|
token: string;
|
||||||
|
dialMode: DialMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
table Welcome {
|
table Welcome {
|
||||||
@@ -82,12 +120,12 @@ table Welcome {
|
|||||||
stageRing: SegmentRef;
|
stageRing: SegmentRef;
|
||||||
replyPool: SegmentRef;
|
replyPool: SegmentRef;
|
||||||
eventRing: SegmentRef;
|
eventRing: SegmentRef;
|
||||||
// The server's half of the assertion above. The string is carried beside the
|
|
||||||
// mixed value only so a mismatch can name both builds in the Fatal line; the
|
|
||||||
// COMPARISON is on abiFingerprint, which also covers the three sizeofs the
|
|
||||||
// string cannot.
|
|
||||||
buildFingerprint: string;
|
buildFingerprint: string;
|
||||||
|
// Retained legacy slot; do not reuse or renumber it.
|
||||||
abiFingerprint: ulong;
|
abiFingerprint: ulong;
|
||||||
|
wireFingerprint: ulong;
|
||||||
|
linkTerms: LinkTerms;
|
||||||
|
backendType: uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -176,6 +214,12 @@ enum SurfaceOpKind : ubyte {
|
|||||||
SetSwapInterval = 8,
|
SetSwapInterval = 8,
|
||||||
ReleaseResources = 9,
|
ReleaseResources = 9,
|
||||||
SetWindowHandle = 10,
|
SetWindowHandle = 10,
|
||||||
|
// P6 (package cp) appended this one. The draft held that InitCapabilities needs
|
||||||
|
// no wire form because "the CapsSnapshot answers it" - but a CapsSnapshot is the
|
||||||
|
// ANSWER and this is the REQUEST, and a spawn client has a live caller for it
|
||||||
|
// (Client/BackendObject_Remote.cpp). Without the tag the codec refused it by
|
||||||
|
// name and every spawned eglMakeCurrent failed with InprocOnlyOpOnTheWire.
|
||||||
|
InitCapabilities = 11,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum WindowKind : ubyte {
|
enum WindowKind : ubyte {
|
||||||
@@ -215,6 +259,8 @@ table SurfaceReply {
|
|||||||
eglMajor: int;
|
eglMajor: int;
|
||||||
eglMinor: int;
|
eglMinor: int;
|
||||||
defaultFb: DefaultFramebufferInfo;
|
defaultFb: DefaultFramebufferInfo;
|
||||||
|
// P6.5: all preceding data-plane events must arrive before this reply is observed.
|
||||||
|
eventHead: ulong;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -258,6 +304,11 @@ enum FatalCode : uint {
|
|||||||
table Fatal {
|
table Fatal {
|
||||||
code: FatalCode;
|
code: FatalCode;
|
||||||
message: string;
|
message: string;
|
||||||
|
// P6 dl (CONTRACT-P6 5.2, D2). The internal MGFatalFamily word, so a peer that receives this
|
||||||
|
// frame before the sender aborts can name WHICH family ended the session instead of reading a
|
||||||
|
// bare EOF. `code` stays the coarse seven-value projection; this carries the full vocabulary.
|
||||||
|
// Append-only: an older peer that does not read it still gets `code` and `message`.
|
||||||
|
family: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Severity-graded per plan B section 8.2: <= Warn is lossy, >= Error is
|
// Severity-graded per plan B section 8.2: <= Warn is lossy, >= Error is
|
||||||
@@ -295,6 +346,8 @@ union CtrlMsg {
|
|||||||
AuxRequest,
|
AuxRequest,
|
||||||
Fatal,
|
Fatal,
|
||||||
LogLine,
|
LogLine,
|
||||||
|
Refuse,
|
||||||
|
LogFlush,
|
||||||
}
|
}
|
||||||
|
|
||||||
table CtrlEnvelope {
|
table CtrlEnvelope {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
// P5 package v1: the applier bridge, and the consumer for contract 7's five class-B verbs.
|
// P5 package v1: the applier bridge, and the consumer for contract 7's five class-B verbs.
|
||||||
|
|
||||||
#include "PipeApplier.h"
|
#include "PipeApplier.h"
|
||||||
|
#include <MG_Remote/FatalFunnel.h>
|
||||||
|
|
||||||
#include "ServerSession.h"
|
#include "ServerSession.h"
|
||||||
#include "../Transport/ReplySlot.h"
|
#include "../Transport/ReplySlot.h"
|
||||||
@@ -61,6 +62,12 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// The view is rebuilt per call rather than stored, so that this body does not change
|
// The view is rebuilt per call rather than stored, so that this body does not change
|
||||||
// ReplyPool's four members and therefore does not touch v1's header at all.
|
// ReplyPool's four members and therefore does not touch v1's header at all.
|
||||||
void ReplyPool::PostReply(Uint64 seq, Int32 status, const void* bytes, Uint64 size) {
|
void ReplyPool::PostReply(Uint64 seq, Int32 status, const void* bytes, Uint64 size) {
|
||||||
|
if (m_link) {
|
||||||
|
const auto result = m_link->PostReply(seq, status, bytes, size);
|
||||||
|
if (result == MOBILEGL_ERR_BUFFER_TOO_SMALL)
|
||||||
|
SessionFail(MGFatalFamily::ReplyTooLarge, "MGPipe: Fatal{ReplyTooLarge, stream reply}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Transport::ReplySlotPool pool(m_base, m_size, m_slots);
|
Transport::ReplySlotPool pool(m_base, m_size, m_slots);
|
||||||
// Fatal inside Post when the answer does not fit a slot: P5 does not chunk replies,
|
// Fatal inside Post when the answer does not fit a slot: P5 does not chunk replies,
|
||||||
// and the client knows an answer's size before it emits the record.
|
// and the client knows an answer's size before it emits the record.
|
||||||
@@ -326,11 +333,10 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// is a protocol fault, because such a client is pacing on this answer and a 0 would
|
// is a protocol fault, because such a client is pacing on this answer and a 0 would
|
||||||
// acknowledge a frame nobody asked about.
|
// acknowledge a frame nobody asked about.
|
||||||
if (present.FrameSerial == 0 && MGPipeServerPublishesRunAhead()) {
|
if (present.FrameSerial == 0 && MGPipeServerPublishesRunAhead()) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"Present.FrameSerial\"} - a run-ahead "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"Present.FrameSerial\"} - a run-ahead "
|
||||||
"server was handed present serial 0. The client mints this 1-based and "
|
"server was handed present serial 0. The client mints this 1-based and "
|
||||||
"waits on it for its credit (CONTRACT-P5E §2.4); returning a credit for "
|
"waits on it for its credit (CONTRACT-P5E §2.4); returning a credit for "
|
||||||
"serial 0 would release a wait that is asking about frame N");
|
"serial 0 would release a wait that is asking about frame N");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
m_lastPresentSerial = present.FrameSerial != 0 ? present.FrameSerial : m_presents;
|
m_lastPresentSerial = present.FrameSerial != 0 ? present.FrameSerial : m_presents;
|
||||||
// §2.4's other half, and the reason ServerSession::ReturnPresentCredit has had no
|
// §2.4's other half, and the reason ServerSession::ReturnPresentCredit has had no
|
||||||
@@ -385,11 +391,10 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// The decoder always passes its ReplySink; a null one means the applier was built
|
// The decoder always passes its ReplySink; a null one means the applier was built
|
||||||
// without a reply pool, and answering nothing would leave the client's barrier
|
// without a reply pool, and answering nothing would leave the client's barrier
|
||||||
// waiting for a slot that never gets stamped - a hang, not a wrong picture.
|
// waiting for a slot that never gets stamped - a hang, not a wrong picture.
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"read_pixels without a reply sink\"} - "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"read_pixels without a reply sink\"} - "
|
||||||
"the pixels' only destination in P5 is SEG_REPLY (contract table 1 row 23) "
|
"the pixels' only destination in P5 is SEG_REPLY (contract table 1 row 23) "
|
||||||
"and a client blocked on seq %llu would never be answered",
|
"and a client blocked on seq %llu would never be answered",
|
||||||
static_cast<unsigned long long>(seq));
|
static_cast<unsigned long long>(seq));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
const MG_Backend::GlobalBackendFunctionsTable* table = Table("read_pixels");
|
const MG_Backend::GlobalBackendFunctionsTable* table = Table("read_pixels");
|
||||||
if (table == nullptr || table->GL.ReadPixels == nullptr) {
|
if (table == nullptr || table->GL.ReadPixels == nullptr) {
|
||||||
@@ -482,10 +487,9 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// rather than rendering nothing. Named "(server sink)" in the message so a log reader can
|
// rather than rendering nothing. Named "(server sink)" in the message so a log reader can
|
||||||
// tell which half is missing.
|
// tell which half is missing.
|
||||||
[[noreturn]] static void ServerUnmigratedVerbFatal(const char* slot) {
|
[[noreturn]] static void ServerUnmigratedVerbFatal(const char* slot) {
|
||||||
MGLOG_F("MGPipe: Fatal{UnmigratedVerb, \"%s\"} (server sink: the record crossed and "
|
SessionFail(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)",
|
"ServerVerbSink has no body for it yet - CONTRACT-P5B.md names the package)",
|
||||||
slot);
|
slot);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// P5b d1 (MG_Remote/CONTRACT-P5B.md §2 d1): draw_vbo's whole cross product. The record
|
// P5b d1 (MG_Remote/CONTRACT-P5B.md §2 d1): draw_vbo's whole cross product. The record
|
||||||
@@ -553,22 +557,20 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
if (maxTouched < 0) return;
|
if (maxTouched < 0) return;
|
||||||
const Uint32 required = static_cast<Uint32>(maxTouched) + 1u;
|
const Uint32 required = static_cast<Uint32>(maxTouched) + 1u;
|
||||||
if (st.SamplerViewStart != 0 || st.SamplerViewCount < required) {
|
if (st.SamplerViewStart != 0 || st.SamplerViewCount < required) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"SetSamplerViews.Count\"} - %s applies with "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"SetSamplerViews.Count\"} - %s applies with "
|
||||||
"units 0..%d touched, so set_sampler_views must carry Start=0 and Count >= %u "
|
"units 0..%d touched, so set_sampler_views must carry Start=0 and Count >= %u "
|
||||||
"(CONTRACT-P5E.md §5.3); the applied window is Start=%u Count=%u, which drops "
|
"(CONTRACT-P5E.md §5.3); the applied window is Start=%u Count=%u, which drops "
|
||||||
"the sync of at least one texture this draw samples",
|
"the sync of at least one texture this draw samples",
|
||||||
verb, static_cast<int>(maxTouched), required, st.SamplerViewStart,
|
verb, static_cast<int>(maxTouched), required, st.SamplerViewStart,
|
||||||
st.SamplerViewCount);
|
st.SamplerViewCount);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (st.SamplerStateStart != 0 || st.SamplerStateCount < required) {
|
if (st.SamplerStateStart != 0 || st.SamplerStateCount < required) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"BindSamplerStates.Count\"} - %s applies with "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"BindSamplerStates.Count\"} - %s applies with "
|
||||||
"units 0..%d touched, so bind_sampler_states must carry Start=0 and Count >= %u "
|
"units 0..%d touched, so bind_sampler_states must carry Start=0 and Count >= %u "
|
||||||
"(CONTRACT-P5E.md §5.3); the applied window is Start=%u Count=%u, which leaves "
|
"(CONTRACT-P5E.md §5.3); the applied window is Start=%u Count=%u, which leaves "
|
||||||
"an earlier draw's sampler object on at least one unit",
|
"an earlier draw's sampler object on at least one unit",
|
||||||
verb, static_cast<int>(maxTouched), required, st.SamplerStateStart,
|
verb, static_cast<int>(maxTouched), required, st.SamplerStateStart,
|
||||||
st.SamplerStateCount);
|
st.SamplerStateCount);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -1147,13 +1149,12 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// accepted resets IS the expected value; anything else means the two ends disagree
|
// accepted resets IS the expected value; anything else means the two ends disagree
|
||||||
// about how many make-current edges have crossed, which no backend answer can fix.
|
// about how many make-current edges have crossed, which no backend answer can fix.
|
||||||
if (reset.ContextSerial != m_applierResetSerial) {
|
if (reset.ContextSerial != m_applierResetSerial) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"ApplierReset.ContextSerial\"} - the "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"ApplierReset.ContextSerial\"} - the "
|
||||||
"record carries %llu and this session has accepted %llu reset(s); the "
|
"record carries %llu and this session has accepted %llu reset(s); the "
|
||||||
"serial is asserted against the session's own count, not dispatched on "
|
"serial is asserted against the session's own count, not dispatched on "
|
||||||
"(one context per session in P5c)",
|
"(one context per session in P5c)",
|
||||||
static_cast<unsigned long long>(reset.ContextSerial),
|
static_cast<unsigned long long>(reset.ContextSerial),
|
||||||
static_cast<unsigned long long>(m_applierResetSerial));
|
static_cast<unsigned long long>(m_applierResetSerial));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
++m_applierResetSerial;
|
++m_applierResetSerial;
|
||||||
// THE WHOLE POINT OF THE RECORD: the reset runs HERE, on the apply thread, against
|
// THE WHOLE POINT OF THE RECORD: the reset runs HERE, on the apply thread, against
|
||||||
@@ -1170,16 +1171,14 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// emits NOTHING in that case (§5.2) - so a null handle arriving here is corruption,
|
// emits NOTHING in that case (§5.2) - so a null handle arriving here is corruption,
|
||||||
// not a no-op.
|
// not a no-op.
|
||||||
if (MG_Pipe::MGPipeHandleIsNull(death.Handle)) {
|
if (MG_Pipe::MGPipeHandleIsNull(death.Handle)) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"ObjectDeath.Handle\"} - a null "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"ObjectDeath.Handle\"} - a null "
|
||||||
"handle never crosses: the client emits nothing for an object its own "
|
"handle never crosses: the client emits nothing for an object its own "
|
||||||
"allocator cannot resolve (CONTRACT-P5C.md §5.2)");
|
"allocator cannot resolve (CONTRACT-P5C.md §5.2)");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (death.Kind >= static_cast<Uint32>(MG_Pipe::MGPipeKind::KindCount)) {
|
if (death.Kind >= static_cast<Uint32>(MG_Pipe::MGPipeKind::KindCount)) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"ObjectDeath.Kind\"} - %u is not an "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"ObjectDeath.Kind\"} - %u is not an "
|
||||||
"MGPipeKind",
|
"MGPipeKind",
|
||||||
static_cast<unsigned>(death.Kind));
|
static_cast<unsigned>(death.Kind));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
// The per-kind release, keyed by the handle the record carried. A false answer is
|
// The per-kind release, keyed by the handle the record carried. A false answer is
|
||||||
// NOT a decline: the kind's own delete opcode may already have released the twin
|
// NOT a decline: the kind's own delete opcode may already have released the twin
|
||||||
@@ -1199,12 +1198,20 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
PipeApplier::PipeApplier(Wire::SegmentTable* segments, ReplyPool* replies)
|
PipeApplier::PipeApplier(Wire::SegmentTable* segments, ReplyPool* replies)
|
||||||
: m_segments(segments), m_replies(replies) {}
|
: m_segments(segments), m_replies(replies) {}
|
||||||
|
|
||||||
|
void PipeApplier::Attach(Transport::ILink* link, MG_Backend::BackendObject* backend) {
|
||||||
|
if (!link || !link->Attached() || !m_segments)
|
||||||
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, PipeApplier::Attach missing link}");
|
||||||
|
m_verbs.SetBackend(backend);
|
||||||
|
m_decoder = Wire::PipeWireDecoder(link, m_segments, m_replies);
|
||||||
|
m_decoder.SetVerbSink(&m_verbs);
|
||||||
|
MG_Pipe::MGPipeServerBlockNoteIdentity(); m_attached = true;
|
||||||
|
}
|
||||||
|
|
||||||
void PipeApplier::Attach(Transport::RingControl* control, MG_Backend::BackendObject* backend) {
|
void PipeApplier::Attach(Transport::RingControl* control, MG_Backend::BackendObject* backend) {
|
||||||
if (control == nullptr || m_segments == nullptr) {
|
if (control == nullptr || m_segments == nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"PipeApplier::Attach\"} - no control "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"PipeApplier::Attach\"} - no control "
|
||||||
"page or no segment table; ServerSession::Accept builds both before the "
|
"page or no segment table; ServerSession::Accept builds both before the "
|
||||||
"apply thread starts");
|
"apply thread starts");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
m_verbs.SetBackend(backend);
|
m_verbs.SetBackend(backend);
|
||||||
m_decoder = Wire::PipeWireDecoder(control, m_segments, m_replies);
|
m_decoder = Wire::PipeWireDecoder(control, m_segments, m_replies);
|
||||||
@@ -1228,10 +1235,9 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
|
|
||||||
Bool PipeApplier::ApplyOne(const Transport::RingRecordView& record) {
|
Bool PipeApplier::ApplyOne(const Transport::RingRecordView& record) {
|
||||||
if (!m_attached) {
|
if (!m_attached) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"PipeApplier::ApplyOne before Attach\"} "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"PipeApplier::ApplyOne before Attach\"} "
|
||||||
"- a record reached the applier with no decoder; the apply thread calls "
|
"- a record reached the applier with no decoder; the apply thread calls "
|
||||||
"Attach once before its first pop");
|
"Attach once before its first pop");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
// R-1's INVARIANT, THE SERVER'S HALF (table 3's gPipeInputs row, c1-v1 8.1). The flag
|
// R-1's INVARIANT, THE SERVER'S HALF (table 3's gPipeInputs row, c1-v1 8.1). The flag
|
||||||
// is raised for the WHOLE of this function and not only around DecodeAndApply: the
|
// is raised for the WHOLE of this function and not only around DecodeAndApply: the
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
ReplyPool() = default;
|
ReplyPool() = default;
|
||||||
ReplyPool(void* base, Uint64 sizeBytes, Uint32 slotCount, Uint32 slotBytes);
|
ReplyPool(void* base, Uint64 sizeBytes, Uint32 slotCount, Uint32 slotBytes);
|
||||||
|
|
||||||
|
void SetLink(Transport::ILink* link) { m_link = link; }
|
||||||
void PostReply(Uint64 seq, Int32 status, const void* bytes, Uint64 size) override;
|
void PostReply(Uint64 seq, Int32 status, const void* bytes, Uint64 size) override;
|
||||||
|
|
||||||
// A reply larger than one slot is Fatal rather than chunked: P5's only large answer is
|
// A reply larger than one slot is Fatal rather than chunked: P5's only large answer is
|
||||||
@@ -97,6 +98,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
Uint32 SlotBytes() const;
|
Uint32 SlotBytes() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Transport::ILink* m_link = nullptr;
|
||||||
Uint8* m_base = nullptr;
|
Uint8* m_base = nullptr;
|
||||||
Uint64 m_size = 0;
|
Uint64 m_size = 0;
|
||||||
Uint32 m_slots = 0;
|
Uint32 m_slots = 0;
|
||||||
@@ -350,6 +352,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// CALLED ON THE APPLY THREAD, ONCE, BEFORE THE FIRST RECORD. PipeWireDecoder is "not
|
// CALLED ON THE APPLY THREAD, ONCE, BEFORE THE FIRST RECORD. PipeWireDecoder is "not
|
||||||
// thread safe: one decoder on the apply thread, by construction", and its constructor
|
// thread safe: one decoder on the apply thread, by construction", and its constructor
|
||||||
// installs the process-wide apply hook.
|
// installs the process-wide apply hook.
|
||||||
|
void Attach(Transport::ILink* link, MG_Backend::BackendObject* backend);
|
||||||
void Attach(Transport::RingControl* control, MG_Backend::BackendObject* backend);
|
void Attach(Transport::RingControl* control, MG_Backend::BackendObject* backend);
|
||||||
void Detach();
|
void Detach();
|
||||||
Bool Attached() const;
|
Bool Attached() const;
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Remote/Server/ServerEntry.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
|
||||||
|
|
||||||
|
// The server image's main(). Package `sm`.
|
||||||
|
//
|
||||||
|
// Deliberately the smallest thing that can be one: everything it could do
|
||||||
|
// belongs to mobilegl_server_main, which lives IN THE LIBRARY so that one
|
||||||
|
// shared library serves both roles (ARCHITECTURE.md:496). Keeping this file
|
||||||
|
// empty of logic is what stops the server growing a second, divergent copy of
|
||||||
|
// bring-up that the client half never executes.
|
||||||
|
|
||||||
|
extern "C" int mobilegl_server_main(int argc, char** argv);
|
||||||
|
|
||||||
|
int main(int argc, char** argv) { return mobilegl_server_main(argc, argv); }
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
// P5 package v1: the apply thread, its affinity, its parking, and the EGL ownership move.
|
// P5 package v1: the apply thread, its affinity, its parking, and the EGL ownership move.
|
||||||
|
|
||||||
#include "ServerLoop.h"
|
#include "ServerLoop.h"
|
||||||
|
#include <MG_Remote/FatalFunnel.h>
|
||||||
#include <MG_Backend/MGPipe/PipeInputs.h>
|
#include <MG_Backend/MGPipe/PipeInputs.h>
|
||||||
|
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
@@ -343,6 +344,10 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// declaration: it is an identity, not a handshake, and this thread is the only writer.
|
// declaration: it is an identity, not a handshake, and this thread is the only writer.
|
||||||
Detail::g_applyThreadKey.store(Detail::CurrentThreadKey(), std::memory_order_relaxed);
|
Detail::g_applyThreadKey.store(Detail::CurrentThreadKey(), std::memory_order_relaxed);
|
||||||
NameThisThread("mgl-srv-apply");
|
NameThisThread("mgl-srv-apply");
|
||||||
|
// P6: THIS THREAD IS THE SERVER, and saying so is what sends its lines to the server's
|
||||||
|
// own log. Under spawn the process role already answers this; under INPROC it is the
|
||||||
|
// only thing that can, because the client role is another thread of this same process.
|
||||||
|
MG_Util::Debug::SetThreadLogRole(MG_Util::Debug::LogRole::Server);
|
||||||
|
|
||||||
Bool recognised = true;
|
Bool recognised = true;
|
||||||
const char* raw = AffinityStringFromConfig();
|
const char* raw = AffinityStringFromConfig();
|
||||||
@@ -367,10 +372,10 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// The decoder is built HERE, on this thread, because PipeWireDecoder is "not thread
|
// The decoder is built HERE, on this thread, because PipeWireDecoder is "not thread
|
||||||
// safe: one decoder on the apply thread, by construction" and its constructor installs
|
// safe: one decoder on the apply thread, by construction" and its constructor installs
|
||||||
// the process-wide apply hook.
|
// the process-wide apply hook.
|
||||||
session.Applier().Attach(&session.Control(), m_backend.get());
|
session.Applier().Attach(session.DataLink(), m_backend.get());
|
||||||
|
|
||||||
Transport::RingControl& control = session.Control();
|
const auto signals = session.DataLink()->Signals();
|
||||||
Transport::Doorbell& bell = session.ConsumerDoorbell();
|
Transport::Doorbell& bell = session.DataLink()->ConsumerBell();
|
||||||
Transport::RingConsumer& ring = session.CommandRing();
|
Transport::RingConsumer& ring = session.CommandRing();
|
||||||
const Uint32 spinUs = SpinUsFromConfig();
|
const Uint32 spinUs = SpinUsFromConfig();
|
||||||
|
|
||||||
@@ -395,16 +400,16 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// this bell (that pairing is the whole of the flow-control protocol; a cleared flag
|
// this bell (that pairing is the whole of the flow-control protocol; a cleared flag
|
||||||
// with no bell is the lost wakeup the forward direction's publish-then-ring order
|
// with no bell is the lost wakeup the forward direction's publish-then-ring order
|
||||||
// exists to prevent).
|
// exists to prevent).
|
||||||
const auto ready = [this, &control, &ring] {
|
const auto ready = [this, signals, &ring] {
|
||||||
if (m_stopRequested.load(std::memory_order_acquire) || ControlIsPending()) return true;
|
if (m_stopRequested.load(std::memory_order_acquire) || ControlIsPending()) return true;
|
||||||
if (control.eventRingFull.load(std::memory_order_acquire) != 0) return false;
|
if (signals.EventRingFull->load(std::memory_order_acquire) != 0) return false;
|
||||||
return control.cmdHead.load(std::memory_order_acquire) != ring.LocalTail();
|
return signals.CmdHead->load(std::memory_order_acquire) != ring.LocalTail();
|
||||||
};
|
};
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
PumpControlRequest();
|
PumpControlRequest();
|
||||||
if (m_stopRequested.load(std::memory_order_acquire)) break;
|
if (m_stopRequested.load(std::memory_order_acquire)) break;
|
||||||
if (control.eventRingFull.load(std::memory_order_acquire) == 0) DrainRing();
|
if (signals.EventRingFull->load(std::memory_order_acquire) == 0) DrainRing();
|
||||||
if (m_stopRequested.load(std::memory_order_acquire)) break;
|
if (m_stopRequested.load(std::memory_order_acquire)) break;
|
||||||
if (ready()) continue;
|
if (ready()) continue;
|
||||||
|
|
||||||
@@ -431,7 +436,9 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
MG_Util::PipeStats::PublishGauge(Gauge::ServerWaits, waits);
|
MG_Util::PipeStats::PublishGauge(Gauge::ServerWaits, waits);
|
||||||
MG_Util::PipeStats::PublishGauge(Gauge::ServerParks, ParkBlockCount());
|
MG_Util::PipeStats::PublishGauge(Gauge::ServerParks, ParkBlockCount());
|
||||||
}
|
}
|
||||||
const bool woke = bell.Wait(control.consumerParked, ready, spinUs,
|
// Flush-on-idle publishes the last reply record even below the batch threshold.
|
||||||
|
session.FlushDataProgress();
|
||||||
|
const bool woke = bell.Wait(*signals.ConsumerParked, ready, spinUs,
|
||||||
Transport::kWaitForever, &m_parkBlocks);
|
Transport::kWaitForever, &m_parkBlocks);
|
||||||
if (!woke) {
|
if (!woke) {
|
||||||
// Wait returns false only on a dead bell or an expired deadline, and this park
|
// Wait returns false only on a dead bell or an expired deadline, and this park
|
||||||
@@ -618,10 +625,9 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// Ring.h's own rule: a header the producer could not have written is
|
// Ring.h's own rule: a header the producer could not have written is
|
||||||
// Fatal{ProtocolCorruption}, never a retry. Retrying re-reads the same bytes
|
// Fatal{ProtocolCorruption}, never a retry. Retrying re-reads the same bytes
|
||||||
// for ever; skipping desynchronises seq, and seq IS the reply-slot id.
|
// for ever; skipping desynchronises seq, and seq IS the reply-slot id.
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"SEG_CMD record header\"} - the "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"SEG_CMD record header\"} - the "
|
||||||
"consumer refused a record header at applied seq %llu",
|
"consumer refused a record header at applied seq %llu",
|
||||||
static_cast<unsigned long long>(consumer.AppliedSeq()));
|
static_cast<unsigned long long>(consumer.AppliedSeq()));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (!popped) break;
|
if (!popped) break;
|
||||||
++applied;
|
++applied;
|
||||||
@@ -632,13 +638,12 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// and PipeWireDecoder keeps its own count; a batched publish would move one and not
|
// and PipeWireDecoder keeps its own count; a batched publish would move one and not
|
||||||
// the other, which a single counter could not have told apart (w1-v1 5).
|
// the other, which a single counter could not have told apart (w1-v1 5).
|
||||||
if (applier.DecoderAppliedSeq() != consumer.AppliedSeq()) {
|
if (applier.DecoderAppliedSeq() != consumer.AppliedSeq()) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"appliedSeq batched\"} - the "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"appliedSeq batched\"} - the "
|
||||||
"session's watermark is %llu and the decoder applied %llu records. P5 "
|
"session's watermark is %llu and the decoder applied %llu records. P5 "
|
||||||
"forbids batching appliedSeq (R-9): the verb barrier's waiter reads it, "
|
"forbids batching appliedSeq (R-9): the verb barrier's waiter reads it, "
|
||||||
"and a watermark ahead of the decoder promises work that has not run",
|
"and a watermark ahead of the decoder promises work that has not run",
|
||||||
static_cast<unsigned long long>(consumer.AppliedSeq()),
|
static_cast<unsigned long long>(consumer.AppliedSeq()),
|
||||||
static_cast<unsigned long long>(applier.DecoderAppliedSeq()));
|
static_cast<unsigned long long>(applier.DecoderAppliedSeq()));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
// RETIRE. MANDATORY, not optional: RingProducer::FreeBytes() reclaims against
|
// RETIRE. MANDATORY, not optional: RingProducer::FreeBytes() reclaims against
|
||||||
// retiredTail only, and w1's SEG_STAGE linear allocator reclaims on retiredSeq - so
|
// retiredTail only, and w1's SEG_STAGE linear allocator reclaims on retiredSeq - so
|
||||||
@@ -655,8 +660,22 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
return applied;
|
return applied;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerLoop::SetRemoteControlSink(RemoteControlSink sink, void* user) {
|
||||||
|
m_remoteSink = sink;
|
||||||
|
m_remoteSinkUser = user;
|
||||||
|
}
|
||||||
|
|
||||||
MobileGLResult ServerLoop::RunSurfaceControlFrame(SurfaceControlFrame& frame) {
|
MobileGLResult ServerLoop::RunSurfaceControlFrame(SurfaceControlFrame& frame) {
|
||||||
if (frame.kind == SurfaceControlOp::None) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
if (frame.kind == SurfaceControlOp::None) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
|
||||||
|
// `cp`: the server is another process, so the frame CROSSES instead of
|
||||||
|
// being posted. Checked before the seq mint below, because a wire request
|
||||||
|
// must carry the CLIENT's number all the way through dispatch and the
|
||||||
|
// reply - the local mint at :662 is for unnumbered LOCAL requests and
|
||||||
|
// renumbering a wire one would make its reply uncorrelatable.
|
||||||
|
if (m_remoteSink != nullptr) {
|
||||||
|
return m_remoteSink(m_remoteSinkUser, frame);
|
||||||
|
}
|
||||||
// Zero marks an unnumbered local request. A wire request is already numbered by its
|
// Zero marks an unnumbered local request. A wire request is already numbered by its
|
||||||
// client and MUST retain that number all the way through dispatch and the reply.
|
// client and MUST retain that number all the way through dispatch and the reply.
|
||||||
if (frame.seq == 0) frame.seq = m_controlSeq.fetch_add(1, std::memory_order_acq_rel) + 1;
|
if (frame.seq == 0) frame.seq = m_controlSeq.fetch_add(1, std::memory_order_acq_rel) + 1;
|
||||||
@@ -687,13 +706,12 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// render correctly with the context on the wrong thread - the one outcome R-1
|
// render correctly with the context on the wrong thread - the one outcome R-1
|
||||||
// exists to make impossible. Fatal by name, never a fallback; compare
|
// exists to make impossible. Fatal by name, never a fallback; compare
|
||||||
// CreateBackend's default: arm, which also refuses rather than substitutes.
|
// CreateBackend's default: arm, which also refuses rather than substitutes.
|
||||||
MGLOG_F("MGPipe: Fatal{ApplyThreadNotRunning, \"EGL on the app thread\"} - a "
|
SessionFail(MGFatalFamily::ApplyThreadNotRunning, "MGPipe: Fatal{ApplyThreadNotRunning, \"EGL on the app thread\"} - a "
|
||||||
"control frame reached RunSurfaceControlFrame with the server's backend "
|
"control frame reached RunSurfaceControlFrame with the server's backend "
|
||||||
"built but no mgl-srv-apply thread running (ClientSession::Start failed "
|
"built but no mgl-srv-apply thread running (ClientSession::Start failed "
|
||||||
"after ServerLoop::CreateBackend). Dispatching it inline would make the "
|
"after ServerLoop::CreateBackend). Dispatching it inline would make the "
|
||||||
"context current on the APP thread - the split lane's whole premise. "
|
"context current on the APP thread - the split lane's whole premise. "
|
||||||
"Refusing by name rather than falling back to monolith");
|
"Refusing by name rather than falling back to monolith");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
// Backend already gone (post-Stop teardown, or the pre-Init window): the dispatch's
|
// Backend already gone (post-Stop teardown, or the pre-Init window): the dispatch's
|
||||||
// null-backend arm would answer NOT_INITIALIZED anyway, so that is the honest result
|
// null-backend arm would answer NOT_INITIALIZED anyway, so that is the honest result
|
||||||
@@ -719,7 +737,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// it atomically, so the apply thread cannot observe the request until this side is
|
// it atomically, so the apply thread cannot observe the request until this side is
|
||||||
// waiting, and the doorbell remembers the notify regardless.
|
// waiting, and the doorbell remembers the notify regardless.
|
||||||
if (m_session != nullptr) {
|
if (m_session != nullptr) {
|
||||||
m_session->ConsumerDoorbell().Notify();
|
m_session->DataLink()->ConsumerBell().Notify();
|
||||||
}
|
}
|
||||||
m_controlDone.wait(lock, [this] { return m_controlFinished; });
|
m_controlDone.wait(lock, [this] { return m_controlFinished; });
|
||||||
frame = m_controlFrame; // the reply half, written by the dispatch
|
frame = m_controlFrame; // the reply half, written by the dispatch
|
||||||
@@ -770,7 +788,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// The bell may already be dead - ClientSession::Stop calls transport->Shutdown()
|
// The bell may already be dead - ClientSession::Stop calls transport->Shutdown()
|
||||||
// first, which is what table 3's step 2 requires - and Notify on a dead bell is
|
// first, which is what table 3's step 2 requires - and Notify on a dead bell is
|
||||||
// harmless. Ringing anyway covers the paths that Stop without a Kill.
|
// harmless. Ringing anyway covers the paths that Stop without a Kill.
|
||||||
m_session->ConsumerDoorbell().Notify();
|
m_session->DataLink()->ConsumerBell().Notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
// THE JOIN IS BOUNDED. std::thread::join has no deadline, so a lost wakeup would wedge
|
// THE JOIN IS BOUNDED. std::thread::join has no deadline, so a lost wakeup would wedge
|
||||||
@@ -787,7 +805,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// run on into the client's teardown, reading rings the client is about to unmap -
|
// run on into the client's teardown, reading rings the client is about to unmap -
|
||||||
// a use-after-free whose only symptom is an intermittent crash somewhere else.
|
// a use-after-free whose only symptom is an intermittent crash somewhere else.
|
||||||
// Aborting here is red, immediate, and names the cause.
|
// Aborting here is red, immediate, and names the cause.
|
||||||
MGLOG_F("MGPipe: Fatal{ApplyThreadJoinTimeout} - mgl-srv-apply did not exit within "
|
SessionFail(MGFatalFamily::ApplyThreadJoinTimeout, "MGPipe: Fatal{ApplyThreadJoinTimeout} - mgl-srv-apply did not exit within "
|
||||||
"%u ms of Stop(). Stop() published m_stopRequested (in the park predicate) "
|
"%u ms of Stop(). Stop() published m_stopRequested (in the park predicate) "
|
||||||
"BEFORE it rang, so a plain Notify should already have un-parked the thread; "
|
"BEFORE it rang, so a plain Notify should already have un-parked the thread; "
|
||||||
"Doorbell::Kill() (Doorbell.h, CondVarDoorbell::Kill; table 3 step 2) is "
|
"Doorbell::Kill() (Doorbell.h, CondVarDoorbell::Kill; table 3 step 2) is "
|
||||||
@@ -796,7 +814,6 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
"lost, not slow. Aborting rather than detaching: a detached apply thread still "
|
"lost, not slow. Aborting rather than detaching: a detached apply thread still "
|
||||||
"owns the context and would read rings the client is about to unmap",
|
"owns the context and would read rings the client is about to unmap",
|
||||||
kJoinTimeoutMs);
|
kJoinTimeoutMs);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
m_thread.join();
|
m_thread.join();
|
||||||
// The identity is NOT cleared here any more: the thread clears it itself, under
|
// The identity is NOT cleared here any more: the thread clears it itself, under
|
||||||
@@ -864,10 +881,9 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
MG_Backend::WindowBackend WindowBackendFromFrameValue(Int value) {
|
MG_Backend::WindowBackend WindowBackendFromFrameValue(Int value) {
|
||||||
if (value < static_cast<Int>(MG_Backend::WindowBackend::Unknown) ||
|
if (value < static_cast<Int>(MG_Backend::WindowBackend::Unknown) ||
|
||||||
value >= static_cast<Int>(MG_Backend::WindowBackend::WindowBackendCount)) {
|
value >= static_cast<Int>(MG_Backend::WindowBackend::WindowBackendCount)) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"SurfaceOp.windowBackend\"} - a "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"SurfaceOp.windowBackend\"} - a "
|
||||||
"control frame carried window backend tag %d, which names no "
|
"control frame carried window backend tag %d, which names no "
|
||||||
"WindowBackend", value);
|
"WindowBackend", value);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
return static_cast<MG_Backend::WindowBackend>(value);
|
return static_cast<MG_Backend::WindowBackend>(value);
|
||||||
}
|
}
|
||||||
@@ -1016,7 +1032,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
backend->SetWindowHandle(UnpackWindowHandle(frame));
|
backend->SetWindowHandle(UnpackWindowHandle(frame));
|
||||||
frame.ok = true;
|
frame.ok = true;
|
||||||
return MOBILEGL_OK;
|
return MOBILEGL_OK;
|
||||||
case SurfaceControlOp::InitCapabilitiesInprocOnly:
|
case SurfaceControlOp::InitCapabilities:
|
||||||
// Inproc-only (f0-egl §4.2): on the wire the ANSWER to this op is the CapsSnapshot
|
// Inproc-only (f0-egl §4.2): on the wire the ANSWER to this op is the CapsSnapshot
|
||||||
// frame itself, so there is no SurfaceOp kind for it. The frame channel still has to
|
// frame itself, so there is no SurfaceOp kind for it. The frame channel still has to
|
||||||
// carry it inproc because InitCapabilities runs GL queries and therefore belongs to
|
// carry it inproc because InitCapabilities runs GL queries and therefore belongs to
|
||||||
@@ -1051,9 +1067,8 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// A kind the switch does not know never legitimately posts (RunSurfaceControlFrame
|
// A kind the switch does not know never legitimately posts (RunSurfaceControlFrame
|
||||||
// refuses None), so reaching this line means the slot's bytes were not written by the
|
// refuses None), so reaching this line means the slot's bytes were not written by the
|
||||||
// poster at all - the ring's Fatal{ProtocolCorruption} discipline, one channel over.
|
// poster at all - the ring's Fatal{ProtocolCorruption} discipline, one channel over.
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"SurfaceOp.kind\"} - the control slot held "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"SurfaceOp.kind\"} - the control slot held "
|
||||||
"kind %d, which names no dispatchable op", static_cast<int>(frame.kind));
|
"kind %d, which names no dispatchable op", static_cast<int>(frame.kind));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
@@ -1158,7 +1173,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
|
|
||||||
Bool ServerInitCapabilities() {
|
Bool ServerInitCapabilities() {
|
||||||
SurfaceControlFrame frame;
|
SurfaceControlFrame frame;
|
||||||
frame.kind = SurfaceControlOp::InitCapabilitiesInprocOnly;
|
frame.kind = SurfaceControlOp::InitCapabilities;
|
||||||
const MobileGLResult rc = ServerLoopInstance().RunSurfaceControlFrame(frame);
|
const MobileGLResult rc = ServerLoopInstance().RunSurfaceControlFrame(frame);
|
||||||
return rc == MOBILEGL_OK && frame.ok;
|
return rc == MOBILEGL_OK && frame.ok;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,6 +223,21 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// What did NOT move: the blocking handshake, the one slot, and the apply-thread
|
// What did NOT move: the blocking handshake, the one slot, and the apply-thread
|
||||||
// ownership. Under spawn the same frame is what SurfaceOpCodec encodes into a
|
// ownership. Under spawn the same frame is what SurfaceOpCodec encodes into a
|
||||||
// Wire::SurfaceOp - this signature is the seam both transports share.
|
// Wire::SurfaceOp - this signature is the seam both transports share.
|
||||||
|
// P6 `cp`: where a control frame goes when the server is ANOTHER PROCESS.
|
||||||
|
//
|
||||||
|
// All twelve Server* forwarders funnel through RunSurfaceControlFrame, so
|
||||||
|
// this is ONE seam rather than twelve (a6 row A4-13 counted them). The
|
||||||
|
// client installs a sink at handshake; with none installed the behaviour
|
||||||
|
// is exactly what it was - post into the one-slot mailbox, or run inline
|
||||||
|
// when we are already on the apply thread.
|
||||||
|
//
|
||||||
|
// A HOOK RATHER THAN A CALL INTO ClientSession, deliberately: the server
|
||||||
|
// half calling the client half is four of the six symbols a6 found
|
||||||
|
// MG_Remote owes itself (a6-link-experiment §5), and this is the one
|
||||||
|
// place that would have added a fifth.
|
||||||
|
using RemoteControlSink = MobileGLResult (*)(void* user, SurfaceControlFrame& frame);
|
||||||
|
void SetRemoteControlSink(RemoteControlSink sink, void* user);
|
||||||
|
|
||||||
MobileGLResult RunSurfaceControlFrame(SurfaceControlFrame& frame);
|
MobileGLResult RunSurfaceControlFrame(SurfaceControlFrame& frame);
|
||||||
|
|
||||||
// The TEST seam through the same channel: posts a ProbeForTesting frame whose dispatch
|
// The TEST seam through the same channel: posts a ProbeForTesting frame whose dispatch
|
||||||
@@ -364,6 +379,9 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
Bool ControlIsPending() const;
|
Bool ControlIsPending() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
RemoteControlSink m_remoteSink = nullptr;
|
||||||
|
void* m_remoteSinkUser = nullptr;
|
||||||
|
|
||||||
void ApplyThreadMain();
|
void ApplyThreadMain();
|
||||||
// Runs a posted control frame, if there is one. Returns true if it ran one.
|
// Runs a posted control frame, if there is one. Returns true if it ran one.
|
||||||
Bool PumpControlRequest();
|
Bool PumpControlRequest();
|
||||||
|
|||||||
@@ -0,0 +1,311 @@
|
|||||||
|
// MobileGL - separate-process server and TCP session supervisor.
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
#include "../Transport/Doorbell.h"
|
||||||
|
#include "../Transport/SocketTransport.h"
|
||||||
|
#include "../Transport/WireLog.h"
|
||||||
|
#include "../Protocol/SurfaceOpCodec.h"
|
||||||
|
#include "../Handshake.h"
|
||||||
|
#include "ServerLoop.h"
|
||||||
|
#include "ServerSession.h"
|
||||||
|
#include "SurfaceControlFrame.h"
|
||||||
|
#include <Config.h>
|
||||||
|
#include <Init.h>
|
||||||
|
#include <MG_Backend/MGPipe/PipeInputs.h>
|
||||||
|
#include <MG_Backend/ServerRole.h>
|
||||||
|
#include <MG_Util/Debug/Log.h>
|
||||||
|
#include <MG_Util/Metrics/PipeStats.h>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <chrono>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
using namespace MobileGL::MG_Remote;
|
||||||
|
using namespace MobileGL::MG_Remote::Transport;
|
||||||
|
namespace Protocol = ::MobileGL::Wire;
|
||||||
|
|
||||||
|
void Refuse(SocketTransport& transport, Protocol::RefuseCode code, const char* detail) {
|
||||||
|
flatbuffers::FlatBufferBuilder builder(256);
|
||||||
|
auto refusal = Protocol::CreateRefuseDirect(builder, code, detail);
|
||||||
|
auto envelope = Protocol::CreateCtrlEnvelope(builder, Protocol::CtrlMsg::Refuse, refusal.Union());
|
||||||
|
Protocol::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||||
|
transport.SendFrame({builder.GetBufferPointer(), builder.GetSize()});
|
||||||
|
WireLogError("MG_Remote server: Refuse{%s} %s", Protocol::EnumNameRefuseCode(code), detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForwardLog(void* user, const char* text) {
|
||||||
|
auto& transport = *static_cast<ITransport*>(user);
|
||||||
|
flatbuffers::FlatBufferBuilder builder(512);
|
||||||
|
auto log = Protocol::CreateLogLine(builder, Protocol::LogLevel::Info, builder.CreateString(text));
|
||||||
|
auto envelope = Protocol::CreateCtrlEnvelope(builder, Protocol::CtrlMsg::LogLine, log.Union());
|
||||||
|
Protocol::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||||
|
(void)transport.SendFrame({builder.GetBufferPointer(), builder.GetSize()});
|
||||||
|
}
|
||||||
|
|
||||||
|
void RefuseBusy(SocketTransport& transport, const char* detail) {
|
||||||
|
// Unread Hello bytes can make close send RST and discard our Refuse.
|
||||||
|
std::uint64_t bytes = 0;
|
||||||
|
if (transport.ReceiveFrame({nullptr, 0}, &bytes, 2000) == MOBILEGL_ERR_BUFFER_TOO_SMALL &&
|
||||||
|
bytes <= 1024 * 1024) {
|
||||||
|
std::vector<std::uint8_t> hello(static_cast<std::size_t>(bytes));
|
||||||
|
(void)transport.ReceiveFrame({hello.data(), hello.size()}, &bytes, 0);
|
||||||
|
}
|
||||||
|
Refuse(transport, Protocol::RefuseCode::Busy, detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FlushAck { ITransport* transport; std::uint64_t seq; };
|
||||||
|
void SendLogAck(void* pointer) {
|
||||||
|
auto& ack = *static_cast<FlushAck*>(pointer);
|
||||||
|
flatbuffers::FlatBufferBuilder builder(64);
|
||||||
|
auto flush = Protocol::CreateLogFlush(builder, ack.seq, true);
|
||||||
|
auto envelope = Protocol::CreateCtrlEnvelope(builder, Protocol::CtrlMsg::LogFlush, flush.Union());
|
||||||
|
Protocol::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||||
|
(void)ack.transport->SendFrame({builder.GetBufferPointer(), builder.GetSize()});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called only after fork: the supervisor never creates a backend or EGL context.
|
||||||
|
[[noreturn]] void RunSession(std::unique_ptr<SocketTransport> control) {
|
||||||
|
const int selfPid = static_cast<int>(::getpid());
|
||||||
|
const bool tcp = control->IsTcp();
|
||||||
|
std::vector<std::uint8_t> helloFrame;
|
||||||
|
std::uint64_t bytes = 0;
|
||||||
|
auto received = control->ReceiveFrame({nullptr, 0}, &bytes, 10000);
|
||||||
|
if (received != MOBILEGL_ERR_BUFFER_TOO_SMALL || bytes > 1024 * 1024) ::_exit(67);
|
||||||
|
helloFrame.resize(static_cast<std::size_t>(bytes));
|
||||||
|
if (control->ReceiveFrame({helloFrame.data(), helloFrame.size()}, &bytes, 0) != MOBILEGL_OK) ::_exit(67);
|
||||||
|
flatbuffers::Verifier verifier(helloFrame.data(), helloFrame.size());
|
||||||
|
if (!Protocol::VerifyCtrlEnvelopeBuffer(verifier)) ::_exit(67);
|
||||||
|
const auto* hello = Protocol::GetCtrlEnvelope(helloFrame.data())->msg_as_Hello();
|
||||||
|
if (!hello) ::_exit(67);
|
||||||
|
// Reject incompatible wire before backend bring-up can obscure the cause.
|
||||||
|
if (ValidatePeerHandshake(*control, hello->abiMajor(), hello->abiMinor(),
|
||||||
|
hello->wireFingerprint(), hello->buildFingerprint() ? hello->buildFingerprint()->c_str() : nullptr,
|
||||||
|
hello->dialMode()) != MOBILEGL_OK) ::_exit(0);
|
||||||
|
if (tcp) {
|
||||||
|
const char* expected = std::getenv("MOBILEGL_IPC_TOKEN");
|
||||||
|
const std::string token = hello->token() ? hello->token()->str() : std::string();
|
||||||
|
if (token != (expected ? expected : "")) {
|
||||||
|
Refuse(*control, Protocol::RefuseCode::Authentication, "TCP token mismatch");
|
||||||
|
::_exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MobileGL::MG_ConfigLoader::Init();
|
||||||
|
MobileGL::MG_Config::Transport = MobileGL::MG_Config::TransportMode::Spawn;
|
||||||
|
MobileGL::MG_Pipe::MGPipeSetServerProcessRole(true);
|
||||||
|
// The child bypasses MobileGL::Initialize: arm its own role counters.
|
||||||
|
MobileGL::MG_Util::PipeStats::Init();
|
||||||
|
const auto backend = static_cast<MobileGL::BackendType>(hello->backendType());
|
||||||
|
if (backend != MobileGL::BackendType::DirectGLES && backend != MobileGL::BackendType::DirectVulkan) {
|
||||||
|
Refuse(*control, Protocol::RefuseCode::Backend, "unsupported Hello.backendType");
|
||||||
|
::_exit(0);
|
||||||
|
}
|
||||||
|
const char* pinned = std::getenv("MOBILEGL_BACKEND_TYPE");
|
||||||
|
if (pinned && *pinned && backend != MobileGL::MG_Config::ActiveBackendType) {
|
||||||
|
Refuse(*control, Protocol::RefuseCode::Backend, "Hello.backendType disagrees with pinned backend");
|
||||||
|
::_exit(0);
|
||||||
|
}
|
||||||
|
MobileGL::MG_Config::ActiveBackendType = backend;
|
||||||
|
if (!MobileGL::MG_Backend::InitServerRoleForSpawn()) ::_exit(66);
|
||||||
|
auto& session = Server::ServerSessionInstance();
|
||||||
|
int serverBell[2] = {-1, -1}, clientBell[2] = {-1, -1};
|
||||||
|
std::unique_ptr<SocketDoorbell> selfBell, peerBell;
|
||||||
|
if (!tcp) {
|
||||||
|
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, serverBell) != 0 ||
|
||||||
|
::socketpair(AF_UNIX, SOCK_STREAM, 0, clientBell) != 0) ::_exit(74);
|
||||||
|
selfBell = std::make_unique<SocketDoorbell>(serverBell[0], serverBell[1], 1, true);
|
||||||
|
peerBell = std::make_unique<SocketDoorbell>(-1, clientBell[1], 1, true);
|
||||||
|
session.SetExternalDoorbells(selfBell.get(), peerBell.get());
|
||||||
|
}
|
||||||
|
const auto accepted = session.Accept(*control, &helloFrame);
|
||||||
|
if (accepted != MOBILEGL_OK) {
|
||||||
|
WireLogError("MG_Remote server: pid=%d Accept failed (rc=%d)", selfPid, static_cast<int>(accepted));
|
||||||
|
std::fflush(nullptr);
|
||||||
|
::_exit(accepted == MOBILEGL_ERR_PROTOCOL_MISMATCH ? 0 : 67);
|
||||||
|
}
|
||||||
|
if (!tcp)
|
||||||
|
{
|
||||||
|
struct Sideband {
|
||||||
|
std::uint32_t slot;
|
||||||
|
std::uint64_t bytes;
|
||||||
|
};
|
||||||
|
using Slot = SessionSegmentSlot;
|
||||||
|
static constexpr Slot kSlots[4] = {Slot::Cmd, Slot::Stage, Slot::Reply, Slot::Event};
|
||||||
|
for (const Slot slot : kSlots) {
|
||||||
|
const std::uint32_t tag = static_cast<std::uint32_t>(slot);
|
||||||
|
const int fd = session.Shm().DescriptorFor(slot);
|
||||||
|
if (fd < 0) {
|
||||||
|
std::fprintf(stderr, "MG_Remote server: pid=%d segment %u has no descriptor\n",
|
||||||
|
selfPid, tag);
|
||||||
|
std::fflush(nullptr);
|
||||||
|
::_exit(68);
|
||||||
|
}
|
||||||
|
Sideband sideband{tag, session.Shm().AnnouncedSize(slot)};
|
||||||
|
if (control->ShareFd(fd, MobileGLByteSpan{&sideband, sizeof(sideband)}) !=
|
||||||
|
MOBILEGL_OK) {
|
||||||
|
std::fprintf(stderr, "MG_Remote server: pid=%d could not share segment %u\n",
|
||||||
|
selfPid, tag);
|
||||||
|
std::fflush(nullptr);
|
||||||
|
::_exit(69);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// SLOTS 4, 5 AND 6 ARE THE BELLS - three, not two, and the third is the
|
||||||
|
// one the two-fd form above forces:
|
||||||
|
// 4 serverBell[1] the client's handle to RING THE SERVER
|
||||||
|
// 5 clientBell[0] the client's PARK end
|
||||||
|
// 6 clientBell[1] the client's handle to ring ITSELF, for the same
|
||||||
|
// reason the server needs serverBell[1]
|
||||||
|
// Sharing DUPs, so the descriptors these bells own stay valid here.
|
||||||
|
const int bellFds[3] = {serverBell[1], clientBell[0], clientBell[1]};
|
||||||
|
for (std::uint32_t index = 0; index < 3; ++index) {
|
||||||
|
Sideband sideband{4 + index, 0};
|
||||||
|
if (control->ShareFd(bellFds[index], MobileGLByteSpan{&sideband, sizeof(sideband)}) !=
|
||||||
|
MOBILEGL_OK) {
|
||||||
|
std::fprintf(stderr, "MG_Remote server: pid=%d could not share bell %u\n", selfPid,
|
||||||
|
index);
|
||||||
|
std::fflush(nullptr);
|
||||||
|
::_exit(69);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// clientBell[0] is the CLIENT's park end and no bell here owns it; the
|
||||||
|
// other three belong to selfBell and peerBell and are closed with them.
|
||||||
|
::close(clientBell[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* forwarding = std::getenv("MOBILEGL_IPC_LOG_FORWARD");
|
||||||
|
if (tcp && (!forwarding || std::strcmp(forwarding, "0") != 0))
|
||||||
|
MobileGL::MG_Util::Debug::SetLogForwarder(&ForwardLog, control.get());
|
||||||
|
auto& loop = Server::ServerLoopInstance();
|
||||||
|
if (loop.Start(session) != MOBILEGL_OK) ::_exit(70);
|
||||||
|
WireLogError("MG_Remote server: pid=%d transport=spawn role=server ready control=%s data=%s",
|
||||||
|
selfPid, tcp ? "tcp" : "unix", tcp ? "stream" : "shm");
|
||||||
|
std::vector<std::uint8_t> buffer(64 * 1024);
|
||||||
|
for (;;) {
|
||||||
|
std::uint64_t size = 0;
|
||||||
|
const auto result = control->ReceiveFrame({buffer.data(), buffer.size()}, &size, kWaitForever);
|
||||||
|
if (result == MOBILEGL_ERR_BUFFER_TOO_SMALL) { buffer.resize(static_cast<std::size_t>(size)); continue; }
|
||||||
|
if (result != MOBILEGL_OK) break;
|
||||||
|
flatbuffers::Verifier check(buffer.data(), static_cast<std::size_t>(size));
|
||||||
|
if (!Protocol::VerifyCtrlEnvelopeBuffer(check)) break;
|
||||||
|
const auto* envelope = Protocol::GetCtrlEnvelope(buffer.data());
|
||||||
|
if (const auto* flush = envelope->msg_as_LogFlush()) {
|
||||||
|
if (flush->ack()) break;
|
||||||
|
if (const char* inspect = std::getenv("MOBILEGL_TEST_SERVER_COUNTERS");
|
||||||
|
inspect && std::strcmp(inspect, "1") == 0) {
|
||||||
|
// SyncPeerLog has fenced the client's complete command prefix.
|
||||||
|
// Acquire the applier's publication before reading its counters;
|
||||||
|
// this serial client sends no more records until this ack.
|
||||||
|
const auto applied = session.DataLink()->Progress()->appliedSeq.load(std::memory_order_acquire);
|
||||||
|
const auto& verbs = session.Applier().Verbs();
|
||||||
|
MGLOG_I("MGPipe server counters: applied=%llu resets=%llu reset-serial=%llu deaths=%llu",
|
||||||
|
static_cast<unsigned long long>(applied),
|
||||||
|
static_cast<unsigned long long>(verbs.ApplierResets()),
|
||||||
|
static_cast<unsigned long long>(verbs.ExpectedApplierResetSerial()),
|
||||||
|
static_cast<unsigned long long>(verbs.ObjectDeaths()));
|
||||||
|
}
|
||||||
|
FlushAck ack{control.get(), flush->seq()};
|
||||||
|
MobileGL::MG_Util::Debug::WithLogBarrier(&SendLogAck, &ack);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const auto* operation = envelope->msg_as_SurfaceOp();
|
||||||
|
if (!operation) break;
|
||||||
|
Server::SurfaceControlFrame reply{};
|
||||||
|
(void)ServerApplyWireSurfaceOp(*operation, &reply);
|
||||||
|
session.FlushDataProgress();
|
||||||
|
if (session.DataLink()) reply.eventHead = session.DataLink()->EventPublishedHead();
|
||||||
|
flatbuffers::FlatBufferBuilder builder(256);
|
||||||
|
EncodeSurfaceReplyFrame(reply, &builder);
|
||||||
|
if (control->SendFrame({builder.GetBufferPointer(), builder.GetSize()}) != MOBILEGL_OK) break;
|
||||||
|
}
|
||||||
|
loop.Stop();
|
||||||
|
// Publish the final server window while log forwarding is still attached.
|
||||||
|
MobileGL::MG_Util::PipeStats::Shutdown();
|
||||||
|
session.Close();
|
||||||
|
MobileGL::MG_Util::Debug::SetLogForwarder(nullptr, nullptr);
|
||||||
|
// _exit closes control after cleanup/flush; peer EOF is the client's fence.
|
||||||
|
std::fflush(nullptr);
|
||||||
|
::_exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" __attribute__((visibility("default"))) int mobilegl_server_main(int argc, char** argv) {
|
||||||
|
// The supervisor and every forked session child log under the server role.
|
||||||
|
// Set it here rather than trusting the launcher to have done so: log role is
|
||||||
|
// resolved from this env at first use, and a launcher that omits it would
|
||||||
|
// silently misfile this process's main-thread server lines as the client
|
||||||
|
// role and never forward them. Done before any logging so the value is cached
|
||||||
|
// as server and inherited by the fork children. DIAL/scrub stay hard checks.
|
||||||
|
if (const char* role = std::getenv("MOBILEGL_IPC_ROLE");
|
||||||
|
!role || std::strcmp(role, "server") != 0) {
|
||||||
|
::setenv("MOBILEGL_IPC_ROLE", "server", 1);
|
||||||
|
}
|
||||||
|
const char* dial = std::getenv("MOBILEGL_IPC_DIAL");
|
||||||
|
if (!dial || std::strcmp(dial, "no") != 0) {
|
||||||
|
std::fprintf(stderr, "MG_Remote server: MOBILEGL_IPC_DIAL=no anti-recursion catch (a) missing\n");
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
for (const char* name : {"MOBILEGL_TRANSPORT", "MOBILEGL_IPC_SERVER_PATH", "MOBILEGL_IPC_RING_MB", "MOBILEGL_IPC_STAGE_MB"}) {
|
||||||
|
if (std::getenv(name)) {
|
||||||
|
std::fprintf(stderr, "MG_Remote server: envp scrub FAILED, catch (b): %s\n", name);
|
||||||
|
return 65;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string endpoint;
|
||||||
|
bool serve = false;
|
||||||
|
for (int i = 1; i < argc; ++i) {
|
||||||
|
const std::string arg(argv[i]);
|
||||||
|
if (arg == "--serve") serve = true;
|
||||||
|
else if (arg == "--max-sessions" && i + 1 < argc) {
|
||||||
|
char* end = nullptr;
|
||||||
|
const auto count = std::strtoul(argv[++i], &end, 10);
|
||||||
|
// This is a concurrency limit, not a cumulative session budget.
|
||||||
|
// P6.5 deliberately supports one active rendering session.
|
||||||
|
if (*end || count != 1) return 71;
|
||||||
|
} else if (endpoint.empty() && arg.compare(0, 2, "--") != 0) endpoint = arg;
|
||||||
|
else return 71;
|
||||||
|
}
|
||||||
|
if (endpoint.empty()) if (const char* value = std::getenv("MOBILEGL_IPC_ENDPOINT")) endpoint = value;
|
||||||
|
if (endpoint.empty()) return 71;
|
||||||
|
int listener = -1;
|
||||||
|
if (SocketTransport::Listen(endpoint, &listener) != MOBILEGL_OK) return 72;
|
||||||
|
WireLogError("MG_Remote server: pid=%d listening on %s", static_cast<int>(::getpid()), endpoint.c_str());
|
||||||
|
pid_t active = -1;
|
||||||
|
for (;;) {
|
||||||
|
if (active > 0 && ::waitpid(active, nullptr, WNOHANG) == active) active = -1;
|
||||||
|
std::unique_ptr<SocketTransport> control;
|
||||||
|
const auto accepted = SocketTransport::AcceptPair(listener, serve ? 250 : 30000, control);
|
||||||
|
if (accepted == MOBILEGL_ERR_TIMEOUT && serve) continue;
|
||||||
|
if (accepted != MOBILEGL_OK) { ::close(listener); return 73; }
|
||||||
|
if (!serve) {
|
||||||
|
::close(listener);
|
||||||
|
if (endpoint[0] != '@' && endpoint.compare(0, 6, "tcp://") != 0) ::unlink(endpoint.c_str());
|
||||||
|
RunSession(std::move(control));
|
||||||
|
}
|
||||||
|
if (active > 0 && ::waitpid(active, nullptr, WNOHANG) == active) active = -1;
|
||||||
|
// exit_group closes files just before waitpid can observe the exit.
|
||||||
|
// Allow that small scheduling window; a live peer remains Busy.
|
||||||
|
const auto reapDeadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(50);
|
||||||
|
while (active > 0 && std::chrono::steady_clock::now() < reapDeadline) {
|
||||||
|
if (::waitpid(active, nullptr, WNOHANG) == active) { active = -1; break; }
|
||||||
|
::usleep(1000);
|
||||||
|
}
|
||||||
|
if (active > 0) {
|
||||||
|
RefuseBusy(*control, "one session is already active");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::fflush(nullptr);
|
||||||
|
const pid_t child = ::fork();
|
||||||
|
if (child == 0) { ::close(listener); RunSession(std::move(control)); }
|
||||||
|
if (child < 0) { RefuseBusy(*control, "could not create session child"); continue; }
|
||||||
|
active = child;
|
||||||
|
control->CloseLocalCopy();
|
||||||
|
}
|
||||||
|
::close(listener);
|
||||||
|
if (endpoint[0] != '@' && endpoint.compare(0, 6, "tcp://") != 0) ::unlink(endpoint.c_str());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -8,9 +8,13 @@
|
|||||||
|
|
||||||
// P5 package s1: the server half of a session.
|
// P5 package s1: the server half of a session.
|
||||||
|
|
||||||
|
#include "../Transport/SocketTransport.h"
|
||||||
#include "ServerSession.h"
|
#include "ServerSession.h"
|
||||||
|
#include <MG_Remote/FatalFunnel.h>
|
||||||
|
|
||||||
#include "../CapsCodec.h"
|
#include "../CapsCodec.h"
|
||||||
|
#include "../Handshake.h"
|
||||||
|
#include "../Transport/LinkMetrics.h"
|
||||||
#include "../Protocol/generated/protocol_generated.h"
|
#include "../Protocol/generated/protocol_generated.h"
|
||||||
#include "../Transport/InProcessTransport.h"
|
#include "../Transport/InProcessTransport.h"
|
||||||
|
|
||||||
@@ -24,8 +28,27 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// CONTRACT-P6 4.3: the one value in the handshake that a same-process session cannot fake.
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include <process.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace MobileGL::MG_Remote::Server {
|
namespace MobileGL::MG_Remote::Server {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// File-local on purpose: two callers, both handshake facts. A process-id helper on a
|
||||||
|
// public header invites uses that are not.
|
||||||
|
std::uint32_t SelfProcessId() {
|
||||||
|
#if defined(_WIN32)
|
||||||
|
return static_cast<std::uint32_t>(::_getpid());
|
||||||
|
#else
|
||||||
|
return static_cast<std::uint32_t>(::getpid());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
// THE THREE FLAG-SPACE COLLISIONS, AS TRIPWIRES RATHER THAN AS A COMMENT.
|
// THE THREE FLAG-SPACE COLLISIONS, AS TRIPWIRES RATHER THAN AS A COMMENT.
|
||||||
//
|
//
|
||||||
// MGPipeCallFlags (MG_Pipe/MGPipe.h:42-54) and RingRecordFlags (Ring.h) are separate spaces
|
// MGPipeCallFlags (MG_Pipe/MGPipe.h:42-54) and RingRecordFlags (Ring.h) are separate spaces
|
||||||
@@ -89,24 +112,6 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
return ::MobileGL::Wire::GetCtrlEnvelope(bytes.data());
|
return ::MobileGL::Wire::GetCtrlEnvelope(bytes.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[noreturn]] void FatalAbiMismatch(const char* what, Uint64 ours, Uint64 theirs,
|
|
||||||
const char* ourStamp, const char* theirStamp) {
|
|
||||||
// NEVER a downgrade. Every alternative to aborting here reads one struct as
|
|
||||||
// another - MGPCaps has only a compositional size assertion because
|
|
||||||
// DynamicBackendParameters still carries SizeT, so a peer built from a different
|
|
||||||
// tree hands over a caps block whose members are at different offsets and whose
|
|
||||||
// bytes are all individually plausible.
|
|
||||||
MGLOG_F("MGPipe: Fatal{AbiMismatch, \"%s\"} ours=%llu theirs=%llu ourBuild=%s "
|
|
||||||
"theirBuild=%s - the two peers were not built from the same struct shapes, "
|
|
||||||
"and there is no downgrade path: the caps block's size is ABI-dependent "
|
|
||||||
"(MGPipeTypes.h:145-146) and every field past the first difference would be "
|
|
||||||
"read at the wrong offset",
|
|
||||||
what, static_cast<unsigned long long>(ours),
|
|
||||||
static_cast<unsigned long long>(theirs),
|
|
||||||
ourStamp == nullptr ? "?" : ourStamp, theirStamp == nullptr ? "?" : theirStamp);
|
|
||||||
std::abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
// MOBILEGL_IPC_RING_MB / MOBILEGL_IPC_STAGE_MB, actually applied.
|
// MOBILEGL_IPC_RING_MB / MOBILEGL_IPC_STAGE_MB, actually applied.
|
||||||
//
|
//
|
||||||
// The first version of this file called this only `if (m_sizes.CmdBytes == 0)`, and
|
// The first version of this file called this only `if (m_sizes.CmdBytes == 0)`, and
|
||||||
@@ -145,7 +150,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// SetCapabilityBits / SetConsumedSubsystems for why the one that used to be here was
|
// SetCapabilityBits / SetConsumedSubsystems for why the one that used to be here was
|
||||||
// the phase's marquee defect committed from the server's side.
|
// the phase's marquee defect committed from the server's side.
|
||||||
[[noreturn]] void FatalUnsetCallMask(Bool capBitsSet, Bool consumedSet) {
|
[[noreturn]] void FatalUnsetCallMask(Bool capBitsSet, Bool consumedSet) {
|
||||||
MGLOG_F("MGPipe: Fatal{UnsetCallMask} - %s%s%s was never set on this ServerSession, "
|
SessionFail(MGFatalFamily::UnsetCallMask, "MGPipe: Fatal{UnsetCallMask} - %s%s%s was never set on this ServerSession, "
|
||||||
"and there is no default: a guessed consumer mask makes the client's R-8 "
|
"and there is no default: a guessed consumer mask makes the client's R-8 "
|
||||||
"liveness gates answer from a server-side fact the server never stated. The "
|
"liveness gates answer from a server-side fact the server never stated. The "
|
||||||
"client would stop emitting whole record families, clear its dirty flags on "
|
"client would stop emitting whole record families, clear its dirty flags on "
|
||||||
@@ -155,7 +160,6 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
capBitsSet ? "" : "SetCapabilityBits",
|
capBitsSet ? "" : "SetCapabilityBits",
|
||||||
(!capBitsSet && !consumedSet) ? " and " : "",
|
(!capBitsSet && !consumedSet) ? " and " : "",
|
||||||
consumedSet ? "" : "SetConsumedSubsystems");
|
consumedSet ? "" : "SetConsumedSubsystems");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- P5c ev: the reverse channel's PRODUCER callbacks (CONTRACT-P5C §4.1) --------
|
// ---- P5c ev: the reverse channel's PRODUCER callbacks (CONTRACT-P5C §4.1) --------
|
||||||
@@ -173,12 +177,11 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// a Reserve that returns nullptr is Fatal{EventRingOverflow}. CountDrop and the
|
// a Reserve that returns nullptr is Fatal{EventRingOverflow}. CountDrop and the
|
||||||
// eventRingFull latch stay built and stay unused-by-policy; P9 owns the policy.
|
// eventRingFull latch stay built and stay unused-by-policy; P9 owns the policy.
|
||||||
[[noreturn]] void FatalEventRingOverflow(const char* eventName, Uint64 payloadBytes) {
|
[[noreturn]] void FatalEventRingOverflow(const char* eventName, Uint64 payloadBytes) {
|
||||||
MGLOG_F("MGPipe: Fatal{EventRingOverflow} - the producer of %s could not reserve "
|
SessionFail(MGFatalFamily::EventRingOverflow, "MGPipe: Fatal{EventRingOverflow} - the producer of %s could not reserve "
|
||||||
"%llu bytes on SEG_EVENT. P5c's events are lossless and a full ring under "
|
"%llu bytes on SEG_EVENT. P5c's events are lossless and a full ring under "
|
||||||
"lockstep is a producer burst no measured workload has, so this is a "
|
"lockstep is a producer burst no measured workload has, so this is a "
|
||||||
"defect, not a drop (CONTRACT-P5C §4.4; the drop policy is P9's)",
|
"defect, not a drop (CONTRACT-P5C §4.4; the drop policy is P9's)",
|
||||||
eventName, static_cast<unsigned long long>(payloadBytes));
|
eventName, static_cast<unsigned long long>(payloadBytes));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- P5e (ra), CONTRACT-P5E §2.6: the ring stops being a Fatal and becomes a queue --
|
// ---- P5e (ra), CONTRACT-P5E §2.6: the ring stops being a Fatal and becomes a queue --
|
||||||
@@ -220,34 +223,32 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// be a hang with a comment on it.
|
// be a hang with a comment on it.
|
||||||
const Uint64 cap = session.Events().Ring().MaxRecordBytes();
|
const Uint64 cap = session.Events().Ring().MaxRecordBytes();
|
||||||
if (payloadBytes + sizeof(Transport::RingRecordHeader) > cap) {
|
if (payloadBytes + sizeof(Transport::RingRecordHeader) > cap) {
|
||||||
MGLOG_F("MGPipe: Fatal{EventRingOverflow} - %s needs %llu bytes and SEG_EVENT "
|
SessionFail(MGFatalFamily::EventRingOverflow, "MGPipe: Fatal{EventRingOverflow} - %s needs %llu bytes and SEG_EVENT "
|
||||||
"caps ONE record at %llu (half its capacity). Flow control cannot help: "
|
"caps ONE record at %llu (half its capacity). Flow control cannot help: "
|
||||||
"no amount of draining makes a record fit a ring that is too small for "
|
"no amount of draining makes a record fit a ring that is too small for "
|
||||||
"it. Raise MOBILEGL_IPC_EVENT_KB or slice the event at its producer, as "
|
"it. Raise MOBILEGL_IPC_EVENT_KB or slice the event at its producer, as "
|
||||||
"the writeback path already does",
|
"the writeback path already does",
|
||||||
eventName, static_cast<unsigned long long>(payloadBytes),
|
eventName, static_cast<unsigned long long>(payloadBytes),
|
||||||
static_cast<unsigned long long>(cap));
|
static_cast<unsigned long long>(cap));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Transport::RingControl& control = session.Control();
|
const auto signals = session.DataLink()->Signals();
|
||||||
Transport::Doorbell& bell = session.ConsumerDoorbell();
|
Transport::Doorbell& bell = session.DataLink()->ConsumerBell();
|
||||||
const auto drained = [&control] {
|
const auto drained = [signals] {
|
||||||
return control.eventRingFull.load(std::memory_order_acquire) == 0;
|
return signals.EventRingFull->load(std::memory_order_acquire) == 0;
|
||||||
};
|
};
|
||||||
for (Uint32 round = 0; round < 2; ++round) {
|
for (Uint32 round = 0; round < 2; ++round) {
|
||||||
// PUBLISH AND RING FIRST. The client cannot drain a ring whose head it has not
|
// PUBLISH AND RING FIRST. The client cannot drain a ring whose head it has not
|
||||||
// been shown, and the latch Reserve just set is only useful to a client that
|
// been shown, and the latch Reserve just set is only useful to a client that
|
||||||
// gets a bell with it.
|
// gets a bell with it.
|
||||||
session.PublishEvents();
|
session.PublishEvents();
|
||||||
if (!drained() && !bell.Wait(control.consumerParked, drained, /*spinUs=*/0,
|
if (!drained() && !bell.Wait(*signals.ConsumerParked, drained, /*spinUs=*/0,
|
||||||
kEventBacklogWaitMs)) {
|
kEventBacklogWaitMs)) {
|
||||||
MGLOG_F("MGPipe: Fatal{EventRingOverflow} - %s waited %u ms for the client "
|
SessionFail(MGFatalFamily::EventRingOverflow, "MGPipe: Fatal{EventRingOverflow} - %s waited %u ms for the client "
|
||||||
"to drain SEG_EVENT and it never did. Under run-ahead the apply "
|
"to drain SEG_EVENT and it never did. Under run-ahead the apply "
|
||||||
"thread parks on this ring (CONTRACT-P5E §2.6); a client that does "
|
"thread parks on this ring (CONTRACT-P5E §2.6); a client that does "
|
||||||
"not drain is one that is not running",
|
"not drain is one that is not running",
|
||||||
eventName, kEventBacklogWaitMs);
|
eventName, kEventBacklogWaitMs);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
slot = session.Events().Reserve(kind, payloadBytes);
|
slot = session.Events().Reserve(kind, payloadBytes);
|
||||||
if (slot != nullptr) return slot;
|
if (slot != nullptr) return slot;
|
||||||
@@ -255,11 +256,10 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// Two full rounds against a ring the record provably fits: something else is
|
// Two full rounds against a ring the record provably fits: something else is
|
||||||
// producing into it, which on this side is impossible (one producer, the apply
|
// producing into it, which on this side is impossible (one producer, the apply
|
||||||
// thread, by construction).
|
// thread, by construction).
|
||||||
MGLOG_F("MGPipe: Fatal{EventRingOverflow} - %s could not reserve %llu bytes on an "
|
SessionFail(MGFatalFamily::EventRingOverflow, "MGPipe: Fatal{EventRingOverflow} - %s could not reserve %llu bytes on an "
|
||||||
"emptied SEG_EVENT. The apply thread is SEG_EVENT's only producer, so a "
|
"emptied SEG_EVENT. The apply thread is SEG_EVENT's only producer, so a "
|
||||||
"drained ring that still refuses a record it fits is a corrupt cursor set",
|
"drained ring that still refuses a record it fits is a corrupt cursor set",
|
||||||
eventName, static_cast<unsigned long long>(payloadBytes));
|
eventName, static_cast<unsigned long long>(payloadBytes));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accept owns the single process callback table. Its owner need not be the
|
// Accept owns the single process callback table. Its owner need not be the
|
||||||
@@ -267,9 +267,8 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
ServerSession& ReverseCallbackOwner(const char* callback) {
|
ServerSession& ReverseCallbackOwner(const char* callback) {
|
||||||
auto* session = ServerSession::Active();
|
auto* session = ServerSession::Active();
|
||||||
if (session == nullptr) {
|
if (session == nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{RoleViolation, \"%s.session-missing\"} - "
|
SessionFail(MGFatalFamily::RoleViolation, "MGPipe: Fatal{RoleViolation, \"%s.session-missing\"} - "
|
||||||
"a reverse callback has no accepted session owner", callback);
|
"a reverse callback has no accepted session owner", callback);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
return *session;
|
return *session;
|
||||||
}
|
}
|
||||||
@@ -281,12 +280,11 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// The backend handed over a segment-tagged blobref. The ONLY legal shape at
|
// The backend handed over a segment-tagged blobref. The ONLY legal shape at
|
||||||
// this boundary is the monolith one - Offset is the mapped address, valid
|
// this boundary is the monolith one - Offset is the mapped address, valid
|
||||||
// for this call - because the segment copy is THIS function's own job.
|
// for this call - because the segment copy is THIS function's own job.
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"OnBufferWriteback.Seg\"} - the "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"OnBufferWriteback.Seg\"} - the "
|
||||||
"writeback producer was handed Seg %u; at the backend boundary the "
|
"writeback producer was handed Seg %u; at the backend boundary the "
|
||||||
"blobref names the backend's own mapped bytes (Seg = "
|
"blobref names the backend's own mapped bytes (Seg = "
|
||||||
"kMGHostSpanSegNone) and the copy into SEG_EVENT is the producer's",
|
"kMGHostSpanSegNone) and the copy into SEG_EVENT is the producer's",
|
||||||
bytes.Seg);
|
bytes.Seg);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
const Uint64 payloadBytes = sizeof(Transport::EventBufferWritebackHead) + bytes.Size;
|
const Uint64 payloadBytes = sizeof(Transport::EventBufferWritebackHead) + bytes.Size;
|
||||||
void* slot = ReserveEventOrBlock(session, Transport::kEventBufferWriteback,
|
void* slot = ReserveEventOrBlock(session, Transport::kEventBufferWriteback,
|
||||||
@@ -356,11 +354,10 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
template <typename Fn>
|
template <typename Fn>
|
||||||
void InstallReverseCallback(Fn& entry, Fn producer) {
|
void InstallReverseCallback(Fn& entry, Fn producer) {
|
||||||
if (entry != nullptr && entry != producer) {
|
if (entry != nullptr && entry != producer) {
|
||||||
MGLOG_F("MGPipe: Fatal{RoleViolation, \"callback-double-install\"} - a reverse "
|
SessionFail(MGFatalFamily::RoleViolation, "MGPipe: Fatal{RoleViolation, \"callback-double-install\"} - a reverse "
|
||||||
"MGPipeCallbacks entry is already claimed by a different function. With "
|
"MGPipeCallbacks entry is already claimed by a different function. With "
|
||||||
"an active transport the four reverse entries are the server "
|
"an active transport the four reverse entries are the server "
|
||||||
"session's producers; the client installs them under monolith only");
|
"session's producers; the client installs them under monolith only");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
entry = producer;
|
entry = producer;
|
||||||
}
|
}
|
||||||
@@ -383,6 +380,11 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
|
|
||||||
ServerSession* ServerSession::Active() { return g_active.load(std::memory_order_acquire); }
|
ServerSession* ServerSession::Active() { return g_active.load(std::memory_order_acquire); }
|
||||||
|
|
||||||
|
ServerSession::ServerSession() {
|
||||||
|
m_link = Transport::CreateSharedLink(Transport::TransportRoleTag::ServerConsumer);
|
||||||
|
m_commands = &m_link->CommandsIn(); m_events = &m_link->EventsOut();
|
||||||
|
}
|
||||||
|
|
||||||
ServerSession::~ServerSession() { Close(); }
|
ServerSession::~ServerSession() { Close(); }
|
||||||
|
|
||||||
void ServerSession::SetSegmentSizes(const Transport::SessionSegmentSizes& sizes) {
|
void ServerSession::SetSegmentSizes(const Transport::SessionSegmentSizes& sizes) {
|
||||||
@@ -418,14 +420,14 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
|
|
||||||
Bool ServerSession::Accepted() const { return m_accepted; }
|
Bool ServerSession::Accepted() const { return m_accepted; }
|
||||||
|
|
||||||
MobileGLResult ServerSession::Accept(Transport::ITransport& transport) {
|
MobileGLResult ServerSession::Accept(Transport::ITransport& transport,
|
||||||
|
const std::vector<Uint8>* firstFrame) {
|
||||||
ServerSession* expectedOwner = nullptr;
|
ServerSession* expectedOwner = nullptr;
|
||||||
if (!g_sessionOwner.compare_exchange_strong(expectedOwner, this,
|
if (!g_sessionOwner.compare_exchange_strong(expectedOwner, this,
|
||||||
std::memory_order_acq_rel, std::memory_order_acquire)) {
|
std::memory_order_acq_rel, std::memory_order_acquire)) {
|
||||||
if (expectedOwner == this) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
if (expectedOwner == this) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
MGLOG_F("MGPipe: Fatal{RoleViolation, \"callback-double-install\"} - another "
|
SessionFail(MGFatalFamily::RoleViolation, "MGPipe: Fatal{RoleViolation, \"callback-double-install\"} - another "
|
||||||
"ServerSession already owns or is accepting the process reverse channel");
|
"ServerSession already owns or is accepting the process reverse channel");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
struct ReleaseFailedClaim {
|
struct ReleaseFailedClaim {
|
||||||
ServerSession* self;
|
ServerSession* self;
|
||||||
@@ -447,7 +449,9 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// ---- 1/2. the ABI assertion, BEFORE a single record is decoded and before a byte of
|
// ---- 1/2. the ABI assertion, BEFORE a single record is decoded and before a byte of
|
||||||
// shared memory exists. Its whole purpose is to refuse to interpret the peer's bytes.
|
// shared memory exists. Its whole purpose is to refuse to interpret the peer's bytes.
|
||||||
std::vector<Uint8> frame;
|
std::vector<Uint8> frame;
|
||||||
const MobileGLResult received = ReceiveEnvelope(transport, frame, kHandshakeTimeoutMs);
|
if (firstFrame != nullptr) frame = *firstFrame;
|
||||||
|
const MobileGLResult received = firstFrame != nullptr ? MOBILEGL_OK
|
||||||
|
: ReceiveEnvelope(transport, frame, kHandshakeTimeoutMs);
|
||||||
if (received != MOBILEGL_OK) {
|
if (received != MOBILEGL_OK) {
|
||||||
MGLOG_E("MG_Remote server: no Hello within %u ms (rc=%d)", kHandshakeTimeoutMs,
|
MGLOG_E("MG_Remote server: no Hello within %u ms (rc=%d)", kHandshakeTimeoutMs,
|
||||||
static_cast<int>(received));
|
static_cast<int>(received));
|
||||||
@@ -462,57 +466,69 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
if (envelope == nullptr || envelope->msg_type() != ::MobileGL::Wire::CtrlMsg::Hello ||
|
if (envelope == nullptr || envelope->msg_type() != ::MobileGL::Wire::CtrlMsg::Hello ||
|
||||||
envelope->msg_as_Hello() == nullptr) {
|
envelope->msg_as_Hello() == nullptr) {
|
||||||
MGLOG_E("MG_Remote server: the first control frame is not a verifiable Hello");
|
MGLOG_E("MG_Remote server: the first control frame is not a verifiable Hello");
|
||||||
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::MalformedHello,
|
||||||
|
"first control frame is not a verifiable Hello");
|
||||||
}
|
}
|
||||||
const ::MobileGL::Wire::Hello* hello = envelope->msg_as_Hello();
|
const ::MobileGL::Wire::Hello* hello = envelope->msg_as_Hello();
|
||||||
const char* theirStamp =
|
const char* theirStamp =
|
||||||
hello->buildFingerprint() == nullptr ? nullptr : hello->buildFingerprint()->c_str();
|
hello->buildFingerprint() == nullptr ? nullptr : hello->buildFingerprint()->c_str();
|
||||||
|
|
||||||
if (hello->abiMajor() != static_cast<Uint32>(MOBILEGL_PROTOCOL_ABI_MAJOR) ||
|
if (hello->dialMode() != ::MobileGL::Wire::DialMode::No &&
|
||||||
hello->abiMinor() != static_cast<Uint32>(MOBILEGL_PROTOCOL_ABI_MINOR)) {
|
hello->dialMode() != ::MobileGL::Wire::DialMode::Fork &&
|
||||||
FatalAbiMismatch("protocol version",
|
hello->dialMode() != ::MobileGL::Wire::DialMode::Connect)
|
||||||
MOBILEGL_ABI_VERSION(MOBILEGL_PROTOCOL_ABI_MAJOR,
|
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::MalformedHello,
|
||||||
MOBILEGL_PROTOCOL_ABI_MINOR),
|
"unknown dial mode");
|
||||||
MOBILEGL_ABI_VERSION(hello->abiMajor(), hello->abiMinor()),
|
const MobileGLResult compatible = ValidatePeerHandshake(transport, hello->abiMajor(),
|
||||||
GIT_COMMIT_HASH_SHORT, theirStamp);
|
hello->abiMinor(), hello->wireFingerprint(), theirStamp, hello->dialMode());
|
||||||
}
|
if (compatible != MOBILEGL_OK) return compatible;
|
||||||
const Uint64 ourFingerprint = CapsAbiFingerprint();
|
const Uint64 ourFingerprint = WireFingerprint();
|
||||||
if (hello->abiFingerprint() != ourFingerprint) {
|
const auto* terms = hello->linkTerms();
|
||||||
FatalAbiMismatch("struct shapes", ourFingerprint, hello->abiFingerprint(),
|
if (terms == nullptr || terms->wireForm() != ::MobileGL::Wire::WireForm::StructImage ||
|
||||||
GIT_COMMIT_HASH_SHORT, theirStamp);
|
(terms->dataPlane() != ::MobileGL::Wire::DataPlane::SharedSegments &&
|
||||||
}
|
terms->dataPlane() != ::MobileGL::Wire::DataPlane::Stream))
|
||||||
|
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::LinkTerms,
|
||||||
|
"unsupported or missing link terms");
|
||||||
|
const bool stream = terms->dataPlane() == ::MobileGL::Wire::DataPlane::Stream;
|
||||||
|
if (stream && transport.Role() == Transport::TransportRole::InProcess)
|
||||||
|
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::LinkTerms,
|
||||||
|
"stream requires a data connection");
|
||||||
|
const char* expectedToken = std::getenv("MOBILEGL_IPC_TOKEN");
|
||||||
|
if (transport.Role() != Transport::TransportRole::InProcess && expectedToken != nullptr &&
|
||||||
|
expectedToken[0] != '\0' && (hello->token() == nullptr ||
|
||||||
|
std::strcmp(hello->token()->c_str(), expectedToken) != 0))
|
||||||
|
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::Authentication,
|
||||||
|
"token mismatch");
|
||||||
|
if (hello->backendType() >= static_cast<Uint32>(BackendType::BackendTypeCount) ||
|
||||||
|
(m_backend != nullptr && hello->backendType() != static_cast<Uint32>(m_backend->GetBackendType())))
|
||||||
|
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::Backend,
|
||||||
|
"backend request differs from server", m_backend == nullptr ? 0 :
|
||||||
|
static_cast<Uint32>(m_backend->GetBackendType()), hello->backendType());
|
||||||
|
|
||||||
// ---- 3. the four segments, both control pages, the rings.
|
// ---- 3. the four segments, both control pages, the rings.
|
||||||
const MobileGLResult created = m_shm.Create(m_sizes, Transport::MemoryRole::Server);
|
MobileGLResult created = MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
if (stream) {
|
||||||
|
auto* socket = dynamic_cast<Transport::SocketTransport*>(&transport);
|
||||||
|
if (socket && socket->IsTcp()) created = AttachStreamLink(socket->TakeDataFd(), m_sizes);
|
||||||
|
} else {
|
||||||
|
created = m_link->Memory().Create(m_sizes, Transport::MemoryRole::Server);
|
||||||
|
}
|
||||||
if (created != MOBILEGL_OK) {
|
if (created != MOBILEGL_OK) {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transport::RingControl* control = m_shm.CmdControl();
|
m_link->InitializeEndpoints();
|
||||||
m_commands = Transport::RingConsumer(control, m_shm.CmdRingBase(), m_shm.CmdRingCapacity(),
|
if (!m_commands->Valid()) {
|
||||||
Transport::RingCursorSet::Cmd);
|
|
||||||
if (!m_commands.Valid()) {
|
|
||||||
Close();
|
Close();
|
||||||
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
m_consumer.Attach(control, &m_commands, &ProducerDoorbell(), &ConsumerDoorbell(),
|
m_link->BindDoorbells(&ConsumerDoorbell(), &ProducerDoorbell());
|
||||||
SpinUsFromConfig());
|
m_consumer.Attach(*m_link, SpinUsFromConfig());
|
||||||
|
m_replies = ReplyPool();
|
||||||
|
m_replies.SetLink(m_link.get());
|
||||||
|
|
||||||
{
|
|
||||||
Transport::ReplySlotPool pool(m_shm.ReplyBase(), m_shm.ReplyBytes(),
|
|
||||||
m_shm.ReplySlotCount());
|
|
||||||
if (!pool.Valid()) {
|
|
||||||
Close();
|
|
||||||
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
|
||||||
}
|
|
||||||
// A stale stamp from a previous session must never read as this session's answer.
|
|
||||||
pool.Clear();
|
|
||||||
m_replies = ReplyPool(m_shm.ReplyBase(), m_shm.ReplyBytes(), m_shm.ReplySlotCount(),
|
|
||||||
pool.SlotBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
m_events = Transport::EventRingProducer(m_shm.EventControl(), control, m_shm.EventRingBase(),
|
m_consumer.SetLink(m_link->Capabilities().PublishIsDelivery ? nullptr : m_link.get());
|
||||||
m_shm.EventRingCapacity());
|
m_replies.SetLink(m_link.get());
|
||||||
m_applier = PipeApplier(&m_segments, &m_replies);
|
m_applier = PipeApplier(&m_segments, &m_replies);
|
||||||
|
|
||||||
// ---- 4. Welcome: the four SegmentRefs, plus this side's half of the ABI statement.
|
// ---- 4. Welcome: the four SegmentRefs, plus this side's half of the ABI statement.
|
||||||
@@ -521,17 +537,30 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
using Slot = Transport::SessionSegmentSlot;
|
using Slot = Transport::SessionSegmentSlot;
|
||||||
const auto segmentRef = [&](Uint32 id, ::MobileGL::Wire::SegmentKind kind, Slot slot) {
|
const auto segmentRef = [&](Uint32 id, ::MobileGL::Wire::SegmentKind kind, Slot slot) {
|
||||||
return ::MobileGL::Wire::CreateSegmentRefDirect(builder, id, kind,
|
return ::MobileGL::Wire::CreateSegmentRefDirect(builder, id, kind,
|
||||||
m_shm.AnnouncedSize(slot),
|
m_link->Memory().AnnouncedSize(slot),
|
||||||
m_shm.AnnouncedName(slot));
|
m_link->Memory().AnnouncedName(slot));
|
||||||
};
|
};
|
||||||
auto cmd = segmentRef(1, ::MobileGL::Wire::SegmentKind::Cmd, Slot::Cmd);
|
auto cmd = segmentRef(1, ::MobileGL::Wire::SegmentKind::Cmd, Slot::Cmd);
|
||||||
auto stage = segmentRef(2, ::MobileGL::Wire::SegmentKind::Stage, Slot::Stage);
|
auto stage = segmentRef(2, ::MobileGL::Wire::SegmentKind::Stage, Slot::Stage);
|
||||||
auto reply = segmentRef(3, ::MobileGL::Wire::SegmentKind::Reply, Slot::Reply);
|
auto reply = segmentRef(3, ::MobileGL::Wire::SegmentKind::Reply, Slot::Reply);
|
||||||
auto event = segmentRef(4, ::MobileGL::Wire::SegmentKind::Event, Slot::Event);
|
auto event = segmentRef(4, ::MobileGL::Wire::SegmentKind::Event, Slot::Event);
|
||||||
auto stamp = builder.CreateString(GIT_COMMIT_HASH_SHORT);
|
auto stamp = builder.CreateString(BuildFingerprint());
|
||||||
|
const Uint64 maxReply = m_sizes.ReplyBytes / m_sizes.ReplySlotCount - sizeof(Transport::ReplySlotHeader);
|
||||||
|
auto negotiated = ::MobileGL::Wire::CreateLinkTerms(builder, terms->dataPlane(),
|
||||||
|
::MobileGL::Wire::WireForm::StructImage, maxReply, m_link->Memory().CmdRingCapacity(),
|
||||||
|
m_link->Memory().StageBytes(), m_link->Memory().EventRingCapacity());
|
||||||
auto welcome = ::MobileGL::Wire::CreateWelcome(
|
auto welcome = ::MobileGL::Wire::CreateWelcome(
|
||||||
builder, MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR,
|
builder, MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR,
|
||||||
static_cast<Uint32>(hello->pid()), cmd, stage, reply, event, stamp, ourFingerprint);
|
// CONTRACT-P6 4.3: THE SERVER'S OWN PID, not an echo of the client's.
|
||||||
|
//
|
||||||
|
// This field echoed hello->pid() - which is itself hard-coded 0 - so serverPid
|
||||||
|
// was ALWAYS 0 and named nothing. §9.5's arm-proof gate wants the child pid and
|
||||||
|
// this is its natural carrier: under spawn it is the one value in the handshake
|
||||||
|
// that a same-process session cannot produce, because there the two pids are
|
||||||
|
// equal by construction.
|
||||||
|
static_cast<Uint32>(SelfProcessId()),
|
||||||
|
cmd, stage, reply, event, stamp, ourFingerprint, ourFingerprint, negotiated,
|
||||||
|
m_backend == nullptr ? hello->backendType() : static_cast<Uint32>(m_backend->GetBackendType()));
|
||||||
auto root = ::MobileGL::Wire::CreateCtrlEnvelope(
|
auto root = ::MobileGL::Wire::CreateCtrlEnvelope(
|
||||||
builder, ::MobileGL::Wire::CtrlMsg::Welcome, welcome.Union());
|
builder, ::MobileGL::Wire::CtrlMsg::Welcome, welcome.Union());
|
||||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, root);
|
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, root);
|
||||||
@@ -553,15 +582,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// w1 lands. That is deliberate and is where the bring-up currently stops: a session
|
// w1 lands. That is deliberate and is where the bring-up currently stops: a session
|
||||||
// that skipped them and carried on would be a decoder with no segments, which is the
|
// that skipped them and carried on would be a decoder with no segments, which is the
|
||||||
// "split lane ran monolith and went green" shape.
|
// "split lane ran monolith and went green" shape.
|
||||||
m_segments.Install(Wire::kSegCmd,
|
m_segments.AttachLink(m_link.get());
|
||||||
Wire::SegmentView{m_shm.CmdRingBase(), m_shm.CmdRingCapacity()});
|
|
||||||
m_segments.Install(Wire::kSegStage,
|
|
||||||
Wire::SegmentView{m_shm.StageBase(), m_shm.StageBytes()});
|
|
||||||
m_segments.Install(Wire::kSegReply,
|
|
||||||
Wire::SegmentView{m_shm.ReplyBase(), m_shm.ReplyBytes()});
|
|
||||||
m_segments.Install(Wire::kSegEvent, Wire::SegmentView{m_shm.EventSegmentBase(),
|
|
||||||
m_shm.AnnouncedSize(
|
|
||||||
Transport::SessionSegmentSlot::Event)});
|
|
||||||
m_segments.InstallProcessResolver();
|
m_segments.InstallProcessResolver();
|
||||||
|
|
||||||
m_accepted = true;
|
m_accepted = true;
|
||||||
@@ -653,6 +674,26 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
return SendEnvelope(*m_transport, builder);
|
return SendEnvelope(*m_transport, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobileGLResult ServerSession::AttachStreamLink(int fd, const Transport::SessionSegmentSizes& sizes) {
|
||||||
|
std::unique_ptr<Transport::ILink> link;
|
||||||
|
const auto attached = Transport::CreateStreamLink(fd, sizes, Transport::TransportRoleTag::ServerConsumer, link);
|
||||||
|
if (attached != MOBILEGL_OK) return attached;
|
||||||
|
AttachDataLink(std::move(link));
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerSession::AttachDataLink(std::unique_ptr<Transport::ILink> link) {
|
||||||
|
m_link = std::move(link);
|
||||||
|
m_commands = &m_link->CommandsIn(); m_events = &m_link->EventsOut();
|
||||||
|
m_consumer.SetLink(m_link->Capabilities().PublishIsDelivery ? nullptr : m_link.get());
|
||||||
|
m_replies.SetLink(m_link.get());
|
||||||
|
if (m_link) SetExternalDoorbells(&m_link->ConsumerBell(), &m_link->ProducerBell());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerSession::FlushDataProgress() {
|
||||||
|
if (m_link) m_link->FlushProgress();
|
||||||
|
}
|
||||||
|
|
||||||
void ServerSession::Close() {
|
void ServerSession::Close() {
|
||||||
ServerSession* expectedActive = this;
|
ServerSession* expectedActive = this;
|
||||||
g_active.compare_exchange_strong(expectedActive, nullptr,
|
g_active.compare_exchange_strong(expectedActive, nullptr,
|
||||||
@@ -677,10 +718,13 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_consumer.Detach();
|
m_consumer.Detach();
|
||||||
m_commands = Transport::RingConsumer();
|
*m_commands = Transport::RingConsumer();
|
||||||
m_events = Transport::EventRingProducer();
|
*m_events = Transport::EventRingProducer();
|
||||||
m_replies = ReplyPool();
|
m_replies = ReplyPool();
|
||||||
m_shm.Close();
|
m_link = Transport::CreateSharedLink(Transport::TransportRoleTag::ServerConsumer);
|
||||||
|
m_commands = &m_link->CommandsIn(); m_events = &m_link->EventsOut();
|
||||||
|
m_externalConsumerBell = nullptr; m_externalProducerBell = nullptr;
|
||||||
|
m_link->Memory().Close();
|
||||||
m_transport = nullptr;
|
m_transport = nullptr;
|
||||||
m_accepted = false;
|
m_accepted = false;
|
||||||
ServerSession* expectedOwner = this;
|
ServerSession* expectedOwner = this;
|
||||||
@@ -688,14 +732,13 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
std::memory_order_release, std::memory_order_relaxed);
|
std::memory_order_release, std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transport::RingConsumer& ServerSession::CommandRing() { return m_commands; }
|
Transport::RingConsumer& ServerSession::CommandRing() { return *m_commands; }
|
||||||
|
|
||||||
Transport::RingControl& ServerSession::Control() {
|
Transport::RingControl& ServerSession::Control() {
|
||||||
Transport::RingControl* control = m_shm.CmdControl();
|
Transport::RingControl* control = m_link->Memory().CmdControl();
|
||||||
if (control == nullptr) {
|
if (control == nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"ServerSession::Control\"} - the control "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"ServerSession::Control\"} - the control "
|
||||||
"page does not exist until Accept() has mapped SEG_CMD");
|
"page does not exist until Accept() has mapped SEG_CMD");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
return *control;
|
return *control;
|
||||||
}
|
}
|
||||||
@@ -706,11 +749,21 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
|
|
||||||
// The bell the apply thread parks on. On the server endpoint of an InProcessTransport that
|
// The bell the apply thread parks on. On the server endpoint of an InProcessTransport that
|
||||||
// is SelfDoorbell(); the client reaches the same bell through its own PeerDoorbell().
|
// is SelfDoorbell(); the client reaches the same bell through its own PeerDoorbell().
|
||||||
|
void ServerSession::SetExternalDoorbells(Transport::Doorbell* consumer,
|
||||||
|
Transport::Doorbell* producer) {
|
||||||
|
m_externalConsumerBell = consumer;
|
||||||
|
m_externalProducerBell = producer;
|
||||||
|
}
|
||||||
|
|
||||||
Transport::Doorbell& ServerSession::ConsumerDoorbell() {
|
Transport::Doorbell& ServerSession::ConsumerDoorbell() {
|
||||||
|
// sm: injected first, because a spawn session's bells are sockets the
|
||||||
|
// entry point made and the transport has never heard of.
|
||||||
|
if (m_externalConsumerBell != nullptr) {
|
||||||
|
return *m_externalConsumerBell;
|
||||||
|
}
|
||||||
if (m_transport == nullptr) {
|
if (m_transport == nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"ServerSession::ConsumerDoorbell\"} - no "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"ServerSession::ConsumerDoorbell\"} - no "
|
||||||
"transport; Accept() has not run");
|
"transport; Accept() has not run");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (m_transport->Role() == Transport::TransportRole::InProcess) {
|
if (m_transport->Role() == Transport::TransportRole::InProcess) {
|
||||||
return static_cast<Transport::InProcessTransport*>(m_transport)->SelfDoorbell();
|
return static_cast<Transport::InProcessTransport*>(m_transport)->SelfDoorbell();
|
||||||
@@ -718,30 +771,30 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// P6: SocketTransport's pair. The accessors stay off ITransport by ruling (contract
|
// P6: SocketTransport's pair. The accessors stay off ITransport by ruling (contract
|
||||||
// §3.9) precisely so that this stays one switch in one file rather than two virtuals
|
// §3.9) precisely so that this stays one switch in one file rather than two virtuals
|
||||||
// every transport has to invent a home for.
|
// every transport has to invent a home for.
|
||||||
MGLOG_F("MGPipe: Fatal{UnmigratedVerb, \"ServerSession::ConsumerDoorbell\"} - transport "
|
SessionFail(MGFatalFamily::UnmigratedVerb, "MGPipe: Fatal{UnmigratedVerb, \"ServerSession::ConsumerDoorbell\"} - transport "
|
||||||
"role %u has no doorbell pair yet; that is P6's SocketTransport",
|
"role %u has no doorbell pair yet; that is P6's SocketTransport",
|
||||||
static_cast<unsigned>(m_transport->Role()));
|
static_cast<unsigned>(m_transport->Role()));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Transport::Doorbell& ServerSession::ProducerDoorbell() {
|
Transport::Doorbell& ServerSession::ProducerDoorbell() {
|
||||||
|
if (m_externalProducerBell != nullptr) {
|
||||||
|
return *m_externalProducerBell;
|
||||||
|
}
|
||||||
if (m_transport == nullptr) {
|
if (m_transport == nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"ServerSession::ProducerDoorbell\"} - no "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"ServerSession::ProducerDoorbell\"} - no "
|
||||||
"transport; Accept() has not run");
|
"transport; Accept() has not run");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (m_transport->Role() == Transport::TransportRole::InProcess) {
|
if (m_transport->Role() == Transport::TransportRole::InProcess) {
|
||||||
return static_cast<Transport::InProcessTransport*>(m_transport)->PeerDoorbell();
|
return static_cast<Transport::InProcessTransport*>(m_transport)->PeerDoorbell();
|
||||||
}
|
}
|
||||||
MGLOG_F("MGPipe: Fatal{UnmigratedVerb, \"ServerSession::ProducerDoorbell\"} - transport "
|
SessionFail(MGFatalFamily::UnmigratedVerb, "MGPipe: Fatal{UnmigratedVerb, \"ServerSession::ProducerDoorbell\"} - transport "
|
||||||
"role %u has no doorbell pair yet; that is P6's SocketTransport",
|
"role %u has no doorbell pair yet; that is P6's SocketTransport",
|
||||||
static_cast<unsigned>(m_transport->Role()));
|
static_cast<unsigned>(m_transport->Role()));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Transport::SessionSegments& ServerSession::Shm() { return m_shm; }
|
Transport::SessionSegments& ServerSession::Shm() { return m_link->Memory(); }
|
||||||
Transport::SessionConsumer& ServerSession::Consumer() { return m_consumer; }
|
Transport::SessionConsumer& ServerSession::Consumer() { return m_consumer; }
|
||||||
Transport::EventRingProducer& ServerSession::Events() { return m_events; }
|
Transport::EventRingProducer& ServerSession::Events() { return *m_events; }
|
||||||
Transport::ITransport* ServerSession::Control_Plane() { return m_transport; }
|
Transport::ITransport* ServerSession::Control_Plane() { return m_transport; }
|
||||||
|
|
||||||
void ServerSession::PublishEvents() {
|
void ServerSession::PublishEvents() {
|
||||||
@@ -750,8 +803,9 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
}
|
}
|
||||||
// Publish, THEN ring - the same order as the forward direction, and the session picks
|
// Publish, THEN ring - the same order as the forward direction, and the session picks
|
||||||
// the bell so that no caller can pair the right ring with the wrong flag.
|
// the bell so that no caller can pair the right ring with the wrong flag.
|
||||||
m_events.Ring().Publish();
|
m_events->Ring().Publish();
|
||||||
m_consumer.NotifyClient();
|
m_consumer.NotifyClient();
|
||||||
|
FlushDataProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerSession::PostGlError(Uint32 code, const char* message) {
|
void ServerSession::PostGlError(Uint32 code, const char* message) {
|
||||||
@@ -793,13 +847,16 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_consumer.CompleteFrame(serial);
|
m_consumer.CompleteFrame(serial);
|
||||||
|
FlushDataProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerSession::ReturnPresentCredit(Uint64 serial) {
|
void ServerSession::ReturnPresentCredit(Uint64 serial) {
|
||||||
if (!m_accepted) {
|
if (!m_accepted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Transport::LinkMetricsServerPresent(serial);
|
||||||
m_consumer.ReturnPresentCredit(serial);
|
m_consumer.ReturnPresentCredit(serial);
|
||||||
|
FlushDataProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
Transport::RoleMemorySample ServerSession::SampleMemory() const {
|
Transport::RoleMemorySample ServerSession::SampleMemory() const {
|
||||||
|
|||||||
@@ -40,7 +40,9 @@
|
|||||||
// refused to exist until both landed would block every other package's bring-up.
|
// refused to exist until both landed would block every other package's bring-up.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "../Transport/ILink.h"
|
||||||
#include <Includes.h>
|
#include <Includes.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <MG_Pipe/MGPipe.h>
|
#include <MG_Pipe/MGPipe.h>
|
||||||
|
|
||||||
@@ -60,13 +62,19 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
public:
|
public:
|
||||||
static ServerSession* Active();
|
static ServerSession* Active();
|
||||||
|
|
||||||
|
ServerSession();
|
||||||
~ServerSession();
|
~ServerSession();
|
||||||
|
MobileGLResult AttachStreamLink(int dataFd, const Transport::SessionSegmentSizes& sizes);
|
||||||
|
void AttachDataLink(std::unique_ptr<Transport::ILink> link);
|
||||||
|
Transport::ILink* DataLink() const { return m_link.get(); }
|
||||||
|
void FlushDataProgress();
|
||||||
|
|
||||||
// Maps the four segments, answers Hello with Welcome, and publishes the first
|
// Maps the four segments, answers Hello with Welcome, and publishes the first
|
||||||
// CapsSnapshot. The ABI assertion (CapsCodec.h) happens HERE, before a single record is
|
// CapsSnapshot. The ABI assertion (CapsCodec.h) happens HERE, before a single record is
|
||||||
// decoded: sizeof(DynamicBackendParameters), sizeof(MGPCaps), sizeof(GLFunctionsTable)
|
// decoded: sizeof(DynamicBackendParameters), sizeof(MGPCaps), sizeof(GLFunctionsTable)
|
||||||
// and the build fingerprint must match, and a mismatch is Fatal{AbiMismatch}.
|
// and the build fingerprint must match, and a mismatch is Fatal{AbiMismatch}.
|
||||||
MobileGLResult Accept(Transport::ITransport& transport);
|
MobileGLResult Accept(Transport::ITransport& transport,
|
||||||
|
const std::vector<Uint8>* firstFrame = nullptr);
|
||||||
|
|
||||||
// Re-publishes the whole snapshot. R-12: a SECOND arrival IS the invalidation signal,
|
// Re-publishes the whole snapshot. R-12: a SECOND arrival IS the invalidation signal,
|
||||||
// which is how DirectGLES - which has no OnCapsInvalidated producer - tells the client
|
// which is how DirectGLES - which has no OnCapsInvalidated producer - tells the client
|
||||||
@@ -82,11 +90,27 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
ReplyPool& Replies();
|
ReplyPool& Replies();
|
||||||
|
|
||||||
// The client rings this one; the apply thread parks on it.
|
// The client rings this one; the apply thread parks on it.
|
||||||
|
// P6 `sm`: the bells a spawn session parks on, injected because they do
|
||||||
|
// not come from the transport. CONTRACT-P5 §3.9 kept these accessors on
|
||||||
|
// the session precisely so this would be ONE switch in ONE file rather
|
||||||
|
// than two virtuals on every transport - and the switch it produced
|
||||||
|
// aborts for every role but InProcess, which is where a spawn apply
|
||||||
|
// thread died before popping its first record (a6 row A7-1).
|
||||||
|
//
|
||||||
|
// This is the narrow fix, not the general one: `lk` moves both bells
|
||||||
|
// behind ILink and DELETES these accessors, which is what CONTRACT-P6
|
||||||
|
// §8.1 means by retiring the ruling rather than amending it. Until then
|
||||||
|
// an injected pair is honest about where they come from, and the
|
||||||
|
// InProcess arm below is untouched.
|
||||||
|
void SetExternalDoorbells(Transport::Doorbell* consumer, Transport::Doorbell* producer);
|
||||||
|
|
||||||
Transport::Doorbell& ConsumerDoorbell();
|
Transport::Doorbell& ConsumerDoorbell();
|
||||||
// The server rings this one, but only when producerParked is set (a store to a shared
|
// The server rings this one, but only when producerParked is set (a store to a shared
|
||||||
// cache line otherwise burns a big core for a whole frame on a phone).
|
// cache line otherwise burns a big core for a whole frame on a phone).
|
||||||
Transport::Doorbell& ProducerDoorbell();
|
Transport::Doorbell& ProducerDoorbell();
|
||||||
|
|
||||||
|
bool HasExternalDoorbells() const { return m_externalConsumerBell != nullptr; }
|
||||||
|
|
||||||
// ---- s1's additions beyond c0's signature block ---------------------------------
|
// ---- s1's additions beyond c0's signature block ---------------------------------
|
||||||
|
|
||||||
// The sizes to create the segments with. Must be called before Accept; after it, the
|
// The sizes to create the segments with. Must be called before Accept; after it, the
|
||||||
@@ -183,14 +207,17 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
void LogMemory(const char* phase) const;
|
void LogMemory(const char* phase) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Transport::RingConsumer m_commands;
|
std::unique_ptr<Transport::ILink> m_link;
|
||||||
|
// sm: non-owning; the spawn entry point owns the SocketDoorbells.
|
||||||
|
Transport::Doorbell* m_externalConsumerBell = nullptr;
|
||||||
|
Transport::Doorbell* m_externalProducerBell = nullptr;
|
||||||
|
Transport::RingConsumer* m_commands = nullptr;
|
||||||
Wire::SegmentTable m_segments;
|
Wire::SegmentTable m_segments;
|
||||||
PipeApplier m_applier;
|
PipeApplier m_applier;
|
||||||
ReplyPool m_replies;
|
ReplyPool m_replies;
|
||||||
|
|
||||||
Transport::SessionSegments m_shm;
|
|
||||||
Transport::SessionConsumer m_consumer;
|
Transport::SessionConsumer m_consumer;
|
||||||
Transport::EventRingProducer m_events;
|
Transport::EventRingProducer* m_events = nullptr;
|
||||||
Transport::ITransport* m_transport = nullptr;
|
Transport::ITransport* m_transport = nullptr;
|
||||||
MG_Backend::BackendObject* m_backend = nullptr;
|
MG_Backend::BackendObject* m_backend = nullptr;
|
||||||
Transport::SessionSegmentSizes m_sizes;
|
Transport::SessionSegmentSizes m_sizes;
|
||||||
|
|||||||
@@ -0,0 +1,319 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Remote/Server/ServerSpawn.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
|
||||||
|
|
||||||
|
#include "ServerSpawn.h"
|
||||||
|
|
||||||
|
#include "../Transport/FdPassing.h"
|
||||||
|
#include "../Transport/WireLog.h"
|
||||||
|
|
||||||
|
#include <Config.h>
|
||||||
|
|
||||||
|
#include <cerrno>
|
||||||
|
#include <cstring>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#if defined(__unix__) || defined(__APPLE__) || defined(__ANDROID__)
|
||||||
|
# define MOBILEGL_SERVER_SPAWN_POSIX 1
|
||||||
|
# include <dirent.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
# include <dlfcn.h>
|
||||||
|
# include <sys/socket.h>
|
||||||
|
# include <sys/stat.h>
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <sys/wait.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
#else
|
||||||
|
# define MOBILEGL_SERVER_SPAWN_POSIX 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote::Server {
|
||||||
|
|
||||||
|
#if MOBILEGL_SERVER_SPAWN_POSIX
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr int kChildStreamFd = 3;
|
||||||
|
constexpr int kChildAuxFd = 4;
|
||||||
|
constexpr int kChildServerBellFd = 5;
|
||||||
|
constexpr int kChildClientBellFd = 6;
|
||||||
|
|
||||||
|
bool IsExecutableFile(const std::string& path) {
|
||||||
|
if (path.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
struct stat st {};
|
||||||
|
if (::stat(path.c_str(), &st) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return S_ISREG(st.st_mode) && ::access(path.c_str(), X_OK) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MOBILEGL_IPC_SERVER_PATH, then dladdr beside our own library.
|
||||||
|
// The fallback exists because the integration tests link MobileGL_s
|
||||||
|
// statically and trace replay's executable does not live in the library
|
||||||
|
// directory - ARCHITECTURE.md §15.1 names both.
|
||||||
|
std::string ResolveImage(const std::string& requested) {
|
||||||
|
if (!requested.empty()) {
|
||||||
|
return requested; // caller's explicit choice; validated below
|
||||||
|
}
|
||||||
|
const std::string configured(MG_Config::Ipc.ServerPath.c_str());
|
||||||
|
if (!configured.empty()) {
|
||||||
|
return configured;
|
||||||
|
}
|
||||||
|
Dl_info info{};
|
||||||
|
if (::dladdr(reinterpret_cast<void*>(&ResolveImage), &info) != 0 &&
|
||||||
|
info.dli_fname != nullptr) {
|
||||||
|
const std::string self(info.dli_fname);
|
||||||
|
const std::size_t slash = self.find_last_of('/');
|
||||||
|
if (slash != std::string::npos) {
|
||||||
|
return self.substr(0, slash + 1) + "libMobileGLServer.so";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every MOBILEGL_TRANSPORT and MOBILEGL_IPC_* goes. Built BEFORE fork:
|
||||||
|
// between fork and execve only async-signal-safe calls are allowed, and
|
||||||
|
// allocating a vector of strings is not one of them.
|
||||||
|
bool ShouldScrub(const char* entry) {
|
||||||
|
static constexpr const char* kPrefixes[] = {"MOBILEGL_TRANSPORT=", "MOBILEGL_IPC_"};
|
||||||
|
for (const char* prefix : kPrefixes) {
|
||||||
|
if (std::strncmp(entry, prefix, std::strlen(prefix)) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ScrubbedEnv {
|
||||||
|
std::vector<std::string> storage;
|
||||||
|
std::vector<char*> pointers; // NULL-terminated, valid while `storage` lives
|
||||||
|
int removed = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
ScrubbedEnv BuildChildEnv(const std::string& imageDir) {
|
||||||
|
// `environ` is glibc/bionic's, declared by <unistd.h> at global
|
||||||
|
// scope. Re-declaring it inside this anonymous namespace made it a
|
||||||
|
// NEW symbol that nothing defines - which the linker caught, and
|
||||||
|
// which is worth a comment because the error names a mangled name
|
||||||
|
// that looks nothing like the variable.
|
||||||
|
ScrubbedEnv env;
|
||||||
|
for (char** e = ::environ; e != nullptr && *e != nullptr; ++e) {
|
||||||
|
if (ShouldScrub(*e)) {
|
||||||
|
++env.removed;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
env.storage.emplace_back(*e);
|
||||||
|
}
|
||||||
|
// (a) of the two catches: the child is told, structurally, that it
|
||||||
|
// must not dial. Separate from which ROLE it plays - CONTRACT-P6
|
||||||
|
// §3.1 is the whole argument for why those are two axes.
|
||||||
|
env.storage.emplace_back("MOBILEGL_IPC_ROLE=server");
|
||||||
|
env.storage.emplace_back("MOBILEGL_IPC_DIAL=no");
|
||||||
|
// LD_LIBRARY_PATH, BECAUSE THE SERVER IS EXEC'd AND NOT dlopen'd.
|
||||||
|
//
|
||||||
|
// It links libMobileGL.so, and an exec'd process gets a FRESH linker
|
||||||
|
// namespace with the default search path - not the one the app built
|
||||||
|
// for its own libraries. An APK's lib/<abi>/ is not on that path, and
|
||||||
|
// the failure is total and immediate:
|
||||||
|
//
|
||||||
|
// CANNOT LINK EXECUTABLE ".../libMobileGLServer.so":
|
||||||
|
// library "libMobileGL.so" not found: needed by main executable
|
||||||
|
//
|
||||||
|
// It is invisible on desktop, where CMake gives build-tree targets an
|
||||||
|
// absolute RPATH of their own - so the WSL server had been resolving
|
||||||
|
// its dependency through a path no phone has.
|
||||||
|
//
|
||||||
|
// $ORIGIN WOULD BE THE TIDIER ANSWER and the target asks for it, but
|
||||||
|
// the NDK toolchain drops RPATH from the link: measured with readelf
|
||||||
|
// on the APK's own copy, which carries NEEDED libMobileGL.so and no
|
||||||
|
// RUNPATH at all. So the launcher states it instead - it is the one
|
||||||
|
// component that has already resolved where the image lives, and a
|
||||||
|
// pair that is not co-located is not a pair.
|
||||||
|
if (!imageDir.empty()) {
|
||||||
|
env.storage.emplace_back("LD_LIBRARY_PATH=" + imageDir);
|
||||||
|
}
|
||||||
|
env.pointers.reserve(env.storage.size() + 1);
|
||||||
|
for (auto& entry : env.storage) {
|
||||||
|
env.pointers.push_back(entry.data());
|
||||||
|
}
|
||||||
|
env.pointers.push_back(nullptr);
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
int CountOwnChildren() {
|
||||||
|
const pid_t self = ::getpid();
|
||||||
|
DIR* proc = ::opendir("/proc");
|
||||||
|
if (proc == nullptr) {
|
||||||
|
return -1; // not Linux-shaped; the gate must say so rather than read 0
|
||||||
|
}
|
||||||
|
int children = 0;
|
||||||
|
while (const dirent* entry = ::readdir(proc)) {
|
||||||
|
if (entry->d_name[0] < '0' || entry->d_name[0] > '9') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::string statPath = std::string("/proc/") + entry->d_name + "/stat";
|
||||||
|
FILE* file = std::fopen(statPath.c_str(), "r");
|
||||||
|
if (file == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// `comm` can contain spaces and parentheses, so parse from the LAST
|
||||||
|
// ')' rather than by field index - the classic /proc/pid/stat trap.
|
||||||
|
char buffer[512] = {};
|
||||||
|
const std::size_t read = std::fread(buffer, 1, sizeof(buffer) - 1, file);
|
||||||
|
std::fclose(file);
|
||||||
|
if (read == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const char* close = std::strrchr(buffer, ')');
|
||||||
|
if (close == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int ppid = 0;
|
||||||
|
char state = 0;
|
||||||
|
if (std::sscanf(close + 1, " %c %d", &state, &ppid) == 2 && ppid == self) {
|
||||||
|
++children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
::closedir(proc);
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult LaunchServer(const std::string& imagePath, const std::string& endpoint,
|
||||||
|
LaunchedServer* out) {
|
||||||
|
if (out == nullptr || endpoint.empty()) {
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
*out = LaunchedServer{};
|
||||||
|
|
||||||
|
const std::string image = ResolveImage(imagePath);
|
||||||
|
if (!IsExecutableFile(image)) {
|
||||||
|
// NAMED, never a fallback. ConfigLoader.cpp's own comment names the
|
||||||
|
// accident this prevents: a lane that asked for spawn, silently got
|
||||||
|
// monolith, and went green on the wrong arm.
|
||||||
|
Transport::WireLogError(
|
||||||
|
"MG_Remote spawn: the server image is not executable: \"%s\" - refusing. Set "
|
||||||
|
"MOBILEGL_IPC_SERVER_PATH, or place libMobileGLServer.so beside libMobileGL.so. "
|
||||||
|
"There is NO monolith fallback from here.",
|
||||||
|
image.empty() ? "<unresolved>" : image.c_str());
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The image's directory, which is where its libMobileGL.so is.
|
||||||
|
const std::string::size_type slash = image.find_last_of('/');
|
||||||
|
ScrubbedEnv env =
|
||||||
|
BuildChildEnv(slash == std::string::npos ? std::string() : image.substr(0, slash));
|
||||||
|
std::string argv0 = image;
|
||||||
|
std::string argv1 = endpoint;
|
||||||
|
char* argv[] = {argv0.data(), argv1.data(), nullptr};
|
||||||
|
|
||||||
|
// A close-on-exec pipe so an execve that fails reports its errno back
|
||||||
|
// instead of vanishing: the app process's stderr is /dev/null on Android
|
||||||
|
// (ARCHITECTURE.md §15.2), so a silent exec failure would look exactly
|
||||||
|
// like a server that started and then died.
|
||||||
|
int report[2] = {-1, -1};
|
||||||
|
if (::pipe(report) != 0) {
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
::fcntl(report[1], F_SETFD, FD_CLOEXEC);
|
||||||
|
|
||||||
|
const pid_t pid = ::fork();
|
||||||
|
if (pid < 0) {
|
||||||
|
Transport::WireLogError("MG_Remote spawn: fork failed: %s", std::strerror(errno));
|
||||||
|
::close(report[0]);
|
||||||
|
::close(report[1]);
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pid == 0) {
|
||||||
|
// ---- child: async-signal-safe calls ONLY until execve -------------
|
||||||
|
// NOTHING IS HANDED OVER. No dup2, no fixed fd numbers, no
|
||||||
|
// close-on-exec dance - the child gets an endpoint name in argv and
|
||||||
|
// finds everything else by listening. That is the whole difference
|
||||||
|
// between a launcher and a fork-coupled pair, and it is why this
|
||||||
|
// function is now twenty lines shorter than the version that tried
|
||||||
|
// to be both.
|
||||||
|
::close(report[0]);
|
||||||
|
::execve(image.c_str(), argv, env.pointers.data());
|
||||||
|
const int failure = errno;
|
||||||
|
const ssize_t ignored = ::write(report[1], &failure, sizeof(failure));
|
||||||
|
(void)ignored;
|
||||||
|
::_exit(127);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- parent ---------------------------------------------------------
|
||||||
|
::close(report[1]);
|
||||||
|
int childErrno = 0;
|
||||||
|
const ssize_t got = ::read(report[0], &childErrno, sizeof(childErrno));
|
||||||
|
::close(report[0]);
|
||||||
|
if (got == static_cast<ssize_t>(sizeof(childErrno))) {
|
||||||
|
Transport::WireLogError("MG_Remote spawn: execve(\"%s\") failed in the child: %s",
|
||||||
|
image.c_str(), std::strerror(childErrno));
|
||||||
|
int status = 0;
|
||||||
|
::waitpid(pid, &status, 0);
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
out->pid = static_cast<int>(pid);
|
||||||
|
out->endpoint = endpoint;
|
||||||
|
Transport::WireLogError("MG_Remote spawn: server pid=%d image=\"%s\" endpoint=\"%s\" "
|
||||||
|
"transport=spawn (env scrubbed: %d entries removed)",
|
||||||
|
out->pid, image.c_str(), endpoint.c_str(), env.removed);
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult ReapServer(LaunchedServer& server, std::uint32_t timeoutMs,
|
||||||
|
int* outExitCode) {
|
||||||
|
if (server.pid < 0) {
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
// NOTHING TO CLOSE HERE ANY MORE. The launcher holds no descriptor
|
||||||
|
// into the child: whoever owns the CONNECTION closes it, and that EOF is
|
||||||
|
// what the child exits on. A launcher that also owned the connection is
|
||||||
|
// what made the two processes one unit.
|
||||||
|
|
||||||
|
const auto deadline = timeoutMs;
|
||||||
|
std::uint32_t waited = 0;
|
||||||
|
for (;;) {
|
||||||
|
int status = 0;
|
||||||
|
const pid_t done = ::waitpid(server.pid, &status, WNOHANG);
|
||||||
|
if (done == server.pid) {
|
||||||
|
if (outExitCode != nullptr) {
|
||||||
|
*outExitCode = WIFEXITED(status) ? WEXITSTATUS(status) : -WTERMSIG(status);
|
||||||
|
}
|
||||||
|
server.pid = -1;
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
if (done < 0) {
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
if (waited >= deadline) {
|
||||||
|
return MOBILEGL_ERR_TIMEOUT;
|
||||||
|
}
|
||||||
|
::usleep(1000);
|
||||||
|
waited += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // !MOBILEGL_SERVER_SPAWN_POSIX
|
||||||
|
|
||||||
|
MobileGLResult LaunchServer(const std::string&, const std::string&, LaunchedServer*) {
|
||||||
|
Transport::WireLogError("MG_Remote spawn: unsupported on this platform - P6 lands POSIX only "
|
||||||
|
"(CONTRACT-P6 §2.6); there is no fork() to build a second process from");
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
MobileGLResult ReapServer(LaunchedServer&, std::uint32_t, int*) {
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
int CountOwnChildren() { return -1; }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace MobileGL::MG_Remote::Server
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Remote/Server/ServerSpawn.h
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// LAUNCHING a server process, and the process discipline around it.
|
||||||
|
// Package `sm` (CONTRACT-P6.md §3).
|
||||||
|
//
|
||||||
|
// IT LAUNCHES; IT DOES NOT COUPLE. The two processes are independent: this
|
||||||
|
// hands the child an endpoint NAME and nothing else - no inherited descriptors,
|
||||||
|
// no shared memory, no handshake. The child listens on that name and the client
|
||||||
|
// connects to it, exactly as it would to a server someone started by hand or
|
||||||
|
// that an Android Service started minutes earlier.
|
||||||
|
//
|
||||||
|
// An earlier shape of this file forked the server and handed it fds 3..6.
|
||||||
|
// Inheritance works and is less code, but it can only ever produce a server
|
||||||
|
// that is a CHILD OF ITS CLIENT - which the end state cannot use, because there
|
||||||
|
// the server is a standing application and the client is elsewhere, possibly on
|
||||||
|
// another kernel. So fork/execve survives here only as A WAY TO START A
|
||||||
|
// PROCESS, which is all it ever needed to be, and every fd it used to carry is
|
||||||
|
// gone.
|
||||||
|
//
|
||||||
|
// ANTI-RECURSION IS STILL TWO INDEPENDENT CATCHES, and CONTRACT-P6 §3.1 is why
|
||||||
|
// neither is ARCHITECTURE.md:488's. That rule says the child hard-sets
|
||||||
|
// Transport to Monolith; a6 measured that 226 live lines test
|
||||||
|
// `Transport != Monolith` to select the SERVER arm, 148 of them in MG_Backend,
|
||||||
|
// so obeying it flips the whole backend to frontend glue in the one process
|
||||||
|
// with no frontend. Instead:
|
||||||
|
// (a) STRUCTURAL: MOBILEGL_IPC_DIAL=no, a separate axis from which role the
|
||||||
|
// process plays;
|
||||||
|
// (b) ENVIRONMENTAL: MOBILEGL_TRANSPORT and every MOBILEGL_IPC_* removed
|
||||||
|
// from the child's envp.
|
||||||
|
// The child refuses with exit 64 for (a) and 65 for (b), so the two safeties
|
||||||
|
// are distinguishable - two that cannot be told apart are one.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Includes.h>
|
||||||
|
|
||||||
|
#include "../Protocol/mg_protocol_base.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote::Server {
|
||||||
|
|
||||||
|
struct LaunchedServer {
|
||||||
|
// -1 when nothing was spawned. Non-negative means this process owes the
|
||||||
|
// child a wait(): a SpawnedServer that goes out of scope without being
|
||||||
|
// reaped leaves a zombie, which is exactly what the process-tree gate
|
||||||
|
// (CONTRACT-P6 §9.4) counts.
|
||||||
|
// -1 when nothing was launched. Non-negative means this process owes the
|
||||||
|
// child a wait(): a LaunchedServer that goes out of scope unreaped leaves
|
||||||
|
// a zombie, which is what the process-tree gate (§9.4) counts.
|
||||||
|
int pid = -1;
|
||||||
|
// The endpoint the child was told to listen on. The launcher's only
|
||||||
|
// output besides the pid: everything else the client needs, it gets by
|
||||||
|
// connecting.
|
||||||
|
std::string endpoint;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Locates the server image and starts it on `endpoint`. Returns as soon as
|
||||||
|
// the process exists; the client's bounded connect retry is what waits for
|
||||||
|
// it to finish binding (SocketTransport::ConnectTo).
|
||||||
|
//
|
||||||
|
// `imagePath` empty means "resolve it": MOBILEGL_IPC_SERVER_PATH first, then
|
||||||
|
// dladdr on our own library to find libMobileGLServer.so beside it. An
|
||||||
|
// unresolvable path is a NAMED REFUSAL and never a monolith fallback -
|
||||||
|
// ConfigLoader.cpp names that accident and this is the code that must not
|
||||||
|
// repeat it.
|
||||||
|
MobileGLResult LaunchServer(const std::string& imagePath, const std::string& endpoint,
|
||||||
|
LaunchedServer* out);
|
||||||
|
|
||||||
|
// Waits for the child, up to `timeoutMs`. Returns MOBILEGL_ERR_TIMEOUT if it
|
||||||
|
// is still running, in which case the caller decides whether to escalate -
|
||||||
|
// this function never signals a child it did not have to.
|
||||||
|
MobileGLResult ReapServer(LaunchedServer& server, std::uint32_t timeoutMs, int* outExitCode);
|
||||||
|
|
||||||
|
// How many children this process currently has, by scanning for our own
|
||||||
|
// pid as a parent. The process-tree gate needs a number, not a promise:
|
||||||
|
// "exactly one while running, zero after".
|
||||||
|
int CountOwnChildren();
|
||||||
|
|
||||||
|
} // namespace MobileGL::MG_Remote::Server
|
||||||
@@ -23,7 +23,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
case SurfaceControlOp::SetSwapInterval: return "SetSwapInterval";
|
case SurfaceControlOp::SetSwapInterval: return "SetSwapInterval";
|
||||||
case SurfaceControlOp::ReleaseResources: return "ReleaseResources";
|
case SurfaceControlOp::ReleaseResources: return "ReleaseResources";
|
||||||
case SurfaceControlOp::SetWindowHandle: return "SetWindowHandle";
|
case SurfaceControlOp::SetWindowHandle: return "SetWindowHandle";
|
||||||
case SurfaceControlOp::InitCapabilitiesInprocOnly: return "InitCapabilitiesInprocOnly";
|
case SurfaceControlOp::InitCapabilities: return "InitCapabilities";
|
||||||
case SurfaceControlOp::SwapBuffersInprocOnly: return "SwapBuffersInprocOnly";
|
case SurfaceControlOp::SwapBuffersInprocOnly: return "SwapBuffersInprocOnly";
|
||||||
case SurfaceControlOp::InitWindowSurfaceInprocOnly: return "InitWindowSurfaceInprocOnly";
|
case SurfaceControlOp::InitWindowSurfaceInprocOnly: return "InitWindowSurfaceInprocOnly";
|
||||||
case SurfaceControlOp::ProbeForTesting: return "ProbeForTesting";
|
case SurfaceControlOp::ProbeForTesting: return "ProbeForTesting";
|
||||||
@@ -43,6 +43,10 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
case SurfaceControlOp::SetSwapInterval:
|
case SurfaceControlOp::SetSwapInterval:
|
||||||
case SurfaceControlOp::ReleaseResources:
|
case SurfaceControlOp::ReleaseResources:
|
||||||
case SurfaceControlOp::SetWindowHandle:
|
case SurfaceControlOp::SetWindowHandle:
|
||||||
|
// cp: the request half of InitCapabilities. Its ANSWER is a CapsSnapshot
|
||||||
|
// frame, which is why this row was missing; the request still has to
|
||||||
|
// cross, because under spawn the apply thread is in another process.
|
||||||
|
case SurfaceControlOp::InitCapabilities:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -55,12 +55,18 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
SetSwapInterval = 8,
|
SetSwapInterval = 8,
|
||||||
ReleaseResources = 9,
|
ReleaseResources = 9,
|
||||||
SetWindowHandle = 10,
|
SetWindowHandle = 10,
|
||||||
|
// P6 (cp) MOVED THIS ONE ONTO THE WIRE, and the old name was a lie the
|
||||||
|
// moment spawn existed. f0-egl reasoned that the wire's ANSWER to
|
||||||
|
// InitCapabilities is the CapsSnapshot frame, which is true and beside
|
||||||
|
// the point: the REQUEST still has to reach the apply thread, and under
|
||||||
|
// spawn that thread is in another process. Measured before the fix -
|
||||||
|
// every spawned eglMakeCurrent died at "surface op kind 11 cannot cross
|
||||||
|
// the wire (InprocOnlyOpOnTheWire)", one call after the backend came up.
|
||||||
|
InitCapabilities = 11,
|
||||||
// INPROC-ONLY kinds: legal inside this process's frame channel, NEVER encodable onto the
|
// INPROC-ONLY kinds: legal inside this process's frame channel, NEVER encodable onto the
|
||||||
// wire (SurfaceOpCodec refuses them by name). f0-egl's census found no production caller
|
// wire (SurfaceOpCodec refuses them by name). f0-egl's census found no production caller
|
||||||
// for the two dead forwarders and a CapsSnapshot answer for the third; they ride the same
|
// for the two dead forwarders; they ride the same frame channel because the
|
||||||
// frame channel because the function-pointer mailbox is GONE, not because they are wire
|
// function-pointer mailbox is GONE, not because they are wire ops.
|
||||||
// ops.
|
|
||||||
InitCapabilitiesInprocOnly = 11, // the wire's answer is the CapsSnapshot frame itself
|
|
||||||
SwapBuffersInprocOnly = 12, // present travels as a record (the class-B Present emitter)
|
SwapBuffersInprocOnly = 12, // present travels as a record (the class-B Present emitter)
|
||||||
InitWindowSurfaceInprocOnly = 13,// a client-side no-op; kept for the inproc test lane
|
InitWindowSurfaceInprocOnly = 13,// a client-side no-op; kept for the inproc test lane
|
||||||
ProbeForTesting = 14, // MG_Test's arbitrary-work seam through the same channel
|
ProbeForTesting = 14, // MG_Test's arbitrary-work seam through the same channel
|
||||||
@@ -90,6 +96,7 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
Bool ok = false;
|
Bool ok = false;
|
||||||
Int eglMajor = 0;
|
Int eglMajor = 0;
|
||||||
Int eglMinor = 0;
|
Int eglMinor = 0;
|
||||||
|
Uint64 eventHead = 0; // data-plane delivery fence carried by SurfaceReply
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
@@ -104,14 +111,15 @@ namespace MobileGL::MG_Remote::Server {
|
|||||||
// Exhaustive by the language's aggregate decomposition rule: adding ANY member
|
// Exhaustive by the language's aggregate decomposition rule: adding ANY member
|
||||||
// without extending this binding is a compile error, so new fields cannot evade it.
|
// without extending this binding is a compile error, so new fields cannot evade it.
|
||||||
const auto& [kind, seq, display, surface, readSurface, context, windowBackend,
|
const auto& [kind, seq, display, surface, readSurface, context, windowBackend,
|
||||||
nativeToken, width, height, swapInterval, ok, eglMajor, eglMinor] = frame;
|
nativeToken, width, height, swapInterval, ok, eglMajor, eglMinor, eventHead] = frame;
|
||||||
return IsSurfaceControlValue<decltype(kind)> && IsSurfaceControlValue<decltype(seq)> &&
|
return IsSurfaceControlValue<decltype(kind)> && IsSurfaceControlValue<decltype(seq)> &&
|
||||||
IsSurfaceControlValue<decltype(display)> && IsSurfaceControlValue<decltype(surface)> &&
|
IsSurfaceControlValue<decltype(display)> && IsSurfaceControlValue<decltype(surface)> &&
|
||||||
IsSurfaceControlValue<decltype(readSurface)> && IsSurfaceControlValue<decltype(context)> &&
|
IsSurfaceControlValue<decltype(readSurface)> && IsSurfaceControlValue<decltype(context)> &&
|
||||||
IsSurfaceControlValue<decltype(windowBackend)> && IsSurfaceControlValue<decltype(nativeToken)> &&
|
IsSurfaceControlValue<decltype(windowBackend)> && IsSurfaceControlValue<decltype(nativeToken)> &&
|
||||||
IsSurfaceControlValue<decltype(width)> && IsSurfaceControlValue<decltype(height)> &&
|
IsSurfaceControlValue<decltype(width)> && IsSurfaceControlValue<decltype(height)> &&
|
||||||
IsSurfaceControlValue<decltype(swapInterval)> && IsSurfaceControlValue<decltype(ok)> &&
|
IsSurfaceControlValue<decltype(swapInterval)> && IsSurfaceControlValue<decltype(ok)> &&
|
||||||
IsSurfaceControlValue<decltype(eglMajor)> && IsSurfaceControlValue<decltype(eglMinor)>;
|
IsSurfaceControlValue<decltype(eglMajor)> && IsSurfaceControlValue<decltype(eglMinor)> &&
|
||||||
|
IsSurfaceControlValue<decltype(eventHead)>;
|
||||||
}
|
}
|
||||||
} // namespace Detail
|
} // namespace Detail
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
#include "ControlInbox.h"
|
||||||
|
#include "Doorbell.h"
|
||||||
|
#include "../Protocol/SurfaceOpCodec.h"
|
||||||
|
#include <MG_Util/Debug/Log.h>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
|
ControlInbox::ControlInbox(ITransport& transport) : m_transport(transport), m_reader([this] { Read(); }) {}
|
||||||
|
ControlInbox::~ControlInbox() { Stop(); }
|
||||||
|
|
||||||
|
void ControlInbox::Stop() {
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
m_stop = true;
|
||||||
|
m_cv.notify_all();
|
||||||
|
}
|
||||||
|
// Receive uses a short bounded wait, so no shutdown of the data plane is needed.
|
||||||
|
if (m_reader.joinable()) m_reader.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlInbox::Read() {
|
||||||
|
for (;;) {
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
if (m_stop) return;
|
||||||
|
}
|
||||||
|
std::uint64_t size = 0;
|
||||||
|
auto result = m_transport.ReceiveFrame({nullptr, 0}, &size, 100);
|
||||||
|
if (result == MOBILEGL_ERR_TIMEOUT) continue;
|
||||||
|
std::vector<std::uint8_t> frame;
|
||||||
|
if (result == MOBILEGL_ERR_BUFFER_TOO_SMALL && size <= 64ull * 1024 * 1024) {
|
||||||
|
frame.resize(static_cast<std::size_t>(size));
|
||||||
|
result = m_transport.ReceiveFrame({frame.data(), frame.size()}, &size, 0);
|
||||||
|
}
|
||||||
|
if (result == MOBILEGL_OK) {
|
||||||
|
flatbuffers::Verifier verifier(frame.data(), frame.size());
|
||||||
|
if (!::MobileGL::Wire::VerifyCtrlEnvelopeBuffer(verifier)) result = MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
|
else {
|
||||||
|
const auto* envelope = ::MobileGL::Wire::GetCtrlEnvelope(frame.data());
|
||||||
|
if (const auto* log = envelope->msg_as_LogLine()) {
|
||||||
|
if (log->text()) MG_Util::Debug::WritePeerLog(log->text()->c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
if (result != MOBILEGL_OK) {
|
||||||
|
m_result = result;
|
||||||
|
m_cv.notify_all();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_cv.wait(lock, [&] { return m_stop || (m_frames.size() < 256 && m_bytes < 64ull * 1024 * 1024); });
|
||||||
|
if (m_stop) return;
|
||||||
|
m_bytes += frame.size();
|
||||||
|
m_frames.push_back(std::move(frame));
|
||||||
|
m_cv.notify_all();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult ControlInbox::Receive(std::vector<std::uint8_t>& frame, std::uint32_t timeoutMs) {
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
const auto ready = [&] { return m_stop || !m_frames.empty() || m_result != MOBILEGL_OK; };
|
||||||
|
if (timeoutMs == kWaitForever) m_cv.wait(lock, ready);
|
||||||
|
else if (!m_cv.wait_for(lock, std::chrono::milliseconds(timeoutMs), ready)) return MOBILEGL_ERR_TIMEOUT;
|
||||||
|
if (m_frames.empty()) return m_result == MOBILEGL_OK ? MOBILEGL_ERR_TRANSPORT_CLOSED : m_result;
|
||||||
|
frame = std::move(m_frames.front());
|
||||||
|
m_frames.pop_front();
|
||||||
|
m_bytes -= frame.size();
|
||||||
|
m_cv.notify_all();
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uint64_t ControlInbox::Peek() {
|
||||||
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
return m_frames.empty() ? 0 : m_frames.front().size();
|
||||||
|
}
|
||||||
|
bool ControlInbox::WaitClosed(std::uint32_t timeoutMs) {
|
||||||
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
// Teardown has no outstanding control caller; discard queued snapshots
|
||||||
|
// so the reader can always reach EOF through its bounded inbox.
|
||||||
|
const auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeoutMs);
|
||||||
|
for (;;) {
|
||||||
|
m_frames.clear();
|
||||||
|
m_bytes = 0;
|
||||||
|
m_cv.notify_all();
|
||||||
|
if (m_result != MOBILEGL_OK || m_stop) return true;
|
||||||
|
if (m_cv.wait_until(lock, deadline) == std::cv_status::timeout) return m_result != MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ITransport.h"
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <deque>
|
||||||
|
#include <mutex>
|
||||||
|
#include <thread>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
|
// The control reader remains runnable while the GL thread waits on data.
|
||||||
|
// Log forwarding can therefore never fill a socket and block the applier.
|
||||||
|
class ControlInbox {
|
||||||
|
public:
|
||||||
|
explicit ControlInbox(ITransport& transport);
|
||||||
|
~ControlInbox();
|
||||||
|
void Stop();
|
||||||
|
MobileGLResult Receive(std::vector<std::uint8_t>& frame, std::uint32_t timeoutMs);
|
||||||
|
std::uint64_t Peek();
|
||||||
|
bool WaitClosed(std::uint32_t timeoutMs);
|
||||||
|
private:
|
||||||
|
void Read();
|
||||||
|
ITransport& m_transport;
|
||||||
|
std::mutex m_mutex;
|
||||||
|
std::condition_variable m_cv;
|
||||||
|
std::deque<std::vector<std::uint8_t>> m_frames;
|
||||||
|
std::uint64_t m_bytes = 0;
|
||||||
|
bool m_stop = false;
|
||||||
|
MobileGLResult m_result = MOBILEGL_OK;
|
||||||
|
std::thread m_reader;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -22,6 +22,22 @@
|
|||||||
|
|
||||||
// Same fallback as FdPassing.cpp: on macOS / BSD the protection is SO_NOSIGPIPE on the
|
// Same fallback as FdPassing.cpp: on macOS / BSD the protection is SO_NOSIGPIPE on the
|
||||||
// socket, set in SocketDoorbell's constructor, not a per-send flag.
|
// socket, set in SocketDoorbell's constructor, not a per-send flag.
|
||||||
|
// THE WITNESS'S `events`, and the whole reason it can watch a socket it must not read.
|
||||||
|
//
|
||||||
|
// POLLRDHUP is what Linux and bionic report when the PEER shuts down its writing end - the exact
|
||||||
|
// fact the death witness wants - and asking for it alone means poll never reports POLLIN for that
|
||||||
|
// descriptor, so unread control replies queued on it can neither wake this bell nor be consumed
|
||||||
|
// from under SocketTransport's reassembler. POLLHUP / POLLERR / POLLNVAL arrive in revents whether
|
||||||
|
// requested or not, so an 0 here would still catch a full close; POLLRDHUP only makes the
|
||||||
|
// half-close case - the one a dying peer actually produces first - visible too.
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
#if defined(POLLRDHUP)
|
||||||
|
#define MOBILEGL_POLL_PEER_HANGUP POLLRDHUP
|
||||||
|
#else
|
||||||
|
#define MOBILEGL_POLL_PEER_HANGUP 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(MSG_NOSIGNAL)
|
#if !defined(_WIN32) && !defined(MSG_NOSIGNAL)
|
||||||
#define MSG_NOSIGNAL 0
|
#define MSG_NOSIGNAL 0
|
||||||
#endif
|
#endif
|
||||||
@@ -212,7 +228,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
SocketDoorbell::SocketDoorbell(int fd, std::uint8_t code, bool ownsFd)
|
SocketDoorbell::SocketDoorbell(int fd, std::uint8_t code, bool ownsFd)
|
||||||
: m_fd(fd), m_code(code), m_ownsFd(ownsFd) {
|
: m_fd(fd), m_notifyFd(fd), m_code(code), m_ownsFd(ownsFd) {
|
||||||
#if defined(SO_NOSIGPIPE)
|
#if defined(SO_NOSIGPIPE)
|
||||||
// The per-socket form of MSG_NOSIGNAL, on the platforms that lack the per-call one:
|
// The per-socket form of MSG_NOSIGNAL, on the platforms that lack the per-call one:
|
||||||
// a Notify to a hung-up peer must come back as EPIPE, not as a fatal signal.
|
// a Notify to a hung-up peer must come back as EPIPE, not as a fatal signal.
|
||||||
@@ -223,19 +239,44 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The two-fd form: park on one descriptor, ring another. See the header for
|
||||||
|
// why the server needs it and the cross-process form cannot provide it.
|
||||||
|
SocketDoorbell::SocketDoorbell(int parkFd, int notifyFd, std::uint8_t code, bool ownsFds)
|
||||||
|
: m_fd(parkFd), m_notifyFd(notifyFd), m_code(code), m_ownsFd(ownsFds) {
|
||||||
|
#if defined(SO_NOSIGPIPE)
|
||||||
|
for (int fd : {m_fd, m_notifyFd}) {
|
||||||
|
if (fd >= 0) {
|
||||||
|
const int one = 1;
|
||||||
|
(void)::setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof(one));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
SocketDoorbell::~SocketDoorbell() {
|
SocketDoorbell::~SocketDoorbell() {
|
||||||
if (m_ownsFd && m_fd >= 0) {
|
if (!m_ownsFd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_fd >= 0) {
|
||||||
::close(m_fd);
|
::close(m_fd);
|
||||||
}
|
}
|
||||||
|
// Only when they are different: the single-fd form has m_notifyFd == m_fd
|
||||||
|
// and closing it twice is a double close, which on a busy process closes
|
||||||
|
// somebody else's descriptor rather than failing.
|
||||||
|
if (m_notifyFd >= 0 && m_notifyFd != m_fd) {
|
||||||
|
::close(m_notifyFd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SocketDoorbell::Notify() {
|
void SocketDoorbell::Notify() {
|
||||||
if (m_fd < 0) {
|
// The NOTIFY descriptor, not the park one: a ring-only bell has no park
|
||||||
|
// fd at all and must still be able to ring.
|
||||||
|
if (m_notifyFd < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const std::uint8_t byte = m_code;
|
const std::uint8_t byte = m_code;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const ssize_t written = ::send(m_fd, &byte, 1, MSG_DONTWAIT | MSG_NOSIGNAL);
|
const ssize_t written = ::send(m_notifyFd, &byte, 1, MSG_DONTWAIT | MSG_NOSIGNAL);
|
||||||
if (written == 1) {
|
if (written == 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -250,7 +291,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
if (written < 0 && (errno == EPIPE || errno == ECONNRESET)) {
|
if (written < 0 && (errno == EPIPE || errno == ECONNRESET)) {
|
||||||
// The peer is gone: it can never ring back either, so latch it
|
// The peer is gone: it can never ring back either, so latch it
|
||||||
// here too rather than waiting for a Park to discover it.
|
// here too rather than waiting for a Park to discover it.
|
||||||
m_dead = true;
|
m_dead.store(true, std::memory_order_release);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MGLOG_D("MG_Remote doorbell: send failed (errno=%d)", errno);
|
MGLOG_D("MG_Remote doorbell: send failed (errno=%d)", errno);
|
||||||
@@ -259,7 +300,12 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SocketDoorbell::Park(std::uint32_t timeoutMs) {
|
bool SocketDoorbell::Park(std::uint32_t timeoutMs) {
|
||||||
if (m_fd < 0 || m_dead) {
|
// A ring-only bell was never a waiter. Saying so immediately is the
|
||||||
|
// honest answer; blocking forever on -1 would be a hang with no cause.
|
||||||
|
if (m_fd < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (m_fd < 0 || m_dead.load(std::memory_order_acquire)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto start = std::chrono::steady_clock::now();
|
const auto start = std::chrono::steady_clock::now();
|
||||||
@@ -272,10 +318,22 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
const long long remaining = static_cast<long long>(timeoutMs) - elapsed;
|
const long long remaining = static_cast<long long>(timeoutMs) - elapsed;
|
||||||
pollTimeout = remaining <= 0 ? 0 : static_cast<int>(remaining);
|
pollTimeout = remaining <= 0 ? 0 : static_cast<int>(remaining);
|
||||||
}
|
}
|
||||||
struct pollfd pfd{};
|
// THE WITNESS ASKS FOR HANGUP AND NOTHING ELSE. POLLHUP/POLLERR/POLLNVAL are
|
||||||
pfd.fd = m_fd;
|
// reported in revents whether or not they were requested, so an `events` of
|
||||||
pfd.events = POLLIN;
|
// POLLRDHUP alone gets the peer's shutdown and never POLLIN - which is the whole
|
||||||
const int ready = ::poll(&pfd, 1, pollTimeout);
|
// point: the control socket legitimately carries unread REPLY bytes, and asking for
|
||||||
|
// readability there would make every queued reply a wakeup, spin this loop, and race
|
||||||
|
// SocketTransport's reassembler for the same bytes. Nothing is ever recv'd from it.
|
||||||
|
struct pollfd pfds[2]{};
|
||||||
|
pfds[0].fd = m_fd;
|
||||||
|
pfds[0].events = POLLIN;
|
||||||
|
const bool watching = m_witnessFd >= 0;
|
||||||
|
if (watching) {
|
||||||
|
pfds[1].fd = m_witnessFd;
|
||||||
|
pfds[1].events = MOBILEGL_POLL_PEER_HANGUP;
|
||||||
|
}
|
||||||
|
const int ready = ::poll(pfds, watching ? 2 : 1, pollTimeout);
|
||||||
|
struct pollfd& pfd = pfds[0];
|
||||||
if (ready < 0) {
|
if (ready < 0) {
|
||||||
if (errno == EINTR) {
|
if (errno == EINTR) {
|
||||||
continue; // a signal is not a wakeup; keep the deadline
|
continue; // a signal is not a wakeup; keep the deadline
|
||||||
@@ -286,6 +344,20 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
if (ready == 0) {
|
if (ready == 0) {
|
||||||
return false; // timed out
|
return false; // timed out
|
||||||
}
|
}
|
||||||
|
// THE WITNESS FIRST, because a peer that is gone makes every other answer stale. It
|
||||||
|
// reports only hangup shapes by construction, so any revent on it IS the death.
|
||||||
|
if (watching && pfds[1].revents != 0) {
|
||||||
|
MGLOG_I("MG_Remote doorbell: the peer hung up (witness fd %d, revents=0x%X) - "
|
||||||
|
"this is the DEATH FACT, taken from a descriptor and not from a "
|
||||||
|
"deadline: a server one frame behind is the intended steady state and "
|
||||||
|
"must never be mistaken for one that is gone (CONTRACT-P6 5.4)",
|
||||||
|
m_witnessFd, static_cast<unsigned>(pfds[1].revents));
|
||||||
|
// THE CAUSE BEFORE THE FACT, so a reader that sees Dead() can never find
|
||||||
|
// PeerHungUp() still false and conclude "orderly teardown".
|
||||||
|
m_peerHungUp.store(true, std::memory_order_release);
|
||||||
|
m_dead.store(true, std::memory_order_release);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// revents has to be inspected, not just `ready > 0`. Once the peer
|
// revents has to be inspected, not just `ready > 0`. Once the peer
|
||||||
// closes its end the descriptor is permanently poll-ready with
|
// closes its end the descriptor is permanently poll-ready with
|
||||||
// nothing to read (measured on Linux: revents=POLLIN|POLLHUP,
|
// nothing to read (measured on Linux: revents=POLLIN|POLLHUP,
|
||||||
@@ -296,14 +368,14 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
if ((pfd.revents & (POLLERR | POLLNVAL)) != 0) {
|
if ((pfd.revents & (POLLERR | POLLNVAL)) != 0) {
|
||||||
MGLOG_D("MG_Remote doorbell: fd %d unusable (revents=0x%X)", m_fd,
|
MGLOG_D("MG_Remote doorbell: fd %d unusable (revents=0x%X)", m_fd,
|
||||||
static_cast<unsigned>(pfd.revents));
|
static_cast<unsigned>(pfd.revents));
|
||||||
m_dead = true;
|
m_dead.store(true, std::memory_order_release);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((pfd.revents & POLLIN) != 0) {
|
if ((pfd.revents & POLLIN) != 0) {
|
||||||
if (Drain() != 0) {
|
if (Drain() != 0) {
|
||||||
return true; // a real wakeup byte
|
return true; // a real wakeup byte
|
||||||
}
|
}
|
||||||
if (m_dead) {
|
if (m_dead.load(std::memory_order_acquire)) {
|
||||||
return false; // EOF, not an event
|
return false; // EOF, not an event
|
||||||
}
|
}
|
||||||
// Ready but empty and still alive: someone else drained it.
|
// Ready but empty and still alive: someone else drained it.
|
||||||
@@ -311,7 +383,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((pfd.revents & POLLHUP) != 0) {
|
if ((pfd.revents & POLLHUP) != 0) {
|
||||||
m_dead = true;
|
m_dead.store(true, std::memory_order_release);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Readiness with no bit we requested or recognise: there is
|
// Readiness with no bit we requested or recognise: there is
|
||||||
@@ -319,7 +391,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// poll this descriptor again.
|
// poll this descriptor again.
|
||||||
MGLOG_D("MG_Remote doorbell: fd %d ready with revents=0x%X", m_fd,
|
MGLOG_D("MG_Remote doorbell: fd %d ready with revents=0x%X", m_fd,
|
||||||
static_cast<unsigned>(pfd.revents));
|
static_cast<unsigned>(pfd.revents));
|
||||||
m_dead = true;
|
m_dead.store(true, std::memory_order_release);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,7 +410,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
if (got == 0) {
|
if (got == 0) {
|
||||||
// Orderly shutdown on a stream socket: the peer is gone and
|
// Orderly shutdown on a stream socket: the peer is gone and
|
||||||
// will never ring again.
|
// will never ring again.
|
||||||
m_dead = true;
|
m_dead.store(true, std::memory_order_release);
|
||||||
return consumed;
|
return consumed;
|
||||||
}
|
}
|
||||||
if (errno == EINTR) {
|
if (errno == EINTR) {
|
||||||
@@ -348,13 +420,13 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
return consumed; // drained
|
return consumed; // drained
|
||||||
}
|
}
|
||||||
MGLOG_D("MG_Remote doorbell: recv failed (errno=%d)", errno);
|
MGLOG_D("MG_Remote doorbell: recv failed (errno=%d)", errno);
|
||||||
m_dead = true;
|
m_dead.store(true, std::memory_order_release);
|
||||||
return consumed;
|
return consumed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SocketDoorbell::Reset() {
|
void SocketDoorbell::Reset() {
|
||||||
if (m_fd < 0 || m_dead) {
|
if (m_fd < 0 || m_dead.load(std::memory_order_acquire)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(void)Drain();
|
(void)Drain();
|
||||||
|
|||||||
@@ -171,6 +171,17 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// bell that cannot die.
|
// bell that cannot die.
|
||||||
virtual bool Dead() const { return false; }
|
virtual bool Dead() const { return false; }
|
||||||
|
|
||||||
|
// P6 `dl`: DEAD AND DEAD-BECAUSE-THE-PEER-DIED ARE NOT THE SAME FACT, and only the
|
||||||
|
// second one is a device loss. Dead() is also true after an ORDERLY teardown -
|
||||||
|
// CondVarDoorbell::Kill() is how Stop() wakes a parked applier, and the barrier reports
|
||||||
|
// SessionWait::ShutDown for that too. Latching device-lost from Dead() would therefore
|
||||||
|
// arm it on every clean exit.
|
||||||
|
//
|
||||||
|
// This says the peer HUNG UP: a descriptor whose far end only the peer held reported
|
||||||
|
// hangup. Nothing this side did can produce it. False for every doorbell that has no
|
||||||
|
// peer process, which is what makes the whole latch a no-op under inproc and monolith.
|
||||||
|
virtual bool PeerHungUp() const { return false; }
|
||||||
|
|
||||||
// How many Wait() calls on this bell exhausted their spin budget and
|
// How many Wait() calls on this bell exhausted their spin budget and
|
||||||
// really blocked. THE WAIT LEDGER'S RAW READING: the pair (waits, parks)
|
// really blocked. THE WAIT LEDGER'S RAW READING: the pair (waits, parks)
|
||||||
// is what says whether the spin budget is sized for the workload, and it
|
// is what says whether the spin budget is sized for the workload, and it
|
||||||
@@ -397,15 +408,52 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// When `ownsFd` the descriptor is closed with this object. `code` is
|
// When `ownsFd` the descriptor is closed with this object. `code` is
|
||||||
// the byte written by Notify.
|
// the byte written by Notify.
|
||||||
SocketDoorbell(int fd, std::uint8_t code, bool ownsFd);
|
SocketDoorbell(int fd, std::uint8_t code, bool ownsFd);
|
||||||
|
|
||||||
|
// P6: PARK AND NOTIFY ON DIFFERENT DESCRIPTORS.
|
||||||
|
//
|
||||||
|
// The single-fd form above is the cross-process one: send() on this end
|
||||||
|
// is delivered to the PEER's end, so the peer's own SocketDoorbell is
|
||||||
|
// what receives it. That is correct, and it is also why the single-fd
|
||||||
|
// form cannot wake ITSELF - and the server needs exactly that, because
|
||||||
|
// its control pump posts into the apply thread's mailbox and must ring
|
||||||
|
// the bell that thread is parked on. Under inproc CondVarDoorbell has no
|
||||||
|
// such split: notify and wait are the same object.
|
||||||
|
//
|
||||||
|
// So: `parkFd` is polled, `notifyFd` is written. For a socketpair where
|
||||||
|
// this side holds both ends they are [0] and [1], and a peer that must
|
||||||
|
// also be able to ring it gets a DUP of [1]. `parkFd` may be -1 for a
|
||||||
|
// bell this side only ever RINGS - Park then returns immediately, which
|
||||||
|
// is the honest answer for an object that was never a waiter.
|
||||||
|
SocketDoorbell(int parkFd, int notifyFd, std::uint8_t code, bool ownsFds);
|
||||||
~SocketDoorbell() override;
|
~SocketDoorbell() override;
|
||||||
|
|
||||||
void Notify() override;
|
void Notify() override;
|
||||||
bool Park(std::uint32_t timeoutMs) override;
|
bool Park(std::uint32_t timeoutMs) override;
|
||||||
void Reset() override;
|
void Reset() override;
|
||||||
bool Dead() const override { return m_dead; }
|
bool Dead() const override { return m_dead.load(std::memory_order_acquire); }
|
||||||
|
bool PeerHungUp() const override { return m_peerHungUp.load(std::memory_order_acquire); }
|
||||||
|
|
||||||
int Fd() const { return m_fd; }
|
int Fd() const { return m_fd; }
|
||||||
|
|
||||||
|
// P6 `dl` (CONTRACT-P6 D5c). THE DESCRIPTOR THAT ANSWERS "IS THE PEER STILL THERE",
|
||||||
|
// which for this object can never be the one it parks on.
|
||||||
|
//
|
||||||
|
// The client parks on clientBell[0] and rings ITSELF through clientBell[1], so it holds
|
||||||
|
// BOTH ends of that socketpair. EOF arrives only when every writer closes and the client
|
||||||
|
// is one of them, so that descriptor cannot hang up no matter what happens to the server.
|
||||||
|
// A bell that can wake itself is a bell that cannot hear a death. Measured: a server that
|
||||||
|
// died on its first Clear left the client waiting out the full 120 s barrier and
|
||||||
|
// reporting Fatal{BarrierTimeout} - the wrong diagnosis, two minutes late.
|
||||||
|
//
|
||||||
|
// The witness is a descriptor whose FAR END ONLY THE PEER HOLDS - in practice the control
|
||||||
|
// socket. It is NOT OWNED here and is NEVER READ FROM: Park adds it to the poll set with
|
||||||
|
// `events` asking for hangup ALONE, so a control reply sitting unread in its queue cannot
|
||||||
|
// wake the bell and cannot be consumed from under SocketTransport's reassembler. What it
|
||||||
|
// contributes is exactly one fact, and only once: the peer is gone.
|
||||||
|
//
|
||||||
|
// -1 disables it, which is what every bell that has no peer socket uses.
|
||||||
|
void SetDeathWitness(int fd) { m_witnessFd = fd; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Consumes every queued wakeup byte and returns how many. Latches
|
// Consumes every queued wakeup byte and returns how many. Latches
|
||||||
// m_dead on EOF: recv returning 0 on a stream socket is the peer's
|
// m_dead on EOF: recv returning 0 on a stream socket is the peer's
|
||||||
@@ -413,10 +461,18 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// afterwards.
|
// afterwards.
|
||||||
std::uint64_t Drain();
|
std::uint64_t Drain();
|
||||||
|
|
||||||
int m_fd;
|
int m_fd; // polled
|
||||||
|
int m_notifyFd; // written; equals m_fd in the single-fd (cross-process) form
|
||||||
|
int m_witnessFd = -1; // polled for hangup only; NOT owned, NEVER read
|
||||||
|
// Set ONLY by the witness branch of Park, never by Kill or by our own EOF. See
|
||||||
|
// Doorbell::PeerHungUp for why the distinction is the whole design.
|
||||||
|
std::atomic<bool> m_peerHungUp{false};
|
||||||
std::uint8_t m_code;
|
std::uint8_t m_code;
|
||||||
bool m_ownsFd;
|
bool m_ownsFd;
|
||||||
bool m_dead = false;
|
// ATOMIC BECAUSE THE LATCH READS IT ACROSS THREADS. Park() runs on whichever thread is
|
||||||
|
// waiting; the device-lost latch is consulted from the GL thread and from
|
||||||
|
// glGetGraphicsResetStatus. It was a plain bool while Dead() had no cross-thread reader.
|
||||||
|
std::atomic<bool> m_dead{false};
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// finished with every payload pointer it popped: a writeback's bytes live
|
// finished with every payload pointer it popped: a writeback's bytes live
|
||||||
// in the ring itself, so retiring early is the R-11 violation one level
|
// in the ring itself, so retiring early is the R-11 violation one level
|
||||||
// down.
|
// down.
|
||||||
|
void SetLink(ILink* link) { m_link = link; }
|
||||||
void Drained() {
|
void Drained() {
|
||||||
m_consumer.PublishRetired();
|
m_consumer.PublishRetired();
|
||||||
if (m_cmdControl != nullptr) {
|
if (m_cmdControl != nullptr) {
|
||||||
@@ -202,6 +203,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
NotifyIfParked(*m_serverBell, m_cmdControl->consumerParked);
|
NotifyIfParked(*m_serverBell, m_cmdControl->consumerParked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (m_link) m_link->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The bell the SERVER parks on, lent by the session so that Drained() can ring it.
|
// The bell the SERVER parks on, lent by the session so that Drained() can ring it.
|
||||||
@@ -231,6 +233,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RingControl* m_cmdControl = nullptr;
|
RingControl* m_cmdControl = nullptr;
|
||||||
|
ILink* m_link = nullptr;
|
||||||
RingConsumer m_consumer;
|
RingConsumer m_consumer;
|
||||||
const std::uint8_t* m_segmentBase = nullptr;
|
const std::uint8_t* m_segmentBase = nullptr;
|
||||||
// P5e (ra): the server's bell, rung by Drained() when it cleared a full latch.
|
// P5e (ra): the server's bell, rung by Drained() when it cleared a full latch.
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// Incremental frame extractor over a raw byte stream.
|
// Incremental frame extractor over a raw byte stream.
|
||||||
class FrameReader {
|
class FrameReader {
|
||||||
public:
|
public:
|
||||||
|
explicit FrameReader(std::uint32_t expectedMagic = kFrameMagic) : m_expectedMagic(expectedMagic) {}
|
||||||
|
|
||||||
// Feeds raw stream bytes. Validates the frame header the moment enough
|
// Feeds raw stream bytes. Validates the frame header the moment enough
|
||||||
// bytes for one exist - a bad magic or an oversized length is reported
|
// bytes for one exist - a bad magic or an oversized length is reported
|
||||||
// here, not swallowed.
|
// here, not swallowed.
|
||||||
@@ -163,11 +165,11 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
std::uint32_t length = 0;
|
std::uint32_t length = 0;
|
||||||
std::memcpy(&magic, m_buffer.data() + m_readPos, sizeof(magic));
|
std::memcpy(&magic, m_buffer.data() + m_readPos, sizeof(magic));
|
||||||
std::memcpy(&length, m_buffer.data() + m_readPos + 4, sizeof(length));
|
std::memcpy(&length, m_buffer.data() + m_readPos + 4, sizeof(length));
|
||||||
if (magic != kFrameMagic) {
|
if (magic != m_expectedMagic) {
|
||||||
m_failed = true;
|
m_failed = true;
|
||||||
WireLogError("MG_Remote framing: bad frame magic 0x%08X (expected 0x%08X); the "
|
WireLogError("MG_Remote framing: bad frame magic 0x%08X (expected 0x%08X); the "
|
||||||
"control stream is desynchronized and this transport is now dead",
|
"control stream is desynchronized and this transport is now dead",
|
||||||
magic, kFrameMagic);
|
magic, m_expectedMagic);
|
||||||
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
}
|
}
|
||||||
if (length > kMaxFramePayloadSize) {
|
if (length > kMaxFramePayloadSize) {
|
||||||
@@ -203,6 +205,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
std::uint64_t m_pendingSize = 0;
|
std::uint64_t m_pendingSize = 0;
|
||||||
bool m_haveHeader = false;
|
bool m_haveHeader = false;
|
||||||
bool m_failed = false;
|
bool m_failed = false;
|
||||||
|
std::uint32_t m_expectedMagic = kFrameMagic;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace MobileGL::MG_Remote::Transport
|
} // namespace MobileGL::MG_Remote::Transport
|
||||||
|
|||||||
@@ -0,0 +1,347 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Remote/Transport/ILink.h
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// The DATA-plane seam. Declared by package c6, implemented by package lk.
|
||||||
|
// Authority: CONTRACT-P6.md §8.
|
||||||
|
//
|
||||||
|
// WHY THIS EXISTS AND WHY IT IS NOT ITransport. ITransport.h:16-20 says in its
|
||||||
|
// own header that everything on the hot path bypasses it: it carries the
|
||||||
|
// handshake, surface ops, resync, aux requests and fatals, and that scope is
|
||||||
|
// already correct for a socket. Below it there was NO interface of any kind -
|
||||||
|
// Ring.h, ReplySlot.h and EventRing.h each take a raw `void* base` plus a
|
||||||
|
// capacity, so "swap the transport" had nothing to swap. This header is that
|
||||||
|
// missing thing, and ITransport is neither extended nor changed by it.
|
||||||
|
//
|
||||||
|
// NOTHING INCLUDES THIS FILE IN c6. That is the whole of c6's behaviour
|
||||||
|
// guarantee: the seam is declared, StreamLink.h is declared against it (which
|
||||||
|
// is the adequacy proof - see below), and not one call site moves. Package lk
|
||||||
|
// implements ShmLink by relocating today's SessionSegments / Ring /
|
||||||
|
// ReplySlotPool / EventRing behind it, line for line, and only then rewrites
|
||||||
|
// the call sites.
|
||||||
|
//
|
||||||
|
// THE SEAM IS SETUP-TIME, NOT HOT-PATH. No method here is called per record,
|
||||||
|
// per publish, or inside a spin predicate. The producer takes a LinkArena once
|
||||||
|
// at attach and reserves through it non-virtually; every wait predicate reads
|
||||||
|
// LinkProgress through a raw pointer taken once. Three grounds, the second
|
||||||
|
// decisive (CONTRACT-P6.md §8.2):
|
||||||
|
//
|
||||||
|
// 1. Two virtuals per record at the 4000 records/frame SEG_CMD is sized
|
||||||
|
// against is ~8000 indirect calls/frame, about 0.5% of the measured
|
||||||
|
// 15.72 ms client frame - affordable, but the only lane that could
|
||||||
|
// measure it has +/-4% dispersion, EIGHT TIMES the effect. A gate that
|
||||||
|
// can only ever print "within noise" is ID-124's failure mode one level
|
||||||
|
// down.
|
||||||
|
// 2. Doorbell::Wait is a non-virtual template whose spin loop calls ready()
|
||||||
|
// up to SpinItersPerUs() * spinUs times; at 916 waits/frame with 99.8%
|
||||||
|
// resolved inside the spin, the predicate runs 1e5-1e6 times per frame
|
||||||
|
// and reads the watermarks straight off the shared page. That is the
|
||||||
|
// 31.58%-of-the-GL-thread path. A virtual there is not a rounding
|
||||||
|
// question.
|
||||||
|
// 3. The encode path already depends on four inline accessors around its one
|
||||||
|
// Reserve; virtualising Reserve alone forces either four more virtuals or
|
||||||
|
// moving R-10's wrap counters behind the seam, and those are deliberately
|
||||||
|
// encoder-owned.
|
||||||
|
//
|
||||||
|
// So lk's gate is an objdump call-count of the encode path, not a wall clock:
|
||||||
|
// after lk that path has no more out-of-line calls than before. That is
|
||||||
|
// falsifiable; "within noise" is not.
|
||||||
|
//
|
||||||
|
// WHAT THIS HEADER DELIBERATELY DOES NOT DO.
|
||||||
|
// - It does not define Watermark::Reached or any other predicate that
|
||||||
|
// SessionRings.h already defines. One definition, one owner.
|
||||||
|
// - It does not relocate the bodies of RingProducer::Reserve or
|
||||||
|
// RingConsumer::Pop. Those log (MGLOG_E / MGLOG_D) and use Align8 and
|
||||||
|
// <cstring>; no header under Transport/ pulls the logger in, and this one
|
||||||
|
// does not start. They stay out of line and move to ShmLink.cpp in lk.
|
||||||
|
// - It declares no function it does not define. Every entry point here is
|
||||||
|
// pure virtual or a POD accessor.
|
||||||
|
// - It does not regroup RingControl. That regroup is real and necessary
|
||||||
|
// (CONTRACT-P6.md §8.3) but its rename blast radius is 109 production
|
||||||
|
// sites, five of them behind a non-Android #if, so it is lk's with a
|
||||||
|
// published per-file itemisation - not a side effect of declaring a seam.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../Protocol/mg_protocol_base.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
|
|
||||||
|
class Doorbell;
|
||||||
|
class SessionSegments;
|
||||||
|
struct SessionSegmentSizes;
|
||||||
|
class RingProducer;
|
||||||
|
class RingConsumer;
|
||||||
|
class EventRingProducer;
|
||||||
|
class EventRingConsumer;
|
||||||
|
|
||||||
|
// Which end of the link this instance is. Deliberately NOT ITransport's
|
||||||
|
// TransportRole: that enum's InProcess value names a control-plane
|
||||||
|
// hand-off, and a data plane's two ends are producer and consumer whatever
|
||||||
|
// the control plane did.
|
||||||
|
enum class TransportRoleTag : std::uint32_t {
|
||||||
|
ClientProducer = 1,
|
||||||
|
ServerConsumer = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---- the progress block -------------------------------------------------
|
||||||
|
//
|
||||||
|
// The watermarks every wait predicate reads. On ShmLink this aliases the
|
||||||
|
// shared control page and the loads are cross-process acquire loads; on
|
||||||
|
// StreamLink it is process-local and a reader thread stores into it from
|
||||||
|
// decoded progress messages.
|
||||||
|
//
|
||||||
|
// THE RULES SURVIVE THE MECHANISM VERBATIM, and that is the point of naming
|
||||||
|
// the block rather than the page: late-never-early (Ring.h's "BATCHING MAY ONLY MAKE A WATERMARK LATE"), `>=`
|
||||||
|
// never `==` (SessionRings.h's Watermark::Reached), monotone with a
|
||||||
|
// backwards move Fatal (Ring.cpp's AdvanceMonotonic). A stream link changes
|
||||||
|
// only HOW a value arrives, never what it means.
|
||||||
|
//
|
||||||
|
// WHY THESE FOUR AND NOT THE WHOLE PAGE, AND WHY THE EVENT FLAGS ARE NOT
|
||||||
|
// HERE. RingControl's watermark cache line HELD, until lk regrouped it, {appliedSeq,
|
||||||
|
// submittedSeq, retiredSeq, completedFrameSerial, presentAckSerial}, and
|
||||||
|
// submittedSeq is PRODUCER-written (Ring.h's "THE FIVE WATERMARKS" block,
|
||||||
|
// "Advanced by the PRODUCER after it publishes") while the other four are consumer-written - so the
|
||||||
|
// line has MIXED WRITERS as it stands and no single-writer block can be
|
||||||
|
// aliased over it. lk's regroup moves submittedSeq out to the producer's
|
||||||
|
// own line, beside cmdHead, which is the other thing the producer writes;
|
||||||
|
// what is left IS this struct, and it IS a named member of RingControl,
|
||||||
|
// pinned there by per-field offsetof static_asserts (Ring.h).
|
||||||
|
//
|
||||||
|
// THE TWO EVENT FLAGS ARE DELIBERATELY EXCLUDED, and an earlier draft of
|
||||||
|
// this header had them in and was wrong. eventRingFull has TWO writers:
|
||||||
|
// the server latches it with store(1) when SEG_EVENT fills
|
||||||
|
// (EventRing.h:140) and the CLIENT clears it with an exchange(0) on EVERY
|
||||||
|
// DRAIN (EventRing.h:200). Promoting it here would put a per-drain RMW by
|
||||||
|
// the client on the same cache line as appliedSeq - which the server
|
||||||
|
// release-stores every 64 records and the client's spin predicate reads
|
||||||
|
// 1e5-1e6 times per frame. That is new false sharing on the hottest line
|
||||||
|
// in the system, and it would land in exactly the numbers lk's gate has to
|
||||||
|
// hold constant. They stay in the doorbell/generation group, where mixed
|
||||||
|
// writers already live beside consumerParked/producerParked, and cross the
|
||||||
|
// seam through EventFlags() instead.
|
||||||
|
//
|
||||||
|
// It was free to regroup while both peers are the same binary; a wire break the day a second build exists,
|
||||||
|
// which is why it is booked now rather than later.
|
||||||
|
struct LinkProgress {
|
||||||
|
std::atomic<std::uint64_t> appliedSeq; // records applied
|
||||||
|
std::atomic<std::uint64_t> retiredSeq; // GPU finished
|
||||||
|
std::atomic<std::uint64_t> completedFrameSerial; // releases *RetiredTail / SEG_ADOPT
|
||||||
|
std::atomic<std::uint64_t> presentAckSerial; // returns present credit
|
||||||
|
};
|
||||||
|
|
||||||
|
// The reverse channel's two flags. Separated from LinkProgress for the
|
||||||
|
// false-sharing reason above, not for a taxonomic one: both roles read
|
||||||
|
// eventRingFull in a park predicate, and both roles write it.
|
||||||
|
struct LinkEventFlags {
|
||||||
|
std::atomic<std::uint32_t> eventRingFull; // server latches, client clears
|
||||||
|
std::atomic<std::uint32_t> eventDropped; // server-only counter
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---- the producer's handle ----------------------------------------------
|
||||||
|
//
|
||||||
|
// POD state, taken ONCE at attach and used non-virtually thereafter. The
|
||||||
|
// reserve/commit algorithm is NOT inlined here (see the header comment):
|
||||||
|
// ShmLink keeps today's out-of-line body, StreamLink writes its own.
|
||||||
|
// `Base` is null on a link that has no mapping, and a link that publishes
|
||||||
|
// that shape must answer every span through ResolveSpan.
|
||||||
|
struct LinkArena {
|
||||||
|
void* Base = nullptr;
|
||||||
|
std::uint64_t Capacity = 0;
|
||||||
|
std::uint64_t Mask = 0;
|
||||||
|
std::uint64_t LocalHead = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// The consumer's mirror of the same.
|
||||||
|
struct LinkCursor {
|
||||||
|
const void* Base = nullptr;
|
||||||
|
std::uint64_t Capacity = 0;
|
||||||
|
std::uint64_t Mask = 0;
|
||||||
|
std::uint64_t LocalTail = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// A run of bulk bytes named on the wire. On ShmLink `Offset` indexes the
|
||||||
|
// shared SEG_STAGE mapping; on StreamLink it indexes the trailing staged
|
||||||
|
// region of the batch that carried the record. MGPBlobRef's spelling and
|
||||||
|
// every honesty check over it (R-2) are unchanged either way - which is the
|
||||||
|
// property that lets the whole record catalogue cross a boundary with no
|
||||||
|
// mapping without a single record layout changing.
|
||||||
|
struct LinkSpan {
|
||||||
|
std::uint64_t Offset = 0;
|
||||||
|
std::uint64_t Size = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Which segment a span or a view belongs to. Mirrors SegmentKind's wire
|
||||||
|
// values; declared here so ILink does not pull the protocol headers in.
|
||||||
|
enum class LinkSegment : std::uint32_t {
|
||||||
|
Cmd = 1,
|
||||||
|
Stage = 2,
|
||||||
|
Reply = 3,
|
||||||
|
Event = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
// What a link can do. A caller may not infer any of these from the
|
||||||
|
// transport's role, and a link may not answer "sometimes" - rule G's
|
||||||
|
// second clause is that a transport DECLARES what it supports and may not
|
||||||
|
// invent a third answer.
|
||||||
|
struct LinkCapabilities {
|
||||||
|
bool SharedMapping = false; // peers see one set of bytes; no copy on read
|
||||||
|
bool DescriptorPassing = false;
|
||||||
|
bool PublishIsDelivery = false; // false => Flush() is mandatory before any wait
|
||||||
|
std::uint64_t MaxRecordBytes = 0;
|
||||||
|
std::uint64_t MaxReplyBytes = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Non-owning synchronization addresses, acquired once at attachment. They
|
||||||
|
// denote process-local atomics on a stream and shared atomics on a mapping.
|
||||||
|
struct LinkSignals {
|
||||||
|
std::atomic<std::uint64_t>* CmdHead = nullptr;
|
||||||
|
std::atomic<std::uint64_t>* SubmittedSeq = nullptr;
|
||||||
|
std::atomic<std::uint32_t>* ConsumerParked = nullptr;
|
||||||
|
std::atomic<std::uint32_t>* ProducerParked = nullptr;
|
||||||
|
std::atomic<std::uint32_t>* EventRingFull = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// The seam itself.
|
||||||
|
//
|
||||||
|
// Nineteen entry points, every one taken at attach, at a park boundary, or
|
||||||
|
// once per control operation. None on the hot path.
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
class ILink {
|
||||||
|
public:
|
||||||
|
virtual ~ILink() = default;
|
||||||
|
|
||||||
|
ILink(const ILink&) = delete;
|
||||||
|
ILink& operator=(const ILink&) = delete;
|
||||||
|
|
||||||
|
// ---- setup ----------------------------------------------------------
|
||||||
|
|
||||||
|
virtual LinkCapabilities Capabilities() const = 0;
|
||||||
|
|
||||||
|
// Setup views. Ownership remains in the link; callers cache the ring
|
||||||
|
// endpoint once so reserve/pop and spin predicates remain non-virtual.
|
||||||
|
virtual SessionSegments& Memory() = 0;
|
||||||
|
virtual void InitializeEndpoints() = 0;
|
||||||
|
LinkSignals Signals();
|
||||||
|
std::uint64_t SegmentSize(LinkSegment segment);
|
||||||
|
virtual RingProducer& CommandsOut() = 0;
|
||||||
|
virtual RingConsumer& CommandsIn() = 0;
|
||||||
|
virtual EventRingProducer& EventsOut() = 0;
|
||||||
|
virtual EventRingConsumer& EventsIn() = 0;
|
||||||
|
virtual void BindDoorbells(Doorbell*, Doorbell*) {}
|
||||||
|
|
||||||
|
|
||||||
|
// The watermark block. Taken once; every wait predicate reads through
|
||||||
|
// the returned pointer with no further virtual dispatch. Never null on
|
||||||
|
// an attached link.
|
||||||
|
virtual LinkProgress* Progress() = 0;
|
||||||
|
|
||||||
|
// The reverse channel's flags. A separate ACCESSOR, for the reason
|
||||||
|
// LinkEventFlags documents. NOT a separate cache line: they sit in the
|
||||||
|
// doorbell/generation group beside serverEpoch, which is where mixed
|
||||||
|
// writers already live.
|
||||||
|
virtual LinkEventFlags* EventFlags() = 0;
|
||||||
|
|
||||||
|
// The command-record arena (producer side) and cursor (consumer side).
|
||||||
|
// Exactly one of the two is valid on a given peer.
|
||||||
|
virtual LinkArena* RecordArena() = 0;
|
||||||
|
virtual LinkCursor* RecordCursor() = 0;
|
||||||
|
|
||||||
|
// ---- bulk bytes -----------------------------------------------------
|
||||||
|
|
||||||
|
// Reserve `bytes` of staging and return where the record should name
|
||||||
|
// it. MOBILEGL_ERR_RING_OVERRUN when the request cannot be satisfied at
|
||||||
|
// any occupancy; the caller's existing back-pressure path is unchanged.
|
||||||
|
virtual MobileGLResult StageBytes(std::uint64_t bytes, LinkSpan* outSpan,
|
||||||
|
void** outWritePtr) = 0;
|
||||||
|
|
||||||
|
// Resolve a span the peer named. On a shared mapping this is pointer
|
||||||
|
// arithmetic over the peer's segment; on a stream it points into the
|
||||||
|
// reassembly buffer of the batch that carried the record, and the
|
||||||
|
// lifetime rule ("valid until retiredSeq passes the record") is
|
||||||
|
// restated against that buffer rather than against the mapping.
|
||||||
|
//
|
||||||
|
// THIS IS THE METHOD WRITING StreamLink REVEALED. The brief's list -
|
||||||
|
// progress transmission, send window, flush - did not name it, and
|
||||||
|
// without it a stream link has no way to answer the eleven
|
||||||
|
// ResolveOrFatal call sites in the decoder.
|
||||||
|
virtual MobileGLResult ResolveSpan(LinkSegment segment, LinkSpan span,
|
||||||
|
const void** outPtr) = 0;
|
||||||
|
|
||||||
|
// ---- replies --------------------------------------------------------
|
||||||
|
|
||||||
|
virtual MobileGLResult PostReply(std::uint64_t seq, std::int32_t status,
|
||||||
|
const void* payload, std::uint64_t size) = 0;
|
||||||
|
virtual MobileGLResult ReadReply(std::uint64_t seq, std::int32_t* outStatus,
|
||||||
|
const void** outPayload, std::uint64_t* outSize) = 0;
|
||||||
|
|
||||||
|
// ---- the reverse channel --------------------------------------------
|
||||||
|
|
||||||
|
virtual LinkArena* EventArena() = 0;
|
||||||
|
virtual LinkCursor* EventCursor() = 0;
|
||||||
|
virtual std::uint64_t EventPublishedHead() const = 0;
|
||||||
|
virtual MobileGLResult WaitForEventDelivery(std::uint64_t head, std::uint32_t timeoutMs) = 0;
|
||||||
|
|
||||||
|
// ---- wakeups --------------------------------------------------------
|
||||||
|
//
|
||||||
|
// THESE TWO RETIRE CONTRACT-P5 §3.9. That ruling kept the doorbell
|
||||||
|
// accessors on the session "so that this stays one switch in one file
|
||||||
|
// rather than two virtuals every transport has to invent a home for"
|
||||||
|
// (ServerSession.cpp:709-724) - and the switch it produced aborts for
|
||||||
|
// every role but InProcess, so a spawn apply thread dies in
|
||||||
|
// ConsumerDoorbell before it pops its first record. The seam is the
|
||||||
|
// home the ruling said did not exist. lk deletes both accessors rather
|
||||||
|
// than growing them a socket arm.
|
||||||
|
virtual Doorbell& ConsumerBell() = 0;
|
||||||
|
virtual Doorbell& ProducerBell() = 0;
|
||||||
|
|
||||||
|
// ---- publication -----------------------------------------------------
|
||||||
|
|
||||||
|
// Make everything published so far visible to the peer. On a shared
|
||||||
|
// mapping publish IS delivery and this is a no-op; on a stream it is a
|
||||||
|
// write(), and CONTRACT-P6.md requires every transition into a wait to
|
||||||
|
// call it first, or a kWaitReply record sitting in a send buffer while
|
||||||
|
// the client parks is a hang rather than a slowdown.
|
||||||
|
virtual MobileGLResult Flush() = 0;
|
||||||
|
|
||||||
|
// Push the local progress block to the peer. A no-op on a shared
|
||||||
|
// mapping, where a release-store IS the transmission. Named separately
|
||||||
|
// from Flush because the two have different triggers: Flush is about
|
||||||
|
// records the peer has not seen, this is about watermarks the peer is
|
||||||
|
// waiting on. The second method writing StreamLink revealed.
|
||||||
|
virtual MobileGLResult FlushProgress() = 0;
|
||||||
|
|
||||||
|
// The encoder keeps its established stage allocator; the link tracks only the
|
||||||
|
// newly written spans that must precede command delivery.
|
||||||
|
virtual void NoteStage(LinkSpan) {}
|
||||||
|
// Called after local progress advances. Stream links coalesce transmission;
|
||||||
|
// the explicit FlushProgress at every park remains mandatory.
|
||||||
|
virtual void ProgressChanged() {}
|
||||||
|
virtual bool PeerHungUp() const { return false; }
|
||||||
|
|
||||||
|
// ---- lifecycle -------------------------------------------------------
|
||||||
|
|
||||||
|
virtual bool Attached() const = 0;
|
||||||
|
virtual void Detach() = 0;
|
||||||
|
virtual TransportRoleTag Role() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ILink() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Setup factories keep concrete link selection out of codec/session code.
|
||||||
|
std::unique_ptr<ILink> CreateSharedLink(TransportRoleTag role);
|
||||||
|
MobileGLResult CreateStreamLink(int fd, const SessionSegmentSizes& sizes,
|
||||||
|
TransportRoleTag role, std::unique_ptr<ILink>& out);
|
||||||
|
|
||||||
|
} // namespace MobileGL::MG_Remote::Transport
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
#include "LinkMetrics.h"
|
||||||
|
#include <MG_Util/Debug/Log.h>
|
||||||
|
#include <array>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
|
namespace {
|
||||||
|
struct Window {
|
||||||
|
std::uint64_t waitReplies = 0, samples = 0, replyNs = 0, stageBytes = 0;
|
||||||
|
std::array<std::uint64_t, 32> histogram{};
|
||||||
|
};
|
||||||
|
// The client already has exactly one record producer. The server never writes these.
|
||||||
|
struct Metrics {
|
||||||
|
bool active = false;
|
||||||
|
std::uint64_t frame = 0, started = 0, lastFrame = 0, cpuStarted = 0, cpuLast = 0;
|
||||||
|
Window total{}, current{};
|
||||||
|
} metrics;
|
||||||
|
std::uint64_t ClockNs() {
|
||||||
|
return std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||||
|
std::chrono::steady_clock::now().time_since_epoch()).count();
|
||||||
|
}
|
||||||
|
std::uint64_t ThreadCpuNs() {
|
||||||
|
#if defined(CLOCK_THREAD_CPUTIME_ID)
|
||||||
|
timespec value{};
|
||||||
|
if (::clock_gettime(CLOCK_THREAD_CPUTIME_ID, &value) == 0)
|
||||||
|
return std::uint64_t(value.tv_sec) * 1000000000ull + value.tv_nsec;
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
std::uint64_t QuantileUpperUs(const Window& w, unsigned percentile) {
|
||||||
|
if (w.samples == 0) return 0;
|
||||||
|
const auto target = (w.samples * percentile + 99) / 100;
|
||||||
|
std::uint64_t count = 0;
|
||||||
|
for (unsigned i = 0; i < w.histogram.size(); ++i) {
|
||||||
|
count += w.histogram[i];
|
||||||
|
if (count >= target) return 1ull << i;
|
||||||
|
}
|
||||||
|
return 1ull << 31;
|
||||||
|
}
|
||||||
|
void Emit(const char* kind, const Window& w, std::uint64_t wallNs, std::uint64_t cpuNs) {
|
||||||
|
char histogram[768]{};
|
||||||
|
std::size_t at = 0;
|
||||||
|
for (unsigned i = 0; i < w.histogram.size(); ++i) {
|
||||||
|
const int n = std::snprintf(histogram + at, sizeof(histogram) - at, "%s%llu",
|
||||||
|
i == 0 ? "" : ",", static_cast<unsigned long long>(w.histogram[i]));
|
||||||
|
if (n < 0 || static_cast<std::size_t>(n) >= sizeof(histogram) - at) break;
|
||||||
|
at += static_cast<std::size_t>(n);
|
||||||
|
}
|
||||||
|
MGLOG_I("P65LinkMetrics kind=%s frame=%llu wait_replies=%llu rtt_samples=%llu "
|
||||||
|
"rtt_mean_us=%.3f rtt_p50_upper_us=%llu rtt_p99_upper_us=%llu "
|
||||||
|
"stage_bytes=%llu wall_ns=%llu client_thread_cpu_ns=%llu rtt_hist_us_pow2=%s",
|
||||||
|
kind, static_cast<unsigned long long>(metrics.frame),
|
||||||
|
static_cast<unsigned long long>(w.waitReplies), static_cast<unsigned long long>(w.samples),
|
||||||
|
w.samples == 0 ? 0.0 : double(w.replyNs) / double(w.samples) / 1000.0,
|
||||||
|
static_cast<unsigned long long>(QuantileUpperUs(w, 50)),
|
||||||
|
static_cast<unsigned long long>(QuantileUpperUs(w, 99)),
|
||||||
|
static_cast<unsigned long long>(w.stageBytes), static_cast<unsigned long long>(wallNs),
|
||||||
|
static_cast<unsigned long long>(cpuNs), histogram);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void LinkMetricsBegin() {
|
||||||
|
metrics = {};
|
||||||
|
const char* enabled = std::getenv("MOBILEGL_PIPE_STATS");
|
||||||
|
metrics.active = enabled != nullptr && std::strcmp(enabled, "1") == 0;
|
||||||
|
if (!metrics.active) return;
|
||||||
|
metrics.started = metrics.lastFrame = ClockNs();
|
||||||
|
metrics.cpuStarted = metrics.cpuLast = ThreadCpuNs();
|
||||||
|
}
|
||||||
|
std::uint64_t LinkMetricsBeginReply(bool wantsReply) {
|
||||||
|
if (!metrics.active || !wantsReply) return 0;
|
||||||
|
++metrics.current.waitReplies; ++metrics.total.waitReplies;
|
||||||
|
return ClockNs();
|
||||||
|
}
|
||||||
|
void LinkMetricsReplyApplied(std::uint64_t startedNs) {
|
||||||
|
if (!metrics.active || startedNs == 0) return;
|
||||||
|
const auto ns = ClockNs() - startedNs;
|
||||||
|
const auto us = (ns + 999) / 1000;
|
||||||
|
unsigned bucket = 0;
|
||||||
|
while (bucket < 31 && us > (1ull << bucket)) ++bucket;
|
||||||
|
for (Window* w : {&metrics.current, &metrics.total}) {
|
||||||
|
++w->samples; w->replyNs += ns; ++w->histogram[bucket];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void LinkMetricsStageBytes(std::uint64_t bytes) {
|
||||||
|
if (!metrics.active) return;
|
||||||
|
metrics.current.stageBytes += bytes; metrics.total.stageBytes += bytes;
|
||||||
|
}
|
||||||
|
void LinkMetricsPresent() {
|
||||||
|
if (!metrics.active) return;
|
||||||
|
++metrics.frame;
|
||||||
|
const auto now = ClockNs(), cpu = ThreadCpuNs();
|
||||||
|
Emit("frame", metrics.current, now - metrics.lastFrame, cpu - metrics.cpuLast);
|
||||||
|
metrics.current = {}; metrics.lastFrame = now; metrics.cpuLast = cpu;
|
||||||
|
}
|
||||||
|
void LinkMetricsEnd() {
|
||||||
|
if (!metrics.active) return;
|
||||||
|
Emit("summary", metrics.total, ClockNs() - metrics.started, ThreadCpuNs() - metrics.cpuStarted);
|
||||||
|
metrics.active = false;
|
||||||
|
}
|
||||||
|
void LinkMetricsServerPresent(std::uint64_t serial) {
|
||||||
|
// Independent of the client latch: spawn servers never call LinkMetricsBegin.
|
||||||
|
// The baseline belongs to the apply thread, and is discarded if that thread is replaced.
|
||||||
|
static thread_local const bool enabled = [] {
|
||||||
|
const char* value = std::getenv("MOBILEGL_PIPE_STATS");
|
||||||
|
return value != nullptr && std::strcmp(value, "1") == 0;
|
||||||
|
}();
|
||||||
|
if (!enabled) return;
|
||||||
|
static thread_local std::uint64_t previousSerial = 0, previousWall = 0, previousCpu = 0;
|
||||||
|
const auto wall = ClockNs(), cpu = ThreadCpuNs();
|
||||||
|
const bool valid = previousWall != 0 && serial > previousSerial && cpu >= previousCpu;
|
||||||
|
MGLOG_I("P65ServerMetrics frame=%llu valid=%u wall_ns=%llu apply_thread_cpu_ns=%llu",
|
||||||
|
static_cast<unsigned long long>(serial), valid ? 1u : 0u,
|
||||||
|
static_cast<unsigned long long>(valid ? wall - previousWall : 0),
|
||||||
|
static_cast<unsigned long long>(valid ? cpu - previousCpu : 0));
|
||||||
|
previousSerial = serial; previousWall = wall; previousCpu = cpu;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// P6.5 transport measurements. Called only by the single client producer.
|
||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
|
// Disabled sessions never read a clock. Samples are a fixed 32-bucket histogram.
|
||||||
|
void LinkMetricsBegin();
|
||||||
|
void LinkMetricsEnd();
|
||||||
|
std::uint64_t LinkMetricsBeginReply(bool wantsReply);
|
||||||
|
void LinkMetricsReplyApplied(std::uint64_t startedNs);
|
||||||
|
void LinkMetricsStageBytes(std::uint64_t bytes);
|
||||||
|
void LinkMetricsPresent();
|
||||||
|
void LinkMetricsServerPresent(std::uint64_t serial);
|
||||||
|
}
|
||||||
@@ -257,6 +257,19 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
std::memcpy(slot, &header, sizeof(header));
|
std::memcpy(slot, &header, sizeof(header));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The link can lend the immutable payload after appliedSeq without a
|
||||||
|
// second copy. The same seq and size honesty checks guard both readers.
|
||||||
|
bool ReadView(std::uint64_t seq, std::int32_t* status, const void** payload,
|
||||||
|
std::uint64_t* size) const {
|
||||||
|
if (!m_base || !seq || !status || !payload || !size) return false;
|
||||||
|
const auto* slot = SlotAt(seq);
|
||||||
|
ReplySlotHeader header{}; std::memcpy(&header, slot, sizeof header);
|
||||||
|
std::atomic_thread_fence(std::memory_order_acquire);
|
||||||
|
if (header.Seq != seq || header.Size > MaxReplyBytes()) return false;
|
||||||
|
*status = header.Status; *size = header.Size;
|
||||||
|
*payload = slot + sizeof header; return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Client side. Returns false when the slot does not carry THIS seq - the
|
// Client side. Returns false when the slot does not carry THIS seq - the
|
||||||
// self-check the stamp exists for. `outBytes` may be null for an answer
|
// self-check the stamp exists for. `outBytes` may be null for an answer
|
||||||
// with no payload (every DECLINE, and the four Bool acceptances).
|
// with no payload (every DECLINE, and the four Bool acceptances).
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AdvanceApplied(RingControl& control, std::uint64_t seq) {
|
void AdvanceApplied(RingControl& control, std::uint64_t seq) {
|
||||||
AdvanceMonotonic(control.appliedSeq, seq, "appliedSeq");
|
AdvanceMonotonic(control.Progress.appliedSeq, seq, "appliedSeq");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvanceRetired(RingControl& control, std::uint64_t seq) {
|
void AdvanceRetired(RingControl& control, std::uint64_t seq) {
|
||||||
@@ -399,16 +399,16 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// reclaims behind it, so a retire ahead of the apply hands live bytes
|
// reclaims behind it, so a retire ahead of the apply hands live bytes
|
||||||
// back to the producer. Clamped rather than refused, because a
|
// back to the producer. Clamped rather than refused, because a
|
||||||
// caller that retires "everything applied" is the normal shape.
|
// caller that retires "everything applied" is the normal shape.
|
||||||
const std::uint64_t applied = control.appliedSeq.load(std::memory_order_acquire);
|
const std::uint64_t applied = control.Progress.appliedSeq.load(std::memory_order_acquire);
|
||||||
AdvanceMonotonic(control.retiredSeq, seq > applied ? applied : seq, "retiredSeq");
|
AdvanceMonotonic(control.Progress.retiredSeq, seq > applied ? applied : seq, "retiredSeq");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvanceCompletedFrame(RingControl& control, std::uint64_t serial) {
|
void AdvanceCompletedFrame(RingControl& control, std::uint64_t serial) {
|
||||||
AdvanceMonotonic(control.completedFrameSerial, serial, "completedFrameSerial");
|
AdvanceMonotonic(control.Progress.completedFrameSerial, serial, "completedFrameSerial");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvancePresentAck(RingControl& control, std::uint64_t serial) {
|
void AdvancePresentAck(RingControl& control, std::uint64_t serial) {
|
||||||
AdvanceMonotonic(control.presentAckSerial, serial, "presentAckSerial");
|
AdvanceMonotonic(control.Progress.presentAckSerial, serial, "presentAckSerial");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Watermark
|
} // namespace Watermark
|
||||||
@@ -417,6 +417,11 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// SessionProducer
|
// SessionProducer
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
void SessionProducer::Attach(ILink& link, std::uint32_t spinUs) {
|
||||||
|
Attach(link.Memory().CmdControl(), &link.CommandsOut(), &link.ConsumerBell(), &link.ProducerBell(), spinUs);
|
||||||
|
SetLink(link.Capabilities().PublishIsDelivery ? nullptr : &link);
|
||||||
|
}
|
||||||
|
|
||||||
void SessionProducer::Attach(RingControl* control, RingProducer* cmd, Doorbell* peerBell,
|
void SessionProducer::Attach(RingControl* control, RingProducer* cmd, Doorbell* peerBell,
|
||||||
Doorbell* selfBell, std::uint32_t spinUs) {
|
Doorbell* selfBell, std::uint32_t spinUs) {
|
||||||
m_control = control;
|
m_control = control;
|
||||||
@@ -432,6 +437,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
m_peerBell = nullptr;
|
m_peerBell = nullptr;
|
||||||
m_selfBell = nullptr;
|
m_selfBell = nullptr;
|
||||||
m_lastPublishedSeq = 0;
|
m_lastPublishedSeq = 0;
|
||||||
|
m_link = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionProducer::PublishAndNotify(std::uint64_t submittedSeq) {
|
void SessionProducer::PublishAndNotify(std::uint64_t submittedSeq) {
|
||||||
@@ -469,6 +475,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// COUNTED BEFORE THE WAIT AND ONLY WHEN ONE REALLY HAPPENS - after the two refusals
|
// COUNTED BEFORE THE WAIT AND ONLY WHEN ONE REALLY HAPPENS - after the two refusals
|
||||||
// above, which answer TimedOut without ever reaching the bell. See Waits()/Parks() in
|
// above, which answer TimedOut without ever reaching the bell. See Waits()/Parks() in
|
||||||
// the header for why the pair is the reading and either number alone is not.
|
// the header for why the pair is the reading and either number alone is not.
|
||||||
|
if (m_link && m_link->Flush() != MOBILEGL_OK) return SessionWait::ShutDown;
|
||||||
m_waits.fetch_add(1, std::memory_order_relaxed);
|
m_waits.fetch_add(1, std::memory_order_relaxed);
|
||||||
// &m_parks is the OTHER half of the pair, and it is passed rather than read off the
|
// &m_parks is the OTHER half of the pair, and it is passed rather than read off the
|
||||||
// bell: the bell is this endpoint's and the encoder waits on it too, so its own
|
// bell: the bell is this endpoint's and the encoder waits on it too, so its own
|
||||||
@@ -488,7 +495,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
return SessionWait::TimedOut;
|
return SessionWait::TimedOut;
|
||||||
}
|
}
|
||||||
RingControl* control = m_control;
|
RingControl* control = m_control;
|
||||||
return Park([control, seq] { return Watermark::Reached(control->appliedSeq, seq); },
|
return Park([control, seq] { return Watermark::Reached(control->Progress.appliedSeq, seq); },
|
||||||
timeoutMs);
|
timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +504,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
return SessionWait::TimedOut;
|
return SessionWait::TimedOut;
|
||||||
}
|
}
|
||||||
RingControl* control = m_control;
|
RingControl* control = m_control;
|
||||||
return Park([control, serial] { return Watermark::Reached(control->presentAckSerial, serial); },
|
return Park([control, serial] { return Watermark::Reached(control->Progress.presentAckSerial, serial); },
|
||||||
timeoutMs);
|
timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,7 +522,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
RingControl* control = m_control;
|
RingControl* control = m_control;
|
||||||
return Park(
|
return Park(
|
||||||
[control, seq] {
|
[control, seq] {
|
||||||
return Watermark::Reached(control->appliedSeq, seq) ||
|
return Watermark::Reached(control->Progress.appliedSeq, seq) ||
|
||||||
control->eventRingFull.load(std::memory_order_acquire) != 0;
|
control->eventRingFull.load(std::memory_order_acquire) != 0;
|
||||||
},
|
},
|
||||||
timeoutMs);
|
timeoutMs);
|
||||||
@@ -529,7 +536,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
RingControl* control = m_control;
|
RingControl* control = m_control;
|
||||||
return Park(
|
return Park(
|
||||||
[control, serial] {
|
[control, serial] {
|
||||||
return Watermark::Reached(control->presentAckSerial, serial) ||
|
return Watermark::Reached(control->Progress.presentAckSerial, serial) ||
|
||||||
control->eventRingFull.load(std::memory_order_acquire) != 0;
|
control->eventRingFull.load(std::memory_order_acquire) != 0;
|
||||||
},
|
},
|
||||||
timeoutMs);
|
timeoutMs);
|
||||||
@@ -547,6 +554,11 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// SessionConsumer
|
// SessionConsumer
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
void SessionConsumer::Attach(ILink& link, std::uint32_t spinUs) {
|
||||||
|
Attach(link.Memory().CmdControl(), &link.CommandsIn(), &link.ProducerBell(), &link.ConsumerBell(), spinUs);
|
||||||
|
SetLink(link.Capabilities().PublishIsDelivery ? nullptr : &link);
|
||||||
|
}
|
||||||
|
|
||||||
void SessionConsumer::Attach(RingControl* control, RingConsumer* cmd, Doorbell* peerBell,
|
void SessionConsumer::Attach(RingControl* control, RingConsumer* cmd, Doorbell* peerBell,
|
||||||
Doorbell* selfBell, std::uint32_t spinUs) {
|
Doorbell* selfBell, std::uint32_t spinUs) {
|
||||||
m_control = control;
|
m_control = control;
|
||||||
@@ -554,7 +566,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
m_peerBell = peerBell;
|
m_peerBell = peerBell;
|
||||||
m_selfBell = selfBell;
|
m_selfBell = selfBell;
|
||||||
m_spinUs = spinUs;
|
m_spinUs = spinUs;
|
||||||
m_appliedSeq = control == nullptr ? 0 : control->appliedSeq.load(std::memory_order_acquire);
|
m_appliedSeq = control == nullptr ? 0 : control->Progress.appliedSeq.load(std::memory_order_acquire);
|
||||||
m_retirableCursor = cmd == nullptr ? 0 : cmd->LocalTail();
|
m_retirableCursor = cmd == nullptr ? 0 : cmd->LocalTail();
|
||||||
m_borrowHeld = false;
|
m_borrowHeld = false;
|
||||||
}
|
}
|
||||||
@@ -566,6 +578,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
m_selfBell = nullptr;
|
m_selfBell = nullptr;
|
||||||
m_retirableCursor = 0;
|
m_retirableCursor = 0;
|
||||||
m_borrowHeld = false;
|
m_borrowHeld = false;
|
||||||
|
m_link = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionWait SessionConsumer::WaitForWork(std::uint32_t timeoutMs) {
|
SessionWait SessionConsumer::WaitForWork(std::uint32_t timeoutMs) {
|
||||||
@@ -574,6 +587,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
}
|
}
|
||||||
RingControl* control = m_control;
|
RingControl* control = m_control;
|
||||||
RingConsumer* cmd = m_cmd;
|
RingConsumer* cmd = m_cmd;
|
||||||
|
if (m_link && m_link->FlushProgress() != MOBILEGL_OK) return SessionWait::ShutDown;
|
||||||
const bool woke = m_selfBell->Wait(
|
const bool woke = m_selfBell->Wait(
|
||||||
control->consumerParked,
|
control->consumerParked,
|
||||||
[control, cmd] {
|
[control, cmd] {
|
||||||
@@ -647,6 +661,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SessionConsumer::NotifyClient() {
|
void SessionConsumer::NotifyClient() {
|
||||||
|
if (m_link) m_link->ProgressChanged();
|
||||||
if (m_control != nullptr && m_peerBell != nullptr) {
|
if (m_control != nullptr && m_peerBell != nullptr) {
|
||||||
NotifyIfParked(*m_peerBell, m_control->producerParked);
|
NotifyIfParked(*m_peerBell, m_control->producerParked);
|
||||||
}
|
}
|
||||||
@@ -671,23 +686,19 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
};
|
};
|
||||||
mix(inputs.DynamicParamsSize);
|
mix(inputs.DynamicParamsSize);
|
||||||
mix(inputs.CapsSize);
|
mix(inputs.CapsSize);
|
||||||
mix(inputs.FunctionTableSize);
|
mix(inputs.MemberLayout);
|
||||||
|
mix(inputs.CatalogueLayout);
|
||||||
|
mix(inputs.RenderStateLayout);
|
||||||
mix(inputs.FormatCapabilityTargets);
|
mix(inputs.FormatCapabilityTargets);
|
||||||
mix(inputs.FormatCapabilityFormats);
|
mix(inputs.FormatCapabilityFormats);
|
||||||
mix(inputs.FormatCapabilitiesCodecVersion);
|
mix(inputs.FormatCapabilitiesCodecVersion);
|
||||||
mix(inputs.RendererInfoCodecVersion);
|
mix(inputs.RendererInfoCodecVersion);
|
||||||
|
mix(inputs.ProgramArtifactsCodecVersion);
|
||||||
|
mix(inputs.ProgramArtifactsSchema);
|
||||||
mix(inputs.OpCount);
|
mix(inputs.OpCount);
|
||||||
mix(inputs.AbiVersion);
|
mix(inputs.AbiVersion);
|
||||||
// A presence marker before the bytes, so that "no stamp" (nullptr) and
|
mix(inputs.PointerBits);
|
||||||
// "an empty stamp" ("") are different inputs rather than the same
|
mix(inputs.LittleEndian);
|
||||||
// absence of bytes.
|
|
||||||
mix(inputs.BuildStamp != nullptr ? 1u : 0u);
|
|
||||||
if (inputs.BuildStamp != nullptr) {
|
|
||||||
for (const char* c = inputs.BuildStamp; *c != '\0'; ++c) {
|
|
||||||
hash ^= static_cast<std::uint64_t>(static_cast<unsigned char>(*c));
|
|
||||||
hash *= 1099511628211ull;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 0 is reserved for "not stated": a peer that forgot to fill the field
|
// 0 is reserved for "not stated": a peer that forgot to fill the field
|
||||||
// must not accidentally agree with one that did.
|
// must not accidentally agree with one that did.
|
||||||
return hash == 0 ? 1ull : hash;
|
return hash == 0 ? 1ull : hash;
|
||||||
|
|||||||
@@ -43,13 +43,19 @@
|
|||||||
// land without changing shape.
|
// land without changing shape.
|
||||||
//
|
//
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// THE FIVE WATERMARKS (P5 R-9). One sentence each, and they are a contract:
|
// THE FIVE WATERMARKS (P5 R-9). Four of them are Transport::LinkProgress and
|
||||||
|
// are reached as `control.Progress.<name>`; submittedSeq is the fifth and stays
|
||||||
|
// at RingControl scope, on the producer's line (lk, CONTRACT-P6 §8.3).
|
||||||
|
// One sentence each, and they are a contract:
|
||||||
// every one of the five was declared here at P0 and written by nobody but
|
// every one of the five was declared here at P0 and written by nobody but
|
||||||
// InitRingControl, so until P5 there was nothing to disagree with.
|
// InitRingControl, so until P5 there was nothing to disagree with.
|
||||||
//
|
//
|
||||||
// submittedSeq Advanced by the PRODUCER after it publishes. NOBODY
|
// submittedSeq Advanced by the PRODUCER after it publishes. NOBODY
|
||||||
// WAITS ON IT - it is diagnostic, the answer to "how far
|
// WAITS ON IT - it is diagnostic, the answer to "how far
|
||||||
// ahead of the server is the client right now".
|
// ahead of the server is the client right now". It lives
|
||||||
|
// on the producer's own cache line beside cmdHead; it is
|
||||||
|
// the ONE of the five that is not in LinkProgress, and
|
||||||
|
// that is why LinkProgress can be single-writer.
|
||||||
// appliedSeq Advanced by the CONSUMER for EVERY SINGLE RECORD it
|
// appliedSeq Advanced by the CONSUMER for EVERY SINGLE RECORD it
|
||||||
// applies. The client's verb barrier and every reply wait
|
// applies. The client's verb barrier and every reply wait
|
||||||
// read it, so it is the one watermark P5 FORBIDS BATCHING:
|
// read it, so it is the one watermark P5 FORBIDS BATCHING:
|
||||||
@@ -88,9 +94,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Protocol/mg_protocol_base.h"
|
#include "../Protocol/mg_protocol_base.h"
|
||||||
|
#include "ILink.h" // LinkProgress: the four consumer-written watermarks, lk
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <type_traits>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace MobileGL::MG_Remote::Transport {
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
@@ -99,7 +107,13 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// each contended group on its own cache line.
|
// each contended group on its own cache line.
|
||||||
struct alignas(4096) RingControl {
|
struct alignas(4096) RingControl {
|
||||||
// ---- SEG_CMD cursors ------------------------------------------------
|
// ---- SEG_CMD cursors ------------------------------------------------
|
||||||
|
//
|
||||||
|
// cmdHead and submittedSeq share a line because they share a WRITER:
|
||||||
|
// the producer publishes the head and then stamps how far it has got.
|
||||||
|
// submittedSeq used to sit with the four consumer-written watermarks,
|
||||||
|
// which made that group mixed-writer and unaliasable (lk, §8.3).
|
||||||
alignas(64) std::atomic<std::uint64_t> cmdHead; // producer: bytes written
|
alignas(64) std::atomic<std::uint64_t> cmdHead; // producer: bytes written
|
||||||
|
std::atomic<std::uint64_t> submittedSeq; // producer: records published
|
||||||
alignas(64) std::atomic<std::uint64_t> cmdAppliedTail; // consumer: bytes decoded/copied out
|
alignas(64) std::atomic<std::uint64_t> cmdAppliedTail; // consumer: bytes decoded/copied out
|
||||||
std::atomic<std::uint64_t> cmdRetiredTail; // consumer: borrowed slots released
|
std::atomic<std::uint64_t> cmdRetiredTail; // consumer: borrowed slots released
|
||||||
|
|
||||||
@@ -132,11 +146,16 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
std::atomic<std::uint64_t> stageRetiredTail;
|
std::atomic<std::uint64_t> stageRetiredTail;
|
||||||
|
|
||||||
// ---- sequence / frame watermarks -------------------------------------
|
// ---- sequence / frame watermarks -------------------------------------
|
||||||
alignas(64) std::atomic<std::uint64_t> appliedSeq; // records applied
|
//
|
||||||
std::atomic<std::uint64_t> submittedSeq; // handed to the driver
|
// THE CONSUMER-WRITTEN FOUR, AND ONLY THOSE. This is Transport::LinkProgress
|
||||||
std::atomic<std::uint64_t> retiredSeq; // GPU finished
|
// (ILink.h), named so that a data plane with no shared page can own the
|
||||||
std::atomic<std::uint64_t> completedFrameSerial;
|
// same four values and every wait predicate in SessionRings.h keeps ONE
|
||||||
std::atomic<std::uint64_t> presentAckSerial;
|
// implementation at source level. Single-writer by construction now that
|
||||||
|
// submittedSeq has moved up to the producer's line; the two event flags
|
||||||
|
// stay in the doorbell group below, because the client clears
|
||||||
|
// eventRingFull with an RMW on every drain and that traffic may not land
|
||||||
|
// on the line the client also spins on.
|
||||||
|
alignas(64) LinkProgress Progress;
|
||||||
|
|
||||||
// ---- doorbell / generation -------------------------------------------
|
// ---- doorbell / generation -------------------------------------------
|
||||||
alignas(64) std::atomic<std::uint32_t> serverEpoch; // ++ on context loss / server restart
|
alignas(64) std::atomic<std::uint32_t> serverEpoch; // ++ on context loss / server restart
|
||||||
@@ -148,6 +167,73 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(RingControl) == 4096, "RingControl must be exactly one page");
|
static_assert(sizeof(RingControl) == 4096, "RingControl must be exactly one page");
|
||||||
|
// lk (CONTRACT-P6 §8.3). The regroup is free while both peers are the same binary
|
||||||
|
// and a LAYOUT BREAK the day they are not, so the shape is pinned here - by asserts
|
||||||
|
// that can each go red for the reason they exist, which the first revision of this
|
||||||
|
// block did not manage.
|
||||||
|
//
|
||||||
|
// NOTHING ELSE IN THE TREE PINS ANY OF THIS. The ABI fingerprint
|
||||||
|
// (SessionRings.h's AbiFingerprintInputs) takes three sizeofs, the caps geometry, two
|
||||||
|
// codec versions, kOpCount, the protocol version and the build stamp - and NO input
|
||||||
|
// from this page at all. sizeof(RingControl) is 4096 whatever the members do, because
|
||||||
|
// alignas(4096) makes it so. So a silent field reorder here would leave every gate in
|
||||||
|
// the tree green and both peers hashing identically.
|
||||||
|
static_assert(std::is_standard_layout_v<RingControl> && std::is_standard_layout_v<LinkProgress>,
|
||||||
|
"the offsetof gates below are defined only for standard-layout types");
|
||||||
|
|
||||||
|
// The producer's line: cmdHead and submittedSeq, together and nothing else waiting on them.
|
||||||
|
static_assert(offsetof(RingControl, submittedSeq) == offsetof(RingControl, cmdHead) + 8,
|
||||||
|
"submittedSeq sits immediately after cmdHead");
|
||||||
|
static_assert(offsetof(RingControl, submittedSeq) / 64 == offsetof(RingControl, cmdHead) / 64,
|
||||||
|
"submittedSeq shares the producer's cache line with cmdHead");
|
||||||
|
|
||||||
|
// The Progress line, and it owns that line ALONE.
|
||||||
|
//
|
||||||
|
// Written as `serverEpoch == Progress + 64` rather than the obvious
|
||||||
|
// `Progress + sizeof(LinkProgress) <= offsetof(serverEpoch)`, because the obvious one
|
||||||
|
// CANNOT GO RED: serverEpoch is alignas(64) and is declared next, so the compiler puts
|
||||||
|
// it at the following 64-multiple no matter what precedes it, and the `<=` holds for
|
||||||
|
// every layout including a wrong one.
|
||||||
|
//
|
||||||
|
// WHAT THIS PAIR DOES NOT CATCH, stated because a gate nobody can falsify is worse
|
||||||
|
// than no gate: a SMALL member inserted between Progress and serverEpoch lands at
|
||||||
|
// offset 288, inside Progress's own line - and serverEpoch's alignas(64) absorbs it,
|
||||||
|
// so both asserts still pass. Verified by trying it. Up to 32 bytes can be hidden
|
||||||
|
// there. Growth INSIDE LinkProgress is caught, by sizeof below; growth BESIDE it is
|
||||||
|
// not, and the only thing standing between that and a false-sharing regression is
|
||||||
|
// this comment and the group's own.
|
||||||
|
static_assert(offsetof(RingControl, Progress) % 64 == 0,
|
||||||
|
"LinkProgress starts a cache line of its own");
|
||||||
|
static_assert(offsetof(RingControl, serverEpoch) == offsetof(RingControl, Progress) + 64,
|
||||||
|
"the Progress line holds Progress and nothing else");
|
||||||
|
|
||||||
|
// PER FIELD, which is what §8.3 asks for and what the aggregate asserts above cannot
|
||||||
|
// do: the field ORDER inside LinkProgress is a wire-visible fact about a page both
|
||||||
|
// roles map, and swapping two of them passes every other check in this file.
|
||||||
|
static_assert(offsetof(LinkProgress, appliedSeq) == 0, "LinkProgress field order: appliedSeq");
|
||||||
|
static_assert(offsetof(LinkProgress, retiredSeq) == 8, "LinkProgress field order: retiredSeq");
|
||||||
|
static_assert(offsetof(LinkProgress, completedFrameSerial) == 16,
|
||||||
|
"LinkProgress field order: completedFrameSerial");
|
||||||
|
static_assert(offsetof(LinkProgress, presentAckSerial) == 24,
|
||||||
|
"LinkProgress field order: presentAckSerial");
|
||||||
|
static_assert(sizeof(LinkProgress) == 32,
|
||||||
|
"four consumer-written watermarks; the event flags are NOT in here");
|
||||||
|
|
||||||
|
// The two event flags stay in the doorbell group on purpose (see the group's comment).
|
||||||
|
// LinkEventFlags mirrors them, so the mirror's shape is pinned too.
|
||||||
|
static_assert(offsetof(RingControl, eventDropped) == offsetof(RingControl, eventRingFull) + 4,
|
||||||
|
"the two event flags are adjacent, in that order");
|
||||||
|
static_assert(offsetof(RingControl, eventRingFull) / 64 == offsetof(RingControl, serverEpoch) / 64,
|
||||||
|
"the event flags share the doorbell group's line, NOT the Progress line");
|
||||||
|
static_assert(offsetof(LinkEventFlags, eventRingFull) == 0 &&
|
||||||
|
offsetof(LinkEventFlags, eventDropped) == 4 && sizeof(LinkEventFlags) == 8,
|
||||||
|
"LinkEventFlags mirrors the pair in RingControl");
|
||||||
|
|
||||||
|
// The page's real content must fit the page it claims. sizeof(RingControl) == 4096
|
||||||
|
// above cannot catch a member that grew, because alignas(4096) forces that number;
|
||||||
|
// the struct's content ends far short of it and the tail is padding.
|
||||||
|
static_assert(offsetof(RingControl, eventDropped) + sizeof(std::uint32_t) <= 4096,
|
||||||
|
"RingControl's members must fit the page it claims to be");
|
||||||
static_assert(alignof(RingControl) == 4096, "RingControl must be page aligned");
|
static_assert(alignof(RingControl) == 4096, "RingControl must be page aligned");
|
||||||
static_assert(std::atomic<std::uint64_t>::is_always_lock_free,
|
static_assert(std::atomic<std::uint64_t>::is_always_lock_free,
|
||||||
"the ring cursors are shared across processes: they must be lock-free");
|
"the ring cursors are shared across processes: they must be lock-free");
|
||||||
|
|||||||
@@ -138,6 +138,8 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// Creates and maps all four, initialises BOTH control pages (SEG_CMD's
|
// Creates and maps all four, initialises BOTH control pages (SEG_CMD's
|
||||||
// and SEG_EVENT's), and books the mapping in `role`'s ledger.
|
// and SEG_EVENT's), and books the mapping in `role`'s ledger.
|
||||||
MobileGLResult Create(const SessionSegmentSizes& sizes, MemoryRole role);
|
MobileGLResult Create(const SessionSegmentSizes& sizes, MemoryRole role);
|
||||||
|
// Private, identically addressed mirrors for the stream data plane.
|
||||||
|
MobileGLResult CreatePrivate(const SessionSegmentSizes& sizes, MemoryRole role);
|
||||||
|
|
||||||
// The inproc peer's view of the owner's four segments, booked under the
|
// The inproc peer's view of the owner's four segments, booked under the
|
||||||
// OTHER role. It does NOT re-init the control pages - there is one shared
|
// OTHER role. It does NOT re-init the control pages - there is one shared
|
||||||
@@ -159,6 +161,24 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// travels in SegmentRef instead), so there it still aliases and says so.
|
// travels in SegmentRef instead), so there it still aliases and says so.
|
||||||
MobileGLResult AttachInProcess(SessionSegments& owner, MemoryRole role);
|
MobileGLResult AttachInProcess(SessionSegments& owner, MemoryRole role);
|
||||||
|
|
||||||
|
// P6 `sm`: the spawn client's half. The four descriptors arrived over
|
||||||
|
// SCM_RIGHTS and this side adopts and maps them.
|
||||||
|
//
|
||||||
|
// IT IS THE SAME THREE CALLS AttachInProcess ALREADY MAKES - Adopt, then
|
||||||
|
// Map, per slot - because that was the point of writing the inproc attach
|
||||||
|
// as dup+Adopt+Map rather than as an alias (see the comment above it).
|
||||||
|
// The fstat size check inside Adopt, the alignment, the peer lifetime and
|
||||||
|
// the ledger booking have all been exercised on every inproc run since
|
||||||
|
// P5; what is new here is only where the fd came from.
|
||||||
|
//
|
||||||
|
// OWNERSHIP: on success this object owns all four descriptors and closes
|
||||||
|
// them in Close(). On failure it closes none of them - the caller still
|
||||||
|
// owns what it received and is the only one that can report which slot
|
||||||
|
// failed, so a half-consuming failure path would lose descriptors in the
|
||||||
|
// one situation where the diagnostic matters.
|
||||||
|
MobileGLResult AdoptFromDescriptors(const int fds[4], const std::uint64_t sizes[4],
|
||||||
|
std::uint32_t replySlotCount, MemoryRole role);
|
||||||
|
|
||||||
void Close();
|
void Close();
|
||||||
bool Valid() const { return m_valid; }
|
bool Valid() const { return m_valid; }
|
||||||
|
|
||||||
@@ -192,6 +212,8 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
private:
|
private:
|
||||||
void DeriveViews();
|
void DeriveViews();
|
||||||
|
|
||||||
|
void* m_private[4] = {};
|
||||||
|
std::uint64_t m_privateSizes[4] = {};
|
||||||
ShmSegment m_owned[4]; // empty on an attached (peer) view
|
ShmSegment m_owned[4]; // empty on an attached (peer) view
|
||||||
ShmSegment* m_segments[4] = {nullptr, nullptr, nullptr, nullptr};
|
ShmSegment* m_segments[4] = {nullptr, nullptr, nullptr, nullptr};
|
||||||
|
|
||||||
@@ -296,9 +318,11 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// stageHead with nothing advancing the two tails, so FreeBytes() would
|
// stageHead with nothing advancing the two tails, so FreeBytes() would
|
||||||
// fall to zero the first time the head lapped the capacity and never
|
// fall to zero the first time the head lapped the capacity and never
|
||||||
// recover: a guaranteed hang, not a slow path.
|
// recover: a guaranteed hang, not a slow path.
|
||||||
|
void Attach(ILink& link, std::uint32_t spinUs);
|
||||||
void Attach(RingControl* control, RingProducer* cmd, Doorbell* peerBell, Doorbell* selfBell,
|
void Attach(RingControl* control, RingProducer* cmd, Doorbell* peerBell, Doorbell* selfBell,
|
||||||
std::uint32_t spinUs);
|
std::uint32_t spinUs);
|
||||||
void Detach();
|
void Detach();
|
||||||
|
void SetLink(ILink* link) { m_link = link; }
|
||||||
bool Valid() const { return m_control != nullptr && m_cmd != nullptr; }
|
bool Valid() const { return m_control != nullptr && m_cmd != nullptr; }
|
||||||
|
|
||||||
// Publish the command ring's head, record submittedSeq, THEN ring - in
|
// Publish the command ring's head, record submittedSeq, THEN ring - in
|
||||||
@@ -347,6 +371,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// stalls forever.
|
// stalls forever.
|
||||||
SessionWait WaitForCmdSpace(std::uint64_t bytes, std::uint32_t timeoutMs);
|
SessionWait WaitForCmdSpace(std::uint64_t bytes, std::uint32_t timeoutMs);
|
||||||
|
|
||||||
|
LinkProgress* Progress() const { return m_control ? &m_control->Progress : nullptr; }
|
||||||
RingControl* Control() const { return m_control; }
|
RingControl* Control() const { return m_control; }
|
||||||
RingProducer* Cmd() const { return m_cmd; }
|
RingProducer* Cmd() const { return m_cmd; }
|
||||||
Doorbell* PeerDoorbell() const { return m_peerBell; }
|
Doorbell* PeerDoorbell() const { return m_peerBell; }
|
||||||
@@ -380,6 +405,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
template <class Ready>
|
template <class Ready>
|
||||||
SessionWait Park(Ready&& ready, std::uint32_t timeoutMs);
|
SessionWait Park(Ready&& ready, std::uint32_t timeoutMs);
|
||||||
|
|
||||||
|
ILink* m_link = nullptr;
|
||||||
RingControl* m_control = nullptr;
|
RingControl* m_control = nullptr;
|
||||||
RingProducer* m_cmd = nullptr;
|
RingProducer* m_cmd = nullptr;
|
||||||
Doorbell* m_peerBell = nullptr;
|
Doorbell* m_peerBell = nullptr;
|
||||||
@@ -402,9 +428,11 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
public:
|
public:
|
||||||
SessionConsumer() = default;
|
SessionConsumer() = default;
|
||||||
|
|
||||||
|
void Attach(ILink& link, std::uint32_t spinUs);
|
||||||
void Attach(RingControl* control, RingConsumer* cmd, Doorbell* peerBell, Doorbell* selfBell,
|
void Attach(RingControl* control, RingConsumer* cmd, Doorbell* peerBell, Doorbell* selfBell,
|
||||||
std::uint32_t spinUs);
|
std::uint32_t spinUs);
|
||||||
void Detach();
|
void Detach();
|
||||||
|
void SetLink(ILink* link) { m_link = link; }
|
||||||
bool Valid() const { return m_control != nullptr && m_cmd != nullptr; }
|
bool Valid() const { return m_control != nullptr && m_cmd != nullptr; }
|
||||||
|
|
||||||
// Park until a record is waiting, the session is shut down, or the
|
// Park until a record is waiting, the session is shut down, or the
|
||||||
@@ -502,6 +530,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
// How many kRecBorrowSlot records this consumer has seen. Non-zero in P5
|
// How many kRecBorrowSlot records this consumer has seen. Non-zero in P5
|
||||||
// is a finding, not a statistic.
|
// is a finding, not a statistic.
|
||||||
std::uint64_t BorrowedRecordsSeen() const { return m_borrowedSeen; }
|
std::uint64_t BorrowedRecordsSeen() const { return m_borrowedSeen; }
|
||||||
|
LinkProgress* Progress() const { return m_control ? &m_control->Progress : nullptr; }
|
||||||
RingControl* Control() const { return m_control; }
|
RingControl* Control() const { return m_control; }
|
||||||
RingConsumer* Cmd() const { return m_cmd; }
|
RingConsumer* Cmd() const { return m_cmd; }
|
||||||
Doorbell* PeerDoorbell() const { return m_peerBell; }
|
Doorbell* PeerDoorbell() const { return m_peerBell; }
|
||||||
@@ -509,6 +538,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
std::uint32_t SpinUs() const { return m_spinUs; }
|
std::uint32_t SpinUs() const { return m_spinUs; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ILink* m_link = nullptr;
|
||||||
RingControl* m_control = nullptr;
|
RingControl* m_control = nullptr;
|
||||||
RingConsumer* m_cmd = nullptr;
|
RingConsumer* m_cmd = nullptr;
|
||||||
Doorbell* m_peerBell = nullptr;
|
Doorbell* m_peerBell = nullptr;
|
||||||
@@ -525,43 +555,27 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// The ABI fingerprint's mixer - THE ONE IMPLEMENTATION.
|
// P6.5 wire fingerprint: one mixer, driven by compiler-derived layout facts.
|
||||||
//
|
// CapsCodec supplies generated member/catalogue digests; build identity and
|
||||||
// CapsCodec.cpp's CapsAbiFingerprint(), the value both handshakes compare,
|
// negotiated window sizes do not participate in wire compatibility.
|
||||||
// is exactly MixAbiFingerprint(CapsAbiFingerprintInputs()). It lives under
|
|
||||||
// Transport/ so that it can be tested without the GL frontend's umbrella
|
|
||||||
// header, and it takes its inputs as a struct so that the SAME function the
|
|
||||||
// handshake calls can be driven with one field perturbed at a time.
|
|
||||||
//
|
|
||||||
// The wave-1 review (ID-46 finding 6) found the previous shape - a
|
|
||||||
// five-argument mixer here and a SEPARATE hand-rolled FNV loop in
|
|
||||||
// CapsCodec.cpp - had exactly one caller of this function: the sensitivity
|
|
||||||
// test. Production never called it, so replacing CapsAbiFingerprint() with
|
|
||||||
// `return 1;` left every fingerprint test green and both peers agreeing on
|
|
||||||
// nothing. Now there is one mixer, the sensitivity case starts from the
|
|
||||||
// production entry point, and that perturbation turns it red.
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
// Wire facts only. Segment geometry and build identity are negotiated separately.
|
||||||
struct AbiFingerprintInputs {
|
struct AbiFingerprintInputs {
|
||||||
// The three struct shapes table 0's ABI-agreement row names.
|
|
||||||
std::uint64_t DynamicParamsSize = 0;
|
std::uint64_t DynamicParamsSize = 0;
|
||||||
std::uint64_t CapsSize = 0;
|
std::uint64_t CapsSize = 0;
|
||||||
std::uint64_t FunctionTableSize = 0;
|
std::uint64_t MemberLayout = 0;
|
||||||
// The caps blob's own geometry and the two blob codecs' versions: the
|
std::uint64_t CatalogueLayout = 0;
|
||||||
// format-capability table's extents and the codec version stamps.
|
std::uint64_t RenderStateLayout = 0;
|
||||||
std::uint64_t FormatCapabilityTargets = 0;
|
std::uint64_t FormatCapabilityTargets = 0;
|
||||||
std::uint64_t FormatCapabilityFormats = 0;
|
std::uint64_t FormatCapabilityFormats = 0;
|
||||||
std::uint64_t FormatCapabilitiesCodecVersion = 0;
|
std::uint64_t FormatCapabilitiesCodecVersion = 0;
|
||||||
std::uint64_t RendererInfoCodecVersion = 0;
|
std::uint64_t RendererInfoCodecVersion = 0;
|
||||||
// The catalogue's length (ID-33): a peer with one more opcode is a
|
std::uint64_t ProgramArtifactsCodecVersion = 0;
|
||||||
// different wire even if every struct kept its size.
|
std::uint64_t ProgramArtifactsSchema = 0;
|
||||||
std::uint64_t OpCount = 0;
|
std::uint64_t OpCount = 0;
|
||||||
// MOBILEGL_ABI_VERSION(major, minor): a protocol change that left every
|
|
||||||
// struct the same size, which nothing above can see.
|
|
||||||
std::uint32_t AbiVersion = 0;
|
std::uint32_t AbiVersion = 0;
|
||||||
// GIT_COMMIT_HASH_SHORT: two builds of the same sizes can still disagree
|
std::uint32_t PointerBits = 0;
|
||||||
// about a FIELD ORDER, which no sizeof can see. nullptr and "" are
|
std::uint32_t LittleEndian = 0;
|
||||||
// distinct inputs and neither equals a real stamp.
|
|
||||||
const char* BuildStamp = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// FNV-1a over every field above, in declaration order. Never 0: that value is
|
// FNV-1a over every field above, in declaration order. Never 0: that value is
|
||||||
|
|||||||
@@ -0,0 +1,136 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
#include "ShmLink.h"
|
||||||
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
|
LinkSignals ILink::Signals() {
|
||||||
|
auto* c = Memory().CmdControl();
|
||||||
|
return {&c->cmdHead, &c->submittedSeq, &c->consumerParked, &c->producerParked, &c->eventRingFull};
|
||||||
|
}
|
||||||
|
std::uint64_t ILink::SegmentSize(LinkSegment segment) {
|
||||||
|
auto& m = Memory();
|
||||||
|
switch (segment) {
|
||||||
|
case LinkSegment::Cmd:
|
||||||
|
return m.CmdRingCapacity();
|
||||||
|
case LinkSegment::Stage:
|
||||||
|
return m.StageBytes();
|
||||||
|
case LinkSegment::Reply:
|
||||||
|
return m.ReplyBytes();
|
||||||
|
case LinkSegment::Event:
|
||||||
|
return m.AnnouncedSize(SessionSegmentSlot::Event);
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::unique_ptr<ILink> CreateSharedLink(TransportRoleTag role) {
|
||||||
|
auto link = std::make_unique<ShmLink>();
|
||||||
|
link->SetRole(role);
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
void ShmLink::InitializeEndpoints() {
|
||||||
|
auto* c = m_memory.CmdControl();
|
||||||
|
m_commandsOut = RingProducer(c, m_memory.CmdRingBase(), m_memory.CmdRingCapacity(), RingCursorSet::Cmd);
|
||||||
|
m_commandsIn = RingConsumer(c, m_memory.CmdRingBase(), m_memory.CmdRingCapacity(), RingCursorSet::Cmd);
|
||||||
|
m_eventsOut =
|
||||||
|
EventRingProducer(m_memory.EventControl(), c, m_memory.EventRingBase(), m_memory.EventRingCapacity());
|
||||||
|
m_eventsIn = EventRingConsumer(m_memory.EventControl(), c, m_memory.EventRingBase(),
|
||||||
|
m_memory.EventRingCapacity(), m_memory.EventSegmentBase());
|
||||||
|
if (m_role == TransportRoleTag::ServerConsumer) {
|
||||||
|
ReplySlotPool pool(m_memory.ReplyBase(), m_memory.ReplyBytes(), m_memory.ReplySlotCount());
|
||||||
|
pool.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void ShmLink::BindDoorbells(Doorbell* c, Doorbell* p) {
|
||||||
|
m_consumer = c;
|
||||||
|
m_producer = p;
|
||||||
|
}
|
||||||
|
LinkCapabilities ShmLink::Capabilities() const {
|
||||||
|
const ReplySlotPool replies(m_memory.ReplyBase(), m_memory.ReplyBytes(), m_memory.ReplySlotCount());
|
||||||
|
return {true, true, true, m_memory.CmdRingCapacity() / 2, replies.MaxReplyBytes()};
|
||||||
|
}
|
||||||
|
LinkProgress* ShmLink::Progress() {
|
||||||
|
return m_memory.Valid() ? &m_memory.CmdControl()->Progress : nullptr;
|
||||||
|
}
|
||||||
|
LinkEventFlags* ShmLink::EventFlags() {
|
||||||
|
return m_memory.Valid() ? reinterpret_cast<LinkEventFlags*>(&m_memory.CmdControl()->eventRingFull) : nullptr;
|
||||||
|
}
|
||||||
|
LinkArena* ShmLink::RecordArena() {
|
||||||
|
m_recordArena = {m_memory.CmdRingBase(), m_memory.CmdRingCapacity(), m_memory.CmdRingCapacity() - 1,
|
||||||
|
m_commandsOut.LocalHead()};
|
||||||
|
return &m_recordArena;
|
||||||
|
}
|
||||||
|
LinkCursor* ShmLink::RecordCursor() {
|
||||||
|
m_recordCursor = {m_memory.CmdRingBase(), m_memory.CmdRingCapacity(), m_memory.CmdRingCapacity() - 1,
|
||||||
|
m_commandsIn.LocalTail()};
|
||||||
|
return &m_recordCursor;
|
||||||
|
}
|
||||||
|
LinkArena* ShmLink::EventArena() {
|
||||||
|
m_eventArena = {m_memory.EventRingBase(), m_memory.EventRingCapacity(), m_memory.EventRingCapacity() - 1,
|
||||||
|
m_eventsOut.Ring().LocalHead()};
|
||||||
|
return &m_eventArena;
|
||||||
|
}
|
||||||
|
LinkCursor* ShmLink::EventCursor() {
|
||||||
|
m_eventCursor = {m_memory.EventRingBase(), m_memory.EventRingCapacity(), m_memory.EventRingCapacity() - 1,
|
||||||
|
m_eventsIn.Ring().LocalTail()};
|
||||||
|
return &m_eventCursor;
|
||||||
|
}
|
||||||
|
MobileGLResult ShmLink::StageBytes(std::uint64_t, LinkSpan*, void**) {
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
MobileGLResult ShmLink::ResolveSpan(LinkSegment segment, LinkSpan span, const void** out) {
|
||||||
|
if (!out || !Attached()) return MOBILEGL_ERR_NOT_INITIALIZED;
|
||||||
|
const void* base = nullptr;
|
||||||
|
std::uint64_t size = 0;
|
||||||
|
switch (segment) {
|
||||||
|
case LinkSegment::Cmd:
|
||||||
|
base = m_memory.CmdRingBase();
|
||||||
|
size = m_memory.CmdRingCapacity();
|
||||||
|
break;
|
||||||
|
case LinkSegment::Stage:
|
||||||
|
base = m_memory.StageBase();
|
||||||
|
size = m_memory.StageBytes();
|
||||||
|
break;
|
||||||
|
case LinkSegment::Reply:
|
||||||
|
base = m_memory.ReplyBase();
|
||||||
|
size = m_memory.ReplyBytes();
|
||||||
|
break;
|
||||||
|
case LinkSegment::Event:
|
||||||
|
base = m_memory.EventSegmentBase();
|
||||||
|
size = m_memory.AnnouncedSize(SessionSegmentSlot::Event);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
if (span.Offset > size || span.Size > size - span.Offset) return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
|
*out = static_cast<const std::uint8_t*>(base) + span.Offset;
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
MobileGLResult ShmLink::PostReply(std::uint64_t seq, std::int32_t status, const void* payload, std::uint64_t size) {
|
||||||
|
ReplySlotPool replies(m_memory.ReplyBase(), m_memory.ReplyBytes(), m_memory.ReplySlotCount());
|
||||||
|
replies.Post(seq, status, payload, size);
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
MobileGLResult ShmLink::ReadReply(std::uint64_t seq, std::int32_t* status, const void** payload,
|
||||||
|
std::uint64_t* size) {
|
||||||
|
if (!status || !payload || !size) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
ReplySlotPool replies(m_memory.ReplyBase(), m_memory.ReplyBytes(), m_memory.ReplySlotCount());
|
||||||
|
return replies.ReadView(seq, status, payload, size) ? MOBILEGL_OK : MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
|
}
|
||||||
|
std::uint64_t ShmLink::EventPublishedHead() const {
|
||||||
|
return m_memory.Valid() ? m_memory.EventControl()->cmdHead.load(std::memory_order_acquire) : 0;
|
||||||
|
}
|
||||||
|
MobileGLResult ShmLink::WaitForEventDelivery(std::uint64_t head, std::uint32_t) {
|
||||||
|
return EventPublishedHead() >= head ? MOBILEGL_OK : MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
|
}
|
||||||
|
Doorbell& ShmLink::ConsumerBell() {
|
||||||
|
return *m_consumer;
|
||||||
|
}
|
||||||
|
Doorbell& ShmLink::ProducerBell() {
|
||||||
|
return *m_producer;
|
||||||
|
}
|
||||||
|
void ShmLink::Detach() {
|
||||||
|
m_commandsOut = {};
|
||||||
|
m_commandsIn = {};
|
||||||
|
m_eventsOut = {};
|
||||||
|
m_eventsIn = {};
|
||||||
|
m_memory.Close();
|
||||||
|
}
|
||||||
|
} // namespace MobileGL::MG_Remote::Transport
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
#pragma once
|
||||||
|
#include "ILink.h"
|
||||||
|
#include "SessionRings.h"
|
||||||
|
#include <vector>
|
||||||
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
|
// Owns the mappings and every physical endpoint. Shared and private mirrored
|
||||||
|
// storage use identical ring algorithms; only delivery belongs to the link.
|
||||||
|
class ShmLink final : public ILink {
|
||||||
|
public:
|
||||||
|
ShmLink() = default;
|
||||||
|
~ShmLink() override = default;
|
||||||
|
SessionSegments& Memory() override { return m_memory; }
|
||||||
|
RingProducer& CommandsOut() override { return m_commandsOut; }
|
||||||
|
RingConsumer& CommandsIn() override { return m_commandsIn; }
|
||||||
|
EventRingProducer& EventsOut() override { return m_eventsOut; }
|
||||||
|
EventRingConsumer& EventsIn() override { return m_eventsIn; }
|
||||||
|
void InitializeEndpoints() override;
|
||||||
|
void BindDoorbells(Doorbell* consumer, Doorbell* producer) override;
|
||||||
|
void SetRole(TransportRoleTag role) { m_role = role; }
|
||||||
|
LinkCapabilities Capabilities() const override;
|
||||||
|
LinkProgress* Progress() override;
|
||||||
|
LinkEventFlags* EventFlags() override;
|
||||||
|
LinkArena* RecordArena() override;
|
||||||
|
LinkCursor* RecordCursor() override;
|
||||||
|
MobileGLResult StageBytes(std::uint64_t, LinkSpan*, void**) override;
|
||||||
|
MobileGLResult ResolveSpan(LinkSegment, LinkSpan, const void**) override;
|
||||||
|
MobileGLResult PostReply(std::uint64_t, std::int32_t, const void*, std::uint64_t) override;
|
||||||
|
MobileGLResult ReadReply(std::uint64_t, std::int32_t*, const void**, std::uint64_t*) override;
|
||||||
|
LinkArena* EventArena() override;
|
||||||
|
LinkCursor* EventCursor() override;
|
||||||
|
std::uint64_t EventPublishedHead() const override;
|
||||||
|
MobileGLResult WaitForEventDelivery(std::uint64_t head, std::uint32_t timeoutMs) override;
|
||||||
|
Doorbell& ConsumerBell() override;
|
||||||
|
Doorbell& ProducerBell() override;
|
||||||
|
MobileGLResult Flush() override { return MOBILEGL_OK; }
|
||||||
|
MobileGLResult FlushProgress() override { return MOBILEGL_OK; }
|
||||||
|
bool Attached() const override { return m_memory.Valid(); }
|
||||||
|
void Detach() override;
|
||||||
|
TransportRoleTag Role() const override { return m_role; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
SessionSegments m_memory;
|
||||||
|
RingProducer m_commandsOut;
|
||||||
|
RingConsumer m_commandsIn;
|
||||||
|
EventRingProducer m_eventsOut;
|
||||||
|
EventRingConsumer m_eventsIn;
|
||||||
|
Doorbell* m_consumer = nullptr;
|
||||||
|
Doorbell* m_producer = nullptr;
|
||||||
|
TransportRoleTag m_role = TransportRoleTag::ClientProducer;
|
||||||
|
LinkArena m_recordArena{}, m_eventArena{};
|
||||||
|
LinkCursor m_recordCursor{}, m_eventCursor{};
|
||||||
|
std::vector<std::uint8_t> m_reply;
|
||||||
|
};
|
||||||
|
} // namespace MobileGL::MG_Remote::Transport
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "RoleMemory.h"
|
#include "RoleMemory.h"
|
||||||
#include "SessionRings.h"
|
#include "SessionRings.h"
|
||||||
|
#include <new>
|
||||||
|
|
||||||
#include <MG_Util/Debug/Log.h>
|
#include <MG_Util/Debug/Log.h>
|
||||||
|
|
||||||
@@ -308,6 +309,36 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
return MOBILEGL_OK;
|
return MOBILEGL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobileGLResult SessionSegments::CreatePrivate(const SessionSegmentSizes& sizes, MemoryRole role) {
|
||||||
|
Close();
|
||||||
|
const std::uint64_t bytes[4] = {SegmentBytesForRing(sizes.CmdRingBytes), sizes.StageBytes,
|
||||||
|
sizes.ReplyBytes, SegmentBytesForRing(sizes.EventRingBytes)};
|
||||||
|
for (unsigned i = 0; i != 4; ++i) {
|
||||||
|
if (!bytes[i] || bytes[i] > static_cast<std::uint64_t>(SIZE_MAX)) {
|
||||||
|
Close(); return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
m_private[i] = ::operator new(static_cast<std::size_t>(bytes[i]),
|
||||||
|
std::align_val_t{alignof(RingControl)}, std::nothrow);
|
||||||
|
if (!m_private[i]) { Close(); return MOBILEGL_ERR_OUT_OF_MEMORY; }
|
||||||
|
m_privateSizes[i] = bytes[i];
|
||||||
|
std::memset(m_private[i], 0, static_cast<std::size_t>(bytes[i]));
|
||||||
|
m_mappedBytes += bytes[i];
|
||||||
|
}
|
||||||
|
m_cmdControl = static_cast<RingControl*>(m_private[0]);
|
||||||
|
m_cmdRingBase = static_cast<std::uint8_t*>(m_private[0]) + sizeof(RingControl);
|
||||||
|
m_cmdRingCapacity = RingCapacityForSegment(bytes[0]);
|
||||||
|
m_stageBase = m_private[1]; m_stageBytes = bytes[1];
|
||||||
|
m_replyBase = m_private[2]; m_replyBytes = bytes[2]; m_replySlotCount = sizes.ReplySlotCount;
|
||||||
|
m_eventControl = static_cast<RingControl*>(m_private[3]);
|
||||||
|
m_eventSegmentBase = m_private[3];
|
||||||
|
m_eventRingBase = static_cast<std::uint8_t*>(m_private[3]) + sizeof(RingControl);
|
||||||
|
m_eventRingCapacity = RingCapacityForSegment(bytes[3]);
|
||||||
|
InitRingControl(*m_cmdControl); InitRingControl(*m_eventControl);
|
||||||
|
m_role = role; m_valid = true;
|
||||||
|
LedgerAddSegment(role, m_mappedBytes); m_booked = true;
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
MobileGLResult SessionSegments::AttachInProcess(SessionSegments& owner, MemoryRole role) {
|
MobileGLResult SessionSegments::AttachInProcess(SessionSegments& owner, MemoryRole role) {
|
||||||
Close();
|
Close();
|
||||||
if (!owner.Valid()) {
|
if (!owner.Valid()) {
|
||||||
@@ -373,6 +404,65 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
return MOBILEGL_OK;
|
return MOBILEGL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobileGLResult SessionSegments::AdoptFromDescriptors(const int fds[4],
|
||||||
|
const std::uint64_t sizes[4],
|
||||||
|
std::uint32_t replySlotCount,
|
||||||
|
MemoryRole role) {
|
||||||
|
Close();
|
||||||
|
#if defined(_WIN32)
|
||||||
|
(void)fds; (void)sizes; (void)replySlotCount; (void)role;
|
||||||
|
// ShmSegment::Adopt is POSIX-only and a Windows peer resolves the section
|
||||||
|
// by the name in SegmentRef instead. Refused BY NAME rather than silently
|
||||||
|
// producing an unmapped session (CONTRACT-P6 §2.6).
|
||||||
|
MGLOG_E("MG_Remote session: AdoptFromDescriptors is POSIX-only - P6 lands POSIX only");
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
#else
|
||||||
|
for (std::size_t index = 0; index < kSlotCount; ++index) {
|
||||||
|
if (fds[index] < 0 || sizes[index] == 0) {
|
||||||
|
MGLOG_E("MG_Remote session: slot %zu arrived with fd=%d size=%llu - the server's "
|
||||||
|
"SCM_RIGHTS hand-off is incomplete",
|
||||||
|
index, fds[index], static_cast<unsigned long long>(sizes[index]));
|
||||||
|
Close();
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_owns = true;
|
||||||
|
for (std::size_t index = 0; index < kSlotCount; ++index) {
|
||||||
|
// Adopt takes ownership only on success, and it fstats the descriptor
|
||||||
|
// against the announced size - which is the only bound there is on a
|
||||||
|
// peer's claim about how big a segment is (CONTRACT-P6 §4.4 notes it
|
||||||
|
// has no analogue on a link with no fd).
|
||||||
|
const MobileGLResult adopted = ShmSegment::Adopt(fds[index], sizes[index],
|
||||||
|
m_owned[index]);
|
||||||
|
if (adopted != MOBILEGL_OK) {
|
||||||
|
MGLOG_E("MG_Remote session: adopting slot %zu (fd=%d, %llu bytes) failed",
|
||||||
|
index, fds[index], static_cast<unsigned long long>(sizes[index]));
|
||||||
|
Close();
|
||||||
|
return adopted;
|
||||||
|
}
|
||||||
|
const MobileGLResult mapped = m_owned[index].Map(false);
|
||||||
|
if (mapped != MOBILEGL_OK) {
|
||||||
|
Close();
|
||||||
|
return mapped;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_replySlotCount = replySlotCount;
|
||||||
|
// NOT DeriveViews' control-page initialisation: the SERVER created these
|
||||||
|
// and already initialised both RingControls. Re-initialising here would
|
||||||
|
// zero the owner's cursors out from under a session that is already
|
||||||
|
// running - the same reason AttachInProcess does not do it either.
|
||||||
|
DeriveViews();
|
||||||
|
if (!m_valid) {
|
||||||
|
Close();
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
m_role = role;
|
||||||
|
LedgerAddSegment(role, m_mappedBytes);
|
||||||
|
m_booked = true;
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void SessionSegments::DeriveViews() {
|
void SessionSegments::DeriveViews() {
|
||||||
m_valid = false;
|
m_valid = false;
|
||||||
if (m_owns) {
|
if (m_owns) {
|
||||||
@@ -438,6 +528,8 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
}
|
}
|
||||||
for (std::size_t index = 0; index < kSlotCount; ++index) {
|
for (std::size_t index = 0; index < kSlotCount; ++index) {
|
||||||
m_segments[index] = nullptr;
|
m_segments[index] = nullptr;
|
||||||
|
if (m_private[index]) ::operator delete(m_private[index], std::align_val_t{alignof(RingControl)});
|
||||||
|
m_private[index] = nullptr; m_privateSizes[index] = 0;
|
||||||
}
|
}
|
||||||
m_cmdControl = nullptr;
|
m_cmdControl = nullptr;
|
||||||
m_cmdRingBase = nullptr;
|
m_cmdRingBase = nullptr;
|
||||||
@@ -457,7 +549,7 @@ namespace MobileGL::MG_Remote::Transport {
|
|||||||
|
|
||||||
std::uint64_t SessionSegments::AnnouncedSize(SessionSegmentSlot slot) const {
|
std::uint64_t SessionSegments::AnnouncedSize(SessionSegmentSlot slot) const {
|
||||||
const ShmSegment* segment = m_segments[SlotIndex(slot)];
|
const ShmSegment* segment = m_segments[SlotIndex(slot)];
|
||||||
return segment == nullptr ? 0 : segment->Size();
|
return segment == nullptr ? m_privateSizes[SlotIndex(slot)] : segment->Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* SessionSegments::AnnouncedName(SessionSegmentSlot slot) const {
|
const char* SessionSegments::AnnouncedName(SessionSegmentSlot slot) const {
|
||||||
|
|||||||
@@ -0,0 +1,714 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Remote/Transport/SocketTransport.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
|
||||||
|
|
||||||
|
#include "SocketTransport.h"
|
||||||
|
|
||||||
|
#include "Doorbell.h" // kWaitForever
|
||||||
|
#include "FdPassing.h"
|
||||||
|
#include "WireLog.h"
|
||||||
|
|
||||||
|
#include <cerrno>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
#if defined(__unix__) || defined(__APPLE__) || defined(__ANDROID__)
|
||||||
|
# define MOBILEGL_SOCKET_TRANSPORT_POSIX 1
|
||||||
|
# include <poll.h>
|
||||||
|
# include <sys/stat.h>
|
||||||
|
# include <sys/un.h>
|
||||||
|
# include <sys/socket.h>
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
# include <netdb.h>
|
||||||
|
# include <netinet/in.h>
|
||||||
|
# include <netinet/tcp.h>
|
||||||
|
#else
|
||||||
|
# define MOBILEGL_SOCKET_TRANSPORT_POSIX 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
|
|
||||||
|
#if MOBILEGL_SOCKET_TRANSPORT_POSIX
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr std::uint64_t kPumpChunkBytes = 64ull * 1024;
|
||||||
|
|
||||||
|
bool TcpName(const std::string& name) { return name.compare(0, 6, "tcp://") == 0; }
|
||||||
|
|
||||||
|
bool TcpAddress(const std::string& name, addrinfo** result) {
|
||||||
|
*result = nullptr;
|
||||||
|
const std::string address = name.substr(6);
|
||||||
|
std::string host, port;
|
||||||
|
if (!address.empty() && address[0] == '[') {
|
||||||
|
const auto end = address.find(']');
|
||||||
|
if (end == std::string::npos || end + 1 >= address.size() || address[end + 1] != ':')
|
||||||
|
return false;
|
||||||
|
host = address.substr(1, end - 1);
|
||||||
|
port = address.substr(end + 2);
|
||||||
|
} else {
|
||||||
|
const auto colon = address.find(':');
|
||||||
|
if (colon == std::string::npos || address.find(':', colon + 1) != std::string::npos)
|
||||||
|
return false;
|
||||||
|
host = address.substr(0, colon);
|
||||||
|
port = address.substr(colon + 1);
|
||||||
|
}
|
||||||
|
if (host.empty() || port.empty() || port.find_first_not_of("0123456789") != std::string::npos)
|
||||||
|
return false;
|
||||||
|
char* end = nullptr;
|
||||||
|
const auto number = std::strtoul(port.c_str(), &end, 10);
|
||||||
|
if (*end || number == 0 || number > 65535) return false;
|
||||||
|
addrinfo hints{};
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_protocol = IPPROTO_TCP;
|
||||||
|
hints.ai_flags = AI_NUMERICSERV;
|
||||||
|
return ::getaddrinfo(host.c_str(), port.c_str(), &hints, result) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Loopback(const sockaddr* address) {
|
||||||
|
if (address->sa_family == AF_INET)
|
||||||
|
return (ntohl(reinterpret_cast<const sockaddr_in*>(address)->sin_addr.s_addr) >> 24) == 127;
|
||||||
|
if (address->sa_family == AF_INET6)
|
||||||
|
return IN6_IS_ADDR_LOOPBACK(&reinterpret_cast<const sockaddr_in6*>(address)->sin6_addr);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TcpSocket(int fd) {
|
||||||
|
sockaddr_storage address{};
|
||||||
|
socklen_t size = sizeof(address);
|
||||||
|
return ::getsockname(fd, reinterpret_cast<sockaddr*>(&address), &size) == 0 &&
|
||||||
|
(address.ss_family == AF_INET || address.ss_family == AF_INET6);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConfigureTcp(int fd) {
|
||||||
|
const int one = 1, idle = 2, interval = 1, count = 3, timeout = 5000;
|
||||||
|
if (::setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) != 0 ||
|
||||||
|
::setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof(one)) != 0) return false;
|
||||||
|
#if defined(TCP_KEEPIDLE)
|
||||||
|
if (::setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle)) != 0) return false;
|
||||||
|
#endif
|
||||||
|
#if defined(TCP_KEEPINTVL)
|
||||||
|
if (::setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(interval)) != 0) return false;
|
||||||
|
#endif
|
||||||
|
#if defined(TCP_KEEPCNT)
|
||||||
|
if (::setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &count, sizeof(count)) != 0) return false;
|
||||||
|
#endif
|
||||||
|
#if defined(TCP_USER_TIMEOUT)
|
||||||
|
if (::setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout, sizeof(timeout)) != 0) return false;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult ConnectTcp(const std::string& name, std::uint32_t timeoutMs, int* outFd) {
|
||||||
|
addrinfo* addresses = nullptr;
|
||||||
|
if (!TcpAddress(name, &addresses)) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
const auto deadline = std::chrono::steady_clock::now() +
|
||||||
|
std::chrono::milliseconds(std::max(1u, timeoutMs));
|
||||||
|
do {
|
||||||
|
for (auto* address = addresses; address; address = address->ai_next) {
|
||||||
|
const int fd = ::socket(address->ai_family, SOCK_STREAM, IPPROTO_TCP);
|
||||||
|
if (fd < 0) continue;
|
||||||
|
const int flags = ::fcntl(fd, F_GETFL, 0);
|
||||||
|
::fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
||||||
|
bool connected = ::connect(fd, address->ai_addr, address->ai_addrlen) == 0;
|
||||||
|
if (!connected && errno == EINPROGRESS) {
|
||||||
|
const auto remaining = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
|
deadline - std::chrono::steady_clock::now()).count();
|
||||||
|
pollfd pfd{fd, POLLOUT, 0};
|
||||||
|
int rc;
|
||||||
|
do { rc = ::poll(&pfd, 1, static_cast<int>(std::max<std::int64_t>(0, remaining))); }
|
||||||
|
while (rc < 0 && errno == EINTR && std::chrono::steady_clock::now() < deadline);
|
||||||
|
int error = 0;
|
||||||
|
socklen_t length = sizeof(error);
|
||||||
|
connected = rc > 0 && ::getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &length) == 0 && error == 0;
|
||||||
|
}
|
||||||
|
if (connected && ConfigureTcp(fd)) {
|
||||||
|
::fcntl(fd, F_SETFL, flags);
|
||||||
|
::fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||||
|
*outFd = fd;
|
||||||
|
::freeaddrinfo(addresses);
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
::close(fd);
|
||||||
|
if (std::chrono::steady_clock::now() >= deadline) break;
|
||||||
|
}
|
||||||
|
::usleep(5000);
|
||||||
|
} while (std::chrono::steady_clock::now() < deadline);
|
||||||
|
::freeaddrinfo(addresses);
|
||||||
|
WireLogError("MG_Remote SocketTransport: TCP connect to %s exhausted %u ms", name.c_str(), timeoutMs);
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult ListenTcp(const std::string& name, int* outFd) {
|
||||||
|
addrinfo* addresses = nullptr;
|
||||||
|
if (!TcpAddress(name, &addresses)) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
const char* token = std::getenv("MOBILEGL_IPC_TOKEN");
|
||||||
|
const bool authenticated = token != nullptr && token[0] != '\0';
|
||||||
|
MobileGLResult result = MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
for (auto* address = addresses; address; address = address->ai_next) {
|
||||||
|
if (!authenticated && !Loopback(address->ai_addr)) {
|
||||||
|
WireLogError("MG_Remote: Refuse{AuthenticationRequired} non-loopback TCP listen needs MOBILEGL_IPC_TOKEN");
|
||||||
|
result = MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const int fd = ::socket(address->ai_family, SOCK_STREAM, IPPROTO_TCP);
|
||||||
|
if (fd < 0) continue;
|
||||||
|
const int one = 1;
|
||||||
|
::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||||
|
::fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||||
|
if (::bind(fd, address->ai_addr, address->ai_addrlen) == 0 && ::listen(fd, 8) == 0) {
|
||||||
|
*outFd = fd;
|
||||||
|
result = MOBILEGL_OK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
::close(fd);
|
||||||
|
}
|
||||||
|
::freeaddrinfo(addresses);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseIfOpen(int& fd) {
|
||||||
|
if (fd >= 0) {
|
||||||
|
::close(fd);
|
||||||
|
fd = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// poll() for readability. Returns:
|
||||||
|
// 1 readable 0 timed out -1 error (errno set)
|
||||||
|
// EINTR is retried rather than reported: a signal is not a transport
|
||||||
|
// event, and reporting it as one would make every caller's timeout
|
||||||
|
// budget a lie on a process that takes signals (and `sm`'s child takes
|
||||||
|
// SIGCHLD by construction).
|
||||||
|
int WaitReadable(int fd, std::uint32_t timeoutMs) {
|
||||||
|
for (;;) {
|
||||||
|
struct pollfd pfd {};
|
||||||
|
pfd.fd = fd;
|
||||||
|
pfd.events = POLLIN;
|
||||||
|
const int timeout =
|
||||||
|
timeoutMs == kWaitForever ? -1 : static_cast<int>(timeoutMs);
|
||||||
|
const int rc = ::poll(&pfd, 1, timeout);
|
||||||
|
if (rc < 0 && errno == EINTR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// A filesystem AF_UNIX path, bounded by sun_path. Refused BY NAME when it
|
||||||
|
// does not fit rather than silently truncated - a truncated path is a
|
||||||
|
// different socket, and both sides would then "succeed" onto two
|
||||||
|
// different names.
|
||||||
|
// A LEADING '@' MEANS THE ABSTRACT NAMESPACE, which is the convention systemd and D-Bus
|
||||||
|
// use and the only rendezvous that works on Android.
|
||||||
|
//
|
||||||
|
// A filesystem AF_UNIX endpoint needs a writable directory, and an Android app has no
|
||||||
|
// /tmp - measured, not assumed: the first device run of the spawn arm launched its server
|
||||||
|
// fine and then died on `could not connect to "/tmp/mgl-15731-...sock" ... No such file or
|
||||||
|
// directory`, because bind() in the child had nowhere to put the node. The app's own cache
|
||||||
|
// dir would work, but only if every integrator remembered to say where it is, and the
|
||||||
|
// library has no way to ask.
|
||||||
|
//
|
||||||
|
// An abstract name has no filesystem presence at all: no directory, no mode bits, no stale
|
||||||
|
// node to unlink after a crash - which is the bind() failure `Listen` currently works
|
||||||
|
// around. It is scoped to the network namespace, so the two processes of ONE app find each
|
||||||
|
// other and nothing else can, which is exactly the reach this needs.
|
||||||
|
//
|
||||||
|
// Linux-only by construction. A path without '@' still works everywhere, and that is what
|
||||||
|
// an explicit endpoint (P12's "connect to something somebody else is listening on") uses.
|
||||||
|
bool IsAbstractEndpoint(const std::string& path) {
|
||||||
|
return !path.empty() && path[0] == '@';
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FillAddress(const std::string& path, sockaddr_un* out, socklen_t* outLen) {
|
||||||
|
std::memset(out, 0, sizeof(*out));
|
||||||
|
out->sun_family = AF_UNIX;
|
||||||
|
if (path.empty() || path.size() >= sizeof(out->sun_path)) {
|
||||||
|
WireLogError("MG_Remote SocketTransport: endpoint path is empty or longer than "
|
||||||
|
"sun_path allows (%zu >= %zu): \"%s\"",
|
||||||
|
path.size(), sizeof(out->sun_path), path.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (IsAbstractEndpoint(path)) {
|
||||||
|
// sun_path[0] STAYS NUL and the rest is the name. The length carries the name's
|
||||||
|
// end - there is no terminator - so it is offsetof + 1 + (size - 1), which is
|
||||||
|
// offsetof + size. Getting this wrong does not fail: it binds a DIFFERENT name
|
||||||
|
// (one padded with NULs), and the peer then connects to something that is not
|
||||||
|
// there.
|
||||||
|
std::memcpy(out->sun_path + 1, path.c_str() + 1, path.size() - 1);
|
||||||
|
*outLen = static_cast<socklen_t>(offsetof(sockaddr_un, sun_path) + path.size());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
std::memcpy(out->sun_path, path.c_str(), path.size());
|
||||||
|
*outLen = static_cast<socklen_t>(offsetof(sockaddr_un, sun_path) + path.size() + 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult ConnectOne(const std::string& path, std::uint32_t timeoutMs, int* outFd) {
|
||||||
|
if (TcpName(path)) return ConnectTcp(path, timeoutMs, outFd);
|
||||||
|
sockaddr_un address{};
|
||||||
|
socklen_t length = 0;
|
||||||
|
if (!FillAddress(path, &address, &length)) {
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
// Retry with a bound budget: the server may not have reached bind()
|
||||||
|
// yet. An exhausted budget is a NAMED refusal, never a fallback -
|
||||||
|
// CONTRACT-P6 §3.4 calls for a bounded retry and says so.
|
||||||
|
const std::uint32_t deadline = timeoutMs == 0 ? 1 : timeoutMs;
|
||||||
|
for (std::uint32_t waited = 0;; waited += 5) {
|
||||||
|
const int fd = ::socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
if (fd < 0) {
|
||||||
|
WireLogError("MG_Remote SocketTransport: socket() failed: %s",
|
||||||
|
std::strerror(errno));
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
if (::connect(fd, reinterpret_cast<sockaddr*>(&address), length) == 0) {
|
||||||
|
*outFd = fd;
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
const int failure = errno;
|
||||||
|
::close(fd);
|
||||||
|
if (waited >= deadline) {
|
||||||
|
WireLogError("MG_Remote SocketTransport: could not connect to \"%s\" within "
|
||||||
|
"%u ms: %s - REFUSING BY NAME, there is no monolith fallback "
|
||||||
|
"from here",
|
||||||
|
path.c_str(), deadline, std::strerror(failure));
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
::usleep(5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
MobileGLResult SocketTransport::Listen(const std::string& path, int* outListenFd) {
|
||||||
|
if (outListenFd == nullptr) {
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
*outListenFd = -1;
|
||||||
|
if (TcpName(path)) return ListenTcp(path, outListenFd);
|
||||||
|
sockaddr_un address{};
|
||||||
|
socklen_t length = 0;
|
||||||
|
if (!FillAddress(path, &address, &length)) {
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
// A stale socket file from a server that died is the normal case, not the
|
||||||
|
// exceptional one, and bind() fails on it with EADDRINUSE. Unlinking first
|
||||||
|
// is what every AF_UNIX server does; the alternative is a server that
|
||||||
|
// cannot restart until someone cleans up by hand. An ABSTRACT name has no
|
||||||
|
// node to go stale and unlink("@...") would delete a file of that literal
|
||||||
|
// name if one happened to exist.
|
||||||
|
const bool abstractEndpoint = IsAbstractEndpoint(path);
|
||||||
|
if (!abstractEndpoint) {
|
||||||
|
::unlink(path.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
const int listenFd = ::socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
if (listenFd < 0) {
|
||||||
|
WireLogError("MG_Remote SocketTransport: socket() failed: %s", std::strerror(errno));
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
if (::bind(listenFd, reinterpret_cast<sockaddr*>(&address), length) != 0) {
|
||||||
|
WireLogError("MG_Remote SocketTransport: bind(\"%s\") failed: %s", path.c_str(),
|
||||||
|
std::strerror(errno));
|
||||||
|
::close(listenFd);
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
// 0600: the rendezvous is between one user's processes. An AF_UNIX path
|
||||||
|
// is a filesystem object and its mode is the only access control there is.
|
||||||
|
// An abstract name is not a filesystem object and has none; its reach is
|
||||||
|
// the network namespace, which for an Android app is the app.
|
||||||
|
if (!abstractEndpoint) {
|
||||||
|
::chmod(path.c_str(), 0600);
|
||||||
|
}
|
||||||
|
if (::listen(listenFd, 4) != 0) {
|
||||||
|
WireLogError("MG_Remote SocketTransport: listen(\"%s\") failed: %s", path.c_str(),
|
||||||
|
std::strerror(errno));
|
||||||
|
::close(listenFd);
|
||||||
|
if (!abstractEndpoint) {
|
||||||
|
::unlink(path.c_str());
|
||||||
|
}
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
*outListenFd = listenFd;
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult SocketTransport::AcceptPair(int listenFd, std::uint32_t timeoutMs,
|
||||||
|
std::unique_ptr<SocketTransport>& outServer) {
|
||||||
|
outServer.reset();
|
||||||
|
if (listenFd < 0) {
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
int accepted[2] = {-1, -1};
|
||||||
|
for (int index = 0; index < 2; ++index) {
|
||||||
|
const std::uint32_t budget = index == 0 ? timeoutMs : 2000;
|
||||||
|
for (;;) {
|
||||||
|
const int ready = WaitReadable(listenFd, budget);
|
||||||
|
if (ready <= 0) {
|
||||||
|
for (int fd : accepted) {
|
||||||
|
if (fd >= 0) ::close(fd);
|
||||||
|
}
|
||||||
|
// Half a client is not a client. Both connections or neither, so
|
||||||
|
// a peer that died between the two cannot leave a session that
|
||||||
|
// looks up but has no way to receive a descriptor.
|
||||||
|
if (index != 0 || ready < 0) WireLogError("MG_Remote SocketTransport: only %d of 2 connections arrived within "
|
||||||
|
"%u ms", index, timeoutMs);
|
||||||
|
return ready == 0 ? MOBILEGL_ERR_TIMEOUT : MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
accepted[index] = ::accept(listenFd, nullptr, nullptr);
|
||||||
|
if (accepted[index] >= 0) break;
|
||||||
|
// EINTR (this process reaps SIGCHLD by construction) and ECONNABORTED
|
||||||
|
// (the peer reset between poll() and accept()) are not transport
|
||||||
|
// failures: the listener is still good. Re-poll within the budget
|
||||||
|
// rather than returning TRANSPORT_CLOSED, which the --serve
|
||||||
|
// supervisor turns into a full server exit (return 73).
|
||||||
|
if (errno == EINTR || errno == ECONNABORTED) continue;
|
||||||
|
for (int fd : accepted) {
|
||||||
|
if (fd >= 0) ::close(fd);
|
||||||
|
}
|
||||||
|
WireLogError("MG_Remote SocketTransport: accept failed: %s", std::strerror(errno));
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
::fcntl(accepted[index], F_SETFD, FD_CLOEXEC);
|
||||||
|
if (TcpSocket(accepted[index]) && !ConfigureTcp(accepted[index])) {
|
||||||
|
for (int fd : accepted) if (fd >= 0) ::close(fd);
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// First connection is control, second is aux. The order IS the protocol;
|
||||||
|
// it is stated here and in ConnectTo and nowhere else.
|
||||||
|
outServer = std::make_unique<SocketTransport>(accepted[0], accepted[1],
|
||||||
|
TransportRole::Server);
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult SocketTransport::ConnectTo(const std::string& path, std::uint32_t timeoutMs,
|
||||||
|
std::unique_ptr<SocketTransport>& outClient) {
|
||||||
|
outClient.reset();
|
||||||
|
int control = -1;
|
||||||
|
const MobileGLResult first = ConnectOne(path, timeoutMs, &control);
|
||||||
|
if (first != MOBILEGL_OK) {
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
int aux = -1;
|
||||||
|
// The second connect has a SHORT budget: the server is provably up - we
|
||||||
|
// just connected to it - so a slow second connection means something is
|
||||||
|
// wrong rather than something is starting.
|
||||||
|
const MobileGLResult second = ConnectOne(path, 2000, &aux);
|
||||||
|
if (second != MOBILEGL_OK) {
|
||||||
|
::close(control);
|
||||||
|
return second;
|
||||||
|
}
|
||||||
|
outClient = std::make_unique<SocketTransport>(control, aux, TransportRole::Client);
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult SocketTransport::CreatePair(std::unique_ptr<SocketTransport>& outClient,
|
||||||
|
std::unique_ptr<SocketTransport>& outServer) {
|
||||||
|
outClient.reset();
|
||||||
|
outServer.reset();
|
||||||
|
|
||||||
|
int stream[2] = {-1, -1};
|
||||||
|
// SOCK_STREAM, not SOCK_SEQPACKET: Doorbell.h:390-398 already chose a
|
||||||
|
// stream socket for the bell so that a closed peer surfaces as
|
||||||
|
// POLLIN|POLLHUP with recv()==0 rather than as a hang, and the control
|
||||||
|
// plane must not disagree with the bell about what death looks like.
|
||||||
|
// Framing.h is what makes a stream safe: the message boundary is in the
|
||||||
|
// payload, not in the socket.
|
||||||
|
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, stream) != 0) {
|
||||||
|
WireLogError("MG_Remote SocketTransport: socketpair(SOCK_STREAM) failed: %s",
|
||||||
|
std::strerror(errno));
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
int aux[2] = {-1, -1};
|
||||||
|
const MobileGLResult auxResult = FdPassing::CreateSocketPair(aux);
|
||||||
|
if (auxResult != MOBILEGL_OK) {
|
||||||
|
::close(stream[0]);
|
||||||
|
::close(stream[1]);
|
||||||
|
WireLogError("MG_Remote SocketTransport: the aux (SCM_RIGHTS) pair failed");
|
||||||
|
return auxResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
outClient = std::make_unique<SocketTransport>(stream[0], aux[0], TransportRole::Client);
|
||||||
|
outServer = std::make_unique<SocketTransport>(stream[1], aux[1], TransportRole::Server);
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
SocketTransport::SocketTransport(int streamFd, int auxFd, TransportRole role)
|
||||||
|
: m_streamFd(streamFd), m_auxFd(auxFd), m_tcp(TcpSocket(streamFd)), m_role(role) {}
|
||||||
|
|
||||||
|
int SocketTransport::TakeDataFd() {
|
||||||
|
if (!m_tcp) return -1;
|
||||||
|
const int fd = m_auxFd;
|
||||||
|
m_auxFd = -1;
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SocketTransport::CloseLocalCopy() {
|
||||||
|
CloseIfOpen(m_streamFd);
|
||||||
|
CloseIfOpen(m_auxFd);
|
||||||
|
m_closed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult SocketTransport::ShutdownSend() {
|
||||||
|
std::lock_guard<std::mutex> lock(m_sendMutex);
|
||||||
|
if (m_streamFd < 0 || m_closed) return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
return ::shutdown(m_streamFd, SHUT_WR) == 0 ? MOBILEGL_OK : MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
SocketTransport::~SocketTransport() { Shutdown(); }
|
||||||
|
|
||||||
|
MobileGLResult SocketTransport::SendFrame(MobileGLByteSpan bytes) {
|
||||||
|
if (bytes.size > kMaxFramePayloadSize) {
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
if (bytes.size != 0 && bytes.data == nullptr) {
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(m_sendMutex);
|
||||||
|
if (m_closed || m_streamFd < 0) {
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Framed into ONE buffer and written as one span. Not because a stream
|
||||||
|
// needs it - it does not - but because a partial write of the header
|
||||||
|
// followed by a failure would leave the peer's reassembler parked on a
|
||||||
|
// length it will never receive, which is indistinguishable from a slow
|
||||||
|
// sender and therefore not detectable at all.
|
||||||
|
std::vector<std::uint8_t> framed;
|
||||||
|
framed.reserve(static_cast<std::size_t>(kFrameHeaderSize + bytes.size));
|
||||||
|
const MobileGLResult appended = AppendFrame(framed, bytes.data, bytes.size);
|
||||||
|
if (appended != MOBILEGL_OK) {
|
||||||
|
return appended;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uint64_t written = 0;
|
||||||
|
while (written < framed.size()) {
|
||||||
|
const ssize_t n = ::send(m_streamFd, framed.data() + written,
|
||||||
|
static_cast<std::size_t>(framed.size() - written),
|
||||||
|
MSG_NOSIGNAL);
|
||||||
|
if (n > 0) {
|
||||||
|
written += static_cast<std::uint64_t>(n);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (n < 0 && errno == EINTR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// EPIPE / ECONNRESET are the peer being gone, which is a transport
|
||||||
|
// state and not an error to shout about: the device-lost latch (dl)
|
||||||
|
// is what turns it into a GL-visible fact.
|
||||||
|
if (n < 0 && (errno == EPIPE || errno == ECONNRESET)) {
|
||||||
|
m_closed = true;
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
// SendFrame is also the log sink: do not recurse into the logger.
|
||||||
|
std::fprintf(stderr, "MG_Remote SocketTransport: send failed after %llu of %llu bytes: %s\n",
|
||||||
|
static_cast<unsigned long long>(written),
|
||||||
|
static_cast<unsigned long long>(framed.size()), std::strerror(errno));
|
||||||
|
m_closed = true;
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult SocketTransport::PumpOnce(std::uint32_t timeoutMs) {
|
||||||
|
// Caller holds m_recvMutex.
|
||||||
|
if (m_failed) {
|
||||||
|
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
|
}
|
||||||
|
if (m_streamFd < 0) {
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int ready = WaitReadable(m_streamFd, timeoutMs);
|
||||||
|
if (ready == 0) {
|
||||||
|
return MOBILEGL_ERR_TIMEOUT;
|
||||||
|
}
|
||||||
|
if (ready < 0) {
|
||||||
|
WireLogError("MG_Remote SocketTransport: poll failed: %s", std::strerror(errno));
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uint8_t chunk[kPumpChunkBytes];
|
||||||
|
for (;;) {
|
||||||
|
const ssize_t n = ::recv(m_streamFd, chunk, sizeof(chunk), 0);
|
||||||
|
if (n > 0) {
|
||||||
|
const MobileGLResult fed =
|
||||||
|
m_reader.Feed(chunk, static_cast<std::uint64_t>(n));
|
||||||
|
if (fed != MOBILEGL_OK) {
|
||||||
|
// Bad magic or an over-long length. FrameReader latches
|
||||||
|
// itself failed and never recovers; mirror that here so a
|
||||||
|
// caller cannot retry its way past a corrupt stream.
|
||||||
|
m_failed = true;
|
||||||
|
WireLogError("MG_Remote SocketTransport: framing violated on the stream; "
|
||||||
|
"the transport is latched failed");
|
||||||
|
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
|
}
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
if (n == 0) {
|
||||||
|
// Request EOF can be a half-close: drain queued frames and keep
|
||||||
|
// the reverse direction usable for teardown diagnostics.
|
||||||
|
m_readClosed = true;
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
if (errno == EINTR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
|
return MOBILEGL_ERR_TIMEOUT;
|
||||||
|
}
|
||||||
|
if (errno == ECONNRESET) {
|
||||||
|
m_closed = true;
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
WireLogError("MG_Remote SocketTransport: recv failed: %s", std::strerror(errno));
|
||||||
|
m_closed = true;
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult SocketTransport::ReceiveFrame(MobileGLMutableByteSpan buffer,
|
||||||
|
std::uint64_t* outSize,
|
||||||
|
std::uint32_t timeoutMs) {
|
||||||
|
if (outSize == nullptr) {
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
*outSize = 0;
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(m_recvMutex);
|
||||||
|
if (m_failed) {
|
||||||
|
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
// Drain the reassembler FIRST, every time. A message that is already
|
||||||
|
// whole must be returned even when the peer has since closed, and
|
||||||
|
// must be returned without a syscall when the caller is polling.
|
||||||
|
if (m_reader.HasMessage()) {
|
||||||
|
return m_reader.TakeMessage(buffer, outSize);
|
||||||
|
}
|
||||||
|
if (m_closed || m_readClosed) {
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MobileGLResult pumped = PumpOnce(timeoutMs);
|
||||||
|
if (pumped == MOBILEGL_OK) {
|
||||||
|
continue; // maybe a whole message now; maybe a fragment - loop decides
|
||||||
|
}
|
||||||
|
if (pumped == MOBILEGL_ERR_TRANSPORT_CLOSED && m_reader.HasMessage()) {
|
||||||
|
return m_reader.TakeMessage(buffer, outSize);
|
||||||
|
}
|
||||||
|
return pumped;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uint64_t SocketTransport::PeekFrameSize() {
|
||||||
|
std::lock_guard<std::mutex> lock(m_recvMutex);
|
||||||
|
if (m_failed) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!m_reader.HasMessage() && !m_closed && !m_readClosed) {
|
||||||
|
// A non-blocking pump, so a caller that has not received yet can
|
||||||
|
// still size its buffer. Errors are not reported here: PeekFrameSize
|
||||||
|
// answers "how big is the next message", and 0 means "none buffered",
|
||||||
|
// which is the truthful answer for every failure this can hit.
|
||||||
|
(void)PumpOnce(0);
|
||||||
|
}
|
||||||
|
return m_reader.PendingMessageSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult SocketTransport::ShareFd(int fd, MobileGLByteSpan sideband) {
|
||||||
|
if (m_tcp || m_auxFd < 0) {
|
||||||
|
// A link that declared no descriptor passing. Rule G: it does not
|
||||||
|
// invent a third answer, and the caller transfers the bytes instead.
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
std::lock_guard<std::mutex> lock(m_sendMutex);
|
||||||
|
if (m_closed) {
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
return FdPassing::SendFd(m_auxFd, fd, sideband);
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileGLResult SocketTransport::ReceiveFd(int* outFd, MobileGLMutableByteSpan sideband,
|
||||||
|
std::uint64_t* outSidebandSize,
|
||||||
|
std::uint32_t timeoutMs) {
|
||||||
|
if (m_tcp || m_auxFd < 0) {
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
return FdPassing::ReceiveFd(m_auxFd, outFd, sideband, outSidebandSize, timeoutMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SocketTransport::Shutdown() {
|
||||||
|
// Wake a blocking ReceiveFrame before taking its lock.
|
||||||
|
if (m_streamFd >= 0) ::shutdown(m_streamFd, SHUT_RDWR);
|
||||||
|
// Idempotent, and tears down BOTH directions - which on a socket is what
|
||||||
|
// closing does anyway. Taking both locks in a fixed order (send, then
|
||||||
|
// recv) so a concurrent sender and the dedicated reader cannot deadlock
|
||||||
|
// against each other here; every other path takes exactly one.
|
||||||
|
std::lock_guard<std::mutex> sendLock(m_sendMutex);
|
||||||
|
std::lock_guard<std::mutex> recvLock(m_recvMutex);
|
||||||
|
if (m_streamFd >= 0) {
|
||||||
|
// shutdown() before close() so a peer blocked in recv() wakes now
|
||||||
|
// rather than whenever the last duplicate of this fd goes away.
|
||||||
|
::shutdown(m_streamFd, SHUT_RDWR);
|
||||||
|
}
|
||||||
|
CloseIfOpen(m_streamFd);
|
||||||
|
CloseIfOpen(m_auxFd);
|
||||||
|
m_closed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // !MOBILEGL_SOCKET_TRANSPORT_POSIX
|
||||||
|
|
||||||
|
// Windows has no SCM_RIGHTS and ShmSegment::Adopt is POSIX-only, so P6 lands
|
||||||
|
// POSIX only (CONTRACT-P6 §2.6). The refusal is NAMED at construction rather
|
||||||
|
// than at first use: a transport that accepts a connection and then fails
|
||||||
|
// every operation is the silent-fallback shape this project forbids.
|
||||||
|
MobileGLResult SocketTransport::CreatePair(std::unique_ptr<SocketTransport>&,
|
||||||
|
std::unique_ptr<SocketTransport>&) {
|
||||||
|
WireLogError("MG_Remote SocketTransport: unsupported on this platform - P6 lands POSIX "
|
||||||
|
"only (CONTRACT-P6 §2.6); `unix:` and `pipe:` stay named refusals");
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
SocketTransport::SocketTransport(int, int, TransportRole role) : m_role(role) {}
|
||||||
|
SocketTransport::~SocketTransport() = default;
|
||||||
|
int SocketTransport::TakeDataFd() { return -1; }
|
||||||
|
void SocketTransport::CloseLocalCopy() {}
|
||||||
|
MobileGLResult SocketTransport::ShutdownSend() { return MOBILEGL_ERR_UNSUPPORTED; }
|
||||||
|
|
||||||
|
MobileGLResult SocketTransport::SendFrame(MobileGLByteSpan) { return MOBILEGL_ERR_UNSUPPORTED; }
|
||||||
|
MobileGLResult SocketTransport::ReceiveFrame(MobileGLMutableByteSpan, std::uint64_t*,
|
||||||
|
std::uint32_t) {
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
std::uint64_t SocketTransport::PeekFrameSize() { return 0; }
|
||||||
|
MobileGLResult SocketTransport::ShareFd(int, MobileGLByteSpan) {
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
MobileGLResult SocketTransport::ReceiveFd(int*, MobileGLMutableByteSpan, std::uint64_t*,
|
||||||
|
std::uint32_t) {
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
MobileGLResult SocketTransport::PumpOnce(std::uint32_t) { return MOBILEGL_ERR_UNSUPPORTED; }
|
||||||
|
void SocketTransport::Shutdown() { m_closed = true; }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace MobileGL::MG_Remote::Transport
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
// MobileGL - MobileGL/MG_Remote/Transport/SocketTransport.h
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// ITransport over a connected stream socket. Package `so` (CONTRACT-P6.md).
|
||||||
|
//
|
||||||
|
// WHY THIS IS THE FIRST P6 CODE THAT RUNS. It is the whole control plane for a
|
||||||
|
// second process, and it needs NOTHING from the second process to be correct:
|
||||||
|
// CONTRACT-P6 and the spawn plan both require it green over a plain
|
||||||
|
// socketpair() with two threads, running the WHOLE InProcessTransportTest
|
||||||
|
// suite, BEFORE a child is ever forked. Same discipline as SessionRings.h's
|
||||||
|
// "the attach half is the half P6 replaces, so exercise it now" - a transport
|
||||||
|
// first exercised on the day the process appears is a transport whose bugs all
|
||||||
|
// arrive at once.
|
||||||
|
//
|
||||||
|
// WHAT IT IS NOT. It is not the data plane. The hot path bypasses ITransport
|
||||||
|
// entirely (ITransport.h) and crosses through ILink, which is a separate seam
|
||||||
|
// with a separate implementation. This class carries the handshake, surface
|
||||||
|
// ops, resync, aux requests and fatals - the rare, variable-length,
|
||||||
|
// must-evolve traffic.
|
||||||
|
//
|
||||||
|
// THREE THINGS IT DOES NOT REINVENT, because they are already in the tree and
|
||||||
|
// already tested:
|
||||||
|
// Framing.h - AppendFrame writes [u32 'MGLF'][u32 len][payload]; FrameReader
|
||||||
|
// is a real byte-stream reassembler with the BUFFER_TOO_SMALL
|
||||||
|
// keep-the-message semantics ITransport requires. A socket
|
||||||
|
// hands you arbitrary fragments, which is precisely what
|
||||||
|
// FrameReader was written for and what InProcessTransport's
|
||||||
|
// message queue never needed.
|
||||||
|
// FdPassing.h - SCM_RIGHTS over a DEDICATED SOCK_DGRAM aux socket, so an fd
|
||||||
|
// offer is one datagram and cannot be half-consumed.
|
||||||
|
// Doorbell.h - SocketDoorbell already exists, is unit-tested, and has NO
|
||||||
|
// production construction site until now. It was written for
|
||||||
|
// this and is priced as new work here, not as already paid for.
|
||||||
|
//
|
||||||
|
// LIFETIME. The transport owns its stream fd and its aux fd and closes both in
|
||||||
|
// Shutdown/dtor. Shutdown is idempotent and tears down BOTH directions, which
|
||||||
|
// is what ITransport promises and what a socket does anyway: after either end
|
||||||
|
// calls it, the peer's reads return 0 and its sends fail.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
#include "Framing.h"
|
||||||
|
#include "ITransport.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
|
|
||||||
|
class SocketTransport final : public ITransport {
|
||||||
|
public:
|
||||||
|
// Creates a connected pair and hands back one transport per end, with
|
||||||
|
// the aux (fd-passing) socketpair already made. POSIX only; on a
|
||||||
|
// platform without SCM_RIGHTS this refuses BY NAME rather than handing
|
||||||
|
// back a transport whose ShareFd would surprise its caller later.
|
||||||
|
static MobileGLResult CreatePair(std::unique_ptr<SocketTransport>& outClient,
|
||||||
|
std::unique_ptr<SocketTransport>& outServer);
|
||||||
|
|
||||||
|
// ---- independent processes: listen / connect -----------------------
|
||||||
|
//
|
||||||
|
// THE TWO PROCESSES ARE NOT COUPLED BY INHERITANCE. An earlier shape of
|
||||||
|
// this package forked the server and handed it fds 3..6; that can never
|
||||||
|
// be the end state, where the server is a standing application and the
|
||||||
|
// client connects to it from somewhere else entirely - possibly from
|
||||||
|
// another kernel. So the rendezvous is a NAME, and both sides are
|
||||||
|
// started by whoever starts them.
|
||||||
|
//
|
||||||
|
// TWO CONNECTIONS, not one. SCM_RIGHTS needs a socket of its own: an fd
|
||||||
|
// offer is a sendmsg whose ancillary data rides with specific BYTES, and
|
||||||
|
// interleaving those bytes with the framed control stream would make the
|
||||||
|
// frame reassembler and the descriptor receiver race for the same bytes.
|
||||||
|
// So the client connects twice to the same listening path - first
|
||||||
|
// connection is control, second is aux - and the server accepts them in
|
||||||
|
// that order. One name, no extra configuration, and FdPassing keeps the
|
||||||
|
// dedicated socket it was written for.
|
||||||
|
//
|
||||||
|
// `path` is a filesystem AF_UNIX path. ARCHITECTURE.md §15.1 ruled
|
||||||
|
// against one for the FORK shape, where the fds were inherited and a
|
||||||
|
// path would have been a strictly larger attack surface for no gain.
|
||||||
|
// Independent processes have to name a rendezvous somehow, and a path
|
||||||
|
// with 0600 permissions in a private directory is the portable answer;
|
||||||
|
// the abstract namespace is Linux-only and TCP would be reachable off
|
||||||
|
// the machine.
|
||||||
|
static MobileGLResult Listen(const std::string& path, int* outListenFd);
|
||||||
|
|
||||||
|
// Accepts one client's TWO connections, in order.
|
||||||
|
static MobileGLResult AcceptPair(int listenFd, std::uint32_t timeoutMs,
|
||||||
|
std::unique_ptr<SocketTransport>& outServer);
|
||||||
|
|
||||||
|
// The client's half: connects twice to `path`.
|
||||||
|
static MobileGLResult ConnectTo(const std::string& path, std::uint32_t timeoutMs,
|
||||||
|
std::unique_ptr<SocketTransport>& outClient);
|
||||||
|
|
||||||
|
// Adopts an already-connected stream fd - what `sm` uses on each side of
|
||||||
|
// the fork, where fd 3 is the stream and fd 4 is the aux socket.
|
||||||
|
// `auxFd` may be -1: the transport then answers MOBILEGL_ERR_UNSUPPORTED
|
||||||
|
// to ShareFd/ReceiveFd, which is the honest answer for a link that
|
||||||
|
// cannot pass descriptors (CONTRACT-P6 rule G: a transport declares what
|
||||||
|
// it supports and may not invent a third answer).
|
||||||
|
SocketTransport(int streamFd, int auxFd, TransportRole role);
|
||||||
|
~SocketTransport() override;
|
||||||
|
|
||||||
|
MobileGLResult SendFrame(MobileGLByteSpan bytes) override;
|
||||||
|
MobileGLResult ReceiveFrame(MobileGLMutableByteSpan buffer, std::uint64_t* outSize,
|
||||||
|
std::uint32_t timeoutMs) override;
|
||||||
|
std::uint64_t PeekFrameSize() override;
|
||||||
|
|
||||||
|
MobileGLResult ShareFd(int fd, MobileGLByteSpan sideband) override;
|
||||||
|
MobileGLResult ReceiveFd(int* outFd, MobileGLMutableByteSpan sideband,
|
||||||
|
std::uint64_t* outSidebandSize, std::uint32_t timeoutMs) override;
|
||||||
|
|
||||||
|
void Shutdown() override;
|
||||||
|
TransportRole Role() const override { return m_role; }
|
||||||
|
|
||||||
|
// For `sm`'s process discipline and for the arm-proof gate: the fds this
|
||||||
|
// transport owns, so a test can assert the child inherited exactly these.
|
||||||
|
int StreamFd() const { return m_streamFd; }
|
||||||
|
int AuxFd() const { return m_auxFd; }
|
||||||
|
bool IsTcp() const { return m_tcp; }
|
||||||
|
// TCP's second connection belongs exclusively to the data plane.
|
||||||
|
// Taking it disables all descriptor passing on this transport.
|
||||||
|
int TakeDataFd();
|
||||||
|
// Parent of a session child closes its duplicate without shutdown(2),
|
||||||
|
// which would also disconnect the child's inherited socket.
|
||||||
|
void CloseLocalCopy();
|
||||||
|
// End requests while retaining the receive side for final diagnostics/EOF.
|
||||||
|
MobileGLResult ShutdownSend();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Pulls whatever the socket has into the reassembler. Returns
|
||||||
|
// TRANSPORT_CLOSED on a clean EOF with nothing buffered.
|
||||||
|
MobileGLResult PumpOnce(std::uint32_t timeoutMs);
|
||||||
|
|
||||||
|
int m_streamFd = -1;
|
||||||
|
int m_auxFd = -1;
|
||||||
|
bool m_tcp = false;
|
||||||
|
TransportRole m_role = TransportRole::Client;
|
||||||
|
|
||||||
|
// ITransport's threading rule: callers serialise sends, and receives may
|
||||||
|
// run on one dedicated reader thread concurrently with those sends. So
|
||||||
|
// the two directions get one mutex each rather than one shared - a
|
||||||
|
// single lock would make a blocked receive stall every send, which is
|
||||||
|
// exactly the wedge the control plane must not have.
|
||||||
|
std::mutex m_sendMutex;
|
||||||
|
std::mutex m_recvMutex;
|
||||||
|
|
||||||
|
FrameReader m_reader;
|
||||||
|
std::atomic<bool> m_closed{false};
|
||||||
|
std::atomic<bool> m_readClosed{false};
|
||||||
|
bool m_failed = false; // framing violated: latched, never recovers
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace MobileGL::MG_Remote::Transport
|
||||||
@@ -0,0 +1,555 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
#include "StreamLink.h"
|
||||||
|
#include "SessionRings.h"
|
||||||
|
#include "ShmLink.h"
|
||||||
|
#include "Doorbell.h"
|
||||||
|
#include "ReplySlot.h"
|
||||||
|
#include "Framing.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <cstring>
|
||||||
|
#include <mutex>
|
||||||
|
#include <thread>
|
||||||
|
#include <vector>
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
#include <cerrno>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#if defined(__linux__)
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
|
namespace {
|
||||||
|
constexpr std::uint64_t kDataEnvelopeBytes = 20;
|
||||||
|
constexpr std::uint64_t kMaxDataPayload = kMaxFramePayloadSize - kDataEnvelopeBytes;
|
||||||
|
constexpr std::uint32_t kDataMagic = 0x444c474d; // MGLD, little endian
|
||||||
|
enum Kind : unsigned {
|
||||||
|
Cmd = 1,
|
||||||
|
Stage,
|
||||||
|
ClientProgress,
|
||||||
|
ProgressFrame,
|
||||||
|
Reply,
|
||||||
|
Event
|
||||||
|
};
|
||||||
|
void Put32(std::uint8_t* p, std::uint32_t v) {
|
||||||
|
for (unsigned i = 0; i < 4; ++i)
|
||||||
|
p[i] = v >> (i * 8);
|
||||||
|
}
|
||||||
|
void Put64(std::uint8_t* p, std::uint64_t v) {
|
||||||
|
for (unsigned i = 0; i < 8; ++i)
|
||||||
|
p[i] = v >> (i * 8);
|
||||||
|
}
|
||||||
|
std::uint32_t Get32(const std::uint8_t* p) {
|
||||||
|
std::uint32_t v = 0;
|
||||||
|
for (unsigned i = 0; i < 4; ++i)
|
||||||
|
v |= std::uint32_t(p[i]) << (i * 8);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
std::uint64_t Get64(const std::uint8_t* p) {
|
||||||
|
std::uint64_t v = 0;
|
||||||
|
for (unsigned i = 0; i < 8; ++i)
|
||||||
|
v |= std::uint64_t(p[i]) << (i * 8);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
[[noreturn]] void Corrupt(const char* detail) {
|
||||||
|
WireLogFatal("MGPipe: Fatal{ProtocolCorruption, \"StreamLink\"} %s", detail);
|
||||||
|
}
|
||||||
|
void Advance(std::atomic<std::uint64_t>& value, std::uint64_t next) {
|
||||||
|
if (next < value.load(std::memory_order_acquire)) Corrupt("watermark moved backwards");
|
||||||
|
value.store(next, std::memory_order_release);
|
||||||
|
}
|
||||||
|
class StreamBell final : public Doorbell {
|
||||||
|
public:
|
||||||
|
void Notify() override { m_bell.Notify(); }
|
||||||
|
bool Park(std::uint32_t timeout) override { return m_bell.Park(timeout); }
|
||||||
|
void Reset() override { m_bell.Reset(); }
|
||||||
|
bool Dead() const override { return m_bell.Dead(); }
|
||||||
|
bool PeerHungUp() const override { return m_peer.load(std::memory_order_acquire); }
|
||||||
|
void Kill(bool peer) {
|
||||||
|
if (peer) m_peer.store(true, std::memory_order_release);
|
||||||
|
m_bell.Kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CondVarDoorbell m_bell;
|
||||||
|
std::atomic<bool> m_peer{false};
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
struct StreamLink::Impl {
|
||||||
|
std::unique_ptr<ShmLink> owned = std::make_unique<ShmLink>();
|
||||||
|
SessionSegments* memory = nullptr;
|
||||||
|
TransportRoleTag role = TransportRoleTag::ClientProducer;
|
||||||
|
int fd = -1;
|
||||||
|
std::atomic<bool> closed{false}, stopping{false};
|
||||||
|
StreamBell consumer, producer;
|
||||||
|
std::thread reader;
|
||||||
|
std::mutex writeMutex, replyMutex;
|
||||||
|
std::condition_variable replyReady;
|
||||||
|
std::vector<LinkSpan> stage;
|
||||||
|
std::vector<std::uint8_t> reply, readReply;
|
||||||
|
std::uint64_t replySeq = 0, sentCmd = 0, receivedCmd = 0, sentEvent = 0, receivedEvent = 0;
|
||||||
|
std::int32_t replyStatus = 0;
|
||||||
|
std::uint64_t lastProgressSeq = 0;
|
||||||
|
std::chrono::steady_clock::time_point lastProgress = std::chrono::steady_clock::now();
|
||||||
|
LinkArena records{}, events{};
|
||||||
|
LinkCursor recordCursor{}, eventCursor{};
|
||||||
|
bool Client() const { return role == TransportRoleTag::ClientProducer; }
|
||||||
|
RingControl& C() const { return *memory->CmdControl(); }
|
||||||
|
RingControl& E() const { return *memory->EventControl(); }
|
||||||
|
std::uint64_t MaxReply() const {
|
||||||
|
return memory->ReplyBytes() / memory->ReplySlotCount() - sizeof(ReplySlotHeader);
|
||||||
|
}
|
||||||
|
void Die(bool peer) {
|
||||||
|
{
|
||||||
|
// Pair every reply-wait predicate transition with its mutex:
|
||||||
|
// an EOF between the predicate and cv.wait must not lose a wake.
|
||||||
|
std::lock_guard<std::mutex> lock(replyMutex);
|
||||||
|
closed.store(true, std::memory_order_release);
|
||||||
|
}
|
||||||
|
consumer.Kill(peer);
|
||||||
|
producer.Kill(peer);
|
||||||
|
replyReady.notify_all();
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
if (fd >= 0) ::shutdown(fd, SHUT_RDWR);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
bool Read(void* data, std::size_t size) {
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
auto* p = static_cast<std::uint8_t*>(data);
|
||||||
|
while (size) {
|
||||||
|
const auto n = ::recv(fd, p, size, 0);
|
||||||
|
if (n < 0 && errno == EINTR) continue;
|
||||||
|
if (n <= 0) {
|
||||||
|
Die(!stopping.load(std::memory_order_acquire));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
p += n;
|
||||||
|
size -= static_cast<std::size_t>(n);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
(void)data;
|
||||||
|
(void)size;
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
bool Send(unsigned kind, std::uint64_t a, std::uint64_t b, const void* payload, std::uint64_t size) {
|
||||||
|
if (size > kMaxDataPayload) Corrupt("outgoing frame exceeds limit");
|
||||||
|
std::uint8_t h[28]{};
|
||||||
|
Put32(h, kDataMagic);
|
||||||
|
Put32(h + 4, static_cast<std::uint32_t>(kDataEnvelopeBytes + size));
|
||||||
|
h[8] = static_cast<std::uint8_t>(kind);
|
||||||
|
Put64(h + 12, a);
|
||||||
|
Put64(h + 20, b);
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
// One gather write keeps a small command and its envelope in one
|
||||||
|
// TCP send (TCP_NODELAY is enabled). Partial writes retain the same
|
||||||
|
// frame lock and advance through both vectors without copying.
|
||||||
|
iovec vectors[2] = {{h, sizeof h}, {const_cast<void*>(payload), static_cast<std::size_t>(size)}};
|
||||||
|
msghdr message{};
|
||||||
|
message.msg_iov = vectors;
|
||||||
|
message.msg_iovlen = size ? 2 : 1;
|
||||||
|
while (message.msg_iovlen) {
|
||||||
|
const auto sent = ::sendmsg(fd, &message, MSG_NOSIGNAL);
|
||||||
|
if (sent < 0 && errno == EINTR) continue;
|
||||||
|
if (sent <= 0) {
|
||||||
|
Die(!stopping.load(std::memory_order_acquire));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto consumed = static_cast<std::size_t>(sent);
|
||||||
|
while (message.msg_iovlen && consumed >= message.msg_iov->iov_len) {
|
||||||
|
consumed -= message.msg_iov->iov_len;
|
||||||
|
++message.msg_iov;
|
||||||
|
--message.msg_iovlen;
|
||||||
|
}
|
||||||
|
if (message.msg_iovlen && consumed) {
|
||||||
|
message.msg_iov->iov_base = static_cast<std::uint8_t*>(message.msg_iov->iov_base) + consumed;
|
||||||
|
message.msg_iov->iov_len -= consumed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
(void)payload;
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
bool SendRing(unsigned kind, void* base, std::uint64_t capacity, std::uint64_t head, std::uint64_t& sent) {
|
||||||
|
if (head < sent || head - sent > capacity) Corrupt("outgoing ring window invalid");
|
||||||
|
while (sent < head) {
|
||||||
|
const auto at = sent % capacity;
|
||||||
|
const auto count = std::min({head - sent, capacity - at, kMaxDataPayload});
|
||||||
|
if (!Send(kind, sent, 0, static_cast<std::uint8_t*>(base) + at, count)) return false;
|
||||||
|
sent += count;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool SendEvents() {
|
||||||
|
return SendRing(Event, memory->EventRingBase(), memory->EventRingCapacity(),
|
||||||
|
E().cmdHead.load(std::memory_order_acquire), sentEvent);
|
||||||
|
}
|
||||||
|
bool SendProgress() {
|
||||||
|
// Events and replies always precede the applied watermark that publishes them.
|
||||||
|
if (!SendEvents()) return false;
|
||||||
|
std::uint8_t p[64]{};
|
||||||
|
Put64(p, C().Progress.appliedSeq.load(std::memory_order_acquire));
|
||||||
|
Put64(p + 8, C().Progress.retiredSeq.load(std::memory_order_acquire));
|
||||||
|
Put64(p + 16, C().Progress.completedFrameSerial.load(std::memory_order_acquire));
|
||||||
|
Put64(p + 24, C().Progress.presentAckSerial.load(std::memory_order_acquire));
|
||||||
|
Put64(p + 32, C().cmdAppliedTail.load(std::memory_order_acquire));
|
||||||
|
// FreeBytes uses RETIRED tail. Sending only applied tail silently permits
|
||||||
|
// reuse of borrowed command slots, and omitting this tail wedges on wrap.
|
||||||
|
Put64(p + 40, C().cmdRetiredTail.load(std::memory_order_acquire));
|
||||||
|
Put64(p + 48, C().eventRingFull.load(std::memory_order_acquire));
|
||||||
|
Put64(p + 56, C().eventDropped.load(std::memory_order_acquire));
|
||||||
|
lastProgressSeq = Get64(p);
|
||||||
|
lastProgress = std::chrono::steady_clock::now();
|
||||||
|
return Send(ProgressFrame, 0, 0, p, sizeof p);
|
||||||
|
}
|
||||||
|
void ReceiveRing(void* base, std::uint64_t capacity, std::uint64_t tail, std::uint64_t a,
|
||||||
|
const std::uint8_t* payload, std::uint64_t size, std::uint64_t& received) {
|
||||||
|
if (a != received || a < tail || a - tail > capacity || size > capacity - (a - tail) ||
|
||||||
|
size > capacity - a % capacity || size == 0)
|
||||||
|
Corrupt("ring frame outside receive window");
|
||||||
|
std::memcpy(static_cast<std::uint8_t*>(base) + a % capacity, payload, static_cast<std::size_t>(size));
|
||||||
|
received += size;
|
||||||
|
}
|
||||||
|
void Loop() {
|
||||||
|
#if defined(__linux__)
|
||||||
|
pthread_setname_np(pthread_self(), Client() ? "mgl-cli-io" : "mgl-srv-io");
|
||||||
|
#endif
|
||||||
|
FrameReader frames(kDataMagic);
|
||||||
|
for (;;) {
|
||||||
|
std::uint8_t h[28];
|
||||||
|
if (!Read(h, kFrameHeaderSize)) return;
|
||||||
|
if (frames.Feed(h, kFrameHeaderSize) != MOBILEGL_OK) Corrupt("invalid data frame header");
|
||||||
|
const auto framedSize = Get32(h + 4);
|
||||||
|
if (framedSize < kDataEnvelopeBytes) Corrupt("truncated data envelope");
|
||||||
|
if (!Read(h + kFrameHeaderSize, kDataEnvelopeBytes)) return;
|
||||||
|
if (frames.Feed(h + kFrameHeaderSize, kDataEnvelopeBytes) != MOBILEGL_OK)
|
||||||
|
Corrupt("invalid data frame envelope");
|
||||||
|
const auto size = framedSize - static_cast<std::uint32_t>(kDataEnvelopeBytes);
|
||||||
|
const auto kind = unsigned(h[8]);
|
||||||
|
const auto a = Get64(h + 12), b = Get64(h + 20);
|
||||||
|
if (Get32(h) != kDataMagic || h[9] || h[10] || h[11] || size > kMaxDataPayload)
|
||||||
|
Corrupt("invalid data frame header");
|
||||||
|
// Reject the size/window before allocating or reading a hostile payload.
|
||||||
|
if ((kind == Stage && (Client() || a > memory->StageBytes() || size > memory->StageBytes() - a)) ||
|
||||||
|
(kind == Cmd && (Client() || size > memory->CmdRingCapacity())) ||
|
||||||
|
(kind == Event && (!Client() || size > memory->EventRingCapacity())) ||
|
||||||
|
(kind == Reply && (!Client() || size > MaxReply())) ||
|
||||||
|
(kind == ProgressFrame && (!Client() || size != 64)) ||
|
||||||
|
(kind == ClientProgress && (Client() || size != 8)) || kind < Cmd || kind > Event)
|
||||||
|
Corrupt("frame kind or size outside negotiated window");
|
||||||
|
if (((kind == Cmd || kind == Stage || kind == Event) && b != 0) ||
|
||||||
|
(kind == ProgressFrame && (a != 0 || b != 0)) || (kind == Reply && b > UINT32_MAX))
|
||||||
|
Corrupt("nonzero reserved data envelope field");
|
||||||
|
std::uint8_t chunk[64 * 1024];
|
||||||
|
std::uint64_t remaining = size;
|
||||||
|
while (remaining) {
|
||||||
|
const auto count = std::min<std::uint64_t>(remaining, sizeof chunk);
|
||||||
|
if (!Read(chunk, static_cast<std::size_t>(count))) return;
|
||||||
|
if (frames.Feed(chunk, count) != MOBILEGL_OK) Corrupt("invalid data frame payload");
|
||||||
|
remaining -= count;
|
||||||
|
}
|
||||||
|
std::vector<std::uint8_t> p;
|
||||||
|
if (frames.TakeMessage(p) != MOBILEGL_OK) Corrupt("incomplete data frame");
|
||||||
|
const auto* payload = p.data() + kDataEnvelopeBytes;
|
||||||
|
if (kind == Stage) {
|
||||||
|
std::memcpy(static_cast<std::uint8_t*>(memory->StageBase()) + a, payload, size);
|
||||||
|
} else if (kind == Cmd) {
|
||||||
|
ReceiveRing(memory->CmdRingBase(), memory->CmdRingCapacity(),
|
||||||
|
C().cmdRetiredTail.load(std::memory_order_acquire), a, payload, size, receivedCmd);
|
||||||
|
} else if (kind == ClientProgress) {
|
||||||
|
if (a != receivedCmd) Corrupt("cmdHead does not match delivered bytes");
|
||||||
|
const auto tail = Get64(payload);
|
||||||
|
if (tail > E().cmdHead.load(std::memory_order_acquire)) Corrupt("event tail ahead of head");
|
||||||
|
const auto oldTail = E().cmdRetiredTail.load(std::memory_order_acquire);
|
||||||
|
Advance(E().cmdAppliedTail, tail);
|
||||||
|
Advance(E().cmdRetiredTail, tail);
|
||||||
|
// Only a real drain can clear a latched backlog. A command-only
|
||||||
|
// publication carrying the old tail must not undo a new full latch.
|
||||||
|
if (tail > oldTail) C().eventRingFull.store(0, std::memory_order_release);
|
||||||
|
Watermark::AdvanceSubmitted(C(), b);
|
||||||
|
Advance(C().cmdHead, a);
|
||||||
|
consumer.Notify();
|
||||||
|
} else if (kind == Event) {
|
||||||
|
ReceiveRing(memory->EventRingBase(), memory->EventRingCapacity(),
|
||||||
|
E().cmdRetiredTail.load(std::memory_order_acquire), a, payload, size, receivedEvent);
|
||||||
|
Advance(E().cmdHead, receivedEvent);
|
||||||
|
producer.Notify();
|
||||||
|
} else if (kind == ProgressFrame) {
|
||||||
|
const auto* v = payload;
|
||||||
|
if (Get64(v + 8) > Get64(v) || Get64(v) > C().submittedSeq.load(std::memory_order_acquire) ||
|
||||||
|
Get64(v + 40) > Get64(v + 32) || Get64(v + 32) > C().cmdHead.load(std::memory_order_acquire) ||
|
||||||
|
Get64(v + 48) > 1)
|
||||||
|
Corrupt("progress ahead of delivered work");
|
||||||
|
Advance(C().cmdAppliedTail, Get64(v + 32));
|
||||||
|
Advance(C().cmdRetiredTail, Get64(v + 40));
|
||||||
|
C().eventRingFull.store(static_cast<std::uint32_t>(Get64(v + 48)), std::memory_order_release);
|
||||||
|
C().eventDropped.store(static_cast<std::uint32_t>(Get64(v + 56)), std::memory_order_release);
|
||||||
|
Watermark::AdvanceCompletedFrame(C(), Get64(v + 16));
|
||||||
|
Watermark::AdvancePresentAck(C(), Get64(v + 24));
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(replyMutex);
|
||||||
|
Watermark::AdvanceApplied(C(), Get64(v));
|
||||||
|
// AdvanceRetired clamps to local appliedSeq. Apply this
|
||||||
|
// received snapshot in dependency order or the final
|
||||||
|
// retirement is silently clamped to the previous batch.
|
||||||
|
Watermark::AdvanceRetired(C(), Get64(v + 8));
|
||||||
|
}
|
||||||
|
replyReady.notify_all();
|
||||||
|
producer.Notify();
|
||||||
|
} else if (kind == Reply) {
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(replyMutex);
|
||||||
|
if (a <= replySeq) Corrupt("reply sequence moved backwards");
|
||||||
|
replySeq = a;
|
||||||
|
replyStatus = static_cast<std::int32_t>(static_cast<std::uint32_t>(b));
|
||||||
|
reply.assign(payload, payload + size);
|
||||||
|
}
|
||||||
|
replyReady.notify_all();
|
||||||
|
producer.Notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
StreamLink::StreamLink() : m_impl(new Impl) {}
|
||||||
|
StreamLink::~StreamLink() {
|
||||||
|
Detach();
|
||||||
|
}
|
||||||
|
MobileGLResult StreamLink::Attach(int fd, SessionSegments& mirrors, TransportRoleTag role) {
|
||||||
|
#if defined(_WIN32)
|
||||||
|
(void)fd;
|
||||||
|
(void)mirrors;
|
||||||
|
(void)role;
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
#else
|
||||||
|
if (fd < 0 || !mirrors.Valid() || !mirrors.ReplySlotCount() ||
|
||||||
|
mirrors.ReplyBytes() / mirrors.ReplySlotCount() <= sizeof(ReplySlotHeader))
|
||||||
|
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
Detach();
|
||||||
|
m_impl.reset(new Impl);
|
||||||
|
auto& x = *m_impl;
|
||||||
|
x.fd = fd;
|
||||||
|
x.memory = &mirrors;
|
||||||
|
x.role = role;
|
||||||
|
x.records = {mirrors.CmdRingBase(), mirrors.CmdRingCapacity(), mirrors.CmdRingCapacity() - 1, 0};
|
||||||
|
x.recordCursor = {mirrors.CmdRingBase(), mirrors.CmdRingCapacity(), mirrors.CmdRingCapacity() - 1, 0};
|
||||||
|
x.events = {mirrors.EventRingBase(), mirrors.EventRingCapacity(), mirrors.EventRingCapacity() - 1, 0};
|
||||||
|
x.eventCursor = {mirrors.EventRingBase(), mirrors.EventRingCapacity(), mirrors.EventRingCapacity() - 1, 0};
|
||||||
|
x.reader = std::thread([&x] { x.Loop(); });
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
MobileGLResult StreamLink::AttachOwned(int fd, const SessionSegmentSizes& sizes, TransportRoleTag role) {
|
||||||
|
auto owned = std::make_unique<ShmLink>();
|
||||||
|
const auto result = owned->Memory().CreatePrivate(
|
||||||
|
sizes, role == TransportRoleTag::ClientProducer ? MemoryRole::Client : MemoryRole::Server);
|
||||||
|
if (result != MOBILEGL_OK) return result;
|
||||||
|
const auto attached = Attach(fd, owned->Memory(), role);
|
||||||
|
if (attached == MOBILEGL_OK) m_impl->owned = std::move(owned);
|
||||||
|
return attached;
|
||||||
|
}
|
||||||
|
MobileGLResult CreateStreamLink(int fd, const SessionSegmentSizes& sizes, TransportRoleTag role,
|
||||||
|
std::unique_ptr<ILink>& out) {
|
||||||
|
auto link = std::make_unique<StreamLink>();
|
||||||
|
const auto result = link->AttachOwned(fd, sizes, role);
|
||||||
|
if (result == MOBILEGL_OK) out = std::move(link);
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
else if (fd >= 0)
|
||||||
|
::close(fd);
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
void StreamLink::InitializeEndpoints() {
|
||||||
|
m_impl->owned->SetRole(m_impl->role);
|
||||||
|
m_impl->owned->InitializeEndpoints();
|
||||||
|
}
|
||||||
|
SessionSegments& StreamLink::Memory() {
|
||||||
|
return m_impl->memory ? *m_impl->memory : m_impl->owned->Memory();
|
||||||
|
}
|
||||||
|
RingProducer& StreamLink::CommandsOut() {
|
||||||
|
return m_impl->owned->CommandsOut();
|
||||||
|
}
|
||||||
|
RingConsumer& StreamLink::CommandsIn() {
|
||||||
|
return m_impl->owned->CommandsIn();
|
||||||
|
}
|
||||||
|
EventRingProducer& StreamLink::EventsOut() {
|
||||||
|
return m_impl->owned->EventsOut();
|
||||||
|
}
|
||||||
|
EventRingConsumer& StreamLink::EventsIn() {
|
||||||
|
return m_impl->owned->EventsIn();
|
||||||
|
}
|
||||||
|
LinkCapabilities StreamLink::Capabilities() const {
|
||||||
|
if (!m_impl->memory) return {};
|
||||||
|
return {false, false, false, m_impl->memory->CmdRingCapacity() / 2, m_impl->MaxReply()};
|
||||||
|
}
|
||||||
|
LinkProgress* StreamLink::Progress() {
|
||||||
|
return m_impl->memory ? &m_impl->C().Progress : nullptr;
|
||||||
|
}
|
||||||
|
LinkEventFlags* StreamLink::EventFlags() {
|
||||||
|
return m_impl->memory ? reinterpret_cast<LinkEventFlags*>(&m_impl->C().eventRingFull) : nullptr;
|
||||||
|
}
|
||||||
|
LinkArena* StreamLink::RecordArena() {
|
||||||
|
return m_impl->Client() ? &m_impl->records : nullptr;
|
||||||
|
}
|
||||||
|
LinkCursor* StreamLink::RecordCursor() {
|
||||||
|
return m_impl->Client() ? nullptr : &m_impl->recordCursor;
|
||||||
|
}
|
||||||
|
LinkArena* StreamLink::EventArena() {
|
||||||
|
return m_impl->Client() ? nullptr : &m_impl->events;
|
||||||
|
}
|
||||||
|
LinkCursor* StreamLink::EventCursor() {
|
||||||
|
return m_impl->Client() ? &m_impl->eventCursor : nullptr;
|
||||||
|
}
|
||||||
|
Doorbell& StreamLink::ConsumerBell() {
|
||||||
|
return m_impl->consumer;
|
||||||
|
}
|
||||||
|
Doorbell& StreamLink::ProducerBell() {
|
||||||
|
return m_impl->producer;
|
||||||
|
}
|
||||||
|
MobileGLResult StreamLink::StageBytes(std::uint64_t, LinkSpan*, void**) {
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
MobileGLResult StreamLink::ResolveSpan(LinkSegment segment, LinkSpan span, const void** out) {
|
||||||
|
if (!out || !m_impl->memory) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
auto& m = *m_impl->memory;
|
||||||
|
const void* base = nullptr;
|
||||||
|
std::uint64_t cap = 0;
|
||||||
|
switch (segment) {
|
||||||
|
case LinkSegment::Cmd:
|
||||||
|
base = m.CmdRingBase();
|
||||||
|
cap = m.CmdRingCapacity();
|
||||||
|
break;
|
||||||
|
case LinkSegment::Stage:
|
||||||
|
base = m.StageBase();
|
||||||
|
cap = m.StageBytes();
|
||||||
|
break;
|
||||||
|
case LinkSegment::Reply:
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
case LinkSegment::Event:
|
||||||
|
base = m.EventSegmentBase();
|
||||||
|
cap = m.AnnouncedSize(SessionSegmentSlot::Event);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return MOBILEGL_ERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
if (span.Offset > cap || span.Size > cap - span.Offset) return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
|
*out = static_cast<const std::uint8_t*>(base) + span.Offset;
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
void StreamLink::NoteStage(LinkSpan span) {
|
||||||
|
auto& x = *m_impl;
|
||||||
|
if (!x.Client() || span.Offset > x.memory->StageBytes() || span.Size > x.memory->StageBytes() - span.Offset)
|
||||||
|
Corrupt("staged span outside window");
|
||||||
|
if (!x.stage.empty() && x.stage.back().Offset + x.stage.back().Size == span.Offset)
|
||||||
|
x.stage.back().Size += span.Size;
|
||||||
|
else
|
||||||
|
x.stage.push_back(span);
|
||||||
|
}
|
||||||
|
MobileGLResult StreamLink::Flush() {
|
||||||
|
auto& x = *m_impl;
|
||||||
|
if (!Attached()) return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
std::lock_guard<std::mutex> lock(x.writeMutex);
|
||||||
|
if (!x.Client()) return x.SendEvents() ? MOBILEGL_OK : MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
for (const auto span : x.stage) {
|
||||||
|
std::uint64_t sent = 0;
|
||||||
|
while (sent < span.Size) {
|
||||||
|
const auto count = std::min(span.Size - sent, kMaxDataPayload);
|
||||||
|
if (!x.Send(Stage, span.Offset + sent, 0,
|
||||||
|
static_cast<std::uint8_t*>(x.memory->StageBase()) + span.Offset + sent, count))
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
sent += count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x.stage.clear();
|
||||||
|
const auto head = x.C().cmdHead.load(std::memory_order_acquire);
|
||||||
|
if (!x.SendRing(Cmd, x.memory->CmdRingBase(), x.memory->CmdRingCapacity(), head, x.sentCmd))
|
||||||
|
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
std::uint8_t tail[8];
|
||||||
|
Put64(tail, x.E().cmdRetiredTail.load(std::memory_order_acquire));
|
||||||
|
return x.Send(ClientProgress, head, x.C().submittedSeq.load(std::memory_order_acquire), tail, sizeof tail)
|
||||||
|
? MOBILEGL_OK
|
||||||
|
: MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
MobileGLResult StreamLink::FlushProgress() {
|
||||||
|
auto& x = *m_impl;
|
||||||
|
if (!Attached()) return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
if (x.Client()) return Flush();
|
||||||
|
std::lock_guard<std::mutex> lock(x.writeMutex);
|
||||||
|
return x.SendProgress() ? MOBILEGL_OK : MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
void StreamLink::ProgressChanged() {
|
||||||
|
auto& x = *m_impl;
|
||||||
|
if (x.Client() || !Attached()) return;
|
||||||
|
const auto seq = x.C().Progress.appliedSeq.load(std::memory_order_acquire);
|
||||||
|
if (seq - x.lastProgressSeq >= 64 ||
|
||||||
|
std::chrono::steady_clock::now() - x.lastProgress >= std::chrono::milliseconds(1))
|
||||||
|
FlushProgress();
|
||||||
|
}
|
||||||
|
MobileGLResult StreamLink::PostReply(std::uint64_t seq, std::int32_t status, const void* p, std::uint64_t size) {
|
||||||
|
auto& x = *m_impl;
|
||||||
|
if (x.Client() || !Attached()) return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
if (size > x.MaxReply() || (size && !p)) return MOBILEGL_ERR_BUFFER_TOO_SMALL;
|
||||||
|
std::lock_guard<std::mutex> lock(x.writeMutex);
|
||||||
|
return x.Send(Reply, seq, static_cast<std::uint32_t>(status), p, size) && x.SendProgress()
|
||||||
|
? MOBILEGL_OK
|
||||||
|
: MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||||
|
}
|
||||||
|
MobileGLResult StreamLink::ReadReply(std::uint64_t seq, std::int32_t* status, const void** p, std::uint64_t* size) {
|
||||||
|
auto& x = *m_impl;
|
||||||
|
if (!status || !p || !size || !seq || !x.Client()) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||||
|
if (!x.memory) return MOBILEGL_ERR_NOT_INITIALIZED;
|
||||||
|
std::unique_lock<std::mutex> lock(x.replyMutex);
|
||||||
|
// The applied watermark is sent after the reply, so normal callers never
|
||||||
|
// wait here. A standalone reply reader may wait without polling.
|
||||||
|
x.replyReady.wait(lock, [&] {
|
||||||
|
return x.closed.load(std::memory_order_acquire) || x.replySeq >= seq ||
|
||||||
|
x.C().Progress.appliedSeq.load(std::memory_order_acquire) >= seq;
|
||||||
|
});
|
||||||
|
if (x.replySeq != seq) return x.closed.load() ? MOBILEGL_ERR_TRANSPORT_CLOSED : MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||||
|
x.readReply = x.reply;
|
||||||
|
*status = x.replyStatus;
|
||||||
|
*size = x.readReply.size();
|
||||||
|
*p = x.readReply.data();
|
||||||
|
return MOBILEGL_OK;
|
||||||
|
}
|
||||||
|
std::uint64_t StreamLink::EventPublishedHead() const {
|
||||||
|
return m_impl->memory ? m_impl->E().cmdHead.load(std::memory_order_acquire) : 0;
|
||||||
|
}
|
||||||
|
MobileGLResult StreamLink::WaitForEventDelivery(std::uint64_t head, std::uint32_t timeoutMs) {
|
||||||
|
auto& x = *m_impl;
|
||||||
|
if (!x.memory) return MOBILEGL_ERR_NOT_INITIALIZED;
|
||||||
|
const auto ready = [&] { return x.E().cmdHead.load(std::memory_order_acquire) >= head; };
|
||||||
|
if (ready()) return MOBILEGL_OK;
|
||||||
|
const bool delivered = x.producer.Wait(x.C().producerParked, ready, 0, timeoutMs);
|
||||||
|
return delivered ? MOBILEGL_OK : x.producer.Dead() ? MOBILEGL_ERR_TRANSPORT_CLOSED : MOBILEGL_ERR_TIMEOUT;
|
||||||
|
}
|
||||||
|
bool StreamLink::Attached() const {
|
||||||
|
return m_impl->memory && !m_impl->closed.load(std::memory_order_acquire);
|
||||||
|
}
|
||||||
|
bool StreamLink::PeerHungUp() const {
|
||||||
|
return m_impl->producer.PeerHungUp();
|
||||||
|
}
|
||||||
|
TransportRoleTag StreamLink::Role() const {
|
||||||
|
return m_impl->role;
|
||||||
|
}
|
||||||
|
void StreamLink::Detach() {
|
||||||
|
auto& x = *m_impl;
|
||||||
|
if (!x.memory) return;
|
||||||
|
x.stopping.store(true, std::memory_order_release);
|
||||||
|
x.Die(false);
|
||||||
|
if (x.reader.joinable()) x.reader.join();
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
if (x.fd >= 0) ::close(x.fd);
|
||||||
|
#endif
|
||||||
|
x.fd = -1;
|
||||||
|
x.memory = nullptr;
|
||||||
|
}
|
||||||
|
} // namespace MobileGL::MG_Remote::Transport
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
#pragma once
|
||||||
|
#include "ILink.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace MobileGL::MG_Remote::Transport {
|
||||||
|
class SessionSegments;
|
||||||
|
// One reader owns receive/reassembly. Writers serialize complete frames and use
|
||||||
|
// the caller thread, so both directions can always drain a blocked peer writer.
|
||||||
|
class StreamLink final : public ILink {
|
||||||
|
public:
|
||||||
|
StreamLink();
|
||||||
|
~StreamLink() override;
|
||||||
|
MobileGLResult Attach(int dataFd, SessionSegments& mirrors, TransportRoleTag role);
|
||||||
|
MobileGLResult AttachOwned(int dataFd, const struct SessionSegmentSizes& sizes, TransportRoleTag role);
|
||||||
|
SessionSegments& Memory() override;
|
||||||
|
void InitializeEndpoints() override;
|
||||||
|
RingProducer& CommandsOut() override;
|
||||||
|
RingConsumer& CommandsIn() override;
|
||||||
|
EventRingProducer& EventsOut() override;
|
||||||
|
EventRingConsumer& EventsIn() override;
|
||||||
|
LinkCapabilities Capabilities() const override;
|
||||||
|
LinkProgress* Progress() override;
|
||||||
|
LinkEventFlags* EventFlags() override;
|
||||||
|
LinkArena* RecordArena() override;
|
||||||
|
LinkCursor* RecordCursor() override;
|
||||||
|
MobileGLResult StageBytes(std::uint64_t, LinkSpan*, void**) override;
|
||||||
|
MobileGLResult ResolveSpan(LinkSegment, LinkSpan, const void**) override;
|
||||||
|
MobileGLResult PostReply(std::uint64_t, std::int32_t, const void*, std::uint64_t) override;
|
||||||
|
MobileGLResult ReadReply(std::uint64_t, std::int32_t*, const void**, std::uint64_t*) override;
|
||||||
|
LinkArena* EventArena() override;
|
||||||
|
LinkCursor* EventCursor() override;
|
||||||
|
std::uint64_t EventPublishedHead() const override;
|
||||||
|
MobileGLResult WaitForEventDelivery(std::uint64_t head, std::uint32_t timeoutMs) override;
|
||||||
|
Doorbell& ConsumerBell() override;
|
||||||
|
Doorbell& ProducerBell() override;
|
||||||
|
MobileGLResult Flush() override;
|
||||||
|
MobileGLResult FlushProgress() override;
|
||||||
|
void NoteStage(LinkSpan span) override;
|
||||||
|
void ProgressChanged() override;
|
||||||
|
bool PeerHungUp() const override;
|
||||||
|
bool Attached() const override;
|
||||||
|
void Detach() override;
|
||||||
|
TransportRoleTag Role() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Impl;
|
||||||
|
std::unique_ptr<Impl> m_impl;
|
||||||
|
};
|
||||||
|
} // namespace MobileGL::MG_Remote::Transport
|
||||||
@@ -26,7 +26,9 @@
|
|||||||
// first place. The static_asserts below pin the collision so it cannot be re-introduced by
|
// first place. The static_asserts below pin the collision so it cannot be re-introduced by
|
||||||
// someone who reads the comment and not this file.
|
// someone who reads the comment and not this file.
|
||||||
|
|
||||||
|
#include <MG_Remote/Transport/LinkMetrics.h>
|
||||||
#include "PipeWireCodec.h"
|
#include "PipeWireCodec.h"
|
||||||
|
#include <MG_Remote/FatalFunnel.h>
|
||||||
|
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <MG_Pipe/MGPipeRenderStateSpans.h>
|
#include <MG_Pipe/MGPipeRenderStateSpans.h>
|
||||||
@@ -37,6 +39,10 @@
|
|||||||
#include <MG_Remote/Protocol/generated/protocol_generated.h>
|
#include <MG_Remote/Protocol/generated/protocol_generated.h>
|
||||||
#include <MG_State/GLState/ProgramState/ProgramArtifactsCodec.h>
|
#include <MG_State/GLState/ProgramState/ProgramArtifactsCodec.h>
|
||||||
#include <MG_Util/Debug/Log.h>
|
#include <MG_Util/Debug/Log.h>
|
||||||
|
// P6 gate 8's two wire counters. MG_Util is BELOW MG_Remote in the build order and the pull build
|
||||||
|
// has no MG_Remote at all, which is why every counter this file touches is behind
|
||||||
|
// #if MOBILEGL_PIPE_PUSH - the same guard the header's producer readings live under.
|
||||||
|
#include <MG_Util/Metrics/PipeStats.h>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -375,20 +381,29 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
void WireProtocolFatal(const char* what, const char* detail) {
|
void WireProtocolFatal(const char* what, const char* detail) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"%s\"} %s", what, detail != nullptr ? detail : "");
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s\"} %s", what, detail != nullptr ? detail : "");
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WireProtocolFatalAt(const char* what, Uint64 got, Uint64 expected) {
|
void WireProtocolFatalAt(const char* what, Uint64 got, Uint64 expected) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"%s\"} got=%llu expected=%llu", what,
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s\"} got=%llu expected=%llu", what,
|
||||||
static_cast<unsigned long long>(got), static_cast<unsigned long long>(expected));
|
static_cast<unsigned long long>(got), static_cast<unsigned long long>(expected));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
// SegmentTable
|
// SegmentTable
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void SegmentTable::AttachLink(Transport::ILink* link) {
|
||||||
|
m_link = link;
|
||||||
|
for (Uint32 id = kSegCmd; id <= kSegEvent; ++id) {
|
||||||
|
const auto segment = static_cast<Transport::LinkSegment>(id);
|
||||||
|
const Uint64 size = link ? link->SegmentSize(segment) : 0;
|
||||||
|
const void* base = nullptr;
|
||||||
|
if (link && link->ResolveSpan(segment, {0, size}, &base) != MOBILEGL_OK) base = nullptr;
|
||||||
|
Install(static_cast<SegmentId>(id), {const_cast<void*>(base), size});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SegmentTable::Install(SegmentId seg, SegmentView view) {
|
void SegmentTable::Install(SegmentId seg, SegmentView view) {
|
||||||
if (seg == kSegNone || static_cast<Uint32>(seg) > static_cast<Uint32>(kSegAdopt)) {
|
if (seg == kSegNone || static_cast<Uint32>(seg) > static_cast<Uint32>(kSegAdopt)) {
|
||||||
WireProtocolFatalAt("SegmentTable::Install", static_cast<Uint64>(seg),
|
WireProtocolFatalAt("SegmentTable::Install", static_cast<Uint64>(seg),
|
||||||
@@ -415,6 +430,11 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
if (m_link) {
|
||||||
|
const void* bytes = nullptr;
|
||||||
|
return m_link->ResolveSpan(static_cast<Transport::LinkSegment>(seg), {offset, size}, &bytes)
|
||||||
|
== MOBILEGL_OK ? bytes : nullptr;
|
||||||
|
}
|
||||||
const SegmentView& view = m_views[static_cast<SizeT>(seg)];
|
const SegmentView& view = m_views[static_cast<SizeT>(seg)];
|
||||||
if (view.Base == nullptr) {
|
if (view.Base == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -458,20 +478,18 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// The monolith shape: Seg = None, Offset = a host address, Size = 0. Legal
|
// The monolith shape: Seg = None, Offset = a host address, Size = 0. Legal
|
||||||
// there, and precisely what must not cross (rule A). Reading it as "absent"
|
// there, and precisely what must not cross (rule A). Reading it as "absent"
|
||||||
// would silently drop the bytes of every record an unconverted emitter sent.
|
// would silently drop the bytes of every record an unconverted emitter sent.
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"%s.blob\"} a blob with Size 0 "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s.blob\"} a blob with Size 0 "
|
||||||
"declares Seg=%u Offset=%llu; under split a blobref is either fully "
|
"declares Seg=%u Offset=%llu; under split a blobref is either fully "
|
||||||
"declared or all three fields zero",
|
"declared or all three fields zero",
|
||||||
WireOpName(op), static_cast<unsigned>(blob.Seg),
|
WireOpName(op), static_cast<unsigned>(blob.Seg),
|
||||||
static_cast<unsigned long long>(blob.Offset));
|
static_cast<unsigned long long>(blob.Offset));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (blob.Seg == kSegNone) {
|
if (blob.Seg == kSegNone) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"%s.blob\"} Size=%llu with no segment "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s.blob\"} Size=%llu with no segment "
|
||||||
"(R-2.3): a non-zero Size must name a real SEG_*",
|
"(R-2.3): a non-zero Size must name a real SEG_*",
|
||||||
WireOpName(op), static_cast<unsigned long long>(blob.Size));
|
WireOpName(op), static_cast<unsigned long long>(blob.Size));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
// R-2.3's SECOND HALF: "inside SOME segment" IS NOT THE RULE. Contract table 1 gives
|
// R-2.3's SECOND HALF: "inside SOME segment" IS NOT THE RULE. Contract table 1 gives
|
||||||
// every client->server content blob - groups A, B and C, all nineteen rows - the ONE
|
// every client->server content blob - groups A, B and C, all nineteen rows - the ONE
|
||||||
@@ -493,7 +511,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// seventh name would be a token nothing else in the tree recognises. The SEGMENT is in
|
// seventh name would be a token nothing else in the tree recognises. The SEGMENT is in
|
||||||
// the message, which is what has to be greppable.
|
// the message, which is what has to be greppable.
|
||||||
if (blob.Seg != kSegStage) {
|
if (blob.Seg != kSegStage) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"%s.blob\"} seg=%u offset=%llu "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s.blob\"} seg=%u offset=%llu "
|
||||||
"size=%llu is not SEG_STAGE(%u); every client->server content blob is "
|
"size=%llu is not SEG_STAGE(%u); every client->server content blob is "
|
||||||
"staged whole in SEG_STAGE (contract table 1 groups A/B/C, R-10) and no "
|
"staged whole in SEG_STAGE (contract table 1 groups A/B/C, R-10) and no "
|
||||||
"other segment may carry one",
|
"other segment may carry one",
|
||||||
@@ -501,24 +519,21 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
static_cast<unsigned long long>(blob.Offset),
|
static_cast<unsigned long long>(blob.Offset),
|
||||||
static_cast<unsigned long long>(blob.Size),
|
static_cast<unsigned long long>(blob.Size),
|
||||||
static_cast<unsigned>(kSegStage));
|
static_cast<unsigned>(kSegStage));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (segments.Resolve(blob.Seg, blob.Offset, blob.Size) == nullptr) {
|
if (segments.Resolve(blob.Seg, blob.Offset, blob.Size) == nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"%s.blob\"} seg=%u offset=%llu size=%llu "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s.blob\"} seg=%u offset=%llu size=%llu "
|
||||||
"does not lie inside that segment (R-2.3)",
|
"does not lie inside that segment (R-2.3)",
|
||||||
WireOpName(op), static_cast<unsigned>(blob.Seg),
|
WireOpName(op), static_cast<unsigned>(blob.Seg),
|
||||||
static_cast<unsigned long long>(blob.Offset),
|
static_cast<unsigned long long>(blob.Offset),
|
||||||
static_cast<unsigned long long>(blob.Size));
|
static_cast<unsigned long long>(blob.Size));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequireDeclaredBlob(MGPWireOp op, const MGPBlobRef& blob, const SegmentTable& segments) {
|
void RequireDeclaredBlob(MGPWireOp op, const MGPBlobRef& blob, const SegmentTable& segments) {
|
||||||
if (blob.Size == 0) {
|
if (blob.Size == 0) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"%s.blob\"} the record's own fields say "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s.blob\"} the record's own fields say "
|
||||||
"it carries content and its blob declares none (R-2.2 / rule A)",
|
"it carries content and its blob declares none (R-2.2 / rule A)",
|
||||||
WireOpName(op));
|
WireOpName(op));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
CheckBlobIsHonest(op, blob, segments);
|
CheckBlobIsHonest(op, blob, segments);
|
||||||
}
|
}
|
||||||
@@ -554,12 +569,11 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// resolver, reads outside the segment. P5 emits no spans, so this was latent; P8 arms
|
// resolver, reads outside the segment. P5 emits no spans, so this was latent; P8 arms
|
||||||
// it, which is exactly when nobody will be reading this code.
|
// it, which is exactly when nobody will be reading this code.
|
||||||
if (segments.Resolve(span.Seg, span.Offset, span.Size) == nullptr) {
|
if (segments.Resolve(span.Seg, span.Offset, span.Size) == nullptr) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"host-span\"} seg=%u offset=%llu "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"host-span\"} seg=%u offset=%llu "
|
||||||
"size=%llu does not lie inside that segment (R-2.3 arm 4)",
|
"size=%llu does not lie inside that segment (R-2.3 arm 4)",
|
||||||
static_cast<unsigned>(span.Seg),
|
static_cast<unsigned>(span.Seg),
|
||||||
static_cast<unsigned long long>(span.Offset),
|
static_cast<unsigned long long>(span.Offset),
|
||||||
static_cast<unsigned long long>(span.Size));
|
static_cast<unsigned long long>(span.Size));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -825,13 +839,35 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// Encoder
|
// Encoder
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
PipeWireEncoder::PipeWireEncoder(Transport::ILink* link, SegmentTable* segments)
|
||||||
|
: m_segments(segments) {
|
||||||
|
if (!link) return;
|
||||||
|
m_progress = link->Progress(); m_signals = link->Signals(); m_cmd = &link->CommandsOut();
|
||||||
|
m_link = link->Capabilities().PublishIsDelivery ? nullptr : link;
|
||||||
|
}
|
||||||
|
|
||||||
PipeWireEncoder::PipeWireEncoder(Transport::RingControl* control, Transport::RingProducer* cmd,
|
PipeWireEncoder::PipeWireEncoder(Transport::RingControl* control, Transport::RingProducer* cmd,
|
||||||
Transport::RingProducer* stage, SegmentTable* segments)
|
Transport::RingProducer* stage, SegmentTable* segments)
|
||||||
: m_control(control), m_cmd(cmd), m_stage(stage), m_segments(segments) {}
|
: m_cmd(cmd), m_stage(stage), m_segments(segments) {
|
||||||
|
if (control) {
|
||||||
|
m_progress = &control->Progress;
|
||||||
|
m_signals = {&control->cmdHead, &control->submittedSeq, &control->consumerParked,
|
||||||
|
&control->producerParked, &control->eventRingFull};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bool PipeWireEncoder::Valid() const { return m_control != nullptr && m_cmd != nullptr; }
|
Bool PipeWireEncoder::Valid() const { return m_progress != nullptr && m_cmd != nullptr; }
|
||||||
|
|
||||||
|
Bool PipeWireEncoder::CheckCancellation() {
|
||||||
|
if (Cancelled() || (m_cancellationHook && m_cancellationHook(m_cancellationSelf)) ||
|
||||||
|
(m_stageRetirementBell && m_stageRetirementBell->Dead())) {
|
||||||
|
m_cancelled = true;
|
||||||
|
}
|
||||||
|
return m_cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
Uint8* PipeWireEncoder::StageAllocate(Uint64 size) {
|
Uint8* PipeWireEncoder::StageAllocate(Uint64 size) {
|
||||||
|
if (CheckCancellation()) return nullptr;
|
||||||
if (m_stageBase == nullptr) {
|
if (m_stageBase == nullptr) {
|
||||||
const SegmentView view = m_segments != nullptr ? m_segments->Get(kSegStage)
|
const SegmentView view = m_segments != nullptr ? m_segments->Get(kSegStage)
|
||||||
: SegmentView{};
|
: SegmentView{};
|
||||||
@@ -855,19 +891,37 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
|
|
||||||
const Uint64 need = Align8(size);
|
const Uint64 need = Align8(size);
|
||||||
if (need > m_stageCapacity) {
|
if (need > m_stageCapacity) {
|
||||||
MGLOG_F("MGPipe: Fatal{RingOverrun, \"SEG_STAGE\"} a %llu byte blob cannot fit a "
|
SessionFail(MGFatalFamily::RingOverrun, "MGPipe: Fatal{RingOverrun, \"SEG_STAGE\"} a %llu byte blob cannot fit a "
|
||||||
"%llu byte staging segment at any occupancy; a blob is staged whole, so a "
|
"%llu byte staging segment at any occupancy; a blob is staged whole, so a "
|
||||||
"row that cuts its content at MGPipeStageChunkBytes() never reaches this - "
|
"row that cuts its content at MGPipeStageChunkBytes() never reaches this - "
|
||||||
"raise MOBILEGL_IPC_STAGE_MB or report the record type with no cut to the "
|
"raise MOBILEGL_IPC_STAGE_MB or report the record type with no cut to the "
|
||||||
"integrator",
|
"integrator",
|
||||||
static_cast<unsigned long long>(size),
|
static_cast<unsigned long long>(size),
|
||||||
static_cast<unsigned long long>(m_stageCapacity));
|
static_cast<unsigned long long>(m_stageCapacity));
|
||||||
std::abort();
|
}
|
||||||
|
|
||||||
|
// P6 GATE 8's FIRST NUMBER (CONTRACT-P6.md §9 item 8): the bytes this producer staged. The
|
||||||
|
// blob's OWN bytes are recorded, from here - where the request first becomes an allocation
|
||||||
|
// - because this is the ONE place every writer of SEG_STAGE passes through (StageBytes is
|
||||||
|
// the only caller, and every buffer walk, texture slab, CSO archive and block name reaches
|
||||||
|
// them through it), which is what makes the count complete by construction rather than by
|
||||||
|
// a hand-kept list of callers.
|
||||||
|
//
|
||||||
|
// `size`, NOT `need`: the Align8 slack is the allocator's, not content the producer wrote,
|
||||||
|
// and charging it here would make a workload of 8-byte blobs look like one of 16-byte
|
||||||
|
// blobs. The allocator's wrap skip is excluded for the same reason.
|
||||||
|
//
|
||||||
|
// The sample below the byte add is the same call site for the same reason: the per-blob
|
||||||
|
// distribution is a property of what the PRODUCER handed over, before the arena rounds it.
|
||||||
|
if (MG_Util::PipeStats::Enabled()) {
|
||||||
|
MG_Util::PipeStats::AddBytes(MG_Util::PipeStats::ByteClass::StageSegmentBytes, size);
|
||||||
|
MG_Util::PipeStats::RecordStagedBlobBytes(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool reclaimed = false;
|
bool reclaimed = false;
|
||||||
bool waited = false;
|
bool waited = false;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
if (CheckCancellation()) return nullptr;
|
||||||
// THE WRAP SKIP MAY ONLY BE CHARGED AGAINST BYTES THAT ARE STILL IN FLIGHT. When
|
// THE WRAP SKIP MAY ONLY BE CHARGED AGAINST BYTES THAT ARE STILL IN FLIGHT. When
|
||||||
// there are none the allocator starts over at offset zero, so a blob the segment
|
// there are none the allocator starts over at offset zero, so a blob the segment
|
||||||
// can hold whole is never refused (see RebaseEmptyStage). On retry this runs
|
// can hold whole is never refused (see RebaseEmptyStage). On retry this runs
|
||||||
@@ -882,6 +936,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
if ((m_stageHead + skip + need) - m_stageTail <= m_stageCapacity) {
|
if ((m_stageHead + skip + need) - m_stageTail <= m_stageCapacity) {
|
||||||
const Uint64 at = (m_stageHead + skip) % m_stageCapacity;
|
const Uint64 at = (m_stageHead + skip) % m_stageCapacity;
|
||||||
m_stageHead += skip + need;
|
m_stageHead += skip + need;
|
||||||
|
Transport::LinkMetricsStageBytes(size);
|
||||||
return m_stageBase + at;
|
return m_stageBase + at;
|
||||||
}
|
}
|
||||||
if (!reclaimed) {
|
if (!reclaimed) {
|
||||||
@@ -893,7 +948,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
if (m_stageRetirementBell == nullptr || m_stageMarkFront == m_stageMarks.size()) break;
|
if (m_stageRetirementBell == nullptr || m_stageMarkFront == m_stageMarks.size()) break;
|
||||||
const Uint64 pending = m_stageMarks[m_stageMarkFront].Seq;
|
const Uint64 pending = m_stageMarks[m_stageMarkFront].Seq;
|
||||||
const auto ready = [&] {
|
const auto ready = [&] {
|
||||||
return m_control->retiredSeq.load(std::memory_order_acquire) >= pending;
|
return m_progress->retiredSeq.load(std::memory_order_acquire) >= pending;
|
||||||
};
|
};
|
||||||
if (!ready()) {
|
if (!ready()) {
|
||||||
// The allocation still cannot progress after reclamation. Count this
|
// The allocation still cannot progress after reclamation. Count this
|
||||||
@@ -906,16 +961,20 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// again. The hook is null in every standalone codec, which has no session and
|
// again. The hook is null in every standalone codec, which has no session and
|
||||||
// therefore no reverse channel to drain.
|
// therefore no reverse channel to drain.
|
||||||
if (m_stageWaitHook != nullptr) m_stageWaitHook(m_stageWaitSelf);
|
if (m_stageWaitHook != nullptr) m_stageWaitHook(m_stageWaitSelf);
|
||||||
if (!ready() && !m_stageRetirementBell->Wait(m_control->producerParked, ready, 0, 5000)) {
|
if (m_link) m_link->Flush();
|
||||||
MGLOG_F("MGPipe: Fatal{RetirementWaitFailed, \"SEG_STAGE\"} producer wait "
|
if (CheckCancellation()) return nullptr;
|
||||||
"ended before the pending allocation retired (shutdown or timeout)");
|
if (!ready() && !m_stageRetirementBell->Wait(*m_signals.ProducerParked, ready, 0,
|
||||||
std::abort();
|
m_stageWaitTimeoutMs)) {
|
||||||
|
if (CheckCancellation()) return nullptr;
|
||||||
|
SessionFail(MGFatalFamily::RetirementWaitFailed,
|
||||||
|
"MGPipe: Fatal{RetirementWaitFailed, \"SEG_STAGE\"} live peer did not retire "
|
||||||
|
"the pending allocation within %u ms", m_stageWaitTimeoutMs);
|
||||||
}
|
}
|
||||||
if (m_stageWaitHook != nullptr) m_stageWaitHook(m_stageWaitSelf);
|
if (m_stageWaitHook != nullptr) m_stageWaitHook(m_stageWaitSelf);
|
||||||
}
|
}
|
||||||
ReclaimStagedBytes();
|
ReclaimStagedBytes();
|
||||||
}
|
}
|
||||||
MGLOG_F("MGPipe: Fatal{RingOverrun, \"SEG_STAGE\"} a %llu byte blob does not fit a %llu "
|
SessionFail(MGFatalFamily::RingOverrun, "MGPipe: Fatal{RingOverrun, \"SEG_STAGE\"} a %llu byte blob does not fit a %llu "
|
||||||
"byte staging segment with %llu bytes still in flight (retiredSeq=%llu); a "
|
"byte staging segment with %llu bytes still in flight (retiredSeq=%llu); a "
|
||||||
"blob is staged whole and only the rows that cut at the stage chunk budget "
|
"blob is staged whole and only the rows that cut at the stage chunk budget "
|
||||||
"stay small - raise MOBILEGL_IPC_STAGE_MB or report that row to the integrator",
|
"stay small - raise MOBILEGL_IPC_STAGE_MB or report that row to the integrator",
|
||||||
@@ -923,11 +982,11 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
static_cast<unsigned long long>(m_stageCapacity),
|
static_cast<unsigned long long>(m_stageCapacity),
|
||||||
static_cast<unsigned long long>(m_stageHead - m_stageTail),
|
static_cast<unsigned long long>(m_stageHead - m_stageTail),
|
||||||
static_cast<unsigned long long>(
|
static_cast<unsigned long long>(
|
||||||
m_control != nullptr ? m_control->retiredSeq.load(std::memory_order_acquire) : 0));
|
m_progress != nullptr ? m_progress->retiredSeq.load(std::memory_order_acquire) : 0));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MGPBlobRef PipeWireEncoder::StageBytes(const void* bytes, Uint64 size) {
|
MGPBlobRef PipeWireEncoder::StageBytes(const void* bytes, Uint64 size) {
|
||||||
|
if (CheckCancellation()) return {};
|
||||||
if (!Valid() || m_segments == nullptr) {
|
if (!Valid() || m_segments == nullptr) {
|
||||||
WireProtocolFatal("PipeWireEncoder::StageBytes",
|
WireProtocolFatal("PipeWireEncoder::StageBytes",
|
||||||
"no command producer or segment table installed");
|
"no command producer or segment table installed");
|
||||||
@@ -944,8 +1003,10 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Uint8* slot = StageAllocate(size);
|
Uint8* slot = StageAllocate(size);
|
||||||
|
if (slot == nullptr || CheckCancellation()) return {};
|
||||||
std::memcpy(slot, bytes, static_cast<SizeT>(size));
|
std::memcpy(slot, bytes, static_cast<SizeT>(size));
|
||||||
const Uint64 offset = static_cast<Uint64>(slot - m_stageBase);
|
const Uint64 offset = static_cast<Uint64>(slot - m_stageBase);
|
||||||
|
if (m_link) m_link->NoteStage({offset, size});
|
||||||
|
|
||||||
MGPBlobRef ref{};
|
MGPBlobRef ref{};
|
||||||
ref.Seg = kSegStage;
|
ref.Seg = kSegStage;
|
||||||
@@ -972,6 +1033,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
|
|
||||||
Uint64 PipeWireEncoder::EncodeRecord(MGPWireOp op, const void* payload, Uint64 payloadBytes,
|
Uint64 PipeWireEncoder::EncodeRecord(MGPWireOp op, const void* payload, Uint64 payloadBytes,
|
||||||
const WireTail* tails, Uint32 tailCount) {
|
const WireTail* tails, Uint32 tailCount) {
|
||||||
|
if (Cancelled()) return kInvalidSeq;
|
||||||
if (!Valid()) {
|
if (!Valid()) {
|
||||||
WireProtocolFatal("PipeWireEncoder::EncodeRecord", "no SEG_CMD producer installed");
|
WireProtocolFatal("PipeWireEncoder::EncodeRecord", "no SEG_CMD producer installed");
|
||||||
}
|
}
|
||||||
@@ -1020,14 +1082,13 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
if (total > m_cmd->MaxRecordBytes()) {
|
if (total > m_cmd->MaxRecordBytes()) {
|
||||||
// R-10's record bound. The content rows cut their BLOBS at the stage chunk budget
|
// R-10's record bound. The content rows cut their BLOBS at the stage chunk budget
|
||||||
// (MGPipeStageChunkBytes); a record's own bytes have no such budget and die here.
|
// (MGPipeStageChunkBytes); a record's own bytes have no such budget and die here.
|
||||||
MGLOG_F("MGPipe: Fatal{RingOverrun, \"%s\"} a %llu byte record exceeds "
|
SessionFail(MGFatalFamily::RingOverrun, "MGPipe: Fatal{RingOverrun, \"%s\"} a %llu byte record exceeds "
|
||||||
"RingProducer::MaxRecordBytes() == %llu (half of a %llu byte SEG_CMD); the stage chunk "
|
"RingProducer::MaxRecordBytes() == %llu (half of a %llu byte SEG_CMD); the stage chunk "
|
||||||
"budget cuts blobs, not a record's own bytes - report the row to the "
|
"budget cuts blobs, not a record's own bytes - report the row to the "
|
||||||
"integrator",
|
"integrator",
|
||||||
WireOpName(op), static_cast<unsigned long long>(total),
|
WireOpName(op), static_cast<unsigned long long>(total),
|
||||||
static_cast<unsigned long long>(m_cmd->MaxRecordBytes()),
|
static_cast<unsigned long long>(m_cmd->MaxRecordBytes()),
|
||||||
static_cast<unsigned long long>(m_cmd->Capacity()));
|
static_cast<unsigned long long>(m_cmd->Capacity()));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MGPipeCallFlags -> RingRecordFlags. See the file header: these are two flag spaces
|
// MGPipeCallFlags -> RingRecordFlags. See the file header: these are two flag spaces
|
||||||
@@ -1131,13 +1192,12 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// here and a Fatal on a peer - exactly the asymmetry EncodeRecord's own
|
// here and a Fatal on a peer - exactly the asymmetry EncodeRecord's own
|
||||||
// comment says it exists to prevent.
|
// comment says it exists to prevent.
|
||||||
if (op == MGPWireOp::CreateShaderState && i < 6 && blob.Size != 0) {
|
if (op == MGPWireOp::CreateShaderState && i < 6 && blob.Size != 0) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"CreateShaderState.Spirv[%u]\"} "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"CreateShaderState.Spirv[%u]\"} "
|
||||||
"declares %llu bytes at the ENCODER; under split the modules travel "
|
"declares %llu bytes at the ENCODER; under split the modules travel "
|
||||||
"inside the Reflection archive and the six per-stage runs stay "
|
"inside the Reflection archive and the six per-stage runs stay "
|
||||||
"undeclared",
|
"undeclared",
|
||||||
static_cast<unsigned>(i),
|
static_cast<unsigned>(i),
|
||||||
static_cast<unsigned long long>(blob.Size));
|
static_cast<unsigned long long>(blob.Size));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1164,6 +1224,20 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// the measured answer on the reduced path is a different row entirely.
|
// the measured answer on the reduced path is a different row entirely.
|
||||||
m_maxRecordOp = op;
|
m_maxRecordOp = op;
|
||||||
}
|
}
|
||||||
|
// P6 GATE 8's SECOND NUMBER (CONTRACT-P6.md §9 item 8), and it is counted HERE rather than
|
||||||
|
// at any emitter for the reason the CallClass comment gives: after chunking, the emitter
|
||||||
|
// no longer knows how many records its one call produced. By this point the record is
|
||||||
|
// COMMITTED - Reserve succeeded, the body is written and the blob slots have been checked
|
||||||
|
// honest - so this is exactly "records/frame post-chunking", not "emitter calls/frame".
|
||||||
|
//
|
||||||
|
// A kRecPad FILLER CANNOT REACH HERE: Reserve returns the filler's wake-up as a refusal
|
||||||
|
// (kInvalidSeq) and the caller retries, so no pad is ever counted, which is what keeps
|
||||||
|
// this number comparable with the seq space R-3 defines. A REFUSED emission is not counted
|
||||||
|
// either - the early return above is what makes one record cost exactly one.
|
||||||
|
if (MG_Util::PipeStats::Enabled()) {
|
||||||
|
MG_Util::PipeStats::AddCalls(MG_Util::PipeStats::CallClass::WireRecords, 1);
|
||||||
|
}
|
||||||
|
|
||||||
++m_emitSeq;
|
++m_emitSeq;
|
||||||
// The stage mark: where SEG_STAGE stood once everything this record names had been
|
// The stage mark: where SEG_STAGE stood once everything this record names had been
|
||||||
// staged. ReclaimStagedBytes releases up to the newest mark the server has retired.
|
// staged. ReclaimStagedBytes releases up to the newest mark the server has retired.
|
||||||
@@ -1198,10 +1272,10 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PipeWireEncoder::ReclaimStagedBytes() {
|
void PipeWireEncoder::ReclaimStagedBytes() {
|
||||||
if (m_control == nullptr) {
|
if (m_progress == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const Uint64 retired = m_control->retiredSeq.load(std::memory_order_acquire);
|
const Uint64 retired = m_progress->retiredSeq.load(std::memory_order_acquire);
|
||||||
Uint64 upTo = m_stageTail;
|
Uint64 upTo = m_stageTail;
|
||||||
while (m_stageMarkFront < m_stageMarks.size() &&
|
while (m_stageMarkFront < m_stageMarks.size() &&
|
||||||
m_stageMarks[m_stageMarkFront].Seq <= retired) {
|
m_stageMarks[m_stageMarkFront].Seq <= retired) {
|
||||||
@@ -1257,11 +1331,11 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// popping a ring, and the release store on SEG_CMD's head below is what orders the
|
// popping a ring, and the release store on SEG_CMD's head below is what orders the
|
||||||
// staged writes before the record that names them.
|
// staged writes before the record that names them.
|
||||||
m_cmd->Publish();
|
m_cmd->Publish();
|
||||||
if (m_control != nullptr) {
|
if (m_progress != nullptr) {
|
||||||
// submittedSeq is the one watermark the PRODUCER owns (Ring.h's five-watermark
|
// submittedSeq is the one watermark the PRODUCER owns (Ring.h's five-watermark
|
||||||
// block). Nobody waits on it; it answers "how far ahead of the server is the
|
// block). Nobody waits on it; it answers "how far ahead of the server is the
|
||||||
// client right now".
|
// client right now".
|
||||||
m_control->submittedSeq.store(m_emitSeq, std::memory_order_release);
|
m_signals.SubmittedSeq->store(m_emitSeq, std::memory_order_release);
|
||||||
}
|
}
|
||||||
// The reclaim has a trigger in this package, rather than depending on a c1 barrier
|
// The reclaim has a trigger in this package, rather than depending on a c1 barrier
|
||||||
// that does not exist yet: every publish is a chance to notice what the server has
|
// that does not exist yet: every publish is a chance to notice what the server has
|
||||||
@@ -1300,9 +1374,15 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// Decoder
|
// Decoder
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
PipeWireDecoder::PipeWireDecoder(Transport::ILink* link, SegmentTable* segments, ReplySink* replies)
|
||||||
|
: m_valid(link && link->Attached()), m_segments(segments), m_replies(replies) {
|
||||||
|
m_auditPoison = MG_Config::Ipc.Audit;
|
||||||
|
InstallApplyHook();
|
||||||
|
}
|
||||||
|
|
||||||
PipeWireDecoder::PipeWireDecoder(Transport::RingControl* control, SegmentTable* segments,
|
PipeWireDecoder::PipeWireDecoder(Transport::RingControl* control, SegmentTable* segments,
|
||||||
ReplySink* replies)
|
ReplySink* replies)
|
||||||
: m_control(control), m_segments(segments), m_replies(replies) {
|
: m_valid(control != nullptr), m_segments(segments), m_replies(replies) {
|
||||||
m_auditPoison = MG_Config::Ipc.Audit;
|
m_auditPoison = MG_Config::Ipc.Audit;
|
||||||
// Once, at construction, beside the resolver it is modelled on - not per record from
|
// Once, at construction, beside the resolver it is modelled on - not per record from
|
||||||
// the apply thread. The thunk is inert without a decoder on the calling thread, so an
|
// the apply thread. The thunk is inert without a decoder on the calling thread, so an
|
||||||
@@ -1316,7 +1396,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
|
|
||||||
void PipeWireDecoder::UninstallApplyHook() { MG_Pipe::gMGPipeWireRecordApply = nullptr; }
|
void PipeWireDecoder::UninstallApplyHook() { MG_Pipe::gMGPipeWireRecordApply = nullptr; }
|
||||||
|
|
||||||
Bool PipeWireDecoder::Valid() const { return m_control != nullptr && m_segments != nullptr; }
|
Bool PipeWireDecoder::Valid() const { return m_valid && m_segments != nullptr; }
|
||||||
|
|
||||||
Uint64 PipeWireDecoder::AppliedSeq() const { return m_applySeq; }
|
Uint64 PipeWireDecoder::AppliedSeq() const { return m_applySeq; }
|
||||||
|
|
||||||
@@ -1347,11 +1427,10 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// then fails for ever: the barrier HANGS rather than returning something wrong, which
|
// then fails for ever: the barrier HANGS rather than returning something wrong, which
|
||||||
// is the harder failure to diagnose of the two.
|
// is the harder failure to diagnose of the two.
|
||||||
if ((MGPipeCallFlagsFor(op) & static_cast<Uint32>(kReplySlot)) == 0) {
|
if ((MGPipeCallFlagsFor(op) & static_cast<Uint32>(kReplySlot)) == 0) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"%s\"} the decoder tried to answer into "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s\"} the decoder tried to answer into "
|
||||||
"a reply slot for a call the catalogue gives no kReplySlot; s1 sizes "
|
"a reply slot for a call the catalogue gives no kReplySlot; s1 sizes "
|
||||||
"ReplyPool from MGPipeCallFlagsFor and reserved none",
|
"ReplyPool from MGPipeCallFlagsFor and reserved none",
|
||||||
WireOpName(op));
|
WireOpName(op));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (m_replies != nullptr) {
|
if (m_replies != nullptr) {
|
||||||
m_replies->PostReply(seq, status, bytes, size);
|
m_replies->PostReply(seq, status, bytes, size);
|
||||||
@@ -1376,23 +1455,21 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// the audit has stopped covering the carrier, which is the same failure as no audit at
|
// the audit has stopped covering the carrier, which is the same failure as no audit at
|
||||||
// all - the reason the run-count overflow just below is a Fatal too.
|
// all - the reason the run-count overflow just below is a Fatal too.
|
||||||
if (blob.Size == 0 || blob.Seg != kSegStage) {
|
if (blob.Size == 0 || blob.Seg != kSegStage) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"%s\"} the audit was asked to record a "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s\"} the audit was asked to record a "
|
||||||
"resolved run with seg=%u size=%llu; only declared SEG_STAGE(%u) runs "
|
"resolved run with seg=%u size=%llu; only declared SEG_STAGE(%u) runs "
|
||||||
"reach the poison fill (R-2.5)",
|
"reach the poison fill (R-2.5)",
|
||||||
WireOpName(op), static_cast<unsigned>(blob.Seg),
|
WireOpName(op), static_cast<unsigned>(blob.Seg),
|
||||||
static_cast<unsigned long long>(blob.Size),
|
static_cast<unsigned long long>(blob.Size),
|
||||||
static_cast<unsigned>(kSegStage));
|
static_cast<unsigned>(kSegStage));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
if (m_resolvedCount >= sizeof(m_resolved) / sizeof(m_resolved[0])) {
|
if (m_resolvedCount >= sizeof(m_resolved) / sizeof(m_resolved[0])) {
|
||||||
// LOUD, NOT A SILENT DROP. This array is what the 0xDD fill covers, and a poison
|
// LOUD, NOT A SILENT DROP. This array is what the 0xDD fill covers, and a poison
|
||||||
// that quietly stopped covering a run is the same failure as no poison at all -
|
// that quietly stopped covering a run is the same failure as no poison at all -
|
||||||
// rule C's only mechanical control going dark without a line in the log.
|
// rule C's only mechanical control going dark without a line in the log.
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"%s\"} more than %llu SEG_STAGE runs in "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s\"} more than %llu SEG_STAGE runs in "
|
||||||
"one record; the audit fill would stop covering them",
|
"one record; the audit fill would stop covering them",
|
||||||
WireOpName(op),
|
WireOpName(op),
|
||||||
static_cast<unsigned long long>(sizeof(m_resolved) / sizeof(m_resolved[0])));
|
static_cast<unsigned long long>(sizeof(m_resolved) / sizeof(m_resolved[0])));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
m_resolved[m_resolvedCount++] = blob;
|
m_resolved[m_resolvedCount++] = blob;
|
||||||
}
|
}
|
||||||
@@ -1508,7 +1585,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// record type)`; it CANNOT SEE THE TAIL, so this is the first thing that holds a
|
// record type)`; it CANNOT SEE THE TAIL, so this is the first thing that holds a
|
||||||
// record declaring Count = 4000 while carrying 8 bytes to its own arithmetic.
|
// record declaring Count = 4000 while carrying 8 bytes to its own arithmetic.
|
||||||
if (size != layout.TotalBytes) {
|
if (size != layout.TotalBytes) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"%s\"} the record declares Size=%llu and "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"%s\"} the record declares Size=%llu and "
|
||||||
"its own count fields describe %llu bytes (fixed payload %llu + tails "
|
"its own count fields describe %llu bytes (fixed payload %llu + tails "
|
||||||
"%llu/%llu/%llu)",
|
"%llu/%llu/%llu)",
|
||||||
WireOpName(op), static_cast<unsigned long long>(size),
|
WireOpName(op), static_cast<unsigned long long>(size),
|
||||||
@@ -1517,7 +1594,6 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
static_cast<unsigned long long>(layout.TailBytes[0]),
|
static_cast<unsigned long long>(layout.TailBytes[0]),
|
||||||
static_cast<unsigned long long>(layout.TailBytes[1]),
|
static_cast<unsigned long long>(layout.TailBytes[1]),
|
||||||
static_cast<unsigned long long>(layout.TailBytes[2]));
|
static_cast<unsigned long long>(layout.TailBytes[2]));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The record's own ordinal, which is its reply-slot id (R-3). 1-based, and m_applySeq
|
// The record's own ordinal, which is its reply-slot id (R-3). 1-based, and m_applySeq
|
||||||
@@ -1791,12 +1867,11 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
for (Uint32 i = 0; i < 6; ++i) {
|
for (Uint32 i = 0; i < 6; ++i) {
|
||||||
CheckBlobIsHonest(op, desc.Spirv[i], *m_segments);
|
CheckBlobIsHonest(op, desc.Spirv[i], *m_segments);
|
||||||
if (desc.Spirv[i].Size != 0) {
|
if (desc.Spirv[i].Size != 0) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"CreateShaderState.Spirv[%u]\"} "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"CreateShaderState.Spirv[%u]\"} "
|
||||||
"declares %llu bytes; under split the modules travel inside the "
|
"declares %llu bytes; under split the modules travel inside the "
|
||||||
"Reflection archive and the six per-stage runs stay undeclared",
|
"Reflection archive and the six per-stage runs stay undeclared",
|
||||||
static_cast<unsigned>(i),
|
static_cast<unsigned>(i),
|
||||||
static_cast<unsigned long long>(desc.Spirv[i].Size));
|
static_cast<unsigned long long>(desc.Spirv[i].Size));
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const void* archiveBytes = ResolveOrFatal(op, desc.Reflection);
|
const void* archiveBytes = ResolveOrFatal(op, desc.Reflection);
|
||||||
@@ -2067,11 +2142,10 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
const Bool boxIsWhole =
|
const Bool boxIsWhole =
|
||||||
rec.UnionBox.W != 0 && rec.UnionBox.H != 0 && rec.UnionBox.D != 0;
|
rec.UnionBox.W != 0 && rec.UnionBox.H != 0 && rec.UnionBox.D != 0;
|
||||||
if (!namesABuffer && !boxIsEmpty && !boxIsWhole) {
|
if (!namesABuffer && !boxIsEmpty && !boxIsWhole) {
|
||||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"ResourceSubData\"} the union box "
|
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"ResourceSubData\"} the union box "
|
||||||
"%ux%ux%u has a zero extent on some axes and not others; a box is "
|
"%ux%ux%u has a zero extent on some axes and not others; a box is "
|
||||||
"either empty or whole",
|
"either empty or whole",
|
||||||
rec.UnionBox.W, rec.UnionBox.H, rec.UnionBox.D);
|
rec.UnionBox.W, rec.UnionBox.H, rec.UnionBox.D);
|
||||||
std::abort();
|
|
||||||
}
|
}
|
||||||
const Bool carriesContent = namesABuffer ? MGPipeSubDataBufferSize(rec) != 0
|
const Bool carriesContent = namesABuffer ? MGPipeSubDataBufferSize(rec) != 0
|
||||||
: (boxIsWhole || rec.RegionCount != 0);
|
: (boxIsWhole || rec.RegionCount != 0);
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// span at all (it only ever writes Ptr = nullptr). Install() therefore takes the role.
|
// span at all (it only ever writes Ptr = nullptr). Install() therefore takes the role.
|
||||||
class SegmentTable {
|
class SegmentTable {
|
||||||
public:
|
public:
|
||||||
|
void AttachLink(Transport::ILink* link);
|
||||||
void Install(SegmentId seg, SegmentView view);
|
void Install(SegmentId seg, SegmentView view);
|
||||||
SegmentView Get(SegmentId seg) const;
|
SegmentView Get(SegmentId seg) const;
|
||||||
|
|
||||||
@@ -100,6 +101,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
static void UninstallProcessResolver();
|
static void UninstallProcessResolver();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Transport::ILink* m_link = nullptr;
|
||||||
SegmentView m_views[kSegAdopt + 1];
|
SegmentView m_views[kSegAdopt + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -218,6 +220,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
class PipeWireEncoder {
|
class PipeWireEncoder {
|
||||||
public:
|
public:
|
||||||
PipeWireEncoder() = default;
|
PipeWireEncoder() = default;
|
||||||
|
PipeWireEncoder(Transport::ILink* link, SegmentTable* segments);
|
||||||
PipeWireEncoder(Transport::RingControl* control, Transport::RingProducer* cmd,
|
PipeWireEncoder(Transport::RingControl* control, Transport::RingProducer* cmd,
|
||||||
Transport::RingProducer* stage, SegmentTable* segments);
|
Transport::RingProducer* stage, SegmentTable* segments);
|
||||||
|
|
||||||
@@ -338,7 +341,20 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
Uint64 StageReclaimWaits() const;
|
Uint64 StageReclaimWaits() const;
|
||||||
// The live session supplies its shutdown-aware producer doorbell. Standalone codecs
|
// The live session supplies its shutdown-aware producer doorbell. Standalone codecs
|
||||||
// without a consumer cannot wait for retirement and retain the named refusal.
|
// without a consumer cannot wait for retirement and retain the named refusal.
|
||||||
|
void SetLink(Transport::ILink* link) { m_link = link; }
|
||||||
void SetStageRetirementDoorbell(Transport::Doorbell* bell) { m_stageRetirementBell = bell; }
|
void SetStageRetirementDoorbell(Transport::Doorbell* bell) { m_stageRetirementBell = bell; }
|
||||||
|
using CancellationHook = Bool (*)(void* self);
|
||||||
|
void SetCancellationState(const std::atomic<bool>* lost, CancellationHook hook, void* self) {
|
||||||
|
m_sessionLost = lost; m_cancellationHook = hook; m_cancellationSelf = self;
|
||||||
|
}
|
||||||
|
// The fast check is used on encode; the doorbell probe only runs while
|
||||||
|
// staging or at an unsuccessful wait boundary.
|
||||||
|
Bool Cancelled() const {
|
||||||
|
return m_cancelled || (m_sessionLost && m_sessionLost->load(std::memory_order_acquire));
|
||||||
|
}
|
||||||
|
Bool CheckCancellation();
|
||||||
|
void SetStageWaitTimeoutMs(Uint32 timeoutMs) { m_stageWaitTimeoutMs = timeoutMs; }
|
||||||
|
|
||||||
|
|
||||||
// P5e (ra, CONTRACT-P5E §2.6): THE STAGE BELL IS A CLIENT WAIT, so it has to drain the
|
// P5e (ra, CONTRACT-P5E §2.6): THE STAGE BELL IS A CLIENT WAIT, so it has to drain the
|
||||||
// reverse channel like every other one. The encoder cannot drain it itself - SEG_EVENT
|
// reverse channel like every other one. The encoder cannot drain it itself - SEG_EVENT
|
||||||
@@ -373,6 +389,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// over the segment; the in-segment offset is `cursor % capacity` and a run that would
|
// over the segment; the in-segment offset is `cursor % capacity` and a run that would
|
||||||
// straddle the end skips to the boundary, exactly as a ring does, but WITHOUT touching
|
// straddle the end skips to the boundary, exactly as a ring does, but WITHOUT touching
|
||||||
// RingControl - see ReclaimStagedBytes above.
|
// RingControl - see ReclaimStagedBytes above.
|
||||||
|
Transport::ILink* m_link = nullptr;
|
||||||
Uint8* StageAllocate(Uint64 size);
|
Uint8* StageAllocate(Uint64 size);
|
||||||
|
|
||||||
// AN EMPTY STAGE STARTS OVER AT ZERO, so that the wrap skip is only ever charged
|
// AN EMPTY STAGE STARTS OVER AT ZERO, so that the wrap skip is only ever charged
|
||||||
@@ -386,7 +403,8 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
// the head and underflow StagedBytesInFlight().
|
// the head and underflow StagedBytesInFlight().
|
||||||
void RebaseEmptyStage();
|
void RebaseEmptyStage();
|
||||||
|
|
||||||
Transport::RingControl* m_control = nullptr;
|
Transport::LinkProgress* m_progress = nullptr;
|
||||||
|
Transport::LinkSignals m_signals{};
|
||||||
Transport::RingProducer* m_cmd = nullptr;
|
Transport::RingProducer* m_cmd = nullptr;
|
||||||
Transport::RingProducer* m_stage = nullptr;
|
Transport::RingProducer* m_stage = nullptr;
|
||||||
SegmentTable* m_segments = nullptr;
|
SegmentTable* m_segments = nullptr;
|
||||||
@@ -397,6 +415,12 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
Uint64 m_cmdWrapPads = 0;
|
Uint64 m_cmdWrapPads = 0;
|
||||||
Uint64 m_stageReclaimWaits = 0;
|
Uint64 m_stageReclaimWaits = 0;
|
||||||
Transport::Doorbell* m_stageRetirementBell = nullptr;
|
Transport::Doorbell* m_stageRetirementBell = nullptr;
|
||||||
|
const std::atomic<bool>* m_sessionLost = nullptr;
|
||||||
|
CancellationHook m_cancellationHook = nullptr;
|
||||||
|
void* m_cancellationSelf = nullptr;
|
||||||
|
Bool m_cancelled = false;
|
||||||
|
Uint32 m_stageWaitTimeoutMs = 120000;
|
||||||
|
|
||||||
// P5e (ra): the session's event drain, called around the stage-bell park (§2.6).
|
// P5e (ra): the session's event drain, called around the stage-bell park (§2.6).
|
||||||
StageWaitHook m_stageWaitHook = nullptr;
|
StageWaitHook m_stageWaitHook = nullptr;
|
||||||
void* m_stageWaitSelf = nullptr;
|
void* m_stageWaitSelf = nullptr;
|
||||||
@@ -606,6 +630,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
class PipeWireDecoder {
|
class PipeWireDecoder {
|
||||||
public:
|
public:
|
||||||
PipeWireDecoder() = default;
|
PipeWireDecoder() = default;
|
||||||
|
PipeWireDecoder(Transport::ILink* link, SegmentTable* segments, ReplySink* replies);
|
||||||
PipeWireDecoder(Transport::RingControl* control, SegmentTable* segments,
|
PipeWireDecoder(Transport::RingControl* control, SegmentTable* segments,
|
||||||
ReplySink* replies);
|
ReplySink* replies);
|
||||||
|
|
||||||
@@ -707,7 +732,7 @@ namespace MobileGL::MG_Remote::Wire {
|
|||||||
|
|
||||||
friend Bool MGPipeWireRecordApplyThunk(MG_Pipe::MGPWireOp, const void*, Uint64, Uint64);
|
friend Bool MGPipeWireRecordApplyThunk(MG_Pipe::MGPWireOp, const void*, Uint64, Uint64);
|
||||||
|
|
||||||
Transport::RingControl* m_control = nullptr;
|
Bool m_valid = false;
|
||||||
SegmentTable* m_segments = nullptr;
|
SegmentTable* m_segments = nullptr;
|
||||||
ReplySink* m_replies = nullptr;
|
ReplySink* m_replies = nullptr;
|
||||||
WireVerbSink* m_verbs = nullptr;
|
WireVerbSink* m_verbs = nullptr;
|
||||||
|
|||||||
@@ -413,9 +413,9 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
// {h,cpp}, beside this header rather than inside it so the check_include_closure.py
|
// {h,cpp}, beside this header rather than inside it so the check_include_closure.py
|
||||||
// "artifacts-header" probe stays untouched. It is two visitors over the tables below - a
|
// "artifacts-header" probe stays untouched. It is two visitors over the tables below - a
|
||||||
// writer that appends to a Vector<Uint8> and a reader that consumes one - length-prefixed,
|
// writer that appends to a Vector<Uint8> and a reader that consumes one - length-prefixed,
|
||||||
// little-endian, with a format-version word first and a MGL_LINKARTIFACTS_SIZE echo
|
// little-endian, with a format-version word and (for disaggregated v2) a recursive
|
||||||
// second, so a struct that gained a field and a codec that did not is a mismatch at READ
|
// wire-schema digest of these tables. Native container sizes are local maintenance
|
||||||
// time rather than a silent truncation. Adding a member to any struct above therefore
|
// assertions below, never cross-standard-library wire facts. Adding a member to any struct above therefore
|
||||||
// means: add its VisitFields row here, update the sizeof number below, and bump
|
// means: add its VisitFields row here, update the sizeof number below, and bump
|
||||||
// kProgramArtifactsCodecVersion. `LinkArtifacts::program` stays the one deliberate
|
// kProgramArtifactsCodecVersion. `LinkArtifacts::program` stays the one deliberate
|
||||||
// omission, and the codec has no arm for it.
|
// omission, and the codec has no arm for it.
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <bit>
|
#include <bit>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -70,6 +71,88 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
template <class T>
|
template <class T>
|
||||||
concept ArchiveUniformInitializer = std::same_as<T, UniformInitializer>;
|
concept ArchiveUniformInitializer = std::same_as<T, UniformInitializer>;
|
||||||
|
|
||||||
|
// glslang supplies no VisitFields table for this aggregate. Keep its one explicit
|
||||||
|
// table shared by the payload writer, reader and wire-schema walk.
|
||||||
|
template <class Self, class Visitor>
|
||||||
|
void VisitUniformInitializer(Self& value, Visitor&& visit) {
|
||||||
|
visit("name", value.name);
|
||||||
|
visit("basicType", value.basicType);
|
||||||
|
visit("vectorSize", value.vectorSize);
|
||||||
|
visit("matrixCols", value.matrixCols);
|
||||||
|
visit("matrixRows", value.matrixRows);
|
||||||
|
visit("arraySize", value.arraySize);
|
||||||
|
visit("intValues", value.intValues);
|
||||||
|
visit("floatValues", value.floatValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
void SchemaWord(Uint64& hash, Uint64 word) {
|
||||||
|
for (unsigned i = 0; i < 8; ++i) {
|
||||||
|
hash ^= (word >> (i * 8)) & 255u;
|
||||||
|
hash *= 1099511628211ull;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void SchemaName(Uint64& hash, const char* text) {
|
||||||
|
do {
|
||||||
|
hash ^= static_cast<unsigned char>(*text);
|
||||||
|
hash *= 1099511628211ull;
|
||||||
|
} while (*text++ != '\0');
|
||||||
|
}
|
||||||
|
template <class Value>
|
||||||
|
void DescribeWireType(Uint64& hash) {
|
||||||
|
using T = std::remove_cv_t<Value>;
|
||||||
|
if constexpr (ArchiveScalar<T>) {
|
||||||
|
// These are the bytes PutRaw/TakeRaw actually carry, not the surrounding
|
||||||
|
// C++ object's layout. Equal-width signed/unsigned or float/int differ.
|
||||||
|
if constexpr (std::is_enum_v<T>) {
|
||||||
|
SchemaName(hash, "enum");
|
||||||
|
DescribeWireType<std::underlying_type_t<T>>(hash);
|
||||||
|
} else {
|
||||||
|
SchemaName(hash, std::is_same_v<T, bool> ? "bool" :
|
||||||
|
std::is_floating_point_v<T> ? "ieee-float" :
|
||||||
|
std::is_signed_v<T> ? "signed" : "unsigned");
|
||||||
|
SchemaWord(hash, sizeof(T));
|
||||||
|
if constexpr (std::is_floating_point_v<T>) {
|
||||||
|
static_assert(std::numeric_limits<T>::is_iec559);
|
||||||
|
SchemaWord(hash, std::numeric_limits<T>::digits);
|
||||||
|
SchemaWord(hash, std::numeric_limits<T>::max_exponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if constexpr (ArchiveString<T>) {
|
||||||
|
SchemaName(hash, "string-u64-count-byte-content");
|
||||||
|
} else if constexpr (ArchiveMap<T>) {
|
||||||
|
SchemaName(hash, "map-u64-count");
|
||||||
|
DescribeWireType<typename T::key_type>(hash);
|
||||||
|
DescribeWireType<typename T::mapped_type>(hash);
|
||||||
|
} else if constexpr (ArchiveSet<T>) {
|
||||||
|
SchemaName(hash, "set-u64-count");
|
||||||
|
DescribeWireType<typename T::value_type>(hash);
|
||||||
|
} else if constexpr (ArchiveFixedArray<T>) {
|
||||||
|
SchemaName(hash, "fixed-array");
|
||||||
|
SchemaWord(hash, std::tuple_size<T>::value);
|
||||||
|
DescribeWireType<typename T::value_type>(hash);
|
||||||
|
} else if constexpr (ArchiveVector<T>) {
|
||||||
|
SchemaName(hash, "vector-u64-count");
|
||||||
|
DescribeWireType<typename T::value_type>(hash);
|
||||||
|
} else {
|
||||||
|
SchemaName(hash, ArchiveUniformInitializer<T> ? "uniform-initializer" : "record");
|
||||||
|
// Visit only types/names from default records. Container contents are never
|
||||||
|
// traversed, and no sizeof(string/vector/map), offset or allocator enters it.
|
||||||
|
T value{};
|
||||||
|
Uint64 fields = 0;
|
||||||
|
const auto field = [&](const char* name, const auto& member) {
|
||||||
|
++fields;
|
||||||
|
SchemaName(hash, name);
|
||||||
|
DescribeWireType<std::remove_cvref_t<decltype(member)>>(hash);
|
||||||
|
};
|
||||||
|
if constexpr (ArchiveUniformInitializer<T>) VisitUniformInitializer(value, field);
|
||||||
|
else VisitFields(value, field);
|
||||||
|
SchemaWord(hash, fields);
|
||||||
|
SchemaName(hash, "end-record");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// ---- the writer ----
|
// ---- the writer ----
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -117,6 +200,11 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
} else if constexpr (ArchiveVector<T>) {
|
} else if constexpr (ArchiveVector<T>) {
|
||||||
WriteSequence(out, value);
|
WriteSequence(out, value);
|
||||||
} else if constexpr (ArchiveUniformInitializer<T>) {
|
} else if constexpr (ArchiveUniformInitializer<T>) {
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
VisitUniformInitializer(value, [&out](const char*, const auto& member) {
|
||||||
|
WriteValue(out, member);
|
||||||
|
});
|
||||||
|
#else
|
||||||
WriteValue(out, value.name);
|
WriteValue(out, value.name);
|
||||||
WriteValue(out, value.basicType);
|
WriteValue(out, value.basicType);
|
||||||
WriteValue(out, value.vectorSize);
|
WriteValue(out, value.vectorSize);
|
||||||
@@ -125,6 +213,7 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
WriteValue(out, value.arraySize);
|
WriteValue(out, value.arraySize);
|
||||||
WriteValue(out, value.intValues);
|
WriteValue(out, value.intValues);
|
||||||
WriteValue(out, value.floatValues);
|
WriteValue(out, value.floatValues);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// The archive's own structs: TypeFacts, ResourceReflection, XfbVarying. ONE
|
// The archive's own structs: TypeFacts, ResourceReflection, XfbVarying. ONE
|
||||||
// table serves both directions, so a member added to any of them is carried by
|
// table serves both directions, so a member added to any of them is carried by
|
||||||
@@ -223,6 +312,11 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
if (!in.Ok) return;
|
if (!in.Ok) return;
|
||||||
}
|
}
|
||||||
} else if constexpr (ArchiveUniformInitializer<T>) {
|
} else if constexpr (ArchiveUniformInitializer<T>) {
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
VisitUniformInitializer(value, [&in](const char*, auto& member) {
|
||||||
|
if (in.Ok) ReadValue(in, member);
|
||||||
|
});
|
||||||
|
#else
|
||||||
ReadValue(in, value.name);
|
ReadValue(in, value.name);
|
||||||
ReadValue(in, value.basicType);
|
ReadValue(in, value.basicType);
|
||||||
ReadValue(in, value.vectorSize);
|
ReadValue(in, value.vectorSize);
|
||||||
@@ -231,6 +325,7 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
ReadValue(in, value.arraySize);
|
ReadValue(in, value.arraySize);
|
||||||
ReadValue(in, value.intValues);
|
ReadValue(in, value.intValues);
|
||||||
ReadValue(in, value.floatValues);
|
ReadValue(in, value.floatValues);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
VisitFields(value, [&in](const char*, auto& field) {
|
VisitFields(value, [&in](const char*, auto& field) {
|
||||||
if (in.Ok) ReadValue(in, field);
|
if (in.Ok) ReadValue(in, field);
|
||||||
@@ -238,29 +333,41 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The struct-size echo. Under a toolchain whose sizes are not pinned yet
|
// v1 is retained for local monolith verification. Its native size echo is not a
|
||||||
// (ProgramArtifacts.h's libc++ branch until the integrator fills it in) this is 0,
|
// wire compatibility fact: libstdc++ writes 1056 while unpinned libc++ writes zero.
|
||||||
// which still round-trips within one build - the echo compares what THIS build wrote
|
#if !MOBILEGL_BUILD_DISAGGREGATED
|
||||||
// against what THIS build expects - and stops mattering the moment the pin lands.
|
|
||||||
//
|
|
||||||
// P5e (pg) READ THIS LINE AS THE CONTRACT ASKED (CONTRACT-P5E §5.5) and its verdict is
|
|
||||||
// in ProgramArtifactsCodec.h's header comment: the caveat is about the ECHO WORD, not
|
|
||||||
// about a member the codec skips - the one member VisitFields omits is
|
|
||||||
// `LinkArtifacts::program`, and no backend twin reads it. A 0 echo is exact for an
|
|
||||||
// in-process split, where the writer and the reader are one build, and becomes a real
|
|
||||||
// cross-toolchain check when P6 puts a client and a server in different processes
|
|
||||||
// built by different compilers.
|
|
||||||
#ifdef MGL_LINKARTIFACTS_SIZE
|
#ifdef MGL_LINKARTIFACTS_SIZE
|
||||||
inline constexpr Uint64 kLinkArtifactsSizeEcho = MGL_LINKARTIFACTS_SIZE;
|
inline constexpr Uint64 kLinkArtifactsSizeEcho = MGL_LINKARTIFACTS_SIZE;
|
||||||
#else
|
#else
|
||||||
inline constexpr Uint64 kLinkArtifactsSizeEcho = 0;
|
inline constexpr Uint64 kLinkArtifactsSizeEcho = 0;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
Uint64 ProgramArtifactsSchemaFingerprint() {
|
||||||
|
static const Uint64 fingerprint = [] {
|
||||||
|
Uint64 hash = 1469598103934665603ull;
|
||||||
|
SchemaName(hash, "MobileGL.ProgramArchive.v2.little-endian");
|
||||||
|
// The outer stage framing is part of the same wire contract.
|
||||||
|
SchemaName(hash, "stage-list-u32-count-u32-elements");
|
||||||
|
SchemaWord(hash, kProgramArchiveMaxStages);
|
||||||
|
DescribeWireType<LinkArtifacts>(hash);
|
||||||
|
DescribeWireType<SpirvArtifacts>(hash);
|
||||||
|
return hash == 0 ? Uint64{1} : hash;
|
||||||
|
}();
|
||||||
|
return fingerprint;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void EncodeProgramArtifacts(const LinkArtifacts& link, const SpirvArtifacts& spirv,
|
void EncodeProgramArtifacts(const LinkArtifacts& link, const SpirvArtifacts& spirv,
|
||||||
Vector<Uint8>& out) {
|
Vector<Uint8>& out) {
|
||||||
PutRaw(out, kProgramArtifactsCodecVersion);
|
PutRaw(out, kProgramArtifactsCodecVersion);
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
PutRaw(out, ProgramArtifactsSchemaFingerprint());
|
||||||
|
#else
|
||||||
PutRaw(out, kLinkArtifactsSizeEcho);
|
PutRaw(out, kLinkArtifactsSizeEcho);
|
||||||
|
#endif
|
||||||
// `link` is walked through its own VisitFields table, which omits the live
|
// `link` is walked through its own VisitFields table, which omits the live
|
||||||
// SharedPtr<glslang::TProgram>: 57 of the 58 members. There is no arm here for it and
|
// SharedPtr<glslang::TProgram>: 57 of the 58 members. There is no arm here for it and
|
||||||
// there must not be one - it points into a glslang arena that no archived instance
|
// there must not be one - it points into a glslang arena that no archived instance
|
||||||
@@ -280,14 +387,16 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
|
|
||||||
ReadCursor in{bytes, size, 0, true};
|
ReadCursor in{bytes, size, 0, true};
|
||||||
Uint32 version = 0;
|
Uint32 version = 0;
|
||||||
Uint64 sizeEcho = 0;
|
Uint64 schema = 0;
|
||||||
if (!TakeRaw(in, version) || !TakeRaw(in, sizeEcho)) return false;
|
if (!TakeRaw(in, version) || !TakeRaw(in, schema)) return false;
|
||||||
// REFUSED, NOT GUESSED. A different version word or a struct that changed width means
|
// Refuse the declared wire shape before reading any field. In v2 the second word
|
||||||
// the bytes describe a layout this build does not have; deserialising them anyway
|
// follows serialization types/order; C++ container object sizes are irrelevant.
|
||||||
// writes garbage into the tail of a reflection table, which is exactly the failure the
|
|
||||||
// two words exist to turn into a clean false.
|
|
||||||
if (version != kProgramArtifactsCodecVersion) return false;
|
if (version != kProgramArtifactsCodecVersion) return false;
|
||||||
if (sizeEcho != kLinkArtifactsSizeEcho) return false;
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
if (schema != ProgramArtifactsSchemaFingerprint()) return false;
|
||||||
|
#else
|
||||||
|
if (schema != kLinkArtifactsSizeEcho) return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
ReadValue(in, link);
|
ReadValue(in, link);
|
||||||
ReadValue(in, spirv);
|
ReadValue(in, spirv);
|
||||||
|
|||||||
@@ -32,9 +32,9 @@
|
|||||||
// path.
|
// path.
|
||||||
//
|
//
|
||||||
// THE FORMAT, and every part of it is a refusal rather than a guess:
|
// THE FORMAT, and every part of it is a refusal rather than a guess:
|
||||||
// * a VERSION word first, and a MGL_LINKARTIFACTS_SIZE echo second, so a struct that gained
|
// * a VERSION word first, and a wire-schema fingerprint second (v2), so member order,
|
||||||
// a field and a codec that did not is a MISMATCH AT READ TIME rather than a silent
|
// type or count-layout drift is a MISMATCH before decoding. The local-only v1 form
|
||||||
// truncation that deserialises garbage into the tail of a reflection table;
|
// retains its legacy native-size echo;
|
||||||
// * length-prefixed everything - strings, vectors, maps, sets - with the count checked
|
// * length-prefixed everything - strings, vectors, maps, sets - with the count checked
|
||||||
// against the bytes that remain before a single element is allocated, so a corrupt count
|
// against the bytes that remain before a single element is allocated, so a corrupt count
|
||||||
// cannot turn into a four-billion-element resize;
|
// cannot turn into a four-billion-element resize;
|
||||||
@@ -54,19 +54,20 @@
|
|||||||
// member it does not carry is one no twin has ever asked for. It could not be carried in any
|
// member it does not carry is one no twin has ever asked for. It could not be carried in any
|
||||||
// case: it points into a glslang arena that no archived instance owns.
|
// case: it points into a glslang arena that no archived instance owns.
|
||||||
//
|
//
|
||||||
// AND THE OTHER HALF OF THAT CONTRACT LINE - `ProgramArtifactsCodec.cpp`'s libc++ caveat - is
|
// P6.5: native STL object sizes never describe this field-wise byte stream. Disaggregated
|
||||||
// about the STRUCT-SIZE ECHO, not about a member: under a toolchain whose `MGL_LINKARTIFACTS_SIZE`
|
// peers use v2's recursive wire-schema fingerprint; monolith verification retains v1.
|
||||||
// is not pinned yet (the NDK's libc++ branch of `ProgramArtifacts.h`, inert until the integrator
|
|
||||||
// fills it in) the echo word is 0. That is SAFE FOR P5e AND NOT A GAP: the echo compares what
|
|
||||||
// this build wrote against what this build expects, so a round trip within one build is exact,
|
|
||||||
// and P5e is an in-process split where the writer and the reader ARE one build. It becomes a
|
|
||||||
// real check the day a client and a server built by different toolchains share a wire, which is
|
|
||||||
// P6's boundary and P6's problem - stated here so it cannot be discovered instead.
|
|
||||||
namespace MobileGL::MG_State::GLState {
|
namespace MobileGL::MG_State::GLState {
|
||||||
|
|
||||||
// Bumped whenever the byte format changes in a way a previous reader would misread. A
|
// Bumped whenever the byte format changes in a way a previous reader would misread. A
|
||||||
// reader that sees a different word REFUSES; it never tries to guess a layout.
|
// reader that sees a different word REFUSES; it never tries to guess a layout.
|
||||||
|
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||||
|
inline constexpr Uint32 kProgramArtifactsCodecVersion = 2;
|
||||||
|
// Derived from the actual VisitFields order/names, container element schemas and scalar
|
||||||
|
// representations. No native container size/offset is included. Also checked in Hello.
|
||||||
|
Uint64 ProgramArtifactsSchemaFingerprint();
|
||||||
|
#else
|
||||||
inline constexpr Uint32 kProgramArtifactsCodecVersion = 1;
|
inline constexpr Uint32 kProgramArtifactsCodecVersion = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Appends the archive to `out` (which is not cleared, so a caller may frame it). Never
|
// Appends the archive to `out` (which is not cleared, so a caller may frame it). Never
|
||||||
// fails: everything it walks is owned plain data.
|
// fails: everything it walks is owned plain data.
|
||||||
@@ -75,7 +76,7 @@ namespace MobileGL::MG_State::GLState {
|
|||||||
|
|
||||||
// Replaces `link` and `spirv` with what `bytes` describes. Returns false - with both
|
// Replaces `link` and `spirv` with what `bytes` describes. Returns false - with both
|
||||||
// outputs left in a defined, default state - for a truncated stream, a version mismatch, a
|
// outputs left in a defined, default state - for a truncated stream, a version mismatch, a
|
||||||
// struct-size mismatch, or trailing bytes the format does not account for. `link.program`
|
// wire-schema mismatch (native-size echo for local v1), or trailing bytes. `link.program`
|
||||||
// is always null on return.
|
// is always null on return.
|
||||||
Bool DecodeProgramArtifacts(const Uint8* bytes, SizeT size, LinkArtifacts& link,
|
Bool DecodeProgramArtifacts(const Uint8* bytes, SizeT size, LinkArtifacts& link,
|
||||||
SpirvArtifacts& spirv);
|
SpirvArtifacts& spirv);
|
||||||
|
|||||||
@@ -213,6 +213,17 @@ endif()
|
|||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(PipeCatalogueTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
gtest_discover_tests(PipeCatalogueTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||||
|
# This source scanner must inspect the configured checkout, including in out-of-tree builds.
|
||||||
|
# Apply the override after GoogleTest's deferred discovery, and only to this one test.
|
||||||
|
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/PipeCatalogueSourceRoot.cmake" CONTENT
|
||||||
|
"if(\"PipeCatalogue.FrontendNeverTakesAnApplierAddress\" IN_LIST PipeCatalogueTest_TESTS)
|
||||||
|
set_tests_properties(PipeCatalogue.FrontendNeverTakesAnApplierAddress PROPERTIES
|
||||||
|
WORKING_DIRECTORY [==[${MGL_ROOT}]==])
|
||||||
|
endif()
|
||||||
|
")
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/PipeCatalogueSourceRoot.cmake")
|
||||||
|
|
||||||
gtest_discover_tests(FieldOwnershipTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
gtest_discover_tests(FieldOwnershipTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||||
foreach(pipeTest ResourceEmitTest VertexInputEmitTest
|
foreach(pipeTest ResourceEmitTest VertexInputEmitTest
|
||||||
FramebufferEmitTest TextureEmitTest SamplerEmitTest ImageEmitTest
|
FramebufferEmitTest TextureEmitTest SamplerEmitTest ImageEmitTest
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user