Repository navigation
refactor(raytracing): group long parameter lists and bump to 0.31.2 - #318
Merged
Merged
Conversation
added 2 commits
October 18, 2026 13:45
Functions in the raytracing and lighting paths that had grown to five or more ordinary parameters now take a struct instead, so call sites read as one conceptual argument rather than a positional run of scalars. The new RayTraceFrame collects the borrowed camera, lights and settings plus the two copied dimensions, which brings pack_raytrace_frame and render_raytrace_rgba down to three parameters each. BVH build and traversal, shading and cleanup paths reuse the Ray, RayTraceSettings, LightingUniforms and Camera3D types that already exist. push_vec4 was a thin extend_from_slice wrapper and is removed; grow_texture and call4 fold into ensure_packed_texture and draw_vertices. The new PixelSample in pipeline/render/struct.rs holds the four scalars pixel_direction needs per supersample, so that path keeps allocating nothing. Triangle intersection keeps both entry points and their existing semantics: the free function intersect_triangle(ray, vertices) deliberately does not filter by the ray's t_min/t_max range, and Ray::intersect_triangle keeps the range clamp. The 19 pre-existing renderer entry points and the WebGL/WebGPU backend APIs are unchanged. Adds 8 regression tests covering the frame struct's inputs, packing across a non-square dimension pair, rejection without touching the buffer, output buffer reuse across frame shapes, and three soft-shadow edge cases.
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.
Summary
Groups the raytracing/lighting parameter lists that grew past four ordinary
parameters into parameter structs, and bumps the workspace to 0.31.2 as a
patch release. This is the follow-up delivery of the parameter-object refactor:
the renderer work itself already reached
masterthrough the earlier PR; thisPR carries the remaining parameter grouping plus the version bump on top of the
current
master.Scope: 26 functions with >= 5 ordinary parameters
All 26 functions added by PR #317 that carried five or more ordinary
parameters now have four or fewer, or have been removed. Measured with a
scratch
synAST scanner over 148 source files: the original renderer scope's147 files plus this PR's new source file:
The 26 changed signatures resolve three ways:
RayTraceFramecollects camera, lights,settings and dimensions so
pack_raytrace_frameandrender_raytrace_rgbashrink from 6 to 2 and from 7 to 3 ordinary parameters, respectively.
New stack-based BVH, light, upload and lifecycle parameter structs group
the other related inputs without adding long positional constructors.
Raywithoutnormalizing its direction, and the WebGPU draw helper uses the existing
DrawArgsdescriptor while preserving four separate JavaScript arguments.push_vec4helper is replacedwith direct
extend_from_slicecalls.grow_textureis consolidated intoensure_packed_texture, while the genericcall4helper becomes thedraw-specific
draw_vertices.The only new source file is
engine/src/raytracing/pipeline/render/struct.rs,which holds
PixelSample— aCopystruct of four scalars used bypixel_direction; constructing this parameter object adds no per-sampleheap allocation.
Public API migration
Callers move from positional arguments to the frame struct:
RayTraceFrame<'a>is aCopystruct of public fields — the camera, lights andsettings are borrowed, the two dimensions are copied — so constructing one
allocates nothing and clones nothing:
Triangle intersection keeps both entry points, with their existing range
semantics untouched:
The free function's lack of range filtering and the inherent method's range
clamp are preserved and covered by regression tests.
The 19 inherited long-parameter renderer methods are outside this refactor's
scope and remain unchanged, as do the public WebGL and WebGPU backend entry
points. The public frame and triangle signatures above are breaking source
changes: downstream callers must migrate them.
Tests
8 new regression tests cover the shapes the parameter grouping has to preserve:
frame_struct_carries_its_own_inputsframe_packs_the_camera_lights_and_settings_it_was_givenframe_packs_a_non_square_dimensions_pair_into_its_own_slotsframe_rejects_invalid_dimensions_without_touching_the_bufferrender_reuses_its_output_buffer_across_frame_shapessoft_shadow_treats_a_coincident_light_as_visiblesoft_shadow_ignores_a_sphere_the_segment_only_touches_at_an_endpointsoft_shadow_tests_both_ray_sphere_roots_so_a_segment_starting_inside_an_occluder_is_shadowedVerification performed on this branch
All gates were run against the final tree of this branch, including upstream
CI-generated derive ordering in
backend/canvas/struct.rsandbackend/data/struct.rs:cargo fmt --all -- --checkand two idempotentcargo fmt --allrunscrate fmt --check— cleancargo check --workspace --all-targets --all-featurescargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-features: 2877 passed, 0 failed, 286 ignoredeuv-engine+euv-example, and a release check ofthe workspace (excluding
euv-cli)cargo metadata: 8 workspace members, all at a single version0.31.2The three-backend browser run (189/189) was executed on the same 0.31.2 business
logic in the previous round and is not re-run here; the only upstream delta in
this branch is derive attribute ordering.
Versioning
Patch release
0.31.1→0.31.2. The root[workspace.package].versionandall 7 path-dependency entries in the root
Cargo.tomlcarry0.31.2, andcargo metadataconfirms all 8 members resolve to that single version.Note for reviewers: this repo's
publishandreleasejobs are gated onpushtomaster, so this PR runscheck/tests/clippy/buildonly. Nopublication happens from a pull request.