[clang] [llvm] [HLSL] Add handling of Interpolation Modifiers (PR #225452)
Deric C. via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 15:55:46 PDT 2026
================
@@ -9384,6 +9384,31 @@ The full documentation is available here: <https://learn.microsoft.com/en-us/win
}];
}
+def HLSLInterpolationModifierDocs : Documentation {
+ let Category = DocCatVariable;
+ let Heading = "HLSL Interpolation Modifiers";
+ let Content = [{
+The HLSL keywords `nointerpolation`, `linear`, `centroid`,
+`noperspective`, `sample`, and `center` control interpolation of pixel
+shader inputs and vertex shader outputs.
+
+When applied to an aggregate type, the modifier propagates recursively to every
+scalar or vector of the type. A modifier on an inner field overrides one
+inherited from an enclosing declaration.
+
+`nointerpolation` cannot be combined with another interpolation modifier.
+For pixel shader inputs and vertex shader outputs, it cannot be used on
+`SV_Position`, and integer, boolean, and 64-bit floating-point components only
+support `nointerpolation`.
----------------
Icohedron wrote:
Should the [0047 proposal](https://github.com/llvm/wg-hlsl/blob/a7681e78c9219ee05170b3ea97e4dc9e6a12ca51/proposals/0047-semantic-signatures-metadata-schema.md) in wg-hlsl be updated to include this statement?
> For pixel shader inputs and vertex shader outputs, `nointerpolation` cannot be used on
`SV_Position`, and integer, boolean, and 64-bit floating-point components only
support `nointerpolation`.
Right now, [the wording in 0047](https://github.com/llvm/wg-hlsl/blob/a7681e78c9219ee05170b3ea97e4dc9e6a12ca51/proposals/0047-semantic-signatures-metadata-schema.md?plain=1#L302-L303) seems to imply that `nointerpolation` can not be used on *any* integer, boolean, or 64-bit floating-point:
> - Error: Any non-`nointerpolation` modifier on integer, boolean and 64-bit
floating point
Which would imply something like this is invalid:
```hlsl
linear uint helper() { return 1; } // use of `linear` on a `uint`
struct VSOut {
float4 position : SV_Position;
centroid float value : TEXCOORD0;
};
VSOut vs(float4 position : POSITION) {
VSOut output;
output.position = position;
output.value = position.x + helper();
return output;
}
```
but it is valid according to this current PR implementation, and DXC (https://hlsl.godbolt.org/z/Mb6x54n7x)
https://github.com/llvm/llvm-project/pull/225452
More information about the llvm-commits
mailing list