Reload host on shader frame contract changes

This commit is contained in:
Meta Vens 2026-05-08 20:36:25 +01:00
commit 897fff3e0b
3 changed files with 40 additions and 3 deletions

View file

@ -71,7 +71,9 @@ Current frame order:
The shader far distance is frame-derived, not a fixed constant. C# sends the
distance from the camera to the Grid origin plus the Grid radius, which matches
the circular Grid fade boundary and avoids wasting raymarch work past the
visible field.
visible field. Changes to the `AquariumFrame` shader constant buffer are host
contract changes; `dev-watch.ps1` fingerprints that block and restarts the host
instead of treating it as ordinary shader hot reload.
The target currently stores height in `.r` only. The next useful expansion is to
store packed gradients in `.g/.b` during the Grid pass so the raymarcher can use

View file

@ -16,6 +16,7 @@ $liveProjectPath = Join-Path $repoRoot "src\Aquarium.Engine.Live\Aquarium.Engine
$watchLogPath = Join-Path $repoRoot "artifacts\dev-reload\watch.log"
$liveSlotRoot = Join-Path $repoRoot "artifacts\dev-reload\live-slots"
$liveReloadPointerPath = Join-Path $repoRoot "artifacts\dev-reload\live-current.txt"
$shaderPath = Join-Path $repoRoot "src\Aquarium.Engine\Render\Shaders\Aquarium.hlsl"
New-Item -ItemType Directory -Force -Path (Split-Path $watchLogPath) | Out-Null
New-Item -ItemType Directory -Force -Path $liveSlotRoot | Out-Null
@ -84,8 +85,39 @@ function Get-Fingerprint($files) {
}
}
function Get-Hash([string]$text) {
$bytes = [System.Text.Encoding]::UTF8.GetBytes($text)
$sha = [System.Security.Cryptography.SHA256]::Create()
try {
$hashBytes = $sha.ComputeHash($bytes)
return -join ($hashBytes | ForEach-Object { $_.ToString("x2") })
}
finally {
$sha.Dispose()
}
}
function Get-AquariumFrameContractText {
if (-not (Test-Path $shaderPath)) {
return ""
}
$text = Get-Content -Raw -LiteralPath $shaderPath
$match = [regex]::Match(
$text,
"cbuffer\s+AquariumFrame\s*:\s*register\(b0\)\s*\{(?<body>.*?)\};",
[System.Text.RegularExpressions.RegexOptions]::Singleline)
if (-not $match.Success) {
return ""
}
return $match.Value
}
function Get-SourceFingerprint {
Get-Fingerprint (Get-SourceFiles)
$fileFingerprint = Get-Fingerprint (Get-SourceFiles)
$contractFingerprint = Get-Hash (Get-AquariumFrameContractText)
Get-Hash "$fileFingerprint`nAquariumFrame:$contractFingerprint"
}
function Get-LiveFingerprint {
@ -93,7 +125,9 @@ function Get-LiveFingerprint {
}
function Get-RestartFingerprint {
Get-Fingerprint (Get-RestartFiles)
$fileFingerprint = Get-Fingerprint (Get-RestartFiles)
$contractFingerprint = Get-Hash (Get-AquariumFrameContractText)
Get-Hash "$fileFingerprint`nAquariumFrame:$contractFingerprint"
}
function Wait-StableFingerprints {

View file

@ -4,3 +4,4 @@
{"topic":"grid_derivative_linework","summary":"Ported the Aetheria UI isoline idea into the Aquarium Grid shader: height contours and gradient-angle field lines now derive from the deferred Grid height field, and Cartesian Gridlines use fwidth-based masks so line width stays stable in pixels across zoom.","files":["src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","docs/hlsl-renderer.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4"],"ts":"2026-05-08"}
{"topic":"dev_reload_visible_headless_split","summary":"Fixed dev-reload so headless smoke runs use separate PID state and logs from the visible dev window, preventing headless verification from stopping the active window. Added -Reopen to relaunch the last visible slot without rebuilding.","files":["scripts/dev-reload.ps1","README.md","state/evidence.jsonl"],"verification":[".\\scripts\\dev-reload.ps1 -Reopen",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4","visible Aquarium PID remained running after headless smoke"],"ts":"2026-05-08"}
{"topic":"grid_far_distance","summary":"Replaced the shader fixed raymarch far distance with a per-frame value equal to camera distance from the Grid origin plus Grid radius, matching the circular Grid fade boundary.","files":["src/Aquarium.Engine/Render/D3D11Renderer.cs","src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","docs/hlsl-renderer.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4"],"ts":"2026-05-08"}
{"topic":"watcher_renderer_contract_reload","summary":"dev-watch now fingerprints the AquariumFrame cbuffer in Aquarium.hlsl as host contract input. Ordinary shader edits can still hot reload, but cbuffer layout changes trigger a host reload so C# frame constants and shader reads stay in sync.","files":["scripts/dev-watch.ps1","docs/hlsl-renderer.md","state/evidence.jsonl"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -RetainSlots 4",".\\scripts\\dev-watch.ps1 -NoInitialLaunch -Once"],"ts":"2026-05-08"}