mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
writer/msl: Emit builtins as parameters
Add a config parameter for the CanonicalizeEntryPoint transform that selects between emitting builtins as parameters (for MSL) or struct members (for HLSL). This fixes all of the shader IO issues in Tint's E2E tests for MSL. Fixed: tint:817 Change-Id: Ieb31cdbd2e4d96ac41f8d8515fd07ead8241d770 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53282 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: James Price <jrprice@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
3604e80321
commit
7697c31e84
@@ -1,5 +1,3 @@
|
||||
SKIP: crbug.com/tint/817
|
||||
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
@@ -27,11 +25,11 @@ struct SimParams {
|
||||
/* 0x0014 */ float rule2Scale;
|
||||
/* 0x0018 */ float rule3Scale;
|
||||
};
|
||||
struct Particles {
|
||||
/* 0x0000 */ Particle particles[5];
|
||||
struct tint_array_wrapper_0 {
|
||||
Particle array[5];
|
||||
};
|
||||
struct tint_symbol_5 {
|
||||
uint3 gl_GlobalInvocationID [[thread_position_in_grid]];
|
||||
struct Particles {
|
||||
/* 0x0000 */ tint_array_wrapper_0 particles;
|
||||
};
|
||||
|
||||
vertex tint_symbol_2 vert_main(tint_symbol_1 tint_symbol [[stage_in]]) {
|
||||
@@ -40,21 +38,22 @@ vertex tint_symbol_2 vert_main(tint_symbol_1 tint_symbol [[stage_in]]) {
|
||||
float2 const a_pos = tint_symbol.a_pos;
|
||||
float angle = -( atan2(a_particleVel.x, a_particleVel.y));
|
||||
float2 pos = float2(((a_pos.x * cos(angle)) - (a_pos.y * sin(angle))), ((a_pos.x * sin(angle)) + (a_pos.y * cos(angle))));
|
||||
return {float4((pos + a_particlePos), 0.0f, 1.0f)};
|
||||
tint_symbol_2 const tint_symbol_5 = {.value=float4((pos + a_particlePos), 0.0f, 1.0f)};
|
||||
return tint_symbol_5;
|
||||
}
|
||||
|
||||
fragment tint_symbol_3 frag_main() {
|
||||
return {float4(1.0f, 1.0f, 1.0f, 1.0f)};
|
||||
tint_symbol_3 const tint_symbol_6 = {.value=float4(1.0f, 1.0f, 1.0f, 1.0f)};
|
||||
return tint_symbol_6;
|
||||
}
|
||||
|
||||
kernel void comp_main(tint_symbol_5 tint_symbol_4 [[stage_in]], constant SimParams& params [[buffer(0)]], device Particles& particlesA [[buffer(1)]], device Particles& particlesB [[buffer(2)]]) {
|
||||
uint3 const gl_GlobalInvocationID = tint_symbol_4.gl_GlobalInvocationID;
|
||||
kernel void comp_main(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant SimParams& params [[buffer(0)]], device Particles& particlesA [[buffer(1)]], device Particles& particlesB [[buffer(2)]]) {
|
||||
uint index = gl_GlobalInvocationID.x;
|
||||
if ((index >= 5u)) {
|
||||
return;
|
||||
}
|
||||
float2 vPos = particlesA.particles[index].pos;
|
||||
float2 vVel = particlesA.particles[index].vel;
|
||||
float2 vPos = particlesA.particles.array[index].pos;
|
||||
float2 vVel = particlesA.particles.array[index].vel;
|
||||
float2 cMass = float2(0.0f, 0.0f);
|
||||
float2 cVel = float2(0.0f, 0.0f);
|
||||
float2 colVel = float2(0.0f, 0.0f);
|
||||
@@ -78,8 +77,8 @@ kernel void comp_main(tint_symbol_5 tint_symbol_4 [[stage_in]], constant SimPara
|
||||
if ((i == index)) {
|
||||
continue;
|
||||
}
|
||||
pos = particlesA.particles[i].pos.xy;
|
||||
vel = particlesA.particles[i].vel.xy;
|
||||
pos = particlesA.particles.array[i].pos.xy;
|
||||
vel = particlesA.particles.array[i].vel.xy;
|
||||
if (( distance(pos, vPos) < params.rule1Distance)) {
|
||||
cMass = (cMass + pos);
|
||||
cMassCount = (cMassCount + 1);
|
||||
@@ -115,8 +114,8 @@ kernel void comp_main(tint_symbol_5 tint_symbol_4 [[stage_in]], constant SimPara
|
||||
if ((vPos.y > 1.0f)) {
|
||||
vPos.y = -1.0f;
|
||||
}
|
||||
particlesB.particles[index].pos = vPos;
|
||||
particlesB.particles[index].vel = vVel;
|
||||
particlesB.particles.array[index].pos = vPos;
|
||||
particlesB.particles.array[index].vel = vVel;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
SKIP: crbug.com/tint/817
|
||||
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct tint_symbol_1 {
|
||||
int VertexIndex [[vertex_id]];
|
||||
};
|
||||
struct tint_symbol_2 {
|
||||
float4 value [[position]];
|
||||
};
|
||||
struct tint_symbol_3 {
|
||||
struct tint_symbol_2 {
|
||||
float4 value [[color(0)]];
|
||||
};
|
||||
struct tint_array_wrapper_0 {
|
||||
float2 array[3];
|
||||
};
|
||||
|
||||
constant float2 pos[3] = {float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)};
|
||||
vertex tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol [[stage_in]]) {
|
||||
int const VertexIndex = tint_symbol.VertexIndex;
|
||||
return {float4(pos[VertexIndex], 0.0f, 1.0f)};
|
||||
constant tint_array_wrapper_0 pos = {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)};
|
||||
return tint_symbol_3;
|
||||
}
|
||||
|
||||
fragment tint_symbol_3 frag_main() {
|
||||
return {float4(1.0f, 0.0f, 0.0f, 1.0f)};
|
||||
fragment tint_symbol_2 frag_main() {
|
||||
tint_symbol_2 const tint_symbol_4 = {.value=float4(1.0f, 0.0f, 0.0f, 1.0f)};
|
||||
return tint_symbol_4;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user