KhronosGroup / KhronosGroup/glslang
Component swizzling of `gl_MeshVerticesEXT[].gl_Position`, produces invalid code.
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
Found while working on test-cases for cross-compiler:
```
// glsl - source
const vec3 vertices[3] = {vec3(1,0,0), vec3(0,1,0), vec3(0,0,1)};
gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position.yxzw = vec4(vertices[gl_LocalInvocationIndex], 1);
```
Produces spir-v:
```
%38 = OpCompositeConstruct %v4float %35 %36 %37 %float_1
// vec4* _40 = &gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position;
%40 = OpAccessChain %_ptr_Output_v4float %gl_MeshVerticesEXT %18 %int_0
// vec4 _41 = *_40; // AFAIK this is illegal instruction, since meshlet is write-only
%41 = OpLoad %v4float %40
// _41 is referenced, but not used
%42 = OpVectorShuffle %v4float %41 %38 5 4 6 7
// *_40 = _42 // writing - should be fine
OpStore %40 %42
```
Contributor guide
Research direction
No repository files or tests are named. Start by compiling the provided GLSL mesh-shader snippet with glslang and inspecting the generated SPIR-V around the component-swizzled gl_Position assignment. Done means the generated code no longer loads from the write-only mesh output while preserving the requested swizzle assignment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100