diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2021-03-03 11:45:39 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-03 11:45:39 -0800 |
| commit | 13ff0bd345990c0fdfb7b52ebd5339cddb04889e (patch) | |
| tree | ae3773d4f3475439a55603007b3908e31c6c31fb /tests/pipeline | |
| parent | d6ae67160c33460bf952c9959077dc481a16eca2 (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 'tests/pipeline')
| -rw-r--r-- | tests/pipeline/rasterization/get-attribute-at-vertex.slang | 3 | ||||
| -rw-r--r-- | tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl | 25 |
2 files changed, 27 insertions, 1 deletions
diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex.slang b/tests/pipeline/rasterization/get-attribute-at-vertex.slang index 56fbcce78..87d39c806 100644 --- a/tests/pipeline/rasterization/get-attribute-at-vertex.slang +++ b/tests/pipeline/rasterization/get-attribute-at-vertex.slang @@ -3,10 +3,11 @@ // Basic test for `GetAttributeAtVertex` function //TEST:CROSS_COMPILE:-target dxil -entry main -stage fragment -profile sm_6_1 +//TEST:CROSS_COMPILE:-target spirv -entry main -stage fragment -profile glsl_450 [shader("fragment")] void main( - nointerpolation float4 color : COLOR, + pervertex float4 color : COLOR, float3 bary : SV_Barycentrics, out float4 result : SV_Target) { diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl b/tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl new file mode 100644 index 000000000..c07e9b61c --- /dev/null +++ b/tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl @@ -0,0 +1,25 @@ +// get-attribute-at-vertex.slang.glsl +//TEST_IGNORE_FILE: + +#version 450 + +#extension GL_NV_fragment_shader_barycentric : require + +pervertexNV layout(location = 0) +in vec4 _S1[3]; + +layout(location = 0) +out vec4 _S2; + +void main() +{ + vec4 _S3; + + _S3 = gl_BaryCoordNV.x * _S1[0] + + gl_BaryCoordNV.y * _S1[1] + + gl_BaryCoordNV.z * _S1[2]; + + _S2 = _S3; + + return; +} |
