Repository navigation
runtime: preamble-only flat scan, safe type lookups, and portable CPU test for rect_list_geometry - #1970
Conversation
…t for rect_list_geometry
…ry (RT-RECT-LIST-CORNER) Addresses review feedback on ProjectLeonida#2478: - Drop the unmeasured NDC + 1/w differing-w fourth-corner extrapolation and w4=1 fallback, keeping the documented clip-space other_a + other_b - corner rule (with bit-exact component selection) uniformly for Position and all attributes. - Restore the original range-based corners loop so rect_list_geometry.h merges cleanly with ProjectLeonida#1970. - Update d3d12_rect_list_corner_test cases and header comment to match.
|
Independent RTX 4080 validation of MEASURED on baseline
Independent evidence review completed. AI-assisted: OpenAI Codex. |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed 57b853a46 merged locally with main c1ecf04ed for the rectangle-list package in #2464. The flat lookups preserve the previous last-wins behavior, and the generated geometry module was byte-identical to main across 60 synthetic cases, varying locations, PointSize, and the function body length. The new rect_list_geometry_test passes against both implementations, consistent with its role as a behavior-preservation test.
CPU microbenchmark of the generator on Ubuntu 22.04 under WSL2, GCC 11.4 -O2, four locations, median of seven alternating A/B batches of 2,500 calls each. Each call also checked its output against main. A repeat produced the same pattern.
| Synthetic function body | Main | Main + PR |
|---|---|---|
| 8 OpNops | 3.07 us/call | 1.93 us/call |
| 16,384 OpNops | 31.56 us/call | 1.91 us/call |
| 65,536 OpNops | 119.19 us/call | 1.94 us/call |
This measures CPU-side geometry shader generation only. The same changed files pass check_no_game_data.py and git diff --check. The heads of #1970 and #2478 also merge cleanly in git merge-tree.
AI-assisted.
|
Verified by OreoFR
Note: shares AI-assisted (Claude Code, Claude Opus 5.5). |
Claim:
RT-RECT-LIST-GEOMETRY-PREAMBLE-AND-TESTS(claim comment#7168816576on #1608).Fixes & Optimizations (
runtime/src/rect_list_geometry.h)OpFunction(preamble-only):OpType*,OpDecorate, and globalOutputOpVariabledeclarations all precede the firstOpFunction(SPIR-V logical layout §2.4), so scanning tens of thousands of body instructions during graphics PSO creation was wasted work.i + n > vertex_words.size()withn > vertex_words.size() - i.std::map/std::setRB-trees and silentoperator[]lookups:types,variable_type,location,builtin, andoutputswith 4 flat sorted vectors (stable_sort+upper_boundpreserving exact last-wins semantics) and explicitfind_type()/find_kv()checks instead oftypes[...]silent default-insertion on missing IDs.headvector and pre-reserve output buffers: pre-reservesannotations,globals,body,vars,io_vars,corners,emitted, andout, and emitsOpEntryPointdirectly intooutwithout a temporaryentryvector.rect_list_geometry(runtime/test/rect_list_geometry_test.cpp): previously only the GPU testd3d12_rect_list_test.cppexercisedrect_list_geometry.h.Verification
runtime/test/rect_list_geometry_test.cpp(8 test groups verifying generated SPIR-V header/bound/capability/memory-model/entry-point/all-4-execution-modes/decorations/6-EmitVertex/2-EndPrimitive, position-only shaders, PointSize allowed, unsorted/duplicate Locations, large body skipped identically, non-SPIR-V/short/zero-len/truncated refusal, missing Position refusal, ClipDistance/Layer refusal, vec3/uvec4/dangling-type-id refusal).rect_list_geometry_testcleanly under:clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Werrorclang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Werrorclang++ -std=c++20 -O2 -Wall -Wextra -Werror-O2vsmain(best of 5 runs, Apple Silicon):python3 -I scripts/check_no_game_data.pyon all 3 changed files andpython3 -I tests/test_text_write_line_endings.py: all passed.