mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
Add transform/WrapArraysInStructs
And replace the MSL writer's logic to do this with the transform. We need to do the same thing in HLSL, and in the future GLSL too. Partially reverts fbfde720 Change-Id: Ie280e011bc3ded8e15ccacc0aeb12da3c2407389 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54242 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
@@ -25,11 +25,11 @@ struct SimParams {
|
||||
/* 0x0014 */ float rule2Scale;
|
||||
/* 0x0018 */ float rule3Scale;
|
||||
};
|
||||
struct tint_array_wrapper_0 {
|
||||
Particle array[5];
|
||||
struct tint_array_wrapper {
|
||||
/* 0x0000 */ Particle arr[5];
|
||||
};
|
||||
struct Particles {
|
||||
/* 0x0000 */ tint_array_wrapper_0 particles;
|
||||
/* 0x0000 */ tint_array_wrapper particles;
|
||||
};
|
||||
|
||||
vertex tint_symbol_2 vert_main(tint_symbol_1 tint_symbol [[stage_in]]) {
|
||||
@@ -52,8 +52,8 @@ kernel void comp_main(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], c
|
||||
if ((index >= 5u)) {
|
||||
return;
|
||||
}
|
||||
float2 vPos = particlesA.particles.array[index].pos;
|
||||
float2 vVel = particlesA.particles.array[index].vel;
|
||||
float2 vPos = particlesA.particles.arr[index].pos;
|
||||
float2 vVel = particlesA.particles.arr[index].vel;
|
||||
float2 cMass = float2(0.0f, 0.0f);
|
||||
float2 cVel = float2(0.0f, 0.0f);
|
||||
float2 colVel = float2(0.0f, 0.0f);
|
||||
@@ -77,8 +77,8 @@ kernel void comp_main(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], c
|
||||
if ((i == index)) {
|
||||
continue;
|
||||
}
|
||||
pos = particlesA.particles.array[i].pos.xy;
|
||||
vel = particlesA.particles.array[i].vel.xy;
|
||||
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);
|
||||
@@ -114,8 +114,8 @@ kernel void comp_main(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], c
|
||||
if ((vPos.y > 1.0f)) {
|
||||
vPos.y = -1.0f;
|
||||
}
|
||||
particlesB.particles.array[index].pos = vPos;
|
||||
particlesB.particles.array[index].vel = vVel;
|
||||
particlesB.particles.arr[index].pos = vPos;
|
||||
particlesB.particles.arr[index].vel = vVel;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct tint_array_wrapper {
|
||||
float2 arr[3];
|
||||
};
|
||||
struct tint_symbol_1 {
|
||||
float4 value [[position]];
|
||||
};
|
||||
struct tint_symbol_2 {
|
||||
float4 value [[color(0)]];
|
||||
};
|
||||
struct tint_array_wrapper_0 {
|
||||
float2 array[3];
|
||||
};
|
||||
|
||||
constant tint_array_wrapper_0 pos = {float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)};
|
||||
constant tint_array_wrapper pos = {.arr={float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)}};
|
||||
vertex tint_symbol_1 vtx_main(uint VertexIndex [[vertex_id]]) {
|
||||
tint_symbol_1 const tint_symbol_3 = {.value=float4(pos.array[VertexIndex], 0.0f, 1.0f)};
|
||||
tint_symbol_1 const tint_symbol_3 = {.value=float4(pos.arr[VertexIndex], 0.0f, 1.0f)};
|
||||
return tint_symbol_3;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user