mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-20 00:11:56 +09:00
[docs, tools] (Disaggregated): P5f close - record final host device and review evidence
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(P5fDevicePixels LANGUAGES C CXX)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
foreach(required MOBILEGL_SOURCE MOBILEGL_LIBRARY GTEST_SOURCE)
|
||||
if(NOT DEFINED ${required})
|
||||
message(FATAL_ERROR "Set -D${required}=...")
|
||||
endif()
|
||||
endforeach()
|
||||
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
|
||||
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory("${GTEST_SOURCE}" googletest EXCLUDE_FROM_ALL)
|
||||
add_library(DeviceMobileGL SHARED IMPORTED)
|
||||
set_target_properties(DeviceMobileGL PROPERTIES IMPORTED_LOCATION "${MOBILEGL_LIBRARY}")
|
||||
set(itest "${MOBILEGL_SOURCE}/MobileGL/MG_IntegrationTest")
|
||||
add_executable(P5fDevicePixels
|
||||
"${itest}/Main.cpp"
|
||||
"${itest}/Harness/HeadlessGL.cpp"
|
||||
"${itest}/Harness/SplitRuntimePeek.cpp"
|
||||
"${itest}/Scenarios/ClipDistanceScenario.cpp"
|
||||
"${itest}/Scenarios/CopyImageLayeredScenario.cpp"
|
||||
P5fPublicMipmapScenario.cpp)
|
||||
target_include_directories(P5fDevicePixels PRIVATE
|
||||
"${MOBILEGL_SOURCE}/include" "${MOBILEGL_SOURCE}/MobileGL" "${itest}")
|
||||
target_link_libraries(P5fDevicePixels PRIVATE DeviceMobileGL GTest::gtest)
|
||||
if(ANDROID)
|
||||
target_link_libraries(P5fDevicePixels PRIVATE android log mediandk)
|
||||
endif()
|
||||
@@ -0,0 +1,62 @@
|
||||
// Device-only P5f preparation. Public GL calls, no MobileGL internal symbols.
|
||||
#include "Harness/ScenarioFixture.h"
|
||||
#include <array>
|
||||
#ifdef GLAPI
|
||||
#undef GLAPI
|
||||
#endif
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glcorearb.h>
|
||||
#undef GL_GLEXT_PROTOTYPES
|
||||
|
||||
namespace MGITest {
|
||||
class P5fPublicMipmapScenario : public ScenarioTest {
|
||||
protected:
|
||||
void Check(bool gpuWritten) {
|
||||
if (!Ready()) return;
|
||||
GLuint texture = 0, fbo = 0;
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
std::array<GLubyte, 4 * 4 * 4> red{};
|
||||
for (std::size_t i = 0; i < red.size(); i += 4) {
|
||||
red[i] = 255;
|
||||
red[i + 3] = 255;
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, red.data());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
glGenFramebuffers(1, &fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
if (gpuWritten) {
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
|
||||
ASSERT_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GLenum{GL_FRAMEBUFFER_COMPLETE});
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
for (GLint level = 0; level <= 2; ++level) {
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, level);
|
||||
ASSERT_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GLenum{GL_FRAMEBUFFER_COMPLETE}) << level;
|
||||
std::array<GLubyte, 4> pixel{71, 72, 73, 74};
|
||||
glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel.data());
|
||||
EXPECT_EQ(pixel[0], gpuWritten ? 0 : 255) << "mip=" << level;
|
||||
EXPECT_EQ(pixel[1], gpuWritten ? 255 : 0) << "mip=" << level;
|
||||
EXPECT_EQ(pixel[2], 0) << "mip=" << level;
|
||||
EXPECT_EQ(pixel[3], 255) << "mip=" << level;
|
||||
}
|
||||
EXPECT_EQ(glGetError(), GLenum{GL_NO_ERROR});
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glDeleteFramebuffers(1, &fbo);
|
||||
glDeleteTextures(1, &texture);
|
||||
Gl().EndFrame();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(P5fPublicMipmapScenario, UploadedRgba8BaseGeneratesRedMipChain) { Check(false); }
|
||||
TEST_F(P5fPublicMipmapScenario, GpuWrittenBaseGeneratesGreenMipChainWithoutStaleCpuUpload) { Check(true); }
|
||||
} // namespace MGITest
|
||||
@@ -0,0 +1,26 @@
|
||||
# P5f Android public-pixel gate
|
||||
|
||||
Build `bash build_android.sh <Linux-source-tree> <full-source-SHA>` with NDK 27.3/API26/arm64.
|
||||
This produces one disaggregated/PUSH library and a runner using only public GL/EGL APIs.
|
||||
Original symbols stay in `library/` and `pixels/`; bundle copies have only debug data stripped.
|
||||
No FCL/APK configuration or private diagnostic export is required.
|
||||
|
||||
The coordinator reboots Redmi `2f7cbe2e` before each arm and waits for `sys.boot_completed=1`.
|
||||
Run `run_pixel_arm.sh <bundle> <new-output-dir> <DirectGLES|DirectVulkan> <monolith|inproc> <0|1>`
|
||||
from Windows Git Bash; the script itself never reboots. Set `ADB_BIN` if the Windows adb path differs.
|
||||
Then run `python3 verify_arm.py <output-dir>`.
|
||||
|
||||
Arms: GLES monolith, GLES inproc role0/role1; Magma monolith, Magma inproc role1/role0.
|
||||
All use the same bundle. Check six distinct boot IDs and equal host/device hashes.
|
||||
Performance is recorded only; this short pixel suite is not an MC/FPS benchmark.
|
||||
|
||||
11 selected cases cover clip distance, six layered image copies and two mipmap cases.
|
||||
The verifier requires the exact case set with no missing, extra, duplicate or unexecuted entries.
|
||||
It allows only Magma's two pre-existing per-distance-enable limitations, matched by
|
||||
exact case and skip reason. They are never counted as passes and must be identical across arms.
|
||||
Every other skip/failure is an error. Every actual stats window must have `rsp=0`; inproc must
|
||||
publish `vbs>0` and correct runtime/capability logs, monolith must keep `vbs=0`.
|
||||
|
||||
Android's normal integration target omits F1/Ct/DualBlock and private peek bridges. This runner
|
||||
therefore does not claim those host cases ran on Android. See `device-report.md` in the P5f notes
|
||||
for the completed six-arm run and immutable artifact hashes.
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build only. No adb or device operation. Run after the final integrated SHA exists.
|
||||
# Usage: bash build_android.sh /home/swung/w7/p5f-int <full-final-sha>
|
||||
set -euo pipefail
|
||||
TREE=$(realpath "${1:?source tree}")
|
||||
HEAD_SHA=${2:?full final SHA}
|
||||
[[ $HEAD_SHA =~ ^[0-9a-f]{40}$ ]] || exit 64
|
||||
[[ $(git -C "$TREE" rev-parse HEAD) == "$HEAD_SHA" ]] || { echo 'source head mismatch'; exit 65; }
|
||||
git -C "$TREE" diff --quiet --ignore-submodules=all HEAD -- MobileGL CMakeLists.txt
|
||||
PREP=$(cd "$(dirname "$0")" && pwd)
|
||||
OUT="$HOME/w7/p5f-android-${HEAD_SHA:0:12}"
|
||||
NDK="$HOME/android-sdk/ndk/27.3.13750724"
|
||||
GTEST="$TREE/build-split/_deps/googletest-src"
|
||||
[[ -f "$GTEST/CMakeLists.txt" && -f "$NDK/build/cmake/android.toolchain.cmake" ]] || exit 66
|
||||
mkdir -p "$OUT"
|
||||
COMMON=(-G Ninja "-DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake"
|
||||
-DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-26 -DANDROID_STL=c++_shared
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_POLICY_VERSION_MINIMUM=3.5
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON)
|
||||
cmake -S "$TREE" -B "$OUT/library" "${COMMON[@]}" \
|
||||
-DMOBILEGL_BUILD_TEST=OFF -DMOBILEGL_BUILD_BENCHMARK=OFF \
|
||||
-DMOBILEGL_BUILD_INTEGRATION_TEST=OFF -DMOBILEGL_BUILD_DISAGGREGATED=ON \
|
||||
-DMOBILEGL_BUILD_DISAGGREGATED_INPROC=ON -DMOBILEGL_PIPE_PUSH=ON \
|
||||
-DMOBILEGL_LOG_ACTIVE_LEVEL=MOBILEGL_LOG_LEVEL_INFO > "$OUT/configure-library.log" 2>&1
|
||||
grep -q -- '-DMOBILEGL_BUILD_DISAGGREGATED=1' "$OUT/library/compile_commands.json"
|
||||
grep -q -- '-DMOBILEGL_PIPE_PUSH=1' "$OUT/library/compile_commands.json"
|
||||
cmake --build "$OUT/library" --target MobileGL -j "${P5F_ANDROID_JOBS:-4}" > "$OUT/build-library.log" 2>&1
|
||||
cmake -S "$PREP" -B "$OUT/pixels" "${COMMON[@]}" \
|
||||
"-DMOBILEGL_SOURCE=$TREE" "-DMOBILEGL_LIBRARY=$OUT/library/libMobileGL.so" \
|
||||
"-DGTEST_SOURCE=$GTEST" > "$OUT/configure-pixels.log" 2>&1
|
||||
cmake --build "$OUT/pixels" --target P5fDevicePixels -j "${P5F_ANDROID_JOBS:-4}" > "$OUT/build-pixels.log" 2>&1
|
||||
mkdir -p "$OUT/bundle"
|
||||
cp "$OUT/library/libMobileGL.so" "$OUT/pixels/P5fDevicePixels" "$OUT/bundle/"
|
||||
cp "$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so" "$OUT/bundle/"
|
||||
# Keep unstripped originals in library/pixels; deploy only a debug-stripped copy.
|
||||
"$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip" --strip-debug \
|
||||
"$OUT/bundle/libMobileGL.so" "$OUT/bundle/P5fDevicePixels"
|
||||
printf '%s\n' "$HEAD_SHA" > "$OUT/bundle/source-head.txt"
|
||||
file "$OUT/bundle/P5fDevicePixels" "$OUT/bundle/libMobileGL.so" > "$OUT/bundle/elf-identity.txt"
|
||||
(cd "$OUT/bundle" && sha256sum ./*.so ./P5fDevicePixels > sha256.txt)
|
||||
echo "Prepared $OUT/bundle (not deployed)"
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
# Windows Git Bash. Root coordinator runs this only AFTER its own clean reboot.
|
||||
# Does not reboot, install an APK, alter clocks, clear logcat, or launch FCL.
|
||||
# Usage: bash run_pixel_arm.sh <bundle-dir> <new-output-dir> DirectGLES|DirectVulkan inproc|monolith 0|1
|
||||
set -euo pipefail
|
||||
export MSYS_NO_PATHCONV=1 MSYS2_ARG_CONV_EXCL='*'
|
||||
BUNDLE=${1:?bundle}; OUT=${2:?new output}; BACKEND=${3:?backend}; TRANSPORT=${4:?transport}; ROLE=${5:?role}
|
||||
[[ $BACKEND == DirectGLES || $BACKEND == DirectVulkan ]] || exit 64
|
||||
[[ $TRANSPORT == inproc || $TRANSPORT == monolith ]] || exit 64
|
||||
[[ $ROLE == 0 || $ROLE == 1 ]] || exit 64
|
||||
[[ ! -e $OUT ]] || { echo 'Output exists; do not overwrite an arm'; exit 65; }
|
||||
HEAD_SHA=$(tr -d '\r\n' < "$BUNDLE/source-head.txt")
|
||||
[[ $HEAD_SHA =~ ^[0-9a-f]{40}$ ]] || exit 66
|
||||
(cd "$BUNDLE" && sha256sum -c sha256.txt)
|
||||
ADB_BIN=${ADB_BIN:-/c/Users/geekerwan/AppData/Local/Android/Sdk/platform-tools/adb.exe}
|
||||
A=("$ADB_BIN" -s 2f7cbe2e)
|
||||
[[ $("${A[@]}" get-state | tr -d '\r') == device ]] || exit 67
|
||||
mkdir -p "$OUT"
|
||||
cp "$BUNDLE/source-head.txt" "$BUNDLE/sha256.txt" "$OUT/"
|
||||
"${A[@]}" shell cat /proc/sys/kernel/random/boot_id > "$OUT/boot-id.txt"
|
||||
REMOTE=/data/local/tmp/p5f-${HEAD_SHA:0:12}
|
||||
TAG=$BACKEND-$TRANSPORT-r$ROLE-$(date +%s)
|
||||
"${A[@]}" shell "mkdir -p $REMOTE"
|
||||
for f in libMobileGL.so libc++_shared.so P5fDevicePixels; do
|
||||
"${A[@]}" push "$BUNDLE/$f" "$REMOTE/$f" > "$OUT/push-$f.log" 2>&1
|
||||
done
|
||||
"${A[@]}" shell "chmod 755 $REMOTE/P5fDevicePixels; cd $REMOTE; sha256sum libMobileGL.so libc++_shared.so P5fDevicePixels" > "$OUT/device-sha256.txt"
|
||||
FILTER='ClipDistanceScenario.AnEnabledClipDistanceRemovesTheNegativeHalf:ClipDistanceScenario.ADisabledClipDistanceRemovesNothing:ClipDistanceScenario.TheEnablesAreIndependentPerDistance:CopyImageLayeredScenario.*:P5fPublicMipmapScenario.*'
|
||||
printf '%s\n' "backend=$BACKEND transport=$TRANSPORT role=$ROLE" > "$OUT/arm.txt"
|
||||
rc=0
|
||||
"${A[@]}" shell "cd $REMOTE; env LD_LIBRARY_PATH=$REMOTE MOBILEGL_BACKEND_TYPE=$BACKEND MOBILEGL_TRANSPORT=$TRANSPORT MOBILEGL_IPC_ROLE_SPLIT_STATE=$ROLE MOBILEGL_IPC_STRICT_ERRORS=1 MOBILEGL_IPC_RUN_AHEAD=1 MOBILEGL_IPC_STAGE_MB=256 MOBILEGL_ITEST_REQUIRE_GPU=1 MOBILEGL_ITEST_REQUIRE_HARDWARE_GPU=1 MOBILEGL_PIPE_STATS=1 MOBILEGL_PIPE_STATS_PERIOD=1 MOBILEGL_LOG_FILE_PATH=$REMOTE/$TAG.library.log ./P5fDevicePixels --gtest_filter='$FILTER' --gtest_output=xml:$REMOTE/$TAG.xml >$REMOTE/$TAG.stdout.txt 2>&1" || rc=$?
|
||||
printf '%s\n' "$rc" > "$OUT/process-exit.txt"
|
||||
for f in library.log xml stdout.txt; do
|
||||
"${A[@]}" pull "$REMOTE/$TAG.$f" "$OUT/$f" > "$OUT/pull-$f.log" 2>&1 || true
|
||||
done
|
||||
"${A[@]}" logcat -d -b crash -v time > "$OUT/crash-buffer.txt"
|
||||
echo "Arm completed with process rc=$rc. Verify XML, library log, boot id, and hashes in $OUT."
|
||||
exit "$rc"
|
||||
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only verdict for the prepared public-pixel arm; never invokes adb."""
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
d = pathlib.Path(sys.argv[1])
|
||||
def hashes(path):
|
||||
return {name.removeprefix('./'): digest for digest, name in
|
||||
(line.split(maxsplit=1) for line in path.read_text().splitlines() if line.strip())}
|
||||
assert hashes(d / 'sha256.txt') == hashes(d / 'device-sha256.txt'), 'host/device artifact hash mismatch'
|
||||
arm = dict(re.findall(r'(backend|transport|role)=(\S+)', (d / 'arm.txt').read_text()))
|
||||
assert (d / 'process-exit.txt').read_text().strip() == '0', 'process failed'
|
||||
cases = ET.parse(d / 'xml').getroot().findall('.//testcase')
|
||||
expected_cases = {
|
||||
'ClipDistanceScenario.AnEnabledClipDistanceRemovesTheNegativeHalf',
|
||||
'ClipDistanceScenario.ADisabledClipDistanceRemovesNothing',
|
||||
'ClipDistanceScenario.TheEnablesAreIndependentPerDistance',
|
||||
'CopyImageLayeredScenario.ArrayToArrayCopiesEverySlice',
|
||||
'CopyImageLayeredScenario.ArrayToArrayHonoursDifferentLayerOffsets',
|
||||
'CopyImageLayeredScenario.VolumeToVolumeHonoursNonZeroZ',
|
||||
'CopyImageLayeredScenario.VolumeToVolumeAtNonZeroMipLevel',
|
||||
'CopyImageLayeredScenario.ArrayToVolumeCopiesEverySlice',
|
||||
'CopyImageLayeredScenario.VolumeToArrayCopiesEverySlice',
|
||||
'P5fPublicMipmapScenario.UploadedRgba8BaseGeneratesRedMipChain',
|
||||
'P5fPublicMipmapScenario.GpuWrittenBaseGeneratesGreenMipChainWithoutStaleCpuUpload',
|
||||
}
|
||||
case_names = [c.get('classname', '') + '.' + c.get('name', '') for c in cases]
|
||||
assert len(cases) == len(expected_cases), f'expected 11 selected cases, got {len(cases)}'
|
||||
assert len(case_names) == len(set(case_names)), ('duplicate test cases', case_names)
|
||||
assert set(case_names) == expected_cases, (
|
||||
'selected case set mismatch',
|
||||
{'missing': sorted(expected_cases - set(case_names)),
|
||||
'extra': sorted(set(case_names) - expected_cases)})
|
||||
# The two pre-existing Vulkan per-distance-enable limitations are explicit,
|
||||
# matched by exact case and reason, and never counted as executed passes.
|
||||
allowed_skips = {
|
||||
'ClipDistanceScenario.ADisabledClipDistanceRemovesNothing': 'clips by a DISABLED gl_ClipDistance',
|
||||
'ClipDistanceScenario.TheEnablesAreIndependentPerDistance': 'clips by every declared gl_ClipDistance regardless of the enables',
|
||||
} if arm['backend'] == 'DirectVulkan' else {}
|
||||
skipped = []
|
||||
for c in cases:
|
||||
name = c.get('classname', '') + '.' + c.get('name', '')
|
||||
assert c.get('status') == 'run', ('case did not execute', name, c.attrib)
|
||||
assert c.find('failure') is None and c.find('error') is None, c.attrib
|
||||
skip = c.find('skipped')
|
||||
if skip is not None:
|
||||
assert c.get('result') == 'skipped', ('invalid executed-skip result', name, c.attrib)
|
||||
text = ' '.join(skip.itertext()) + ' ' + skip.get('message', '')
|
||||
assert name in allowed_skips and allowed_skips[name] in text, ('unexpected skip', c.attrib, text)
|
||||
skipped.append(name)
|
||||
else:
|
||||
assert c.get('result') == 'completed', ('case did not complete', name, c.attrib)
|
||||
stdout = (d / 'stdout.txt').read_text(errors='replace')
|
||||
log = (d / 'library.log').read_text(errors='replace')
|
||||
assert f'backend={arm["backend"]}' in stdout
|
||||
assert 'AImageReader window' in stdout, 'not the Android window harness'
|
||||
assert not re.search(r'Fatal\{|SIGSEGV|SIGABRT|AddressSanitizer', stdout + log)
|
||||
stats = [line for line in log.splitlines() if 'MGPipe stats:' in line and re.search(r'\bframes=\d+', line)]
|
||||
assert stats, 'no actual stats windows'
|
||||
assert all(re.search(r'\brsp=0(?:\s|$)', line) for line in stats), 'nonzero/missing rsp'
|
||||
assert any(int(re.search(r'\bframes=(\d+)', line)[1]) > 0 for line in stats), 'no present frames'
|
||||
vbs = [int(re.search(r'\bvbs=(\d+)', line)[1]) for line in stats]
|
||||
if arm['transport'] == 'inproc':
|
||||
assert any(v > 0 for v in vbs), 'no applied verb boundaries; transport not proven'
|
||||
assert re.search(r'Config: IPC .*strict=1 .*role-split-state=' + arm['role'] + r'\b', log)
|
||||
expected = 'run-ahead ARMED' if arm['backend'] == 'DirectGLES' else 'run-ahead requested, server does not publish'
|
||||
assert expected in log, 'missing runtime capability evidence'
|
||||
else:
|
||||
assert all(v == 0 for v in vbs), 'monolith control has applied verb boundaries'
|
||||
print(f'PASS {arm}: {len(cases)-len(skipped)} passed, {len(skipped)} named legacy feature skips, {len(stats)} stats windows, rsp=0, vbs={sum(vbs)}')
|
||||
for name in skipped: print(' preserved limitation:', name)
|
||||
Reference in New Issue
Block a user