Fix self-relative shader register pointers in ShaderInfo #5

Open
Gudui wants to merge 1 commit from Gudui/codex/shaderinfo-relative-pointers into main
Gudui commented 2026-08-30 14:52:27 -05:00 (Migrated from github.com)

Summary

Fix the host-only ShaderInfo inspector's register-array pointer bases. Context and shader pointer
values at header offsets 24 and 32 are self-relative: each is based on its own field, not the beginning
of the header. The old reader starts the arrays 24/32 bytes early while still reporting plausible
register counts.

The fix also bounds the relative value before addition/conversion, preventing oversized offsets from
wrapping back into the header. Null pointers and zero counts remain empty; truncated arrays retain
only complete records, as before.

Reproduction

On the existing upstream mesh_ps.sb, the old CLI reports 9 context and 6 shader records but starts
the context list at 0x0006 = 0x7EAF2669 rather than 0x01C4 = 0. It also begins the shader list with
three zero-offset records. Resolving the two pointers from their own fields produces the intended
arrays. This matches the pointer relocation performed by the shader-creation routine inspected during
the investigation; no shader code or runtime behavior is changed.

dotnet run --project tools/SharpProspero.Bindings.Generator -c Release -- shader --file src/SharpProspero/Graphics/Agc/Shaders/mesh_ps.sb --registers

Tests

Added independent synthetic ELF/header fixtures; no shader binaries, module dumps, proprietary
fixtures, graphics initialization or console are required. They assert exact offset/value lists at
different placements, both pointer bases, null/zero counts, final complete records, truncation and
oversized offsets.

  • Unchanged upstream parser (e24e25e) with these tests: 12 failed, 7 passed.
  • Corrected parser: 19 passed, 0 failed, 0 skipped.
  • dotnet build SharpProspero.slnx -c Release: 0 warnings, 0 errors.
  • CLI reproduction against the unchanged upstream mesh pixel shader: corrected register lists.
dotnet test SharpProspero.slnx -c Release

Scope and review note

One host parser change, synthetic tests, test README, and minimal project/solution wiring. There are
no runtime SDK, renderer, shader-resource or GPU-state changes. No hardware validation is claimed or
needed for this host parsing regression.

The base revision has no tracked test project although CONTRIBUTING references
tests/SharpProspero.Tests. This draft adds a small xUnit project at that path referencing only
SharpProspero.Prx, rather than bringing in our larger fork suite. Please advise if another test
location/framework is preferred.

## Summary Fix the host-only `ShaderInfo` inspector's register-array pointer bases. Context and shader pointer values at header offsets 24 and 32 are self-relative: each is based on its own field, not the beginning of the header. The old reader starts the arrays 24/32 bytes early while still reporting plausible register counts. The fix also bounds the relative value before addition/conversion, preventing oversized offsets from wrapping back into the header. Null pointers and zero counts remain empty; truncated arrays retain only complete records, as before. ## Reproduction On the existing upstream `mesh_ps.sb`, the old CLI reports 9 context and 6 shader records but starts the context list at `0x0006 = 0x7EAF2669` rather than `0x01C4 = 0`. It also begins the shader list with three zero-offset records. Resolving the two pointers from their own fields produces the intended arrays. This matches the pointer relocation performed by the shader-creation routine inspected during the investigation; no shader code or runtime behavior is changed. ```sh dotnet run --project tools/SharpProspero.Bindings.Generator -c Release -- shader --file src/SharpProspero/Graphics/Agc/Shaders/mesh_ps.sb --registers ``` ## Tests Added independent synthetic ELF/header fixtures; no shader binaries, module dumps, proprietary fixtures, graphics initialization or console are required. They assert exact offset/value lists at different placements, both pointer bases, null/zero counts, final complete records, truncation and oversized offsets. - Unchanged upstream parser (`e24e25e`) with these tests: **12 failed, 7 passed**. - Corrected parser: **19 passed, 0 failed, 0 skipped**. - `dotnet build SharpProspero.slnx -c Release`: **0 warnings, 0 errors**. - CLI reproduction against the unchanged upstream mesh pixel shader: corrected register lists. ```sh dotnet test SharpProspero.slnx -c Release ``` ## Scope and review note One host parser change, synthetic tests, test README, and minimal project/solution wiring. There are no runtime SDK, renderer, shader-resource or GPU-state changes. No hardware validation is claimed or needed for this host parsing regression. The base revision has no tracked test project although CONTRIBUTING references `tests/SharpProspero.Tests`. This draft adds a small xUnit project at that path referencing only `SharpProspero.Prx`, rather than bringing in our larger fork suite. Please advise if another test location/framework is preferred.
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'Gudui/codex/shaderinfo-relative-pointers:Gudui/codex/shaderinfo-relative-pointers'
git switch 'Gudui/codex/shaderinfo-relative-pointers'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'Gudui/codex/shaderinfo-relative-pointers'
git switch 'Gudui/codex/shaderinfo-relative-pointers'
git rebase 'main'
git switch 'main'
git merge --ff-only 'Gudui/codex/shaderinfo-relative-pointers'
git switch 'Gudui/codex/shaderinfo-relative-pointers'
git rebase 'main'
git switch 'main'
git merge --no-ff 'Gudui/codex/shaderinfo-relative-pointers'
git switch 'main'
git merge --squash 'Gudui/codex/shaderinfo-relative-pointers'
git switch 'main'
git merge --ff-only 'Gudui/codex/shaderinfo-relative-pointers'
git switch 'main'
git merge 'Gudui/codex/shaderinfo-relative-pointers'
git push origin 'main'
Sign in to join this conversation.
No description provided.