Add runtime-toggleable spatial anti-aliasing to PRK.Client on HDR foundation
Outcome Implement high-quality, reasonably inexpensive non-temporal anti-aliasing in PRK.Client, with enable/disable during gameplay without restarting. HDR is merged into develop (#2652). AA branch/worktree is now based on origin/develop8db746362, which has the same code tree as the original HDR basef2f734123. Keep AA isolated on feature/client-spatial-antialiasing in /home/mathias/Projects/worktrees/engines-client-aa. Design recommendation from initial source inspection SMAA 1x with High preset as initial quality target; no T2x, camera jitter, motion vectors or frame history. Reference iryoku/smaa SMAA.hlsl provides GLSL support and MIT notice, three passes, lookup textures, diagonal/corner handling and explicit color-space contract. Pin exact upstream revision and matching Area/Search assets and preserve notices before reuse. SMAA is not a newly published algorithm but remains a suitable high-quality spatial choice. Compare CMAA2 only if measured SMAA cost is unacceptable; Intel reference is DX11/12 HLSL compute with indirect dispatch/buffer complexity. Do not promise GPU timing from other implementations. Integration evidence HDR composite_fragment.glsl calls DisplaySceneSample, which performs scene-referred immersion then SceneToDisplay. RendererVulkan.RecordCompositePass draws the tone-mapped world followed by depth-tested display overlays and UI. Insert AA after display transform and before overlays, leaving HDR reflection/refraction/AO/picking unchanged. Preserve the existing direct composite path when Off. Reuse DisplaySceneSample rather than duplicate immersion/tone mapping; materialize display color only for AA. Edge detection uses encoded display RGB without sRGB decoding; neighborhood blending uses display-linear RGB. Validate exactly-one final transfer encoding and avoid pre-tone-map filtering or encoded-space final blends. Decide intermediate format/views from capability, precision and bandwidth measurements rather than introducing mismatched mutable views. Edge and blend buffers must be cleared each invocation; reference wording 'temporal render targets' refers to scratch buffers here, not frame history. Runtime contract Graphics options and saved preference expose at least Off/SMAA High. Reuse GraphicsPreferences/GraphicsOptionsModel and Engine/Renderer live-setting patterns, GPU maintenance gate, GpuConstructionScope and retirement. Prepare all replacement resources before committing settings; failure leaves old rendering and saved state intact with a useful refusal. Respect frames-in-flight ownership, viewport resize, minimize/restore, surface-format changes and shutdown. Off skips all AA passes; document whether scratch resources are retained for fast toggles or released safely. Runtime enable may require a bounded preparation hitch, not restart. Do not rebuild unrelated world material variants. Acceptance - No temporal accumulation, reprojection or jitter; UI/cursor/nameplates remain outside AA and keep depth occlusion/color contracts. - Repeated live Off/On changes work with 1-3 frame slots and resizing; unsupported formats/allocation failures do not damage renderer state. - Reference lookup assets, shader packaging, stage compilation and attribution verified. GPU tests cover actual edge/weight/resolve stages, uniform/no-edge images, horizontal/vertical/diagonal/corner patterns, chromatic contrast as appropriate, subpixel/transparent edges and finite output. Test color-space boundaries and immutable source/target hazards with Vulkan synchronization validation. - Preferences/options apply/cancel/revert persistence and running-state behavior verified. Existing graphics/client regressions pass. - Profile incremental AA pass cost and target memory at 1440p/4K with matched settings; set budget based on measurements, not historical vendor timings. Report per-frame scratch footprint and per-slot multiplication. - User-owned scene checks cover geometry silhouettes, foliage, thin rails, bright effects, water and UI. Spatial-only limitations (unresolved subpixel/specular shimmer and no recovery of missing samples) remain explicit. No autonomous game GUI launches assumed. Progress Implemented and committed in /home/mathias/Projects/worktrees/engines-client-aa on feature/client-spatial-antialiasing, based on origin/develop8db746362 after HDR's merge. Commit75674df27 (feature: Add runtime-toggleable spatial anti-aliasing) contains only29 session files and is pushed with origin upstream. User authorized pushing the SMAA-default follow-up. Commitfb00a7af5 (feature: Enable SMAA High by default) contains the three follow-up files, is pushed to origin/feature/client-spatial-antialiasing, and working tree is clean. PR#2655 description reflects the new default and updated CPU validation. Subsequent CI failure investigation reproduced the exact four SMAA failures in a node:22-bookworm container with .NET10 and llvmpipe LLVM15: client CI omitted glslc, so ShaderCompiler selected the bundled binary with missing libSPIRV-Tools-opt.so. Local fix adds Debian glslc to the client CI dependency list and a glslc --version preflight. After installing the compiler, Bookworm's older validation layer exposed an unused vertex binding0 declaration for the vertex-buffer-free fullscreen shader. GraphicsPipeline now emits zero vertex bindings/null binding pointer when there are no vertex attributes; existing attribute-backed pipelines are unchanged. User authorized pushing both fixes. Committed695bb7819 (fix: Support headless SMAA tests in client CI), containing only .github/workflows/engines-dotnet.yml and PRK.Client/PRK.GraphicsEngine/GraphicsPipeline.cs; pushed to origin/feature/client-spatial-antialiasing and included in PR#2655. Working tree clean; no force push. No source-tree differences between original HDR base and merged develop; no rebase/conflicts required. All29 AA modified/untracked files were archived and byte-verified unchanged before/after update at /home/mathias/.local/share/prk-aa-backups/pre-develop-update-20261013-211852. HDR worktree not edited. Post-update build/affected CPU tests pass33 and headless Vulkan tests pass19; logs at AA .dev-data/aa-develop-{cpu,headless}.log. PR preparation subsequently authorized by user; AA is now committed and pushed without published-history rewrite. Vendored shader/license line endings and shader trailing whitespace were normalized during preparation; no algorithm changes. Separate uncommitted HDR tuning is not part of merged develop and is not copied into AA. User now requests SMAA as default. Follow-up changes set AntialiasingQualityConfiguration.Default to SmaaHigh for unset preferences, startup features, presets and Restore Defaults; explicitly saved Off and environment overrides remain honored. Added a red-green default/saved-Off/Restore Defaults regression and made enable/refusal/override tests start from explicit Off. Full non-install CPU suite passes3679 with52skipped; git diff --check is clean. The three-file follow-up is committed/pushed asfb00a7af5 and included in PR#2655. Explicitly saved Off stays Off; new/unset preferences and Restore Defaults use SmaaHigh. Graphics options expose Off/SMAA High with Apply during gameplay and machine persistence/PRK_ANTIALIASING override. SMAA 1x High uses luma edges and pinned upstream GLSL/reference Area/Search assets at71c806a838bdd7d517df19192a20f0c61b3ca29d, embedded lookup bytes and exported MIT notice. Luma-only detection can miss equal-luminance chromatic edges. World HDR/immersion/display transform is reused into a mutable SRGB8 SDR target; UNORM view supplies encoded edge samples, SRGB view supplies linear neighborhood filtering. RG8 edges and RGBA8 weights are cleared every invocation. Per-slot targets, capability fallback, transactional AA/lighting preparation, resize/surface-format recreation, teardown and inclusive profiler child spans are wired. Off releases AA resources after GPU idle and bypasses the extra passes; enables can pause for preparation/cold shader compilation. Existing texture loader now supports explicit 2D views while retaining array-view defaults; real GPU validation reproduced the wrong-array-view error before this fix. Verified validation Exact ./run-client-dev.sh --build-only and Release client build pass with zero warnings/errors;198 production shader artifacts compile. Complete CPU suite excluding RequiresInstall passes3678 with52skipped; final affected-area rerun after startup enum validation/transition naming passes33. Nineteen headless Vulkan tests pass onRX9070/RADV with synchronization validation, including four AA tests: uniform/axis images on3slots, diagonal coverage against independent16x16 per-pixel supersampling with strong improvement for white and dark contrast, known-weight decode-before-filter/exactly-one encode, scratch clearing after patterned frames, recreation with1–3slots and injected lookup-upload construction rollback. Existing texture/material lifetime, image transfer, render-target and timestamp tests also pass. Broader native suite attempt has10 RendererLifetimeTests failures at missing PRK_RENDERER_ASSETS/display prerequisite, before window creation; these are NOT passed lifecycle gates. No GUI launched or game-install files touched. A fresh PR-preparation review/validation attempt was aborted when the user requested a separate review later; no additional validation or review approval is inferred from it. Performance foundation Opt-in native synthetic diagonal-stripe benchmark:3slots,6warmup pairs/16measured Off-On pairs, synchronization validation enabled.1440p median Off0.11190ms/SMAA0.46708ms, delta0.35518ms;4K Off0.24428ms/SMAA1.01496ms, delta0.77068ms. Includes display transform/AA only; excludes upload/readback/UI/gameplay/presentation and is not gameplay acceptance. Raw scratch storage10bytes/pixel/slot:110592000bytes at1440p/3slots,248832000bytes(~237.3MiB) at4K/3slots, plus small expanded lookup textures/alignment/allocator overhead. Logs/results in AA .dev-data/{aa-benchmark.json,aa-cpu-full.log,aa-cpu-final.log,aa-headless-final.log,aa-gpu-tests-final.log,aa-shaders.log,aa-dev-build.log,aa-release-build.log}. Repository-native Antialiasing/README.md records contracts, provenance, storage and test commands. Remaining acceptance User-owned gameplay Off→SMAA High→Off, repeated toggles and resize/minimize/restore, image-quality review (foliage/thin rails/bright effects/water/UI), matched gameplay GPU/memory measurements and other-platform coverage remain open. Native headless tests do not approve the actual window/settings/render loop. No release approval or claim of completed acceptance. Opened PR #2655, feature: Add runtime-toggleable spatial anti-aliasing: https://git.project-rk.com/prk/engines/pulls/2655 . Head feature/client-spatial-antialiasing, base develop. No duplicate open PR found. PR includes completed automated validation, synthetic benchmark scope and remaining live-window/gameplay/platform caveats. Separate code review deferred at user's request; opening PR does not complete acceptance. CI reproduction now passes the exact Release headless command in Bookworm/llvmpipe with synchronization validation:17passed/1opt-in benchmark skipped, zero failures and warnings-as-errors build. Hardware Debug rerun also passes all19 headless tests onRX9070/RADV. Logs/container definitions are local AA .dev-data/aa-ci-repro/{red.log,green.log,green-final.log,hardware.log}; initial compiler failure and subsequent vertex-binding failure are preserved as red evidence. No game GUI/system packages changed. Software-rendering success is not window/gameplay acceptance. Sources https://github.com/iryoku/smaa/blob/master/SMAA.hlsl https://github.com/GameTechDev/CMAA2 https://www.intel.com/content/www/us/en/developer/articles/technical/conservative-morphological-anti-aliasing-20.html
Checklist
2 of 4 complete- Integrate pinned SMAA 1x shaders/lookups after HDR display transform and before overlays, with verified color-space contracts.
- Pass shader packaging/compilation, AA GPU correctness and synchronization tests, and relevant client regressions.
- Measure incremental GPU cost/memory and obtain user visual acceptance at representative resolutions/scenes.
- Verify live Off/On settings, saved preferences, frame-slot lifetimes, resize and failure rollback without restarting.
- Area
- Project Rubi-Ka
- Project
- engines
- Kind
- Feature
- Task ID
tsk_259zrjhf5s- Updated