mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 06:53:19 -10:00
Two gaps a launch film found in <Compute>, both of one cause: its uniforms never reached it after frame 0. A compute's uniforms travelled only inside its `shader` spec, which a row holds from its first frame, so an inline compute (or one as written) saw frame 0's values on every frame. They now also go as a keyed `uniforms` column, as a frame pass's do. raea-sys-compute's `follow` repacks them when the column changes: an inline compute's into its slots by name (a name it wasn't built with is refused), one as written through its packer (written::follow_uniforms; `Ranged` is kept for every compute as written, and a field that is a mesh's slab range is still packed each frame). An mp4 render draws its 3D live (LiveScene): each frame's changed columns are set on the live rows. The compute's and the frame pass's `follow` read the timeline's columns (`FrameRows::cols`), which in a live render hold only the load's first frame, so an mp4 of a compute driven by its uniforms stayed black. FrameRows::at reads a row's value by its place, the live row's when there is one; both follows use it. bench/compute-frames/check.sh renders level.tsx (an inline compute filling an image with the grey `level`, f / 20, gives) to PNGs and to an mp4: frame 0 is black and frame 10 grey 188 in both (the mp4 within 4, its YUV round trip). Before, frame 10 was black in both. shader/compute_shader_game_of_life, shader_advanced/compute_mesh, custom_phase_item and custom_post_processing still pass pixel for pixel.
24 lines
976 B
TypeScript
24 lines
976 B
TypeScript
// bench/compute-frames: an inline <Compute> fills a 64 x 64 render image with the grey its uniform `level` gives,
|
|
// f / 20 at frame f, and a Sprite shows it over the whole 128 x 128 frame (check.sh).
|
|
import { Composition, registerRoot, useCurrentFrame } from "raea";
|
|
import { Canvas3D, Compute, Sprite } from "raea/3d";
|
|
|
|
const FILL = `
|
|
@compute @workgroup_size(8, 8, 1)
|
|
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
|
|
let l = u_level();
|
|
textureStore(out, vec2<i32>(id.xy), vec4<f32>(l, l, l, 1.0));
|
|
}`;
|
|
|
|
function Shot() {
|
|
const f = useCurrentFrame();
|
|
return (
|
|
<Canvas3D layered clearColor="#000000">
|
|
<Compute wesl={FILL} workgroups={[8, 8, 1]} uniforms={{ level: f / 20 }} images={{ out: "render:level:64x64" }} />
|
|
<Sprite src="render:level:64x64" x={64} y={64} width={64} height={64} scale={2} />
|
|
</Canvas3D>
|
|
);
|
|
}
|
|
|
|
registerRoot(() => <Composition id="main" component={Shot} durationInFrames={12} fps={30} width={128} height={128} />);
|