summaryrefslogtreecommitdiff
path: root/source/slang/hlsl.meta.slang
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2021-03-03 11:45:39 -0800
committerGitHub <noreply@github.com>2021-03-03 11:45:39 -0800
commit13ff0bd345990c0fdfb7b52ebd5339cddb04889e (patch)
treeae3773d4f3475439a55603007b3908e31c6c31fb /source/slang/hlsl.meta.slang
parentd6ae67160c33460bf952c9959077dc481a16eca2 (diff)
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.
Diffstat (limited to 'source/slang/hlsl.meta.slang')
-rw-r--r--source/slang/hlsl.meta.slang12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index adbe6f9c8..77b371662 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -1821,6 +1821,10 @@ matrix<T, N, M> fwidth(matrix<T, N, M> x)
///
__generic<T : __BuiltinType>
[__readNone]
+__target_intrinsic(hlsl)
+__target_intrinsic(glsl, "$0[$1]")
+__glsl_version(450)
+__glsl_extension(GL_NV_fragment_shader_barycentric)
T GetAttributeAtVertex(T attribute, uint vertexIndex);
/// Get the value of a vertex attribute at a specific vertex.
@@ -1839,6 +1843,10 @@ T GetAttributeAtVertex(T attribute, uint vertexIndex);
///
__generic<T : __BuiltinType, let N : int>
[__readNone]
+__target_intrinsic(hlsl)
+__target_intrinsic(glsl, "$0[$1]")
+__glsl_version(450)
+__glsl_extension(GL_NV_fragment_shader_barycentric)
vector<T,N> GetAttributeAtVertex(vector<T,N> attribute, uint vertexIndex);
/// Get the value of a vertex attribute at a specific vertex.
@@ -1857,6 +1865,10 @@ vector<T,N> GetAttributeAtVertex(vector<T,N> attribute, uint vertexIndex);
///
__generic<T : __BuiltinType, let N : int, let M : int>
[__readNone]
+__target_intrinsic(hlsl)
+__target_intrinsic(glsl, "$0[$1]")
+__glsl_version(450)
+__glsl_extension(GL_NV_fragment_shader_barycentric)
matrix<T,N,M> GetAttributeAtVertex(matrix<T,N,M> attribute, uint vertexIndex);