Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
[msl-out] Implement index bounds check policies for non-texture acces…
Browse files Browse the repository at this point in the history
…ses.
  • Loading branch information
jimblandy committed Dec 4, 2021
1 parent 73dd5bc commit 7f49425
Show file tree
Hide file tree
Showing 14 changed files with 1,680 additions and 269 deletions.
5 changes: 4 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,17 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
"metal" => {
use naga::back::msl;

let mut options = params.msl.clone();
options.bounds_check_policies = params.bounds_check_policies;

let pipeline_options = msl::PipelineOptions::default();
let (msl, _) = msl::write_string(
&module,
info.as_ref().ok_or(CliError(
"Generating metal output requires validation to \
succeed, and it failed in a previous step",
))?,
&params.msl,
&options,
&pipeline_options,
)
.unwrap_pretty();
Expand Down
6 changes: 5 additions & 1 deletion src/back/msl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For the result type, if it's a structure, we re-compose it with a temporary valu
holding the result.
!*/

use crate::{arena::Handle, valid::ModuleInfo};
use crate::{arena::Handle, proc::index, valid::ModuleInfo};
use std::{
fmt::{Error as FmtError, Write},
ops,
Expand Down Expand Up @@ -177,6 +177,9 @@ pub struct Options {
pub spirv_cross_compatibility: bool,
/// Don't panic on missing bindings, instead generate invalid MSL.
pub fake_missing_bindings: bool,
/// Bounds checking policies.
#[cfg_attr(feature = "deserialize", serde(default))]
pub bounds_check_policies: index::BoundsCheckPolicies,
}

impl Default for Options {
Expand All @@ -187,6 +190,7 @@ impl Default for Options {
inline_samplers: Vec::new(),
spirv_cross_compatibility: false,
fake_missing_bindings: true,
bounds_check_policies: index::BoundsCheckPolicies::default(),
}
}
}
Expand Down
Loading

0 comments on commit 7f49425

Please sign in to comment.