Update Tint samples to new entry point IO syntax
Change-Id: Iadfb311a66b709470740d13884e94702856858b4 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46920 Auto-Submit: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: James Price <jrprice@google.com>
This commit is contained in:
parent
ca0f51fe45
commit
a2239c64e0
|
@ -14,26 +14,23 @@
|
||||||
|
|
||||||
// vertex shader
|
// vertex shader
|
||||||
|
|
||||||
[[location(0)]] var<in> a_particlePos : vec2<f32>;
|
|
||||||
[[location(1)]] var<in> a_particleVel : vec2<f32>;
|
|
||||||
[[location(2)]] var<in> a_pos : vec2<f32>;
|
|
||||||
[[builtin(position)]] var<out> gl_Position : vec4<f32>;
|
|
||||||
|
|
||||||
[[stage(vertex)]]
|
[[stage(vertex)]]
|
||||||
fn vert_main() -> void {
|
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 angle : f32 = -atan2(a_particleVel.x, a_particleVel.y);
|
||||||
var pos : vec2<f32> = vec2<f32>(
|
var pos : vec2<f32> = vec2<f32>(
|
||||||
(a_pos.x * cos(angle)) - (a_pos.y * sin(angle)),
|
(a_pos.x * cos(angle)) - (a_pos.y * sin(angle)),
|
||||||
(a_pos.x * sin(angle)) + (a_pos.y * cos(angle)));
|
(a_pos.x * sin(angle)) + (a_pos.y * cos(angle)));
|
||||||
gl_Position = vec4<f32>(pos + a_particlePos, 0.0, 1.0);
|
return vec4<f32>(pos + a_particlePos, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fragment shader
|
// fragment shader
|
||||||
[[location(0)]] var<out> fragColor : vec4<f32>;
|
|
||||||
|
|
||||||
[[stage(fragment)]]
|
[[stage(fragment)]]
|
||||||
fn frag_main() -> void {
|
fn frag_main() -> [[location(0)]] vec4<f32> {
|
||||||
fragColor = vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute shader
|
// compute shader
|
||||||
|
@ -60,11 +57,10 @@ fn frag_main() -> void {
|
||||||
[[binding(1), group(0)]] var<storage> particlesA : [[access(read_write)]] Particles;
|
[[binding(1), group(0)]] var<storage> particlesA : [[access(read_write)]] Particles;
|
||||||
[[binding(2), group(0)]] var<storage> particlesB : [[access(read_write)]] Particles;
|
[[binding(2), group(0)]] var<storage> particlesB : [[access(read_write)]] Particles;
|
||||||
|
|
||||||
[[builtin(global_invocation_id)]] var<in> gl_GlobalInvocationID : vec3<u32>;
|
|
||||||
|
|
||||||
// https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp
|
// https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp
|
||||||
[[stage(compute)]]
|
[[stage(compute)]]
|
||||||
fn comp_main() -> void {
|
fn comp_main(
|
||||||
|
[[builtin(global_invocation_id)]] gl_GlobalInvocationID : vec3<u32>) -> void {
|
||||||
var index : u32 = gl_GlobalInvocationID.x;
|
var index : u32 = gl_GlobalInvocationID.x;
|
||||||
if (index >= 5u) {
|
if (index >= 5u) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -19,22 +19,28 @@
|
||||||
|
|
||||||
[[binding(0), group(0)]] var<uniform> uniforms : [[access(read)]] Uniforms;
|
[[binding(0), group(0)]] var<uniform> uniforms : [[access(read)]] Uniforms;
|
||||||
|
|
||||||
[[location(0)]] var<in> cur_position : vec4<f32>;
|
struct VertexInput {
|
||||||
[[location(1)]] var<in> color : vec4<f32>;
|
[[location(0)]] cur_position : vec4<f32>;
|
||||||
[[location(0)]] var<out> vtxFragColor : vec4<f32>;
|
[[location(1)]] color : vec4<f32>;
|
||||||
[[builtin(position)]] var<out> Position : vec4<f32>;
|
};
|
||||||
|
|
||||||
|
struct VertexOutput {
|
||||||
|
[[location(0)]] vtxFragColor : vec4<f32>;
|
||||||
|
[[builtin(position)]] Position : vec4<f32>;
|
||||||
|
};
|
||||||
|
|
||||||
[[stage(vertex)]]
|
[[stage(vertex)]]
|
||||||
fn vtx_main() -> void {
|
fn vtx_main(input : VertexInput) -> VertexOutput {
|
||||||
Position = uniforms.modelViewProjectionMatrix * cur_position;
|
var output : VertexOutput;
|
||||||
vtxFragColor = color;
|
output.Position = uniforms.modelViewProjectionMatrix * input.cur_position;
|
||||||
|
output.vtxFragColor = input.color;
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fragment shader
|
// Fragment shader
|
||||||
[[location(0)]] var<in> fragColor : vec4<f32>;
|
|
||||||
[[location(0)]] var<out> outColor : vec4<f32>;
|
|
||||||
|
|
||||||
[[stage(fragment)]]
|
[[stage(fragment)]]
|
||||||
fn frag_main() -> void {
|
fn frag_main([[location(0)]] fragColor : vec4<f32>)
|
||||||
outColor = fragColor;
|
-> [[location(0)]] vec4<f32> {
|
||||||
|
return fragColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,12 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
[[location(0)]] var<out> gl_FragColor : vec4<f32>;
|
|
||||||
|
|
||||||
fn bar() -> void {
|
fn bar() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
[[stage(fragment)]]
|
[[stage(fragment)]]
|
||||||
fn main() -> void {
|
fn main() -> [[location(0)]] vec4<f32> {
|
||||||
var a : vec2<f32> = vec2<f32>();
|
var a : vec2<f32> = vec2<f32>();
|
||||||
gl_FragColor = vec4<f32>(0.4, 0.4, 0.8, 1.0);
|
|
||||||
bar();
|
bar();
|
||||||
|
return vec4<f32>(0.4, 0.4, 0.8, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,18 +18,14 @@ const pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
||||||
vec2<f32>(-0.5, -0.5),
|
vec2<f32>(-0.5, -0.5),
|
||||||
vec2<f32>(0.5, -0.5));
|
vec2<f32>(0.5, -0.5));
|
||||||
|
|
||||||
[[builtin(position)]] var<out> Position : vec4<f32>;
|
|
||||||
[[builtin(vertex_index)]] var<in> VertexIndex : i32;
|
|
||||||
|
|
||||||
[[stage(vertex)]]
|
[[stage(vertex)]]
|
||||||
fn vtx_main() -> void {
|
fn vtx_main([[builtin(vertex_index)]] VertexIndex : i32)
|
||||||
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
-> [[builtin(position)]] vec4<f32> {
|
||||||
|
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fragment shader
|
// Fragment shader
|
||||||
[[location(0)]] var<out> outColor : vec4<f32>;
|
|
||||||
|
|
||||||
[[stage(fragment)]]
|
[[stage(fragment)]]
|
||||||
fn frag_main() -> void {
|
fn frag_main() -> [[location(0)]] vec4<f32> {
|
||||||
outColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue