Skip to content

Conversation

Keenuts
Copy link
Contributor

@Keenuts Keenuts commented Aug 13, 2025

This commit depends on #152537 and #153224

This commit adds support for HLSL input semantics. User semantics are
all semantics not starting with SV_.
Those semantics ends up with a Location assignment in SPIR-V.

Note: user semantics means Location, but the opposite is not true. Depending on the stage, some system semantics can rely on a Location index. This is not implemented in this PR.

@Keenuts Keenuts requested a review from s-perron August 13, 2025 14:49
This commit adds the support for semantics annotations on structs, but
only for inputs. Due to the current semantics implemented, we cannot
test much more than nesting/shadowing.

Once user semantics are implemented, we'll be able to test arrays in
structs and more complex cases.

As-is, this commit has one weakness vs DXC: semantics type validation is
not looking at the inner-most type, but the outermost type:

```hlsl
struct Inner {
  uint tid;
};

Inner inner : SV_GroupID
```

This sample would fail today because `SV_GroupID` require the type to be
an integer. This works in DXC as the inner type is a integer.
Because GroupIndex is not correctly validated, I uses this semantic to
test the inheritance/shadowing. But this will need to be fixed in a
later commit.

Requires llvm#152537
The previous solution had a major drawback: if a stuct was used
by multiple entrypoints, we had conflicting attribute.

This commit moves the attribute to the function declaration:
 - each field with an active semantic will have a related attribute
   attached to the corresponding entrypoint.
   This means the semantic list is per-entrypoint.
This commit adds initial support for user semantics.
Those are generic cpp idenfier which translate differently
than system semantics.

Supporting user semantics will allows testing another side of
semantics: shadowing and implicit indices.
When a semantic is applied on a parent element (parameter or type
definition), the semantics on its children declarations are ignored.
Also, the semantic index is used to determine the index of the first
element, but increases with each array element or struct field.

See https://github.com/llvm/wg-hlsl/blob/main/proposals/0031-semantics.md
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.

1 participant