blob: 8faf6243ff739d96be0859219f0c5dce28143bd6 [file] [log] [blame]
[require]
VK_KHR_spirv_1_4
VK_KHR_variable_pointers
VariablePointerFeatures.variablePointersStorageBuffer
VK_KHR_storage_buffer_storage_class
VK_KHR_get_physical_device_properties2
[compute shader spirv]
; Test operates on a SSBO (%in_var) containing a runtime array of an array of four ints.
; Size of the runtime array is passed another SSBO (%n_var).
; Each invocation writes out the result of OpPtrEqual
; for elements of the input runtime array to index 16 of the corresponding output
; variable. Pointers are based the gid'th element vs the zero'th element.
; Each invocation loops 4 times and writes out results each for
; OpPtrEqual. The pointers are the lid'th element of gid'th element of
; the runtime array vs the iteration count element of the gid'th element of
; the runtime array.
OpCapability Shader
OpCapability VariablePointersStorageBuffer
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main" %in_var %equal_var %n_var %lid_var %gid_var
OpExecutionMode %main LocalSize 4 1 1
OpDecorate %struct_4 Block
OpMemberDecorate %struct_4 0 Offset 0
OpDecorate %runtime_4 ArrayStride 16
OpDecorate %struct_17 Block
OpMemberDecorate %struct_17 0 Offset 0
OpDecorate %runtime_17 ArrayStride 68
OpDecorate %n_struct Block
OpMemberDecorate %n_struct 0 Offset 0
OpDecorate %array_4 ArrayStride 4
OpDecorate %array_17 ArrayStride 4
OpDecorate %in_var DescriptorSet 0
OpDecorate %in_var Binding 0
OpDecorate %equal_var DescriptorSet 0
OpDecorate %equal_var Binding 1
OpDecorate %n_var DescriptorSet 0
OpDecorate %n_var Binding 2
OpDecorate %lid_var BuiltIn LocalInvocationId
OpDecorate %gid_var BuiltIn WorkgroupId
%void = OpTypeVoid
%bool = OpTypeBool
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%int_1 = OpConstant %int 1
%int_4 = OpConstant %int 4
%int_16 = OpConstant %int 16
%int_17 = OpConstant %int 17
%int3 = OpTypeVector %int 3
%ptr_input_int3 = OpTypePointer Input %int3
%array_4 = OpTypeArray %int %int_4
%runtime_4 = OpTypeRuntimeArray %array_4
%struct_4 = OpTypeStruct %runtime_4
%ptr_struct_4 = OpTypePointer StorageBuffer %struct_4
%ptr_array_4 = OpTypePointer StorageBuffer %array_4
%array_17 = OpTypeArray %int %int_17
%runtime_17 = OpTypeRuntimeArray %array_17
%struct_17 = OpTypeStruct %runtime_17
%ptr_struct_17 = OpTypePointer StorageBuffer %struct_17
%ptr_array_17 = OpTypePointer StorageBuffer %array_17
%ptr_int = OpTypePointer StorageBuffer %int
%n_struct = OpTypeStruct %int
%ptr_n_struct = OpTypePointer Uniform %n_struct
%ptr_n = OpTypePointer Uniform %int
%in_var = OpVariable %ptr_struct_4 StorageBuffer
%equal_var = OpVariable %ptr_struct_17 StorageBuffer
%n_var = OpVariable %ptr_n_struct Uniform
%lid_var = OpVariable %ptr_input_int3 Input
%gid_var = OpVariable %ptr_input_int3 Input
%void_fn = OpTypeFunction %void
%main = OpFunction %void None %void_fn
%entry = OpLabel
%n_gep = OpAccessChain %ptr_n %n_var %int_0
%n = OpLoad %int %n_gep
%gid = OpLoad %int3 %gid_var
%gid_x = OpCompositeExtract %int %gid 0
%lid = OpLoad %int3 %lid_var
%lid_x = OpCompositeExtract %int %lid 0
%array_gep_0 = OpAccessChain %ptr_array_4 %in_var %int_0 %int_0
%array_gep = OpAccessChain %ptr_array_4 %in_var %int_0 %gid_x
%cmp_gid = OpSGreaterThanEqual %bool %gid_x %n
OpSelectionMerge %body None
OpBranchConditional %cmp_gid %ret %body
%ret = OpLabel
OpReturn
%body = OpLabel
%cmp_lid = OpIEqual %bool %lid_x %int_1
OpSelectionMerge %loop None
OpBranchConditional %cmp_lid %then %loop
%then = OpLabel
; Compute results for outer array
%large_equal = OpPtrEqual %bool %array_gep %array_gep_0
%large_equal_gep = OpAccessChain %ptr_int %equal_var %int_0 %gid_x %int_16
%large_equal_int = OpSelect %int %large_equal %int_1 %int_0
OpStore %large_equal_gep %large_equal_int
;
OpBranch %loop
%loop = OpLabel
%i = OpPhi %int %int_0 %body %int_0 %then %inc_i %loop
%inc_i = OpIAdd %int %i %int_1
%i_cmp = OpIEqual %bool %inc_i %int_4
%lid_offset = OpIMul %int %lid_x %int_4
%gep_offset = OpIAdd %int %lid_offset %i
; Compute results for inner array
%ref_gep = OpAccessChain %ptr_int %array_gep %lid_x
%cmp_gep = OpAccessChain %ptr_int %array_gep %i
%equal = OpPtrEqual %bool %ref_gep %cmp_gep
%equal_int = OpSelect %int %equal %int_1 %int_0
%equal_gep = OpAccessChain %ptr_int %equal_var %int_0 %gid_x %gep_offset
OpStore %equal_gep %equal_int
;
OpLoopMerge %exit %loop None
OpBranchConditional %i_cmp %exit %loop
%exit = OpLabel
OpReturn
OpFunctionEnd
[test]
ssbo 0:0 2048
ssbo 0:1 2176
uniform ubo 0:2 int 0 32
compute entrypoint main
compute 32 1 1
#equal var
probe ssbo int 0:1 0 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1
probe ssbo int 0:1 68 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 136 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 204 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 272 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 340 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 408 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 476 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 544 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 612 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 680 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 748 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 816 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 884 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 952 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1020 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1088 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1156 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1224 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1292 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1360 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1428 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1496 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1564 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1632 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1700 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1768 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1836 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1904 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 1972 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 2040 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0
probe ssbo int 0:1 2108 == 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0