-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSL: Unable to dynamically access an incoming gl_ClipDistance
array under tessellation
#1796
Comments
Yes and no. In the fragment shader case, it is, because MSL doesn't allow arrays to be used for shader stage I/O, other than for the express purpose of outputting
Theoretically, yes. For fragment shaders, we could declare an array to hold the incoming clip distances and index that. For tessellation shaders, we could just declare the clip distances as an array, since it's just a regular buffer. Remapping the access chain in this case could be problematic. |
This is an absolute nightmare to handle. One way to handle this perhaps would be to think outside the box. If the cull/clip count can be limited to 4, we could read it as a float4 attribute, which allows us to index it properly. EDIT: Nah, minspec is 8 :\ |
However...if this was the most appropriate solution, then the portability extension could define and return the lower value of 4 for |
Just dumping some thoughts, unsure how feasible it could be. What about having the array decomposed into a structure with members and then building a local array in the next stage with said structure. I believe Metal should be okay with this? Example:
Metal equivalent
Same thing applies for the fragment, but the other way around, we need to first fill the local array. There's no real need to have a structure just for the array in GLSL and directly add the values to the output structure in Metal. While the approach may not be the best, it should be a good enough workaround at the cost of some performance. As of now, more tests than the ones mentioned in the original report of the issue are affected by this and make them fail (Vulkan 1.0 example):
Let me know your thoughts! |
I don't think that helps the tests that Aito mentioned? https://github.com/ncesario-lunarg/SPIRV-Cross/tree/issue-1796 is a very rough hack that attempts to address the general "indexing into an array with pull interpolants" problem. This is done by creating a new array for each interpolation operation seen, for each input array. This is obviously not ideal from a size and perf standpoint, but I'm not sure how one could fix this in general otherwise. The change referenced appears to get all of the tests posted here passing with the exception of tests that involve @HansKristian-Work if you get a chance to take a look, could you please advise on whether this approach is worth pursuing, or if you would rather go a different route here? |
This is a first attempt at fixing the test failures mentioned in KhronosGroup#1796 by copying scalarized/flattened arrays back into arrays in the fragment shader for each "unique" interpolate opration. This approach has as number of drawbacks such as negative impacts to runtime performance and shader size, as well as having limited coverage for dynamic offsets (InterpolateAtOffset) and samples (InterpolateAtSample).
This is a first attempt at fixing the test failures mentioned in KhronosGroup#1796 by copying scalarized/flattened arrays back into arrays in the fragment shader for each "unique" interpolate opration. This approach has as number of drawbacks such as negative impacts to runtime performance and shader size, as well as having limited coverage for dynamic offsets (InterpolateAtOffset) and samples (InterpolateAtSample).
FWIW... The 24 CTS failures in the OP above are no longer occurring. The 3 additional CTS failures that @aitor-lunarg added:
are still occurring, but report a different error:
|
Thanks for taking a look @billhollings. I must have had an old version of CTS and/or MoltenVK on my system as I'm pretty sure those were not passing when I first looked at this 🤷♂️ . This change is for the general case of passing arrays between shader stages. It fixes the "sample" and "centroid" cases Aitor referenced, but not the "offset" case. For the offset case (and in general), some constant propagation would do the trick, unless we could perhaps use something like spirv-opt in MoltenVK before passing the spirv to spirv-cross? |
SPIR-V conversion to MSL fails with error:
The attempt in GLSL results in
gl_in[0].gl_ClipDistance[_80]
, but in MSLmain0_in
, the incominggl_ClipDistance
array is flattened in tofloat 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? @cdavis5eThese CTS test fail as a result:
SPIR-V file:
tess_dyn_idx_clip_dist.spv.zip
The text was updated successfully, but these errors were encountered: