writer/msl: Fix continuing block emission

Inline the `continuing` block in the places where `continue` is called.

Simplifies the emission, and fixes emission of `let` statements in the loop.

This fix matches the same approach in writer/hlsl.
See: https://dawn-review.googlesource.com/c/tint/+/51784

Fixed: tint:833
Fixed: tint:914
Change-Id: If4d8cde62dfaf8efa24272854ca7ff5edc0a8234
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55341
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton
2021-06-21 08:49:27 +00:00
committed by Tint LUCI CQ
parent c15baf695d
commit 663271dca4
16 changed files with 2061 additions and 2168 deletions

View File

@@ -1,18 +1,34 @@
SKIP: FAILED
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
/* 0x0000 */ uint arr[50];
};
struct Buf {
/* 0x0000 */ uint count;
/* 0x0004 */ tint_array_wrapper data;
};
kernel void tint_symbol(device Buf& b [[buffer(0)]]) {
uint i = 0u;
while (true) {
if ((i >= b.count)) {
break;
}
uint const p_save = i;
if (((i % 2u) == 0u)) {
{
b.data.arr[p_save] = (b.data.arr[p_save] * 2u);
i = (i + 1u);
}
continue;
}
b.data.arr[p_save] = 0u;
{
b.data.arr[p_save] = (b.data.arr[p_save] * 2u);
i = (i + 1u);
}
}
return;
}
Validation Failure:
Compilation failed:
program_source:16:24: error: default initialization of an object of const type 'device uint *const' (aka 'device unsigned int *const')
device uint* const p;
^
= nullptr
program_source:27:9: error: cannot assign to variable 'p' with const-qualified type 'device uint *const' (aka 'device unsigned int *const')
p = &(b.data.array[i]);
~ ^
program_source:16:24: note: variable 'p' declared const here
device uint* const p;
~~~~~~~~~~~~~~~~~~~^

View File

@@ -1,28 +1,36 @@
SKIP: FAILED
#include <metal_stdlib>
using namespace metal;
struct Uniforms {
/* 0x0000 */ packed_uint2 aShape;
/* 0x0008 */ packed_uint2 bShape;
/* 0x0010 */ packed_uint2 outShape;
};
struct Matrix {
/* 0x0000 */ uint numbers[1];
};
kernel void tint_symbol(uint3 global_id [[thread_position_in_grid]], constant Uniforms& uniforms [[buffer(3)]], const device Matrix& firstMatrix [[buffer(0)]], const device Matrix& secondMatrix [[buffer(1)]], device Matrix& resultMatrix [[buffer(2)]]) {
uint2 const resultCell = uint2(global_id.y, global_id.x);
uint const dimInner = uniforms.aShape.y;
uint const dimOutter = uniforms.outShape.y;
uint result = 0u;
{
uint i = 0u;
while (true) {
if (!((i < dimInner))) {
break;
}
uint const a = (i + (resultCell.x * dimInner));
uint const b = (resultCell.y + (i * dimOutter));
result = (result + (firstMatrix.numbers[a] * secondMatrix.numbers[b]));
{
i = (i + 1u);
}
}
}
uint const index = (resultCell.y + (resultCell.x * dimOutter));
resultMatrix.numbers[index] = result;
return;
}
Validation Failure:
Compilation failed:
program_source:22:18: error: default initialization of an object of const type 'const uint' (aka 'const unsigned int')
uint const a;
^
= 0
program_source:23:18: error: default initialization of an object of const type 'const uint' (aka 'const unsigned int')
uint const b;
^
= 0
program_source:33:11: error: cannot assign to variable 'a' with const-qualified type 'const uint' (aka 'const unsigned int')
a = (i + (resultCell.x * dimInner));
~ ^
program_source:22:18: note: variable 'a' declared const here
uint const a;
~~~~~~~~~~~^
program_source:34:11: error: cannot assign to variable 'b' with const-qualified type 'const uint' (aka 'const unsigned int')
b = (resultCell.y + (i * dimOutter));
~ ^
program_source:23:18: note: variable 'b' declared const here
uint const b;
~~~~~~~~~~~^

File diff suppressed because it is too large Load Diff

View File

@@ -14,18 +14,13 @@ kernel void tint_symbol(texture2d_array<float, access::sample> tint_symbol_2 [[t
float4 texel = tint_symbol_2.read(uint2(int2(GlobalInvocationID.xy)), 0, 0);
{
uint i = 0u;
{
bool tint_msl_is_first_1 = true;
for(;;) {
if (!tint_msl_is_first_1) {
i = (i + 1u);
}
tint_msl_is_first_1 = false;
if (!((i < 1u))) {
break;
}
result.values[(flatIndex + i)] = texel.r;
while (true) {
if (!((i < 1u))) {
break;
}
result.values[(flatIndex + i)] = texel.r;
{
i = (i + 1u);
}
}
}

View File

@@ -1,78 +1,224 @@
SKIP: FAILED
#include <metal_stdlib>
using namespace metal;
struct Uniforms {
/* 0x0000 */ uint dimAOuter;
/* 0x0004 */ uint dimInner;
/* 0x0008 */ uint dimBOuter;
};
struct Matrix {
/* 0x0000 */ float numbers[1];
};
struct tint_array_wrapper_1 {
float arr[64];
};
struct tint_array_wrapper {
tint_array_wrapper_1 arr[64];
};
struct tint_array_wrapper_2 {
float arr[16];
};
struct tint_array_wrapper_3 {
float arr[4];
};
constant uint RowPerThread = 4u;
constant uint ColPerThread = 4u;
constant uint TileAOuter = 64u;
constant uint TileBOuter = 64u;
constant uint TileInner = 64u;
float mm_readA(constant Uniforms& uniforms, const device Matrix& firstMatrix, uint row, uint col) {
if (((row < uniforms.dimAOuter) && (col < uniforms.dimInner))) {
float const result = firstMatrix.numbers[((row * uniforms.dimInner) + col)];
return result;
}
return 0.0f;
}
Validation Failure:
float mm_readB(constant Uniforms& uniforms, const device Matrix& secondMatrix, uint row, uint col) {
if (((row < uniforms.dimInner) && (col < uniforms.dimBOuter))) {
float const result = secondMatrix.numbers[((row * uniforms.dimBOuter) + col)];
return result;
}
return 0.0f;
}
Compilation failed:
void mm_write(constant Uniforms& uniforms, device Matrix& resultMatrix, uint row, uint col, float value) {
if (((row < uniforms.dimAOuter) && (col < uniforms.dimBOuter))) {
uint const index = (col + (row * uniforms.dimBOuter));
resultMatrix.numbers[index] = value;
}
}
program_source:56:31: warning: equality comparison with extraneous parentheses
kernel void tint_symbol(uint3 local_id [[thread_position_in_threadgroup]], uint3 global_id [[thread_position_in_grid]], uint local_invocation_index [[thread_index_in_threadgroup]], constant Uniforms& uniforms [[buffer(3)]], const device Matrix& firstMatrix [[buffer(0)]], const device Matrix& secondMatrix [[buffer(1)]], device Matrix& resultMatrix [[buffer(2)]]) {
threadgroup tint_array_wrapper tint_symbol_4;
threadgroup tint_array_wrapper tint_symbol_5;
if ((local_invocation_index == 0u)) {
~~~~~~~~~~~~~~~~~~~~~~~^~~~~
program_source:56:31: note: remove extraneous parentheses around the comparison to silence this warning
if ((local_invocation_index == 0u)) {
~ ^ ~
program_source:56:31: note: use '=' to turn this equality comparison into an assignment
if ((local_invocation_index == 0u)) {
^~
=
program_source:122:30: error: default initialization of an object of const type 'const uint' (aka 'const unsigned int')
uint const inputRow;
^
= 0
program_source:123:30: error: default initialization of an object of const type 'const uint' (aka 'const unsigned int')
uint const inputCol;
^
= 0
program_source:133:30: error: cannot assign to variable 'inputRow' with const-qualified type 'const uint' (aka 'const unsigned int')
inputRow = (tileRow + innerRow);
~~~~~~~~ ^
program_source:122:30: note: variable 'inputRow' declared const here
uint const inputRow;
~~~~~~~~~~~^~~~~~~~
program_source:134:30: error: cannot assign to variable 'inputCol' with const-qualified type 'const uint' (aka 'const unsigned int')
inputCol = (tileColA + innerCol);
~~~~~~~~ ^
program_source:123:30: note: variable 'inputCol' declared const here
uint const inputCol;
~~~~~~~~~~~^~~~~~~~
program_source:159:30: error: default initialization of an object of const type 'const uint' (aka 'const unsigned int')
uint const inputRow;
^
= 0
program_source:160:30: error: default initialization of an object of const type 'const uint' (aka 'const unsigned int')
uint const inputCol;
^
= 0
program_source:170:30: error: cannot assign to variable 'inputRow' with const-qualified type 'const uint' (aka 'const unsigned int')
inputRow = (tileRowB + innerRow);
~~~~~~~~ ^
program_source:159:30: note: variable 'inputRow' declared const here
uint const inputRow;
~~~~~~~~~~~^~~~~~~~
program_source:171:30: error: cannot assign to variable 'inputCol' with const-qualified type 'const uint' (aka 'const unsigned int')
inputCol = (tileCol + innerCol);
~~~~~~~~ ^
program_source:160:30: note: variable 'inputCol' declared const here
uint const inputCol;
~~~~~~~~~~~^~~~~~~~
program_source:228:36: error: default initialization of an object of const type 'const uint' (aka 'const unsigned int')
uint const index;
^
= 0
program_source:238:33: error: cannot assign to variable 'index' with const-qualified type 'const uint' (aka 'const unsigned int')
index = ((innerRow * ColPerThread) + innerCol);
~~~~~ ^
program_source:228:36: note: variable 'index' declared const here
uint const index;
~~~~~~~~~~~^~~~~
program_source:270:24: error: default initialization of an object of const type 'const uint' (aka 'const unsigned int')
uint const index;
^
= 0
program_source:280:21: error: cannot assign to variable 'index' with const-qualified type 'const uint' (aka 'const unsigned int')
index = ((innerRow * ColPerThread) + innerCol);
~~~~~ ^
program_source:270:24: note: variable 'index' declared const here
uint const index;
~~~~~~~~~~~^~~~~
tint_array_wrapper const tint_symbol_2 = {.arr={}};
tint_symbol_4 = tint_symbol_2;
tint_array_wrapper const tint_symbol_3 = {.arr={}};
tint_symbol_5 = tint_symbol_3;
}
threadgroup_barrier(mem_flags::mem_threadgroup);
uint const tileRow = (local_id.y * RowPerThread);
uint const tileCol = (local_id.x * ColPerThread);
uint const globalRow = (global_id.y * RowPerThread);
uint const globalCol = (global_id.x * ColPerThread);
uint const numTiles = (((uniforms.dimInner - 1u) / TileInner) + 1u);
tint_array_wrapper_2 acc = {};
float ACached = 0.0f;
tint_array_wrapper_3 BCached = {};
{
uint index = 0u;
while (true) {
if (!((index < (RowPerThread * ColPerThread)))) {
break;
}
acc.arr[index] = 0.0f;
{
index = (index + 1u);
}
}
}
uint const ColPerThreadA = (TileInner / 16u);
uint const tileColA = (local_id.x * ColPerThreadA);
uint const RowPerThreadB = (TileInner / 16u);
uint const tileRowB = (local_id.y * RowPerThreadB);
{
uint t = 0u;
while (true) {
if (!((t < numTiles))) {
break;
}
{
uint innerRow = 0u;
while (true) {
if (!((innerRow < RowPerThread))) {
break;
}
{
uint innerCol = 0u;
while (true) {
if (!((innerCol < ColPerThreadA))) {
break;
}
uint const inputRow = (tileRow + innerRow);
uint const inputCol = (tileColA + innerCol);
tint_symbol_4.arr[inputRow].arr[inputCol] = mm_readA(uniforms, firstMatrix, (globalRow + innerRow), ((t * TileInner) + inputCol));
{
innerCol = (innerCol + 1u);
}
}
}
{
innerRow = (innerRow + 1u);
}
}
}
{
uint innerRow = 0u;
while (true) {
if (!((innerRow < RowPerThreadB))) {
break;
}
{
uint innerCol = 0u;
while (true) {
if (!((innerCol < ColPerThread))) {
break;
}
uint const inputRow = (tileRowB + innerRow);
uint const inputCol = (tileCol + innerCol);
tint_symbol_5.arr[innerCol].arr[inputCol] = mm_readB(uniforms, secondMatrix, ((t * TileInner) + inputRow), (globalCol + innerCol));
{
innerCol = (innerCol + 1u);
}
}
}
{
innerRow = (innerRow + 1u);
}
}
}
threadgroup_barrier(mem_flags::mem_threadgroup);
{
uint k = 0u;
while (true) {
if (!((k < TileInner))) {
break;
}
{
uint inner = 0u;
while (true) {
if (!((inner < ColPerThread))) {
break;
}
BCached.arr[inner] = tint_symbol_5.arr[k].arr[(tileCol + inner)];
{
inner = (inner + 1u);
}
}
}
{
uint innerRow = 0u;
while (true) {
if (!((innerRow < RowPerThread))) {
break;
}
ACached = tint_symbol_4.arr[(tileRow + innerRow)].arr[k];
{
uint innerCol = 0u;
while (true) {
if (!((innerCol < ColPerThread))) {
break;
}
uint const index = ((innerRow * ColPerThread) + innerCol);
acc.arr[index] = (acc.arr[index] + (ACached * BCached.arr[innerCol]));
{
innerCol = (innerCol + 1u);
}
}
}
{
innerRow = (innerRow + 1u);
}
}
}
{
k = (k + 1u);
}
}
}
threadgroup_barrier(mem_flags::mem_threadgroup);
{
t = (t + 1u);
}
}
}
{
uint innerRow = 0u;
while (true) {
if (!((innerRow < RowPerThread))) {
break;
}
{
uint innerCol = 0u;
while (true) {
if (!((innerCol < ColPerThread))) {
break;
}
uint const index = ((innerRow * ColPerThread) + innerCol);
mm_write(uniforms, resultMatrix, (globalRow + innerRow), (globalCol + innerCol), acc.arr[index]);
{
innerCol = (innerCol + 1u);
}
}
}
{
innerRow = (innerRow + 1u);
}
}
}
return;
}

View File

@@ -1,37 +1,33 @@
SKIP: FAILED
#include <metal_stdlib>
[[block]]
using namespace metal;
struct tint_symbol_2 {
/* 0x0000 */ uint buffer_size[2];
};
struct SB_RO {
arg_0 : array<i32>;
/* 0x0000 */ int arg_0[1];
};
struct tint_symbol {
float4 value [[position]];
};
[[group(0), binding(1)]] var<storage, read> sb_ro : SB_RO;
fn arrayLength_1588cd() {
var res : u32 = arrayLength(&(sb_ro.arg_0));
void arrayLength_1588cd(constant tint_symbol_2& tint_symbol_3) {
uint res = ((tint_symbol_3.buffer_size[1u] - 0u) / 4u);
}
struct tint_symbol {
[[builtin(position)]]
value : vec4<f32>;
};
[[stage(vertex)]]
fn vertex_main() -> tint_symbol {
arrayLength_1588cd();
let tint_symbol_1 : tint_symbol = tint_symbol(vec4<f32>());
vertex tint_symbol vertex_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_1588cd(tint_symbol_3);
tint_symbol const tint_symbol_1 = {.value=float4()};
return tint_symbol_1;
}
[[stage(fragment)]]
fn fragment_main() {
arrayLength_1588cd();
fragment void fragment_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_1588cd(tint_symbol_3);
return;
}
[[stage(compute)]]
fn compute_main() {
arrayLength_1588cd();
kernel void compute_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_1588cd(tint_symbol_3);
return;
}
Failed to generate: error: Unknown import method: arrayLength

View File

@@ -1,37 +1,33 @@
SKIP: FAILED
#include <metal_stdlib>
[[block]]
using namespace metal;
struct tint_symbol_2 {
/* 0x0000 */ uint buffer_size[1];
};
struct SB_RW {
arg_0 : array<i32>;
/* 0x0000 */ int arg_0[1];
};
struct tint_symbol {
float4 value [[position]];
};
[[group(0), binding(0)]] var<storage, read_write> sb_rw : SB_RW;
fn arrayLength_61b1c7() {
var res : u32 = arrayLength(&(sb_rw.arg_0));
void arrayLength_61b1c7(constant tint_symbol_2& tint_symbol_3) {
uint res = ((tint_symbol_3.buffer_size[0u] - 0u) / 4u);
}
struct tint_symbol {
[[builtin(position)]]
value : vec4<f32>;
};
[[stage(vertex)]]
fn vertex_main() -> tint_symbol {
arrayLength_61b1c7();
let tint_symbol_1 : tint_symbol = tint_symbol(vec4<f32>());
vertex tint_symbol vertex_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_61b1c7(tint_symbol_3);
tint_symbol const tint_symbol_1 = {.value=float4()};
return tint_symbol_1;
}
[[stage(fragment)]]
fn fragment_main() {
arrayLength_61b1c7();
fragment void fragment_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_61b1c7(tint_symbol_3);
return;
}
[[stage(compute)]]
fn compute_main() {
arrayLength_61b1c7();
kernel void compute_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_61b1c7(tint_symbol_3);
return;
}
Failed to generate: error: Unknown import method: arrayLength

View File

@@ -1,37 +1,33 @@
SKIP: FAILED
#include <metal_stdlib>
[[block]]
using namespace metal;
struct tint_symbol_2 {
/* 0x0000 */ uint buffer_size[2];
};
struct SB_RO {
arg_0 : array<f32>;
/* 0x0000 */ float arg_0[1];
};
struct tint_symbol {
float4 value [[position]];
};
[[group(0), binding(1)]] var<storage, read> sb_ro : SB_RO;
fn arrayLength_a0f5ca() {
var res : u32 = arrayLength(&(sb_ro.arg_0));
void arrayLength_a0f5ca(constant tint_symbol_2& tint_symbol_3) {
uint res = ((tint_symbol_3.buffer_size[1u] - 0u) / 4u);
}
struct tint_symbol {
[[builtin(position)]]
value : vec4<f32>;
};
[[stage(vertex)]]
fn vertex_main() -> tint_symbol {
arrayLength_a0f5ca();
let tint_symbol_1 : tint_symbol = tint_symbol(vec4<f32>());
vertex tint_symbol vertex_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_a0f5ca(tint_symbol_3);
tint_symbol const tint_symbol_1 = {.value=float4()};
return tint_symbol_1;
}
[[stage(fragment)]]
fn fragment_main() {
arrayLength_a0f5ca();
fragment void fragment_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_a0f5ca(tint_symbol_3);
return;
}
[[stage(compute)]]
fn compute_main() {
arrayLength_a0f5ca();
kernel void compute_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_a0f5ca(tint_symbol_3);
return;
}
Failed to generate: error: Unknown import method: arrayLength

View File

@@ -1,37 +1,33 @@
SKIP: FAILED
#include <metal_stdlib>
[[block]]
using namespace metal;
struct tint_symbol_2 {
/* 0x0000 */ uint buffer_size[1];
};
struct SB_RW {
arg_0 : array<f32>;
/* 0x0000 */ float arg_0[1];
};
struct tint_symbol {
float4 value [[position]];
};
[[group(0), binding(0)]] var<storage, read_write> sb_rw : SB_RW;
fn arrayLength_cdd123() {
var res : u32 = arrayLength(&(sb_rw.arg_0));
void arrayLength_cdd123(constant tint_symbol_2& tint_symbol_3) {
uint res = ((tint_symbol_3.buffer_size[0u] - 0u) / 4u);
}
struct tint_symbol {
[[builtin(position)]]
value : vec4<f32>;
};
[[stage(vertex)]]
fn vertex_main() -> tint_symbol {
arrayLength_cdd123();
let tint_symbol_1 : tint_symbol = tint_symbol(vec4<f32>());
vertex tint_symbol vertex_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_cdd123(tint_symbol_3);
tint_symbol const tint_symbol_1 = {.value=float4()};
return tint_symbol_1;
}
[[stage(fragment)]]
fn fragment_main() {
arrayLength_cdd123();
fragment void fragment_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_cdd123(tint_symbol_3);
return;
}
[[stage(compute)]]
fn compute_main() {
arrayLength_cdd123();
kernel void compute_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_cdd123(tint_symbol_3);
return;
}
Failed to generate: error: Unknown import method: arrayLength

View File

@@ -1,37 +1,33 @@
SKIP: FAILED
#include <metal_stdlib>
[[block]]
using namespace metal;
struct tint_symbol_2 {
/* 0x0000 */ uint buffer_size[2];
};
struct SB_RO {
arg_0 : array<u32>;
/* 0x0000 */ uint arg_0[1];
};
struct tint_symbol {
float4 value [[position]];
};
[[group(0), binding(1)]] var<storage, read> sb_ro : SB_RO;
fn arrayLength_cfca0a() {
var res : u32 = arrayLength(&(sb_ro.arg_0));
void arrayLength_cfca0a(constant tint_symbol_2& tint_symbol_3) {
uint res = ((tint_symbol_3.buffer_size[1u] - 0u) / 4u);
}
struct tint_symbol {
[[builtin(position)]]
value : vec4<f32>;
};
[[stage(vertex)]]
fn vertex_main() -> tint_symbol {
arrayLength_cfca0a();
let tint_symbol_1 : tint_symbol = tint_symbol(vec4<f32>());
vertex tint_symbol vertex_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_cfca0a(tint_symbol_3);
tint_symbol const tint_symbol_1 = {.value=float4()};
return tint_symbol_1;
}
[[stage(fragment)]]
fn fragment_main() {
arrayLength_cfca0a();
fragment void fragment_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_cfca0a(tint_symbol_3);
return;
}
[[stage(compute)]]
fn compute_main() {
arrayLength_cfca0a();
kernel void compute_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_cfca0a(tint_symbol_3);
return;
}
Failed to generate: error: Unknown import method: arrayLength

View File

@@ -1,37 +1,33 @@
SKIP: FAILED
#include <metal_stdlib>
[[block]]
using namespace metal;
struct tint_symbol_2 {
/* 0x0000 */ uint buffer_size[1];
};
struct SB_RW {
arg_0 : array<u32>;
/* 0x0000 */ uint arg_0[1];
};
struct tint_symbol {
float4 value [[position]];
};
[[group(0), binding(0)]] var<storage, read_write> sb_rw : SB_RW;
fn arrayLength_eb510f() {
var res : u32 = arrayLength(&(sb_rw.arg_0));
void arrayLength_eb510f(constant tint_symbol_2& tint_symbol_3) {
uint res = ((tint_symbol_3.buffer_size[0u] - 0u) / 4u);
}
struct tint_symbol {
[[builtin(position)]]
value : vec4<f32>;
};
[[stage(vertex)]]
fn vertex_main() -> tint_symbol {
arrayLength_eb510f();
let tint_symbol_1 : tint_symbol = tint_symbol(vec4<f32>());
vertex tint_symbol vertex_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_eb510f(tint_symbol_3);
tint_symbol const tint_symbol_1 = {.value=float4()};
return tint_symbol_1;
}
[[stage(fragment)]]
fn fragment_main() {
arrayLength_eb510f();
fragment void fragment_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_eb510f(tint_symbol_3);
return;
}
[[stage(compute)]]
fn compute_main() {
arrayLength_eb510f();
kernel void compute_main(constant tint_symbol_2& tint_symbol_3 [[buffer(30)]]) {
arrayLength_eb510f(tint_symbol_3);
return;
}
Failed to generate: error: Unknown import method: arrayLength

View File

@@ -63,33 +63,31 @@ kernel void comp_main(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], c
float2 vel = 0.0f;
{
uint i = 0u;
{
bool tint_msl_is_first_1 = true;
for(;;) {
if (!tint_msl_is_first_1) {
while (true) {
if (!((i < 5u))) {
break;
}
if ((i == index)) {
{
i = (i + 1u);
}
tint_msl_is_first_1 = false;
if (!((i < 5u))) {
break;
}
if ((i == index)) {
continue;
}
pos = particlesA.particles.arr[i].pos.xy;
vel = particlesA.particles.arr[i].vel.xy;
if (( distance(pos, vPos) < params.rule1Distance)) {
cMass = (cMass + pos);
cMassCount = (cMassCount + 1);
}
if (( distance(pos, vPos) < params.rule2Distance)) {
colVel = (colVel - (pos - vPos));
}
if (( distance(pos, vPos) < params.rule3Distance)) {
cVel = (cVel + vel);
cVelCount = (cVelCount + 1);
}
continue;
}
pos = particlesA.particles.arr[i].pos.xy;
vel = particlesA.particles.arr[i].vel.xy;
if (( distance(pos, vPos) < params.rule1Distance)) {
cMass = (cMass + pos);
cMassCount = (cMassCount + 1);
}
if (( distance(pos, vPos) < params.rule2Distance)) {
colVel = (colVel - (pos - vPos));
}
if (( distance(pos, vPos) < params.rule3Distance)) {
cVel = (cVel + vel);
cVelCount = (cVelCount + 1);
}
{
i = (i + 1u);
}
}
}