garage44.eu/jeroen/cartopolis

logclone: git clone https://garage44.eu/jeroen/cartopolis.git

.. /.forgejo/workflows/gpu-shots.yml

raw

# Captures on a real GPU, because the containers cannot judge one.
#
# Every other lane here runs on the VPS, where "the GPU" is Mesa lavapipe. That
# is honest about geometry, placement, culling and visibility and says nothing
# about colour, exposure, bloom or lighting
# (`docs/notes/headless-shots-software-renderer.md`) — which is most of what a
# water surface, a sky or a tonemapping curve *is*. So every judgement about how
# the scene looks has had to end with "check it on a workstation", and mostly did
# not get checked.
#
# The `deck-gpu` runner is a Steam Deck (AMD Van Gogh, RADV). It is the machine
# `docs/notes/render-performance-survey.md` settled the cloud-shell question on,
# and this lane is the same machine answering the other half: what the frame
# actually looks like.
#
# Manual only. It is not a gate and should not become one — a screenshot
# diff has no threshold anybody can defend, and this exists to be *looked at*.
name: gpu shots

on:
  workflow_dispatch:
    inputs:
      manifest:
        description: "Preset manifest to run (repo-relative)"
        required: false
        default: "docs/water-shots.toml"
      only:
        description: "Comma-separated preset names, or empty for all"
        required: false
        default: ""
      size:
        description: "Capture size, WxH"
        required: false
        default: "1600x900"

jobs:
  shots:
    name: capture on the deck
    runs-on: deck-gpu
    steps:
      - uses: actions/checkout@v4
        with:
          # The font, app icon, star catalog and map fixtures are
          # `include_bytes!`-ed, so without the smudge filter this builds
          # 130-byte LFS pointers into the binary. Same reason every other lane
          # sets it.
          lfs: true

      - name: Which adapter answered
        run: |
          vulkaninfo --summary 2>/dev/null | head -30 || true
          echo "--- and it must not be a software one ---"
          if vulkaninfo --summary 2>/dev/null | grep -qi "llvmpipe\|lavapipe"; then
            echo "::error::deck-gpu resolved to a software rasteriser; this lane has no reason to exist then."
            exit 1
          fi

      - name: Capture
        env:
          WGPU_BACKEND: vulkan
        run: |
          set -o pipefail
          ONLY=""
          if [ -n "${{ inputs.only }}" ]; then ONLY="--only ${{ inputs.only }}"; fi
          # Emptied, not just created: the runner is a persistent machine, and a
          # previous run's captures left in here are uploaded by the collect step
          # below as if this run had produced them.
          rm -rf /tmp/gpu-shots && mkdir -p /tmp/gpu-shots
          cargo run -p cartopolis -- \
            --shots "${{ inputs.manifest }}" $ONLY \
            --size "${{ inputs.size }}" \
            --csv /tmp/gpu-shots/metrics.csv \
            --dump-state /tmp/gpu-shots/state.json 2>&1 | tail -60

      - name: Collect
        if: always()
        run: |
          # A manifest's `out_dir` is resolved against the manifest's own
          # directory, so `docs/water-shots.toml` writes into `docs/gpu`.
          #
          # Only that directory. An earlier version also swept `docs/img`, which
          # is where `docs/shots.toml` writes — and is also where six README
          # images are *checked in*, so a run whose capture step had already
          # failed uploaded those six and looked like it had worked.
          cp docs/gpu/*.png /tmp/gpu-shots/ 2>/dev/null || true
          ls -la /tmp/gpu-shots/
          if ! ls /tmp/gpu-shots/*.png >/dev/null 2>&1; then
            echo "::error::no captures were written — read the Capture step, not this artifact."
          fi

      - uses: actions/upload-artifact@v3
        if: always()
        with:
          name: gpu-shots
          path: /tmp/gpu-shots
          # The metrics and the state dump are written even when the capture
          # fails, and they are half the reason to look.
          if-no-files-found: warn