update wgpu to 0.13

This commit is contained in:
Cupnfish 2022-07-02 15:39:42 +08:00
parent e6e3eff876
commit c148557cab
15 changed files with 140 additions and 144 deletions

View file

@ -16,19 +16,19 @@ var<private> uvs: array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(1.0, 1.0)
);
[[group(0), binding(0)]] var u_sampler: sampler;
[[group(1), binding(0)]] var u_texture: texture_2d<f32>;
@group(0) @binding(0) var u_sampler: sampler;
@group(1) @binding(0) var u_texture: texture_2d<f32>;
struct VertexInput {
[[builtin(vertex_index)]] vertex_index: u32;
@builtin(vertex_index) vertex_index: u32,
};
struct VertexOutput {
[[builtin(position)]] position: vec4<f32>;
[[location(0)]] uv: vec2<f32>;
@builtin(position) position: vec4<f32>,
@location(0) uv: vec2<f32>,
};
[[stage(vertex)]]
@vertex
fn vs_main(input: VertexInput) -> VertexOutput {
var out: VertexOutput;
out.uv = uvs[input.vertex_index];
@ -37,7 +37,7 @@ fn vs_main(input: VertexInput) -> VertexOutput {
return out;
}
[[stage(fragment)]]
fn fs_main(input: VertexOutput) -> [[location(0)]] vec4<f32> {
@fragment
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
return textureSample(u_texture, u_sampler, input.uv);
}

View file

@ -2,26 +2,26 @@ struct Globals {
transform: mat4x4<f32>;
};
[[group(0), binding(0)]] var<uniform> globals: Globals;
[[group(0), binding(1)]] var u_sampler: sampler;
[[group(1), binding(0)]] var u_texture: texture_2d_array<f32>;
@group(0) @binding(0) var<uniform> globals: Globals;
@group(0) @binding(1) var u_sampler: sampler;
@group(1) @binding(0) var u_texture: texture_2d_array<f32>;
struct VertexInput {
[[location(0)]] v_pos: vec2<f32>;
[[location(1)]] pos: vec2<f32>;
[[location(2)]] scale: vec2<f32>;
[[location(3)]] atlas_pos: vec2<f32>;
[[location(4)]] atlas_scale: vec2<f32>;
[[location(5)]] layer: i32;
@location(0) v_pos: vec2<f32>,
@location(1) pos: vec2<f32>,
@location(2) scale: vec2<f32>,
@location(3) atlas_pos: vec2<f32>,
@location(4) atlas_scale: vec2<f32>,
@location(5) layer: i32,
};
struct VertexOutput {
[[builtin(position)]] position: vec4<f32>;
[[location(0)]] uv: vec2<f32>;
[[location(1)]] layer: f32; // this should be an i32, but naga currently reads that as requiring interpolation.
@builtin(position) position: vec4<f32>,
@location(0) uv: vec2<f32>,
@location(1) layer: f32, // this should be an i32, but naga currently reads that as requiring interpolation.
};
[[stage(vertex)]]
@vertex
fn vs_main(input: VertexInput) -> VertexOutput {
var out: VertexOutput;
@ -40,7 +40,7 @@ fn vs_main(input: VertexInput) -> VertexOutput {
return out;
}
[[stage(fragment)]]
fn fs_main(input: VertexOutput) -> [[location(0)]] vec4<f32> {
@fragment
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
return textureSample(u_texture, u_sampler, input.uv, i32(input.layer));
}

View file

@ -1,31 +1,31 @@
struct Globals {
transform: mat4x4<f32>;
scale: f32;
transform: mat4x4<f32>,
scale: f32,
};
[[group(0), binding(0)]] var<uniform> globals: Globals;
@group(0) @binding(0) var<uniform> globals: Globals;
struct VertexInput {
[[location(0)]] v_pos: vec2<f32>;
[[location(1)]] pos: vec2<f32>;
[[location(2)]] scale: vec2<f32>;
[[location(3)]] color: vec4<f32>;
[[location(4)]] border_color: vec4<f32>;
[[location(5)]] border_radius: f32;
[[location(6)]] border_width: f32;
@location(0) v_pos: vec2<f32>,
@location(1) pos: vec2<f32>,
@location(2) scale: vec2<f32>,
@location(3) color: vec4<f32>,
@location(4) border_color: vec4<f32>,
@location(5) border_radius: f32,
@location(6) border_width: f32,
};
struct VertexOutput {
[[builtin(position)]] position: vec4<f32>;
[[location(0)]] color: vec4<f32>;
[[location(1)]] border_color: vec4<f32>;
[[location(2)]] pos: vec2<f32>;
[[location(3)]] scale: vec2<f32>;
[[location(4)]] border_radius: f32;
[[location(5)]] border_width: f32;
@builtin(position) position: vec4<f32>,
@location(0) color: vec4<f32>,
@location(1) border_color: vec4<f32>,
@location(2) pos: vec2<f32>,
@location(3) scale: vec2<f32>,
@location(4) border_radius: f32,
@location(5) border_width: f32,
};
[[stage(vertex)]]
@vertex
fn vs_main(input: VertexInput) -> VertexOutput {
var out: VertexOutput;
@ -77,10 +77,10 @@ fn distance_alg(
}
[[stage(fragment)]]
@fragment
fn fs_main(
input: VertexOutput
) -> [[location(0)]] vec4<f32> {
) -> @location(0) vec4<f32> {
var mixed_color: vec4<f32> = input.color;
if (input.border_width > 0.0) {
@ -96,7 +96,7 @@ fn fs_main(
internal_border
);
var border_mix: f32 = smoothStep(
var border_mix: f32 = smoothstep(
max(internal_border - 0.5, 0.0),
internal_border + 0.5,
internal_distance
@ -112,7 +112,7 @@ fn fs_main(
input.border_radius
);
var radius_alpha: f32 = 1.0 - smoothStep(
var radius_alpha: f32 = 1.0 - smoothstep(
max(input.border_radius - 0.5, 0.0),
input.border_radius + 0.5,
dist);

View file

@ -1,20 +1,20 @@
struct Globals {
transform: mat4x4<f32>;
transform: mat4x4<f32>,
};
[[group(0), binding(0)]] var<uniform> globals: Globals;
@group(0) @binding(0) var<uniform> globals: Globals;
struct VertexInput {
[[location(0)]] position: vec2<f32>;
[[location(1)]] color: vec4<f32>;
@location(0) position: vec2<f32>,
@location(1) color: vec4<f32>,
};
struct VertexOutput {
[[builtin(position)]] position: vec4<f32>;
[[location(0)]] color: vec4<f32>;
@builtin(position) position: vec4<f32>,
@location(0) color: vec4<f32>,
};
[[stage(vertex)]]
@vertex
fn vs_main(input: VertexInput) -> VertexOutput {
var out: VertexOutput;
@ -24,7 +24,7 @@ fn vs_main(input: VertexInput) -> VertexOutput {
return out;
}
[[stage(fragment)]]
fn fs_main(input: VertexOutput) -> [[location(0)]] vec4<f32> {
@fragment
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
return input.color;
}