-
Notifications
You must be signed in to change notification settings - Fork 57
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
Validator #19
Comments
I had a few ideas for this. The premise of these ideas is, the validator would be built as a part of the rspirv library (Possibly behind a feature), and the package would also include an application which consumes the validator API (providing nearly the same experience as SPIRV-Tools' validator). Being in a library could allow a developer to add additional scrutiny before allowing Vulkan or GL APIs to run their module --- Diagnostic messages could be localized, or possibly easier to understand than errors produced by their graphics or compute API --- But the primary use would still be the validator application. What do you think? In addition to the above premise, there are a few areas where I'm a bit unsure of how I want this API to look/to be consumed. These are mostly cosmetic, but a few have significant effects on how the library would need to be developed. API entrypoints (and their use)
pub fn validate_bytes<T: AsRef<[u8]>>(binary: T) -> Result<()>;
pub fn validate_words<T: AsRef<[u32]>>(binary: T) -> Result<()>;
pub fn validate_module(module: &mr::Module) -> Result<()>;
pub struct ValidationState {
// ...
}
impl ValidationState {
pub fn new(module: &mr::Module) -> ValidationState {
// ...
}
pub fn validate() -> Result<()> {
// ...
}
// ...
} Error reporting:
trait DiagnosticConsumer {
fn message(severity: Severity, message: Message) -> Action;
// Or, if building diagnostic messages is the responsibility of the API consumer:
fn message(severity: Severity, message: Message, line: Option(mr::Instruction) -> Action;
} Optionally relaxing checks or imposing strict limits, as in SPIRV-Tools:-pub fn validate_module(module: &mr::Module) -> Result<()>;
+pub fn validate_module(module: &mr::Module, options: Options) -> Result<()>; Where pub struct Options {
// Same universal limits options as SPIRV-Tools' validator
// Same lint-relaxing options as SPIRV-Tools' Validator
}
impl Default for Options {
pub fn default() -> Options {
Options {
// Universal limits default to their per-spec values
// Relaxing options default to false
}
}
} Are Options fields publicly visible? Is Options constructed with a Builder? If so, is it |
It is 2021, any efforts remained? |
@Danielmelody not in rspirv, but it's pretty easy to use spirv-val from Rust now, which is able to validate SPIR-V. spirv-tools-rs contains bindings for spirv-val and some of the other tools from SPIR-V Tools. |
We need a validator for SPIR-V code
The text was updated successfully, but these errors were encountered: