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

1
.gitignore vendored
View File

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

70
Cargo.lock generated
View File

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

View File

@ -8,9 +8,9 @@ members = [
#[patch."https://github.com/gfx-rs/gfx"]
#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-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-dx11 = { path = "../gfx/src/backend/dx11" }
#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]
#git = "https://github.com/gfx-rs/gfx"
#rev = "f1398d29c7ad726968723a37187bd3932c539783"
#rev = "" # insert revision here
#features = ["auto-capture"]
[dependencies.wgpu-subscriber]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,11 +25,8 @@ pub enum ShaderModuleSource<'a> {
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
pub struct ShaderModuleDescriptor<'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))]
pub experimental_translation: bool,
pub flags: wgt::ShaderFlags,
}
#[derive(Debug)]

View File

@ -215,7 +215,10 @@ fn get_aligned_type_size(
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| {
Ti::Struct {
block: _,
ref members,
} => members.last().map_or(0, |member| {
let offset = match member.origin {
naga::MemberOrigin::Empty => 0,
naga::MemberOrigin::BuiltIn(_) => {
@ -681,7 +684,10 @@ impl Interface {
_ => continue,
};
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;
for (i, member) in members.iter().enumerate() {
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
/// the adapter, creating a device will panic.
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> {
@ -426,7 +423,6 @@ impl<L> DeviceDescriptor<L> {
label: fun(&self.label),
features: self.features,
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.
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]