tint->dawn: Shuffle source tree in preperation of merging repos

docs/    -> docs/tint/
fuzzers/ -> src/tint/fuzzers/
samples/ -> src/tint/cmd/
src/     -> src/tint/
test/    -> test/tint/

BUG=tint:1418,tint:1433

Change-Id: Id2aa79f989aef3245b80ef4aa37a27ff16cd700b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80482
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
Ryan Harrison
2022-02-21 15:19:07 +00:00
committed by Tint LUCI CQ
parent 38f1e9c75c
commit dbc13af287
12231 changed files with 4897 additions and 4871 deletions

View File

@@ -0,0 +1,134 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// vertex shader
@stage(vertex)
fn vert_main(@location(0) a_particlePos : vec2<f32>,
@location(1) a_particleVel : vec2<f32>,
@location(2) a_pos : vec2<f32>)
-> @builtin(position) vec4<f32> {
var angle : f32 = -atan2(a_particleVel.x, a_particleVel.y);
var pos : vec2<f32> = vec2<f32>(
(a_pos.x * cos(angle)) - (a_pos.y * sin(angle)),
(a_pos.x * sin(angle)) + (a_pos.y * cos(angle)));
return vec4<f32>(pos + a_particlePos, 0.0, 1.0);
}
// fragment shader
@stage(fragment)
fn frag_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
}
// compute shader
struct Particle {
pos : vec2<f32>;
vel : vec2<f32>;
};
struct SimParams {
deltaT : f32;
rule1Distance : f32;
rule2Distance : f32;
rule3Distance : f32;
rule1Scale : f32;
rule2Scale : f32;
rule3Scale : f32;
};
struct Particles {
particles : array<Particle, 5>;
};
@binding(0) @group(0) var<uniform> params : SimParams;
@binding(1) @group(0) var<storage, read_write> particlesA : Particles;
@binding(2) @group(0) var<storage, read_write> particlesB : Particles;
// https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp
@stage(compute) @workgroup_size(1)
fn comp_main(
@builtin(global_invocation_id) gl_GlobalInvocationID : vec3<u32>) {
var index : u32 = gl_GlobalInvocationID.x;
if (index >= 5u) {
return;
}
var vPos : vec2<f32> = particlesA.particles[index].pos;
var vVel : vec2<f32> = particlesA.particles[index].vel;
var cMass : vec2<f32> = vec2<f32>(0.0, 0.0);
var cVel : vec2<f32> = vec2<f32>(0.0, 0.0);
var colVel : vec2<f32> = vec2<f32>(0.0, 0.0);
var cMassCount : i32 = 0;
var cVelCount : i32 = 0;
var pos : vec2<f32>;
var vel : vec2<f32>;
for(var i : u32 = 0u; i < 5u; i = i + 1u) {
if (i == index) {
continue;
}
pos = particlesA.particles[i].pos.xy;
vel = particlesA.particles[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;
}
}
if (cMassCount > 0) {
cMass =
(cMass / vec2<f32>(f32(cMassCount), f32(cMassCount))) - vPos;
}
if (cVelCount > 0) {
cVel = cVel / vec2<f32>(f32(cVelCount), f32(cVelCount));
}
vVel = vVel + (cMass * params.rule1Scale) + (colVel * params.rule2Scale) +
(cVel * params.rule3Scale);
// clamp velocity for a more pleasing simulation
vVel = normalize(vVel) * clamp(length(vVel), 0.0, 0.1);
// kinematic update
vPos = vPos + (vVel * params.deltaT);
// Wrap around boundary
if (vPos.x < -1.0) {
vPos.x = 1.0;
}
if (vPos.x > 1.0) {
vPos.x = -1.0;
}
if (vPos.y < -1.0) {
vPos.y = 1.0;
}
if (vPos.y > 1.0) {
vPos.y = -1.0;
}
// Write back
particlesB.particles[index].pos = vPos;
particlesB.particles[index].vel = vVel;
}

View File

@@ -0,0 +1,170 @@
#version 310 es
layout(location = 0) in vec2 a_particlePos_1;
layout(location = 1) in vec2 a_particleVel_1;
layout(location = 2) in vec2 a_pos_1;
struct Particle {
vec2 pos;
vec2 vel;
};
struct SimParams {
float deltaT;
float rule1Distance;
float rule2Distance;
float rule3Distance;
float rule1Scale;
float rule2Scale;
float rule3Scale;
};
struct Particles {
Particle particles[5];
};
vec4 vert_main(vec2 a_particlePos, vec2 a_particleVel, vec2 a_pos) {
float angle = -(atan(a_particleVel.x, a_particleVel.y));
vec2 pos = vec2(((a_pos.x * cos(angle)) - (a_pos.y * sin(angle))), ((a_pos.x * sin(angle)) + (a_pos.y * cos(angle))));
return vec4((pos + a_particlePos), 0.0f, 1.0f);
}
void main() {
vec4 inner_result = vert_main(a_particlePos_1, a_particleVel_1, a_pos_1);
gl_Position = inner_result;
gl_Position.y = -(gl_Position.y);
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
return;
}
#version 310 es
precision mediump float;
layout(location = 0) out vec4 value;
struct Particle {
vec2 pos;
vec2 vel;
};
struct SimParams {
float deltaT;
float rule1Distance;
float rule2Distance;
float rule3Distance;
float rule1Scale;
float rule2Scale;
float rule3Scale;
};
struct Particles {
Particle particles[5];
};
vec4 frag_main() {
return vec4(1.0f, 1.0f, 1.0f, 1.0f);
}
void main() {
vec4 inner_result = frag_main();
value = inner_result;
return;
}
#version 310 es
struct Particle {
vec2 pos;
vec2 vel;
};
struct SimParams {
float deltaT;
float rule1Distance;
float rule2Distance;
float rule3Distance;
float rule1Scale;
float rule2Scale;
float rule3Scale;
};
struct Particles {
Particle particles[5];
};
layout(binding = 0) uniform SimParams_1 {
float deltaT;
float rule1Distance;
float rule2Distance;
float rule3Distance;
float rule1Scale;
float rule2Scale;
float rule3Scale;
} params;
layout(binding = 1, std430) buffer Particles_1 {
Particle particles[5];
} particlesA;
layout(binding = 2, std430) buffer Particles_2 {
Particle particles[5];
} particlesB;
void comp_main(uvec3 tint_symbol) {
uint index = tint_symbol.x;
if ((index >= 5u)) {
return;
}
vec2 vPos = particlesA.particles[index].pos;
vec2 vVel = particlesA.particles[index].vel;
vec2 cMass = vec2(0.0f, 0.0f);
vec2 cVel = vec2(0.0f, 0.0f);
vec2 colVel = vec2(0.0f, 0.0f);
int cMassCount = 0;
int cVelCount = 0;
vec2 pos = vec2(0.0f, 0.0f);
vec2 vel = vec2(0.0f, 0.0f);
{
for(uint i = 0u; (i < 5u); i = (i + 1u)) {
if ((i == index)) {
continue;
}
pos = particlesA.particles[i].pos.xy;
vel = particlesA.particles[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);
}
}
}
if ((cMassCount > 0)) {
cMass = ((cMass / vec2(float(cMassCount), float(cMassCount))) - vPos);
}
if ((cVelCount > 0)) {
cVel = (cVel / vec2(float(cVelCount), float(cVelCount)));
}
vVel = (((vVel + (cMass * params.rule1Scale)) + (colVel * params.rule2Scale)) + (cVel * params.rule3Scale));
vVel = (normalize(vVel) * clamp(length(vVel), 0.0f, 0.100000001f));
vPos = (vPos + (vVel * params.deltaT));
if ((vPos.x < -1.0f)) {
vPos.x = 1.0f;
}
if ((vPos.x > 1.0f)) {
vPos.x = -1.0f;
}
if ((vPos.y < -1.0f)) {
vPos.y = 1.0f;
}
if ((vPos.y > 1.0f)) {
vPos.y = -1.0f;
}
particlesB.particles[index].pos = vPos;
particlesB.particles[index].vel = vVel;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
comp_main(gl_GlobalInvocationID);
return;
}

View File

@@ -0,0 +1,111 @@
struct tint_symbol_1 {
float2 a_particlePos : TEXCOORD0;
float2 a_particleVel : TEXCOORD1;
float2 a_pos : TEXCOORD2;
};
struct tint_symbol_2 {
float4 value : SV_Position;
};
float4 vert_main_inner(float2 a_particlePos, float2 a_particleVel, float2 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 vert_main(tint_symbol_1 tint_symbol) {
const float4 inner_result = vert_main_inner(tint_symbol.a_particlePos, tint_symbol.a_particleVel, tint_symbol.a_pos);
tint_symbol_2 wrapper_result = (tint_symbol_2)0;
wrapper_result.value = inner_result;
return wrapper_result;
}
struct tint_symbol_3 {
float4 value : SV_Target0;
};
float4 frag_main_inner() {
return float4(1.0f, 1.0f, 1.0f, 1.0f);
}
tint_symbol_3 frag_main() {
const float4 inner_result_1 = frag_main_inner();
tint_symbol_3 wrapper_result_1 = (tint_symbol_3)0;
wrapper_result_1.value = inner_result_1;
return wrapper_result_1;
}
cbuffer cbuffer_params : register(b0, space0) {
uint4 params[2];
};
RWByteAddressBuffer particlesA : register(u1, space0);
RWByteAddressBuffer particlesB : register(u2, space0);
struct tint_symbol_5 {
uint3 gl_GlobalInvocationID : SV_DispatchThreadID;
};
void comp_main_inner(uint3 gl_GlobalInvocationID) {
uint index = gl_GlobalInvocationID.x;
if ((index >= 5u)) {
return;
}
float2 vPos = asfloat(particlesA.Load2((16u * index)));
float2 vVel = asfloat(particlesA.Load2(((16u * index) + 8u)));
float2 cMass = float2(0.0f, 0.0f);
float2 cVel = float2(0.0f, 0.0f);
float2 colVel = float2(0.0f, 0.0f);
int cMassCount = 0;
int cVelCount = 0;
float2 pos = float2(0.0f, 0.0f);
float2 vel = float2(0.0f, 0.0f);
{
[loop] for(uint i = 0u; (i < 5u); i = (i + 1u)) {
if ((i == index)) {
continue;
}
pos = asfloat(particlesA.Load2((16u * i))).xy;
vel = asfloat(particlesA.Load2(((16u * i) + 8u))).xy;
if ((distance(pos, vPos) < asfloat(params[0].y))) {
cMass = (cMass + pos);
cMassCount = (cMassCount + 1);
}
if ((distance(pos, vPos) < asfloat(params[0].z))) {
colVel = (colVel - (pos - vPos));
}
if ((distance(pos, vPos) < asfloat(params[0].w))) {
cVel = (cVel + vel);
cVelCount = (cVelCount + 1);
}
}
}
if ((cMassCount > 0)) {
cMass = ((cMass / float2(float(cMassCount), float(cMassCount))) - vPos);
}
if ((cVelCount > 0)) {
cVel = (cVel / float2(float(cVelCount), float(cVelCount)));
}
vVel = (((vVel + (cMass * asfloat(params[1].x))) + (colVel * asfloat(params[1].y))) + (cVel * asfloat(params[1].z)));
vVel = (normalize(vVel) * clamp(length(vVel), 0.0f, 0.100000001f));
vPos = (vPos + (vVel * asfloat(params[0].x)));
if ((vPos.x < -1.0f)) {
vPos.x = 1.0f;
}
if ((vPos.x > 1.0f)) {
vPos.x = -1.0f;
}
if ((vPos.y < -1.0f)) {
vPos.y = 1.0f;
}
if ((vPos.y > 1.0f)) {
vPos.y = -1.0f;
}
particlesB.Store2((16u * index), asuint(vPos));
particlesB.Store2(((16u * index) + 8u), asuint(vVel));
}
[numthreads(1, 1, 1)]
void comp_main(tint_symbol_5 tint_symbol_4) {
comp_main_inner(tint_symbol_4.gl_GlobalInvocationID);
return;
}

View File

@@ -0,0 +1,126 @@
#include <metal_stdlib>
using namespace metal;
struct tint_symbol_1 {
float2 a_particlePos [[attribute(0)]];
float2 a_particleVel [[attribute(1)]];
float2 a_pos [[attribute(2)]];
};
struct tint_symbol_2 {
float4 value [[position]];
};
float4 vert_main_inner(float2 a_particlePos, float2 a_particleVel, float2 a_pos) {
float angle = -(atan2(a_particleVel[0], a_particleVel[1]));
float2 pos = float2(((a_pos[0] * cos(angle)) - (a_pos[1] * sin(angle))), ((a_pos[0] * sin(angle)) + (a_pos[1] * cos(angle))));
return float4((pos + a_particlePos), 0.0f, 1.0f);
}
vertex tint_symbol_2 vert_main(tint_symbol_1 tint_symbol [[stage_in]]) {
float4 const inner_result = vert_main_inner(tint_symbol.a_particlePos, tint_symbol.a_particleVel, tint_symbol.a_pos);
tint_symbol_2 wrapper_result = {};
wrapper_result.value = inner_result;
return wrapper_result;
}
struct tint_symbol_3 {
float4 value [[color(0)]];
};
float4 frag_main_inner() {
return float4(1.0f, 1.0f, 1.0f, 1.0f);
}
fragment tint_symbol_3 frag_main() {
float4 const inner_result_1 = frag_main_inner();
tint_symbol_3 wrapper_result_1 = {};
wrapper_result_1.value = inner_result_1;
return wrapper_result_1;
}
struct Particle {
/* 0x0000 */ float2 pos;
/* 0x0008 */ float2 vel;
};
struct SimParams {
/* 0x0000 */ float deltaT;
/* 0x0004 */ float rule1Distance;
/* 0x0008 */ float rule2Distance;
/* 0x000c */ float rule3Distance;
/* 0x0010 */ float rule1Scale;
/* 0x0014 */ float rule2Scale;
/* 0x0018 */ float rule3Scale;
};
struct tint_array_wrapper {
/* 0x0000 */ Particle arr[5];
};
struct Particles {
/* 0x0000 */ tint_array_wrapper particles;
};
void comp_main_inner(uint3 gl_GlobalInvocationID, device Particles* const tint_symbol_4, const constant SimParams* const tint_symbol_5, device Particles* const tint_symbol_6) {
uint index = gl_GlobalInvocationID[0];
if ((index >= 5u)) {
return;
}
float2 vPos = (*(tint_symbol_4)).particles.arr[index].pos;
float2 vVel = (*(tint_symbol_4)).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);
int cMassCount = 0;
int cVelCount = 0;
float2 pos = 0.0f;
float2 vel = 0.0f;
for(uint i = 0u; (i < 5u); i = (i + 1u)) {
if ((i == index)) {
continue;
}
pos = float2((*(tint_symbol_4)).particles.arr[i].pos).xy;
vel = float2((*(tint_symbol_4)).particles.arr[i].vel).xy;
if ((distance(pos, vPos) < (*(tint_symbol_5)).rule1Distance)) {
cMass = (cMass + pos);
cMassCount = as_type<int>((as_type<uint>(cMassCount) + as_type<uint>(1)));
}
if ((distance(pos, vPos) < (*(tint_symbol_5)).rule2Distance)) {
colVel = (colVel - (pos - vPos));
}
if ((distance(pos, vPos) < (*(tint_symbol_5)).rule3Distance)) {
cVel = (cVel + vel);
cVelCount = as_type<int>((as_type<uint>(cVelCount) + as_type<uint>(1)));
}
}
if ((cMassCount > 0)) {
cMass = ((cMass / float2(float(cMassCount), float(cMassCount))) - vPos);
}
if ((cVelCount > 0)) {
cVel = (cVel / float2(float(cVelCount), float(cVelCount)));
}
vVel = (((vVel + (cMass * (*(tint_symbol_5)).rule1Scale)) + (colVel * (*(tint_symbol_5)).rule2Scale)) + (cVel * (*(tint_symbol_5)).rule3Scale));
vVel = (normalize(vVel) * clamp(length(vVel), 0.0f, 0.100000001f));
vPos = (vPos + (vVel * (*(tint_symbol_5)).deltaT));
if ((vPos[0] < -1.0f)) {
vPos[0] = 1.0f;
}
if ((vPos[0] > 1.0f)) {
vPos[0] = -1.0f;
}
if ((vPos[1] < -1.0f)) {
vPos[1] = 1.0f;
}
if ((vPos[1] > 1.0f)) {
vPos[1] = -1.0f;
}
(*(tint_symbol_6)).particles.arr[index].pos = vPos;
(*(tint_symbol_6)).particles.arr[index].vel = vVel;
}
kernel void comp_main(device Particles* tint_symbol_7 [[buffer(1)]], const constant SimParams* tint_symbol_8 [[buffer(0)]], device Particles* tint_symbol_9 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) {
comp_main_inner(gl_GlobalInvocationID, tint_symbol_7, tint_symbol_8, tint_symbol_9);
return;
}

View File

@@ -0,0 +1,450 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 280
; Schema: 0
OpCapability Shader
%37 = 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
OpEntryPoint GLCompute %comp_main "comp_main" %gl_GlobalInvocationID_1
OpExecutionMode %frag_main OriginUpperLeft
OpExecutionMode %comp_main LocalSize 1 1 1
OpName %a_particlePos_1 "a_particlePos_1"
OpName %a_particleVel_1 "a_particleVel_1"
OpName %a_pos_1 "a_pos_1"
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
OpName %value_1 "value_1"
OpName %gl_GlobalInvocationID_1 "gl_GlobalInvocationID_1"
OpName %SimParams "SimParams"
OpMemberName %SimParams 0 "deltaT"
OpMemberName %SimParams 1 "rule1Distance"
OpMemberName %SimParams 2 "rule2Distance"
OpMemberName %SimParams 3 "rule3Distance"
OpMemberName %SimParams 4 "rule1Scale"
OpMemberName %SimParams 5 "rule2Scale"
OpMemberName %SimParams 6 "rule3Scale"
OpName %params "params"
OpName %Particles "Particles"
OpMemberName %Particles 0 "particles"
OpName %Particle "Particle"
OpMemberName %Particle 0 "pos"
OpMemberName %Particle 1 "vel"
OpName %particlesA "particlesA"
OpName %particlesB "particlesB"
OpName %vert_main_inner "vert_main_inner"
OpName %a_particlePos "a_particlePos"
OpName %a_particleVel "a_particleVel"
OpName %a_pos "a_pos"
OpName %angle "angle"
OpName %pos "pos"
OpName %vert_main "vert_main"
OpName %frag_main_inner "frag_main_inner"
OpName %frag_main "frag_main"
OpName %comp_main_inner "comp_main_inner"
OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
OpName %index "index"
OpName %vPos "vPos"
OpName %vVel "vVel"
OpName %cMass "cMass"
OpName %cVel "cVel"
OpName %colVel "colVel"
OpName %cMassCount "cMassCount"
OpName %cVelCount "cVelCount"
OpName %pos_0 "pos"
OpName %vel "vel"
OpName %i "i"
OpName %comp_main "comp_main"
OpDecorate %a_particlePos_1 Location 0
OpDecorate %a_particleVel_1 Location 1
OpDecorate %a_pos_1 Location 2
OpDecorate %value BuiltIn Position
OpDecorate %vertex_point_size BuiltIn PointSize
OpDecorate %value_1 Location 0
OpDecorate %gl_GlobalInvocationID_1 BuiltIn GlobalInvocationId
OpDecorate %SimParams Block
OpMemberDecorate %SimParams 0 Offset 0
OpMemberDecorate %SimParams 1 Offset 4
OpMemberDecorate %SimParams 2 Offset 8
OpMemberDecorate %SimParams 3 Offset 12
OpMemberDecorate %SimParams 4 Offset 16
OpMemberDecorate %SimParams 5 Offset 20
OpMemberDecorate %SimParams 6 Offset 24
OpDecorate %params NonWritable
OpDecorate %params Binding 0
OpDecorate %params DescriptorSet 0
OpDecorate %Particles Block
OpMemberDecorate %Particles 0 Offset 0
OpMemberDecorate %Particle 0 Offset 0
OpMemberDecorate %Particle 1 Offset 8
OpDecorate %_arr_Particle_uint_5 ArrayStride 16
OpDecorate %particlesA Binding 1
OpDecorate %particlesA DescriptorSet 0
OpDecorate %particlesB Binding 2
OpDecorate %particlesB DescriptorSet 0
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%_ptr_Input_v2float = OpTypePointer Input %v2float
%a_particlePos_1 = OpVariable %_ptr_Input_v2float Input
%a_particleVel_1 = OpVariable %_ptr_Input_v2float Input
%a_pos_1 = OpVariable %_ptr_Input_v2float Input
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%10 = OpConstantNull %v4float
%value = OpVariable %_ptr_Output_v4float Output %10
%_ptr_Output_float = OpTypePointer Output %float
%13 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %13
%value_1 = OpVariable %_ptr_Output_v4float Output %10
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_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
%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
%_ptr_Function_float = OpTypePointer Function %float
%_ptr_Function_v2float = OpTypePointer Function %v2float
%63 = OpConstantNull %v2float
%float_0 = OpConstant %float 0
%float_1 = OpConstant %float 1
%void = OpTypeVoid
%71 = OpTypeFunction %void
%79 = OpTypeFunction %v4float
%82 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%86 = OpTypeFunction %void %v3uint
%_ptr_Function_uint = OpTypePointer Function %uint
%93 = OpConstantNull %uint
%bool = OpTypeBool
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer_v2float = OpTypePointer StorageBuffer %v2float
%uint_1 = OpConstant %uint 1
%110 = OpConstantComposite %v2float %float_0 %float_0
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_Function_int = OpTypePointer Function %int
%118 = OpConstantNull %int
%_ptr_Uniform_float = OpTypePointer Uniform %float
%int_1 = OpConstant %int 1
%uint_2 = OpConstant %uint 2
%uint_3 = OpConstant %uint 3
%uint_4 = OpConstant %uint 4
%uint_6 = OpConstant %uint 6
%float_0_100000001 = OpConstant %float 0.100000001
%float_n1 = OpConstant %float -1
%vert_main_inner = OpFunction %v4float None %29
%a_particlePos = OpFunctionParameter %v2float
%a_particleVel = OpFunctionParameter %v2float
%a_pos = OpFunctionParameter %v2float
%34 = 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
%70 = OpCompositeConstruct %v4float %66 %67 %float_0 %float_1
OpReturnValue %70
OpFunctionEnd
%vert_main = OpFunction %void None %71
%74 = OpLabel
%76 = OpLoad %v2float %a_particlePos_1
%77 = OpLoad %v2float %a_particleVel_1
%78 = OpLoad %v2float %a_pos_1
%75 = OpFunctionCall %v4float %vert_main_inner %76 %77 %78
OpStore %value %75
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%frag_main_inner = OpFunction %v4float None %79
%81 = OpLabel
OpReturnValue %82
OpFunctionEnd
%frag_main = OpFunction %void None %71
%84 = OpLabel
%85 = OpFunctionCall %v4float %frag_main_inner
OpStore %value_1 %85
OpReturn
OpFunctionEnd
%comp_main_inner = OpFunction %void None %86
%gl_GlobalInvocationID = OpFunctionParameter %v3uint
%89 = OpLabel
%index = OpVariable %_ptr_Function_uint Function %93
%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 %118
%cVelCount = OpVariable %_ptr_Function_int Function %118
%pos_0 = OpVariable %_ptr_Function_v2float Function %63
%vel = OpVariable %_ptr_Function_v2float Function %63
%i = OpVariable %_ptr_Function_uint Function %93
%90 = OpCompositeExtract %uint %gl_GlobalInvocationID 0
OpStore %index %90
%94 = OpLoad %uint %index
%95 = OpUGreaterThanEqual %bool %94 %uint_5
OpSelectionMerge %97 None
OpBranchConditional %95 %98 %97
%98 = OpLabel
OpReturn
%97 = OpLabel
%100 = OpLoad %uint %index
%102 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %100 %uint_0
%103 = OpLoad %v2float %102
OpStore %vPos %103
%105 = OpLoad %uint %index
%107 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %105 %uint_1
%108 = OpLoad %v2float %107
OpStore %vVel %108
OpStore %cMass %110
OpStore %cVel %110
OpStore %colVel %110
OpStore %cMassCount %int_0
OpStore %cVelCount %int_0
OpStore %i %uint_0
OpBranch %123
%123 = OpLabel
OpLoopMerge %124 %125 None
OpBranch %126
%126 = OpLabel
%128 = OpLoad %uint %i
%129 = OpULessThan %bool %128 %uint_5
%127 = OpLogicalNot %bool %129
OpSelectionMerge %130 None
OpBranchConditional %127 %131 %130
%131 = OpLabel
OpBranch %124
%130 = OpLabel
%132 = OpLoad %uint %i
%133 = OpLoad %uint %index
%134 = OpIEqual %bool %132 %133
OpSelectionMerge %135 None
OpBranchConditional %134 %136 %135
%136 = OpLabel
OpBranch %125
%135 = OpLabel
%137 = OpLoad %uint %i
%138 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %137 %uint_0
%139 = OpLoad %v2float %138
%140 = OpVectorShuffle %v2float %139 %139 0 1
OpStore %pos_0 %140
%141 = OpLoad %uint %i
%142 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesA %uint_0 %141 %uint_1
%143 = OpLoad %v2float %142
%144 = OpVectorShuffle %v2float %143 %143 0 1
OpStore %vel %144
%146 = OpLoad %v2float %pos_0
%147 = OpLoad %v2float %vPos
%145 = OpExtInst %float %37 Distance %146 %147
%149 = OpAccessChain %_ptr_Uniform_float %params %uint_1
%150 = OpLoad %float %149
%151 = OpFOrdLessThan %bool %145 %150
OpSelectionMerge %152 None
OpBranchConditional %151 %153 %152
%153 = OpLabel
%154 = OpLoad %v2float %cMass
%155 = OpLoad %v2float %pos_0
%156 = OpFAdd %v2float %154 %155
OpStore %cMass %156
%157 = OpLoad %int %cMassCount
%159 = OpIAdd %int %157 %int_1
OpStore %cMassCount %159
OpBranch %152
%152 = OpLabel
%161 = OpLoad %v2float %pos_0
%162 = OpLoad %v2float %vPos
%160 = OpExtInst %float %37 Distance %161 %162
%164 = OpAccessChain %_ptr_Uniform_float %params %uint_2
%165 = OpLoad %float %164
%166 = OpFOrdLessThan %bool %160 %165
OpSelectionMerge %167 None
OpBranchConditional %166 %168 %167
%168 = OpLabel
%169 = OpLoad %v2float %colVel
%170 = OpLoad %v2float %pos_0
%171 = OpLoad %v2float %vPos
%172 = OpFSub %v2float %170 %171
%173 = OpFSub %v2float %169 %172
OpStore %colVel %173
OpBranch %167
%167 = OpLabel
%175 = OpLoad %v2float %pos_0
%176 = OpLoad %v2float %vPos
%174 = OpExtInst %float %37 Distance %175 %176
%178 = OpAccessChain %_ptr_Uniform_float %params %uint_3
%179 = OpLoad %float %178
%180 = OpFOrdLessThan %bool %174 %179
OpSelectionMerge %181 None
OpBranchConditional %180 %182 %181
%182 = OpLabel
%183 = OpLoad %v2float %cVel
%184 = OpLoad %v2float %vel
%185 = OpFAdd %v2float %183 %184
OpStore %cVel %185
%186 = OpLoad %int %cVelCount
%187 = OpIAdd %int %186 %int_1
OpStore %cVelCount %187
OpBranch %181
%181 = OpLabel
OpBranch %125
%125 = OpLabel
%188 = OpLoad %uint %i
%189 = OpIAdd %uint %188 %uint_1
OpStore %i %189
OpBranch %123
%124 = OpLabel
%190 = OpLoad %int %cMassCount
%191 = OpSGreaterThan %bool %190 %int_0
OpSelectionMerge %192 None
OpBranchConditional %191 %193 %192
%193 = OpLabel
%194 = OpLoad %v2float %cMass
%196 = OpLoad %int %cMassCount
%195 = OpConvertSToF %float %196
%198 = OpLoad %int %cMassCount
%197 = OpConvertSToF %float %198
%199 = OpCompositeConstruct %v2float %195 %197
%200 = OpFDiv %v2float %194 %199
%201 = OpLoad %v2float %vPos
%202 = OpFSub %v2float %200 %201
OpStore %cMass %202
OpBranch %192
%192 = OpLabel
%203 = OpLoad %int %cVelCount
%204 = OpSGreaterThan %bool %203 %int_0
OpSelectionMerge %205 None
OpBranchConditional %204 %206 %205
%206 = OpLabel
%207 = OpLoad %v2float %cVel
%209 = OpLoad %int %cVelCount
%208 = OpConvertSToF %float %209
%211 = OpLoad %int %cVelCount
%210 = OpConvertSToF %float %211
%212 = OpCompositeConstruct %v2float %208 %210
%213 = OpFDiv %v2float %207 %212
OpStore %cVel %213
OpBranch %205
%205 = OpLabel
%214 = OpLoad %v2float %vVel
%215 = OpLoad %v2float %cMass
%217 = OpAccessChain %_ptr_Uniform_float %params %uint_4
%218 = OpLoad %float %217
%219 = OpVectorTimesScalar %v2float %215 %218
%220 = OpFAdd %v2float %214 %219
%221 = OpLoad %v2float %colVel
%222 = OpAccessChain %_ptr_Uniform_float %params %uint_5
%223 = OpLoad %float %222
%224 = OpVectorTimesScalar %v2float %221 %223
%225 = OpFAdd %v2float %220 %224
%226 = OpLoad %v2float %cVel
%228 = OpAccessChain %_ptr_Uniform_float %params %uint_6
%229 = OpLoad %float %228
%230 = OpVectorTimesScalar %v2float %226 %229
%231 = OpFAdd %v2float %225 %230
OpStore %vVel %231
%233 = OpLoad %v2float %vVel
%232 = OpExtInst %v2float %37 Normalize %233
%236 = OpLoad %v2float %vVel
%235 = OpExtInst %float %37 Length %236
%234 = OpExtInst %float %37 NClamp %235 %float_0 %float_0_100000001
%238 = OpVectorTimesScalar %v2float %232 %234
OpStore %vVel %238
%239 = OpLoad %v2float %vPos
%240 = OpLoad %v2float %vVel
%241 = OpAccessChain %_ptr_Uniform_float %params %uint_0
%242 = OpLoad %float %241
%243 = OpVectorTimesScalar %v2float %240 %242
%244 = OpFAdd %v2float %239 %243
OpStore %vPos %244
%245 = OpAccessChain %_ptr_Function_float %vPos %uint_0
%246 = OpLoad %float %245
%248 = OpFOrdLessThan %bool %246 %float_n1
OpSelectionMerge %249 None
OpBranchConditional %248 %250 %249
%250 = OpLabel
%251 = OpAccessChain %_ptr_Function_float %vPos %uint_0
OpStore %251 %float_1
OpBranch %249
%249 = OpLabel
%252 = OpAccessChain %_ptr_Function_float %vPos %uint_0
%253 = OpLoad %float %252
%254 = OpFOrdGreaterThan %bool %253 %float_1
OpSelectionMerge %255 None
OpBranchConditional %254 %256 %255
%256 = OpLabel
%257 = OpAccessChain %_ptr_Function_float %vPos %uint_0
OpStore %257 %float_n1
OpBranch %255
%255 = OpLabel
%258 = OpAccessChain %_ptr_Function_float %vPos %uint_1
%259 = OpLoad %float %258
%260 = OpFOrdLessThan %bool %259 %float_n1
OpSelectionMerge %261 None
OpBranchConditional %260 %262 %261
%262 = OpLabel
%263 = OpAccessChain %_ptr_Function_float %vPos %uint_1
OpStore %263 %float_1
OpBranch %261
%261 = OpLabel
%264 = OpAccessChain %_ptr_Function_float %vPos %uint_1
%265 = OpLoad %float %264
%266 = OpFOrdGreaterThan %bool %265 %float_1
OpSelectionMerge %267 None
OpBranchConditional %266 %268 %267
%268 = OpLabel
%269 = OpAccessChain %_ptr_Function_float %vPos %uint_1
OpStore %269 %float_n1
OpBranch %267
%267 = OpLabel
%270 = OpLoad %uint %index
%271 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesB %uint_0 %270 %uint_0
%272 = OpLoad %v2float %vPos
OpStore %271 %272
%273 = OpLoad %uint %index
%274 = OpAccessChain %_ptr_StorageBuffer_v2float %particlesB %uint_0 %273 %uint_1
%275 = OpLoad %v2float %vVel
OpStore %274 %275
OpReturn
OpFunctionEnd
%comp_main = OpFunction %void None %71
%277 = OpLabel
%279 = OpLoad %v3uint %gl_GlobalInvocationID_1
%278 = OpFunctionCall %void %comp_main_inner %279
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,94 @@
@stage(vertex)
fn vert_main(@location(0) a_particlePos : vec2<f32>, @location(1) a_particleVel : vec2<f32>, @location(2) a_pos : vec2<f32>) -> @builtin(position) vec4<f32> {
var angle : f32 = -(atan2(a_particleVel.x, a_particleVel.y));
var pos : vec2<f32> = vec2<f32>(((a_pos.x * cos(angle)) - (a_pos.y * sin(angle))), ((a_pos.x * sin(angle)) + (a_pos.y * cos(angle))));
return vec4<f32>((pos + a_particlePos), 0.0, 1.0);
}
@stage(fragment)
fn frag_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
}
struct Particle {
pos : vec2<f32>;
vel : vec2<f32>;
}
struct SimParams {
deltaT : f32;
rule1Distance : f32;
rule2Distance : f32;
rule3Distance : f32;
rule1Scale : f32;
rule2Scale : f32;
rule3Scale : f32;
}
struct Particles {
particles : array<Particle, 5>;
}
@binding(0) @group(0) var<uniform> params : SimParams;
@binding(1) @group(0) var<storage, read_write> particlesA : Particles;
@binding(2) @group(0) var<storage, read_write> particlesB : Particles;
@stage(compute) @workgroup_size(1)
fn comp_main(@builtin(global_invocation_id) gl_GlobalInvocationID : vec3<u32>) {
var index : u32 = gl_GlobalInvocationID.x;
if ((index >= 5u)) {
return;
}
var vPos : vec2<f32> = particlesA.particles[index].pos;
var vVel : vec2<f32> = particlesA.particles[index].vel;
var cMass : vec2<f32> = vec2<f32>(0.0, 0.0);
var cVel : vec2<f32> = vec2<f32>(0.0, 0.0);
var colVel : vec2<f32> = vec2<f32>(0.0, 0.0);
var cMassCount : i32 = 0;
var cVelCount : i32 = 0;
var pos : vec2<f32>;
var vel : vec2<f32>;
for(var i : u32 = 0u; (i < 5u); i = (i + 1u)) {
if ((i == index)) {
continue;
}
pos = particlesA.particles[i].pos.xy;
vel = particlesA.particles[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);
}
}
if ((cMassCount > 0)) {
cMass = ((cMass / vec2<f32>(f32(cMassCount), f32(cMassCount))) - vPos);
}
if ((cVelCount > 0)) {
cVel = (cVel / vec2<f32>(f32(cVelCount), f32(cVelCount)));
}
vVel = (((vVel + (cMass * params.rule1Scale)) + (colVel * params.rule2Scale)) + (cVel * params.rule3Scale));
vVel = (normalize(vVel) * clamp(length(vVel), 0.0, 0.100000001));
vPos = (vPos + (vVel * params.deltaT));
if ((vPos.x < -1.0)) {
vPos.x = 1.0;
}
if ((vPos.x > 1.0)) {
vPos.x = -1.0;
}
if ((vPos.y < -1.0)) {
vPos.y = 1.0;
}
if ((vPos.y > 1.0)) {
vPos.y = -1.0;
}
particlesB.particles[index].pos = vPos;
particlesB.particles[index].vel = vVel;
}

View File

@@ -0,0 +1,46 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Vertex shader
struct Uniforms {
modelViewProjectionMatrix : mat4x4<f32>;
};
@binding(0) @group(0) var<uniform> uniforms : Uniforms;
struct VertexInput {
@location(0) cur_position : vec4<f32>;
@location(1) color : vec4<f32>;
};
struct VertexOutput {
@location(0) vtxFragColor : vec4<f32>;
@builtin(position) Position : vec4<f32>;
};
@stage(vertex)
fn vtx_main(input : VertexInput) -> VertexOutput {
var output : VertexOutput;
output.Position = uniforms.modelViewProjectionMatrix * input.cur_position;
output.vtxFragColor = input.color;
return output;
}
// Fragment shader
@stage(fragment)
fn frag_main(@location(0) fragColor : vec4<f32>)
-> @location(0) vec4<f32> {
return fragColor;
}

View File

@@ -0,0 +1,67 @@
#version 310 es
layout(location = 0) in vec4 cur_position_1;
layout(location = 1) in vec4 color_1;
layout(location = 0) out vec4 vtxFragColor_1;
struct Uniforms {
mat4 modelViewProjectionMatrix;
};
layout(binding = 0) uniform Uniforms_1 {
mat4 modelViewProjectionMatrix;
} uniforms;
struct VertexInput {
vec4 cur_position;
vec4 color;
};
struct VertexOutput {
vec4 vtxFragColor;
vec4 Position;
};
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.vtxFragColor = tint_symbol.color;
return tint_symbol_1;
}
void main() {
VertexInput tint_symbol_2 = VertexInput(cur_position_1, color_1);
VertexOutput inner_result = vtx_main(tint_symbol_2);
vtxFragColor_1 = inner_result.vtxFragColor;
gl_Position = inner_result.Position;
gl_Position.y = -(gl_Position.y);
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
return;
}
#version 310 es
precision mediump float;
layout(location = 0) in vec4 fragColor_1;
layout(location = 0) out vec4 value;
struct Uniforms {
mat4 modelViewProjectionMatrix;
};
struct VertexInput {
vec4 cur_position;
vec4 color;
};
struct VertexOutput {
vec4 vtxFragColor;
vec4 Position;
};
vec4 frag_main(vec4 fragColor) {
return fragColor;
}
void main() {
vec4 inner_result = frag_main(fragColor_1);
value = inner_result;
return;
}

View File

@@ -0,0 +1,62 @@
cbuffer cbuffer_uniforms : register(b0, space0) {
uint4 uniforms[4];
};
struct VertexInput {
float4 cur_position;
float4 color;
};
struct VertexOutput {
float4 vtxFragColor;
float4 Position;
};
struct tint_symbol_1 {
float4 cur_position : TEXCOORD0;
float4 color : TEXCOORD1;
};
struct tint_symbol_2 {
float4 vtxFragColor : TEXCOORD0;
float4 Position : SV_Position;
};
float4x4 tint_symbol_6(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
const uint scalar_offset_1 = ((offset + 16u)) / 4;
const uint scalar_offset_2 = ((offset + 32u)) / 4;
const uint scalar_offset_3 = ((offset + 48u)) / 4;
return float4x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]), asfloat(buffer[scalar_offset_3 / 4]));
}
VertexOutput vtx_main_inner(VertexInput input) {
VertexOutput output = (VertexOutput)0;
output.Position = mul(input.cur_position, tint_symbol_6(uniforms, 0u));
output.vtxFragColor = input.color;
return output;
}
tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol) {
const VertexInput tint_symbol_8 = {tint_symbol.cur_position, tint_symbol.color};
const VertexOutput inner_result = vtx_main_inner(tint_symbol_8);
tint_symbol_2 wrapper_result = (tint_symbol_2)0;
wrapper_result.vtxFragColor = inner_result.vtxFragColor;
wrapper_result.Position = inner_result.Position;
return wrapper_result;
}
struct tint_symbol_4 {
float4 fragColor : TEXCOORD0;
};
struct tint_symbol_5 {
float4 value : SV_Target0;
};
float4 frag_main_inner(float4 fragColor) {
return fragColor;
}
tint_symbol_5 frag_main(tint_symbol_4 tint_symbol_3) {
const float4 inner_result_1 = frag_main_inner(tint_symbol_3.fragColor);
tint_symbol_5 wrapper_result_1 = (tint_symbol_5)0;
wrapper_result_1.value = inner_result_1;
return wrapper_result_1;
}

View File

@@ -0,0 +1,62 @@
#include <metal_stdlib>
using namespace metal;
struct Uniforms {
/* 0x0000 */ float4x4 modelViewProjectionMatrix;
};
struct VertexInput {
float4 cur_position;
float4 color;
};
struct VertexOutput {
float4 vtxFragColor;
float4 Position;
};
struct tint_symbol_1 {
float4 cur_position [[attribute(0)]];
float4 color [[attribute(1)]];
};
struct tint_symbol_2 {
float4 vtxFragColor [[user(locn0)]];
float4 Position [[position]];
};
VertexOutput vtx_main_inner(VertexInput input, const constant Uniforms* const tint_symbol_7) {
VertexOutput output = {};
output.Position = ((*(tint_symbol_7)).modelViewProjectionMatrix * input.cur_position);
output.vtxFragColor = input.color;
return output;
}
vertex tint_symbol_2 vtx_main(const constant Uniforms* tint_symbol_8 [[buffer(0)]], tint_symbol_1 tint_symbol [[stage_in]]) {
VertexInput const tint_symbol_6 = {.cur_position=tint_symbol.cur_position, .color=tint_symbol.color};
VertexOutput const inner_result = vtx_main_inner(tint_symbol_6, tint_symbol_8);
tint_symbol_2 wrapper_result = {};
wrapper_result.vtxFragColor = inner_result.vtxFragColor;
wrapper_result.Position = inner_result.Position;
return wrapper_result;
}
struct tint_symbol_4 {
float4 fragColor [[user(locn0)]];
};
struct tint_symbol_5 {
float4 value [[color(0)]];
};
float4 frag_main_inner(float4 fragColor) {
return fragColor;
}
fragment tint_symbol_5 frag_main(tint_symbol_4 tint_symbol_3 [[stage_in]]) {
float4 const inner_result_1 = frag_main_inner(tint_symbol_3.fragColor);
tint_symbol_5 wrapper_result_1 = {};
wrapper_result_1.value = inner_result_1;
return wrapper_result_1;
}

View File

@@ -0,0 +1,124 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 60
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vtx_main "vtx_main" %cur_position_1 %color_1 %vtxFragColor_1 %Position_1 %vertex_point_size
OpEntryPoint Fragment %frag_main "frag_main" %fragColor_1 %value
OpExecutionMode %frag_main OriginUpperLeft
OpName %cur_position_1 "cur_position_1"
OpName %color_1 "color_1"
OpName %vtxFragColor_1 "vtxFragColor_1"
OpName %Position_1 "Position_1"
OpName %vertex_point_size "vertex_point_size"
OpName %fragColor_1 "fragColor_1"
OpName %value "value"
OpName %Uniforms "Uniforms"
OpMemberName %Uniforms 0 "modelViewProjectionMatrix"
OpName %uniforms "uniforms"
OpName %VertexOutput "VertexOutput"
OpMemberName %VertexOutput 0 "vtxFragColor"
OpMemberName %VertexOutput 1 "Position"
OpName %VertexInput "VertexInput"
OpMemberName %VertexInput 0 "cur_position"
OpMemberName %VertexInput 1 "color"
OpName %vtx_main_inner "vtx_main_inner"
OpName %input "input"
OpName %output "output"
OpName %vtx_main "vtx_main"
OpName %frag_main_inner "frag_main_inner"
OpName %fragColor "fragColor"
OpName %frag_main "frag_main"
OpDecorate %cur_position_1 Location 0
OpDecorate %color_1 Location 1
OpDecorate %vtxFragColor_1 Location 0
OpDecorate %Position_1 BuiltIn Position
OpDecorate %vertex_point_size BuiltIn PointSize
OpDecorate %fragColor_1 Location 0
OpDecorate %value Location 0
OpDecorate %Uniforms Block
OpMemberDecorate %Uniforms 0 Offset 0
OpMemberDecorate %Uniforms 0 ColMajor
OpMemberDecorate %Uniforms 0 MatrixStride 16
OpDecorate %uniforms NonWritable
OpDecorate %uniforms Binding 0
OpDecorate %uniforms DescriptorSet 0
OpMemberDecorate %VertexOutput 0 Offset 0
OpMemberDecorate %VertexOutput 1 Offset 16
OpMemberDecorate %VertexInput 0 Offset 0
OpMemberDecorate %VertexInput 1 Offset 16
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Input_v4float = OpTypePointer Input %v4float
%cur_position_1 = OpVariable %_ptr_Input_v4float Input
%color_1 = OpVariable %_ptr_Input_v4float Input
%_ptr_Output_v4float = OpTypePointer Output %v4float
%8 = OpConstantNull %v4float
%vtxFragColor_1 = OpVariable %_ptr_Output_v4float Output %8
%Position_1 = OpVariable %_ptr_Output_v4float Output %8
%_ptr_Output_float = OpTypePointer Output %float
%12 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %12
%fragColor_1 = OpVariable %_ptr_Input_v4float Input
%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
%VertexOutput = OpTypeStruct %v4float %v4float
%VertexInput = OpTypeStruct %v4float %v4float
%19 = OpTypeFunction %VertexOutput %VertexInput
%_ptr_Function_VertexOutput = OpTypePointer Function %VertexOutput
%27 = 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
%float_1 = OpConstant %float 1
%52 = OpTypeFunction %v4float %v4float
%vtx_main_inner = OpFunction %VertexOutput None %19
%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
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
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%frag_main_inner = OpFunction %v4float None %52
%fragColor = OpFunctionParameter %v4float
%55 = 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
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,32 @@
struct Uniforms {
modelViewProjectionMatrix : mat4x4<f32>;
}
@binding(0) @group(0) var<uniform> uniforms : Uniforms;
struct VertexInput {
@location(0)
cur_position : vec4<f32>;
@location(1)
color : vec4<f32>;
}
struct VertexOutput {
@location(0)
vtxFragColor : vec4<f32>;
@builtin(position)
Position : vec4<f32>;
}
@stage(vertex)
fn vtx_main(input : VertexInput) -> VertexOutput {
var output : VertexOutput;
output.Position = (uniforms.modelViewProjectionMatrix * input.cur_position);
output.vtxFragColor = input.color;
return output;
}
@stage(fragment)
fn frag_main(@location(0) fragColor : vec4<f32>) -> @location(0) vec4<f32> {
return fragColor;
}

View File

@@ -0,0 +1,21 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
fn main() -> f32 {
return ((2. * 3.) - 4.) / 5.;
}
@stage(compute) @workgroup_size(2)
fn ep() {
}

View File

@@ -0,0 +1,10 @@
#version 310 es
void ep() {
}
layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in;
void main() {
ep();
return;
}

View File

@@ -0,0 +1,8 @@
float main() {
return (((2.0f * 3.0f) - 4.0f) / 5.0f);
}
[numthreads(2, 1, 1)]
void ep() {
return;
}

View File

@@ -0,0 +1,11 @@
#include <metal_stdlib>
using namespace metal;
float tint_symbol() {
return (((2.0f * 3.0f) - 4.0f) / 5.0f);
}
kernel void ep() {
return;
}

View File

@@ -0,0 +1,30 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 16
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %ep "ep"
OpExecutionMode %ep LocalSize 2 1 1
OpName %main "main"
OpName %ep "ep"
%float = OpTypeFloat 32
%1 = OpTypeFunction %float
%float_2 = OpConstant %float 2
%float_3 = OpConstant %float 3
%float_4 = OpConstant %float 4
%float_5 = OpConstant %float 5
%void = OpTypeVoid
%12 = OpTypeFunction %void
%main = OpFunction %float None %1
%4 = OpLabel
%7 = OpFMul %float %float_2 %float_3
%9 = OpFSub %float %7 %float_4
%11 = OpFDiv %float %9 %float_5
OpReturnValue %11
OpFunctionEnd
%ep = OpFunction %void None %12
%15 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,7 @@
fn main() -> f32 {
return (((2.0 * 3.0) - 4.0) / 5.0);
}
@stage(compute) @workgroup_size(2)
fn ep() {
}

View File

@@ -0,0 +1,23 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
fn bar() {
}
@stage(fragment)
fn main() -> @location(0) vec4<f32> {
var a : vec2<f32> = vec2<f32>();
bar();
return vec4<f32>(0.4, 0.4, 0.8, 1.0);
}

View File

@@ -0,0 +1,18 @@
#version 310 es
precision mediump float;
layout(location = 0) out vec4 value;
void bar() {
}
vec4 tint_symbol() {
vec2 a = vec2(0.0f, 0.0f);
bar();
return vec4(0.400000006f, 0.400000006f, 0.800000012f, 1.0f);
}
void main() {
vec4 inner_result = tint_symbol();
value = inner_result;
return;
}

View File

@@ -0,0 +1,19 @@
void bar() {
}
struct tint_symbol {
float4 value : SV_Target0;
};
float4 main_inner() {
float2 a = float2(0.0f, 0.0f);
bar();
return float4(0.400000006f, 0.400000006f, 0.800000012f, 1.0f);
}
tint_symbol main() {
const float4 inner_result = main_inner();
tint_symbol wrapper_result = (tint_symbol)0;
wrapper_result.value = inner_result;
return wrapper_result;
}

View File

@@ -0,0 +1,23 @@
#include <metal_stdlib>
using namespace metal;
void bar() {
}
struct tint_symbol_1 {
float4 value [[color(0)]];
};
float4 tint_symbol_inner() {
float2 a = float2();
bar();
return float4(0.400000006f, 0.400000006f, 0.800000012f, 1.0f);
}
fragment tint_symbol_1 tint_symbol() {
float4 const inner_result = tint_symbol_inner();
tint_symbol_1 wrapper_result = {};
wrapper_result.value = inner_result;
return wrapper_result;
}

View File

@@ -0,0 +1,47 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 25
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %value
OpExecutionMode %main OriginUpperLeft
OpName %value "value"
OpName %bar "bar"
OpName %main_inner "main_inner"
OpName %a "a"
OpName %main "main"
OpDecorate %value Location 0
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%5 = OpConstantNull %v4float
%value = OpVariable %_ptr_Output_v4float Output %5
%void = OpTypeVoid
%6 = OpTypeFunction %void
%10 = OpTypeFunction %v4float
%v2float = OpTypeVector %float 2
%14 = OpConstantNull %v2float
%_ptr_Function_v2float = OpTypePointer Function %v2float
%float_0_400000006 = OpConstant %float 0.400000006
%float_0_800000012 = OpConstant %float 0.800000012
%float_1 = OpConstant %float 1
%21 = OpConstantComposite %v4float %float_0_400000006 %float_0_400000006 %float_0_800000012 %float_1
%bar = OpFunction %void None %6
%9 = OpLabel
OpReturn
OpFunctionEnd
%main_inner = OpFunction %v4float None %10
%12 = OpLabel
%a = OpVariable %_ptr_Function_v2float Function %14
OpStore %a %14
%17 = OpFunctionCall %void %bar
OpReturnValue %21
OpFunctionEnd
%main = OpFunction %void None %6
%23 = OpLabel
%24 = OpFunctionCall %v4float %main_inner
OpStore %value %24
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,9 @@
fn bar() {
}
@stage(fragment)
fn main() -> @location(0) vec4<f32> {
var a : vec2<f32> = vec2<f32>();
bar();
return vec4<f32>(0.400000006, 0.400000006, 0.800000012, 1.0);
}

View File

@@ -0,0 +1,52 @@
; #version 450
;
; void main() {
; gl_Position = vec4(0.0);
; }
; SPIR-V
; Version: 1.0
; Generator: Google Shaderc over Glslang; 10
; Bound: 20
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %_
OpSource GLSL 450
OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"
OpSourceExtension "GL_GOOGLE_include_directive"
OpName %main "main"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %_ ""
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
%_ = OpVariable %_ptr_Output_gl_PerVertex Output
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%float_0 = OpConstant %float 0
%17 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
%_ptr_Output_v4float = OpTypePointer Output %v4float
%main = OpFunction %void None %3
%5 = OpLabel
%19 = OpAccessChain %_ptr_Output_v4float %_ %int_0
OpStore %19 %17
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,25 @@
#version 310 es
vec4 tint_symbol = vec4(0.0f, 0.0f, 0.0f, 0.0f);
void main_1() {
tint_symbol = vec4(0.0f, 0.0f, 0.0f, 0.0f);
return;
}
struct main_out {
vec4 tint_symbol;
};
main_out tint_symbol_1() {
main_1();
main_out tint_symbol_2 = main_out(tint_symbol);
return tint_symbol_2;
}
void main() {
main_out inner_result = tint_symbol_1();
gl_Position = inner_result.tint_symbol;
gl_Position.y = -(gl_Position.y);
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
return;
}

View File

@@ -0,0 +1,26 @@
static float4 gl_Position = float4(0.0f, 0.0f, 0.0f, 0.0f);
void main_1() {
gl_Position = float4(0.0f, 0.0f, 0.0f, 0.0f);
return;
}
struct main_out {
float4 gl_Position;
};
struct tint_symbol {
float4 gl_Position : SV_Position;
};
main_out main_inner() {
main_1();
const main_out tint_symbol_1 = {gl_Position};
return tint_symbol_1;
}
tint_symbol main() {
const main_out inner_result = main_inner();
tint_symbol wrapper_result = (tint_symbol)0;
wrapper_result.gl_Position = inner_result.gl_Position;
return wrapper_result;
}

View File

@@ -0,0 +1,30 @@
#include <metal_stdlib>
using namespace metal;
void main_1(thread float4* const tint_symbol_3) {
*(tint_symbol_3) = float4(0.0f, 0.0f, 0.0f, 0.0f);
return;
}
struct main_out {
float4 gl_Position;
};
struct tint_symbol_1 {
float4 gl_Position [[position]];
};
main_out tint_symbol_inner(thread float4* const tint_symbol_4) {
main_1(tint_symbol_4);
main_out const tint_symbol_2 = {.gl_Position=*(tint_symbol_4)};
return tint_symbol_2;
}
vertex tint_symbol_1 tint_symbol() {
thread float4 tint_symbol_5 = 0.0f;
main_out const inner_result = tint_symbol_inner(&(tint_symbol_5));
tint_symbol_1 wrapper_result = {};
wrapper_result.gl_Position = inner_result.gl_Position;
return wrapper_result;
}

View File

@@ -0,0 +1,56 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 29
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %gl_Position_1 %vertex_point_size
OpName %gl_Position_1 "gl_Position_1"
OpName %vertex_point_size "vertex_point_size"
OpName %gl_Position "gl_Position"
OpName %main_1 "main_1"
OpName %main_out "main_out"
OpMemberName %main_out 0 "gl_Position"
OpName %main_inner "main_inner"
OpName %main "main"
OpDecorate %gl_Position_1 BuiltIn Position
OpDecorate %vertex_point_size BuiltIn PointSize
OpMemberDecorate %main_out 0 Offset 0
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%5 = OpConstantNull %v4float
%gl_Position_1 = OpVariable %_ptr_Output_v4float Output %5
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%_ptr_Private_v4float = OpTypePointer Private %v4float
%gl_Position = OpVariable %_ptr_Private_v4float Private %5
%void = OpTypeVoid
%11 = OpTypeFunction %void
%float_0 = OpConstant %float 0
%16 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
%main_out = OpTypeStruct %v4float
%17 = OpTypeFunction %main_out
%float_1 = OpConstant %float 1
%main_1 = OpFunction %void None %11
%14 = OpLabel
OpStore %gl_Position %16
OpReturn
OpFunctionEnd
%main_inner = OpFunction %main_out None %17
%20 = OpLabel
%21 = OpFunctionCall %void %main_1
%22 = OpLoad %v4float %gl_Position
%23 = OpCompositeConstruct %main_out %22
OpReturnValue %23
OpFunctionEnd
%main = OpFunction %void None %11
%25 = OpLabel
%26 = OpFunctionCall %main_out %main_inner
%27 = OpCompositeExtract %v4float %26 0
OpStore %gl_Position_1 %27
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,17 @@
var<private> gl_Position : vec4<f32>;
fn main_1() {
gl_Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
return;
}
struct main_out {
@builtin(position)
gl_Position : vec4<f32>;
}
@stage(vertex)
fn main() -> main_out {
main_1();
return main_out(gl_Position);
}

View File

@@ -0,0 +1,31 @@
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Vertex shader
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(0.0, 0.5),
vec2<f32>(-0.5, -0.5),
vec2<f32>(0.5, -0.5));
@stage(vertex)
fn vtx_main(@builtin(vertex_index) VertexIndex : u32)
-> @builtin(position) vec4<f32> {
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
}
// Fragment shader
@stage(fragment)
fn frag_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
}

View File

@@ -0,0 +1,27 @@
#version 310 es
const vec2 pos[3] = vec2[3](vec2(0.0f, 0.5f), vec2(-0.5f, -0.5f), vec2(0.5f, -0.5f));
vec4 vtx_main(uint VertexIndex) {
return vec4(pos[VertexIndex], 0.0f, 1.0f);
}
void main() {
vec4 inner_result = vtx_main(uint(gl_VertexID));
gl_Position = inner_result;
gl_Position.y = -(gl_Position.y);
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
return;
}
#version 310 es
precision mediump float;
layout(location = 0) out vec4 value;
vec4 frag_main() {
return vec4(1.0f, 0.0f, 0.0f, 1.0f);
}
void main() {
vec4 inner_result = frag_main();
value = inner_result;
return;
}

View File

@@ -0,0 +1,34 @@
static const float2 pos[3] = {float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)};
struct tint_symbol_1 {
uint VertexIndex : SV_VertexID;
};
struct tint_symbol_2 {
float4 value : SV_Position;
};
float4 vtx_main_inner(uint VertexIndex) {
return float4(pos[VertexIndex], 0.0f, 1.0f);
}
tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol) {
const float4 inner_result = vtx_main_inner(tint_symbol.VertexIndex);
tint_symbol_2 wrapper_result = (tint_symbol_2)0;
wrapper_result.value = inner_result;
return wrapper_result;
}
struct tint_symbol_3 {
float4 value : SV_Target0;
};
float4 frag_main_inner() {
return float4(1.0f, 0.0f, 0.0f, 1.0f);
}
tint_symbol_3 frag_main() {
const float4 inner_result_1 = frag_main_inner();
tint_symbol_3 wrapper_result_1 = (tint_symbol_3)0;
wrapper_result_1.value = inner_result_1;
return wrapper_result_1;
}

View File

@@ -0,0 +1,39 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
float2 arr[3];
};
constant tint_array_wrapper pos = {.arr={float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)}};
struct tint_symbol {
float4 value [[position]];
};
float4 vtx_main_inner(uint VertexIndex) {
return float4(pos.arr[VertexIndex], 0.0f, 1.0f);
}
vertex tint_symbol vtx_main(uint VertexIndex [[vertex_id]]) {
float4 const inner_result = vtx_main_inner(VertexIndex);
tint_symbol wrapper_result = {};
wrapper_result.value = inner_result;
return wrapper_result;
}
struct tint_symbol_1 {
float4 value [[color(0)]];
};
float4 frag_main_inner() {
return float4(1.0f, 0.0f, 0.0f, 1.0f);
}
fragment tint_symbol_1 frag_main() {
float4 const inner_result_1 = frag_main_inner();
tint_symbol_1 wrapper_result_1 = {};
wrapper_result_1.value = inner_result_1;
return wrapper_result_1;
}

View File

@@ -0,0 +1,87 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 50
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vtx_main "vtx_main" %VertexIndex_1 %value %vertex_point_size
OpEntryPoint Fragment %frag_main "frag_main" %value_1
OpExecutionMode %frag_main OriginUpperLeft
OpName %VertexIndex_1 "VertexIndex_1"
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
OpName %value_1 "value_1"
OpName %pos "pos"
OpName %vtx_main_inner "vtx_main_inner"
OpName %VertexIndex "VertexIndex"
OpName %var_for_index "var_for_index"
OpName %vtx_main "vtx_main"
OpName %frag_main_inner "frag_main_inner"
OpName %frag_main "frag_main"
OpDecorate %VertexIndex_1 BuiltIn VertexIndex
OpDecorate %value BuiltIn Position
OpDecorate %vertex_point_size BuiltIn PointSize
OpDecorate %value_1 Location 0
OpDecorate %_arr_v2float_uint_3 ArrayStride 8
%uint = OpTypeInt 32 0
%_ptr_Input_uint = OpTypePointer Input %uint
%VertexIndex_1 = OpVariable %_ptr_Input_uint Input
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%8 = OpConstantNull %v4float
%value = OpVariable %_ptr_Output_v4float Output %8
%_ptr_Output_float = OpTypePointer Output %float
%11 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %11
%value_1 = OpVariable %_ptr_Output_v4float Output %8
%v2float = OpTypeVector %float 2
%uint_3 = OpConstant %uint 3
%_arr_v2float_uint_3 = OpTypeArray %v2float %uint_3
%float_0 = OpConstant %float 0
%float_0_5 = OpConstant %float 0.5
%18 = OpConstantComposite %v2float %float_0 %float_0_5
%float_n0_5 = OpConstant %float -0.5
%20 = OpConstantComposite %v2float %float_n0_5 %float_n0_5
%21 = OpConstantComposite %v2float %float_0_5 %float_n0_5
%pos = OpConstantComposite %_arr_v2float_uint_3 %18 %20 %21
%23 = OpTypeFunction %v4float %uint
%_ptr_Function__arr_v2float_uint_3 = OpTypePointer Function %_arr_v2float_uint_3
%29 = OpConstantNull %_arr_v2float_uint_3
%_ptr_Function_v2float = OpTypePointer Function %v2float
%float_1 = OpConstant %float 1
%void = OpTypeVoid
%37 = OpTypeFunction %void
%43 = OpTypeFunction %v4float
%46 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
%vtx_main_inner = OpFunction %v4float None %23
%VertexIndex = OpFunctionParameter %uint
%26 = OpLabel
%var_for_index = OpVariable %_ptr_Function__arr_v2float_uint_3 Function %29
OpStore %var_for_index %pos
%31 = OpAccessChain %_ptr_Function_v2float %var_for_index %VertexIndex
%32 = OpLoad %v2float %31
%33 = OpCompositeExtract %float %32 0
%34 = OpCompositeExtract %float %32 1
%36 = OpCompositeConstruct %v4float %33 %34 %float_0 %float_1
OpReturnValue %36
OpFunctionEnd
%vtx_main = OpFunction %void None %37
%40 = OpLabel
%42 = OpLoad %uint %VertexIndex_1
%41 = OpFunctionCall %v4float %vtx_main_inner %42
OpStore %value %41
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%frag_main_inner = OpFunction %v4float None %43
%45 = OpLabel
OpReturnValue %46
OpFunctionEnd
%frag_main = OpFunction %void None %37
%48 = OpLabel
%49 = OpFunctionCall %v4float %frag_main_inner
OpStore %value_1 %49
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,11 @@
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(vec2<f32>(0.0, 0.5), vec2<f32>(-0.5, -0.5), vec2<f32>(0.5, -0.5));
@stage(vertex)
fn vtx_main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
}
@stage(fragment)
fn frag_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
}