From cfe78891a07622eb166be8ca4977da3795af4757 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Tue, 17 Sep 2024 13:22:16 -0400 Subject: [PATCH] Check spir-v version --- tools/clang/lib/Headers/hlsl/vk/khr/cooperative_matrix.h | 4 ++++ tools/clang/test/CodeGenSPIRV/coopmatrix.old.spirv.hlsl | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 tools/clang/test/CodeGenSPIRV/coopmatrix.old.spirv.hlsl diff --git a/tools/clang/lib/Headers/hlsl/vk/khr/cooperative_matrix.h b/tools/clang/lib/Headers/hlsl/vk/khr/cooperative_matrix.h index e40502bb5f..603314d3be 100644 --- a/tools/clang/lib/Headers/hlsl/vk/khr/cooperative_matrix.h +++ b/tools/clang/lib/Headers/hlsl/vk/khr/cooperative_matrix.h @@ -10,6 +10,10 @@ // TODO: Add a macro to HLSL to be able to check the Vulkan version being // targeted. +#if __SPIRV_MAJOR_VERSION__ == 1 && __SPIRV_MINOR_VERSION__ < 6 +#error "CooperativeMatrix requires a minimum of SPIR-V 1.6" +#endif + #include "vk/spirv.h" namespace vk { diff --git a/tools/clang/test/CodeGenSPIRV/coopmatrix.old.spirv.hlsl b/tools/clang/test/CodeGenSPIRV/coopmatrix.old.spirv.hlsl new file mode 100644 index 0000000000..72ba1c2bae --- /dev/null +++ b/tools/clang/test/CodeGenSPIRV/coopmatrix.old.spirv.hlsl @@ -0,0 +1,8 @@ +// RUN: not dxc -fspv-target-env=vulkan1.1 -T cs_6_0 -E main -spirv -HV 2021 -I %hlsl_headers -DTYPE=int %s 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INTEGERS --check-prefix=INT32 + +#include "vk/khr/cooperative_matrix.h" + +[numthreads(64, 1, 1)] void main() { +} + +// CHECK: error: "CooperativeMatrix requires a minimum of SPIR-V 1.6"