rusticl/device: allow enablement of fp64 via RUSTICL_FEATURES
authorKarol Herbst <kherbst@redhat.com>
Mon, 24 Apr 2023 11:08:07 +0000 (13:08 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 25 Apr 2023 04:27:57 +0000 (04:27 +0000)
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22649>

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

index 0c0c0e4..ae1ba9a 100644 (file)
@@ -915,6 +915,8 @@ Rusticl environment variables
    a comma-separated list of features to enable. Those are disabled by default
    as they might not be stable enough or break OpenCL conformance.
 
+   - ``fp64`` enables OpenCL double support
+
 .. envvar:: RUSTICL_DEBUG
 
    a comma-separated list of debug channels to enable.
index 35711d3..bd2d0da 100644 (file)
@@ -1,6 +1,7 @@
 use crate::api::icd::*;
 use crate::api::util::*;
 use crate::core::format::*;
+use crate::core::platform::*;
 use crate::core::util::*;
 use crate::core::version::*;
 use crate::impl_cl_type_trait;
@@ -582,11 +583,11 @@ impl Device {
     }
 
     pub fn doubles_supported(&self) -> bool {
-        false
-        /*
+        if !Platform::features().fp64 {
+            return false;
+        }
 
         self.screen.param(pipe_cap::PIPE_CAP_DOUBLES) == 1
-        */
     }
 
     pub fn doubles_is_softfp(&self) -> bool {
index c5873e8..2126dfa 100644 (file)
@@ -21,7 +21,9 @@ pub struct PlatformDebug {
     pub program: bool,
 }
 
-pub struct PlatformFeatures {}
+pub struct PlatformFeatures {
+    pub fp64: bool,
+}
 
 static PLATFORM_ENV_ONCE: Once = Once::new();
 static PLATFORM_ONCE: Once = Once::new();
@@ -35,7 +37,7 @@ static mut PLATFORM: Platform = Platform {
     devs: Vec::new(),
 };
 static mut PLATFORM_DBG: PlatformDebug = PlatformDebug { program: false };
-static mut PLATFORM_FEATURES: PlatformFeatures = PlatformFeatures {};
+static mut PLATFORM_FEATURES: PlatformFeatures = PlatformFeatures { fp64: false };
 
 fn load_env() {
     let debug = unsafe { &mut PLATFORM_DBG };
@@ -52,6 +54,7 @@ fn load_env() {
     if let Ok(feature_flags) = env::var("RUSTICL_FEATURES") {
         for flag in feature_flags.split(',') {
             match flag {
+                "fp64" => features.fp64 = true,
                 _ => eprintln!("Unknown RUSTICL_FEATURES flag found: {}", flag),
             }
         }