-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPIR-V] Implement EvaluateAttribute* functions
Emits SPIR-V InterpolateAt* instructions from the GLSL.std.450 extended instruction set for EvaluateAttribute*. Relies on the optimizer's copy propagate passes to ensure that these instructions are passed valid pointers in the Input storage class after legalization. Fixes #3649
- Loading branch information
1 parent
d6d3f02
commit 75a9d72
Showing
7 changed files
with
197 additions
and
1 deletion.
There are no files selected for viewing
Submodule SPIRV-Tools
updated
3 files
+39 −2 | source/opt/trim_capabilities_pass.cpp | |
+4 −0 | source/opt/trim_capabilities_pass.h | |
+63 −0 | test/opt/trim_capabilities_pass_test.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tools/clang/test/CodeGenSPIRV/intrinsics.evaluate-attribute-at-sample.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv -Vd | FileCheck %s | ||
|
||
RWStructuredBuffer<float4> a; | ||
|
||
[[vk::ext_builtin_input(/* PointCoord */ 16)]] | ||
static const float2 gl_PointCoord; | ||
|
||
// CHECK: [[instSet:%[0-9]+]] = OpExtInstImport "GLSL.std.450" | ||
|
||
void setValue(float4 input); | ||
|
||
// CHECK: %src_main = OpFunction | ||
void main(float4 color : COLOR, float instance : SV_InstanceID) { | ||
// CHECK: [[val:%[0-9]+]] = OpLoad %v4float %color | ||
// CHECK: OpStore %temp_var_v4float [[val]] | ||
// CHECK: OpExtInst %v4float [[instSet]] InterpolateAtSample %temp_var_v4float %uint_0 | ||
a[0] = EvaluateAttributeAtSample(color, 0); | ||
|
||
setValue(color); | ||
|
||
// CHECK: [[val:%[0-9]+]] = OpLoad %v4float %c2 | ||
// CHECK: OpStore %temp_var_v4float_0 [[val]] | ||
// CHECK: OpExtInst %v4float [[instSet]] InterpolateAtSample %temp_var_v4float_0 %uint_2 | ||
float4 c2 = color; | ||
a[2] = EvaluateAttributeAtSample(c2, 2); | ||
|
||
// CHECK: [[val:%[0-9]+]] = OpLoad %float %instance | ||
// CHECK: OpStore %temp_var_float [[val]] | ||
// CHECK: OpExtInst %float [[instSet]] InterpolateAtSample %temp_var_float %uint_3 | ||
a[3] = EvaluateAttributeAtSample(instance, 3); | ||
|
||
// CHECK: [[val:%[0-9]+]] = OpLoad %v2float %gl_PointCoord | ||
// CHECK: OpStore %temp_var_v2float [[val]] | ||
// CHECK: OpExtInst %v2float [[instSet]] InterpolateAtSample %temp_var_v2float %uint_4 | ||
a[4] = float4(EvaluateAttributeAtSample(gl_PointCoord, 4), 0, 0); | ||
} | ||
|
||
// CHECK: %setValue = OpFunction | ||
void setValue(float4 input) { | ||
// CHECK: [[val:%[0-9]+]] = OpLoad %v4float %input | ||
// CHECK: OpStore %temp_var_v4float_1 [[val]] | ||
// CHECK: OpExtInst %v4float [[instSet]] InterpolateAtSample %temp_var_v4float_1 %uint_1 | ||
a[1] = EvaluateAttributeAtSample(input, 1); | ||
} |
45 changes: 45 additions & 0 deletions
45
tools/clang/test/CodeGenSPIRV/intrinsics.evaluate-attribute-centroid.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv -Vd | FileCheck %s | ||
|
||
RWStructuredBuffer<float4> a; | ||
|
||
[[vk::ext_builtin_input(/* PointCoord */ 16)]] | ||
static const float2 gl_PointCoord; | ||
|
||
// CHECK: [[instSet:%[0-9]+]] = OpExtInstImport "GLSL.std.450" | ||
|
||
void setValue(float4 input); | ||
|
||
// CHECK: %src_main = OpFunction | ||
void main(float4 color : COLOR, float instance : SV_InstanceID) { | ||
// CHECK: [[val:%[0-9]+]] = OpLoad %v4float %color | ||
// CHECK: OpStore %temp_var_v4float [[val]] | ||
// CHECK: OpExtInst %v4float [[instSet]] InterpolateAtCentroid %temp_var_v4float | ||
a[0] = EvaluateAttributeCentroid(color); | ||
|
||
setValue(color); | ||
|
||
// CHECK: [[val:%[0-9]+]] = OpLoad %v4float %c2 | ||
// CHECK: OpStore %temp_var_v4float_0 [[val]] | ||
// CHECK: OpExtInst %v4float [[instSet]] InterpolateAtCentroid %temp_var_v4float_0 | ||
float4 c2 = color; | ||
a[2] = EvaluateAttributeCentroid(c2); | ||
|
||
// CHECK: [[val:%[0-9]+]] = OpLoad %float %instance | ||
// CHECK: OpStore %temp_var_float [[val]] | ||
// CHECK: OpExtInst %float [[instSet]] InterpolateAtCentroid %temp_var_float | ||
a[3] = EvaluateAttributeCentroid(instance); | ||
|
||
// CHECK: [[val:%[0-9]+]] = OpLoad %v2float %gl_PointCoord | ||
// CHECK: OpStore %temp_var_v2float [[val]] | ||
// CHECK: OpExtInst %v2float [[instSet]] InterpolateAtCentroid %temp_var_v2float | ||
a[4] = float4(EvaluateAttributeCentroid(gl_PointCoord), 0, 0); | ||
} | ||
|
||
|
||
// CHECK: %setValue = OpFunction | ||
void setValue(float4 input) { | ||
// CHECK: [[val:%[0-9]+]] = OpLoad %v4float %input | ||
// CHECK: OpStore %temp_var_v4float_1 [[val]] | ||
// CHECK: OpExtInst %v4float [[instSet]] InterpolateAtCentroid %temp_var_v4float_1 | ||
a[1] = EvaluateAttributeCentroid(input); | ||
} |
55 changes: 55 additions & 0 deletions
55
tools/clang/test/CodeGenSPIRV/intrinsics.evaluate-attribute-snapped.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv -Vd | FileCheck %s | ||
|
||
RWStructuredBuffer<float4> a; | ||
|
||
[[vk::ext_builtin_input(/* PointCoord */ 16)]] | ||
static const float2 gl_PointCoord; | ||
|
||
// CHECK: [[instSet:%[0-9]+]] = OpExtInstImport "GLSL.std.450" | ||
|
||
// CHECK: [[v2int_0_0:%[0-9]+]] = OpConstantComposite %v2int %int_0 %int_0 | ||
// CHECK: [[v2int_2_2:%[0-9]+]] = OpConstantComposite %v2int %int_2 %int_2 | ||
// CHECK: [[v2int_3_3:%[0-9]+]] = OpConstantComposite %v2int %int_3 %int_3 | ||
// CHECK: [[v2int_4_4:%[0-9]+]] = OpConstantComposite %v2int %int_4 %int_4 | ||
// CHECK: [[v2int_1_1:%[0-9]+]] = OpConstantComposite %v2int %int_1 %int_1 | ||
|
||
void setValue(float4 input); | ||
|
||
// CHECK: %src_main = OpFunction | ||
void main(float4 color : COLOR, float instance : SV_InstanceID) { | ||
// CHECK: [[val:%[0-9]+]] = OpLoad %v4float %color | ||
// CHECK: OpStore %temp_var_v4float [[val]] | ||
// CHECK: [[offset:%[0-9]+]] = OpConvertSToF %v2float [[v2int_0_0]] | ||
// CHECK: OpExtInst %v4float [[instSet]] InterpolateAtOffset %temp_var_v4float [[offset]] | ||
a[0] = EvaluateAttributeSnapped(color, int2(0,0)); | ||
|
||
setValue(color); | ||
|
||
// CHECK: [[val:%[0-9]+]] = OpLoad %v4float %c2 | ||
// CHECK: OpStore %temp_var_v4float_0 [[val]] | ||
// CHECK: [[offset:%[0-9]+]] = OpConvertSToF %v2float [[v2int_2_2]] | ||
// CHECK: OpExtInst %v4float [[instSet]] InterpolateAtOffset %temp_var_v4float_0 [[offset]] | ||
float4 c2 = color; | ||
a[2] = EvaluateAttributeSnapped(c2, int2(2,2)); | ||
|
||
// CHECK: [[val:%[0-9]+]] = OpLoad %float %instance | ||
// CHECK: OpStore %temp_var_float [[val]] | ||
// CHECK: [[offset:%[0-9]+]] = OpConvertSToF %v2float [[v2int_3_3]] | ||
// CHECK: OpExtInst %float [[instSet]] InterpolateAtOffset %temp_var_float [[offset]] | ||
a[3] = EvaluateAttributeSnapped(instance, int2(3,3)); | ||
|
||
// CHECK: [[val:%[0-9]+]] = OpLoad %v2float %gl_PointCoord | ||
// CHECK: OpStore %temp_var_v2float [[val]] | ||
// CHECK: [[offset:%[0-9]+]] = OpConvertSToF %v2float [[v2int_4_4]] | ||
// CHECK: OpExtInst %v2float [[instSet]] InterpolateAtOffset %temp_var_v2float [[offset]] | ||
a[4] = float4(EvaluateAttributeSnapped(gl_PointCoord, int2(4, 4)), 0, 0); | ||
} | ||
|
||
// CHECK: %setValue = OpFunction | ||
void setValue(float4 input) { | ||
// CHECK: [[val:%[0-9]+]] = OpLoad %v4float %input | ||
// CHECK: OpStore %temp_var_v4float_1 [[val]] | ||
// CHECK: [[offset:%[0-9]+]] = OpConvertSToF %v2float [[v2int_1_1]] | ||
// CHECK: OpExtInst %v4float [[instSet]] InterpolateAtOffset %temp_var_v4float_1 [[offset]] | ||
a[1] = EvaluateAttributeSnapped(input, int2(1,1)); | ||
} |