Skip to content

Commit 620d6e4

Browse files
authored
Merge branch 'master' into solari6
2 parents 82476f8 + 0684428 commit 620d6e4

File tree

10 files changed

+70
-48
lines changed

10 files changed

+70
-48
lines changed

Cargo.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ license = "MIT OR Apache-2.0"
66
description = "a crate for combining and manipulating shaders using naga IR"
77
repository = "https://github.com/bevyengine/naga_oil/"
88
readme = "README.md"
9+
rust-version = "1.84"
910

1011
[features]
1112
default = ["test_shader", "glsl"]
@@ -17,20 +18,20 @@ prune = []
1718
allow_deprecated = []
1819

1920
[dependencies]
20-
naga = { version = "24", features = ["wgsl-in", "wgsl-out"] }
21+
naga = { version = "25", features = ["wgsl-in", "wgsl-out"] }
2122
tracing = "0.1"
2223
regex = "1.8"
2324
regex-syntax = "0.8"
24-
thiserror = "1.0"
25-
codespan-reporting = "0.11"
25+
thiserror = "2.0"
26+
codespan-reporting = "0.12"
2627
data-encoding = "2.3.2"
27-
bit-set = "0.5"
28-
rustc-hash = "1.1.0"
28+
bit-set = "0.8"
29+
rustc-hash = "1.1"
2930
unicode-ident = "1"
3031
once_cell = "1.17.0"
3132
indexmap = "2"
3233

3334
[dev-dependencies]
34-
wgpu = { version = "24", features = ["naga-ir"] }
35-
futures-lite = "1"
35+
wgpu = { version = "25", features = ["naga-ir"] }
36+
futures-lite = "2"
3637
tracing-subscriber = { version = "0.3", features = ["std", "fmt"] }

examples/pbr_compose_test.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,10 @@ fn test_wgsl_string_compile(n: usize) {
145145
.into_iter()
146146
.next()
147147
.unwrap();
148-
let device = futures_lite::future::block_on(
149-
adapter.request_device(&wgpu::DeviceDescriptor::default(), None),
150-
)
151-
.unwrap()
152-
.0;
148+
let device =
149+
futures_lite::future::block_on(adapter.request_device(&wgpu::DeviceDescriptor::default()))
150+
.unwrap()
151+
.0;
153152

154153
for _ in 0..n {
155154
let _desc = device.create_shader_module(wgpu::ShaderModuleDescriptor {
@@ -169,11 +168,10 @@ fn test_composer_compile(n: usize, composer: &mut Composer) {
169168
.into_iter()
170169
.next()
171170
.unwrap();
172-
let device = futures_lite::future::block_on(
173-
adapter.request_device(&wgpu::DeviceDescriptor::default(), None),
174-
)
175-
.unwrap()
176-
.0;
171+
let device =
172+
futures_lite::future::block_on(adapter.request_device(&wgpu::DeviceDescriptor::default()))
173+
.unwrap()
174+
.0;
177175

178176
for _ in 0..n {
179177
let module = composer

src/compose/comment_strip_iter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'a> Iterator for CommentReplaceIter<'a> {
5151
.unwrap_or(line_in.len());
5252

5353
if let CommentState::Block(_) = self.state {
54-
output.extend(std::iter::repeat(' ').take(section_end - section_start));
54+
output.extend(std::iter::repeat_n(' ', section_end - section_start));
5555
} else {
5656
output.push_str(&line_in[section_start..section_end]);
5757
}
@@ -62,10 +62,10 @@ impl<'a> Iterator for CommentReplaceIter<'a> {
6262
match marker.as_str() {
6363
// only possible in None state
6464
"//" => {
65-
output.extend(
66-
std::iter::repeat(' ')
67-
.take(line_in.len() - marker.start() - section_start),
68-
);
65+
output.extend(std::iter::repeat_n(
66+
' ',
67+
line_in.len() - marker.start() - section_start,
68+
));
6969
return Some(Cow::Owned(output));
7070
}
7171
// only possible in None or Block state

src/compose/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ impl Composer {
12331233
for (h, ty) in source_ir.types.iter() {
12341234
if let Some(name) = &ty.name {
12351235
if composable.owned_types.contains(name)
1236-
&& items.map_or(true, |items| items.contains(name))
1236+
&& items.is_none_or(|items| items.contains(name))
12371237
{
12381238
derived.import_type(&h);
12391239
}
@@ -1243,7 +1243,7 @@ impl Composer {
12431243
for (h, c) in source_ir.constants.iter() {
12441244
if let Some(name) = &c.name {
12451245
if composable.owned_constants.contains(name)
1246-
&& items.map_or(true, |items| items.contains(name))
1246+
&& items.is_none_or(|items| items.contains(name))
12471247
{
12481248
derived.import_const(&h);
12491249
}
@@ -1253,7 +1253,7 @@ impl Composer {
12531253
for (h, po) in source_ir.overrides.iter() {
12541254
if let Some(name) = &po.name {
12551255
if composable.owned_functions.contains(name)
1256-
&& items.map_or(true, |items| items.contains(name))
1256+
&& items.is_none_or(|items| items.contains(name))
12571257
{
12581258
derived.import_pipeline_override(&h);
12591259
}
@@ -1263,7 +1263,7 @@ impl Composer {
12631263
for (h, v) in source_ir.global_variables.iter() {
12641264
if let Some(name) = &v.name {
12651265
if composable.owned_vars.contains(name)
1266-
&& items.map_or(true, |items| items.contains(name))
1266+
&& items.is_none_or(|items| items.contains(name))
12671267
{
12681268
derived.import_global(&h);
12691269
}
@@ -1273,7 +1273,7 @@ impl Composer {
12731273
for (h_f, f) in source_ir.functions.iter() {
12741274
if let Some(name) = &f.name {
12751275
if composable.owned_functions.contains(name)
1276-
&& (items.map_or(true, |items| items.contains(name))
1276+
&& (items.is_none_or(|items| items.contains(name))
12771277
|| composable
12781278
.override_functions
12791279
.values()

src/compose/preprocess.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ impl Preprocessor {
267267

268268
loop {
269269
// output spaces for removed lines to keep spans consistent (errors report against substituted_source, which is not preprocessed)
270-
final_string.extend(std::iter::repeat(" ").take(line.len()));
270+
final_string.extend(std::iter::repeat_n(" ", line.len()));
271271
offset += line.len() + 1;
272272

273273
// PERF: Ideally we don't do multiple `match_indices` passes over `line`
@@ -351,15 +351,15 @@ impl Preprocessor {
351351

352352
final_string.push_str(&item_replaced_line);
353353
let diff = line.len().saturating_sub(item_replaced_line.len());
354-
final_string.extend(std::iter::repeat(" ").take(diff));
354+
final_string.extend(std::iter::repeat_n(" ", diff));
355355
offset += original_line.len() + 1;
356356
output = true;
357357
}
358358
}
359359

360360
if !output {
361361
// output spaces for removed lines to keep spans consistent (errors report against substituted_source, which is not preprocessed)
362-
final_string.extend(std::iter::repeat(" ").take(line.len()));
362+
final_string.extend(std::iter::repeat_n(" ", line.len()));
363363
offset += line.len() + 1;
364364
}
365365
final_string.push('\n');

src/compose/test.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,14 +1401,12 @@ mod test {
14011401
.into_iter()
14021402
.next()
14031403
.unwrap();
1404-
let (device, queue) = futures_lite::future::block_on(adapter.request_device(
1405-
&wgpu::DeviceDescriptor {
1404+
let (device, queue) =
1405+
futures_lite::future::block_on(adapter.request_device(&wgpu::DeviceDescriptor {
14061406
required_features: Features::MAPPABLE_PRIMARY_BUFFERS,
14071407
..Default::default()
1408-
},
1409-
None,
1410-
))
1411-
.unwrap();
1408+
}))
1409+
.unwrap();
14121410

14131411
let shader_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
14141412
source: wgpu::ShaderSource::Naga(Cow::Owned(module)),
@@ -1477,15 +1475,23 @@ mod test {
14771475

14781476
queue.submit([buffer]);
14791477

1480-
while !device.poll(wgpu::MaintainBase::Wait).is_queue_empty() {
1478+
while !device
1479+
.poll(wgpu::MaintainBase::Wait)
1480+
.unwrap()
1481+
.is_queue_empty()
1482+
{
14811483
println!("waiting...");
14821484
}
14831485

14841486
output_buffer
14851487
.slice(..)
14861488
.map_async(wgpu::MapMode::Read, |_| ());
14871489

1488-
while !device.poll(wgpu::MaintainBase::Wait).is_queue_empty() {
1490+
while !device
1491+
.poll(wgpu::MaintainBase::Wait)
1492+
.unwrap()
1493+
.is_queue_empty()
1494+
{
14891495
println!("waiting...");
14901496
}
14911497

src/compose/tests/expected/err_validation_1.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ error: failed to build a valid final module: Function [1] 'func' is invalid
33
44
7 │ ╭ fn func() -> f32 {
55
8 │ │ return 1u;
6-
│ │ ^^ naga::Expression [0]
7-
│ ╰──────────────^ naga::Function [1]
6+
│ │ ^^ naga::ir::Expression [0]
7+
│ ╰──────────────^ naga::ir::Function [1]
88
99
= The `return` value Some([0]) does not match the function return value
1010

src/compose/tests/expected/err_validation_2.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ error: failed to build a valid final module: Function [0] 'valid_inc::func' is i
33
44
7 │ ╭ fn func() -> f32 {
55
8 │ │ return 1u;
6-
│ │ ^^ naga::Expression [0]
7-
│ ╰──────────────^ naga::Function [0]
6+
│ │ ^^ naga::ir::Expression [0]
7+
│ ╰──────────────^ naga::ir::Function [0]
88
99
= The `return` value Some([0]) does not match the function return value
1010

src/derive.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ impl<'a> DerivedModule<'a> {
9292
| TypeInner::Image { .. }
9393
| TypeInner::Sampler { .. }
9494
| TypeInner::Atomic { .. }
95-
| TypeInner::AccelerationStructure
96-
| TypeInner::RayQuery => ty.inner.clone(),
95+
| TypeInner::AccelerationStructure { .. }
96+
| TypeInner::RayQuery { .. } => ty.inner.clone(),
9797

9898
TypeInner::Pointer { base, space } => TypeInner::Pointer {
9999
base: self.import_type(base),
@@ -172,7 +172,7 @@ impl<'a> DerivedModule<'a> {
172172
let new_global = GlobalVariable {
173173
name: gv.name.clone(),
174174
space: gv.space,
175-
binding: gv.binding.clone(),
175+
binding: gv.binding,
176176
ty: self.import_type(&gv.ty),
177177
init: gv.init.map(|c| self.import_global_expression(c)),
178178
};
@@ -407,6 +407,14 @@ impl<'a> DerivedModule<'a> {
407407
}
408408
}
409409
naga::RayQueryFunction::Terminate => naga::RayQueryFunction::Terminate,
410+
naga::RayQueryFunction::GenerateIntersection { hit_t } => {
411+
naga::RayQueryFunction::GenerateIntersection {
412+
hit_t: map_expr!(hit_t),
413+
}
414+
}
415+
naga::RayQueryFunction::ConfirmIntersection => {
416+
naga::RayQueryFunction::ConfirmIntersection
417+
}
410418
},
411419
},
412420
Statement::SubgroupBallot { result, predicate } => Statement::SubgroupBallot {
@@ -694,6 +702,12 @@ impl<'a> DerivedModule<'a> {
694702
committed: *committed,
695703
}
696704
}
705+
Expression::RayQueryVertexPositions { query, committed } => {
706+
Expression::RayQueryVertexPositions {
707+
query: map_expr!(query),
708+
committed: *committed,
709+
}
710+
}
697711
Expression::Override(h_override) => {
698712
is_external = true;
699713
Expression::Override(self.import_pipeline_override(h_override))

src/prune/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ impl FunctionReq {
450450
pointer: expr_map[pointer],
451451
fun: *fun,
452452
value: expr_map[value],
453-
result: expr_map[result],
453+
result: result.as_ref().map(|it| expr_map[it]),
454454
})
455455
}
456456
(
@@ -1568,12 +1568,15 @@ impl<'a> Pruner<'a> {
15681568
let required_store = self.store_required(context, &var_ref);
15691569
debug!("atomic store required: {:?}", required_store);
15701570

1571-
let required_load = func_req.exprs_required.get(result).cloned();
1571+
let required_load = match result {
1572+
Some(result) => func_req.exprs_required.get(result).cloned(),
1573+
None => None,
1574+
};
15721575
debug!("atomic load required: {:?}", required_load);
15731576

15741577
if required_load.is_some() || required_store.is_some() {
15751578
// just pass it all through i guess ..?
1576-
if let Some(required_load) = required_load {
1579+
if let (Some(required_load), Some(result)) = (required_load, result) {
15771580
self.add_expression(function, func_req, context, *result, &required_load);
15781581
}
15791582
if let Some(required_store) = required_store {

0 commit comments

Comments
 (0)