Merge pull request #2883 from pml68/fix/16-byte-padding-wgpu-wasm
Fix WebGL WGPU crash
This commit is contained in:
commit
bd556269ea
2 changed files with 7 additions and 2 deletions
|
|
@ -8,7 +8,7 @@ var<private> uvs: array<vec2<f32>, 6> = array<vec2<f32>, 6>(
|
||||||
);
|
);
|
||||||
|
|
||||||
@group(0) @binding(0) var u_sampler: sampler;
|
@group(0) @binding(0) var u_sampler: sampler;
|
||||||
@group(0) @binding(1) var<uniform> u_ratio: vec2<f32>;
|
@group(0) @binding(1) var<uniform> u_ratio: vec4<f32>;
|
||||||
@group(1) @binding(0) var u_texture: texture_2d<f32>;
|
@group(1) @binding(0) var u_texture: texture_2d<f32>;
|
||||||
|
|
||||||
struct VertexInput {
|
struct VertexInput {
|
||||||
|
|
@ -25,7 +25,7 @@ fn vs_main(input: VertexInput) -> VertexOutput {
|
||||||
let uv = uvs[input.vertex_index];
|
let uv = uvs[input.vertex_index];
|
||||||
|
|
||||||
var out: VertexOutput;
|
var out: VertexOutput;
|
||||||
out.uv = uv * u_ratio;
|
out.uv = uv * u_ratio.xy;
|
||||||
out.position = vec4<f32>(uv * vec2(2.0, -2.0) + vec2(-1.0, 1.0), 0.0, 1.0);
|
out.position = vec4<f32>(uv * vec2(2.0, -2.0) + vec2(-1.0, 1.0), 0.0, 1.0);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
|
||||||
|
|
@ -254,6 +254,10 @@ impl Targets {
|
||||||
struct Ratio {
|
struct Ratio {
|
||||||
u: f32,
|
u: f32,
|
||||||
v: f32,
|
v: f32,
|
||||||
|
// Padding field to make Ratio 16 byte aligned
|
||||||
|
//
|
||||||
|
// See https://docs.rs/wgpu/latest/wgpu/struct.DownlevelFlags.html#associatedconstant.BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED
|
||||||
|
_padding: [f32; 2],
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct State {
|
pub struct State {
|
||||||
|
|
@ -306,6 +310,7 @@ impl State {
|
||||||
let ratio = Ratio {
|
let ratio = Ratio {
|
||||||
u: region_size.width as f32 / targets.size.width as f32,
|
u: region_size.width as f32 / targets.size.width as f32,
|
||||||
v: region_size.height as f32 / targets.size.height as f32,
|
v: region_size.height as f32 / targets.size.height as f32,
|
||||||
|
_padding: [0.0; 2],
|
||||||
};
|
};
|
||||||
|
|
||||||
if Some(ratio) != self.last_ratio {
|
if Some(ratio) != self.last_ratio {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue