Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.19.3 #5327

Merged
merged 6 commits into from
Mar 1, 2024
Merged

v0.19.3 #5327

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
[alias]
xtask = "run --manifest-path xtask/Cargo.toml"

[build]
rustflags = [
"--cfg=web_sys_unstable_apis"
]
rustdocflags = [
"--cfg=web_sys_unstable_apis"
]
xtask = "run --manifest-path xtask/Cargo.toml --"
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.mtl binary
*.obj binary
wgpu/src/backend/webgpu/webgpu_sys/** linguist-generated=true
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ env:
RUST_LOG: info
RUST_BACKTRACE: full
PKG_CONFIG_ALLOW_CROSS: 1 # allow android to work
RUSTFLAGS: --cfg=web_sys_unstable_apis -D warnings
RUSTDOCFLAGS: --cfg=web_sys_unstable_apis -D warnings
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
WASM_BINDGEN_TEST_TIMEOUT: 300 # 5 minutes
CACHE_SUFFIX: c # cache busting

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
CARGO_INCREMENTAL: false
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
RUSTFLAGS: --cfg=web_sys_unstable_apis
RUSTFLAGS:

jobs:
publish:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ cts/

# Cached GPU config
.gpuconfig

# Temporary clone location for wasm-bindgen mirroring
wgpu/src/backend/webgpu/webgpu_sys/wasm_bindgen_clone_tmp
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,29 @@ Bottom level categories:
- `tan`
- `tanh`

## v0.19.3 (2024-03-01)

### Major Changes

#### Vendored WebGPU Bindings from `web_sys`

**`--cfg=web_sys_unstable_apis` is no longer needed in your `RUSTFLAGS` to compile for WebGPU!!!**

While WebGPU's javascript api is stable in the browsers, the `web_sys` bindings for WebGPU are still improving. As such they are hidden behind the special cfg `--cfg=web_sys_unstable_apis` and are not available by default. Everyone who wanted to use our WebGPU backend needed to enable this cfg in their `RUSTFLAGS`. This was very inconvenient and made it hard to use WebGPU, especially when WebGPU is enabled by default. Additionally, the unstable APIs don't adhere to semver, so there were repeated breakages.

To combat this problem we have decided to vendor the `web_sys` bindings for WebGPU within the crate. Notably we are not forking the bindings, merely vendoring, so any improvements we make to the bindings will be contributed directly to upstream `web_sys`.

By @cwfitzgerald in [#5325](https://github.com/gfx-rs/wgpu/pull/5325).

### Bug Fixes

#### General

- Fix an issue where command encoders weren't properly freed if an error occurred during command encoding. By @ErichDonGubler in [#5251](https://github.com/gfx-rs/wgpu/pull/5251).

#### Android
- Fix linking error when targeting android without `winit`. By @ashdnazg in [#5326](https://github.com/gfx-rs/wgpu/pull/5326).

## v0.19.2 (2024-02-29)

### Added/New Features
Expand Down
17 changes: 9 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ keywords = ["graphics"]
license = "MIT OR Apache-2.0"
homepage = "https://wgpu.rs/"
repository = "https://github.com/gfx-rs/wgpu"
version = "0.19.2"
version = "0.19.3"
authors = ["gfx-rs developers"]

[workspace.dependencies.wgc]
Expand Down
23 changes: 3 additions & 20 deletions tests/tests/bind_group_layout_dedup.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::num::NonZeroU64;

use wgpu_test::{
fail, gpu_test, FailureCase, GpuTestConfiguration, TestParameters, TestingContext,
};
use wgt::Backends;
use wgpu_test::{fail, gpu_test, GpuTestConfiguration, TestParameters, TestingContext};

const SHADER_SRC: &str = "
@group(0) @binding(0)
Expand Down Expand Up @@ -307,18 +304,10 @@ fn bgl_dedupe_derived(ctx: TestingContext) {
ctx.queue.submit(Some(encoder.finish()));
}

const DX12_VALIDATION_ERROR: &str = "The command allocator cannot be reset because a command list is currently being recorded with the allocator.";

#[gpu_test]
static SEPARATE_PROGRAMS_HAVE_INCOMPATIBLE_DERIVED_BGLS: GpuTestConfiguration =
GpuTestConfiguration::new()
.parameters(
TestParameters::default()
.test_features_limits()
.expect_fail(
FailureCase::backend(Backends::DX12).validation_error(DX12_VALIDATION_ERROR),
),
)
.parameters(TestParameters::default().test_features_limits())
.run_sync(separate_programs_have_incompatible_derived_bgls);

fn separate_programs_have_incompatible_derived_bgls(ctx: TestingContext) {
Expand Down Expand Up @@ -376,13 +365,7 @@ fn separate_programs_have_incompatible_derived_bgls(ctx: TestingContext) {
#[gpu_test]
static DERIVED_BGLS_INCOMPATIBLE_WITH_REGULAR_BGLS: GpuTestConfiguration =
GpuTestConfiguration::new()
.parameters(
TestParameters::default()
.test_features_limits()
.expect_fail(
FailureCase::backend(Backends::DX12).validation_error(DX12_VALIDATION_ERROR),
),
)
.parameters(TestParameters::default().test_features_limits())
.run_sync(derived_bgls_incompatible_with_regular_bgls);

fn derived_bgls_incompatible_with_regular_bgls(ctx: TestingContext) {
Expand Down
22 changes: 14 additions & 8 deletions tests/tests/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ static DROP_ENCODER: GpuTestConfiguration = GpuTestConfiguration::new().run_sync
drop(encoder);
});

// This test crashes on DX12 with the exception:
//
// ID3D12CommandAllocator::Reset: The command allocator cannot be reset because a
// command list is currently being recorded with the allocator. [ EXECUTION ERROR
// #543: COMMAND_ALLOCATOR_CANNOT_RESET]
//
// For now, we mark the test as failing on DX12.
#[gpu_test]
static DROP_QUEUE_BEFORE_CREATING_COMMAND_ENCODER: GpuTestConfiguration =
GpuTestConfiguration::new()
.parameters(TestParameters::default().expect_fail(FailureCase::always()))
.run_sync(|ctx| {
// Use the device after the queue is dropped. Currently this panics
// but it probably shouldn't
let device = ctx.device.clone();
drop(ctx);
let _encoder =
device.create_command_encoder(&wgpu::CommandEncoderDescriptor::default());
});

#[gpu_test]
static DROP_ENCODER_AFTER_ERROR: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(TestParameters::default().expect_fail(FailureCase::backend(wgpu::Backends::DX12)))
.parameters(TestParameters::default())
.run_sync(|ctx| {
let mut encoder = ctx
.device
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wgpu-core"
version = "0.19.2"
version = "0.19.3"
authors = ["gfx-rs developers"]
edition = "2021"
description = "WebGPU core logic on wgpu-hal"
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<A: HalApi> CommandEncoder<A> {
Ok(())
}

fn discard(&mut self) {
pub(crate) fn discard(&mut self) {
if self.is_open {
self.is_open = false;
unsafe { self.raw.discard_encoding() };
Expand Down Expand Up @@ -115,7 +115,7 @@ pub(crate) struct DestroyedBufferError(pub id::BufferId);
pub(crate) struct DestroyedTextureError(pub id::TextureId);

pub struct CommandBufferMutable<A: HalApi> {
encoder: CommandEncoder<A>,
pub(crate) encoder: CommandEncoder<A>,
status: CommandEncoderStatus,
pub(crate) trackers: Tracker<A>,
buffer_memory_init_actions: Vec<BufferInitTrackerAction<A>>,
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/device/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let hub = A::hub(self);

if let Some(cmd_buf) = hub.command_buffers.unregister(command_encoder_id) {
cmd_buf.data.lock().as_mut().unwrap().encoder.discard();

cmd_buf
.device
.untrack(&cmd_buf.data.lock().as_ref().unwrap().trackers);
Expand Down
3 changes: 2 additions & 1 deletion wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wgpu-hal"
version = "0.19.2"
version = "0.19.3"
authors = ["gfx-rs developers"]
edition = "2021"
description = "WebGPU hardware abstraction layer"
Expand Down Expand Up @@ -154,6 +154,7 @@ libc = "0.2"

[target.'cfg(target_os = "android")'.dependencies]
android_system_properties = "0.1.1"
ndk-sys = "0.5.0"

[dependencies.naga]
path = "../naga"
Expand Down
7 changes: 7 additions & 0 deletions wgpu-hal/src/dx12/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ impl super::Temp {
}
}

impl Drop for super::CommandEncoder {
fn drop(&mut self) {
use crate::CommandEncoder;
unsafe { self.discard_encoding() }
}
}

impl super::CommandEncoder {
unsafe fn begin_pass(&mut self, kind: super::PassKind, label: crate::Label) {
let list = self.list.as_ref().unwrap();
Expand Down
6 changes: 1 addition & 5 deletions wgpu-hal/src/dx12/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,7 @@ impl crate::Device<super::Api> for super::Device {
end_of_pass_timer_query: None,
})
}
unsafe fn destroy_command_encoder(&self, encoder: super::CommandEncoder) {
if let Some(list) = encoder.list {
list.close();
}
}
unsafe fn destroy_command_encoder(&self, _encoder: super::CommandEncoder) {}

unsafe fn create_bind_group_layout(
&self,
Expand Down
7 changes: 7 additions & 0 deletions wgpu-hal/src/gles/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ impl super::CommandBuffer {
}
}

impl Drop for super::CommandEncoder {
fn drop(&mut self) {
use crate::CommandEncoder;
unsafe { self.discard_encoding() }
}
}

impl super::CommandEncoder {
fn rebind_stencil_func(&mut self) {
fn make(s: &super::StencilSide, face: u32) -> C {
Expand Down
17 changes: 6 additions & 11 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ type WlEglWindowResizeFun = unsafe extern "system" fn(

type WlEglWindowDestroyFun = unsafe extern "system" fn(window: *const raw::c_void);

#[cfg(target_os = "android")]
extern "C" {
pub fn ANativeWindow_setBuffersGeometry(
window: *mut raw::c_void,
width: i32,
height: i32,
format: i32,
) -> i32;
}

type EglLabel = *const raw::c_void;

#[allow(clippy::upper_case_acronyms)]
Expand Down Expand Up @@ -863,7 +853,12 @@ impl crate::Instance<super::Api> for Instance {
.unwrap();

let ret = unsafe {
ANativeWindow_setBuffersGeometry(handle.a_native_window.as_ptr(), 0, 0, format)
ndk_sys::ANativeWindow_setBuffersGeometry(
handle.a_native_window.as_ptr() as *mut ndk_sys::ANativeWindow,
0,
0,
format,
)
};

if ret != 0 {
Expand Down
Loading
Loading