Skip to content
Merged
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 @@ -22,7 +22,7 @@ env:
REPO_MSRV: "1.92"
# 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.82.0"
CORE_MSRV: "1.90.0"

#
# Environment variables
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ Bottom level categories:
- Added support for no-perspective barycentric coordinates. By @atlv24 in [#8852](https://github.com/gfx-rs/wgpu/issues/8852).
- Added support for obtaining `AdapterInfo` from `Device`. By @sagudev in [#8807](https://github.com/gfx-rs/wgpu/pull/8807).
- Added `Limits::or_worse_values_from`. By @atlv24 in [#8870](https://github.com/gfx-rs/wgpu/pull/8870).
- Made the following available in `const` contexts:
- `naga`
- `Arena::len`
- `Arena::is_empty`
- `Range::first_and_last`
- `front::wgsl::Frontend::set_options`
- `ir::Block::is_empty`
- `ir::Block::len`

#### Naga

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ TL;DR: If you're using `wgpu`, our MSRV is **1.92**.

Due to complex dependants, we have two MSRV policies:

- `naga`, `wgpu-core`, `wgpu-hal`, and `wgpu-types`'s MSRV is **1.82**.
- `naga`, `wgpu-core`, `wgpu-hal`, and `wgpu-types`'s MSRV is **1.90**.
- The rest of the workspace has an MSRV of **1.92**.

It is enforced on CI (in "/.github/workflows/ci.yml") with the `CORE_MSRV` and `REPO_MSRV` variables.
Expand Down
10 changes: 4 additions & 6 deletions naga-cli/src/bin/naga.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![allow(clippy::manual_strip)]
use anyhow::{anyhow, Context as _};
#[allow(unused_imports)]
use std::fs;
use std::{error::Error, fmt, io::Read, path::Path, str::FromStr};

Expand Down Expand Up @@ -260,10 +258,10 @@ impl FromStr for GlslProfileArg {

fn from_str(s: &str) -> Result<Self, Self::Err> {
use naga::back::glsl::Version;
Ok(Self(if s.starts_with("core") {
Version::Desktop(s[4..].parse().unwrap_or(330))
} else if s.starts_with("es") {
Version::new_gles(s[2..].parse().unwrap_or(310))
Ok(Self(if let Some(s) = s.strip_prefix("core") {
Version::Desktop(s.parse().unwrap_or(330))
} else if let Some(s) = s.strip_prefix("es") {
Version::new_gles(s.parse().unwrap_or(310))
} else {
return Err(format!("Unknown profile: {s}"));
}))
Expand Down
2 changes: 1 addition & 1 deletion naga/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exclude = ["bin/**/*", "tests/**/*", "Cargo.lock", "target/**/*"]
# 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.82.0"
rust-version = "1.90.0"

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion naga/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Crates.io](https://img.shields.io/crates/v/naga.svg?label=naga)](https://crates.io/crates/naga)
[![Docs.rs](https://docs.rs/naga/badge.svg)](https://docs.rs/naga)
[![Build Status](https://github.com/gfx-rs/naga/workflows/pipeline/badge.svg)](https://github.com/gfx-rs/naga/actions)
![MSRV](https://img.shields.io/badge/rustc-1.82-blue.svg)
![MSRV](https://img.shields.io/badge/rustc-1.90-blue.svg)
[![codecov.io](https://codecov.io/gh/gfx-rs/naga/branch/master/graph/badge.svg?token=9VOKYO8BM2)](https://codecov.io/gh/gfx-rs/naga)

The shader translation library for the needs of [wgpu](https://github.com/gfx-rs/wgpu).
Expand Down
2 changes: 1 addition & 1 deletion naga/src/arena/handlevec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<T, U> HandleVec<T, U> {
}
}

pub(crate) fn len(&self) -> usize {
pub(crate) const fn len(&self) -> usize {
self.inner.len()
}

Expand Down
5 changes: 2 additions & 3 deletions naga/src/arena/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,17 @@ impl<T> Arena<T> {
}

/// Extracts the inner vector.
#[allow(clippy::missing_const_for_fn)] // ignore due to requirement of #![feature(const_precise_live_drops)]
pub fn into_inner(self) -> Vec<T> {
self.data
}

/// Returns the current number of items stored in this arena.
pub fn len(&self) -> usize {
pub const fn len(&self) -> usize {
self.data.len()
}

/// Returns `true` if the arena contains no elements.
pub fn is_empty(&self) -> bool {
pub const fn is_empty(&self) -> bool {
self.data.is_empty()
}

Expand Down
2 changes: 1 addition & 1 deletion naga/src/arena/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<T> Range<T> {
///
/// If `self` is an empty range, there are no handles included, so
/// return `None`.
pub fn first_and_last(&self) -> Option<(Handle<T>, Handle<T>)> {
pub const fn first_and_last(&self) -> Option<(Handle<T>, Handle<T>)> {
if self.inner.start < self.inner.end {
Some((
// `Range::new_from_bounds` expects a start- and end-inclusive
Expand Down
2 changes: 1 addition & 1 deletion naga/src/back/glsl/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl FeaturesManager {
}

/// Checks if the list of features [`Features`] contains the specified [`Features`]
pub fn contains(&mut self, features: Features) -> bool {
pub const fn contains(&mut self, features: Features) -> bool {
self.0.contains(features)
}

Expand Down
2 changes: 1 addition & 1 deletion naga/src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ struct IdGenerator(u32);

impl IdGenerator {
/// Generates a number that's guaranteed to be unique for this `IdGenerator`
fn generate(&mut self) -> u32 {
const fn generate(&mut self) -> u32 {
// It's just an increasing number but it does the job
let ret = self.0;
self.0 += 1;
Expand Down
1 change: 0 additions & 1 deletion naga/src/back/hlsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ where
pub type BindingMap = alloc::collections::BTreeMap<crate::ResourceBinding, BindTarget>;

/// A HLSL shader model version.
#[allow(non_snake_case, non_camel_case_types)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
Expand Down
2 changes: 0 additions & 2 deletions naga/src/back/msl/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ pub struct InlineSampler {

impl Eq for InlineSampler {}

#[allow(renamed_and_removed_lints)]
#[allow(clippy::derive_hash_xor_eq)]
impl core::hash::Hash for InlineSampler {
fn hash<H: core::hash::Hasher>(&self, hasher: &mut H) {
self.coord.hash(hasher);
Expand Down
2 changes: 0 additions & 2 deletions naga/src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,6 @@ impl<W: Write> Writer<W> {

/// Finishes writing and returns the output.
// See https://github.com/rust-lang/rust-clippy/issues/4979.
#[allow(clippy::missing_const_for_fn)]
pub fn finish(self) -> W {
self.out
}
Expand Down Expand Up @@ -3035,7 +3034,6 @@ impl<W: Write> Writer<W> {
/// [`ReadZeroSkipWrite`]: index::BoundsCheckPolicy::ReadZeroSkipWrite
/// [`Store`]: crate::Statement::Store
/// [`Load`]: crate::Expression::Load
#[allow(unused_variables)]
fn put_bounds_checks(
&mut self,
chain: Handle<crate::Expression>,
Expand Down
2 changes: 1 addition & 1 deletion naga/src/back/spv/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(super) fn string_to_words(input: &str) -> Vec<Word> {

pub(super) fn str_bytes_to_words(bytes: &[u8]) -> Vec<Word> {
let mut words = bytes_to_words(bytes);
if bytes.len() % 4 == 0 {
if bytes.len().is_multiple_of(4) {
// nul-termination
words.push(0x0u32);
}
Expand Down
1 change: 0 additions & 1 deletion naga/src/back/spv/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ impl super::Instruction {
instruction
}

#[allow(clippy::too_many_arguments)]
pub(super) fn type_image(
id: Word,
sampled_type_id: Word,
Expand Down
2 changes: 0 additions & 2 deletions naga/src/back/spv/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,12 @@ impl Instruction {
}
}

#[allow(clippy::panic)]
pub(super) fn set_type(&mut self, id: Word) {
assert!(self.type_id.is_none(), "Type can only be set once");
self.type_id = Some(id);
self.wc += 1;
}

#[allow(clippy::panic)]
pub(super) fn set_result(&mut self, id: Word) {
assert!(self.result_id.is_none(), "Result can only be set once");
self.result_id = Some(id);
Expand Down
6 changes: 3 additions & 3 deletions naga/src/back/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub enum Error {
struct IdGenerator(Word);

impl IdGenerator {
fn next(&mut self) -> Word {
const fn next(&mut self) -> Word {
self.0 += 1;
self.0
}
Expand Down Expand Up @@ -763,7 +763,7 @@ impl GlobalVariable {
}

/// Prepare `self` for use within a single function.
fn reset_for_function(&mut self) {
const fn reset_for_function(&mut self) {
self.handle_id = 0;
self.access_id = 0;
}
Expand Down Expand Up @@ -857,7 +857,7 @@ struct RayQueryTrackers {
}

impl BlockContext<'_> {
fn gen_id(&mut self) -> Word {
const fn gen_id(&mut self) -> Word {
self.writer.id_gen.next()
}

Expand Down
4 changes: 2 additions & 2 deletions naga/src/back/spv/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<'b, M: MergeTuple> Selection<'b, M> {
/// fresh `Selection`.)
///
/// [`finish`]: Selection::finish
pub(super) fn start(block: &'b mut Block, merge_types: M) -> Self {
pub(super) const fn start(block: &'b mut Block, merge_types: M) -> Self {
Selection {
block,
merge_label: None,
Expand All @@ -111,7 +111,7 @@ impl<'b, M: MergeTuple> Selection<'b, M> {
}
}

pub(super) fn block(&mut self) -> &mut Block {
pub(super) const fn block(&mut self) -> &mut Block {
self.block
}

Expand Down
2 changes: 1 addition & 1 deletion naga/src/back/spv/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3488,7 +3488,7 @@ impl Writer {
}
}

fn write_physical_layout(&mut self) {
const fn write_physical_layout(&mut self) {
self.physical_layout.bound = self.id_gen.0 + 1;
}

Expand Down
1 change: 0 additions & 1 deletion naga/src/back/wgsl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,6 @@ impl<W: Write> Writer<W> {
}

// See https://github.com/rust-lang/rust-clippy/issues/4979.
#[allow(clippy::missing_const_for_fn)]
pub fn finish(self) -> W {
self.out
}
Expand Down
2 changes: 1 addition & 1 deletion naga/src/compact/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl FunctionTracer<'_> {
self.as_expression().trace_expressions();
}

fn as_expression(&mut self) -> super::expressions::ExpressionTracer<'_> {
const fn as_expression(&mut self) -> super::expressions::ExpressionTracer<'_> {
super::expressions::ExpressionTracer {
constants: self.constants,
overrides: self.overrides,
Expand Down
4 changes: 2 additions & 2 deletions naga/src/compact/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ impl<'module> ModuleTracer<'module> {
}
}

fn as_type(&mut self) -> types::TypeTracer<'_> {
const fn as_type(&mut self) -> types::TypeTracer<'_> {
types::TypeTracer {
overrides: &self.module.overrides,
types_used: &mut self.types_used,
Expand All @@ -538,7 +538,7 @@ impl<'module> ModuleTracer<'module> {
}
}

fn as_const_expression(&mut self) -> expressions::ExpressionTracer<'_> {
const fn as_const_expression(&mut self) -> expressions::ExpressionTracer<'_> {
expressions::ExpressionTracer {
constants: &self.module.constants,
overrides: &self.module.overrides,
Expand Down
2 changes: 1 addition & 1 deletion naga/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl DiagnosticBuffer {
Self { inner }
}

pub fn inner_mut(&mut self) -> &mut DiagnosticBufferInner {
pub const fn inner_mut(&mut self) -> &mut DiagnosticBufferInner {
&mut self.inner
}

Expand Down
2 changes: 1 addition & 1 deletion naga/src/front/glsl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ impl<'a> Context<'a> {
/// - If more than one [`StmtContext`] are active at the same time or if the
/// previous call didn't use it in lowering.
#[must_use]
pub fn stmt_ctx(&mut self) -> StmtContext {
pub const fn stmt_ctx(&mut self) -> StmtContext {
self.stmt_ctx.take().unwrap()
}

Expand Down
2 changes: 0 additions & 2 deletions naga/src/front/glsl/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ impl Frontend {
ctx.add_expression(Expression::Compose { ty, components }, meta)
}

#[allow(clippy::too_many_arguments)]
fn vector_constructor(
&mut self,
ctx: &mut Context,
Expand Down Expand Up @@ -513,7 +512,6 @@ impl Frontend {
ctx.add_expression(Expression::Compose { ty, components }, meta)
}

#[allow(clippy::too_many_arguments)]
fn function_call(
&mut self,
ctx: &mut Context,
Expand Down
2 changes: 1 addition & 1 deletion naga/src/front/spv/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ impl<I: Iterator<Item = u32>> super::Frontend<I> {
}

impl BlockContext<'_> {
pub(super) fn gctx(&self) -> crate::proc::GlobalCtx<'_> {
pub(super) const fn gctx(&self) -> crate::proc::GlobalCtx<'_> {
crate::proc::GlobalCtx {
types: &self.module.types,
constants: &self.module.constants,
Expand Down
9 changes: 3 additions & 6 deletions naga/src/front/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct Decoration {
}

impl Decoration {
fn debug_name(&self) -> &str {
const fn debug_name(&self) -> &str {
match self.name {
Some(ref name) => name.as_str(),
None => "?",
Expand Down Expand Up @@ -1493,10 +1493,7 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
overrides: &Arena<crate::Override>,
) -> Arena<crate::Expression> {
let mut expressions = Arena::new();
#[allow(clippy::panic)]
{
assert!(self.lookup_expression.is_empty());
}
assert!(self.lookup_expression.is_empty());
// register global variables
for (&id, var) in self.lookup_variable.iter() {
let span = globals.get_span(var.handle);
Expand Down Expand Up @@ -3176,7 +3173,7 @@ fn resolve_constant(gctx: crate::proc::GlobalCtx, constant: &Constant) -> Option
}

pub fn parse_u8_slice(data: &[u8], options: &Options) -> Result<crate::Module, Error> {
if data.len() % 4 != 0 {
if !data.len().is_multiple_of(4) {
return Err(Error::IncompleteData);
}

Expand Down
Loading
Loading