rusticl/program: add debugging option to disable SPIR-V validation
authorKarol Herbst <git@karolherbst.de>
Fri, 23 Jun 2023 00:05:38 +0000 (02:05 +0200)
committerMarge Bot <emma+marge@anholt.net>
Sat, 24 Jun 2023 01:52:07 +0000 (01:52 +0000)
This is useful for running applications known to pass in invalid SPIR-V.

Signed-off-by: Karol Herbst <git@karolherbst.de>
Reviewed-by: Nora Allen <blackcatgames@protonmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23818>

docs/envvars.rst
src/gallium/frontends/rusticl/core/platform.rs
src/gallium/frontends/rusticl/core/program.rs

index a7b44ef..e7cd7a6 100644 (file)
@@ -945,6 +945,7 @@ Rusticl environment variables
 
    a comma-separated list of debug channels to enable.
 
+   - ``allow_invalid_spirv`` disables validation of any input SPIR-V
    - ``clc`` dumps all OpenCL C source being compiled
    - ``program`` dumps compilation logs to stderr
 
index 93ae650..049cab2 100644 (file)
@@ -17,6 +17,7 @@ pub struct Platform {
 }
 
 pub struct PlatformDebug {
+    pub allow_invalid_spirv: bool,
     pub clc: bool,
     pub program: bool,
 }
@@ -57,6 +58,7 @@ static mut PLATFORM: Platform = Platform {
     devs: Vec::new(),
 };
 static mut PLATFORM_DBG: PlatformDebug = PlatformDebug {
+    allow_invalid_spirv: false,
     clc: false,
     program: false,
 };
@@ -70,6 +72,7 @@ fn load_env() {
     if let Ok(debug_flags) = env::var("RUSTICL_DEBUG") {
         for flag in debug_flags.split(',') {
             match flag {
+                "allow_invalid_spirv" => debug.allow_invalid_spirv = true,
                 "clc" => debug.clc = true,
                 "program" => debug.program = true,
                 _ => eprintln!("Unknown RUSTICL_DEBUG flag found: {}", flag),
index b75b510..fe04032 100644 (file)
@@ -559,7 +559,11 @@ impl Program {
                     // has to match CL_DEVICE_MAX_PARAMETER_SIZE
                     limit_max_function_arg: dev.param_max_size() as u32,
                 };
-                spirv.clone_on_validate(&options)
+                if Platform::dbg().allow_invalid_spirv {
+                    (Some(spirv.clone()), String::new())
+                } else {
+                    spirv.clone_on_validate(&options)
+                }
             }
             ProgramSourceType::Src(src) => {
                 let args = prepare_options(&options, dev);