From 49a8644d136b7ae80a465bd2f50050e7e7d6fc57 Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Sat, 29 Aug 2026 11:28:43 +0200 Subject: [PATCH] Temporary: patch V36 soft Retail decode --- .github/workflows/patch-v36-retail-soft.yml | 108 ++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/patch-v36-retail-soft.yml diff --git a/.github/workflows/patch-v36-retail-soft.yml b/.github/workflows/patch-v36-retail-soft.yml new file mode 100644 index 0000000..1e72fce --- /dev/null +++ b/.github/workflows/patch-v36-retail-soft.yml @@ -0,0 +1,108 @@ +name: Patch V36 Retail Soft + +on: + push: + branches: + - test/v36-retail-jfa-soft + +permissions: + contents: write + +jobs: + patch: + if: github.event.head_commit.message != 'V36: soft Retail-style JFA decode' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: test/v36-retail-jfa-soft + - name: Apply conservative V36 decode patch + shell: python + run: | + from pathlib import Path + p = Path('src/outline/d3d9_hook.zig') + s = p.read_text() + + old = '''/// V32 POLISH: hard 3px outline, no feather. +/// c0 = (screen_width, screen_height, radius_px=3, 0). +/// The shader squares radius_px and emits a binary 0/1 edge alpha. +const jfa_decode_src = + "ps_3_0\\n" ++ + "def c1, 0.0, 1.0, -0.002, 0.0\\n" ++ + "dcl_2d s0\\n" ++ + "dcl_2d s1\\n" ++ + "dcl_texcoord0 v0\\n" ++ + // Nearest seed and pixel-space squared distance. + "texld r0, v0, s0\\n" ++ + "sub r1.xy, v0.xy, r0.xy\\n" ++ + "mul r1.xy, r1.xy, c0.xy\\n" ++ + "dp2add r1.z, r1, r1, c0.w\\n" ++ + // Seed colour. + "texld r2, r0, s1\\n" ++ + // Hard radius test: dist² < radius² => alpha 1, otherwise 0. + "mov r3.x, c0.z\\n" ++ + "mul r3.x, r3.x, r3.x\\n" ++ + "sub r3.y, r1.z, r3.x\\n" ++ + "mov r6.w, c1.y\\n" ++ + "cmp r4.w, r3.y, c0.w, r6.w\\n" ++ + // Do not paint over the model interior. + "texld r5, v0, s1\\n" ++ + "add r5.x, r5.a, c1.z\\n" ++ + "cmp r4.w, r5.x, c0.w, r4.w\\n" ++ + "mov r4.xyz, r2.xyz\\n" ++ + "mov oC0, r4\\n";''' + + new = '''/// V36 RETAIL-SOFT: keep the proven V34 JFA, soften only final decode. +/// c0 = (screen_width, screen_height, core_radius_px, halo_radius_px). +/// Uses the same two texture reads as V34: no 17-tap full-screen morphology. +const jfa_decode_src = + "ps_3_0\\n" ++ + // c1 = zero, halo alpha, core alpha, -interior threshold + "def c1, 0.0, 0.22, 0.82, -0.002\\n" ++ + // pale Retail-like yellow/green target colour + "def c2, 1.0, 0.95, 0.58, 0.0\\n" ++ + "dcl_2d s0\\n" ++ + "dcl_2d s1\\n" ++ + "dcl_texcoord0 v0\\n" ++ + // Nearest JFA seed and pixel-space squared distance. + "texld r0, v0, s0\\n" ++ + "sub r1.xy, v0.xy, r0.xy\\n" ++ + "mul r1.xy, r1.xy, c0.xy\\n" ++ + "dp2add r1.z, r1, r1, c1.x\\n" ++ + // Squared core and halo radii. + "mul r3.x, c0.z, c0.z\\n" ++ + "mul r3.y, c0.w, c0.w\\n" ++ + // Outside halo => 0; inside halo => 0.22. + "sub r4.x, r1.z, r3.y\\n" ++ + "cmp r6.w, r4.x, c1.x, c1.y\\n" ++ + // Inside core => 0.82; otherwise keep halo alpha. + "sub r4.x, r1.z, r3.x\\n" ++ + "cmp r6.w, r4.x, r6.w, c1.z\\n" ++ + // Never paint over the original model interior. + "texld r5, v0, s1\\n" ++ + "add r5.x, r5.a, c1.w\\n" ++ + "cmp r6.w, r5.x, c1.x, r6.w\\n" ++ + "mov r6.xyz, c2.xyz\\n" ++ + "mov oC0, r6\\n";''' + + if old not in s: + raise SystemExit('Expected V34 decode block not found') + s = s.replace(old, new) + + old_cpu = ''' // V34: hard 3px edge unchanged; JFA seed precision is now full-float. + c0 = [4]f32{ fw, fh, 3.0, 0.0 };''' + new_cpu = ''' // V36: thin 1.5px core plus a subtle 3px halo. + c0 = [4]f32{ fw, fh, 1.5, 3.0 };''' + if old_cpu not in s: + raise SystemExit('Expected V34 decode constants not found') + s = s.replace(old_cpu, new_cpu) + p.write_text(s) + - name: Commit patch + shell: bash + run: | + set -euo pipefail + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add src/outline/d3d9_hook.zig + git commit -m "V36: soft Retail-style JFA decode" + git push origin HEAD:test/v36-retail-jfa-soft