mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
wgsl: Replace [[decoration]] with @decoration
Deprecate the old syntax. Migrate everything to the new syntax. Bug: tint:1382 Change-Id: Ide12b2e927b17dc93b9714c7049090864cc568d3 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77260 Reviewed-by: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com> Commit-Queue: David Neto <dneto@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
8f1d5224ee
commit
01e4b6fc18
@@ -14,11 +14,11 @@
|
||||
|
||||
// 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> {
|
||||
@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)),
|
||||
@@ -28,8 +28,8 @@ fn vert_main([[location(0)]] a_particlePos : vec2<f32>,
|
||||
|
||||
// fragment shader
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn frag_main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn frag_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -53,14 +53,14 @@ struct Particle {
|
||||
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;
|
||||
@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)]]
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn comp_main(
|
||||
[[builtin(global_invocation_id)]] gl_GlobalInvocationID : vec3<u32>) {
|
||||
@builtin(global_invocation_id) gl_GlobalInvocationID : vec3<u32>) {
|
||||
var index : u32 = gl_GlobalInvocationID.x;
|
||||
if (index >= 5u) {
|
||||
return;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
[[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> {
|
||||
@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> {
|
||||
@stage(fragment)
|
||||
fn frag_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ struct Particles {
|
||||
particles : array<Particle, 5>;
|
||||
}
|
||||
|
||||
[[binding(0), group(0)]] var<uniform> params : SimParams;
|
||||
@binding(0) @group(0) var<uniform> params : SimParams;
|
||||
|
||||
[[binding(1), group(0)]] var<storage, read_write> particlesA : Particles;
|
||||
@binding(1) @group(0) var<storage, read_write> particlesA : Particles;
|
||||
|
||||
[[binding(2), group(0)]] var<storage, read_write> particlesB : 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>) {
|
||||
@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;
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
modelViewProjectionMatrix : mat4x4<f32>;
|
||||
};
|
||||
|
||||
[[binding(0), group(0)]] var<uniform> uniforms : Uniforms;
|
||||
@binding(0) @group(0) var<uniform> uniforms : Uniforms;
|
||||
|
||||
struct VertexInput {
|
||||
[[location(0)]] cur_position : vec4<f32>;
|
||||
[[location(1)]] color : vec4<f32>;
|
||||
@location(0) cur_position : vec4<f32>;
|
||||
@location(1) color : vec4<f32>;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
[[location(0)]] vtxFragColor : vec4<f32>;
|
||||
[[builtin(position)]] Position : vec4<f32>;
|
||||
@location(0) vtxFragColor : vec4<f32>;
|
||||
@builtin(position) Position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn vtx_main(input : VertexInput) -> VertexOutput {
|
||||
var output : VertexOutput;
|
||||
output.Position = uniforms.modelViewProjectionMatrix * input.cur_position;
|
||||
@@ -39,8 +39,8 @@ fn vtx_main(input : VertexInput) -> VertexOutput {
|
||||
|
||||
// Fragment shader
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn frag_main([[location(0)]] fragColor : vec4<f32>)
|
||||
-> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn frag_main(@location(0) fragColor : vec4<f32>)
|
||||
-> @location(0) vec4<f32> {
|
||||
return fragColor;
|
||||
}
|
||||
|
||||
@@ -2,23 +2,23 @@ struct Uniforms {
|
||||
modelViewProjectionMatrix : mat4x4<f32>;
|
||||
}
|
||||
|
||||
[[binding(0), group(0)]] var<uniform> uniforms : Uniforms;
|
||||
@binding(0) @group(0) var<uniform> uniforms : Uniforms;
|
||||
|
||||
struct VertexInput {
|
||||
[[location(0)]]
|
||||
@location(0)
|
||||
cur_position : vec4<f32>;
|
||||
[[location(1)]]
|
||||
@location(1)
|
||||
color : vec4<f32>;
|
||||
}
|
||||
|
||||
struct VertexOutput {
|
||||
[[location(0)]]
|
||||
@location(0)
|
||||
vtxFragColor : vec4<f32>;
|
||||
[[builtin(position)]]
|
||||
@builtin(position)
|
||||
Position : vec4<f32>;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn vtx_main(input : VertexInput) -> VertexOutput {
|
||||
var output : VertexOutput;
|
||||
output.Position = (uniforms.modelViewProjectionMatrix * input.cur_position);
|
||||
@@ -26,7 +26,7 @@ fn vtx_main(input : VertexInput) -> VertexOutput {
|
||||
return output;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn frag_main([[location(0)]] fragColor : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn frag_main(@location(0) fragColor : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return fragColor;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,6 @@ fn main() -> f32 {
|
||||
return ((2. * 3.) - 4.) / 5.;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(2)]]
|
||||
@stage(compute) @workgroup_size(2)
|
||||
fn ep() {
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ fn main() -> f32 {
|
||||
return (((2.0 * 3.0) - 4.0) / 5.0);
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(2)]]
|
||||
@stage(compute) @workgroup_size(2)
|
||||
fn ep() {
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
fn bar() {
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main() -> [[location(0)]] vec4<f32> {
|
||||
@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);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
fn bar() {
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main() -> [[location(0)]] vec4<f32> {
|
||||
@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);
|
||||
|
||||
@@ -6,11 +6,11 @@ fn main_1() {
|
||||
}
|
||||
|
||||
struct main_out {
|
||||
[[builtin(position)]]
|
||||
@builtin(position)
|
||||
gl_Position : vec4<f32>;
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(gl_Position);
|
||||
|
||||
@@ -18,14 +18,14 @@ let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
||||
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> {
|
||||
@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> {
|
||||
@stage(fragment)
|
||||
fn frag_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,11 +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> {
|
||||
@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> {
|
||||
@stage(fragment)
|
||||
fn frag_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user