Skip to content

Preserve guest LDS bounds in Metal compute shaders - #3

Open
LuizDusky wants to merge 38 commits into
TxCsOffc:mainfrom
LuizDusky:metal-preserve-compute-lds
Open

LuizDusky wants to merge 38 commits into
TxCsOffc:mainfrom
LuizDusky:metal-preserve-compute-lds

Conversation

@LuizDusky

Copy link
Copy Markdown
Contributor

Preserve the amount of LDS declared by compute shaders in native MSL. The emitter previously capped LDS at 8192 dwords, changing the guest bounds above that value. Metal can now validate the full pipeline requirement, and compute pipeline failures report the shader hash and host device limit.

The focused test verifies that a 9000-dword declaration emits the full 36,000-byte array. This is a source regression test. The Apple M4 used for validation reports a 32,768-byte threadgroup limit and ran the focused GPU suite for valid allocations.

Validation on the Prospero branch: bash tools/test_metal_msl.sh /path/to/existing/build.

Preserve compacted DMASK operands and map logical guest channels to physical texture channels. Add native GPU coverage for full, sparse and packed 16-bit stores.

@TxCsOffc TxCsOffc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the isolated commit 533afbb2 on top of TxCsOffc/KyTx:main (tools/test_metal_msl.sh passed, reporting Large LDS emission: 36000 guest bytes retained (device limit 32768)), and I appreciate the improved diagnostic logging in metalPipeline.mm (threadgroup_limit) and the build_dir parameter support in tools/test_metal_msl.sh.

However, I cannot merge this PR for two reasons:

  1. Branch contamination from LuizDusky/Prospero:main: Commit 270dd5e2 (Merge branch 'main' into metal-preserve-compute-lds) merged LuizDusky/Prospero's main into this branch, pulling in 38 commits across 64 files (+2789 / -345), including Prospero rebranding (README.md, docs/branding/prospero.svg, src/prospero/Prospero.swift) and unrelated GT7 / archive / FEX changes.
  2. Hard failure on 32 KiB Apple Silicon GPUs without an oversized-LDS fallback: Removing the std::min(declared, 8192u) cap in LdsDwords() without a device-memory fallback (such as your later commit bd29a0b3 in LuizDusky/Prospero backing oversized compute LDS with per-workgroup GPU memory) will cause newComputePipelineStateWithDescriptor to fail hard for any compute shader declaring >32 KiB LDS on Apple Silicon GPUs whose maxThreadgroupMemoryLength is 32768 bytes.

Requested changes

  1. Reset/rebase metal-preserve-compute-lds cleanly onto TxCsOffc/KyTx:main so it contains only the scoped compute LDS changes.
  2. Either include the per-workgroup GPU memory fallback for oversized LDS (>32 KiB) or keep pipeline creation safe on 32 KiB maxThreadgroupMemoryLength devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants