mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 04:08:32 +09:00
[Fix] (Retrace): bundle and select signed ANGLE variants
This commit is contained in:
@@ -39,7 +39,7 @@ crop_width optional compare crop width
|
||||
crop_height optional compare crop height
|
||||
use_angle optional boolean; DirectGLES uses packaged ANGLE when true
|
||||
use_pbuffer optional boolean; DirectGLES uses an offscreen EGL pbuffer when true
|
||||
angle_library_dir optional directory containing libEGL_angle.so and libGLESv2_angle.so; defaults to the APK native library directory
|
||||
angle_variant required with use_angle; signed packaged ANGLE short hash (`ec889e6ea831` or `90a62123d794`)
|
||||
```
|
||||
|
||||
Implementation notes:
|
||||
@@ -51,7 +51,7 @@ Implementation notes:
|
||||
- `DirectGLES` and `DirectVulkan` replay on the Activity `SurfaceView` by default. DirectGLES can still use the old offscreen EGL pbuffer path by passing `use_pbuffer=true`.
|
||||
- Golden comparison is implemented in native C++ with libpng RGBA decode and SSIM validation. The Java Activity only passes arguments and displays the native result, so the replay/compare core is not tied to Android UI or Bitmap APIs and can be ported to Linux.
|
||||
- The plugin profile still excludes `libtrace_replay_runner.so`; normal plugin APK behavior is preserved.
|
||||
- Set `MOBILEGL_USE_ANGLE=1` when running `trace-replay-ci.sh` to pass `use_angle=true` for DirectGLES. Set `MOBILEGL_RETRACE_USE_PBUFFER=1` or pass `--use-pbuffer` to keep DirectGLES offscreen. The APK must include `libEGL_angle.so` and `libGLESv2_angle.so` under its x86_64 native libraries. The native runner prepends the ANGLE directory to `LD_LIBRARY_PATH` before loading MobileGL.
|
||||
- Set `MOBILEGL_USE_ANGLE=1` and `MOBILEGL_TRACE_ANGLE_VARIANT=<short-hash>` when running `trace-replay-ci.sh` for DirectGLES. The trace APK contains both allowlisted ANGLE builds with short-hash filenames and SONAMEs; MobileGL resolves its signed native library directory and loads the selected pair by absolute path. Set `MOBILEGL_RETRACE_USE_PBUFFER=1` or pass `--use-pbuffer` to keep DirectGLES offscreen.
|
||||
|
||||
Example core-profile trace smoke command for a debug trace APK:
|
||||
|
||||
@@ -68,6 +68,8 @@ adb shell am start -a top.mobilegl.plugin.TRACE_REPLAY \
|
||||
--es output_dir /data/user/0/top.mobilegl.plugin.espryt.trace/files/trace-replay/output \
|
||||
--es diff_path /data/user/0/top.mobilegl.plugin.espryt.trace/files/trace-replay/output/app-diff.png \
|
||||
--es backend DirectGLES \
|
||||
--ez use_angle true \
|
||||
--es angle_variant ec889e6ea831 \
|
||||
--el target_call 31249 \
|
||||
--es ssim_threshold 0.99
|
||||
adb shell run-as top.mobilegl.plugin.espryt.trace cat files/trace-replay/output/result.json
|
||||
|
||||
@@ -89,20 +89,6 @@ bool UseAngleForRequest(const Request& request) {
|
||||
return value != nullptr && strcmp(value, "1") == 0;
|
||||
}
|
||||
|
||||
void PrependLibraryPath(const std::string& directory) {
|
||||
if (directory.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char* current = getenv("LD_LIBRARY_PATH");
|
||||
std::string value = directory;
|
||||
if (current != nullptr && current[0] != '\0') {
|
||||
value += ":";
|
||||
value += current;
|
||||
}
|
||||
setenv("LD_LIBRARY_PATH", value.c_str(), 1);
|
||||
}
|
||||
|
||||
bool EnsureDirectory(const std::string& path) {
|
||||
if (path.empty()) {
|
||||
return false;
|
||||
@@ -153,11 +139,10 @@ bool LoadMobileGL(const Request& request, std::string& error) {
|
||||
}
|
||||
if (UseAngleForRequest(request)) {
|
||||
setenv("MOBILEGL_USE_ANGLE", "1", 1);
|
||||
if (!request.angleLibraryDir.empty()) {
|
||||
PrependLibraryPath(request.angleLibraryDir);
|
||||
}
|
||||
setenv("MOBILEGL_TRACE_ANGLE_VARIANT", request.angleVariant.c_str(), 1);
|
||||
} else {
|
||||
unsetenv("MOBILEGL_USE_ANGLE");
|
||||
unsetenv("MOBILEGL_TRACE_ANGLE_VARIANT");
|
||||
}
|
||||
if (request.avoidAngleLlvmpipeSamplerMipmapMinFilter) {
|
||||
setenv("MOBILEGL_AVOID_SAMPLER_MIPMAP_MIN_FILTER", "1", 1);
|
||||
@@ -755,7 +740,7 @@ bool WriteResultJson(const Request& request, const Result& result) {
|
||||
file << " \"actualPath\": \"" << JsonEscape(result.actualPath) << "\",\n";
|
||||
file << " \"diffPath\": \"" << JsonEscape(result.diffPath) << "\",\n";
|
||||
file << " \"backend\": \"" << JsonEscape(request.backend) << "\",\n";
|
||||
file << " \"angleLibraryDir\": \"" << JsonEscape(request.angleLibraryDir) << "\",\n";
|
||||
file << " \"angleVariant\": \"" << JsonEscape(request.angleVariant) << "\",\n";
|
||||
file << " \"targetFrame\": " << request.targetFrame << ",\n";
|
||||
file << " \"targetCall\": " << request.targetCall << ",\n";
|
||||
file << " \"width\": " << request.width << ",\n";
|
||||
|
||||
@@ -23,7 +23,7 @@ struct Request {
|
||||
std::string diffPath;
|
||||
std::string backend;
|
||||
std::string mobileGlLibrary = "libMobileGL.so";
|
||||
std::string angleLibraryDir;
|
||||
std::string angleVariant;
|
||||
int targetFrame = -1;
|
||||
long long targetCall = -1;
|
||||
int width = 0;
|
||||
|
||||
@@ -98,7 +98,7 @@ Java_top_mobilegl_plugin_trace_TraceReplayActivity_nativeRunTraceReplay(JNIEnv*
|
||||
jint cropY,
|
||||
jint cropWidth,
|
||||
jint cropHeight,
|
||||
jstring angleLibraryDir,
|
||||
jstring angleVariant,
|
||||
jboolean useAngle,
|
||||
jboolean usePbuffer,
|
||||
jboolean avoidAngleLlvmpipeSamplerMipmapMinFilter) {
|
||||
@@ -112,7 +112,7 @@ Java_top_mobilegl_plugin_trace_TraceReplayActivity_nativeRunTraceReplay(JNIEnv*
|
||||
request.outputDir = ToString(env, outputDir);
|
||||
request.diffPath = ToString(env, diffPath);
|
||||
request.backend = ToString(env, backend);
|
||||
request.angleLibraryDir = ToString(env, angleLibraryDir);
|
||||
request.angleVariant = ToString(env, angleVariant);
|
||||
request.targetFrame = targetFrame;
|
||||
request.targetCall = targetCall;
|
||||
request.width = width;
|
||||
|
||||
+7
-8
@@ -44,7 +44,6 @@ public final class TraceReplayActivity extends Activity {
|
||||
request = TraceReplayRequest.from(
|
||||
intent,
|
||||
getFilesDir(),
|
||||
getApplicationInfo().nativeLibraryDir,
|
||||
getString(top.mobilegl.plugin.R.string.mobilegl_default_backend)
|
||||
);
|
||||
statusView = new TextView(this);
|
||||
@@ -111,7 +110,7 @@ public final class TraceReplayActivity extends Activity {
|
||||
request.cropY,
|
||||
request.cropWidth,
|
||||
request.cropHeight,
|
||||
request.angleLibraryDir,
|
||||
request.angleVariant,
|
||||
request.useAngle,
|
||||
request.usePbuffer,
|
||||
request.avoidAngleLlvmpipeSamplerMipmapMinFilter
|
||||
@@ -141,7 +140,7 @@ public final class TraceReplayActivity extends Activity {
|
||||
int cropY,
|
||||
int cropWidth,
|
||||
int cropHeight,
|
||||
String angleLibraryDir,
|
||||
String angleVariant,
|
||||
boolean useAngle,
|
||||
boolean usePbuffer,
|
||||
boolean avoidAngleLlvmpipeSamplerMipmapMinFilter
|
||||
@@ -163,7 +162,7 @@ public final class TraceReplayActivity extends Activity {
|
||||
final int cropY;
|
||||
final int cropWidth;
|
||||
final int cropHeight;
|
||||
final String angleLibraryDir;
|
||||
final String angleVariant;
|
||||
final boolean useAngle;
|
||||
final boolean usePbuffer;
|
||||
final boolean avoidAngleLlvmpipeSamplerMipmapMinFilter;
|
||||
@@ -184,7 +183,7 @@ public final class TraceReplayActivity extends Activity {
|
||||
int cropY,
|
||||
int cropWidth,
|
||||
int cropHeight,
|
||||
String angleLibraryDir,
|
||||
String angleVariant,
|
||||
boolean useAngle,
|
||||
boolean usePbuffer,
|
||||
boolean avoidAngleLlvmpipeSamplerMipmapMinFilter
|
||||
@@ -204,13 +203,13 @@ public final class TraceReplayActivity extends Activity {
|
||||
this.cropY = cropY;
|
||||
this.cropWidth = cropWidth;
|
||||
this.cropHeight = cropHeight;
|
||||
this.angleLibraryDir = angleLibraryDir;
|
||||
this.angleVariant = angleVariant;
|
||||
this.useAngle = useAngle;
|
||||
this.usePbuffer = usePbuffer;
|
||||
this.avoidAngleLlvmpipeSamplerMipmapMinFilter = avoidAngleLlvmpipeSamplerMipmapMinFilter;
|
||||
}
|
||||
|
||||
static TraceReplayRequest from(Intent intent, File filesDir, String nativeLibraryDir, String defaultBackend) {
|
||||
static TraceReplayRequest from(Intent intent, File filesDir, String defaultBackend) {
|
||||
String outputDir = readString(intent, "output_dir", new File(filesDir, "trace-replay").getAbsolutePath());
|
||||
String diffPath = readString(intent, "diff_path", "");
|
||||
return new TraceReplayRequest(
|
||||
@@ -229,7 +228,7 @@ public final class TraceReplayActivity extends Activity {
|
||||
intent.getIntExtra("crop_y", 0),
|
||||
intent.getIntExtra("crop_width", 0),
|
||||
intent.getIntExtra("crop_height", 0),
|
||||
readString(intent, "angle_library_dir", nativeLibraryDir),
|
||||
readString(intent, "angle_variant", ""),
|
||||
intent.getBooleanExtra("use_angle", false),
|
||||
intent.getBooleanExtra("use_pbuffer", false),
|
||||
intent.getBooleanExtra("avoid_angle_llvmpipe_sampler_mipmap_min_filter", false)
|
||||
|
||||
@@ -18,7 +18,6 @@ Usage:
|
||||
--trace-file FILE_IN_ARCHIVE \
|
||||
--golden FILE \
|
||||
[--alternate-golden FILE] \
|
||||
[--angle-library-dir DIR] \
|
||||
--target-call N \
|
||||
--width N \
|
||||
--height N \
|
||||
@@ -33,6 +32,8 @@ Usage:
|
||||
|
||||
Set MOBILEGL_USE_ANGLE=1 to run DirectGLES replay with packaged ANGLE
|
||||
instead of the device system GLES driver.
|
||||
Set MOBILEGL_TRACE_ANGLE_VARIANT to the packaged ANGLE short hash used by
|
||||
DirectGLES replay.
|
||||
Set MOBILEGL_RETRACE_USE_PBUFFER=1 or pass --use-pbuffer to run DirectGLES
|
||||
against an offscreen EGL pbuffer instead of the Activity surface.
|
||||
Pass --avoid-angle-llvmpipe-sampler-mipmap-min-filter for DirectGLES traces that
|
||||
@@ -83,7 +84,6 @@ trace_archive=""
|
||||
trace_file=""
|
||||
golden_path=""
|
||||
alternate_golden_path=""
|
||||
angle_library_dir=""
|
||||
target_call=""
|
||||
width=""
|
||||
height=""
|
||||
@@ -116,7 +116,6 @@ while [ "$#" -gt 0 ]; do
|
||||
shift 2
|
||||
fi
|
||||
;;
|
||||
--angle-library-dir) angle_library_dir="$(next_arg "$@")"; shift 2 ;;
|
||||
--target-call) target_call="$(next_arg "$@")"; shift 2 ;;
|
||||
--width) width="$(next_arg "$@")"; shift 2 ;;
|
||||
--height) height="$(next_arg "$@")"; shift 2 ;;
|
||||
@@ -161,11 +160,6 @@ test -f "${golden_path}" || die "golden image does not exist: ${golden_path}"
|
||||
if [ -n "${alternate_golden_path}" ]; then
|
||||
test -f "${alternate_golden_path}" || die "alternate golden image does not exist: ${alternate_golden_path}"
|
||||
fi
|
||||
if [ -n "${angle_library_dir}" ]; then
|
||||
test -f "${angle_library_dir}/libEGL_angle.so" || die "ANGLE override is missing libEGL_angle.so: ${angle_library_dir}"
|
||||
test -f "${angle_library_dir}/libGLESv2_angle.so" || die "ANGLE override is missing libGLESv2_angle.so: ${angle_library_dir}"
|
||||
fi
|
||||
|
||||
safe_case="$(printf '%s' "${case_name}" | sed 's/[^A-Za-z0-9._-]/_/g')"
|
||||
app_dir="/data/user/0/${package_name}/files/trace-replay"
|
||||
|
||||
@@ -203,18 +197,10 @@ prepare_fixture() {
|
||||
if [ -n "${alternate_golden_path}" ]; then
|
||||
adb_device_path push "$(host_path_for_adb "${alternate_golden_path}")" "/data/local/tmp/mobilegl-${safe_case}.alternate-golden.png"
|
||||
fi
|
||||
if [ -n "${angle_library_dir}" ]; then
|
||||
adb_device_path push "$(host_path_for_adb "${angle_library_dir}/libEGL_angle.so")" "/data/local/tmp/mobilegl-${safe_case}.libEGL_angle.so"
|
||||
adb_device_path push "$(host_path_for_adb "${angle_library_dir}/libGLESv2_angle.so")" "/data/local/tmp/mobilegl-${safe_case}.libGLESv2_angle.so"
|
||||
fi
|
||||
adb_device_path shell chmod 0644 "/data/local/tmp/mobilegl-${safe_case}.trace" "/data/local/tmp/mobilegl-${safe_case}.golden.png"
|
||||
if [ -n "${alternate_golden_path}" ]; then
|
||||
adb_device_path shell chmod 0644 "/data/local/tmp/mobilegl-${safe_case}.alternate-golden.png"
|
||||
fi
|
||||
if [ -n "${angle_library_dir}" ]; then
|
||||
adb_device_path shell chmod 0644 "/data/local/tmp/mobilegl-${safe_case}.libEGL_angle.so" \
|
||||
"/data/local/tmp/mobilegl-${safe_case}.libGLESv2_angle.so"
|
||||
fi
|
||||
}
|
||||
|
||||
copy_fixture_to_app() {
|
||||
@@ -229,13 +215,6 @@ copy_fixture_to_app() {
|
||||
if [ -n "${alternate_golden_path}" ]; then
|
||||
adb_device_path shell run-as "${package_name}" cp "${alternate_golden_tmp}" "${app_dir}/input/alternate-golden.png"
|
||||
fi
|
||||
if [ -n "${angle_library_dir}" ]; then
|
||||
adb_device_path shell run-as "${package_name}" mkdir -p "${app_dir}/angle"
|
||||
adb_device_path shell run-as "${package_name}" cp "/data/local/tmp/mobilegl-${safe_case}.libEGL_angle.so" \
|
||||
"${app_dir}/angle/libEGL_angle.so"
|
||||
adb_device_path shell run-as "${package_name}" cp "/data/local/tmp/mobilegl-${safe_case}.libGLESv2_angle.so" \
|
||||
"${app_dir}/angle/libGLESv2_angle.so"
|
||||
fi
|
||||
}
|
||||
|
||||
run_retrace() {
|
||||
@@ -247,6 +226,7 @@ run_retrace() {
|
||||
fi
|
||||
if [ "${MOBILEGL_USE_ANGLE:-}" = "1" ] && [ "${backend}" = "DirectGLES" ]; then
|
||||
use_angle=1
|
||||
test -n "${MOBILEGL_TRACE_ANGLE_VARIANT:-}" || die "MOBILEGL_TRACE_ANGLE_VARIANT is required for DirectGLES ANGLE replay"
|
||||
fi
|
||||
if [ "${MOBILEGL_RETRACE_USE_PBUFFER:-}" = "1" ] && [ "${backend}" = "DirectGLES" ]; then
|
||||
use_pbuffer=1
|
||||
@@ -266,9 +246,7 @@ run_retrace() {
|
||||
fi
|
||||
if [ "${use_angle}" -eq 1 ]; then
|
||||
set -- "$@" --ez use_angle true
|
||||
if [ -n "${angle_library_dir}" ]; then
|
||||
set -- "$@" --es angle_library_dir "${app_dir}/angle"
|
||||
fi
|
||||
set -- "$@" --es angle_variant "${MOBILEGL_TRACE_ANGLE_VARIANT}"
|
||||
fi
|
||||
if [ "${use_pbuffer}" -eq 1 ] && [ "${backend}" = "DirectGLES" ]; then
|
||||
set -- "$@" --ez use_pbuffer true
|
||||
|
||||
Reference in New Issue
Block a user