Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gate MSL infinite loop optimization workaround to a flag enabled by default #6520

Open
wants to merge 7 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion naga/src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3028,7 +3028,10 @@ impl<W: Write> Writer<W> {
ref continuing,
break_if,
} => {
self.emit_loop_reachable_macro()?;
// We only emit the macro if the index policy is not checked.
if context.expression.policies.index != index::BoundsCheckPolicy::Unchecked {
self.emit_loop_reachable_macro()?;
}
if !continuing.is_empty() || break_if.is_some() {
let gate_name = self.namer.call("loop_init");
writeln!(self.out, "{level}bool {gate_name} = true;")?;
Expand Down
1 change: 1 addition & 0 deletions naga/src/proc/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub enum BoundsCheckPolicy {
pub struct BoundsCheckPolicies {
/// How should the generated code handle array, vector, or matrix indices
/// that are out of range?
/// On Metal, this policy also dictates how loops are checked for UB.
rudderbucky marked this conversation as resolved.
Show resolved Hide resolved
#[cfg_attr(feature = "deserialize", serde(default))]
pub index: BoundsCheckPolicy,

Expand Down