Repository navigation
borealis: give M5 mesh shaders without a fragment shader a vertex layer - #1343
Merged
RyanTheTide merged 1 commit intoNov 29, 2026
Conversation
An M5 mesh shader compiled without its fragment shader (a pipeline library or an unlinked shader object) gets a zero layer so that a fragment shader reading gl_Layer finds a layer word. It was stored as a per-primitive gl_PrimitiveLayerEXT, which gives every primitive private vertices and can push the shader past the native output limits, where it fell back to compiling without the layer. The layer is uniform over the workgroup, so store it per vertex instead, the form the view index already takes (vertex_layer in agx_nir_lower_m5_mesh()). The shader keeps its shared vertices. Signed-off-by: Nick <nekreshen@yandex.ru>
There was a problem hiding this comment.
Verdict: MERGE at 15973cfa
Blockers: none.
Checked:
- Audited
src/asahi/vulkan/hk_shader.c(+28/-28):hk_m5_mesh_default_layer()now emits per-vertexVARYING_SLOT_LAYERzero stores (nir_store_per_vertex_output,nir_type_uint32) across0..max_vertices_out-1(withverts == 0guard andfirst + threads > vertspartial-tail guard), dropsper_primitive_outputs |= VARYING_BIT_LAYER, and marksshader->info.mesh.vertex_outputs |= VARYING_BIT_LAYERinhk_compile_shader_impl(), matchinghk_lower_multiview()'svertex_layerform inagx_nir_lower_m5_mesh(). - Preserves shared vertices and avoids unnecessary native output-limit fallbacks (instrumented across 5,475 shaders:
348 -> 30shaders with added vertices,10 -> 0fallbacks). - Exact-head J815 M5 (G17G) Borealis A/B verification: 11,759 mesh library/shader-object cases
0 diffs / 0 regressions, 15,958-case dEQP gate0 diffs,meson test --suite asahi223/223, Godot TPS neutral,0GPU faults. - DCO
Signed-off-by:present; no Apple material or policy issues.
Evidence
- Diff:
src/asahi/vulkan/hk_shader.c(+28/-28). - Note (non-blocking): M5 Pro/Max (G17S/G17C) hardware not yet run; same
agx_nir_lower_m5_mesh()vertex_layerlowering.
This was referenced Nov 29, 2026
|
@DjDeveloperr, code-owner heads-up: App approval at |
This was referenced Nov 29, 2026
|
Merge-train landing at
Revert: |
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.
What: An M5 mesh shader compiled without its fragment shader (pipeline library, unlinked shader object) gets a zero layer so a later fragment shader that reads gl_Layer finds a layer word. It was stored per primitive, which gives every primitive private vertices and pushed some shaders past the native output limits, where they fell back to compiling without the layer. The layer is uniform over the workgroup, so it is now stored per vertex, the form the multiview view index already uses.
Tested: J815 MacBook Air 15" M5 (T8142, G17G), Borealis, kernel
7.3.0-aurora-j815-dev, at 15973cf vs base 8bad0a5: 11,759 mesh cases on the library/shader-object paths: 0 diffs, 0 regressions (the layer is 0 either way); instrumented count over the 5,475 such shaders: per-primitive form added vertices in 348 shaders (+720 vertices) and fell back to no layer in 10; per-vertex form: 30 with added vertices (shaders with their own per-primitive outputs), 0 fallbacks;meson test --suite asahi223/223; Godot TPS demo 1080p FSR2 voxel GI (FAST=1): 49.4 / 49.4 static, 57.4 route vs 49.5 / 49.7, 57.5 base (neutral). 0 GPU faults. Regression line: 0 SELinux denials (N/A on this image), 0 failed units, 0 new kernel errors.Risk: two-way door · M5 Macs; only mesh shaders compiled without a fragment shader.
Not yet: M5 Pro/Max (G17S/G17C) hardware; no game on this desktop uses mesh shaders.
Details
hk_shader.c(+28/-28):hk_m5_mesh_default_layer()stores a per-vertex zero for every vertex belowmax_vertices_out(invocation i stores i, i + threads, ...) instead of a per-primitive zero belowmax_primitives_out, and no longer marks LAYER per primitive; the caller adds VARYING_BIT_LAYER to the mesh vertex outputs.Evidence
Commands (gpu-perf):
mdl-20261129.txt: mesh cases of
pipeline.{pipeline_library,fast_linked_library,shader_object_*},shader_object.*,fragment_shading_barycentric.{pipeline_library,fast_linked_library}and all non-querymesh_shader.extcasesGate (15,958, broad regression list):
Godot TPS demo, 1080p FSR2 voxel GI,
FAST=1(BENCH lines, a = base, c = this PR):