Tint/transform: make AddBlockAttribute always do wrapping if possible

This CL make transform AddBlockAttribute always try to wrap types used
by buffer variables into a struct, in order to generate valid GLSL code
for assigning one buffer struct variable to another buffer struct
variable.

Fixed: tint:1735
Change-Id: I009d8a9ca7ecea1dc0ad6164275c964a18acb33f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108023
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
This commit is contained in:
Zhaoming Jiang
2022-11-02 02:25:38 +00:00
committed by Dawn LUCI CQ
parent 2bea9055f4
commit 6ab5d3c151
465 changed files with 15681 additions and 12853 deletions

View File

@@ -75,7 +75,7 @@ struct Particle {
vec2 vel;
};
layout(binding = 0, std140) uniform SimParams_ubo {
struct SimParams {
float deltaT;
float rule1Distance;
float rule2Distance;
@@ -84,14 +84,22 @@ layout(binding = 0, std140) uniform SimParams_ubo {
float rule2Scale;
float rule3Scale;
uint pad;
};
struct Particles {
Particle particles[5];
};
layout(binding = 0, std140) uniform params_block_ubo {
SimParams inner;
} params;
layout(binding = 1, std430) buffer Particles_ssbo {
Particle particles[5];
layout(binding = 1, std430) buffer particlesA_block_ssbo {
Particles inner;
} particlesA;
layout(binding = 2, std430) buffer Particles_ssbo_1 {
Particle particles[5];
layout(binding = 2, std430) buffer particlesA_block_ssbo_1 {
Particles inner;
} particlesB;
void comp_main(uvec3 tint_symbol) {
@@ -99,8 +107,8 @@ void comp_main(uvec3 tint_symbol) {
if ((index >= 5u)) {
return;
}
vec2 vPos = particlesA.particles[index].pos;
vec2 vVel = particlesA.particles[index].vel;
vec2 vPos = particlesA.inner.particles[index].pos;
vec2 vVel = particlesA.inner.particles[index].vel;
vec2 cMass = vec2(0.0f);
vec2 cVel = vec2(0.0f);
vec2 colVel = vec2(0.0f);
@@ -113,16 +121,16 @@ void comp_main(uvec3 tint_symbol) {
if ((i == index)) {
continue;
}
pos = particlesA.particles[i].pos.xy;
vel = particlesA.particles[i].vel.xy;
if ((distance(pos, vPos) < params.rule1Distance)) {
pos = particlesA.inner.particles[i].pos.xy;
vel = particlesA.inner.particles[i].vel.xy;
if ((distance(pos, vPos) < params.inner.rule1Distance)) {
cMass = (cMass + pos);
cMassCount = (cMassCount + 1);
}
if ((distance(pos, vPos) < params.rule2Distance)) {
if ((distance(pos, vPos) < params.inner.rule2Distance)) {
colVel = (colVel - (pos - vPos));
}
if ((distance(pos, vPos) < params.rule3Distance)) {
if ((distance(pos, vPos) < params.inner.rule3Distance)) {
cVel = (cVel + vel);
cVelCount = (cVelCount + 1);
}
@@ -134,9 +142,9 @@ void comp_main(uvec3 tint_symbol) {
if ((cVelCount > 0)) {
cVel = (cVel / vec2(float(cVelCount), float(cVelCount)));
}
vVel = (((vVel + (cMass * params.rule1Scale)) + (colVel * params.rule2Scale)) + (cVel * params.rule3Scale));
vVel = (((vVel + (cMass * params.inner.rule1Scale)) + (colVel * params.inner.rule2Scale)) + (cVel * params.inner.rule3Scale));
vVel = (normalize(vVel) * clamp(length(vVel), 0.0f, 0.100000001f));
vPos = (vPos + (vVel * params.deltaT));
vPos = (vPos + (vVel * params.inner.deltaT));
if ((vPos.x < -1.0f)) {
vPos.x = 1.0f;
}
@@ -149,8 +157,8 @@ void comp_main(uvec3 tint_symbol) {
if ((vPos.y > 1.0f)) {
vPos.y = -1.0f;
}
particlesB.particles[index].pos = vPos;
particlesB.particles[index].vel = vVel;
particlesB.inner.particles[index].pos = vPos;
particlesB.inner.particles[index].vel = vVel;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@@ -1,10 +1,10 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 277
; Bound: 279
; Schema: 0
OpCapability Shader
%37 = OpExtInstImport "GLSL.std.450"
%39 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vert_main "vert_main" %a_particlePos_1 %a_particleVel_1 %a_pos_1 %value %vertex_point_size
OpEntryPoint Fragment %frag_main "frag_main" %value_1
@@ -18,6 +18,8 @@
OpName %vertex_point_size "vertex_point_size"
OpName %value_1 "value_1"
OpName %gl_GlobalInvocationID_1 "gl_GlobalInvocationID_1"
OpName %params_block "params_block"
OpMemberName %params_block 0 "inner"
OpName %SimParams "SimParams"
OpMemberName %SimParams 0 "deltaT"
OpMemberName %SimParams 1 "rule1Distance"
@@ -27,6 +29,8 @@
OpMemberName %SimParams 5 "rule2Scale"
OpMemberName %SimParams 6 "rule3Scale"
OpName %params "params"
OpName %particlesA_block "particlesA_block"
OpMemberName %particlesA_block 0 "inner"
OpName %Particles "Particles"
OpMemberName %Particles 0 "particles"
OpName %Particle "Particle"
@@ -64,7 +68,8 @@
OpDecorate %vertex_point_size BuiltIn PointSize
OpDecorate %value_1 Location 0
OpDecorate %gl_GlobalInvocationID_1 BuiltIn GlobalInvocationId
OpDecorate %SimParams Block
OpDecorate %params_block Block
OpMemberDecorate %params_block 0 Offset 0
OpMemberDecorate %SimParams 0 Offset 0
OpMemberDecorate %SimParams 1 Offset 4
OpMemberDecorate %SimParams 2 Offset 8
@@ -75,7 +80,8 @@
OpDecorate %params NonWritable
OpDecorate %params Binding 0
OpDecorate %params DescriptorSet 0
OpDecorate %Particles Block
OpDecorate %particlesA_block Block
OpMemberDecorate %particlesA_block 0 Offset 0
OpMemberDecorate %Particles 0 Offset 0
OpMemberDecorate %Particle 0 Offset 0
OpMemberDecorate %Particle 1 Offset 8
@@ -103,33 +109,35 @@
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%gl_GlobalInvocationID_1 = OpVariable %_ptr_Input_v3uint Input
%SimParams = OpTypeStruct %float %float %float %float %float %float %float
%_ptr_Uniform_SimParams = OpTypePointer Uniform %SimParams
%params = OpVariable %_ptr_Uniform_SimParams Uniform
%params_block = OpTypeStruct %SimParams
%_ptr_Uniform_params_block = OpTypePointer Uniform %params_block
%params = OpVariable %_ptr_Uniform_params_block Uniform
%Particle = OpTypeStruct %v2float %v2float
%uint_5 = OpConstant %uint 5
%_arr_Particle_uint_5 = OpTypeArray %Particle %uint_5
%Particles = OpTypeStruct %_arr_Particle_uint_5
%_ptr_StorageBuffer_Particles = OpTypePointer StorageBuffer %Particles
%particlesA = OpVariable %_ptr_StorageBuffer_Particles StorageBuffer
%particlesB = OpVariable %_ptr_StorageBuffer_Particles StorageBuffer
%29 = OpTypeFunction %v4float %v2float %v2float %v2float
%particlesA_block = OpTypeStruct %Particles
%_ptr_StorageBuffer_particlesA_block = OpTypePointer StorageBuffer %particlesA_block
%particlesA = OpVariable %_ptr_StorageBuffer_particlesA_block StorageBuffer
%particlesB = OpVariable %_ptr_StorageBuffer_particlesA_block StorageBuffer
%31 = OpTypeFunction %v4float %v2float %v2float %v2float
%_ptr_Function_float = OpTypePointer Function %float
%_ptr_Function_v2float = OpTypePointer Function %v2float
%63 = OpConstantNull %v2float
%65 = OpConstantNull %v2float
%float_1 = OpConstant %float 1
%void = OpTypeVoid
%70 = OpTypeFunction %void
%78 = OpTypeFunction %v4float
%81 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%85 = OpTypeFunction %void %v3uint
%72 = OpTypeFunction %void
%80 = OpTypeFunction %v4float
%83 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%87 = OpTypeFunction %void %v3uint
%_ptr_Function_uint = OpTypePointer Function %uint
%92 = OpConstantNull %uint
%94 = OpConstantNull %uint
%bool = OpTypeBool
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_v2float = OpTypePointer StorageBuffer %v2float
%uint_1 = OpConstant %uint 1
%int = OpTypeInt 32 1
%113 = OpConstantNull %int
%115 = OpConstantNull %int
%_ptr_Function_int = OpTypePointer Function %int
%_ptr_Uniform_float = OpTypePointer Uniform %float
%int_1 = OpConstant %int 1
@@ -139,309 +147,309 @@
%uint_6 = OpConstant %uint 6
%float_0_100000001 = OpConstant %float 0.100000001
%float_n1 = OpConstant %float -1
%vert_main_inner = OpFunction %v4float None %29
%vert_main_inner = OpFunction %v4float None %31
%a_particlePos = OpFunctionParameter %v2float
%a_particleVel = OpFunctionParameter %v2float
%a_pos = OpFunctionParameter %v2float
%34 = OpLabel
%36 = OpLabel
%angle = OpVariable %_ptr_Function_float Function %13
%pos = OpVariable %_ptr_Function_v2float Function %63
%38 = OpCompositeExtract %float %a_particleVel 0
%39 = OpCompositeExtract %float %a_particleVel 1
%36 = OpExtInst %float %37 Atan2 %38 %39
%35 = OpFNegate %float %36
OpStore %angle %35
%42 = OpCompositeExtract %float %a_pos 0
%44 = OpLoad %float %angle
%43 = OpExtInst %float %37 Cos %44
%45 = OpFMul %float %42 %43
%46 = OpCompositeExtract %float %a_pos 1
%48 = OpLoad %float %angle
%47 = OpExtInst %float %37 Sin %48
%49 = OpFMul %float %46 %47
%50 = OpFSub %float %45 %49
%51 = OpCompositeExtract %float %a_pos 0
%53 = OpLoad %float %angle
%52 = OpExtInst %float %37 Sin %53
%54 = OpFMul %float %51 %52
%55 = OpCompositeExtract %float %a_pos 1
%57 = OpLoad %float %angle
%56 = OpExtInst %float %37 Cos %57
%58 = OpFMul %float %55 %56
%59 = OpFAdd %float %54 %58
%60 = OpCompositeConstruct %v2float %50 %59
OpStore %pos %60
%64 = OpLoad %v2float %pos
%65 = OpFAdd %v2float %64 %a_particlePos
%66 = OpCompositeExtract %float %65 0
%67 = OpCompositeExtract %float %65 1
%69 = OpCompositeConstruct %v4float %66 %67 %13 %float_1
OpReturnValue %69
%pos = OpVariable %_ptr_Function_v2float Function %65
%40 = OpCompositeExtract %float %a_particleVel 0
%41 = OpCompositeExtract %float %a_particleVel 1
%38 = OpExtInst %float %39 Atan2 %40 %41
%37 = OpFNegate %float %38
OpStore %angle %37
%44 = OpCompositeExtract %float %a_pos 0
%46 = OpLoad %float %angle
%45 = OpExtInst %float %39 Cos %46
%47 = OpFMul %float %44 %45
%48 = OpCompositeExtract %float %a_pos 1
%50 = OpLoad %float %angle
%49 = OpExtInst %float %39 Sin %50
%51 = OpFMul %float %48 %49
%52 = OpFSub %float %47 %51
%53 = OpCompositeExtract %float %a_pos 0
%55 = OpLoad %float %angle
%54 = OpExtInst %float %39 Sin %55
%56 = OpFMul %float %53 %54
%57 = OpCompositeExtract %float %a_pos 1
%59 = OpLoad %float %angle
%58 = OpExtInst %float %39 Cos %59
%60 = OpFMul %float %57 %58
%61 = OpFAdd %float %56 %60
%62 = OpCompositeConstruct %v2float %52 %61
OpStore %pos %62
%66 = OpLoad %v2float %pos
%67 = OpFAdd %v2float %66 %a_particlePos
%68 = OpCompositeExtract %float %67 0
%69 = OpCompositeExtract %float %67 1
%71 = OpCompositeConstruct %v4float %68 %69 %13 %float_1
OpReturnValue %71
OpFunctionEnd
%vert_main = OpFunction %void None %70
%73 = OpLabel
%75 = OpLoad %v2float %a_particlePos_1
%76 = OpLoad %v2float %a_particleVel_1
%77 = OpLoad %v2float %a_pos_1
%74 = OpFunctionCall %v4float %vert_main_inner %75 %76 %77
OpStore %value %74
%vert_main = OpFunction %void None %72
%75 = OpLabel
%77 = OpLoad %v2float %a_particlePos_1
%78 = OpLoad %v2float %a_particleVel_1
%79 = OpLoad %v2float %a_pos_1
%76 = OpFunctionCall %v4float %vert_main_inner %77 %78 %79
OpStore %value %76
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%frag_main_inner = OpFunction %v4float None %78
%80 = OpLabel
OpReturnValue %81
%frag_main_inner = OpFunction %v4float None %80
%82 = OpLabel
OpReturnValue %83
OpFunctionEnd
%frag_main = OpFunction %void None %70
%83 = OpLabel
%84 = OpFunctionCall %v4float %frag_main_inner
OpStore %value_1 %84
%frag_main = OpFunction %void None %72
%85 = OpLabel
%86 = OpFunctionCall %v4float %frag_main_inner
OpStore %value_1 %86
OpReturn
OpFunctionEnd
%comp_main_inner = OpFunction %void None %85
%comp_main_inner = OpFunction %void None %87
%gl_GlobalInvocationID = OpFunctionParameter %v3uint
%88 = OpLabel
%index = OpVariable %_ptr_Function_uint Function %92
%vPos = OpVariable %_ptr_Function_v2float Function %63
%vVel = OpVariable %_ptr_Function_v2float Function %63
%cMass = OpVariable %_ptr_Function_v2float Function %63
%cVel = OpVariable %_ptr_Function_v2float Function %63
%colVel = OpVariable %_ptr_Function_v2float Function %63
%cMassCount = OpVariable %_ptr_Function_int Function %113
%cVelCount = OpVariable %_ptr_Function_int Function %113
%pos_0 = OpVariable %_ptr_Function_v2float Function %63
%vel = OpVariable %_ptr_Function_v2float Function %63
%i = OpVariable %_ptr_Function_uint Function %92
%89 = OpCompositeExtract %uint %gl_GlobalInvocationID 0
OpStore %index %89
%93 = OpLoad %uint %index
%94 = OpUGreaterThanEqual %bool %93 %uint_5
OpSelectionMerge %96 None
OpBranchConditional %94 %97 %96
%97 = OpLabel
%90 = OpLabel
%index = OpVariable %_ptr_Function_uint Function %94
%vPos = OpVariable %_ptr_Function_v2float Function %65
%vVel = OpVariable %_ptr_Function_v2float Function %65
%cMass = OpVariable %_ptr_Function_v2float Function %65
%cVel = OpVariable %_ptr_Function_v2float Function %65
%colVel = OpVariable %_ptr_Function_v2float Function %65
%cMassCount = OpVariable %_ptr_Function_int Function %115
%cVelCount = OpVariable %_ptr_Function_int Function %115
%pos_0 = OpVariable %_ptr_Function_v2float Function %65
%vel = OpVariable %_ptr_Function_v2float Function %65
%i = OpVariable %_ptr_Function_uint Function %94
%91 = OpCompositeExtract %uint %gl_GlobalInvocationID 0
OpStore %index %91
%95 = OpLoad %uint %index
%96 = OpUGreaterThanEqual %bool %95 %uint_5
OpSelectionMerge %98 None
OpBranchConditional %96 %99 %98
%99 = OpLabel
OpReturn
%96 = OpLabel
%99 = OpLoad %uint %index
%101 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %99 %uint_0
%102 = OpLoad %v2float %101
OpStore %vPos %102
%104 = OpLoad %uint %index
%106 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %104 %uint_1
%107 = OpLoad %v2float %106
OpStore %vVel %107
OpStore %cMass %63
OpStore %cVel %63
OpStore %colVel %63
OpStore %cMassCount %113
OpStore %cVelCount %113
OpStore %i %92
OpBranch %120
%120 = OpLabel
OpLoopMerge %121 %122 None
OpBranch %123
%123 = OpLabel
%125 = OpLoad %uint %i
%126 = OpULessThan %bool %125 %uint_5
%124 = OpLogicalNot %bool %126
OpSelectionMerge %127 None
OpBranchConditional %124 %128 %127
%128 = OpLabel
OpBranch %121
%127 = OpLabel
%129 = OpLoad %uint %i
%130 = OpLoad %uint %index
%131 = OpIEqual %bool %129 %130
OpSelectionMerge %132 None
OpBranchConditional %131 %133 %132
%133 = OpLabel
OpBranch %122
%132 = OpLabel
%134 = OpLoad %uint %i
%135 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %134 %uint_0
%136 = OpLoad %v2float %135
%137 = OpVectorShuffle %v2float %136 %136 0 1
OpStore %pos_0 %137
%138 = OpLoad %uint %i
%139 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %138 %uint_1
%140 = OpLoad %v2float %139
%141 = OpVectorShuffle %v2float %140 %140 0 1
OpStore %vel %141
%143 = OpLoad %v2float %pos_0
%144 = OpLoad %v2float %vPos
%142 = OpExtInst %float %37 Distance %143 %144
%146 = OpAccessChain %_ptr_Uniform_float %params %uint_1
%147 = OpLoad %float %146
%148 = OpFOrdLessThan %bool %142 %147
OpSelectionMerge %149 None
OpBranchConditional %148 %150 %149
%150 = OpLabel
%151 = OpLoad %v2float %cMass
%152 = OpLoad %v2float %pos_0
%153 = OpFAdd %v2float %151 %152
OpStore %cMass %153
%154 = OpLoad %int %cMassCount
%156 = OpIAdd %int %154 %int_1
OpStore %cMassCount %156
OpBranch %149
%149 = OpLabel
%158 = OpLoad %v2float %pos_0
%159 = OpLoad %v2float %vPos
%157 = OpExtInst %float %37 Distance %158 %159
%161 = OpAccessChain %_ptr_Uniform_float %params %uint_2
%162 = OpLoad %float %161
%163 = OpFOrdLessThan %bool %157 %162
OpSelectionMerge %164 None
OpBranchConditional %163 %165 %164
%165 = OpLabel
%166 = OpLoad %v2float %colVel
%167 = OpLoad %v2float %pos_0
%168 = OpLoad %v2float %vPos
%169 = OpFSub %v2float %167 %168
%170 = OpFSub %v2float %166 %169
OpStore %colVel %170
OpBranch %164
%164 = OpLabel
%172 = OpLoad %v2float %pos_0
%173 = OpLoad %v2float %vPos
%171 = OpExtInst %float %37 Distance %172 %173
%175 = OpAccessChain %_ptr_Uniform_float %params %uint_3
%176 = OpLoad %float %175
%177 = OpFOrdLessThan %bool %171 %176
OpSelectionMerge %178 None
OpBranchConditional %177 %179 %178
%179 = OpLabel
%180 = OpLoad %v2float %cVel
%181 = OpLoad %v2float %vel
%182 = OpFAdd %v2float %180 %181
OpStore %cVel %182
%183 = OpLoad %int %cVelCount
%184 = OpIAdd %int %183 %int_1
OpStore %cVelCount %184
OpBranch %178
%178 = OpLabel
%98 = OpLabel
%101 = OpLoad %uint %index
%103 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %uint_0 %101 %uint_0
%104 = OpLoad %v2float %103
OpStore %vPos %104
%106 = OpLoad %uint %index
%108 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %uint_0 %106 %uint_1
%109 = OpLoad %v2float %108
OpStore %vVel %109
OpStore %cMass %65
OpStore %cVel %65
OpStore %colVel %65
OpStore %cMassCount %115
OpStore %cVelCount %115
OpStore %i %94
OpBranch %122
%122 = OpLabel
%185 = OpLoad %uint %i
%186 = OpIAdd %uint %185 %uint_1
OpStore %i %186
OpBranch %120
%121 = OpLabel
%187 = OpLoad %int %cMassCount
%188 = OpSGreaterThan %bool %187 %113
OpSelectionMerge %189 None
OpBranchConditional %188 %190 %189
%190 = OpLabel
%191 = OpLoad %v2float %cMass
%193 = OpLoad %int %cMassCount
%192 = OpConvertSToF %float %193
OpLoopMerge %123 %124 None
OpBranch %125
%125 = OpLabel
%127 = OpLoad %uint %i
%128 = OpULessThan %bool %127 %uint_5
%126 = OpLogicalNot %bool %128
OpSelectionMerge %129 None
OpBranchConditional %126 %130 %129
%130 = OpLabel
OpBranch %123
%129 = OpLabel
%131 = OpLoad %uint %i
%132 = OpLoad %uint %index
%133 = OpIEqual %bool %131 %132
OpSelectionMerge %134 None
OpBranchConditional %133 %135 %134
%135 = OpLabel
OpBranch %124
%134 = OpLabel
%136 = OpLoad %uint %i
%137 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %uint_0 %136 %uint_0
%138 = OpLoad %v2float %137
%139 = OpVectorShuffle %v2float %138 %138 0 1
OpStore %pos_0 %139
%140 = OpLoad %uint %i
%141 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %uint_0 %140 %uint_1
%142 = OpLoad %v2float %141
%143 = OpVectorShuffle %v2float %142 %142 0 1
OpStore %vel %143
%145 = OpLoad %v2float %pos_0
%146 = OpLoad %v2float %vPos
%144 = OpExtInst %float %39 Distance %145 %146
%148 = OpAccessChain %_ptr_Uniform_float %params %uint_0 %uint_1
%149 = OpLoad %float %148
%150 = OpFOrdLessThan %bool %144 %149
OpSelectionMerge %151 None
OpBranchConditional %150 %152 %151
%152 = OpLabel
%153 = OpLoad %v2float %cMass
%154 = OpLoad %v2float %pos_0
%155 = OpFAdd %v2float %153 %154
OpStore %cMass %155
%156 = OpLoad %int %cMassCount
%158 = OpIAdd %int %156 %int_1
OpStore %cMassCount %158
OpBranch %151
%151 = OpLabel
%160 = OpLoad %v2float %pos_0
%161 = OpLoad %v2float %vPos
%159 = OpExtInst %float %39 Distance %160 %161
%163 = OpAccessChain %_ptr_Uniform_float %params %uint_0 %uint_2
%164 = OpLoad %float %163
%165 = OpFOrdLessThan %bool %159 %164
OpSelectionMerge %166 None
OpBranchConditional %165 %167 %166
%167 = OpLabel
%168 = OpLoad %v2float %colVel
%169 = OpLoad %v2float %pos_0
%170 = OpLoad %v2float %vPos
%171 = OpFSub %v2float %169 %170
%172 = OpFSub %v2float %168 %171
OpStore %colVel %172
OpBranch %166
%166 = OpLabel
%174 = OpLoad %v2float %pos_0
%175 = OpLoad %v2float %vPos
%173 = OpExtInst %float %39 Distance %174 %175
%177 = OpAccessChain %_ptr_Uniform_float %params %uint_0 %uint_3
%178 = OpLoad %float %177
%179 = OpFOrdLessThan %bool %173 %178
OpSelectionMerge %180 None
OpBranchConditional %179 %181 %180
%181 = OpLabel
%182 = OpLoad %v2float %cVel
%183 = OpLoad %v2float %vel
%184 = OpFAdd %v2float %182 %183
OpStore %cVel %184
%185 = OpLoad %int %cVelCount
%186 = OpIAdd %int %185 %int_1
OpStore %cVelCount %186
OpBranch %180
%180 = OpLabel
OpBranch %124
%124 = OpLabel
%187 = OpLoad %uint %i
%188 = OpIAdd %uint %187 %uint_1
OpStore %i %188
OpBranch %122
%123 = OpLabel
%189 = OpLoad %int %cMassCount
%190 = OpSGreaterThan %bool %189 %115
OpSelectionMerge %191 None
OpBranchConditional %190 %192 %191
%192 = OpLabel
%193 = OpLoad %v2float %cMass
%195 = OpLoad %int %cMassCount
%194 = OpConvertSToF %float %195
%196 = OpCompositeConstruct %v2float %192 %194
%197 = OpFDiv %v2float %191 %196
%198 = OpLoad %v2float %vPos
%199 = OpFSub %v2float %197 %198
OpStore %cMass %199
OpBranch %189
%189 = OpLabel
%200 = OpLoad %int %cVelCount
%201 = OpSGreaterThan %bool %200 %113
OpSelectionMerge %202 None
OpBranchConditional %201 %203 %202
%203 = OpLabel
%204 = OpLoad %v2float %cVel
%206 = OpLoad %int %cVelCount
%205 = OpConvertSToF %float %206
%197 = OpLoad %int %cMassCount
%196 = OpConvertSToF %float %197
%198 = OpCompositeConstruct %v2float %194 %196
%199 = OpFDiv %v2float %193 %198
%200 = OpLoad %v2float %vPos
%201 = OpFSub %v2float %199 %200
OpStore %cMass %201
OpBranch %191
%191 = OpLabel
%202 = OpLoad %int %cVelCount
%203 = OpSGreaterThan %bool %202 %115
OpSelectionMerge %204 None
OpBranchConditional %203 %205 %204
%205 = OpLabel
%206 = OpLoad %v2float %cVel
%208 = OpLoad %int %cVelCount
%207 = OpConvertSToF %float %208
%209 = OpCompositeConstruct %v2float %205 %207
%210 = OpFDiv %v2float %204 %209
OpStore %cVel %210
OpBranch %202
%202 = OpLabel
%211 = OpLoad %v2float %vVel
%212 = OpLoad %v2float %cMass
%214 = OpAccessChain %_ptr_Uniform_float %params %uint_4
%215 = OpLoad %float %214
%216 = OpVectorTimesScalar %v2float %212 %215
%217 = OpFAdd %v2float %211 %216
%218 = OpLoad %v2float %colVel
%219 = OpAccessChain %_ptr_Uniform_float %params %uint_5
%220 = OpLoad %float %219
%221 = OpVectorTimesScalar %v2float %218 %220
%222 = OpFAdd %v2float %217 %221
%223 = OpLoad %v2float %cVel
%225 = OpAccessChain %_ptr_Uniform_float %params %uint_6
%226 = OpLoad %float %225
%227 = OpVectorTimesScalar %v2float %223 %226
%228 = OpFAdd %v2float %222 %227
OpStore %vVel %228
%230 = OpLoad %v2float %vVel
%229 = OpExtInst %v2float %37 Normalize %230
%233 = OpLoad %v2float %vVel
%232 = OpExtInst %float %37 Length %233
%231 = OpExtInst %float %37 NClamp %232 %13 %float_0_100000001
%235 = OpVectorTimesScalar %v2float %229 %231
OpStore %vVel %235
%236 = OpLoad %v2float %vPos
%237 = OpLoad %v2float %vVel
%238 = OpAccessChain %_ptr_Uniform_float %params %uint_0
%239 = OpLoad %float %238
%240 = OpVectorTimesScalar %v2float %237 %239
%241 = OpFAdd %v2float %236 %240
OpStore %vPos %241
%242 = OpAccessChain %_ptr_Function_float %vPos %uint_0
%243 = OpLoad %float %242
%245 = OpFOrdLessThan %bool %243 %float_n1
OpSelectionMerge %246 None
OpBranchConditional %245 %247 %246
%247 = OpLabel
%248 = OpAccessChain %_ptr_Function_float %vPos %uint_0
OpStore %248 %float_1
OpBranch %246
%246 = OpLabel
%249 = OpAccessChain %_ptr_Function_float %vPos %uint_0
%250 = OpLoad %float %249
%251 = OpFOrdGreaterThan %bool %250 %float_1
OpSelectionMerge %252 None
OpBranchConditional %251 %253 %252
%253 = OpLabel
%254 = OpAccessChain %_ptr_Function_float %vPos %uint_0
OpStore %254 %float_n1
OpBranch %252
%252 = OpLabel
%255 = OpAccessChain %_ptr_Function_float %vPos %uint_1
%256 = OpLoad %float %255
%257 = OpFOrdLessThan %bool %256 %float_n1
OpSelectionMerge %258 None
OpBranchConditional %257 %259 %258
%259 = OpLabel
%260 = OpAccessChain %_ptr_Function_float %vPos %uint_1
OpStore %260 %float_1
OpBranch %258
%258 = OpLabel
%261 = OpAccessChain %_ptr_Function_float %vPos %uint_1
%262 = OpLoad %float %261
%263 = OpFOrdGreaterThan %bool %262 %float_1
OpSelectionMerge %264 None
OpBranchConditional %263 %265 %264
%265 = OpLabel
%266 = OpAccessChain %_ptr_Function_float %vPos %uint_1
OpStore %266 %float_n1
OpBranch %264
%264 = OpLabel
%267 = OpLoad %uint %index
%268 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesB %uint_0 %267 %uint_0
%269 = OpLoad %v2float %vPos
OpStore %268 %269
%270 = OpLoad %uint %index
%271 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesB %uint_0 %270 %uint_1
%272 = OpLoad %v2float %vVel
OpStore %271 %272
%210 = OpLoad %int %cVelCount
%209 = OpConvertSToF %float %210
%211 = OpCompositeConstruct %v2float %207 %209
%212 = OpFDiv %v2float %206 %211
OpStore %cVel %212
OpBranch %204
%204 = OpLabel
%213 = OpLoad %v2float %vVel
%214 = OpLoad %v2float %cMass
%216 = OpAccessChain %_ptr_Uniform_float %params %uint_0 %uint_4
%217 = OpLoad %float %216
%218 = OpVectorTimesScalar %v2float %214 %217
%219 = OpFAdd %v2float %213 %218
%220 = OpLoad %v2float %colVel
%221 = OpAccessChain %_ptr_Uniform_float %params %uint_0 %uint_5
%222 = OpLoad %float %221
%223 = OpVectorTimesScalar %v2float %220 %222
%224 = OpFAdd %v2float %219 %223
%225 = OpLoad %v2float %cVel
%227 = OpAccessChain %_ptr_Uniform_float %params %uint_0 %uint_6
%228 = OpLoad %float %227
%229 = OpVectorTimesScalar %v2float %225 %228
%230 = OpFAdd %v2float %224 %229
OpStore %vVel %230
%232 = OpLoad %v2float %vVel
%231 = OpExtInst %v2float %39 Normalize %232
%235 = OpLoad %v2float %vVel
%234 = OpExtInst %float %39 Length %235
%233 = OpExtInst %float %39 NClamp %234 %13 %float_0_100000001
%237 = OpVectorTimesScalar %v2float %231 %233
OpStore %vVel %237
%238 = OpLoad %v2float %vPos
%239 = OpLoad %v2float %vVel
%240 = OpAccessChain %_ptr_Uniform_float %params %uint_0 %uint_0
%241 = OpLoad %float %240
%242 = OpVectorTimesScalar %v2float %239 %241
%243 = OpFAdd %v2float %238 %242
OpStore %vPos %243
%244 = OpAccessChain %_ptr_Function_float %vPos %uint_0
%245 = OpLoad %float %244
%247 = OpFOrdLessThan %bool %245 %float_n1
OpSelectionMerge %248 None
OpBranchConditional %247 %249 %248
%249 = OpLabel
%250 = OpAccessChain %_ptr_Function_float %vPos %uint_0
OpStore %250 %float_1
OpBranch %248
%248 = OpLabel
%251 = OpAccessChain %_ptr_Function_float %vPos %uint_0
%252 = OpLoad %float %251
%253 = OpFOrdGreaterThan %bool %252 %float_1
OpSelectionMerge %254 None
OpBranchConditional %253 %255 %254
%255 = OpLabel
%256 = OpAccessChain %_ptr_Function_float %vPos %uint_0
OpStore %256 %float_n1
OpBranch %254
%254 = OpLabel
%257 = OpAccessChain %_ptr_Function_float %vPos %uint_1
%258 = OpLoad %float %257
%259 = OpFOrdLessThan %bool %258 %float_n1
OpSelectionMerge %260 None
OpBranchConditional %259 %261 %260
%261 = OpLabel
%262 = OpAccessChain %_ptr_Function_float %vPos %uint_1
OpStore %262 %float_1
OpBranch %260
%260 = OpLabel
%263 = OpAccessChain %_ptr_Function_float %vPos %uint_1
%264 = OpLoad %float %263
%265 = OpFOrdGreaterThan %bool %264 %float_1
OpSelectionMerge %266 None
OpBranchConditional %265 %267 %266
%267 = OpLabel
%268 = OpAccessChain %_ptr_Function_float %vPos %uint_1
OpStore %268 %float_n1
OpBranch %266
%266 = OpLabel
%269 = OpLoad %uint %index
%270 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesB %uint_0 %uint_0 %269 %uint_0
%271 = OpLoad %v2float %vPos
OpStore %270 %271
%272 = OpLoad %uint %index
%273 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesB %uint_0 %uint_0 %272 %uint_1
%274 = OpLoad %v2float %vVel
OpStore %273 %274
OpReturn
OpFunctionEnd
%comp_main = OpFunction %void None %70
%274 = OpLabel
%276 = OpLoad %v3uint %gl_GlobalInvocationID_1
%275 = OpFunctionCall %void %comp_main_inner %276
%comp_main = OpFunction %void None %72
%276 = OpLabel
%278 = OpLoad %v3uint %gl_GlobalInvocationID_1
%277 = OpFunctionCall %void %comp_main_inner %278
OpReturn
OpFunctionEnd

View File

@@ -3,8 +3,12 @@
layout(location = 0) in vec4 cur_position_1;
layout(location = 1) in vec4 color_1;
layout(location = 0) out vec4 vtxFragColor_1;
layout(binding = 0, std140) uniform Uniforms_ubo {
struct Uniforms {
mat4 modelViewProjectionMatrix;
};
layout(binding = 0, std140) uniform uniforms_block_ubo {
Uniforms inner;
} uniforms;
struct VertexInput {
@@ -19,7 +23,7 @@ struct VertexOutput {
VertexOutput vtx_main(VertexInput tint_symbol) {
VertexOutput tint_symbol_1 = VertexOutput(vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f));
tint_symbol_1.Position = (uniforms.modelViewProjectionMatrix * tint_symbol.cur_position);
tint_symbol_1.Position = (uniforms.inner.modelViewProjectionMatrix * tint_symbol.cur_position);
tint_symbol_1.vtxFragColor = tint_symbol.color;
return tint_symbol_1;
}

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 60
; Bound: 61
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -15,6 +15,8 @@
OpName %vertex_point_size "vertex_point_size"
OpName %fragColor_1 "fragColor_1"
OpName %value "value"
OpName %uniforms_block "uniforms_block"
OpMemberName %uniforms_block 0 "inner"
OpName %Uniforms "Uniforms"
OpMemberName %Uniforms 0 "modelViewProjectionMatrix"
OpName %uniforms "uniforms"
@@ -38,7 +40,8 @@
OpDecorate %vertex_point_size BuiltIn PointSize
OpDecorate %fragColor_1 Location 0
OpDecorate %value Location 0
OpDecorate %Uniforms Block
OpDecorate %uniforms_block Block
OpMemberDecorate %uniforms_block 0 Offset 0
OpMemberDecorate %Uniforms 0 Offset 0
OpMemberDecorate %Uniforms 0 ColMajor
OpMemberDecorate %Uniforms 0 MatrixStride 16
@@ -65,60 +68,61 @@
%value = OpVariable %_ptr_Output_v4float Output %8
%mat4v4float = OpTypeMatrix %v4float 4
%Uniforms = OpTypeStruct %mat4v4float
%_ptr_Uniform_Uniforms = OpTypePointer Uniform %Uniforms
%uniforms = OpVariable %_ptr_Uniform_Uniforms Uniform
%uniforms_block = OpTypeStruct %Uniforms
%_ptr_Uniform_uniforms_block = OpTypePointer Uniform %uniforms_block
%uniforms = OpVariable %_ptr_Uniform_uniforms_block Uniform
%VertexOutput = OpTypeStruct %v4float %v4float
%VertexInput = OpTypeStruct %v4float %v4float
%19 = OpTypeFunction %VertexOutput %VertexInput
%20 = OpTypeFunction %VertexOutput %VertexInput
%_ptr_Function_VertexOutput = OpTypePointer Function %VertexOutput
%27 = OpConstantNull %VertexOutput
%28 = OpConstantNull %VertexOutput
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%_ptr_Function_v4float = OpTypePointer Function %v4float
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float
%void = OpTypeVoid
%41 = OpTypeFunction %void
%42 = OpTypeFunction %void
%float_1 = OpConstant %float 1
%52 = OpTypeFunction %v4float %v4float
%vtx_main_inner = OpFunction %VertexOutput None %19
%53 = OpTypeFunction %v4float %v4float
%vtx_main_inner = OpFunction %VertexOutput None %20
%input = OpFunctionParameter %VertexInput
%24 = OpLabel
%output = OpVariable %_ptr_Function_VertexOutput Function %27
%31 = OpAccessChain %_ptr_Function_v4float %output %uint_1
%34 = OpAccessChain %_ptr_Uniform_mat4v4float %uniforms %uint_0
%35 = OpLoad %mat4v4float %34
%36 = OpCompositeExtract %v4float %input 0
%37 = OpMatrixTimesVector %v4float %35 %36
OpStore %31 %37
%38 = OpAccessChain %_ptr_Function_v4float %output %uint_0
%39 = OpCompositeExtract %v4float %input 1
OpStore %38 %39
%40 = OpLoad %VertexOutput %output
OpReturnValue %40
%25 = OpLabel
%output = OpVariable %_ptr_Function_VertexOutput Function %28
%32 = OpAccessChain %_ptr_Function_v4float %output %uint_1
%35 = OpAccessChain %_ptr_Uniform_mat4v4float %uniforms %uint_0 %uint_0
%36 = OpLoad %mat4v4float %35
%37 = OpCompositeExtract %v4float %input 0
%38 = OpMatrixTimesVector %v4float %36 %37
OpStore %32 %38
%39 = OpAccessChain %_ptr_Function_v4float %output %uint_0
%40 = OpCompositeExtract %v4float %input 1
OpStore %39 %40
%41 = OpLoad %VertexOutput %output
OpReturnValue %41
OpFunctionEnd
%vtx_main = OpFunction %void None %41
%44 = OpLabel
%46 = OpLoad %v4float %cur_position_1
%47 = OpLoad %v4float %color_1
%48 = OpCompositeConstruct %VertexInput %46 %47
%45 = OpFunctionCall %VertexOutput %vtx_main_inner %48
%49 = OpCompositeExtract %v4float %45 0
OpStore %vtxFragColor_1 %49
%50 = OpCompositeExtract %v4float %45 1
OpStore %Position_1 %50
%vtx_main = OpFunction %void None %42
%45 = OpLabel
%47 = OpLoad %v4float %cur_position_1
%48 = OpLoad %v4float %color_1
%49 = OpCompositeConstruct %VertexInput %47 %48
%46 = OpFunctionCall %VertexOutput %vtx_main_inner %49
%50 = OpCompositeExtract %v4float %46 0
OpStore %vtxFragColor_1 %50
%51 = OpCompositeExtract %v4float %46 1
OpStore %Position_1 %51
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%frag_main_inner = OpFunction %v4float None %52
%frag_main_inner = OpFunction %v4float None %53
%fragColor = OpFunctionParameter %v4float
%55 = OpLabel
%56 = OpLabel
OpReturnValue %fragColor
OpFunctionEnd
%frag_main = OpFunction %void None %41
%57 = OpLabel
%59 = OpLoad %v4float %fragColor_1
%58 = OpFunctionCall %v4float %frag_main_inner %59
OpStore %value %58
%frag_main = OpFunction %void None %42
%58 = OpLabel
%60 = OpLoad %v4float %fragColor_1
%59 = OpFunctionCall %v4float %frag_main_inner %60
OpStore %value %59
OpReturn
OpFunctionEnd