Update naga and gfx, move the shader validation into a shader descriptor bit

This commit is contained in:
Dzmitry Malyshau 2020-12-15 01:13:23 -05:00
parent 42a8dc5b34
commit f07cc8156b
13 changed files with 106 additions and 96 deletions

View File

@ -26,11 +26,7 @@ jobs:
PKG_CONFIG_ALLOW_CROSS: 1 PKG_CONFIG_ALLOW_CROSS: 1
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Prepare - run: echo "$ANDROID_HOME/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
run: |
sudo apt-get update -y -qq
sudo apt-get install -y -qq libegl1-mesa-dev
echo "$ANDROID_HOME/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
- run: rustup component add clippy - run: rustup component add clippy
- run: rustup target add ${{ env.TARGET }} - run: rustup target add ${{ env.TARGET }}
- run: cargo clippy --target ${{ env.TARGET }} - run: cargo clippy --target ${{ env.TARGET }}
@ -61,9 +57,7 @@ jobs:
- name: Ubuntu Stable - name: Ubuntu Stable
os: ubuntu-18.04 os: ubuntu-18.04
channel: stable channel: stable
prepare_command: | prepare_command:
sudo apt-get update -y -qq
sudo apt-get install -y -qq libegl1-mesa-dev
additional_core_features: trace,replay additional_core_features: trace,replay
additional_player_features: additional_player_features:
- name: Ubuntu Nightly - name: Ubuntu Nightly
@ -71,8 +65,6 @@ jobs:
channel: nightly channel: nightly
prepare_command: | prepare_command: |
sudo apt-get update -y -qq sudo apt-get update -y -qq
echo "Installing EGL"
sudo apt-get install -y -qq libegl1-mesa-dev
echo "Installing Vulkan" echo "Installing Vulkan"
sudo apt-get install -y -qq mesa-vulkan-drivers sudo apt-get install -y -qq mesa-vulkan-drivers
additional_core_features: serial-pass additional_core_features: serial-pass

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
/target /target
**/*.rs.bk **/*.rs.bk
#Cargo.lock #Cargo.lock
.fuse_hidden*
.DS_Store .DS_Store
.vscode .vscode
.vs .vs

70
Cargo.lock generated
View File

@ -441,7 +441,7 @@ dependencies = [
[[package]] [[package]]
name = "gfx-auxil" name = "gfx-auxil"
version = "0.5.0" version = "0.5.0"
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783" source = "git+https://github.com/gfx-rs/gfx?rev=0244e3401e9f127617cb8636397048584e7bfe8a#0244e3401e9f127617cb8636397048584e7bfe8a"
dependencies = [ dependencies = [
"fxhash", "fxhash",
"gfx-hal", "gfx-hal",
@ -451,7 +451,7 @@ dependencies = [
[[package]] [[package]]
name = "gfx-backend-dx11" name = "gfx-backend-dx11"
version = "0.6.0" version = "0.6.0"
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783" source = "git+https://github.com/gfx-rs/gfx?rev=0244e3401e9f127617cb8636397048584e7bfe8a#0244e3401e9f127617cb8636397048584e7bfe8a"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bitflags", "bitflags",
@ -472,7 +472,7 @@ dependencies = [
[[package]] [[package]]
name = "gfx-backend-dx12" name = "gfx-backend-dx12"
version = "0.6.2" version = "0.6.2"
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783" source = "git+https://github.com/gfx-rs/gfx?rev=0244e3401e9f127617cb8636397048584e7bfe8a#0244e3401e9f127617cb8636397048584e7bfe8a"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bit-set", "bit-set",
@ -492,7 +492,7 @@ dependencies = [
[[package]] [[package]]
name = "gfx-backend-empty" name = "gfx-backend-empty"
version = "0.6.0" version = "0.6.0"
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783" source = "git+https://github.com/gfx-rs/gfx?rev=0244e3401e9f127617cb8636397048584e7bfe8a#0244e3401e9f127617cb8636397048584e7bfe8a"
dependencies = [ dependencies = [
"gfx-hal", "gfx-hal",
"log", "log",
@ -502,7 +502,7 @@ dependencies = [
[[package]] [[package]]
name = "gfx-backend-gl" name = "gfx-backend-gl"
version = "0.6.0" version = "0.6.0"
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783" source = "git+https://github.com/gfx-rs/gfx?rev=0244e3401e9f127617cb8636397048584e7bfe8a#0244e3401e9f127617cb8636397048584e7bfe8a"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bitflags", "bitflags",
@ -511,8 +511,9 @@ dependencies = [
"glow", "glow",
"js-sys", "js-sys",
"khronos-egl", "khronos-egl",
"lazy_static", "libloading",
"log", "log",
"naga",
"parking_lot 0.11.0", "parking_lot 0.11.0",
"raw-window-handle", "raw-window-handle",
"smallvec", "smallvec",
@ -524,7 +525,7 @@ dependencies = [
[[package]] [[package]]
name = "gfx-backend-metal" name = "gfx-backend-metal"
version = "0.6.0" version = "0.6.0"
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783" source = "git+https://github.com/gfx-rs/gfx?rev=0244e3401e9f127617cb8636397048584e7bfe8a#0244e3401e9f127617cb8636397048584e7bfe8a"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bitflags", "bitflags",
@ -549,7 +550,7 @@ dependencies = [
[[package]] [[package]]
name = "gfx-backend-vulkan" name = "gfx-backend-vulkan"
version = "0.6.5" version = "0.6.5"
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783" source = "git+https://github.com/gfx-rs/gfx?rev=0244e3401e9f127617cb8636397048584e7bfe8a#0244e3401e9f127617cb8636397048584e7bfe8a"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"ash", "ash",
@ -559,6 +560,7 @@ dependencies = [
"inplace_it", "inplace_it",
"lazy_static", "lazy_static",
"log", "log",
"naga",
"objc", "objc",
"raw-window-handle", "raw-window-handle",
"smallvec", "smallvec",
@ -568,7 +570,7 @@ dependencies = [
[[package]] [[package]]
name = "gfx-hal" name = "gfx-hal"
version = "0.6.0" version = "0.6.0"
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783" source = "git+https://github.com/gfx-rs/gfx?rev=0244e3401e9f127617cb8636397048584e7bfe8a#0244e3401e9f127617cb8636397048584e7bfe8a"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"naga", "naga",
@ -613,6 +615,7 @@ dependencies = [
"bitflags", "bitflags",
"gpu-descriptor-types", "gpu-descriptor-types",
"hashbrown", "hashbrown",
"tracing",
] ]
[[package]] [[package]]
@ -707,9 +710,9 @@ dependencies = [
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.45" version = "0.3.37"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8" checksum = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055"
dependencies = [ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
@ -724,24 +727,13 @@ dependencies = [
"winapi-build", "winapi-build",
] ]
[[package]]
name = "khronos"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0711aaa80e6ba6eb1fa8978f1f46bfcb38ceb2f3f33f3736efbff39dac89f50"
dependencies = [
"libc 0.1.12",
]
[[package]] [[package]]
name = "khronos-egl" name = "khronos-egl"
version = "2.2.0" version = "3.0.0-beta"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/timothee-haudebourg/khronos-egl?rev=9568b2ee3b02f2c17cc9479f824db16daecf1664#9568b2ee3b02f2c17cc9479f824db16daecf1664"
checksum = "e99a569e2016510b4d6001b8049a377dabbcc00f88b20337641de351bc22edca"
dependencies = [ dependencies = [
"khronos",
"libc 0.2.80", "libc 0.2.80",
"pkg-config", "libloading",
] ]
[[package]] [[package]]
@ -927,7 +919,7 @@ dependencies = [
[[package]] [[package]]
name = "naga" name = "naga"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/gfx-rs/naga?tag=gfx-4#4f958bf658de7ee4e285bd40a5975136582e1113" source = "git+https://github.com/gfx-rs/naga?tag=gfx-5#583f218c9dbca08daa6bf3efda60e80ecada63bb"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"fxhash", "fxhash",
@ -1217,7 +1209,7 @@ dependencies = [
[[package]] [[package]]
name = "range-alloc" name = "range-alloc"
version = "0.1.1" version = "0.1.1"
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783" source = "git+https://github.com/gfx-rs/gfx?rev=0244e3401e9f127617cb8636397048584e7bfe8a#0244e3401e9f127617cb8636397048584e7bfe8a"
[[package]] [[package]]
name = "raw-window-handle" name = "raw-window-handle"
@ -1677,9 +1669,9 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.68" version = "0.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" checksum = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if 0.1.10",
"wasm-bindgen-macro", "wasm-bindgen-macro",
@ -1687,9 +1679,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-backend" name = "wasm-bindgen-backend"
version = "0.2.68" version = "0.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68" checksum = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"lazy_static", "lazy_static",
@ -1702,9 +1694,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.68" version = "0.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038" checksum = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4"
dependencies = [ dependencies = [
"quote 1.0.7", "quote 1.0.7",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
@ -1712,9 +1704,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro-support" name = "wasm-bindgen-macro-support"
version = "0.2.68" version = "0.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe" checksum = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931"
dependencies = [ dependencies = [
"proc-macro2 1.0.24", "proc-macro2 1.0.24",
"quote 1.0.7", "quote 1.0.7",
@ -1725,9 +1717,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-shared" name = "wasm-bindgen-shared"
version = "0.2.68" version = "0.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307" checksum = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639"
[[package]] [[package]]
name = "wayland-client" name = "wayland-client"
@ -1791,9 +1783,9 @@ dependencies = [
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.45" version = "0.3.37"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d" checksum = "2d6f51648d8c56c366144378a33290049eafdd784071077f6fe37dae64c1c4cb"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",

View File

@ -8,9 +8,9 @@ members = [
#[patch."https://github.com/gfx-rs/gfx"] #[patch."https://github.com/gfx-rs/gfx"]
#hal = { package = "gfx-hal", path = "../gfx/src/hal" } #hal = { package = "gfx-hal", path = "../gfx/src/hal" }
#gfx-backend-vulkan = { path = "../gfx/src/backend/vulkan" } #gfx-backend-vulkan = { path = "../gfx/src/backend/vulkan", features = ["naga"] }
#gfx-backend-metal = { path = "../gfx/src/backend/metal", features = ["naga"] } #gfx-backend-metal = { path = "../gfx/src/backend/metal", features = ["naga"] }
#gfx-backend-gl = { path = "../gfx/src/backend/gl" } #gfx-backend-gl = { path = "../gfx/src/backend/gl", features = ["naga"] }
#gfx-backend-dx12 = { path = "../gfx/src/backend/dx12" } #gfx-backend-dx12 = { path = "../gfx/src/backend/dx12" }
#gfx-backend-dx11 = { path = "../gfx/src/backend/dx11" } #gfx-backend-dx11 = { path = "../gfx/src/backend/dx11" }
#gfx-backend-empty = { path = "../gfx/src/backend/empty" } #gfx-backend-empty = { path = "../gfx/src/backend/empty" }

View File

@ -36,7 +36,7 @@ features = ["replay", "raw-window-handle"]
#[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies.gfx-backend-metal] #[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies.gfx-backend-metal]
#git = "https://github.com/gfx-rs/gfx" #git = "https://github.com/gfx-rs/gfx"
#rev = "f1398d29c7ad726968723a37187bd3932c539783" #rev = "" # insert revision here
#features = ["auto-capture"] #features = ["auto-capture"]
[dependencies.wgpu-subscriber] [dependencies.wgpu-subscriber]

View File

@ -93,7 +93,6 @@ impl Test<'_> {
label: None, label: None,
features: self.features | wgt::Features::MAPPABLE_PRIMARY_BUFFERS, features: self.features | wgt::Features::MAPPABLE_PRIMARY_BUFFERS,
limits: wgt::Limits::default(), limits: wgt::Limits::default(),
shader_validation: true,
}, },
None, None,
device device

View File

@ -32,28 +32,29 @@ serde = { version = "1.0", features = ["serde_derive"], optional = true }
smallvec = "1" smallvec = "1"
tracing = { version = "0.1", default-features = false, features = ["std"] } tracing = { version = "0.1", default-features = false, features = ["std"] }
thiserror = "1" thiserror = "1"
gpu-alloc = { git = "https://github.com/zakarumych/gpu-alloc", rev = "d07be73f9439a37c89f5b72f2500cbf0eb4ff613" } #TODO: enable "tracing", blocked by https://github.com/zakarumych/gpu-alloc/issues/30
gpu-descriptor = { git = "https://github.com/zakarumych/gpu-descriptor", rev = "df74fd8c7bea03149058a41aab0e4fe04077b266"} gpu-alloc = { git = "https://github.com/zakarumych/gpu-alloc", rev = "d07be73f9439a37c89f5b72f2500cbf0eb4ff613", features = [] }
gpu-descriptor = { git = "https://github.com/zakarumych/gpu-descriptor", rev = "df74fd8c7bea03149058a41aab0e4fe04077b266", features = ["tracing"] }
hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" } hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" } gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies] [target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies]
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" } gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", features = ["naga"] }
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" } gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", features = ["naga"] }
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies] [target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783", features = ["naga"] } gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", features = ["naga"] }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783", optional = true } gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", optional = true }
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" } gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" } gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" } gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
[dependencies.naga] [dependencies.naga]
git = "https://github.com/gfx-rs/naga" git = "https://github.com/gfx-rs/naga"
tag = "gfx-4" tag = "gfx-5"
features = ["spv-in", "spv-out", "wgsl-in"] features = ["spv-in", "spv-out", "wgsl-in"]
[dependencies.wgt] [dependencies.wgt]

View File

@ -11,8 +11,8 @@ use crate::{
id, pipeline, resource, span, swap_chain, id, pipeline, resource, span, swap_chain,
track::{BufferState, TextureSelector, TextureState, TrackerSet}, track::{BufferState, TextureSelector, TextureState, TrackerSet},
validation::{self, check_buffer_usage, check_texture_usage}, validation::{self, check_buffer_usage, check_texture_usage},
FastHashMap, Label, LabelHelpers, LifeGuard, MultiRefCount, PrivateFeatures, Stored, FastHashMap, FastHashSet, Label, LabelHelpers, LifeGuard, MultiRefCount, PrivateFeatures,
SubmissionIndex, MAX_BIND_GROUPS, Stored, SubmissionIndex, MAX_BIND_GROUPS,
}; };
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
@ -232,6 +232,7 @@ pub struct Device<B: hal::Backend> {
pub(crate) private_features: PrivateFeatures, pub(crate) private_features: PrivateFeatures,
pub(crate) limits: wgt::Limits, pub(crate) limits: wgt::Limits,
pub(crate) features: wgt::Features, pub(crate) features: wgt::Features,
spirv_capabilities: FastHashSet<naga::back::spv::Capability>,
//TODO: move this behind another mutex. This would allow several methods to switch //TODO: move this behind another mutex. This would allow several methods to switch
// to borrow Device immutably, such as `write_buffer`, `write_texture`, and `buffer_unmap`. // to borrow Device immutably, such as `write_buffer`, `write_texture`, and `buffer_unmap`.
pending_writes: queue::PendingWrites<B>, pending_writes: queue::PendingWrites<B>,
@ -256,6 +257,8 @@ impl<B: GfxBackend> Device<B> {
desc: &DeviceDescriptor, desc: &DeviceDescriptor,
trace_path: Option<&std::path::Path>, trace_path: Option<&std::path::Path>,
) -> Result<Self, CreateDeviceError> { ) -> Result<Self, CreateDeviceError> {
use naga::back::spv::Capability as C;
let cmd_allocator = command::CommandAllocator::new(queue_group.family, &raw) let cmd_allocator = command::CommandAllocator::new(queue_group.family, &raw)
.or(Err(CreateDeviceError::OutOfMemory))?; .or(Err(CreateDeviceError::OutOfMemory))?;
@ -267,6 +270,12 @@ impl<B: GfxBackend> Device<B> {
None => (), None => (),
} }
let mut spirv_capabilities = FastHashSet::default();
spirv_capabilities.insert(C::Shader);
spirv_capabilities.insert(C::Matrix);
spirv_capabilities.insert(C::Sampled1D);
spirv_capabilities.insert(C::Image1D);
Ok(Self { Ok(Self {
raw, raw,
adapter_id, adapter_id,
@ -299,6 +308,7 @@ impl<B: GfxBackend> Device<B> {
private_features, private_features,
limits: desc.limits.clone(), limits: desc.limits.clone(),
features: desc.features.clone(), features: desc.features.clone(),
spirv_capabilities,
pending_writes: queue::PendingWrites::new(), pending_writes: queue::PendingWrites::new(),
}) })
} }
@ -876,10 +886,13 @@ impl<B: GfxBackend> Device<B> {
let naga_result = match module { let naga_result = match module {
// If succeeded, then validate it and attempt to give it to gfx-hal directly. // If succeeded, then validate it and attempt to give it to gfx-hal directly.
Some(module) => { Some(module) => {
if self.private_features.shader_validation { if desc.flags.contains(wgt::ShaderFlags::VALIDATION) {
naga::proc::Validator::new().validate(&module)?; naga::proc::Validator::new().validate(&module)?;
} }
if desc.experimental_translation { if desc
.flags
.contains(wgt::ShaderFlags::EXPERIMENTAL_TRANSLATION)
{
match unsafe { self.raw.create_shader_module_from_naga(module) } { match unsafe { self.raw.create_shader_module_from_naga(module) } {
Ok(raw) => Ok(raw), Ok(raw) => Ok(raw),
Err((hal::device::ShaderError::CompilationFailed(msg), module)) => { Err((hal::device::ShaderError::CompilationFailed(msg), module)) => {
@ -900,7 +913,7 @@ impl<B: GfxBackend> Device<B> {
Ok(raw) => Ok(raw), Ok(raw) => Ok(raw),
Err(maybe_module) => { Err(maybe_module) => {
let spv = match spv { let spv = match spv {
Some(data) => data, Some(data) => Ok(data),
None => { None => {
// Produce a SPIR-V from the Naga module // Produce a SPIR-V from the Naga module
let module = maybe_module.unwrap(); let module = maybe_module.unwrap();
@ -908,11 +921,17 @@ impl<B: GfxBackend> Device<B> {
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
flags |= naga::back::spv::WriterFlags::DEBUG; flags |= naga::back::spv::WriterFlags::DEBUG;
} }
let data = naga::back::spv::write_vec(&module, flags); naga::back::spv::write_vec(&module, flags, self.spirv_capabilities.clone())
Cow::Owned(data) .map(Cow::Owned)
} }
}; };
unsafe { self.raw.create_shader_module(&spv) } match spv {
Ok(data) => unsafe { self.raw.create_shader_module(&data) },
Err(e) => Err(hal::device::ShaderError::CompilationFailed(format!(
"{}",
e
))),
}
} }
}; };
@ -1719,13 +1738,14 @@ impl<B: GfxBackend> Device<B> {
.map_err(|_| pipeline::CreateComputePipelineError::InvalidLayout)?; .map_err(|_| pipeline::CreateComputePipelineError::InvalidLayout)?;
let pipeline_desc = hal::pso::ComputePipelineDesc { let pipeline_desc = hal::pso::ComputePipelineDesc {
label: desc.label.as_ref().map(AsRef::as_ref),
shader, shader,
layout: &layout.raw, layout: &layout.raw,
flags, flags,
parent, parent,
}; };
let mut raw = match unsafe { self.raw.create_compute_pipeline(&pipeline_desc, None) } { let raw = match unsafe { self.raw.create_compute_pipeline(&pipeline_desc, None) } {
Ok(pipeline) => pipeline, Ok(pipeline) => pipeline,
Err(hal::pso::CreationError::OutOfMemory(_)) => { Err(hal::pso::CreationError::OutOfMemory(_)) => {
return Err(pipeline::CreateComputePipelineError::Device( return Err(pipeline::CreateComputePipelineError::Device(
@ -1734,9 +1754,6 @@ impl<B: GfxBackend> Device<B> {
} }
other => panic!("Compute pipeline creation error: {:?}", other), other => panic!("Compute pipeline creation error: {:?}", other),
}; };
if let Some(ref label) = desc.label {
unsafe { self.raw.set_compute_pipeline_name(&mut raw, label) };
}
let pipeline = pipeline::ComputePipeline { let pipeline = pipeline::ComputePipeline {
raw, raw,
@ -2099,6 +2116,7 @@ impl<B: GfxBackend> Device<B> {
let mut render_pass_cache = self.render_passes.lock(); let mut render_pass_cache = self.render_passes.lock();
let pipeline_desc = hal::pso::GraphicsPipelineDesc { let pipeline_desc = hal::pso::GraphicsPipelineDesc {
label: desc.label.as_ref().map(AsRef::as_ref),
primitive_assembler, primitive_assembler,
rasterizer, rasterizer,
fragment, fragment,
@ -2123,7 +2141,7 @@ impl<B: GfxBackend> Device<B> {
parent, parent,
}; };
// TODO: cache // TODO: cache
let mut raw = unsafe { let raw = unsafe {
self.raw self.raw
.create_graphics_pipeline(&pipeline_desc, None) .create_graphics_pipeline(&pipeline_desc, None)
.map_err(|err| match err { .map_err(|err| match err {
@ -2131,9 +2149,6 @@ impl<B: GfxBackend> Device<B> {
_ => panic!("failed to create graphics pipeline: {}", err), _ => panic!("failed to create graphics pipeline: {}", err),
})? })?
}; };
if let Some(ref label) = desc.label {
unsafe { self.raw.set_graphics_pipeline_name(&mut raw, label) };
}
let pass_context = RenderPassContext { let pass_context = RenderPassContext {
attachments: AttachmentData { attachments: AttachmentData {

View File

@ -363,11 +363,7 @@ impl<B: GfxBackend> Adapter<B> {
} }
let mem_props = phd.memory_properties(); let mem_props = phd.memory_properties();
if !desc.shader_validation {
tracing::warn!("Shader validation is disabled");
}
let private_features = PrivateFeatures { let private_features = PrivateFeatures {
shader_validation: desc.shader_validation,
anisotropic_filtering: enabled_features.contains(hal::Features::SAMPLER_ANISOTROPY), anisotropic_filtering: enabled_features.contains(hal::Features::SAMPLER_ANISOTROPY),
texture_d24: phd texture_d24: phd
.format_properties(Some(hal::format::Format::X8D24Unorm)) .format_properties(Some(hal::format::Format::X8D24Unorm))

View File

@ -219,7 +219,6 @@ struct Stored<T> {
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
struct PrivateFeatures { struct PrivateFeatures {
shader_validation: bool,
anisotropic_filtering: bool, anisotropic_filtering: bool,
texture_d24: bool, texture_d24: bool,
texture_d24_s8: bool, texture_d24_s8: bool,

View File

@ -25,11 +25,8 @@ pub enum ShaderModuleSource<'a> {
#[cfg_attr(feature = "replay", derive(serde::Deserialize))] #[cfg_attr(feature = "replay", derive(serde::Deserialize))]
pub struct ShaderModuleDescriptor<'a> { pub struct ShaderModuleDescriptor<'a> {
pub label: Label<'a>, pub label: Label<'a>,
/// If enabled, `wgpu` will attempt to operate on `Naga` representation
/// of the shader module for both validation and translation into the
/// backend shader languages, where `gfx-hal` supports this.
#[cfg_attr(any(feature = "replay", feature = "trace"), serde(default))] #[cfg_attr(any(feature = "replay", feature = "trace"), serde(default))]
pub experimental_translation: bool, pub flags: wgt::ShaderFlags,
} }
#[derive(Debug)] #[derive(Debug)]

View File

@ -215,7 +215,10 @@ fn get_aligned_type_size(
Some(stride) => stride.get() as wgt::BufferAddress, Some(stride) => stride.get() as wgt::BufferAddress,
None => get_aligned_type_size(module, base, false), None => get_aligned_type_size(module, base, false),
}, },
Ti::Struct { ref members } => members.last().map_or(0, |member| { Ti::Struct {
block: _,
ref members,
} => members.last().map_or(0, |member| {
let offset = match member.origin { let offset = match member.origin {
naga::MemberOrigin::Empty => 0, naga::MemberOrigin::Empty => 0,
naga::MemberOrigin::BuiltIn(_) => { naga::MemberOrigin::BuiltIn(_) => {
@ -681,7 +684,10 @@ impl Interface {
_ => continue, _ => continue,
}; };
let ty = match module.types[var.ty].inner { let ty = match module.types[var.ty].inner {
naga::TypeInner::Struct { ref members } => { naga::TypeInner::Struct {
block: true,
ref members,
} => {
let mut actual_size = 0; let mut actual_size = 0;
for (i, member) in members.iter().enumerate() { for (i, member) in members.iter().enumerate() {
actual_size += actual_size +=

View File

@ -415,9 +415,6 @@ pub struct DeviceDescriptor<L> {
/// Limits that the device should support. If any limit is "better" than the limit exposed by /// Limits that the device should support. If any limit is "better" than the limit exposed by
/// the adapter, creating a device will panic. /// the adapter, creating a device will panic.
pub limits: Limits, pub limits: Limits,
/// Switch shader validation on/off. This is a temporary field
/// that will be removed once our validation logic is complete.
pub shader_validation: bool,
} }
impl<L> DeviceDescriptor<L> { impl<L> DeviceDescriptor<L> {
@ -426,7 +423,6 @@ impl<L> DeviceDescriptor<L> {
label: fun(&self.label), label: fun(&self.label),
features: self.features, features: self.features,
limits: self.limits.clone(), limits: self.limits.clone(),
shader_validation: self.shader_validation,
} }
} }
} }
@ -451,6 +447,22 @@ bitflags::bitflags! {
} }
} }
bitflags::bitflags! {
#[derive(Default)]
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
pub struct ShaderFlags: u32 {
/// If enabled, `wgpu` will parse the shader with `Naga`
/// and validate it both internally and with regards to
/// the given pipeline interface.
const VALIDATION = 1;
/// If enabled, `wgpu` will attempt to operate on `Naga`'s internal
/// representation of the shader module for both validation and translation
/// into the backend shader language, on backends where `gfx-hal` supports this.
const EXPERIMENTAL_TRANSLATION = 2;
}
}
/// Dimensions of a particular texture view. /// Dimensions of a particular texture view.
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]