Skip to content

Bump MSRV of wgpu-hal and wgpu-core, then use error_in_core. #7232

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

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ env:
REPO_MSRV: "1.85"
# This is the MSRV used by the `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates,
# to ensure that they can be used with firefox.
CORE_MSRV: "1.76"
CORE_MSRV: "1.81"

#
# Environment variables
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0"
# copy the crates it actually uses out of the workspace, so it's meaningful for
# them to have less restrictive MSRVs individually than the workspace as a
# whole, if their code permits. See `../README.md` for details.
rust-version = "1.76"
rust-version = "1.81"

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl fmt::Display for DeviceMismatch {
}
}

impl std::error::Error for DeviceMismatch {}
impl core::error::Error for DeviceMismatch {}

#[derive(Clone, Debug, Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
3 changes: 1 addition & 2 deletions wgpu-core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use alloc::{boxed::Box, string::String, sync::Arc, vec::Vec};
use core::fmt;
use std::error::Error; // TODO(https://github.com/gfx-rs/wgpu/issues/6826): use core::error after MSRV bump
use core::{error::Error, fmt};

use thiserror::Error;

Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0"
# copy the crates it actually uses out of the workspace, so it's meaningful for
# them to have less restrictive MSRVs individually than the workspace as a
# whole, if their code permits. See `../README.md` for details.
rust-version = "1.76"
rust-version = "1.81"

[package.metadata.docs.rs]
# Ideally we would enable all the features.
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/src/auxil/renderdoc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! RenderDoc integration - <https://renderdoc.org/>
#![cfg_attr(not(any(feature = "gles", feature = "vulkan")), allow(dead_code))]

use alloc::format;
use alloc::string::String;
use core::{ffi, ptr};

Expand Down
7 changes: 3 additions & 4 deletions wgpu-hal/src/gles/wgl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,13 @@ impl crate::Instance for Instance {
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
profiling::scope!("Init OpenGL (WGL) Backend");
let opengl_module =
unsafe { LibraryLoader::LoadLibraryA(PCSTR("opengl32.dll\0".as_ptr())) }.map_err(
|e| {
unsafe { LibraryLoader::LoadLibraryA(PCSTR(c"opengl32.dll".as_ptr().cast())) }
.map_err(|e| {
crate::InstanceError::with_source(
String::from("unable to load the OpenGL library"),
e,
)
},
)?;
})?;

let device = create_instance_device()?;
let dc = device.dc;
Expand Down
7 changes: 4 additions & 3 deletions wgpu-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,9 @@

extern crate alloc;
extern crate wgpu_types as wgt;
// TODO(https://github.com/gfx-rs/wgpu/issues/6826): disable std except on noop and gles-WebGL.
// Requires Rust 1.81 for core::error::Error.
// Each of these backends needs `std` in some fashion; usually `std::thread` functions.
// TODO(https://github.com/gfx-rs/wgpu/issues/6826): gles-WebGL backend should be made no-std
#[cfg(any(dx12, gles, metal, vulkan))]
#[macro_use]
extern crate std;

Expand Down Expand Up @@ -290,12 +291,12 @@ use alloc::boxed::Box;
use alloc::{borrow::Cow, string::String, sync::Arc, vec::Vec};
use core::{
borrow::Borrow,
error::Error,
fmt,
num::NonZeroU32,
ops::{Range, RangeInclusive},
ptr::NonNull,
};
use std::error::Error; // TODO(https://github.com/gfx-rs/wgpu/issues/6826): use core::error after MSRV bump

use bitflags::bitflags;
use parking_lot::Mutex;
Expand Down
4 changes: 2 additions & 2 deletions wgpu-hal/src/metal/layer_observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const NSKeyValueObservingOptionNew: usize = 0x01;
#[allow(non_upper_case_globals)]
const NSKeyValueObservingOptionInitial: usize = 0x04;

const CONTENTS_SCALE: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"contentsScale\0") };
const BOUNDS: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"bounds\0") };
const CONTENTS_SCALE: &CStr = c"contentsScale";
const BOUNDS: &CStr = c"bounds";

/// Create a new custom layer that tracks parameters from the given super layer.
///
Expand Down
15 changes: 5 additions & 10 deletions wgpu-hal/src/vulkan/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ unsafe extern "system" fn debug_utils_messenger_callback(
// https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/5671
// Versions 1.3.240 through 1.3.250 return a spurious error here if
// the debug range start and end appear in different command buffers.
const KHRONOS_VALIDATION_LAYER: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"Khronos Validation Layer\0") };
if let Some(layer_properties) = user_data.validation_layer_properties.as_ref() {
if layer_properties.layer_description.as_ref() == KHRONOS_VALIDATION_LAYER
if layer_properties.layer_description.as_ref() == c"Khronos Validation Layer"
&& layer_properties.layer_spec_version >= vk::make_api_version(0, 1, 3, 240)
&& layer_properties.layer_spec_version <= vk::make_api_version(0, 1, 3, 250)
{
Expand Down Expand Up @@ -611,7 +609,7 @@ impl crate::Instance for super::Instance {
let app_info = vk::ApplicationInfo::default()
.application_name(app_name.as_c_str())
.application_version(1)
.engine_name(CStr::from_bytes_with_nul(b"wgpu-hal\0").unwrap())
.engine_name(c"wgpu-hal")
.engine_version(2)
.api_version(
// Vulkan 1.0 doesn't like anything but 1.0 passed in here...
Expand Down Expand Up @@ -653,8 +651,7 @@ impl crate::Instance for super::Instance {
.find(|inst_layer| inst_layer.layer_name_as_c_str() == Ok(name))
}

let validation_layer_name =
CStr::from_bytes_with_nul(b"VK_LAYER_KHRONOS_validation\0").unwrap();
let validation_layer_name = c"VK_LAYER_KHRONOS_validation";
let validation_layer_properties = find_layer(&instance_layers, validation_layer_name);

// Determine if VK_EXT_validation_features is available, so we can enable
Expand All @@ -678,11 +675,9 @@ impl crate::Instance for super::Instance {
.intersects(wgt::InstanceFlags::GPU_BASED_VALIDATION)
&& validation_features_are_enabled;

let nv_optimus_layer = CStr::from_bytes_with_nul(b"VK_LAYER_NV_optimus\0").unwrap();
let has_nv_optimus = find_layer(&instance_layers, nv_optimus_layer).is_some();
let has_nv_optimus = find_layer(&instance_layers, c"VK_LAYER_NV_optimus").is_some();

let obs_layer = CStr::from_bytes_with_nul(b"VK_LAYER_OBS_HOOK\0").unwrap();
let has_obs_layer = find_layer(&instance_layers, obs_layer).is_some();
let has_obs_layer = find_layer(&instance_layers, c"VK_LAYER_OBS_HOOK").is_some();

let mut layers: Vec<&'static CStr> = Vec::new();

Expand Down
3 changes: 1 addition & 2 deletions wgpu/src/api/surface.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use alloc::{boxed::Box, string::String, vec, vec::Vec};
use core::fmt;
use std::error; // TODO(https://github.com/gfx-rs/wgpu/issues/6826): use core::error after MSRV bump
use core::{error, fmt};

use parking_lot::Mutex;
use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
Expand Down
3 changes: 1 addition & 2 deletions wgpu/src/api/surface_texture.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use core::fmt;
use std::error; // TODO(https://github.com/gfx-rs/wgpu/issues/6826): use core::error after MSRV bump
use core::{error, fmt};
use std::thread;

use crate::*;
Expand Down
Loading