Repository navigation
A program's own quoted draws and canvas: sprites by its shaders, meshes by its shader pairs - #1096
Merged
Merged
Conversation
paul-hammant
force-pushed
the
feat/screen-draws
branch
from
November 26, 2026 06:50
37839bc to
d4e1454
Compare
engine_screen_draw queues a draw of a program's quoted pixel shader in a rectangle of the frame, with the shader's inputs as they are when it is queued; the draws are drawn over every frame after the screen pass, in their order, blended over what is there as premultiplied colours are, until engine_screen_draws_clear. engine_set_screen_clip cuts those queued after it to a rectangle. A shader's pass is made the first time it is queued and kept: on Vulkan from its ae3d.quotegen SPIR-V, its sets grown as more draws are queued (vkquote.prepare_with takes each draw's block as it was queued; vkpipes.BLEND_PREMULTIPLIED); on OpenGL its GLSL compiled. examples/screen_draws.ae: a ruled backdrop of fill draws and balls cut to a rectangle, the same on Vulkan and OpenGL, every pixel. The raymarchers' counts in docs/screen-pass.md and the screen pass's change note are re-measured with the reference values rounded to the 8 bits a frame shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
engine_canvas_new makes a canvas, a picture with depth of the program's, that its meshes (engine_mesh_new) are drawn into with its own quoted vertex and pixel shader pairs (engine_canvas_draw), depth-tested, each frame before the frame's own passes; engine_canvas_show shows it in a rectangle of the frame as its shaders wrote it, through the view blit. A draw takes both shaders' inputs as they are when it is queued; draws stay queued till engine_canvas_begin. engine_canvas_lens makes an OpenGL-shaped projection the running renderer's, as ae3d's own camera's is clip-corrected on Vulkan. Vulkan: ae3d.vkcanvas (a colour and a depth image, a render pass of its own, a framebuffer; not in vktargets, whose variables a view swaps), vkquote.program_pair_new (a pair from a program's words, borrowed, depth-tested, culled or not), vkframe's canvas draws (one pass a pair, grown as more of its draws are queued; prepare_with takes the vertex shader's block too). OpenGL: an offscreen view target with depth, a program a pair's shape. ae3d.quotegen.add_pair writes a pair's SPIR-V, gpu.pair_hash is what it is checked by, gpu.set_m4 sets a capture from a shaderlib mat4; quotegen makes the folder of the module it writes. examples/canvas.ae: a turning globe in a canvas, the same on Vulkan and OpenGL to 1/255 at every pixel, nothing from the validation layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
paul-hammant
force-pushed
the
feat/screen-draws
branch
from
November 26, 2026 12:57
617b350 to
4d9fc13
Compare
Drawn whole, its frame is 14 million triangles, seconds a frame on llvmpipe, and the run passed CI's 300 s limit on Linux (main too). As bench_black_hole does: probe a frame drawn whole first, by the GPU's own scene-pass time (a frame's call returns before the GPU is done), and skip past 500 ms; the frame count from AE3D_BENCH_FRAMES. On ae-x64's llvmpipe it now skips in 30 s; on an M6 it measures as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #1094 (a program's screen pass). Two commits:
1. Quoted draws
engine_screen_draw(e, s, spirv, x, y, w, h)queues a draw with the shader's inputs as they are when it is queued; the program sets them again and queues again. Draws are drawn after the screen pass, in order, blended over what is there as premultiplied colours are (destination alpha kept), every frame untilengine_screen_draws_clear.engine_set_screen_clip(e, x, y, w, h)cuts the draws queued after it to a rectangle (a widget's canvas); a draw may run off it or off the frame.ae3d.quotegenSPIR-V the first time it is queued and kept, its descriptor sets grown (doubled, device idle) as more draws are queued;vkquote.prepare_withwrites each draw's block as it was queued;vkpipes.BLEND_PREMULTIPLIED. OpenGL: the tree's GLSL compiled once per shape, scissor for the clip, the renderer's blend and depth state restored after.examples/screen_draws.ae: a ruled backdrop, afilldraw per line, and 40 shaded discs cut to a rectangle.docs/screen-pass.mdhas a section on it;changes/2026-11-26-screen-draws.md.What drove it: a molecule viewer draws its ball shader once per atom, over its backdrop. Held to reference frames drawn by another renderer, every atom is drawn where and as they have it (the same draw list, line for line, for four molecules turned and on each backdrop), and no pixel is more than 2/255 from them, on Vulkan and on OpenGL.
The raymarchers' counts in
docs/screen-pass.mdand the screen pass's change note are re-measured with the reference values rounded to the 8 bits a frame shows: 34 and 36 of 360,000 (were 44, 46), 111 and 87 of 307,200 (163, 143).2. A program's canvas
engine_canvas_new(e, w, h)makes a canvas: a colour and a depth image of the program's.engine_mesh_new(e, mesh)puts anae3d.coremesh of the program's on the GPU.engine_canvas_draw(e, canvas, vs, ps, spirv, mesh, cull, textures, count)queues a mesh drawn by the pair, with both shaders' inputs as they are when it is queued, depth-tested and written. Draws stay queued untilengine_canvas_begin(e, canvas, rgba)clears them and sets the clear colour.engine_canvas_show(e, canvas, x, y, w, h)shows the canvas through the view blit, each frame, asengine_view_blitdoes, so what the shaders wrote is what is shown.engine_canvas_lens(e, m)makes an OpenGL-shaped projection the running renderer's: unchanged on OpenGL, clip-corrected on Vulkan asvkdesc.clip_correctdoes ae3d's own camera's.ae3d.vkcanvasholds the canvas's images, render pass and framebuffer. It is a module of its own, not part ofvktargets, because a view swaps every variable ofvktargetsin and out.vkquote.program_pair_newmakes a pass from a program's SPIR-V. The pass borrows its shaders, may be culled or not, and takes a vertex shader with no input too.vkpipestreats the canvas pass as single-sample with depth.ae3d.quotegen.add_pairwrites a pair's SPIR-V, andgpu.pair_hashis what that SPIR-V is checked against.gpu.set_m4sets a capture from ashaderlibmat4.quotegennow makes the folder of the module it writes, and reports the emitter's error instead of handing glslang an empty shader.examples/canvas.aedraws a turning globe into a 480 x 480 canvas.docs/canvas.md;changes/2026-11-26-program-canvas.md.What drove it: a flight over a land draws its sky, and its land (a grid its vertex shader raises into hills), into a canvas. Held to reference frames drawn by another renderer, at three places on its way no more than 71 of 307,200 pixels are more than 2/255 from them, on Vulkan and on OpenGL.
Checked before this PR
canvasgives the same picture on Vulkan and OpenGL to 1/255 at every pixel of 576,000;screen_passgives the same picture on Vulkan and OpenGL, every pixel of 576,000, andscreen_drawsall but one pixel, 1/255 apart; the Vulkan validation layer reports nothing for any of the three (scripts/validate.sh), nor for the flight program.AE3D_CI_TIER=apps AE3D_CI_SHARD=0/2 ./ci.sh, every example built with warnings as errors (canvasincluded), everything passed; the runs were skipped there for want of a display.🤖 Generated with Claude Code