-
Notifications
You must be signed in to change notification settings - Fork 194
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
Binding arrays play nice with bounds checks #1855
Binding arrays play nice with bounds checks #1855
Conversation
cc97ab4
to
1ac8dae
Compare
@jimblandy please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks to me like the generated MSL code isn't right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question to check over, but otherwise, looks good to me! Thank you very much.
Some(target) => match module.types[var.ty].inner { | ||
crate::TypeInner::Image { .. } => target.texture.is_some(), | ||
crate::TypeInner::Sampler { .. } => target.sampler.is_some(), | ||
_ => target.buffer.is_some(), | ||
}, | ||
Some(target) => { | ||
let binding_ty = match module.types[var.ty].inner { | ||
crate::TypeInner::BindingArray { base, .. } => { | ||
&module.types[base].inner | ||
} | ||
ref ty => ty, | ||
}; | ||
match *binding_ty { | ||
crate::TypeInner::Image { .. } => target.texture.is_some(), | ||
crate::TypeInner::Sampler { .. } => target.sampler.is_some(), | ||
_ => target.buffer.is_some(), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like an unrelated fix. It's fine to include it in this PR, but if it has something to do with bounds checks, let me know, because I'm not understanding the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, sorry this should have been titled "fixes needed to get the binding indexing wgpu PR working" :)
tl;dr: Because of the change above this, it is now possible to get the type of binding array, and we need to "punch through" the binding array to find the actual type of binding we're looking at.
It's only related to bounds checks as this is code that is only hit when bounds checks are on.
Found an issue with binding indexing in the MSL backend when bounds checks were on.
This fixes the issue and adds a binding array bounds check policy that, for now, must be unchecked.