Skip to content

Commit ecef54a

Browse files
committed
CI fixes
1 parent 2d582b2 commit ecef54a

File tree

7 files changed

+65
-31
lines changed

7 files changed

+65
-31
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,
@@ -62,6 +63,26 @@ pub struct ProcessOverridesOutput<'a> {
6263
pub unresolved: UnresolvedOverrides,
6364
}
6465

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

330351
// Process functions, taking note of which ones require overrides that were
331-
// not specified. Like expressions, callees are guarenteed to appear before
352+
// not specified. Like expressions, callees are guaranteed to appear before
332353
// their callers.
333354
let mut functions = mem::take(&mut module.functions);
334355
for (f_handle, function) in functions.iter_mut() {
335-
if let Some(o_handle) = process_function(
356+
let result = if let Some(o_handle) = process_function(
336357
&mut module,
337358
&override_map,
338359
&unresolved.functions,
@@ -344,6 +365,15 @@ pub fn process_overrides<'a>(
344365
function.name,
345366
overrides[o_handle].name
346367
);
368+
Some(o_handle)
369+
} else {
370+
check_for_unresolved_global_use(
371+
module.global_variables.iter(),
372+
&unresolved,
373+
&module_info[f_handle],
374+
)
375+
};
376+
if let Some(o_handle) = result {
347377
unresolved.functions.insert(f_handle, o_handle);
348378
}
349379
}
@@ -370,19 +400,11 @@ pub fn process_overrides<'a>(
370400
{
371401
Some(o_handle)
372402
} else {
373-
// See if we use any global variables that are missing overrides.
374-
let mut missing = None;
375-
for (var_handle, _) in module.global_variables.iter() {
376-
let global_use = module_info.get_entry_point(ep_index)[var_handle];
377-
match unresolved.global_variables.get(&var_handle) {
378-
Some(&o_handle) if !global_use.is_empty() => {
379-
missing = Some(o_handle);
380-
break;
381-
}
382-
_ => {}
383-
}
384-
}
385-
missing
403+
check_for_unresolved_global_use(
404+
module.global_variables.iter(),
405+
&unresolved,
406+
module_info.get_entry_point(ep_index),
407+
)
386408
};
387409
if let Some(o_handle) = result {
388410
// We found a missing override that is required by this entry point.

naga/src/proc/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ impl crate::Module {
414414
}
415415

416416
#[derive(Debug)]
417+
#[cfg_attr(not(any(hlsl_out, msl_out, spv_out, glsl_out)), allow(dead_code))]
417418
pub(super) enum U32EvalError {
418419
/// Expression is not constant.
419420
Runtime,

naga/src/valid/mod.rs

+1-2
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:
@@ -611,7 +610,7 @@ impl<'a> Validator<'a> {
611610
/// in items that appear in one of the maps in `unresolved`.
612611
///
613612
/// [`validate`]: Validator::validate
614-
pub(crate) fn validate_with_resolved_overrides(
613+
pub fn validate_with_resolved_overrides(
615614
&mut self,
616615
module: &crate::Module,
617616
unresolved: &'a UnresolvedOverrides,

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)