From f3d6d242d7feadfef9e502284aa0eaf6962290f5 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Tue, 15 Dec 2020 01:36:51 -0500 Subject: [PATCH 1/2] Update wgpu with Naga fixes and OpenGL backend --- Cargo.toml | 12 ++---------- examples/capture/main.rs | 1 - examples/framework.rs | 5 ++--- examples/hello-compute/main.rs | 1 - examples/hello-triangle/main.rs | 3 +-- examples/hello-windows/main.rs | 1 - src/backend/direct.rs | 2 +- src/lib.rs | 6 +++--- src/macros.rs | 2 +- 9 files changed, 10 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e345a05f8..82b007b21 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,13 +25,13 @@ vulkan-portability = ["wgc/gfx-backend-vulkan"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "42a8dc5b343b1c882d7c5bb03b0718602ea03915" +rev = "89e585af615c5ed2050a1cab7225f6e92a26b3ba" features = ["raw-window-handle"] [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "42a8dc5b343b1c882d7c5bb03b0718602ea03915" +rev = "89e585af615c5ed2050a1cab7225f6e92a26b3ba" [dependencies] arrayvec = "0.5" @@ -43,14 +43,6 @@ tracing = { version = "0.1", default-features = false, features = ["std"] } typed-arena = "2.0.1" serde = { version = "1", features = ["derive"], optional = true } -# Enable X11 support for GL -# Note: we may consider switching this to "dev-dependencies" if users -# want to opt into X11 explicitly. -[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies.gfx-backend-gl] -git = "https://github.com/gfx-rs/gfx" -rev = "f1398d29c7ad726968723a37187bd3932c539783" -features = ["x11"] - [dev-dependencies] cgmath = "0.17" log = "0.4" diff --git a/examples/capture/main.rs b/examples/capture/main.rs index 7c3e42e3f..80f96aa21 100644 --- a/examples/capture/main.rs +++ b/examples/capture/main.rs @@ -39,7 +39,6 @@ async fn create_red_image_with_dimensions( label: None, features: wgpu::Features::empty(), limits: wgpu::Limits::default(), - shader_validation: true, }, None, ) diff --git a/examples/framework.rs b/examples/framework.rs index cf6fb4762..d448b93bb 100644 --- a/examples/framework.rs +++ b/examples/framework.rs @@ -142,7 +142,7 @@ async fn setup(title: &str) -> Setup { compatible_surface: Some(&surface), }) .await - .unwrap(); + .expect("No suitable GPU adapters found on the system!"); #[cfg(not(target_arch = "wasm32"))] { @@ -168,12 +168,11 @@ async fn setup(title: &str) -> Setup { label: None, features: (optional_features & adapter_features) | required_features, limits: needed_limits, - shader_validation: false, }, trace_dir.ok().as_ref().map(std::path::Path::new), ) .await - .unwrap(); + .expect("Unable to find a suitable GPU adapter!"); Setup { window, diff --git a/examples/hello-compute/main.rs b/examples/hello-compute/main.rs index 340e03d99..962b8c257 100644 --- a/examples/hello-compute/main.rs +++ b/examples/hello-compute/main.rs @@ -37,7 +37,6 @@ async fn execute_gpu(numbers: Vec) -> Vec { label: None, features: wgpu::Features::empty(), limits: wgpu::Limits::default(), - shader_validation: true, }, None, ) diff --git a/examples/hello-triangle/main.rs b/examples/hello-triangle/main.rs index dcbe390a5..7ce41c038 100644 --- a/examples/hello-triangle/main.rs +++ b/examples/hello-triangle/main.rs @@ -25,7 +25,6 @@ async fn run(event_loop: EventLoop<()>, window: Window, swapchain_format: wgpu:: label: None, features: wgpu::Features::empty(), limits: wgpu::Limits::default(), - shader_validation: true, }, None, ) @@ -36,7 +35,7 @@ async fn run(event_loop: EventLoop<()>, window: Window, swapchain_format: wgpu:: let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor { label: None, source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))), - experimental_translation: true, + flags: wgpu::ShaderFlags::all(), }); let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { diff --git a/examples/hello-windows/main.rs b/examples/hello-windows/main.rs index 74b54787c..42f098cb1 100644 --- a/examples/hello-windows/main.rs +++ b/examples/hello-windows/main.rs @@ -88,7 +88,6 @@ async fn run( label: None, features: wgpu::Features::empty(), limits: wgpu::Limits::default(), - shader_validation: true, }, None, ) diff --git a/src/backend/direct.rs b/src/backend/direct.rs index 80086ac1e..c97b69e1c 100644 --- a/src/backend/direct.rs +++ b/src/backend/direct.rs @@ -730,7 +730,7 @@ impl crate::Context for Context { let global = &self.0; let descriptor = wgc::pipeline::ShaderModuleDescriptor { label: desc.label.map(Borrowed), - experimental_translation: desc.experimental_translation, + flags: desc.flags, }; let source = match desc.source { ShaderSource::SpirV(ref spv) => wgc::pipeline::ShaderModuleSource::SpirV(Borrowed(spv)), diff --git a/src/lib.rs b/src/lib.rs index 2191cb933..7169fbc53 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,7 +38,7 @@ pub use wgt::{ DepthStencilStateDescriptor, DynamicOffset, Extent3d, Features, FilterMode, FrontFace, IndexFormat, InputStepMode, Limits, Origin3d, PolygonMode, PowerPreference, PresentMode, PrimitiveTopology, PushConstantRange, RasterizationStateDescriptor, SamplerBorderColor, - ShaderLocation, ShaderStage, StencilOperation, StencilStateDescriptor, + ShaderFlags, ShaderLocation, ShaderStage, StencilOperation, StencilStateDescriptor, StencilStateFaceDescriptor, StorageTextureAccess, SwapChainDescriptor, SwapChainStatus, TextureAspect, TextureDataLayout, TextureDimension, TextureFormat, TextureSampleType, TextureUsage, TextureViewDimension, VertexAttributeDescriptor, VertexFormat, @@ -694,8 +694,8 @@ pub struct ShaderModuleDescriptor<'a> { pub label: Label<'a>, /// Source code for the shader. pub source: ShaderSource<'a>, - /// Experimental translation path attempts to avoid SPIR-V and work with Naga IR directly. - pub experimental_translation: bool, + /// Shader handling flags. + pub flags: ShaderFlags, } /// Handle to a pipeline layout. diff --git a/src/macros.rs b/src/macros.rs index 5521df199..d31d645cd 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -52,7 +52,7 @@ macro_rules! include_spirv { $crate::ShaderModuleDescriptor { label: Some($($token)*), source: $crate::util::make_spirv(include_bytes!($($token)*)), - experimental_translation: false, + flags: $crate::ShaderFlags::VALIDATION, } } }; From 6ef5fa2799e04ae8388e58a6cbbf8cfacb2a7430 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Thu, 17 Dec 2020 12:57:57 -0500 Subject: [PATCH 2/2] Simplify the CI check script --- .github/workflows/ci.yml | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 792fd9754..3c68000da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,29 +13,10 @@ jobs: fail-fast: false matrix: os: [macos-10.15, ubuntu-18.04, windows-2019] - include: - - os: macos-10.15 - PREPARE_COMMAND: echo "Ready" - CHECK_COMMAND: cargo check --all-targets --all-features - TEST_COMMAND: cargo test --all-targets --no-run - - os: ubuntu-18.04 - PREPARE_COMMAND: | - sudo apt-get update -y -qq - sudo apt-get install -y -qq libegl1-mesa-dev - CHECK_COMMAND: cargo check --all-targets --all-features - TEST_COMMAND: cargo test --all-targets --no-run - - os: windows-2019 - PREPARE_COMMAND: rustup default stable-msvc - CHECK_COMMAND: cargo check --all-targets --all-features - TEST_COMMAND: cargo test --all-targets --no-run steps: - uses: actions/checkout@v2 - - name: Prepare - run: ${{ matrix.PREPARE_COMMAND }} - - name: Check - run: ${{ matrix.CHECK_COMMAND }} - - name: Test - run: ${{ matrix.TEST_COMMAND }} + - run: cargo check --all-targets --all-features + - run: cargo test --all-targets --no-run wasm: runs-on: [ubuntu-18.04] @@ -44,8 +25,7 @@ jobs: steps: - uses: actions/checkout@v2 - run: rustup target add wasm32-unknown-unknown - - name: Check - run: cargo check --all-targets --all-features --target=wasm32-unknown-unknown + - run: cargo check --all-targets --all-features --target=wasm32-unknown-unknown docs: runs-on: [ubuntu-18.04]