Skip to content

Reject reads of mesh shader outputs under GL_EXT_mesh_shader - #4467

Merged
arcady-lunarg merged 1 commit into
KhronosGroup:mainfrom
apollo-2006:mesh-output-read
Oct 15, 2026
Merged

arcady-lunarg merged 1 commit into
KhronosGroup:mainfrom
apollo-2006:mesh-output-read

Conversation

@apollo-2006

@apollo-2006 apollo-2006 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4170.

GL_EXT_mesh_shader doesn't allow reading mesh shader outputs, but glslang was accepting it and emitting an OpLoad from Output. You'd only find out later when spirv-val failed with VUID-StandaloneSpirv-MeshEXT-07107, which makes it pretty hard to track down. Now glslang points at the line instead:

ERROR: 0:29: 'outVert' : mesh shader outputs can only be written, not read

After parsing, a small traverser walks EXT mesh shaders and flags any output access that isn't a plain write (assignment target or out argument). NV mesh shaders allow these reads, so they're left alone.

Added spv.ext.meshShaderOutputRead.error.mesh, which covers a handful of write and read cases, and all existing tests still pass. Happy to change the error wording or approach if you'd prefer something else :)

GL_EXT_mesh_shader says "mesh shaders do not permit read access on
output variables", but glslang accepted code like

    gl_MeshVerticesEXT[v].gl_Position = vec4(outVert[v].worldPos, 1.0);

and emitted an OpLoad from the Output storage class, which spirv-val
and spirv-opt then reject (VUID-StandaloneSpirv-MeshEXT-07107).

After parsing an EXT mesh shader, walk the tree and report every read
of an output: r-values, compound assignments, increments, inout
arguments and indices. Plain assignments and out arguments are still
allowed. GL_NV_mesh_shader permits these reads and is unchanged.

Fixes KhronosGroup#4170
@arcady-lunarg arcady-lunarg added the kokoro:run Trigger Google bot runs label Oct 14, 2026

@arcady-lunarg arcady-lunarg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for the fix.

@kokoro-team kokoro-team removed the kokoro:run Trigger Google bot runs label Oct 14, 2026
@arcady-lunarg
arcady-lunarg merged commit 4b626a0 into KhronosGroup:main Oct 15, 2026
33 checks passed
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.

Reading from Mesh Shader output should be rejected by compiler

3 participants