1# Copyright 2018 The Amber Authors. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15[comment] 16Source code in GLSL: 17 18#version 430 19 20layout(set = 0, binding = 0) buffer block0 { 21 float data_set0_binding0[3]; 22}; 23 24layout(set = 1, binding = 2) buffer block1 { 25 float data_set1_binding2[3]; 26}; 27 28layout(set = 2, binding = 1) buffer block2 { 29 float data_set2_binding1[3]; 30}; 31 32layout(set = 2, binding = 3) buffer block3 { 33 float data_set2_binding3[3]; 34}; 35 36[compute shader spirv] 37; SPIR-V 38; Version: 1.0 39; Generator: Khronos Glslang Reference Front End; 7 40; Bound: 71 41; Schema: 0 42 OpCapability Shader 43 %1 = OpExtInstImport "GLSL.std.450" 44 OpMemoryModel Logical GLSL450 45 OpEntryPoint GLCompute %main "foo" %gl_WorkGroupID 46 OpExecutionMode %main LocalSize 1 1 1 47 OpSource GLSL 430 48 OpName %main "foo" 49 OpName %index "index" 50 OpName %gl_WorkGroupID "gl_WorkGroupID" 51 OpName %block0 "block0" 52 OpMemberName %block0 0 "data_set0_binding0" 53 OpName %_ "" 54 OpName %block1 "block1" 55 OpMemberName %block1 0 "data_set1_binding2" 56 OpName %__0 "" 57 OpName %block2 "block2" 58 OpMemberName %block2 0 "data_set2_binding1" 59 OpName %__1 "" 60 OpName %block3 "block3" 61 OpMemberName %block3 0 "data_set2_binding3" 62 OpName %__2 "" 63 OpDecorate %gl_WorkGroupID BuiltIn WorkgroupId 64 OpDecorate %_arr_float_uint_3 ArrayStride 4 65 OpMemberDecorate %block0 0 Offset 0 66 OpDecorate %block0 BufferBlock 67 OpDecorate %_ DescriptorSet 0 68 OpDecorate %_ Binding 0 69 OpDecorate %_arr_float_uint_3_0 ArrayStride 4 70 OpMemberDecorate %block1 0 Offset 0 71 OpDecorate %block1 BufferBlock 72 OpDecorate %__0 DescriptorSet 1 73 OpDecorate %__0 Binding 2 74 OpDecorate %_arr_float_uint_3_1 ArrayStride 4 75 OpMemberDecorate %block2 0 Offset 0 76 OpDecorate %block2 BufferBlock 77 OpDecorate %__1 DescriptorSet 2 78 OpDecorate %__1 Binding 1 79 OpDecorate %_arr_float_uint_3_2 ArrayStride 4 80 OpMemberDecorate %block3 0 Offset 0 81 OpDecorate %block3 BufferBlock 82 OpDecorate %__2 DescriptorSet 2 83 OpDecorate %__2 Binding 3 84 %void = OpTypeVoid 85 %3 = OpTypeFunction %void 86 %uint = OpTypeInt 32 0 87%_ptr_Function_uint = OpTypePointer Function %uint 88 %v3uint = OpTypeVector %uint 3 89%_ptr_Input_v3uint = OpTypePointer Input %v3uint 90%gl_WorkGroupID = OpVariable %_ptr_Input_v3uint Input 91 %uint_0 = OpConstant %uint 0 92%_ptr_Input_uint = OpTypePointer Input %uint 93 %float = OpTypeFloat 32 94 %uint_3 = OpConstant %uint 3 95%_arr_float_uint_3 = OpTypeArray %float %uint_3 96 %block0 = OpTypeStruct %_arr_float_uint_3 97%_ptr_Uniform_block0 = OpTypePointer Uniform %block0 98 %_ = OpVariable %_ptr_Uniform_block0 Uniform 99 %int = OpTypeInt 32 1 100 %int_0 = OpConstant %int 0 101%_ptr_Uniform_float = OpTypePointer Uniform %float 102 %float_1 = OpConstant %float 1 103%_arr_float_uint_3_0 = OpTypeArray %float %uint_3 104 %block1 = OpTypeStruct %_arr_float_uint_3_0 105%_ptr_Uniform_block1 = OpTypePointer Uniform %block1 106 %__0 = OpVariable %_ptr_Uniform_block1 Uniform 107%_arr_float_uint_3_1 = OpTypeArray %float %uint_3 108 %block2 = OpTypeStruct %_arr_float_uint_3_1 109%_ptr_Uniform_block2 = OpTypePointer Uniform %block2 110 %__1 = OpVariable %_ptr_Uniform_block2 Uniform 111 %float_10 = OpConstant %float 10 112%_arr_float_uint_3_2 = OpTypeArray %float %uint_3 113 %block3 = OpTypeStruct %_arr_float_uint_3_2 114%_ptr_Uniform_block3 = OpTypePointer Uniform %block3 115 %__2 = OpVariable %_ptr_Uniform_block3 Uniform 116 %float_30 = OpConstant %float 30 117 %main = OpFunction %void None %3 118 %5 = OpLabel 119 %index = OpVariable %_ptr_Function_uint Function 120 %14 = OpAccessChain %_ptr_Input_uint %gl_WorkGroupID %uint_0 121 %15 = OpLoad %uint %14 122 OpStore %index %15 123 %24 = OpLoad %uint %index 124 %25 = OpLoad %uint %index 125 %27 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %25 126 %28 = OpLoad %float %27 127 %30 = OpFAdd %float %28 %float_1 128 %31 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %24 129 OpStore %31 %30 130 %36 = OpLoad %uint %index 131 %41 = OpLoad %uint %index 132 %42 = OpAccessChain %_ptr_Uniform_float %__1 %int_0 %41 133 %43 = OpLoad %float %42 134 %44 = OpLoad %uint %index 135 %45 = OpAccessChain %_ptr_Uniform_float %__0 %int_0 %44 136 %46 = OpLoad %float %45 137 %47 = OpFSub %float %43 %46 138 %48 = OpAccessChain %_ptr_Uniform_float %__0 %int_0 %36 139 OpStore %48 %47 140 %49 = OpLoad %uint %index 141 %55 = OpLoad %uint %index 142 %56 = OpAccessChain %_ptr_Uniform_float %__2 %int_0 %55 143 %57 = OpLoad %float %56 144 %58 = OpFMul %float %float_10 %57 145 %59 = OpLoad %uint %index 146 %60 = OpAccessChain %_ptr_Uniform_float %__1 %int_0 %59 147 %61 = OpLoad %float %60 148 %62 = OpFAdd %float %58 %61 149 %63 = OpAccessChain %_ptr_Uniform_float %__1 %int_0 %49 150 OpStore %63 %62 151 %64 = OpLoad %uint %index 152 %66 = OpLoad %uint %index 153 %67 = OpAccessChain %_ptr_Uniform_float %__2 %int_0 %66 154 %68 = OpLoad %float %67 155 %69 = OpFMul %float %float_30 %68 156 %70 = OpAccessChain %_ptr_Uniform_float %__2 %int_0 %64 157 OpStore %70 %69 158 OpReturn 159 OpFunctionEnd 160[test] 161ssbo 0:0 subdata vec3 0 1.0 2.0 3.0 162ssbo 1:2 subdata vec3 0 4.0 5.0 6.0 163ssbo 2:1 subdata vec3 0 21.0 22.0 23.0 164ssbo 2:3 subdata vec3 0 0.7 0.8 0.9 165 166compute entrypoint foo 167 168compute 3 1 1 169 170probe ssbo vec3 0:0 0 ~= 2.0 3.0 4.0 171probe ssbo vec3 1:2 0 ~= 17.0 17.0 17.0 172probe ssbo vec3 2:1 0 ~= 28.0 30.0 32.0 173probe ssbo vec3 2:3 0 ~= 21.0 24.0 27.0 174