mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:45:53 +01:00
[PR #2027] runtime: guard align_up_saturating against zero alignment and add unit tests (RT-XS-ALLOC-SIZE-GUARDS-AND-TESTS) #2031
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#2031
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/2027
Author: @abnalstlll-byte
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:feat/rt-xs-alloc-size-guards-and-tests📝 Commits (1)
065df3druntime: guard align_up_saturating against zero alignment and add unit tests (RT-XS-ALLOC-SIZE-GUARDS-AND-TESTS)📊 Changes
3 files changed (+278 additions, -0 deletions)
View changed files
📝
runtime/CMakeLists.txt(+12 -0)📝
runtime/shims/d3d12_xs_alloc_size.h(+1 -0)➕
runtime/test/d3d12_xs_alloc_size_test.cpp(+265 -0)📄 Description
Claimed in the coordination issue as: RT-XS-ALLOC-SIZE-GUARDS-AND-TESTS (claim)
What and why
Guard
align_up_saturatingagainst zero alignment:runtime/shims/d3d12_xs_alloc_size.h:204,align_up_saturating(value, to)did not guard againstto == 0, leading to integer division by zero and underflow in(to - 1).if (to == 0) return value;to safely returnvalueunmodified when alignment is 0.Add comprehensive standalone CPU-only unit test
d3d12_xs_alloc_size_test:runtime/shims/d3d12_xs_alloc_size.hcomputes critical console render target and depth-stencil allocation sizing rules (SW_64KB tile padding, mip tail tile sharing, and multi-slice scaling) but had no direct unit test.runtime/test/d3d12_xs_alloc_size_test.cppexercising:align_up_saturating: zero alignment guard, standard rounding, power-of-two alignments, and saturation without wrapping nearUINT64_MAX.render_target_element_bytes: 1, 2, 4, 8, and 16-byte formats, plus 0 for non-RT formats.console_depth_planes: depth/stencil plane separation for D32S8, D24S8, console D16S8 (DXGI 118), D32, D16, and non-depth formats.console_render_target_size: dimension, flag, sample count, format, and extent validation; 1920x1080 4-byte target exact 135-tile computation (8,847,360 bytes); multi-slice arrays and full mip chains.console_depth_stencil_size: plane addition, flags/dimension validation, and sample count checks.console_placement: rejection of null descs and non-targets; placement calculations and offset/size reporting ineacharray for growing console render targets.d3d12_xs_alloc_size_testandd3d12_xs_alloc_sizeCTest inruntime/CMakeLists.txt.Tested
62/62 checks passed(0 failures).python -I tests/test_ci_registration.py: 16/16 pass.python -I tests/test_text_write_line_endings.py: 3/3 pass.python -I scripts/check_no_game_data.py: clean (0 violations, no game data).AI-assisted (Claude Code)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.