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:
James Price 2021-04-06 18:08:47 +00:00 committed by Commit Bot service account
parent ca0f51fe45
commit a2239c64e0
4 changed files with 33 additions and 37 deletions

View File

@ -14,26 +14,23 @@
// 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)]]
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 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)));
gl_Position = vec4<f32>(pos + a_particlePos, 0.0, 1.0);
return vec4<f32>(pos + a_particlePos, 0.0, 1.0);
}
// fragment shader
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]]
fn frag_main() -> void {
fragColor = vec4<f32>(1.0, 1.0, 1.0, 1.0);
fn frag_main() -> [[location(0)]] vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
}
// compute shader
@ -60,11 +57,10 @@ fn frag_main() -> void {
[[binding(1), group(0)]] var<storage> particlesA : [[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
[[stage(compute)]]
fn comp_main() -> void {
fn comp_main(
[[builtin(global_invocation_id)]] gl_GlobalInvocationID : vec3<u32>) -> void {
var index : u32 = gl_GlobalInvocationID.x;
if (index >= 5u) {
return;

View File

@ -19,22 +19,28 @@
[[binding(0), group(0)]] var<uniform> uniforms : [[access(read)]] Uniforms;
[[location(0)]] var<in> cur_position : vec4<f32>;
[[location(1)]] var<in> color : vec4<f32>;
[[location(0)]] var<out> vtxFragColor : vec4<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
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() -> 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<in> fragColor : vec4<f32>;
[[location(0)]] var<out> outColor : vec4<f32>;
[[stage(fragment)]]
fn frag_main() -> void {
outColor = fragColor;
fn frag_main([[location(0)]] fragColor : vec4<f32>)
-> [[location(0)]] vec4<f32> {
return fragColor;
}

View File

@ -12,14 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
[[location(0)]] var<out> gl_FragColor : vec4<f32>;
fn bar() -> void {
}
[[stage(fragment)]]
fn main() -> void {
fn main() -> [[location(0)]] vec4<f32> {
var a : vec2<f32> = vec2<f32>();
gl_FragColor = vec4<f32>(0.4, 0.4, 0.8, 1.0);
bar();
return vec4<f32>(0.4, 0.4, 0.8, 1.0);
}

View File

@ -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));
[[builtin(position)]] var<out> Position : vec4<f32>;
[[builtin(vertex_index)]] var<in> VertexIndex : i32;
[[stage(vertex)]]
fn vtx_main() -> void {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn vtx_main([[builtin(vertex_index)]] VertexIndex : i32)
-> [[builtin(position)]] vec4<f32> {
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
}
// Fragment shader
[[location(0)]] var<out> outColor : vec4<f32>;
[[stage(fragment)]]
fn frag_main() -> void {
outColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
fn frag_main() -> [[location(0)]] vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
}