Skip to content

Commit

Permalink
Merge branch 'trunk' into feature/enable
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald authored Feb 7, 2025
2 parents ad55db7 + 005bde9 commit a15bf38
Show file tree
Hide file tree
Showing 21 changed files with 525 additions and 148 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ By @brodycj in [#6924](https://github.com/gfx-rs/wgpu/pull/6924).
#### Dx12

- Fix HLSL storage format generation. By @Vecvec in [#6993](https://github.com/gfx-rs/wgpu/pull/6993)
- Fix 3D storage texture bindings. By @SparkyPotato in [#7071](https://github.com/gfx-rs/wgpu/pull/7071)

#### WebGPU

Expand Down
27 changes: 14 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ futures-lite = "2"
getrandom = "0.2"
glam = "0.29"
half = { package = "half-2", version = "2.4.1" }
hashbrown = { version = "0.15.2", default-features = false, features = [
"default-hasher",
hashbrown = { version = "0.14.5", default-features = false, features = [
"ahash",
"inline-more",
] }
heck = "0.5.0"
image = { version = "0.24", default-features = false, features = ["png"] }
indexmap = { version = "2.7.1", default-features = false }
indexmap = { version = "2.5.0", default-features = false }
itertools = { version = "0.13.0" }
ktx2 = "0.3"
libc = { version = "0.2", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion deno_webgpu/command_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ pub fn op_webgpu_command_encoder_begin_compute_pass(
let command_encoder = &command_encoder_resource.1;
let descriptor = wgpu_core::command::ComputePassDescriptor {
label: Some(label),
timestamp_writes: timestamp_writes.as_ref(),
timestamp_writes,
};

let (compute_pass, error) =
Expand Down
2 changes: 1 addition & 1 deletion examples/standalone/02_hello_window/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl ApplicationHandler for App {
}
WindowEvent::Resized(size) => {
// Reconfigures the size of the surface. We do not re-render
// here as this event is always folloed up by redraw request.
// here as this event is always followed up by redraw request.
state.resize(size);
}
_ => (),
Expand Down
2 changes: 1 addition & 1 deletion naga/src/arena/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl<T> Arena<T> {

/// Returns an iterator over the items stored in this arena, returning both
/// the item's handle and a reference to it.
pub fn iter(&self) -> impl DoubleEndedIterator<Item = (Handle<T>, &T)> {
pub fn iter(&self) -> impl DoubleEndedIterator<Item = (Handle<T>, &T)> + ExactSizeIterator {
self.data
.iter()
.enumerate()
Expand Down
2 changes: 1 addition & 1 deletion naga/src/arena/unique_arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl<T> Iterator for UniqueArenaDrain<'_, T> {
impl<T: Eq + hash::Hash> UniqueArena<T> {
/// Returns an iterator over the items stored in this arena, returning both
/// the item's handle and a reference to it.
pub fn iter(&self) -> impl DoubleEndedIterator<Item = (Handle<T>, &T)> {
pub fn iter(&self) -> impl DoubleEndedIterator<Item = (Handle<T>, &T)> + ExactSizeIterator {
self.set.iter().enumerate().map(|(i, v)| {
let index = unsafe { Index::new_unchecked(i as u32) };
(Handle::new(index), v)
Expand Down
18 changes: 9 additions & 9 deletions naga/src/back/pipeline_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,28 +305,28 @@ fn process_workgroup_size_override(
///
/// Add the new `Constant` to `override_map` and `adjusted_constant_initializers`.
fn process_override(
(old_h, override_, span): (Handle<Override>, Override, Span),
(old_h, r#override, span): (Handle<Override>, Override, Span),
pipeline_constants: &PipelineConstants,
module: &mut Module,
override_map: &mut HandleVec<Override, Handle<Constant>>,
adjusted_global_expressions: &HandleVec<Expression, Handle<Expression>>,
adjusted_constant_initializers: &mut HashSet<Handle<Constant>>,
global_expression_kind_tracker: &mut crate::proc::ExpressionKindTracker,
) -> Result<Handle<Constant>, PipelineConstantError> {
// Determine which key to use for `override_` in `pipeline_constants`.
let key = if let Some(id) = override_.id {
// Determine which key to use for `r#override` in `pipeline_constants`.
let key = if let Some(id) = r#override.id {
Cow::Owned(id.to_string())
} else if let Some(ref name) = override_.name {
} else if let Some(ref name) = r#override.name {
Cow::Borrowed(name)
} else {
unreachable!();
};

// Generate a global expression for `override_`'s value, either
// Generate a global expression for `r#override`'s value, either
// from the provided `pipeline_constants` table or its initializer
// in the module.
let init = if let Some(value) = pipeline_constants.get::<str>(&key) {
let literal = match module.types[override_.ty].inner {
let literal = match module.types[r#override.ty].inner {
TypeInner::Scalar(scalar) => map_value_to_literal(*value, scalar)?,
_ => unreachable!(),
};
Expand All @@ -335,16 +335,16 @@ fn process_override(
.append(Expression::Literal(literal), Span::UNDEFINED);
global_expression_kind_tracker.insert(expr, crate::proc::ExpressionKind::Const);
expr
} else if let Some(init) = override_.init {
} else if let Some(init) = r#override.init {
adjusted_global_expressions[init]
} else {
return Err(PipelineConstantError::MissingValue(key.to_string()));
};

// Generate a new `Constant` to represent the override's value.
let constant = Constant {
name: override_.name,
ty: override_.ty,
name: r#override.name,
ty: r#override.ty,
init,
};
let h = module.constants.append(constant, span);
Expand Down
37 changes: 23 additions & 14 deletions naga/src/compact/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::arena::{Arena, Handle};

pub struct ExpressionTracer<'tracer> {
pub constants: &'tracer Arena<crate::Constant>,
pub overrides: &'tracer Arena<crate::Override>,

/// The arena in which we are currently tracing expressions.
pub expressions: &'tracer Arena<crate::Expression>,
Expand All @@ -13,6 +14,9 @@ pub struct ExpressionTracer<'tracer> {
/// The used map for `constants`.
pub constants_used: &'tracer mut HandleSet<crate::Constant>,

/// The used map for `overrides`.
pub overrides_used: &'tracer mut HandleSet<crate::Override>,

/// The used set for `arena`.
///
/// This points to whatever arena holds the expressions we are
Expand Down Expand Up @@ -78,25 +82,32 @@ impl ExpressionTracer<'_> {
| Ex::SubgroupBallotResult
| Ex::RayQueryProceedResult => {}

// Expressions can refer to constants and overrides, which can refer
// in turn to expressions, which complicates our nice one-pass
// algorithm. But since constants and overrides don't refer to each
// other directly, only via expressions, we can get around this by
// looking *through* each constant/override and marking its
// initializer expression as used immediately. Since `expr` refers
// to the constant/override, which then refers to the initializer,
// the initializer must precede `expr` in the arena, so we know we
// have yet to visit the initializer, so it's not too late to mark
// it.
Ex::Constant(handle) => {
self.constants_used.insert(handle);
// Constants and expressions are mutually recursive, which
// complicates our nice one-pass algorithm. However, since
// constants don't refer to each other, we can get around
// this by looking *through* each constant and marking its
// initializer as used. Since `expr` refers to the constant,
// and the constant refers to the initializer, it must
// precede `expr` in the arena.
let init = self.constants[handle].init;
match self.global_expressions_used {
Some(ref mut used) => used.insert(init),
None => self.expressions_used.insert(init),
};
}
Ex::Override(_) => {
// All overrides are considered used by definition. We mark
// their types and initialization expressions as used in
// `compact::compact`, so we have no more work to do here.
Ex::Override(handle) => {
self.overrides_used.insert(handle);
if let Some(init) = self.overrides[handle].init {
match self.global_expressions_used {
Some(ref mut used) => used.insert(init),
None => self.expressions_used.insert(init),
};
}
}
Ex::ZeroValue(ty) => {
self.types_used.insert(ty);
Expand Down Expand Up @@ -256,11 +267,9 @@ impl ModuleMap {
| Ex::SubgroupBallotResult
| Ex::RayQueryProceedResult => {}

// All overrides are retained, so their handles never change.
Ex::Override(_) => {}

// Expressions that contain handles that need to be adjusted.
Ex::Constant(ref mut constant) => self.constants.adjust(constant),
Ex::Override(ref mut r#override) => self.overrides.adjust(r#override),
Ex::ZeroValue(ref mut ty) => self.types.adjust(ty),
Ex::Compose {
ref mut ty,
Expand Down
4 changes: 4 additions & 0 deletions naga/src/compact/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ use super::{FunctionMap, ModuleMap};
pub struct FunctionTracer<'a> {
pub function: &'a crate::Function,
pub constants: &'a crate::Arena<crate::Constant>,
pub overrides: &'a crate::Arena<crate::Override>,

pub types_used: &'a mut HandleSet<crate::Type>,
pub constants_used: &'a mut HandleSet<crate::Constant>,
pub overrides_used: &'a mut HandleSet<crate::Override>,
pub global_expressions_used: &'a mut HandleSet<crate::Expression>,

/// Function-local expressions used.
Expand Down Expand Up @@ -47,10 +49,12 @@ impl FunctionTracer<'_> {
fn as_expression(&mut self) -> super::expressions::ExpressionTracer {
super::expressions::ExpressionTracer {
constants: self.constants,
overrides: self.overrides,
expressions: &self.function.expressions,

types_used: self.types_used,
constants_used: self.constants_used,
overrides_used: self.overrides_used,
expressions_used: &mut self.expressions_used,
global_expressions_used: Some(&mut self.global_expressions_used),
}
Expand Down
Loading

0 comments on commit a15bf38

Please sign in to comment.