Skip to content

Commit a386dcc

Browse files
committed
CI fixes
1 parent c6e0c48 commit a386dcc

File tree

6 files changed

+63
-30
lines changed

6 files changed

+63
-30
lines changed

naga/src/back/msl/writer.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -6990,9 +6990,20 @@ mod workgroup_mem_init {
69906990

69916991
let mut access_stack = AccessStack::new();
69926992

6993-
let vars = module.global_variables.iter().filter(|&(handle, var)| {
6994-
!fun_info[handle].is_empty() && var.space == crate::AddressSpace::WorkGroup
6995-
});
6993+
let vars = module
6994+
.global_variables
6995+
.iter()
6996+
.filter(|&(handle, var)| {
6997+
!fun_info[handle].is_empty()
6998+
&& var.space == crate::AddressSpace::WorkGroup
6999+
&& !self
7000+
.unresolved_overrides
7001+
.as_ref()
7002+
.unwrap()
7003+
.global_variables
7004+
.contains_key(&handle)
7005+
})
7006+
.collect::<Vec<_>>();
69967007

69977008
for (handle, var) in vars {
69987009
access_stack.enter(Access::GlobalVariable(handle), |access_stack| {

naga/src/back/pipeline_constants.rs

+38-16
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ use crate::{
1313
ir,
1414
proc::{ConstantEvaluator, ConstantEvaluatorError, Emitter, U32EvalError},
1515
valid::{
16-
Capabilities, ModuleInfo, UnresolvedOverrides, ValidationError, ValidationFlags, Validator,
16+
Capabilities, FunctionInfo, ModuleInfo, UnresolvedOverrides, ValidationError,
17+
ValidationFlags, Validator,
1718
},
1819
Arena, Block, Constant, Expression, FastHashMap, Function, Handle, Literal, Module, Override,
1920
Range, Scalar, Span, Statement, TypeInner, WithSpan,
@@ -59,6 +60,26 @@ pub struct ProcessOverridesOutput<'a> {
5960
pub unresolved: UnresolvedOverrides,
6061
}
6162

63+
/// Check the global usage in `fun_info` for any globals affected by unresolved
64+
/// overrides.
65+
///
66+
/// If any is found, returns `Some`, otherwise returns `None`.
67+
fn check_for_unresolved_global_use<'a>(
68+
globals: impl Iterator<Item = (Handle<ir::GlobalVariable>, &'a ir::GlobalVariable)>,
69+
unresolved: &UnresolvedOverrides,
70+
fun_info: &FunctionInfo,
71+
) -> Option<Handle<Override>> {
72+
for (var_handle, _) in globals {
73+
match unresolved.global_variables.get(&var_handle) {
74+
Some(&o_handle) if !fun_info[var_handle].is_empty() => {
75+
return Some(o_handle);
76+
}
77+
_ => {}
78+
}
79+
}
80+
None
81+
}
82+
6283
/// Replace overrides in `module` with constants.
6384
///
6485
/// If no changes are needed, this just returns `Cow::Borrowed`
@@ -325,11 +346,11 @@ pub fn process_overrides<'a>(
325346
}
326347

327348
// Process functions, taking note of which ones require overrides that were
328-
// not specified. Like expressions, callees are guarenteed to appear before
349+
// not specified. Like expressions, callees are guaranteed to appear before
329350
// their callers.
330351
let mut functions = mem::take(&mut module.functions);
331352
for (f_handle, function) in functions.iter_mut() {
332-
if let Some(o_handle) = process_function(
353+
let result = if let Some(o_handle) = process_function(
333354
&mut module,
334355
&override_map,
335356
&unresolved.functions,
@@ -341,6 +362,15 @@ pub fn process_overrides<'a>(
341362
function.name,
342363
overrides[o_handle].name
343364
);
365+
Some(o_handle)
366+
} else {
367+
check_for_unresolved_global_use(
368+
module.global_variables.iter(),
369+
&unresolved,
370+
&module_info[f_handle],
371+
)
372+
};
373+
if let Some(o_handle) = result {
344374
unresolved.functions.insert(f_handle, o_handle);
345375
}
346376
}
@@ -367,19 +397,11 @@ pub fn process_overrides<'a>(
367397
{
368398
Some(o_handle)
369399
} else {
370-
// See if we use any global variables that are missing overrides.
371-
let mut missing = None;
372-
for (var_handle, _) in module.global_variables.iter() {
373-
let global_use = module_info.get_entry_point(ep_index)[var_handle];
374-
match unresolved.global_variables.get(&var_handle) {
375-
Some(&o_handle) if !global_use.is_empty() => {
376-
missing = Some(o_handle);
377-
break;
378-
}
379-
_ => {}
380-
}
381-
}
382-
missing
400+
check_for_unresolved_global_use(
401+
module.global_variables.iter(),
402+
&unresolved,
403+
module_info.get_entry_point(ep_index),
404+
)
383405
};
384406
if let Some(o_handle) = result {
385407
// We found a missing override that is required by this entry point.

naga/src/valid/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ impl ops::Index<Handle<crate::Expression>> for ModuleInfo {
273273
/// This struct may be passed to the various backend writers.
274274
///
275275
/// [`process_overrides`]: crate::back::pipeline_constants::process_overrides
276-
#[cfg(any(hlsl_out, msl_out, spv_out, glsl_out))]
277276
#[derive(Clone, Debug, Default)]
278277
pub struct UnresolvedOverrides {
279278
pub(crate) global_variables:

naga/tests/naga/snapshots.rs

+6
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ impl Input {
235235
return None;
236236
}
237237

238+
if let Ok(pat) = std::env::var("NAGA_SNAPSHOT") {
239+
if !file_name.to_string_lossy().contains(&pat) {
240+
return None;
241+
}
242+
}
243+
238244
let input = Input::new(
239245
subdirectory,
240246
file_name.file_stem().unwrap().to_str().unwrap(),

naga/tests/out/msl/wgsl-missing-unused-overrides.msl

-9
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ struct FragmentIn {
99
};
1010
constant float ov_for_vertex = 1.5;
1111

12-
void compute_helper(
13-
thread uint& foo,
14-
threadgroup type_4& arr
15-
) {
16-
uint phony = foo;
17-
uint phony_1 = arr.inner[0];
18-
return;
19-
}
20-
2112
struct vert_mainInput {
2213
metal::float2 pos [[attribute(0)]];
2314
};

wgpu-hal/src/dx12/device.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,11 @@ impl super::Device {
276276

277277
let stage_bit = auxil::map_naga_stage(naga_stage);
278278

279-
let (module, info) = naga::back::pipeline_constants::process_overrides(
279+
let naga::back::pipeline_constants::ProcessOverridesOutput {
280+
module,
281+
info,
282+
unresolved: _,
283+
} = naga::back::pipeline_constants::process_overrides(
280284
&stage.module.naga.module,
281285
&stage.module.naga.info,
282286
None,

0 commit comments

Comments
 (0)