Skip to content
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

Legalize array size of SV_TessFactor and SV_InsideTessFactor #6409

Merged
merged 5 commits into from
Feb 25, 2025

Conversation

jkwak-work
Copy link
Collaborator

When targeting SPIR-V or GLSL, the type for SV_TessFactor must be float[4]; note that it is not a vector but an array. Similarly the type of SV_InsideTessFactor has to be an array of float[2].

When the user shader declare them as arrays smaller than the required size, Slang will legalize them to the required sizes.

Note that it is not the user mistake to declare floar[3] when the hull mode is in "tri", as an example. The unused components are expected to be ignored.

Note also that HLSL allows the type to be float[2|3|4] whereas GLSL and SPIR-V requires it to be always float[4].

Closes #6349

@jkwak-work jkwak-work added the pr: non-breaking PRs without breaking changes label Feb 20, 2025
@jkwak-work jkwak-work self-assigned this Feb 20, 2025
@jkwak-work jkwak-work requested a review from a team as a code owner February 20, 2025 08:14
@jkwak-work jkwak-work force-pushed the fix/tessellation_array_sizes branch 2 times, most recently from fa6556b to 2af7c77 Compare February 20, 2025 09:12
When targeting SPIR-V or GLSL, the type for SV_TessFactor must be
float[4]; note that it is not a vector but an array.
Similarly the type of SV_InsideTessFactor has to be an array of
float[2].

When the user shader declare them as arrays smaller than the required
size, Slang will legalize them to the required sizes.

Note that it is not the user mistake to declare floar[3] when the hull
mode is in "tri", as an example. The unused components are expected to
be ignored.

Note also that HLSL allows the type to be float[2|3|4] whereas GLSL and
SPIR-V requires it to be always float[4].
@jkwak-work jkwak-work force-pushed the fix/tessellation_array_sizes branch from 2af7c77 to 31329d7 Compare February 21, 2025 17:09
@csyonghe csyonghe merged commit 73a8d74 into shader-slang:master Feb 25, 2025
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle error case gracefully when SV_TessFactor is incorrectly used.
2 participants