Repository navigation
fix(shader,gpu): repack linked mesh outputs to remove Metal alignment holes - #401
Open
gdemontalivet wants to merge 1 commit into
Open
gdemontalivet wants to merge 1 commit into
gdemontalivet wants to merge 1 commit into
Conversation
Contributor
|
On an Apple M4 Pro with D3DMetal 4.0 beta 3, I applied #401’s shader repacking to #397 and retained #397’s standalone declaration rule. A generated mesh with all 56 channels live went from 51,200 to 30,720 aligned bytes with both declared maxima still at 128. The repacked draw returned all 256 expected RGBA32F pixels. Both builds also returned all 256 expected pixels in the same 4,096-byte sparse control. The 51,200-byte arm stopped at the CPU size check. gdemontalivet’s repacking commit · evan-kolberg’s #397 base Prepared and tested with Codex. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#282 enabled
VICTORY_LINK_MESH_OUTPUTSunder Wine and refuses mesh pipelines whose aligned Metal mesh-output footprint still exceeds 32 KiB (32,768B). Two gaps still cause 18–25 world mesh pipelines (34,816..38,400aligned bytes) to be refused on D3DMetal:Shader::translatedandHostPipeline::newchecked only packedMeshOutputs::bytes() > 32,768when retaining DXIL containers and runningtranslate_linked. Shaders whose packed footprint is<= 32,768bytes while their aligned Metal layout is34,816..38,400bytes skippedtranslate_linkedaltogether and hit fix(gpu): refuse mesh pipelines over Metal's 32 KiB under Wine, by the aligned layout too (#172) #282's refusal path unpruned.float4outputs: Apple's Metal DXIL converter lays out clip/cull distances (4B each),SV_Position(16B), and each remaining vertex (OSG1) or primitive (PSG1) output sequentially aligned to its own byte size (end = end.next_multiple_of(4 * cols) + 4 * cols). Whenever a1-component (4B) or2-component (8B) output precedes a4-component (16B) output, each padding hole wastes up to12bytes per vertex or primitive (1,536bytes across 128 vertices), keeping even pruned signatures above32,768aligned bytes.Changes
victory_shader::emit::mesh_aligned_bytes): Move Metal's per-vertex (OSG1) and per-primitive (PSG1) aligned byte calculation intovictory-shaderand checkpacked.max(aligned) > 32,768in standalone count tightening (Lower::new),translate_linked,Shader::translatedcontainer retention (with spill reload fallback), andHostPipeline::newlinking trigger.prune_signature&container::repack_rows): Order kept arbitrary (kind == 0) elements inMS(OSG1,PSG1) andPS(ISG1) by descending power-of-two size(4, 2, 1, 3)ahead of lowering, then repack(row, col)registers aftersame_mode_per_rowand instruction lowering finish—preserving element IDs forloadInput/storeVertexOutput/storePrimitiveOutputwhile packing compatible sub-vector attributes into 4-component rows without alignment holes.Synthetic Hardware Test (CrossOver Preview + D3DMetal & WARP on M5 Max)
linked_mesh_repacks_interleaved_scalar_and_vector_outputs_and_prunes_primitives: a 128-lane mesh shader (40,960B standalone) with interleaved1-col and4-col reads across bothOSG1andPSG1(27,648B packed,36,864B aligned before repacking) prunes unread vertex and primitive outputs and repacks both stages down to27,648B aligned (0alignment waste), passes DXIL Validator 1.6, builds a mesh+pixel PSO on D3DMetal and WARP, and renders the exact expected RGBA texels.Verification
victory-shader+victory-gpusuites passed.cargo xtask policy,git diff --check, andcargo clippy(-- -D warnings, with and without--features diagnostics) passed. All test inputs are synthetic.Live M5 Max Verification (Combined Build on CrossOver Preview + D3DMetal)
CrossOver Preview+ D3DMetal,wave32=true), the runtime reached and sustained the 3D world through+8, +24, +48, +90at1.5–1.8 FPS(549.7–672.1 ms/frameon1,021–1,258 draws/frame,1.275 FPSoverall across+8..+90) with02.48 sallocation stalls,7.2–9.0 ms/frameGUARDSlock hold time (down from4,887 ms/framebefore unlockingGUARDS),149–154 MB/framebuffer copy volume,0DirectStorage decompression or access-violation failures, and38/38over-32 KiB aligned mesh/pixel pairs linked with0host mesh refusals.