feat(webgl): Add GAL native test harness for visual regression testing
Add a standalone test application that compiles KiCad's actual OPENGL_GAL against system wxWidgets to generate baseline screenshots for comparing native OpenGL rendering against WebGL rendering in the browser. Architecture: - Compiles 18 KiCad GAL source files from the kicad submodule - Uses template-based private member accessor (safer than #define private public) - Generates shader C++ files from GLSL (10 shader pairs for SMAA AA) - Minimal stubs for KiCad dependencies (PGM_BASE, ADVANCED_CFG, etc.) Test coverage: - 11 scenarios testing ~19% of GAL API - basic-lines, line-widths, circles, arcs, rectangles, polygons - alpha-blending, transforms, grid-cursor, segments, complex-scene Key insights documented: - GAL uses world-to-screen transformation requiring 1:1 pixel mapping - FBO reading required for clean screenshots on macOS - Layer depth needed for proper z-ordering in complex scenes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
5147917ea7
commit
490f531521
46 changed files with 4075 additions and 0 deletions
71
scripts/build-gal-native-test.sh
Executable file
71
scripts/build-gal-native-test.sh
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Build script for the native GAL test harness
|
||||
#
|
||||
# This builds a standalone test application that uses KiCad's actual OPENGL_GAL
|
||||
# to render test scenarios and generate baseline screenshots.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
TEST_DIR="$PROJECT_ROOT/tests/gal-regression/native"
|
||||
BUILD_DIR="$TEST_DIR/build"
|
||||
LOG_FILE="$PROJECT_ROOT/tests/logs/gal-native-build.log"
|
||||
|
||||
# Create log directory
|
||||
mkdir -p "$(dirname "$LOG_FILE")"
|
||||
|
||||
echo "Building GAL Native Test..."
|
||||
echo " Test dir: $TEST_DIR"
|
||||
echo " Build dir: $BUILD_DIR"
|
||||
echo " Log file: $LOG_FILE"
|
||||
|
||||
# Create build directory
|
||||
mkdir -p "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
# Generate shader headers if needed
|
||||
if [ ! -d "$TEST_DIR/generated" ] || [ -z "$(ls -A $TEST_DIR/generated 2>/dev/null)" ]; then
|
||||
echo "Generating shader headers..."
|
||||
python3 "$TEST_DIR/generate_shaders.py" >> "$LOG_FILE" 2>&1
|
||||
fi
|
||||
|
||||
# Configure
|
||||
echo "Running CMake..."
|
||||
cmake .. >> "$LOG_FILE" 2>&1
|
||||
CMAKE_STATUS=$?
|
||||
|
||||
if [ $CMAKE_STATUS -ne 0 ]; then
|
||||
echo "CMake configuration failed! Check $LOG_FILE for details."
|
||||
echo ""
|
||||
echo "Last 50 lines of log:"
|
||||
tail -50 "$LOG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build
|
||||
echo "Building..."
|
||||
make -j$(sysctl -n hw.ncpu 2>/dev/null || echo 4) >> "$LOG_FILE" 2>&1
|
||||
BUILD_STATUS=$?
|
||||
|
||||
if [ $BUILD_STATUS -ne 0 ]; then
|
||||
echo "Build failed! Check $LOG_FILE for details."
|
||||
echo ""
|
||||
echo "Last 100 lines of log:"
|
||||
tail -100 "$LOG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Build successful!"
|
||||
echo "Executable: $BUILD_DIR/gal_native_test"
|
||||
echo ""
|
||||
echo "To run:"
|
||||
echo " $BUILD_DIR/gal_native_test"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --output <dir> Output directory for baseline PNGs"
|
||||
echo " --width <w> Canvas width (default: 800)"
|
||||
echo " --height <h> Canvas height (default: 600)"
|
||||
echo " --show Show window (default: headless)"
|
||||
Loading…
Reference in a new issue