Skip to content

Commit

Permalink
Merge remote-tracking branch 'trunk/trunk' into new-get-vertex
Browse files Browse the repository at this point in the history
# Conflicts:
#	wgpu-hal/src/vulkan/adapter.rs
#	wgpu-types/src/features.rs
  • Loading branch information
Vecvec committed Mar 4, 2025
2 parents dbf8ea9 + a6109bf commit c74216c
Show file tree
Hide file tree
Showing 119 changed files with 1,252 additions and 297 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ jobs:
run: taplo format --check --diff

- name: Check for typos
uses: crate-ci/typos@v1.29.9
uses: crate-ci/typos@v1.30.0

check-cts-runner:
# runtime is normally 2 minutes
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ By @jamienicol in [#6929](https://github.com/gfx-rs/wgpu/pull/6929) and [#7080](
### New Features
- Added mesh shader support to `wgpu_hal`. By @SupaMaggie70Incorporated in [#7089](https://github.com/gfx-rs/wgpu/pull/7089)
#### General
- It is now possible to create a dummy `wgpu` device even when no GPU is available. This may be useful for testing of code which manages graphics resources. Currently, it supports reading and writing buffers, and other resource types can be created but do nothing.
Expand Down Expand Up @@ -182,6 +184,10 @@ Refactored some functions to handle the internal trace path as a string to avoid
By @brodycj in [#6924](https://github.com/gfx-rs/wgpu/pull/6924).
#### Naga
- Refactored `use` statements to simplify future `no_std` support. By @bushrat011899 in [#7256](https://github.com/gfx-rs/wgpu/pull/7256)
#### Vulkan
##### HAL queue callback support
Expand Down
5 changes: 5 additions & 0 deletions naga/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,8 @@ serde = { workspace = true, features = ["default", "derive"] }
spirv = { version = "0.3", features = ["deserialize"] }
toml = "0.8"
walkdir.workspace = true

[lints.clippy]
std_instead_of_alloc = "warn"
std_instead_of_core = "warn"
alloc_instead_of_core = "warn"
4 changes: 2 additions & 2 deletions naga/src/arena/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! [`Arena`]: super::Arena
//! [`UniqueArena`]: super::UniqueArena
use std::{cmp::Ordering, fmt, hash, marker::PhantomData};
use core::{cmp::Ordering, fmt, hash, marker::PhantomData};

/// An unique index in the arena array that a handle points to.
/// The "non-max" part ensures that an `Option<Handle<T>>` has
Expand All @@ -22,7 +22,7 @@ pub struct BadHandle {
impl BadHandle {
pub fn new<T>(handle: Handle<T>) -> Self {
Self {
kind: std::any::type_name::<T>(),
kind: core::any::type_name::<T>(),
index: handle.index(),
}
}
Expand Down
8 changes: 4 additions & 4 deletions naga/src/arena/handle_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct HandleSet<T> {
members: bit_set::BitSet,

/// This type is indexed by values of type `T`.
as_keys: std::marker::PhantomData<T>,
as_keys: core::marker::PhantomData<T>,
}

impl<T> HandleSet<T> {
Expand All @@ -21,7 +21,7 @@ impl<T> HandleSet<T> {
Self {
len: 0,
members: bit_set::BitSet::new(),
as_keys: std::marker::PhantomData,
as_keys: core::marker::PhantomData,
}
}

Expand All @@ -35,7 +35,7 @@ impl<T> HandleSet<T> {
Self {
len,
members: bit_set::BitSet::with_capacity(len),
as_keys: std::marker::PhantomData,
as_keys: core::marker::PhantomData,
}
}

Expand Down Expand Up @@ -103,7 +103,7 @@ impl<T> ArenaType<T> for Arena<T> {
}
}

impl<T: std::hash::Hash + Eq> ArenaType<T> for UniqueArena<T> {
impl<T: core::hash::Hash + Eq> ArenaType<T> for UniqueArena<T> {
fn len(&self) -> usize {
self.len()
}
Expand Down
9 changes: 5 additions & 4 deletions naga/src/arena/handlevec.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//! The [`HandleVec`] type and associated definitions.
use super::handle::Handle;
use alloc::{vec, vec::Vec};

use std::marker::PhantomData;
use std::ops;
use core::marker::PhantomData;
use core::ops;

/// A [`Vec`] indexed by [`Handle`]s.
///
Expand All @@ -17,7 +18,7 @@ use std::ops;
/// current length; otherwise, the insertion will panic.
///
/// [`insert`]: HandleVec::insert
/// [`HashMap::insert`]: std::collections::HashMap::insert
/// [`HashMap::insert`]: hashbrown::HashMap::insert
#[derive(Debug)]
pub(crate) struct HandleVec<T, U> {
inner: Vec<U>,
Expand Down Expand Up @@ -59,7 +60,7 @@ impl<T, U> HandleVec<T, U> {
/// the end, like [`Vec::push`]. So the index of `handle` must equal
/// [`self.len()`].
///
/// [`HashMap`]: std::collections::HashMap
/// [`HashMap`]: hashbrown::HashMap
/// [`self.len()`]: HandleVec::len
pub(crate) fn insert(&mut self, handle: Handle<T>, value: U) {
assert_eq!(handle.index(), self.inner.len());
Expand Down
9 changes: 5 additions & 4 deletions naga/src/arena/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ pub(crate) use handlevec::HandleVec;
pub use range::{BadRangeError, Range};
pub use unique_arena::UniqueArena;

use alloc::vec::Vec;
use core::{fmt, ops};

use crate::Span;

use handle::Index;

use std::{fmt, ops};

/// An arena holding some kind of component (e.g., type, constant,
/// instruction, etc.) that can be referenced.
///
Expand Down Expand Up @@ -103,7 +104,7 @@ impl<T> Arena<T> {

/// Drains the arena, returning an iterator over the items stored.
pub fn drain(&mut self) -> impl DoubleEndedIterator<Item = (Handle<T>, T, Span)> {
let arena = std::mem::take(self);
let arena = core::mem::take(self);
arena
.data
.into_iter()
Expand Down Expand Up @@ -258,7 +259,7 @@ where
D: serde::Deserializer<'de>,
{
let data = Vec::deserialize(deserializer)?;
let span_info = std::iter::repeat(Span::default())
let span_info = core::iter::repeat(Span::default())
.take(data.len())
.collect();

Expand Down
6 changes: 3 additions & 3 deletions naga/src/arena/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
//!
//! [`Arena`]: super::Arena
use core::{fmt, marker::PhantomData, ops};

use super::{
handle::{Handle, Index},
Arena,
};

use std::{fmt, marker::PhantomData, ops};

/// A strongly typed range of handles.
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
Expand Down Expand Up @@ -51,7 +51,7 @@ pub struct BadRangeError {
impl BadRangeError {
pub fn new<T>(range: Range<T>) -> Self {
Self {
kind: std::any::type_name::<T>(),
kind: core::any::type_name::<T>(),
range: range.erase_type(),
}
}
Expand Down
12 changes: 7 additions & 5 deletions naga/src/arena/unique_arena.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! The [`UniqueArena`] type and supporting definitions.
use crate::{FastIndexSet, Span};
use alloc::vec::Vec;
use core::{fmt, hash, ops};

use super::handle::{BadHandle, Handle, Index};

use std::{fmt, hash, ops};
use crate::{FastIndexSet, Span};

/// An arena whose elements are guaranteed to be unique.
///
Expand Down Expand Up @@ -84,7 +84,7 @@ impl<T> UniqueArena<T> {
#[cfg(feature = "compact")]
pub struct UniqueArenaDrain<'a, T> {
inner_elts: indexmap::set::Drain<'a, T>,
inner_spans: std::vec::Drain<'a, Span>,
inner_spans: alloc::vec::Drain<'a, Span>,
index: Index,
}

Expand Down Expand Up @@ -224,7 +224,9 @@ where
D: serde::Deserializer<'de>,
{
let set = FastIndexSet::deserialize(deserializer)?;
let span_info = std::iter::repeat(Span::default()).take(set.len()).collect();
let span_info = core::iter::repeat(Span::default())
.take(set.len())
.collect();

Ok(Self { set, span_info })
}
Expand Down
3 changes: 2 additions & 1 deletion naga/src/back/continue_forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@
//! [`Switch`]: crate::Statement::Switch
//! [`SwitchCase`]: crate::SwitchCase
use alloc::{rc::Rc, string::String, vec::Vec};

use crate::proc::Namer;
use std::rc::Rc;

/// A summary of the code surrounding a statement.
enum Nesting {
Expand Down
31 changes: 17 additions & 14 deletions naga/src/back/dot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ of IR inspection and debugging.
[dot]: https://graphviz.org/doc/info/lang.html
*/

use alloc::{
borrow::Cow,
format,
string::{String, ToString},
vec::Vec,
};
use core::fmt::{Error as FmtError, Write as _};

use crate::{
arena::Handle,
valid::{FunctionInfo, ModuleInfo},
};

use std::{
borrow::Cow,
fmt::{Error as FmtError, Write as _},
};

/// Configuration options for the dot backend
#[derive(Clone, Default)]
pub struct Options {
Expand Down Expand Up @@ -412,26 +415,26 @@ const COLORS: &[&str] = &[

struct Prefixed<T>(Handle<T>);

impl std::fmt::Display for Prefixed<crate::Expression> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl core::fmt::Display for Prefixed<crate::Expression> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.0.write_prefixed(f, "e")
}
}

impl std::fmt::Display for Prefixed<crate::LocalVariable> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl core::fmt::Display for Prefixed<crate::LocalVariable> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.0.write_prefixed(f, "l")
}
}

impl std::fmt::Display for Prefixed<crate::GlobalVariable> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl core::fmt::Display for Prefixed<crate::GlobalVariable> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.0.write_prefixed(f, "g")
}
}

impl std::fmt::Display for Prefixed<crate::Function> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl core::fmt::Display for Prefixed<crate::Function> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.0.write_prefixed(f, "f")
}
}
Expand Down Expand Up @@ -798,7 +801,7 @@ pub fn write(
mod_info: Option<&ModuleInfo>,
options: Options,
) -> Result<String, FmtError> {
use std::fmt::Write as _;
use core::fmt::Write as _;

let mut output = String::new();
output += "digraph Module {\n";
Expand Down
7 changes: 4 additions & 3 deletions naga/src/back/glsl/features.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use core::fmt::Write;

use super::{BackendResult, Error, Version, Writer};
use crate::{
back::glsl::{Options, WriterFlags},
AddressSpace, Binding, Expression, Handle, ImageClass, ImageDimension, Interpolation,
SampleLevel, Sampling, Scalar, ScalarKind, ShaderStage, StorageFormat, Type, TypeInner,
};
use std::fmt::Write;

bitflags::bitflags! {
/// Structure used to encode additions to GLSL that aren't supported by all versions.
Expand Down Expand Up @@ -462,7 +463,7 @@ impl<W> Writer<'_, W> {
.functions
.iter()
.map(|(h, f)| (&f.expressions, &info[h]))
.chain(std::iter::once((
.chain(core::iter::once((
&entry_point.function.expressions,
info.get_entry_point(entry_point_idx as usize),
)))
Expand Down Expand Up @@ -559,7 +560,7 @@ impl<W> Writer<'_, W> {
.functions
.iter()
.map(|(_, f)| &f.body)
.chain(std::iter::once(&entry_point.function.body))
.chain(core::iter::once(&entry_point.function.body))
{
for (stmt, _) in blocks.span_iter() {
match *stmt {
Expand Down
29 changes: 19 additions & 10 deletions naga/src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,29 @@ to output a [`Module`](crate::Module) into glsl

pub use features::Features;

use crate::{
back::{self, Baked},
proc::{self, ExpressionKindTracker, NameKey},
valid, Handle, ShaderStage, TypeInner,
use alloc::{
borrow::ToOwned,
format,
string::{String, ToString},
vec,
vec::Vec,
};
use features::FeaturesManager;
use hashbrown::hash_map;
use std::{
use core::{
cmp::Ordering,
fmt::{self, Error as FmtError, Write},
mem,
};

use hashbrown::hash_map;
use thiserror::Error;

use crate::{
back::{self, Baked},
proc::{self, ExpressionKindTracker, NameKey},
valid, Handle, ShaderStage, TypeInner,
};
use features::FeaturesManager;

/// Contains the features related code and the features querying method
mod features;
/// Contains a constant with a slice of all the reserved keywords RESERVED_KEYWORDS
Expand Down Expand Up @@ -102,7 +111,7 @@ where
}

/// Mapping between resources and bindings.
pub type BindingMap = std::collections::BTreeMap<crate::ResourceBinding, u8>;
pub type BindingMap = alloc::collections::BTreeMap<crate::ResourceBinding, u8>;

impl crate::AtomicFunction {
const fn to_glsl(self) -> &'static str {
Expand Down Expand Up @@ -320,7 +329,7 @@ pub struct PipelineOptions {
/// If no entry point that matches is found while creating a [`Writer`], a error will be thrown.
pub entry_point: String,
/// How many views to render to, if doing multiview rendering.
pub multiview: Option<std::num::NonZeroU32>,
pub multiview: Option<core::num::NonZeroU32>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -582,7 +591,7 @@ pub struct Writer<'a, W> {
/// transformed to `do {} while(false);` loops.
continue_ctx: back::continue_forward::ContinueCtx,
/// How many views to render to, if doing multiview rendering.
multiview: Option<std::num::NonZeroU32>,
multiview: Option<core::num::NonZeroU32>,
/// Mapping of varying variables to their location. Needed for reflections.
varying: crate::FastHashMap<String, VaryingLocation>,
}
Expand Down
Loading

0 comments on commit c74216c

Please sign in to comment.