From 13ff0bd345990c0fdfb7b52ebd5339cddb04889e Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 3 Mar 2021 11:45:39 -0800 Subject: Add GLSL/SPIR-V support got GetAttributeAtVertex (#1733) This change allows varying fragment shader inputs to be declared in a way that allows the `GetAttributeAtVertex` operation to compile to valid code for both D3D and GLSL/SPIR-V/Vulkan. The key is that rather than just use ordinary `nointerpolation`-qualified inputs the code must declare these varying inputs with a new `pervertex` qualifier that marks them as *only* being usable with `GetAttributeAtVertex`. The `pervertex`-tagged inputs then translate to GLSL inputs using the `pervertexNV` qualifier Note that this change does *not* include any enforcement of the requirements around how these qualifiers are used (and the compiler doesn't have enforcement for the existing operations like `EvaluateAttributeAtCentroid`). The underlying problem is that the inerpolation-mode qualifiers and explicit interpolation functions in HLSL constitute a kind of rate-qualified type system, but without any systematic rules. It seems wasteful to encode a bunch of ad hoc rules for this stuff as special cases in the compiler when the clear right answer is to implement a systematic approach to rates. --- source/slang/core.meta.slang | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/slang/core.meta.slang') diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index de78229a9..39ee702c6 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -17,6 +17,16 @@ syntax constexpr : ConstExprModifier; // visible at the global-memory scope syntax globallycoherent : GloballyCoherentModifier; +/// Modifier to disable inteprolation and force per-vertex passing of a varying attribute. +/// +/// When a varying attribute passed to the fragment shader is marked `pervertex`, it will +/// not be interpolated during rasterization (similar to `nointerpolate` attributes). +/// Unlike a plain `nointerpolate` attribute, this modifier indicates that the attribute +/// should *only* be acccessed through the `GetAttributeAtVertex()` operation, so access its +/// distinct per-vertex values. +/// +syntax pervertex : PerVertexModifier; + // A type that can be used as an operand for builtins [sealed] [builtin] -- cgit v1.2.3