KhronosGroup / KhronosGroup/SPIRV-Cross
MSL: Unable to dynamically access an incoming `gl_ClipDistance` array under tessellation
- Dominant language
- GLSL
- Stars
- 2.5k
- Forks
- 713
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 16
Description
SPIR-V conversion to MSL fails with error:
```
MSL conversion error: Trying to dynamically index into an array interface variable in tessellation. This is currently unsupported.
```
The attempt in GLSL results in `gl_in[0].gl_ClipDistance[_80]`, but in MSL `main0_in`, the incoming `gl_ClipDistance` array is flattened in to `float gl_ClipDistance_0 [[attribute(8)]];`.
Is this the result of a known limitation in MSL, or is it something we can enhance SPIRV-Cross to emit and access the incoming `gl_ClipDistance` as an array? @cdavis5e
These CTS test fail as a result:
```
dEQP-VK.tessellation.user_defined_io.per_vertex_block.vertex_io_array_size_implicit.triangles
dEQP-VK.tessellation.user_defined_io.per_vertex_block.vertex_io_array_size_implicit.quads
dEQP-VK.tessellation.user_defined_io.per_vertex_block.vertex_io_array_size_shader_builtin.triangles
dEQP-VK.tessellation.user_defined_io.per_vertex_block.vertex_io_array_size_shader_builtin.quads
dEQP-VK.tessellation.user_defined_io.per_vertex_block.vertex_io_array_size_spec_min.triangles
dEQP-VK.tessellation.user_defined_io.per_vertex_block.vertex_io_array_size_spec_min.quads
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.1
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.1_fragmentshader_read
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.2
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.2_fragmentshader_read
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.3
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.3_fragmentshader_read
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.4
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.4_fragmentshader_read
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.5
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.6_fragmentshader_read
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.6
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.6_fragmentshader_read
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.7
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.7_fragmentshader_read
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.8
dEQP-VK.clipping.user_defined.clip_distance_dynamic_index.vert_tess.8_fragmentshader_read
dEQP-VK.clipping.user_defined.clip_cull_distance_dynamic_index.vert_tess.8
dEQP-VK.clipping.user_defined.clip_cull_distance_dynamic_index.vert_tess.8_fragmentshader_read
```
SPIR-V file:
[tess_dyn_idx_clip_dist.spv.zip](https://github.com/KhronosGroup/SPIRV-Cross/files/7444848/tess_dyn_idx_clip_dist.spv.zip)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by examining the attached tess_dyn_idx_clip_dist.spv.zip and reproducing one of the listed dEQP-VK tessellation or clipping tests. Trace the MSL conversion that produces main0_in and flattened gl_ClipDistance_0, then determine whether dynamic access can be represented; done means the affected CTS cases no longer fail.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, computer-graphics
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100