Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/scripts/ck_sky_sharpness_test.sh # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / scripts / ck_sky_sharpness_test.sh` 136 lines ยท 6438 bytes Raw Blame History 1 #!/bin/sh 2 # Hosted production-renderer native-pixel contract and adversarial controls. 3 # Usage: sh scripts/ck_sky_sharpness_test.sh [OUTDIR] 4 # Historical red: sh scripts/ck_sky_sharpness_test.sh --baseline REV OUTDIR 5 set -eu 6 cd "$(dirname "$0")/.." 7 K=native/kernel 8 CC=${HOSTCC:-cc} 9 BASE= 10 if [ "${1:-}" = --baseline ]; then BASE=$2; shift 2; fi 11 OUT=${1:-target/native-kernel-sky-sharpness} 12 mkdir -p "$OUT" 13 OUT=$(realpath "$OUT") 14 WORK=$(mktemp -d "${TMPDIR:-/tmp}/ck_sky_sharpness.XXXXXX") 15 trap 'rm -rf "$WORK"' EXIT HUP INT TERM 16 mkdir -p "$WORK/$K/ui/tests" 17 # Only scoped render sources; no service, GPU, image build or full suite. 18 cp "$K/ui/paint.c" "$K/ui/paint.h" "$K/ui/allen_font.c" "$K/ui/allen_font.h" \ 19 "$K/ui/sky_data.c" "$K/ui/sky_data.h" "$WORK/$K/ui/" 20 if [ -n "$BASE" ]; then 21 git archive "$BASE" "$K/ui/night.c" "$K/ui/night.h" "$K/ui/sky_real.c" "$K/ui/sky_real.h" | tar -x -C "$WORK" 22 else 23 cp "$K/ui/night.c" "$K/ui/night.h" "$K/ui/sky_real.c" "$K/ui/sky_real.h" "$WORK/$K/ui/" 24 fi 25 cp "$K/ui/tests/sky_sharpness_test.c" "$WORK/$K/ui/tests/" 26 build() { 27 "$CC" -std=gnu11 -O2 -Wall -Wextra -Werror ${FLAGS:-} -o "$WORK/test" \ 28 "$WORK/$K/ui/tests/sky_sharpness_test.c" "$WORK/$K/ui/night.c" \ 29 "$WORK/$K/ui/sky_data.c" "$WORK/$K/ui/paint.c" "$WORK/$K/ui/allen_font.c" 30 } 31 if [ -n "$BASE" ]; then 32 FLAGS=-DCK_SKY_BASELINE 33 build 34 status=0 35 "$WORK/test" "$OUT" > "$OUT/baseline.log" || status=$? 36 cat "$OUT/baseline.log" 37 exit "$status" 38 fi 39 build 40 status=0 41 "$WORK/test" "$OUT" > "$OUT/after.log" || status=$? 42 cat "$OUT/after.log" 43 [ "$status" = 0 ] || exit "$status" 44 cp "$WORK/$K/ui/sky_real.c" "$WORK/sky.clean" 45 cp "$WORK/$K/ui/night.c" "$WORK/night.clean" 46 # Mutate copies, never the checkout. Historical cubic lobes and quarter 47 # screen grid are taken verbatim from the rejected pinned source. Each 48 # independent defect must be rejected, as must suppressing the point layer. 49 # init-fog and view-fog reintroduce the diffuse Milky Way into the UI sky in 50 # ck_night_init and ck_night_view; each must fail its own clear-sky assertion. 51 for control in static-bloom dynamic-bloom quarter-grid invisible init-fog view-fog; do 52 cp "$WORK/sky.clean" "$WORK/$K/ui/sky_real.c" 53 cp "$WORK/night.clean" "$WORK/$K/ui/night.c" 54 python3 - "$WORK/$K/ui" "$control" <<'PY' 55 from pathlib import Path 56 import subprocess, sys 57 root, control = Path(sys.argv[1]), sys.argv[2] 58 sky = (root/'sky_real.c').read_text() 59 night = (root/'night.c').read_text() 60 pin = '`735c40bff7270cc4d2a88f663ba4b663986b468c`' 61 def historical(name): 62 return subprocess.check_output(['git','show',pin+':native/kernel/ui/'+name], text=True) 63 def section(text, start, end): 64 return text[text.index(start):text.index(end)] 65 def replace_once(text, before, after): 66 assert text.count(before) == 1, before 67 return text.replace(before,after) 68 if control == 'static-bloom': 69 old = historical('sky_real.c') 70 lobe = section(old, 'static void light_add(', 'static uint32_t srgb_of(') 71 sky = replace_once(sky, 'static void point_add(', lobe+'static void point_add(') 72 sky = replace_once(sky, ' point_add(cv, &all, x16, y16, core, col);', 73 ' point_add(cv, &all, x16, y16, core, col);\n' 74 ' uint32_t k = 512;\n' 75 ' int32_t r0 = (int32_t)(k * 3 / 40);\n' 76 ' if (r0 < 12) r0 = 12;\n' 77 ' light_add(cv, x16, y16, r0 * 4, (core * 15) >> 7, col);\n' 78 ' light_add(cv, x16, y16, r0 * 12, (core * 5) >> 7, col);') 79 elif control == 'dynamic-bloom': 80 night = replace_once(night, ' ck_sky_twinkle(out, r, s, a);', 81 ' int32_t r0 = (int32_t)(n->k * 3 / 40);\n' 82 ' if (r0 < 12) r0 = 12;\n' 83 ' ck_glow(out, r, s->x, s->y, r0 * 4, 0xffffff, a);') 84 elif control == 'quarter-grid': 85 oldsky, oldnight = historical('sky_real.c'), historical('night.c') 86 grid = section(oldsky, 'void ck_sky_milkyway_q(', '/* ---- stars ---- */') 87 upscale = section(oldnight, 'static void scale_up(', '/* ---- coming out of the dark ---- */') 88 replacement = grid+upscale+'''void ck_sky_draw_milkyway(ck_canvas *cv, int32_t cx, int32_t cy, const ck_sky_view *v) 89 { 90 int32_t qw = cv->w/4+2, qh = cv->h/4+2; 91 uint16_t *q = malloc((size_t)qw*qh*3*sizeof *q); 92 if (!q) abort(); 93 ck_sky_milkyway_q(q,qw,qh,cv->w,cx,cy,v); 94 ck_night n = {.w=cv->w,.h=cv->h,.sky=cv->px}; 95 scale_up(&n,q,qw); 96 free(q); 97 } 98 99 ''' 100 before = section(sky,'void ck_sky_draw_milkyway(', '/* ---- stars ---- */') 101 sky = replace_once(sky,before,replacement) 102 elif control == 'invisible': 103 sky = replace_once(sky,' point_add(cv, &all, x16, y16, core, col);', 104 ' point_add(cv, &all, x16, y16, core * 0, col);') 105 sky = replace_once(sky,' point_add(cv, clip, s->x, s->y, (uint64_t)s->peak * amount >> 8, s->col);', 106 ' point_add(cv, clip, s->x, s->y, (uint64_t)s->peak * amount * 0, s->col);') 107 elif control == 'init-fog': 108 night = replace_once(night,' ck_sky_draw_stars(&cv, cx, cy, &n->view,', 109 ' ck_sky_draw_milkyway(&cv, cx, cy, &n->view);\n' 110 ' ck_sky_draw_stars(&cv, cx, cy, &n->view,') 111 elif control == 'view-fog': 112 night = replace_once(night,' ck_sky_draw_stars(&cv, n->cx, n->cy, &n->view,', 113 ' ck_sky_draw_milkyway(&cv, n->cx, n->cy, &n->view);\n' 114 ' ck_sky_draw_stars(&cv, n->cx, n->cy, &n->view,') 115 (root/'sky_real.c').write_text(sky) 116 (root/'night.c').write_text(night) 117 PY 118 build 119 status=0 120 "$WORK/test" > "$OUT/control-$control.log" || status=$? 121 [ "$status" = 1 ] || { echo "SKY_SHARPNESS: FAIL control $control returned $status, expected rejection"; exit 1; } 122 # The fog controls are rejected by their own assertion only. 123 case $control in 124 init-fog) own="clear sky after init"; other="clear sky after view change" ;; 125 view-fog) own="clear sky after view change"; other="clear sky after init" ;; 126 *) own=; other= ;; 127 esac 128 if [ -n "$own" ]; then 129 grep -q "^FAIL $own " "$OUT/control-$control.log" && 130 grep -q "^PASS $other " "$OUT/control-$control.log" && 131 grep -q "^PASS direct milkyway render " "$OUT/control-$control.log" || { 132 echo "SKY_SHARPNESS: FAIL control $control was not rejected by its own assertion ($own)"; exit 1; } 133 fi 134 echo "PASS rejected control: $control (details $OUT/control-$control.log)" 135 done 136 echo "AIENOS_SKY_SHARPNESS: PASS"