================
@@ -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`.
+
+Unqualified pixel shader inputs and vertex shader outputs default to `linear`
+for floating-point components of at most 32 bits and `nointerpolation` 
otherwise.
+`SV_Position` uses the corresponding `noperspective` mode. Vertex shader 
inputs,
+pixel shader outputs, and signatures in other shader stages have no
+interpolation mode; their interpolation modifiers are ignored.
----------------
Icohedron wrote:

This states that the interpolation mode defaults to `linear` for floats and 
`nointerpolation` otherwise for pixel shader inputs and vertex shader outputs.

However, [wg-hlsl proposal 
0047](https://github.com/llvm/wg-hlsl/blob/a7681e78c9219ee05170b3ea97e4dc9e6a12ca51/proposals/0047-semantic-signatures-metadata-schema.md?plain=1#L337-L345)
 states to "normalize" interpolation modes by performing these steps in order:

> Then the interpolation mode is "normalized" as follows:
> 1. If the mode is `Undefined`, set it based on the component type:
   `Linear` for 32-bit-or-smaller floating-point leaves, `Constant`
   otherwise.
> 2. Promote an `SV_Position` interpolation mode into the corresponding
   `noperspective` variant of its current mode (`Linear` →
   `LinearNoperspective`, `LinearCentroid` → `LinearNoperspectiveCentroid`,
   `LinearSample` → `LinearNoperspectiveSample`).
> 3. Finally, if the entry function is not a pixel shader then it is set to
   `Undefined`

The problem is that step 3's setting of `Undefined` is conditioned only on the 
entry function not being a pixel shader. So in this example:
```hlsl
linear uint helper() { return 1; }
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;
}
```

Step 3 states that both `SV_Position`s `noperspective` and `TEXCOORD0`s 
`centroid` should be overwritten with `Undefined` because this is a not a pixel 
shader.

https://github.com/llvm/llvm-project/pull/225452
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to