diff --git a/test/compute_boids.wgsl b/test/compute_boids.wgsl index 47f716069c..5ccf6edb54 100644 --- a/test/compute_boids.wgsl +++ b/test/compute_boids.wgsl @@ -14,26 +14,23 @@ // vertex shader -[[location(0)]] var a_particlePos : vec2; -[[location(1)]] var a_particleVel : vec2; -[[location(2)]] var a_pos : vec2; -[[builtin(position)]] var gl_Position : vec4; - [[stage(vertex)]] -fn vert_main() -> void { +fn vert_main([[location(0)]] a_particlePos : vec2, + [[location(1)]] a_particleVel : vec2, + [[location(2)]] a_pos : vec2) + -> [[builtin(position)]] vec4 { var angle : f32 = -atan2(a_particleVel.x, a_particleVel.y); var pos : vec2 = vec2( (a_pos.x * cos(angle)) - (a_pos.y * sin(angle)), (a_pos.x * sin(angle)) + (a_pos.y * cos(angle))); - gl_Position = vec4(pos + a_particlePos, 0.0, 1.0); + return vec4(pos + a_particlePos, 0.0, 1.0); } // fragment shader -[[location(0)]] var fragColor : vec4; [[stage(fragment)]] -fn frag_main() -> void { - fragColor = vec4(1.0, 1.0, 1.0, 1.0); +fn frag_main() -> [[location(0)]] vec4 { + return vec4(1.0, 1.0, 1.0, 1.0); } // compute shader @@ -60,11 +57,10 @@ fn frag_main() -> void { [[binding(1), group(0)]] var particlesA : [[access(read_write)]] Particles; [[binding(2), group(0)]] var particlesB : [[access(read_write)]] Particles; -[[builtin(global_invocation_id)]] var gl_GlobalInvocationID : vec3; - // https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp [[stage(compute)]] -fn comp_main() -> void { +fn comp_main( + [[builtin(global_invocation_id)]] gl_GlobalInvocationID : vec3) -> void { var index : u32 = gl_GlobalInvocationID.x; if (index >= 5u) { return; diff --git a/test/cube.wgsl b/test/cube.wgsl index aef1be2896..313954a206 100644 --- a/test/cube.wgsl +++ b/test/cube.wgsl @@ -19,22 +19,28 @@ [[binding(0), group(0)]] var uniforms : [[access(read)]] Uniforms; -[[location(0)]] var cur_position : vec4; -[[location(1)]] var color : vec4; -[[location(0)]] var vtxFragColor : vec4; -[[builtin(position)]] var Position : vec4; +struct VertexInput { + [[location(0)]] cur_position : vec4; + [[location(1)]] color : vec4; +}; + +struct VertexOutput { + [[location(0)]] vtxFragColor : vec4; + [[builtin(position)]] Position : vec4; +}; [[stage(vertex)]] -fn vtx_main() -> void { - Position = uniforms.modelViewProjectionMatrix * cur_position; - vtxFragColor = color; +fn vtx_main(input : VertexInput) -> VertexOutput { + var output : VertexOutput; + output.Position = uniforms.modelViewProjectionMatrix * input.cur_position; + output.vtxFragColor = input.color; + return output; } // Fragment shader -[[location(0)]] var fragColor : vec4; -[[location(0)]] var outColor : vec4; [[stage(fragment)]] -fn frag_main() -> void { - outColor = fragColor; +fn frag_main([[location(0)]] fragColor : vec4) + -> [[location(0)]] vec4 { + return fragColor; } diff --git a/test/simple.wgsl b/test/simple.wgsl index e372d2db2e..b7d761a645 100644 --- a/test/simple.wgsl +++ b/test/simple.wgsl @@ -12,14 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -[[location(0)]] var gl_FragColor : vec4; - fn bar() -> void { } [[stage(fragment)]] -fn main() -> void { +fn main() -> [[location(0)]] vec4 { var a : vec2 = vec2(); - gl_FragColor = vec4(0.4, 0.4, 0.8, 1.0); bar(); + return vec4(0.4, 0.4, 0.8, 1.0); } diff --git a/test/triangle.wgsl b/test/triangle.wgsl index bea1c95ff0..1baca52c74 100644 --- a/test/triangle.wgsl +++ b/test/triangle.wgsl @@ -18,18 +18,14 @@ const pos : array, 3> = array, 3>( vec2(-0.5, -0.5), vec2(0.5, -0.5)); -[[builtin(position)]] var Position : vec4; -[[builtin(vertex_index)]] var VertexIndex : i32; - [[stage(vertex)]] -fn vtx_main() -> void { - Position = vec4(pos[VertexIndex], 0.0, 1.0); +fn vtx_main([[builtin(vertex_index)]] VertexIndex : i32) + -> [[builtin(position)]] vec4 { + return vec4(pos[VertexIndex], 0.0, 1.0); } // Fragment shader -[[location(0)]] var outColor : vec4; - [[stage(fragment)]] -fn frag_main() -> void { - outColor = vec4(1.0, 0.0, 0.0, 1.0); +fn frag_main() -> [[location(0)]] vec4 { + return vec4(1.0, 0.0, 0.0, 1.0); }