Repository navigation
A program's own quoted screen pass, on Vulkan and OpenGL - #1094
Conversation
engine_set_screen_pass(e, shader, spirv) draws a full-screen pixel shader of the program's, written with quote, over every frame once the tone curve and FXAA are done, its colours shown as it writes them. The program keeps the shader and sets its inputs between frames by name (gpu.set_float, set_vec2, ...). On Vulkan a program's quoted shader could not be drawn at all: SPIR-V came only from tools/generate_shaders over ae3d's own shaders, a pass took a fixed shader id, the frame's passes were each wired in by hand, and a quoted pass that sampled no texture was refused. - ae3d.quotegen: a program's own generator makes its passes' SPIR-V at build time (glslangValidator on PATH) into an Aether module of words and the tree's hash (gpu.QuotedSpirv). A shader changed since stops the program when its pass is made, naming it and its generator (vkquote.stale), as ae3d's own do (fresh). - vkpipes.shader_words, vkquote.program_pass_new: a pass from words the caller keeps, borrowing the program's shader, with no texture if it samples none (the descriptor pool sized only for what it has). - vkframe and gl draw it before the view blits; engine applies it when the backend comes up, as the upscaler is. - examples/screen_pass.ae, its shader in examples/lib/screenpass and its SPIR-V written by tools/screen_pass_spirv.ae: the same picture on both backends, every one of 576,000 pixels. docs/screen-pass.md. Checked: tools/generate_shaders --check unchanged (71 shaders); the example on Vulkan and OpenGL (M6), warning-free; the Aether port of Chris Hinsley's Raymarch, drawn this way, within 1/255 of his native code's frame on all but 44 of 360,000 pixels on Vulkan, 46 on OpenGL; a stale shader stops it with the message above. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
engine_set_screen_pass_rect(e, x, y, w, h) draws a program's screen pass in a rectangle of the frame, its quad filling it, so a program can put its own controls beside the picture. In the framebuffer's pixels from the top left; 0 wide is the whole frame, as before. The viewport on OpenGL (counted from the bottom there), vkframe.viewport_at on Vulkan, each put back after the draw. Found by the Aether port of Chris Hinsley's Surface, whose 640 x 480 canvas sits under a panel of ae3d.menu sliders: within 1/255 of his native code's frame on all but 163 of 307,200 pixels on Vulkan, 143 on OpenGL. docs/screen-pass.md says where the quad's uv runs on each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ci.sh type-checks each examples/lib module alone, a program importing it and nothing else. examples/lib/screenpass_spirv imported only `ae3d.gpu (QuotedSpirv)`, and on Aether 0.945.0, ae3d's CI pin, a module reached only through selective imports has its own imports left out: ae3d.gpu's std.string was, and string.length was undefined (fixed in Aether 0.946.0, aether #3877). The module now imports ae3d.gpu whole too. Checked with 0.945.0's aetherc: the probe fails with the old header and compiles with the new. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Three commits since the PR opened:
Earlier run's macOS failures: Lab: the suites tier on ae-x64 (llvmpipe), on the first commit. 305 ok, 177 skipped, 14 FAIL lines across 9 suites/benchmarks. I believe none comes from this PR, but I haven't run main there to prove it:
The two questions in the description still stand. One more, from the Surface port: an open 🤖 Generated with Claude Code |
engine_set_screen_pass(e, shader, spirv): a full-screen pixel shader of the program's, written withquote, drawn over every frame after the tone curve and FXAA, on Vulkan and OpenGL. The program keeps the shader and sets its inputs between frames by name (gpu.set_float,set_vec2, ...).docs/screen-pass.mdhas the whole of it.Until now a program could not draw a quoted shader of its own on Vulkan at all: SPIR-V came only from
tools/generate_shadersover ae3d's own shaders, a pass took a fixed shader id, the frame's passes were each wired in by hand, and a quoted pass that sampled no texture was refused.What's added
ae3d.quotegen: a program's own generator makes its passes' SPIR-V at build time (glslangValidator on PATH), an Aether module of words plus the tree's hash (gpu.QuotedSpirv). A shader changed since stops the program when its pass is made, naming it and its generator, as ae3d's own do (vkquote.fresh/stale).vkpipes.shader_words,vkquote.program_pass_new: a pass from words the caller keeps, borrowing the program's shader, allowed to sample no texture (the descriptor pool is sized only for the kinds it has).vkframeandgldraw it before the view blits; the engine applies it when the backend comes up, as it does the upscaler.examples/screen_pass.ae(shader inexamples/lib/screenpass, SPIR-V written bytools/screen_pass_spirv.ae), a change fragment, a README bullet.Checked
tools/generate_shaders --check: unchanged, 71 shaders.examples/screen_pass.aeon Vulkan and OpenGL (Apple M6): identical, every one of 576,000 pixels; builds warning-free.Questions for @nicolas-maman:
quotegenaccepts any glslang, holding the words to the tree's hash rather than byte for byte to 16.6.0 as ae3d's own are. OK for programs?🤖 Generated with Claude Code