add SPIR-V 1.4 testing for various miscellaneous additions (#2122)

This PR adds targeted testing for a few remaining miscellaneous SPIR-V
1.4 features:

* Variables in the Function storage class can have a NonWriteable
decoration.
* OpCopyMemorySized can have two optional memory operands.
* OpSelect can have composite operands that are not vectors.
This commit is contained in:
Ben Ashbaugh
2024-11-11 12:39:00 -08:00
committed by GitHub
parent 10130a1261
commit b149060d52
7 changed files with 349 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
; SPIR-V
; Version: 1.4
OpCapability Addresses
OpCapability Kernel
OpMemoryModel Physical32 OpenCL
OpEntryPoint Kernel %kernel "copymemory_test"
%uint = OpTypeInt 32 0
%void = OpTypeVoid
%gptr_int = OpTypePointer CrossWorkgroup %uint
%pptr_int = OpTypePointer Function %uint
%kernel_sig = OpTypeFunction %void %gptr_int
%uint_42 = OpConstant %uint 42
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%uint_3 = OpConstant %uint 3
%uint_4 = OpConstant %uint 4
%uint_5 = OpConstant %uint 5
%kernel = OpFunction %void None %kernel_sig
%dst = OpFunctionParameter %gptr_int
%entry = OpLabel
%pvalue = OpVariable %pptr_int Function %uint_42
OpCopyMemory %dst %pvalue ; no memory operands
%dst1 = OpInBoundsPtrAccessChain %gptr_int %dst %uint_1
OpCopyMemory %dst1 %pvalue Volatile ; one memory operand
%dst2 = OpInBoundsPtrAccessChain %gptr_int %dst %uint_2
OpCopyMemory %dst2 %pvalue Volatile Volatile ; two memory operands
%dst3 = OpInBoundsPtrAccessChain %gptr_int %dst %uint_3
OpCopyMemorySized %dst3 %pvalue %uint_4 ; no memory operands
%dst4 = OpInBoundsPtrAccessChain %gptr_int %dst %uint_4
OpCopyMemorySized %dst4 %pvalue %uint_4 Volatile ; one memory operand
%dst5 = OpInBoundsPtrAccessChain %gptr_int %dst %uint_5
OpCopyMemorySized %dst5 %pvalue %uint_4 Volatile Volatile ; two memory operands
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,36 @@
; SPIR-V
; Version: 1.4
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %kernel "copymemory_test"
%uint = OpTypeInt 32 0
%ulong = OpTypeInt 64 0
%void = OpTypeVoid
%gptr_int = OpTypePointer CrossWorkgroup %uint
%pptr_int = OpTypePointer Function %uint
%kernel_sig = OpTypeFunction %void %gptr_int
%uint_42 = OpConstant %uint 42
%ulong_1 = OpConstant %ulong 1
%ulong_2 = OpConstant %ulong 2
%ulong_3 = OpConstant %ulong 3
%ulong_4 = OpConstant %ulong 4
%ulong_5 = OpConstant %ulong 5
%kernel = OpFunction %void None %kernel_sig
%dst = OpFunctionParameter %gptr_int
%entry = OpLabel
%pvalue = OpVariable %pptr_int Function %uint_42
OpCopyMemory %dst %pvalue ; no memory operands
%dst1 = OpInBoundsPtrAccessChain %gptr_int %dst %ulong_1
OpCopyMemory %dst1 %pvalue Volatile ; one memory operand
%dst2 = OpInBoundsPtrAccessChain %gptr_int %dst %ulong_2
OpCopyMemory %dst2 %pvalue Volatile Volatile ; two memory operands
%dst3 = OpInBoundsPtrAccessChain %gptr_int %dst %ulong_3
OpCopyMemorySized %dst3 %pvalue %ulong_4 ; no memory operands
%dst4 = OpInBoundsPtrAccessChain %gptr_int %dst %ulong_4
OpCopyMemorySized %dst4 %pvalue %ulong_4 Volatile ; one memory operand
%dst5 = OpInBoundsPtrAccessChain %gptr_int %dst %ulong_5
OpCopyMemorySized %dst5 %pvalue %ulong_4 Volatile Volatile ; two memory operands
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,21 @@
; SPIR-V
; Version: 1.4
OpCapability Addresses
OpCapability Kernel
OpMemoryModel Physical32 OpenCL
OpEntryPoint Kernel %kernel "nonwriteable_test"
OpDecorate %pvalue NonWritable
%uint = OpTypeInt 32 0
%void = OpTypeVoid
%gptr_int = OpTypePointer CrossWorkgroup %uint
%pptr_int = OpTypePointer Function %uint
%kernel_sig = OpTypeFunction %void %gptr_int
%uint_42 = OpConstant %uint 42
%kernel = OpFunction %void None %kernel_sig
%dst = OpFunctionParameter %gptr_int
%entry = OpLabel
%pvalue = OpVariable %pptr_int Function %uint_42
%value = OpLoad %uint %pvalue
OpStore %dst %value
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,21 @@
; SPIR-V
; Version: 1.4
OpCapability Addresses
OpCapability Kernel
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %kernel "nonwriteable_test"
OpDecorate %pvalue NonWritable
%uint = OpTypeInt 32 0
%void = OpTypeVoid
%gptr_int = OpTypePointer CrossWorkgroup %uint
%pptr_int = OpTypePointer Function %uint
%kernel_sig = OpTypeFunction %void %gptr_int
%uint_42 = OpConstant %uint 42
%kernel = OpFunction %void None %kernel_sig
%dst = OpFunctionParameter %gptr_int
%entry = OpLabel
%pvalue = OpVariable %pptr_int Function %uint_42
%value = OpLoad %uint %pvalue
OpStore %dst %value
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,38 @@
; SPIR-V
; Version: 1.4
OpCapability Addresses
OpCapability Kernel
OpMemoryModel Physical32 OpenCL
OpEntryPoint Kernel %kernel "select_struct_test" %pgid
OpDecorate %pgid BuiltIn GlobalInvocationId
OpDecorate %pgid Constant
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%float = OpTypeFloat 32
%void = OpTypeVoid
%bool = OpTypeBool
%struct = OpTypeStruct %uint %float
%gptr_struct = OpTypePointer CrossWorkgroup %struct
%iptr_v3uint = OpTypePointer Input %v3uint
%kernel_sig = OpTypeFunction %void %gptr_struct
%uint_0 = OpConstant %uint 0
%uint_1 = OpConstant %uint 1
%uint_1024 = OpConstant %uint 1024
%float_pi = OpConstant %float 3.1415
%uint_2048 = OpConstant %uint 2048
%float_e = OpConstant %float 2.7128
%struct_a = OpConstantComposite %struct %uint_1024 %float_pi
%struct_b = OpConstantComposite %struct %uint_2048 %float_e
%pgid = OpVariable %iptr_v3uint Input
%kernel = OpFunction %void None %kernel_sig
%dst_base = OpFunctionParameter %gptr_struct
%entry = OpLabel
%gid = OpLoad %v3uint %pgid Aligned 32
%gid0 = OpCompositeExtract %uint %gid 0
%test = OpBitwiseAnd %uint %gid0 %uint_1
%cond = OpIEqual %bool %test %uint_1
%result = OpSelect %struct %cond %struct_a %struct_b
%dst = OpInBoundsPtrAccessChain %gptr_struct %dst_base %gid0
OpStore %dst %result
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,40 @@
; SPIR-V
; Version: 1.4
OpCapability Addresses
OpCapability Kernel
OpCapability Int64
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %kernel "select_struct_test" %pgid
OpDecorate %pgid BuiltIn GlobalInvocationId
OpDecorate %pgid Constant
%uint = OpTypeInt 32 0
%ulong = OpTypeInt 64 0
%v3ulong = OpTypeVector %ulong 3
%float = OpTypeFloat 32
%void = OpTypeVoid
%bool = OpTypeBool
%struct = OpTypeStruct %uint %float
%gptr_struct = OpTypePointer CrossWorkgroup %struct
%iptr_v3ulong = OpTypePointer Input %v3ulong
%kernel_sig = OpTypeFunction %void %gptr_struct
%ulong_0 = OpConstant %ulong 0
%ulong_1 = OpConstant %ulong 1
%uint_1024 = OpConstant %uint 1024
%float_pi = OpConstant %float 3.1415
%uint_2048 = OpConstant %uint 2048
%float_e = OpConstant %float 2.7128
%struct_a = OpConstantComposite %struct %uint_1024 %float_pi
%struct_b = OpConstantComposite %struct %uint_2048 %float_e
%pgid = OpVariable %iptr_v3ulong Input
%kernel = OpFunction %void None %kernel_sig
%dst_base = OpFunctionParameter %gptr_struct
%entry = OpLabel
%gid = OpLoad %v3ulong %pgid Aligned 32
%gid0 = OpCompositeExtract %ulong %gid 0
%test = OpBitwiseAnd %ulong %gid0 %ulong_1
%cond = OpIEqual %bool %test %ulong_1
%result = OpSelect %struct %cond %struct_a %struct_b
%dst = OpInBoundsPtrAccessChain %gptr_struct %dst_base %gid0
OpStore %dst %result
OpReturn
OpFunctionEnd