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)"
|
||||
62
scripts/build-wxwidgets-native.sh
Executable file
62
scripts/build-wxwidgets-native.sh
Executable file
|
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Build wxWidgets for native macOS (not WASM)
|
||||
# This is used for the native GAL test harness
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
WX_SRC="$PROJECT_ROOT/wxwidgets"
|
||||
BUILD_DIR="$PROJECT_ROOT/build-native/wxwidgets"
|
||||
INSTALL_DIR="$PROJECT_ROOT/build-native/wxwidgets-install"
|
||||
LOG_FILE="$PROJECT_ROOT/tests/logs/wxwidgets-native-build.log"
|
||||
|
||||
mkdir -p "$(dirname "$LOG_FILE")"
|
||||
|
||||
echo "Building wxWidgets for native macOS..."
|
||||
echo " Source: $WX_SRC"
|
||||
echo " Build: $BUILD_DIR"
|
||||
echo " Install: $INSTALL_DIR"
|
||||
echo " Log: $LOG_FILE"
|
||||
|
||||
# Create build directory
|
||||
mkdir -p "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
# Set up paths for homebrew libraries
|
||||
export PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig:/opt/homebrew/opt/libpng/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
export CPPFLAGS="-I/opt/homebrew/include $CPPFLAGS"
|
||||
export LDFLAGS="-L/opt/homebrew/lib $LDFLAGS"
|
||||
|
||||
# Configure wxWidgets for native macOS with OpenGL support
|
||||
echo "Configuring..."
|
||||
"$WX_SRC/configure" \
|
||||
--prefix="$INSTALL_DIR" \
|
||||
--disable-shared \
|
||||
--with-opengl \
|
||||
--with-osx_cocoa \
|
||||
--disable-webview \
|
||||
--disable-mediactrl \
|
||||
--with-libpng=sys \
|
||||
--with-libjpeg=sys \
|
||||
--with-libtiff=sys \
|
||||
--with-zlib=sys \
|
||||
>> "$LOG_FILE" 2>&1
|
||||
|
||||
# Build
|
||||
echo "Building (this may take a while)..."
|
||||
make -j$(sysctl -n hw.ncpu 2>/dev/null || echo 4) >> "$LOG_FILE" 2>&1
|
||||
|
||||
# Install
|
||||
echo "Installing..."
|
||||
make install >> "$LOG_FILE" 2>&1
|
||||
|
||||
echo ""
|
||||
echo "wxWidgets native build complete!"
|
||||
echo "wx-config: $INSTALL_DIR/bin/wx-config"
|
||||
echo ""
|
||||
echo "To use in CMake:"
|
||||
echo " set(wxWidgets_CONFIG_EXECUTABLE $INSTALL_DIR/bin/wx-config)"
|
||||
echo " find_package(wxWidgets REQUIRED COMPONENTS core base gl)"
|
||||
Loading…
Reference in a new issue