Skip to content

Fix RT resource lifetimes and shader payload UB - #26

Merged
ComfyFluffy merged 8 commits into
mainfrom
combine-lifetime-shader-fixes
Jul 24, 2026
Merged

Fix RT resource lifetimes and shader payload UB#26
ComfyFluffy merged 8 commits into
mainfrom
combine-lifetime-shader-fixes

Conversation

@ComfyFluffy

@ComfyFluffy ComfyFluffy commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace frame-age lifetime assumptions with exact graphics-timeline completion tokens
  • use one opaque GraphicsUse / TrackedGraphicsUse model for publication, reusable rings, and retirement
  • retire terrain, light-grid, entity, and overlay scratch resources through the GPU executor's deferred-destruction queue
  • fix the ray-tracing payload ABI mismatch and keep shadow traversal state local
  • keep shader RNG samples strictly in [0, 1)

Lifetime model

  • RtComposite reserves one graphics-use token before recording RT work and signals it after the world-overlay command buffer, the frame's final TLAS consumer
  • asynchronously published terrain and light-grid builds retain their build-timeline dependency until the next graphics frame attaches it
  • reusable TLAS, entity, push-data, and descriptor-set slots wait for their exact prior use before mutation, then mark the current token
  • entity frame lists, geometry tables, persistent BLAS slots, rigid-reuse owners, and block-entity caches track their exact last use
  • replaced or evicted published resources retire through the shared graphics-timeline queue; never-published build results use the unpublished retirement path
  • render-thread assertions guard token reservation, marking, waiting, and tracked-owner retirement

Ring depths (4 or 6) are now latency/capacity choices rather than correctness horizons.

Shader fixes

  • use the common Payload structure in raygen, any-hit, and miss stages reachable by the trace
  • replace module-static shadow visibility state with a local, fully initialized shadow payload
  • return explicit VisibilityResult { transmittance, waterHitT } values from shadow traversal
  • derive random floats from the exactly representable high 24 bits so conversion cannot round to 1.0

Simplification

  • remove frame-count deferred-release lists from terrain/entity/overlay paths covered by the graphics timeline
  • batch overlay scratch destruction once per frame
  • share completed-timeline snapshots across related reuse checks
  • remove redundant TLAS ring-slot/use plumbing and stale frame-horizon comments

Non-goals

  • DLSS feature release and persistent pipeline/output recreation keep their existing device-idle synchronization because their consumers are not all represented by the RT graphics token
  • this does not add RtBuffer generation poisoning or raw-handle use-after-free instrumentation

Testing

  • .\gradlew.bat check compileShaders

@ComfyFluffy
ComfyFluffy merged commit f8714d7 into main Jul 24, 2026
3 checks passed
@ComfyFluffy
ComfyFluffy deleted the combine-lifetime-shader-fixes branch July 31, 2026 16:24
xysgottaken2 added a commit to xysgottaken2/Caustica that referenced this pull request Sep 2, 2026
Cherry-picks upstream ddf36c0 "Prepare 0.1.1 release", the only commit
on ComfyFluffy/Caustica's 0.1.x branch beyond its base.

- gradle.properties: mod_version 0.1.0 -> 0.1.1
- lang: add debugView.8 "Emission Mask" / debugView.9 "Emission Source"
  across all 11 locales (en_us included for consistency; upstream's
  commit did not touch it since 0.1.x already carried those keys)

Applied as a cherry-pick rather than a branch merge. upstream/0.1.x
forked from 4a79795 on Jul 20 and does NOT contain the rendering and
performance work this fork already has from upstream/main:

  2cf7397 RIS emitter NEE with a spatial light grid (ComfyFluffy#23)
  f8714d7 Fix RT resource lifetimes and shader payload UB (ComfyFluffy#26)
  47dd18e RT world path tracer: SER/payload/RIS perf pass (ComfyFluffy#27)
  5d6bf62 Split ray tracing into wavefront passes (ComfyFluffy#29)

Merging 0.1.x would have regressed those, plus fork-local features
(SSS, weather lighting, denoiser toggle, hand FOV, tonemapping). Lang
conflicts were resolved to keep both sides.

Note: debugView.8/.9 are currently unused strings - the wavefront-split
renderer exposes debug views 0-7 only.

CI workflow untouched. No rendering logic ported or rewritten.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
xysgottaken2 added a commit to xysgottaken2/Caustica that referenced this pull request Sep 2, 2026
…stingcasutica

fix: ray-traced rain (vanilla geometry) + Overworld distance/rain/night fog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant