| [require] |
| VK_KHR_spirv_1_4 |
| VK_KHR_variable_pointers |
| VariablePointerFeatures.variablePointersStorageBuffer |
| VariablePointerFeatures.variablePointers |
| VK_KHR_storage_buffer_storage_class |
| VK_KHR_get_physical_device_properties2 |
| |
| [compute shader spirv] |
| ; Tests pointer comparisons with variable pointers |
| |
| ; Stores an array of pointers in Function storage class that point into input |
| ; SSBO. Each iteration produces an OpPtrNotEqual comparison. Pointers evolve by |
| ; incrementing or decrementing by 1 each iteration (overall ratio is 2:1). |
| |
| OpCapability Shader |
| OpCapability VariablePointers |
| OpMemoryModel Logical GLSL450 |
| OpEntryPoint GLCompute %main "main" %in_var %out_var |
| OpExecutionMode %main LocalSize 1 1 1 |
| |
| OpDecorate %int_rta ArrayStride 4 |
| OpDecorate %in_struct Block |
| OpMemberDecorate %in_struct 0 Offset 0 |
| OpMemberDecorate %in_struct 1 Offset 4 |
| OpDecorate %in_var DescriptorSet 0 |
| OpDecorate %in_var Binding 0 |
| |
| OpDecorate %out_struct Block |
| OpMemberDecorate %out_struct 0 Offset 0 |
| OpDecorate %out_var DescriptorSet 0 |
| OpDecorate %out_var Binding 1 |
| |
| OpDecorate %ptr_ssbo_int ArrayStride 4 |
| |
| %void = OpTypeVoid |
| %bool = OpTypeBool |
| %uint = OpTypeInt 32 0 |
| %int = OpTypeInt 32 1 |
| %int_n1 = OpConstant %int -1 |
| %int_0 = OpConstant %int 0 |
| %int_1 = OpConstant %int 1 |
| %int_2 = OpConstant %int 2 |
| %int_3 = OpConstant %int 3 |
| |
| %int_rta = OpTypeRuntimeArray %int |
| %in_struct = OpTypeStruct %int %int_rta |
| %ptr_ssbo_in_struct = OpTypePointer StorageBuffer %in_struct |
| %in_var = OpVariable %ptr_ssbo_in_struct StorageBuffer |
| |
| %out_struct = OpTypeStruct %int_rta |
| %ptr_ssbo_out_struct = OpTypePointer StorageBuffer %out_struct |
| %out_var = OpVariable %ptr_ssbo_out_struct StorageBuffer |
| |
| %ptr_ssbo_int = OpTypePointer StorageBuffer %int |
| %array_ptr = OpTypeArray %ptr_ssbo_int %int_2 |
| %ptr_ptr = OpTypePointer Function %array_ptr |
| %ptr_func_ptr = OpTypePointer Function %ptr_ssbo_int |
| |
| %ptr_ssbo_n = OpTypePointer StorageBuffer %int |
| %void_fn = OpTypeFunction %void |
| %main = OpFunction %void None %void_fn |
| %entry = OpLabel |
| %var = OpVariable %ptr_ptr Function |
| %n_gep = OpAccessChain %ptr_ssbo_n %in_var %int_0 |
| %n = OpLoad %int %n_gep |
| %length = OpArrayLength %uint %in_var 1 |
| %length_div_2 = OpSDiv %int %length %int_2 |
| %mid_gep = OpAccessChain %ptr_ssbo_int %in_var %int_1 %length_div_2 |
| %func_gep_0 = OpAccessChain %ptr_func_ptr %var %int_0 |
| %func_gep_1 = OpAccessChain %ptr_func_ptr %var %int_1 |
| OpStore %func_gep_0 %mid_gep |
| OpStore %func_gep_1 %mid_gep |
| %cmp_n = OpSLessThanEqual %bool %n %int_0 |
| OpSelectionMerge %exit None |
| OpBranchConditional %cmp_n %exit %loop |
| |
| %loop = OpLabel |
| %i = OpPhi %int %int_0 %entry %inc_i %continue |
| %gep_0 = OpLoad %ptr_ssbo_int %func_gep_0 |
| %gep_1 = OpLoad %ptr_ssbo_int %func_gep_1 |
| %inc_i = OpIAdd %int %i %int_1 |
| |
| %not_equal = OpPtrNotEqual %bool %gep_0 %gep_1 |
| %not_equal_int = OpSelect %int %not_equal %int_1 %int_0 |
| %out_gep = OpAccessChain %ptr_ssbo_int %out_var %int_0 %i |
| OpStore %out_gep %not_equal_int |
| |
| OpLoopMerge %loop_exit %continue None |
| OpBranch %body |
| |
| %body = OpLabel |
| %i_mod_3 = OpSMod %int %i %int_3 |
| %cmp_vs_0 = OpIEqual %bool %i_mod_3 %int_0 |
| OpSelectionMerge %continue None |
| OpBranchConditional %cmp_vs_0 %then %else |
| |
| %then = OpLabel |
| %then_0_next = OpPtrAccessChain %ptr_ssbo_int %gep_0 %int_n1 |
| %then_1_next = OpPtrAccessChain %ptr_ssbo_int %gep_1 %int_1 |
| OpBranch %continue |
| %else = OpLabel |
| %else_0_next = OpPtrAccessChain %ptr_ssbo_int %gep_0 %int_1 |
| %else_1_next = OpPtrAccessChain %ptr_ssbo_int %gep_1 %int_n1 |
| OpBranch %continue |
| |
| %continue = OpLabel |
| %next_0 = OpPhi %ptr_ssbo_int %then_0_next %then %else_0_next %else |
| %next_1 = OpPhi %ptr_ssbo_int %then_1_next %then %else_1_next %else |
| OpStore %func_gep_0 %next_0 |
| OpStore %func_gep_1 %next_1 |
| %cmp = OpSGreaterThanEqual %bool %i %n |
| OpBranchConditional %cmp %loop_exit %loop |
| |
| %loop_exit = OpLabel |
| OpBranch %exit |
| %exit = OpLabel |
| OpReturn |
| OpFunctionEnd |
| |
| [test] |
| ssbo 0:0 68 |
| ssbo 0:0 subdata uint 0 16 |
| ssbo 0:1 64 |
| |
| compute entrypoint main |
| compute 1 1 1 |
| |
| probe ssbo uint 0:1 0 == 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 |
| |
| |