Skip to content

Commit d2f2aae

Browse files
authored
[SPIRV] Stop running ReplaceInvalidOpcPass (microsoft#7138)
That pass was intended to remove derivative instructions used in non-fragment shaders. Now they are available in more places because of new extensions. In general, it is better practice to issue an error if they are used in an place they are not allowed. Fixes microsoft#7086
1 parent 6b68f3b commit d2f2aae

11 files changed

+22
-13
lines changed

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15219,7 +15219,6 @@ bool SpirvEmitter::spirvToolsLegalize(std::vector<uint32_t> *mod,
1521915219
optimizer.RegisterPass(
1522015220
spvtools::CreateAggressiveDCEPass(spirvOptions.preserveInterface));
1522115221
}
15222-
optimizer.RegisterPass(spvtools::CreateReplaceInvalidOpcodePass());
1522315222
optimizer.RegisterPass(spvtools::CreateCompactIdsPass());
1522415223
optimizer.RegisterPass(spvtools::CreateSpreadVolatileSemanticsPass());
1522515224
if (spirvOptions.fixFuncCallArguments) {

tools/clang/test/CodeGenSPIRV/texture.calculate.lod.compute.linear.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives -fcgl %s -spirv 2>&1 | FileCheck %s --check-prefix=CHECK
2+
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives %s -spirv 2>&1 | FileCheck %s --check-prefix=CHECK
23

34
// CHECK: OpCapability ComputeDerivativeGroupLinearKHR
45
// CHECK: OpExtension "SPV_NV_compute_shader_derivatives"
@@ -19,4 +20,4 @@ void main(uint3 id : SV_GroupThreadID)
1920
//CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQueryLod %v2float [[si1]] %float_0_5
2021
//CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query1]] 0
2122
o[0] = t1.CalculateLevelOfDetail(ss, 0.5);
22-
}
23+
}

tools/clang/test/CodeGenSPIRV/texture.calculate.lod.compute.quad.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives -fcgl %s -spirv 2>&1 | FileCheck %s
2+
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives %s -spirv 2>&1 | FileCheck %s
23

34
// CHECK: OpCapability ComputeDerivativeGroupQuadsKHR
45
// CHECK: OpExtension "SPV_NV_compute_shader_derivatives"
@@ -19,4 +20,4 @@ void main(uint3 id : SV_GroupThreadID)
1920
//CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQueryLod %v2float [[si1]] %float_0_5
2021
//CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query1]] 0
2122
o[0] = t1.CalculateLevelOfDetail(ss, 0.5);
22-
}
23+
}

tools/clang/test/CodeGenSPIRV/texture.calculate.lod.unclamped.compute.linear.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives -fcgl %s -spirv 2>&1 | FileCheck %s
2+
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives %s -spirv 2>&1 | FileCheck %s
23

34
// CHECK: OpCapability ComputeDerivativeGroupLinearKHR
45
// CHECK: OpExtension "SPV_NV_compute_shader_derivatives"
@@ -19,4 +20,4 @@ void main(uint3 id : SV_GroupThreadID)
1920
//CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQueryLod %v2float [[si1]] %float_0_5
2021
//CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query1]] 1
2122
o[0] = t1.CalculateLevelOfDetailUnclamped(ss, 0.5);
22-
}
23+
}

tools/clang/test/CodeGenSPIRV/texture.calculate.lod.unclamped.compute.quad.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives -fcgl %s -spirv 2>&1 | FileCheck %s
2+
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives %s -spirv 2>&1 | FileCheck %s
23

34
// CHECK: OpCapability ComputeDerivativeGroupQuadsKHR
45
// CHECK: OpExtension "SPV_NV_compute_shader_derivatives"
@@ -19,4 +20,4 @@ void main(uint3 id : SV_GroupThreadID)
1920
//CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQueryLod %v2float [[si1]] %float_0_5
2021
//CHECK-NEXT: {{%[0-9]+}} = OpCompositeExtract %float [[query1]] 1
2122
o[0] = t1.CalculateLevelOfDetailUnclamped(ss, 0.5);
22-
}
23+
}

tools/clang/test/CodeGenSPIRV/texture.sample.compute.linear.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives -fcgl %s -spirv 2>&1 | FileCheck %s
2+
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives %s -spirv 2>&1 | FileCheck %s
23

34
// CHECK: OpCapability ComputeDerivativeGroupLinearKHR
45
// CHECK: OpExtension "SPV_NV_compute_shader_derivatives"
@@ -18,4 +19,4 @@ void main(uint3 id : SV_GroupThreadID)
1819
// CHECK-NEXT: [[sampledImg:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1]] [[ss]]
1920
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleImplicitLod %v4float [[sampledImg]] %float_1 None
2021
o[0] = t1.Sample(ss, 1);
21-
}
22+
}

tools/clang/test/CodeGenSPIRV/texture.sample.compute.quad.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives -fcgl %s -spirv 2>&1 | FileCheck %s
2+
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives %s -spirv 2>&1 | FileCheck %s
23

34
// CHECK: OpCapability ComputeDerivativeGroupQuadsKHR
45
// CHECK: OpExtension "SPV_NV_compute_shader_derivatives"
@@ -18,4 +19,4 @@ void main(uint3 id : SV_GroupThreadID)
1819
// CHECK-NEXT: [[sampledImg:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1]] [[ss]]
1920
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleImplicitLod %v4float [[sampledImg]] %float_1 None
2021
o[0] = t1.Sample(ss, 1);
21-
}
22+
}

tools/clang/test/CodeGenSPIRV/texture.samplebias.compute.linear.hlsl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives -fcgl %s -spirv 2>&1 | FileCheck %s
1+
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives %s -spirv 2>&1 | FileCheck %s
22

33
// CHECK: OpCapability ComputeDerivativeGroupLinearKHR
44
// CHECK: OpExtension "SPV_NV_compute_shader_derivatives"
@@ -13,9 +13,10 @@ Texture1D <float> t1;
1313
[numthreads(8,1,1)]
1414
void main(uint3 id : SV_GroupThreadID)
1515
{
16+
Texture1D<float> local_texture = t1;
1617
// CHECK: [[t1:%[0-9]+]] = OpLoad %type_1d_image %t1
1718
// CHECK-NEXT: [[ss:%[0-9]+]] = OpLoad %type_sampler %ss
1819
// CHECK-NEXT: [[sampledImg:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1]] [[ss]]
1920
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleImplicitLod %v4float [[sampledImg]] %float_1 Bias %float_0_5
20-
o[0] = t1.SampleBias(ss, 1, 0.5);
21-
}
21+
o[0] = local_texture.SampleBias(ss, 1, 0.5);
22+
}

tools/clang/test/CodeGenSPIRV/texture.samplebias.compute.quad.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives -fcgl %s -spirv 2>&1 | FileCheck %s
2+
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives %s -spirv 2>&1 | FileCheck %s
23

34
// CHECK: OpCapability ComputeDerivativeGroupQuadsKHR
45
// CHECK: OpExtension "SPV_NV_compute_shader_derivatives"
@@ -18,4 +19,4 @@ void main(uint3 id : SV_GroupThreadID)
1819
// CHECK-NEXT: [[sampledImg:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1]] [[ss]]
1920
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleImplicitLod %v4float [[sampledImg]] %float_1 Bias %float_0_5
2021
o[0] = t1.SampleBias(ss, 1, 0.5);
21-
}
22+
}

tools/clang/test/CodeGenSPIRV/texture.samplecmp.compute.linear.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives -fcgl %s -spirv 2>&1 | FileCheck %s
2+
// RUN: %dxc -T cs_6_6 -E main -fspv-extension=SPV_NV_compute_shader_derivatives %s -spirv 2>&1 | FileCheck %s
23

34
// CHECK: OpCapability ComputeDerivativeGroupLinearKHR
45
// CHECK: OpExtension "SPV_NV_compute_shader_derivatives"
@@ -18,4 +19,4 @@ void main(uint3 id : SV_GroupThreadID)
1819
// CHECK-NEXT: [[sampledImg:%[0-9]+]] = OpSampledImage %type_sampled_image [[t1]] [[scs]]
1920
// CHECK-NEXT: {{%[0-9]+}} = OpImageSampleDrefImplicitLod %float [[sampledImg]] %float_1 %float_0_5
2021
o[0] = t1.SampleCmp(scs, 1, 0.5);
21-
}
22+
}

0 commit comments

Comments
 (0)