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

Migrate to Rust 1.65 #3184

Merged
merged 10 commits into from
Nov 8, 2022
1 change: 1 addition & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
large-error-threshold = 225 # bytes
24 changes: 13 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
RUST_BACKTRACE: 1
RUST_VERSION: 1.64
RUST_VERSION: 1.65
PKG_CONFIG_ALLOW_CROSS: 1 # allow android to work
RUSTFLAGS: --cfg=web_sys_unstable_apis -D warnings
RUSTDOCFLAGS: -Dwarnings
Expand All @@ -23,7 +23,7 @@ env:
# entirely on clippy jobs and reduce it to line-numbers
# only for ones where we run tests.
#
# Additionally, we disable incremental builds entirely
# Additionally, we disable incremental builds entirely
# as our caching system doesn't actually cache our crates.
# It adds overhead to the build and another point of failure.

Expand All @@ -38,7 +38,7 @@ jobs:
os: windows-2022
target: x86_64-pc-windows-msvc
kind: native

# MacOS
- name: MacOS x86_64
os: macos-12
Expand All @@ -49,7 +49,7 @@ jobs:
os: macos-12
target: aarch64-apple-darwin
kind: native

# IOS
- name: IOS aarch64
os: macos-12
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
- name: Linux x86_64
os: ubuntu-22.04
backends: vulkan gl

name: Test ${{ matrix.name }}
runs-on: ${{ matrix.os }}

Expand All @@ -195,24 +195,24 @@ jobs:
uses: taiki-e/install-action@nextest
- name: install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: install swiftshader
if: matrix.os == 'ubuntu-22.04'
shell: bash
run: |
set -e

mkdir -p swiftshader
curl -LsSf https://github.com/gfx-rs/ci-build/releases/latest/download/swiftshader-linux-x86_64.tar.xz | tar -xf - -C swiftshader

echo "LD_LIBRARY_PATH=$PWD/swiftshader" >> $GITHUB_ENV

- name: install llvmpipe, vulkan sdk
if: matrix.os == 'ubuntu-22.04'
shell: bash
run: |
set -e

sudo apt-get update -y -qq

# vulkan sdk
Expand Down Expand Up @@ -264,7 +264,7 @@ jobs:
uses: codecov/codecov-action@v3
with:
files: lcov.info

doctest:
name: Doctest
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -327,11 +327,13 @@ jobs:
- name: checkout repo
uses: actions/checkout@v3

- name: install rust
- name: install rust ${{ env.RUST_VERSION }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
override: true
components: clippy

- name: disable debug
shell: bash
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/cts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

env:
RUST_BACKTRACE: 1
RUST_VERSION: 1.65

jobs:
cts:
Expand Down Expand Up @@ -46,12 +47,13 @@ jobs:
cd cts
git checkout $(cat ../wgpu/cts_runner/revision.txt)

- name: install rust
- name: install rust ${{ env.RUST_VERSION }}
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.target }}
profile: minimal
override: true

- name: caching
uses: Swatinem/rust-cache@v1
Expand Down Expand Up @@ -91,4 +93,4 @@ jobs:
echo "=== Running $test ===";
DENO_WEBGPU_BACKEND=$backend cargo run --manifest-path ../wgpu/cts_runner/Cargo.toml --frozen -- ./tools/run_deno --verbose "$test";
done
done
done
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Bottom level categories:

### Testing/Internal

- Update the `minimum supported rust version` to 1.62
- Update the `minimum supported rust version` to 1.65
- Use cargo 1.64 workspace inheritance feature. By @jinleili in [#3107](https://github.com/gfx-rs/wgpu/pull/3107)

#### Vulkan
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default-members = ["wgpu", "wgpu-hal", "wgpu-info"]

[workspace.package]
edition = "2021"
rust-version = "1.64"
rust-version = "1.65"
keywords = ["graphics"]
license = "MIT OR Apache-2.0"
homepage = "https://wgpu.rs/"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ For an overview of all the components in the gfx-rs ecosystem, see [the big pict

### MSRV policy

Minimum Supported Rust Version is **1.64**.
Minimum Supported Rust Version is **1.65**.
It is enforced on CI (in "/.github/workflows/ci.yml") with `RUST_VERSION` variable.
This version can only be upgraded in breaking releases.

Expand Down Expand Up @@ -93,15 +93,15 @@ Note that the WGSL specification is still under development,
so the [draft specification][wgsl spec] does not exactly describe what `wgpu` supports.
See [below](#tracking-the-webgpu-and-wgsl-draft-specifications) for details.

To enable SPIR-V shaders, enable the `spirv` feature of wgpu.
To enable SPIR-V shaders, enable the `spirv` feature of wgpu.
To enable GLSL shaders, enable the `glsl` feature of wgpu.

### Angle

[Angle](http://angleproject.org) is a translation layer from GLES to other backends, developed by Google.
We support running our GLES3 backend over it in order to reach platforms with GLES2 or DX11 support, which aren't accessible otherwise.
In order to run with Angle, "angle" feature has to be enabled, and Angle libraries placed in a location visible to the application.
These binaries can be downloaded from [gfbuild-angle](https://github.com/DileSoft/gfbuild-angle) artifacts, [manual compilation](https://github.com/google/angle/blob/main/doc/DevSetup.md) may be required on Macs with Apple silicon.
These binaries can be downloaded from [gfbuild-angle](https://github.com/DileSoft/gfbuild-angle) artifacts, [manual compilation](https://github.com/google/angle/blob/main/doc/DevSetup.md) may be required on Macs with Apple silicon.

On Windows, you generally need to copy them into the working directory, in the same directory as the executable, or somewhere in your path.
On Linux, you can point to them using `LD_LIBRARY_PATH` environment.
Expand Down Expand Up @@ -204,7 +204,7 @@ Exactly which WGSL features `wgpu` supports depends on how you are using it:
for catching up to the WGSL specification,
but in general there is no up-to-date summary
of the differences between Naga and the WGSL spec.

- When running in a web browser (by compilation to WebAssembly)
without the `"webgl"` feature enabled,
`wgpu` relies on the browser's own WebGPU implementation.
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5147,7 +5147,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.composite_alpha_modes
.contains(&config.composite_alpha_mode)
{
let new_alpha_mode = 'b: loop {
let new_alpha_mode = 'alpha: loop {
// Automatic alpha mode checks.
let fallbacks = match config.composite_alpha_mode {
wgt::CompositeAlphaMode::Auto => &[
Expand All @@ -5164,7 +5164,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {

for &fallback in fallbacks {
if caps.composite_alpha_modes.contains(&fallback) {
break 'b fallback;
break 'alpha fallback;
}
}

Expand Down
12 changes: 6 additions & 6 deletions wgpu-core/src/hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let mut surface_guard = self.surfaces.data.write();
let hub = A::hub(self);
// this is used for tests, which keep the adapter
hub.clear(&mut *surface_guard, false);
hub.clear(&mut surface_guard, false);
}

pub fn generate_report(&self) -> GlobalReport {
Expand Down Expand Up @@ -1205,23 +1205,23 @@ impl<G: GlobalIdentityHandlerFactory> Drop for Global<G> {
// destroy hubs before the instance gets dropped
#[cfg(vulkan)]
{
self.hubs.vulkan.clear(&mut *surface_guard, true);
self.hubs.vulkan.clear(&mut surface_guard, true);
}
#[cfg(metal)]
{
self.hubs.metal.clear(&mut *surface_guard, true);
self.hubs.metal.clear(&mut surface_guard, true);
}
#[cfg(dx12)]
{
self.hubs.dx12.clear(&mut *surface_guard, true);
self.hubs.dx12.clear(&mut surface_guard, true);
}
#[cfg(dx11)]
{
self.hubs.dx11.clear(&mut *surface_guard, true);
self.hubs.dx11.clear(&mut surface_guard, true);
}
#[cfg(gl)]
{
self.hubs.gl.clear(&mut *surface_guard, true);
self.hubs.gl.clear(&mut surface_guard, true);
}

// destroy surfaces
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/examples/raw-gles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn main() {
*control_flow = ControlFlow::Wait;

match event {
Event::LoopDestroyed => return,
Event::LoopDestroyed => (),
Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested
| WindowEvent::KeyboardInput {
Expand Down
9 changes: 6 additions & 3 deletions wgpu-hal/src/dx12/conv.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use std::iter;
use winapi::um::{d3d12, d3dcommon};
use winapi::{
shared::minwindef::BOOL,
um::{d3d12, d3dcommon},
};

pub fn map_buffer_usage_to_resource_flags(usage: crate::BufferUses) -> d3d12::D3D12_RESOURCE_FLAGS {
let mut flags = 0;
Expand Down Expand Up @@ -329,14 +332,14 @@ fn map_stencil_face(face: &wgt::StencilFaceState) -> d3d12::D3D12_DEPTH_STENCILO

pub fn map_depth_stencil(ds: &wgt::DepthStencilState) -> d3d12::D3D12_DEPTH_STENCIL_DESC {
d3d12::D3D12_DEPTH_STENCIL_DESC {
DepthEnable: if ds.is_depth_enabled() { 1 } else { 0 },
DepthEnable: BOOL::from(ds.is_depth_enabled()),
DepthWriteMask: if ds.depth_write_enabled {
d3d12::D3D12_DEPTH_WRITE_MASK_ALL
} else {
d3d12::D3D12_DEPTH_WRITE_MASK_ZERO
},
DepthFunc: map_comparison(ds.depth_compare),
StencilEnable: if ds.stencil.is_enabled() { 1 } else { 0 },
StencilEnable: BOOL::from(ds.stencil.is_enabled()),
StencilReadMask: ds.stencil.read_mask as u8,
StencilWriteMask: ds.stencil.write_mask as u8,
FrontFace: map_stencil_face(&ds.stencil.front),
Expand Down
16 changes: 6 additions & 10 deletions wgpu-hal/src/dx12/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::{conv, descriptor, view};
use parking_lot::Mutex;
use std::{ffi, mem, num::NonZeroU32, ptr, slice, sync::Arc};
use winapi::{
shared::{dxgiformat, dxgitype, winerror},
shared::{dxgiformat, dxgitype, minwindef::BOOL, winerror},
um::{d3d12, d3dcompiler, synchapi, winbase},
Interface,
};
Expand Down Expand Up @@ -1231,7 +1231,7 @@ impl crate::Device<super::Api> for super::Device {
Some(inner) => {
let dual = descriptor::upload(
self.raw,
&*inner,
&inner,
&self.shared.heap_views,
&desc.layout.copy_counts,
)?;
Expand All @@ -1243,7 +1243,7 @@ impl crate::Device<super::Api> for super::Device {
Some(inner) => {
let dual = descriptor::upload(
self.raw,
&*inner,
&inner,
&self.shared.heap_samplers,
&desc.layout.copy_counts,
)?;
Expand Down Expand Up @@ -1358,8 +1358,8 @@ impl crate::Device<super::Api> for super::Device {
DepthBias: bias.constant,
DepthBiasClamp: bias.clamp,
SlopeScaledDepthBias: bias.slope_scale,
DepthClipEnable: if desc.primitive.unclipped_depth { 0 } else { 1 },
MultisampleEnable: if desc.multisample.count > 1 { 1 } else { 0 },
DepthClipEnable: BOOL::from(!desc.primitive.unclipped_depth),
MultisampleEnable: BOOL::from(desc.multisample.count > 1),
ForcedSampleCount: 0,
AntialiasedLineEnable: 0,
ConservativeRaster: if desc.primitive.conservative {
Expand Down Expand Up @@ -1388,11 +1388,7 @@ impl crate::Device<super::Api> for super::Device {
RasterizedStream: 0,
},
BlendState: d3d12::D3D12_BLEND_DESC {
AlphaToCoverageEnable: if desc.multisample.alpha_to_coverage_enabled {
1
} else {
0
},
AlphaToCoverageEnable: BOOL::from(desc.multisample.alpha_to_coverage_enabled),
IndependentBlendEnable: 1,
RenderTarget: conv::map_render_targets(desc.color_targets),
},
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ impl crate::Adapter<super::Api> for super::Adapter {
wgt::TextureFormat::Bgra8Unorm,
];
if surface.supports_srgb() {
formats.extend(&[
formats.extend([
wgt::TextureFormat::Rgba8UnormSrgb,
#[cfg(not(target_arch = "wasm32"))]
wgt::TextureFormat::Bgra8UnormSrgb,
Expand Down
14 changes: 5 additions & 9 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,17 +654,17 @@ impl crate::Instance<super::Api> for Instance {
client_ext_str.split_whitespace().collect::<Vec<_>>()
);

let wayland_library = if client_ext_str.contains(&"EGL_EXT_platform_wayland") {
let wayland_library = if client_ext_str.contains("EGL_EXT_platform_wayland") {
test_wayland_display()
} else {
None
};
let x11_display_library = if client_ext_str.contains(&"EGL_EXT_platform_x11") {
let x11_display_library = if client_ext_str.contains("EGL_EXT_platform_x11") {
open_x_display()
} else {
None
};
let angle_x11_display_library = if client_ext_str.contains(&"EGL_ANGLE_platform_angle") {
let angle_x11_display_library = if client_ext_str.contains("EGL_ANGLE_platform_angle") {
open_x_display()
} else {
None
Expand Down Expand Up @@ -702,11 +702,7 @@ impl crate::Instance<super::Api> for Instance {
EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE as egl::Attrib,
EGL_PLATFORM_X11_KHR as egl::Attrib,
EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED as egl::Attrib,
if desc.flags.contains(crate::InstanceFlags::VALIDATION) {
1
} else {
0
},
usize::from(desc.flags.contains(crate::InstanceFlags::VALIDATION)),
egl::ATTRIB_NONE,
];
let display = egl
Expand Down Expand Up @@ -735,7 +731,7 @@ impl crate::Instance<super::Api> for Instance {
};

if desc.flags.contains(crate::InstanceFlags::VALIDATION)
&& client_ext_str.contains(&"EGL_KHR_debug")
&& client_ext_str.contains("EGL_KHR_debug")
{
log::info!("Enabling EGL debug output");
let function: EglDebugMessageControlFun =
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/metal/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl crate::Surface<super::Api> for super::Surface {
let () = msg_send![*render_layer, setFrame: bounds];
}
}
render_layer.set_device(&*device_raw);
render_layer.set_device(&device_raw);
render_layer.set_pixel_format(self.raw_swapchain_format);
render_layer.set_framebuffer_only(framebuffer_only);
render_layer.set_presents_with_transaction(self.present_with_transaction);
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/vulkan/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ impl crate::Device<super::Api> for super::Device {
crate::ShaderInput::SpirV(spv) => Cow::Borrowed(spv),
};

let raw = self.create_shader_module_impl(&*spv)?;
let raw = self.create_shader_module_impl(&spv)?;

if let Some(label) = desc.label {
self.shared
Expand Down
Loading