mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:50:52 +01:00
[PR #1696] rgba4_fragment: harden SPIR-V output quantization and add portable unit test #1710
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1710
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1696
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/rgba4-fragment-validation-and-tests📝 Commits (1)
0dda119rgba4_fragment: harden SPIR-V rewrite validation and add portable unit test📊 Changes
3 files changed (+439 additions, -24 deletions)
View changed files
📝
runtime/CMakeLists.txt(+3 -0)📝
runtime/src/rgba4_fragment.h(+74 -24)➕
runtime/test/rgba4_fragment_test.cpp(+362 -0)📄 Description
Item ID:
RGBA4-FRAGMENT-VALIDATION-AND-TESTSClaim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7157180890
Summary
Hardens
leonida::rgba4::quantizeinruntime/src/rgba4_fragment.hand adds a portable CPU-only unit test (runtime/test/rgba4_fragment_test.cpp, registered inruntime/CMakeLists.txt):f32type: resolveoutputsagainstmaskbefore checking!float_type, so depth-only / integer-output shaders with no outputs inmaskreturntrueinstead of failing PSO creation withE_INVALIDARG.Outputvariable matchesmaskbut itsOpTypePointer Outputis absent, fail conservatively instead of silently skipping quantization.OpGroupDecoratelocations: propagateLocationdecorations applied via decoration groups (OpGroupDecorate, opcode 74) ontoOutputvariables.OpMemoryModelplacement before emittingGLSL.std.450: ensureOpExtInstImportis inserted exactly once beforeOpMemoryModel(and beforeOpFunction) when needed; otherwise fail without mutatingwordsinstead of returning invalid SPIR-V with an undeclaredimport_id. Also tightenGLSL.std.450import matching to exact 6-word length and non-zero result ID.OpPtrAccessChain/OpInBoundsPtrAccessChainand reject untracked pointer escapes: rejectOpCopyMemorySized, unknown result pointer types on access chains /OpCopyObject, andOpBitcast/OpSelect/OpPhi/OpFunctionCallinvolving a masked output pointer.words[3]): reject zero bound and prevent 32-bit ID wraparound when allocating new IDs.Verification
clang++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic -fsanitize=address,undefined runtime/test/rgba4_fragment_test.cpp-> exit 0, all checks pass, 0 warnings / 0 sanitizer errors.Mutation check against unpatched
main(git show main:runtime/src/rgba4_fragment.hwith new test) -> exit 1 (15failures reproducing every fix).python3 -I scripts/check_no_game_data.py runtime/src/rgba4_fragment.h runtime/test/rgba4_fragment_test.cpp runtime/CMakeLists.txt-> OK.python3 -m compileall -q make_game.py tools testsandpython3 -I tests/test_text_write_line_endings.py-> OK (3/3).AI-assisted: yes
GPUs tested: none (CPU-only portable SPIR-V rewriter + synthetic unit tests; no game files)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.