mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Update Repo MSRV to 1.91 (#8678)
This commit is contained in:
parent
40b2d3041b
commit
a356cb2026
@ -1,4 +1,4 @@
|
||||
use std::{borrow::Cow, future::Future, iter, mem, pin::Pin, task};
|
||||
use std::{borrow::Cow, iter, mem};
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use glam::{Affine3A, Mat4, Quat, Vec3};
|
||||
@ -98,28 +98,6 @@ fn affine_to_rows(mat: &Affine3A) -> [f32; 12] {
|
||||
]
|
||||
}
|
||||
|
||||
/// A wrapper for `pop_error_scope` futures that panics if an error occurs.
|
||||
///
|
||||
/// Given a future `inner` of an `Option<E>` for some error type `E`,
|
||||
/// wait for the future to be ready, and panic if its value is `Some`.
|
||||
///
|
||||
/// This can be done simpler with `FutureExt`, but we don't want to add
|
||||
/// a dependency just for this small case.
|
||||
struct ErrorFuture<F> {
|
||||
inner: F,
|
||||
}
|
||||
impl<F: Future<Output = Option<wgpu::Error>>> Future for ErrorFuture<F> {
|
||||
type Output = ();
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> task::Poll<()> {
|
||||
let inner = unsafe { self.map_unchecked_mut(|me| &mut me.inner) };
|
||||
inner.poll(cx).map(|error| {
|
||||
if let Some(e) = error {
|
||||
panic!("Rendering {e}");
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct Example {
|
||||
rt_target: wgpu::Texture,
|
||||
#[expect(dead_code)]
|
||||
|
||||
@ -2,7 +2,7 @@ use crate::utils;
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use glam::{Mat4, Quat, Vec3};
|
||||
use std::ops::IndexMut;
|
||||
use std::{borrow::Cow, future::Future, iter, mem, pin::Pin, task};
|
||||
use std::{borrow::Cow, iter, mem};
|
||||
use wgpu::util::DeviceExt;
|
||||
|
||||
// from cube
|
||||
@ -73,28 +73,6 @@ struct Uniforms {
|
||||
proj_inverse: Mat4,
|
||||
}
|
||||
|
||||
/// A wrapper for `pop_error_scope` futures that panics if an error occurs.
|
||||
///
|
||||
/// Given a future `inner` of an `Option<E>` for some error type `E`,
|
||||
/// wait for the future to be ready, and panic if its value is `Some`.
|
||||
///
|
||||
/// This can be done simpler with `FutureExt`, but we don't want to add
|
||||
/// a dependency just for this small case.
|
||||
struct ErrorFuture<F> {
|
||||
inner: F,
|
||||
}
|
||||
impl<F: Future<Output = Option<wgpu::Error>>> Future for ErrorFuture<F> {
|
||||
type Output = ();
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> task::Poll<()> {
|
||||
let inner = unsafe { self.map_unchecked_mut(|me| &mut me.inner) };
|
||||
inner.poll(cx).map(|error| {
|
||||
if let Some(e) = error {
|
||||
panic!("Rendering {e}");
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct Example {
|
||||
uniforms: Uniforms,
|
||||
uniform_buf: wgpu::Buffer,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use std::{borrow::Cow, future::Future, iter, mem, pin::Pin, task};
|
||||
use std::{borrow::Cow, iter, mem};
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use glam::{Affine3A, Mat4, Quat, Vec3};
|
||||
@ -97,28 +97,6 @@ fn affine_to_rows(mat: &Affine3A) -> [f32; 12] {
|
||||
]
|
||||
}
|
||||
|
||||
/// A wrapper for `pop_error_scope` futures that panics if an error occurs.
|
||||
///
|
||||
/// Given a future `inner` of an `Option<E>` for some error type `E`,
|
||||
/// wait for the future to be ready, and panic if its value is `Some`.
|
||||
///
|
||||
/// This can be done simpler with `FutureExt`, but we don't want to add
|
||||
/// a dependency just for this small case.
|
||||
struct ErrorFuture<F> {
|
||||
inner: F,
|
||||
}
|
||||
impl<F: Future<Output = Option<wgpu::Error>>> Future for ErrorFuture<F> {
|
||||
type Output = ();
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> task::Poll<()> {
|
||||
let inner = unsafe { self.map_unchecked_mut(|me| &mut me.inner) };
|
||||
inner.poll(cx).map(|error| {
|
||||
if let Some(e) = error {
|
||||
panic!("Rendering {e}");
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct Example {
|
||||
rt_target: wgpu::Texture,
|
||||
tlas: wgpu::Tlas,
|
||||
|
||||
@ -3,7 +3,7 @@ use bytemuck::{Pod, Zeroable};
|
||||
use glam::{Mat4, Quat, Vec3};
|
||||
use std::f32::consts::PI;
|
||||
use std::ops::IndexMut;
|
||||
use std::{borrow::Cow, future::Future, iter, mem, ops::Range, pin::Pin, task};
|
||||
use std::{borrow::Cow, iter, mem, ops::Range};
|
||||
use wgpu::util::DeviceExt;
|
||||
|
||||
// from cube
|
||||
@ -25,28 +25,6 @@ struct Uniforms {
|
||||
proj_inverse: Mat4,
|
||||
}
|
||||
|
||||
/// A wrapper for `pop_error_scope` futures that panics if an error occurs.
|
||||
///
|
||||
/// Given a future `inner` of an `Option<E>` for some error type `E`,
|
||||
/// wait for the future to be ready, and panic if its value is `Some`.
|
||||
///
|
||||
/// This can be done simpler with `FutureExt`, but we don't want to add
|
||||
/// a dependency just for this small case.
|
||||
struct ErrorFuture<F> {
|
||||
inner: F,
|
||||
}
|
||||
impl<F: Future<Output = Option<wgpu::Error>>> Future for ErrorFuture<F> {
|
||||
type Output = ();
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> task::Poll<()> {
|
||||
let inner = unsafe { self.map_unchecked_mut(|me| &mut me.inner) };
|
||||
inner.poll(cx).map(|error| {
|
||||
if let Some(e) = error {
|
||||
panic!("Rendering {e}");
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
struct RawSceneComponents {
|
||||
vertices: Vec<Vertex>,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use std::{borrow::Cow, future::Future, iter, mem, pin::Pin, task};
|
||||
use std::{borrow::Cow, iter, mem};
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use glam::{Mat4, Vec3};
|
||||
@ -52,28 +52,6 @@ struct Uniforms {
|
||||
vertex: Mat4,
|
||||
}
|
||||
|
||||
/// A wrapper for `pop_error_scope` futures that panics if an error occurs.
|
||||
///
|
||||
/// Given a future `inner` of an `Option<E>` for some error type `E`,
|
||||
/// wait for the future to be ready, and panic if its value is `Some`.
|
||||
///
|
||||
/// This can be done simpler with `FutureExt`, but we don't want to add
|
||||
/// a dependency just for this small case.
|
||||
struct ErrorFuture<F> {
|
||||
inner: F,
|
||||
}
|
||||
impl<F: Future<Output = Option<wgpu::Error>>> Future for ErrorFuture<F> {
|
||||
type Output = ();
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> task::Poll<()> {
|
||||
let inner = unsafe { self.map_unchecked_mut(|me| &mut me.inner) };
|
||||
inner.poll(cx).map(|error| {
|
||||
if let Some(e) = error {
|
||||
panic!("Rendering {e}");
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct Example {
|
||||
uniforms: Uniforms,
|
||||
uniform_buf: wgpu::Buffer,
|
||||
|
||||
@ -494,7 +494,7 @@ impl crate::framework::Example for Example {
|
||||
module: &shader,
|
||||
entry_point: Some("vs_bake"),
|
||||
compilation_options: Default::default(),
|
||||
buffers: &[vb_desc.clone()],
|
||||
buffers: std::slice::from_ref(&vb_desc),
|
||||
},
|
||||
fragment: None,
|
||||
primitive: wgpu::PrimitiveState {
|
||||
|
||||
@ -215,6 +215,10 @@ impl FunctionCtx<'_> {
|
||||
external_texture_key,
|
||||
)
|
||||
}
|
||||
// This is a const function, which _sometimes_ gets called,
|
||||
// so this lint is _sometimes_ triggered, depending on feature set.
|
||||
#[expect(clippy::allow_attributes)]
|
||||
#[allow(clippy::panic)]
|
||||
FunctionType::EntryPoint(_) => {
|
||||
panic!("External textures cannot be used as arguments to entry points")
|
||||
}
|
||||
|
||||
@ -5,20 +5,15 @@ use serde::Deserialize;
|
||||
#[cfg(feature = "serialize")]
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
||||
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
|
||||
pub enum Coord {
|
||||
#[default]
|
||||
Normalized,
|
||||
Pixel,
|
||||
}
|
||||
|
||||
impl Default for Coord {
|
||||
fn default() -> Self {
|
||||
Self::Normalized
|
||||
}
|
||||
}
|
||||
|
||||
impl Coord {
|
||||
pub const fn as_str(&self) -> &'static str {
|
||||
match *self {
|
||||
@ -28,23 +23,18 @@ impl Coord {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
||||
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
|
||||
pub enum Address {
|
||||
Repeat,
|
||||
MirroredRepeat,
|
||||
#[default]
|
||||
ClampToEdge,
|
||||
ClampToZero,
|
||||
ClampToBorder,
|
||||
}
|
||||
|
||||
impl Default for Address {
|
||||
fn default() -> Self {
|
||||
Self::ClampToEdge
|
||||
}
|
||||
}
|
||||
|
||||
impl Address {
|
||||
pub const fn as_str(&self) -> &'static str {
|
||||
match *self {
|
||||
@ -57,21 +47,16 @@ impl Address {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
||||
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
|
||||
pub enum BorderColor {
|
||||
#[default]
|
||||
TransparentBlack,
|
||||
OpaqueBlack,
|
||||
OpaqueWhite,
|
||||
}
|
||||
|
||||
impl Default for BorderColor {
|
||||
fn default() -> Self {
|
||||
Self::TransparentBlack
|
||||
}
|
||||
}
|
||||
|
||||
impl BorderColor {
|
||||
pub const fn as_str(&self) -> &'static str {
|
||||
match *self {
|
||||
@ -82,10 +67,11 @@ impl BorderColor {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
||||
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
|
||||
pub enum Filter {
|
||||
#[default]
|
||||
Nearest,
|
||||
Linear,
|
||||
}
|
||||
@ -99,16 +85,11 @@ impl Filter {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Filter {
|
||||
fn default() -> Self {
|
||||
Self::Nearest
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
||||
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
|
||||
pub enum CompareFunc {
|
||||
#[default]
|
||||
Never,
|
||||
Less,
|
||||
LessEqual,
|
||||
@ -119,12 +100,6 @@ pub enum CompareFunc {
|
||||
Always,
|
||||
}
|
||||
|
||||
impl Default for CompareFunc {
|
||||
fn default() -> Self {
|
||||
Self::Never
|
||||
}
|
||||
}
|
||||
|
||||
impl CompareFunc {
|
||||
pub const fn as_str(&self) -> &'static str {
|
||||
match *self {
|
||||
|
||||
@ -34,7 +34,7 @@ pub(super) fn string_to_byte_chunks(input: &str, limit: usize) -> Vec<&[u8]> {
|
||||
let mut start: usize = 0;
|
||||
let mut words = vec![];
|
||||
while offset < input.len() {
|
||||
offset = input.floor_char_boundary(offset + limit);
|
||||
offset = input.floor_char_boundary_polyfill(offset + limit);
|
||||
// Clippy wants us to call as_bytes() first to avoid the UTF-8 check,
|
||||
// but we want to assert the output is valid UTF-8.
|
||||
#[allow(clippy::sliced_string_as_bytes)]
|
||||
@ -123,30 +123,31 @@ pub fn global_needs_wrapper(ir_module: &crate::Module, var: &crate::GlobalVariab
|
||||
}
|
||||
|
||||
///HACK: this is taken from std unstable, remove it when std's floor_char_boundary is stable
|
||||
/// and available in our msrv.
|
||||
trait U8Internal {
|
||||
fn is_utf8_char_boundary(&self) -> bool;
|
||||
fn is_utf8_char_boundary_polyfill(&self) -> bool;
|
||||
}
|
||||
|
||||
impl U8Internal for u8 {
|
||||
fn is_utf8_char_boundary(&self) -> bool {
|
||||
fn is_utf8_char_boundary_polyfill(&self) -> bool {
|
||||
// This is bit magic equivalent to: b < 128 || b >= 192
|
||||
(*self as i8) >= -0x40
|
||||
}
|
||||
}
|
||||
|
||||
trait StrUnstable {
|
||||
fn floor_char_boundary(&self, index: usize) -> usize;
|
||||
fn floor_char_boundary_polyfill(&self, index: usize) -> usize;
|
||||
}
|
||||
|
||||
impl StrUnstable for str {
|
||||
fn floor_char_boundary(&self, index: usize) -> usize {
|
||||
fn floor_char_boundary_polyfill(&self, index: usize) -> usize {
|
||||
if index >= self.len() {
|
||||
self.len()
|
||||
} else {
|
||||
let lower_bound = index.saturating_sub(3);
|
||||
let new_index = self.as_bytes()[lower_bound..=index]
|
||||
.iter()
|
||||
.rposition(|b| b.is_utf8_char_boundary());
|
||||
.rposition(|b| b.is_utf8_char_boundary_polyfill());
|
||||
|
||||
// SAFETY: we know that the character boundary will be within four bytes
|
||||
unsafe { lower_bound + new_index.unwrap_unchecked() }
|
||||
|
||||
@ -162,6 +162,10 @@ impl crate::proc::overloads::OverloadSet for List {
|
||||
}
|
||||
|
||||
const fn len_to_full_mask(n: usize) -> u64 {
|
||||
// This is a const function, which _sometimes_ gets called,
|
||||
// so this lint is _sometimes_ triggered, depending on feature set.
|
||||
#[expect(clippy::allow_attributes)]
|
||||
#[allow(clippy::panic)]
|
||||
if n >= 64 {
|
||||
panic!("List::rules can only hold up to 63 rules");
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@ impl Player {
|
||||
let spirv = data.iter().find_map(|a| {
|
||||
if a.ends_with(".spv") {
|
||||
let data = fs::read(dir.join(a)).unwrap();
|
||||
assert!(data.len() % 4 == 0);
|
||||
assert!(data.len().is_multiple_of(4));
|
||||
|
||||
Some(Cow::Owned(bytemuck::pod_collect_to_vec(&data)))
|
||||
} else {
|
||||
|
||||
@ -1110,9 +1110,7 @@ impl Global {
|
||||
}
|
||||
|
||||
let mut bind_group = None;
|
||||
if bind_group_id.is_some() {
|
||||
let bind_group_id = bind_group_id.unwrap();
|
||||
|
||||
if let Some(bind_group_id) = bind_group_id {
|
||||
let hub = &self.hub;
|
||||
bind_group = Some(pass_try!(
|
||||
base,
|
||||
|
||||
@ -3158,9 +3158,7 @@ impl Global {
|
||||
}
|
||||
|
||||
let mut bind_group = None;
|
||||
if bind_group_id.is_some() {
|
||||
let bind_group_id = bind_group_id.unwrap();
|
||||
|
||||
if let Some(bind_group_id) = bind_group_id {
|
||||
let hub = &self.hub;
|
||||
bind_group = Some(pass_try!(
|
||||
base,
|
||||
|
||||
@ -253,17 +253,12 @@ bitflags::bitflags! {
|
||||
|
||||
type BindTarget = u32;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
enum VertexAttribKind {
|
||||
#[default]
|
||||
Float, // glVertexAttribPointer
|
||||
Integer, // glVertexAttribIPointer
|
||||
//Double, // glVertexAttribLPointer
|
||||
}
|
||||
|
||||
impl Default for VertexAttribKind {
|
||||
fn default() -> Self {
|
||||
Self::Float
|
||||
}
|
||||
//Double, // glVertexAttribLPointer
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
@ -101,12 +101,13 @@ pub enum PresentMode {
|
||||
/// Specifies how the alpha channel of the textures should be handled during
|
||||
/// compositing.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
|
||||
pub enum CompositeAlphaMode {
|
||||
/// Chooses either `Opaque` or `Inherit` automatically,depending on the
|
||||
/// `alpha_mode` that the current surface can support.
|
||||
#[default]
|
||||
Auto = 0,
|
||||
/// The alpha channel, if it exists, of the textures is ignored in the
|
||||
/// compositing process. Instead, the textures is treated as if it has a
|
||||
@ -130,12 +131,6 @@ pub enum CompositeAlphaMode {
|
||||
Inherit = 4,
|
||||
}
|
||||
|
||||
impl Default for CompositeAlphaMode {
|
||||
fn default() -> Self {
|
||||
Self::Auto
|
||||
}
|
||||
}
|
||||
|
||||
/// Defines the capabilities of a given surface and adapter.
|
||||
#[derive(Debug)]
|
||||
pub struct SurfaceCapabilities {
|
||||
|
||||
@ -2605,11 +2605,11 @@ impl dispatch::QueueInterface for WebQueue {
|
||||
return None;
|
||||
}
|
||||
let write_size = u64::from(size);
|
||||
if write_size % wgt::COPY_BUFFER_ALIGNMENT != 0 {
|
||||
if !write_size.is_multiple_of(wgt::COPY_BUFFER_ALIGNMENT) {
|
||||
log::error!("Copy size {size} does not respect `COPY_BUFFER_ALIGNMENT`");
|
||||
return None;
|
||||
}
|
||||
if offset % wgt::COPY_BUFFER_ALIGNMENT != 0 {
|
||||
if !offset.is_multiple_of(wgt::COPY_BUFFER_ALIGNMENT) {
|
||||
log::error!(
|
||||
"Buffer offset {offset} is not aligned to block size or `COPY_BUFFER_ALIGNMENT`"
|
||||
);
|
||||
|
||||
@ -60,7 +60,7 @@ const fn assert_has_spirv_magic_number_and_length(bytes: &[u8]) -> bool {
|
||||
Some(needs_byte_swap) => {
|
||||
// Note: this assertion is relied upon for the soundness of `make_spirv_const()`.
|
||||
assert!(
|
||||
bytes.len() % size_of::<u32>() == 0,
|
||||
bytes.len().is_multiple_of(mem::size_of::<u32>()),
|
||||
"SPIR-V data must be a multiple of 4 bytes long"
|
||||
);
|
||||
|
||||
@ -75,6 +75,7 @@ const fn assert_has_spirv_magic_number_and_length(bytes: &[u8]) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "spirv"), expect(rustdoc::broken_intra_doc_links))]
|
||||
/// Version of [`make_spirv()`] intended for use with
|
||||
/// [`Device::create_shader_module_passthrough()`].
|
||||
///
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user