From ff5c9c9ffcb4e21b9b43e6e823f1c230a8e1b84a Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 19 Jun 2020 11:14:29 -0400 Subject: [PATCH 1/2] Naga update with offsets and strides --- Cargo.lock | 2 +- wgpu-core/Cargo.toml | 2 +- wgpu-core/src/validation.rs | 24 +++++++++++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 259490e1b2..fc17f1ef1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -742,7 +742,7 @@ dependencies = [ [[package]] name = "naga" version = "0.1.0" -source = "git+https://github.com/gfx-rs/naga?rev=e3aea9619865b16a24164d46ab29cca36ad7daf2#e3aea9619865b16a24164d46ab29cca36ad7daf2" +source = "git+https://github.com/gfx-rs/naga?rev=a9228d2aed38c71388489a95817238ff98198fa3#a9228d2aed38c71388489a95817238ff98198fa3" dependencies = [ "bitflags", "fxhash", diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 8e35c36345..a62c86a832 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -35,7 +35,7 @@ vec_map = "0.8.1" [dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "e3aea9619865b16a24164d46ab29cca36ad7daf2" +rev = "a9228d2aed38c71388489a95817238ff98198fa3" [dependencies.gfx-descriptor] git = "https://github.com/gfx-rs/gfx-extras" diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index 0c0c19b2b4..6a94389874 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -83,16 +83,26 @@ fn get_aligned_type_size( Ti::Pointer { .. } => 4, Ti::Array { base, - size: naga::ArraySize::Static(size), - } => size as wgt::BufferAddress * get_aligned_type_size(module, base, false), + size: naga::ArraySize::Static(count), + stride, + } => { + let base_size = match stride { + Some(stride) => stride.get() as wgt::BufferAddress, + None => get_aligned_type_size(module, base, false), + }; + base_size * count as wgt::BufferAddress + } Ti::Array { base, size: naga::ArraySize::Dynamic, - } if allow_unbound => get_aligned_type_size(module, base, false), - Ti::Struct { ref members } => members - .iter() - .map(|member| get_aligned_type_size(module, member.ty, false)) - .sum(), + stride, + } if allow_unbound => match stride { + Some(stride) => stride.get() as wgt::BufferAddress, + None => get_aligned_type_size(module, base, false), + }, + Ti::Struct { ref members } => members.last().map_or(0, |member| { + member.offset as wgt::BufferAddress + get_aligned_type_size(module, member.ty, false) + }), _ => panic!("Unexpected struct field"), } } From 0c0ecc3b099de9db9f3c71100fef4b459b9b2a10 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 19 Jun 2020 11:16:29 -0400 Subject: [PATCH 2/2] Switch to latest nightly --- .github/workflows/ci.yml | 3 +-- Cargo.lock | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6db7448305..e5e1ab88d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,8 +96,7 @@ jobs: name: Install latest nightly uses: actions-rs/toolchain@v1 with: - # temporary due to https://github.com/Xudong-Huang/generator-rs/issues/21 - toolchain: nightly-2020-05-01 + toolchain: nightly override: true - if: matrix.channel == 'stable' run: rustup component add clippy diff --git a/Cargo.lock b/Cargo.lock index fc17f1ef1b..f335c8580c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -350,9 +350,9 @@ dependencies = [ [[package]] name = "generator" -version = "0.6.20" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa160efb38ce00acbe4450d41a103fb3d2acdb17ff09a7cf38f3ac26af0738" +checksum = "add72f17bb81521258fcc8a7a3245b1e184e916bfbe34f0ea89558f440df5c68" dependencies = [ "cc", "libc",