clover: Allow overriding platform/device version numbers
authorAaron Watry <awatry@gmail.com>
Thu, 10 Aug 2017 03:02:30 +0000 (22:02 -0500)
committerAaron Watry <awatry@gmail.com>
Tue, 6 Mar 2018 02:09:46 +0000 (20:09 -0600)
Useful for testing API, builtin library, and device completeness of
not-yet-supported versions.

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Pierre Moreau <pierre.morrow@free.fr>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
(v3) Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Jan Vesely <jan.vesely@rutgers.edu>
v4: Remove redundant std::string wrapper around debug_get_option calls
v3: mark CL version overrides as static and const
v2: Make version_string in platform const in case

src/gallium/state_trackers/clover/api/platform.cpp
src/gallium/state_trackers/clover/core/device.cpp

index ed861633116dc88b3ff7d1fa78a6653f2c35f13d..3b96b03fde81083e0d04c916f246edeae0df7fd9 100644 (file)
@@ -23,6 +23,7 @@
 #include "api/util.hpp"
 #include "core/platform.hpp"
 #include "git_sha1.h"
+#include "util/u_debug.h"
 
 using namespace clover;
 
@@ -57,14 +58,17 @@ clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
       buf.as_string() = "FULL_PROFILE";
       break;
 
-   case CL_PLATFORM_VERSION:
-      buf.as_string() = "OpenCL 1.1 Mesa " PACKAGE_VERSION
+   case CL_PLATFORM_VERSION: {
+      static const std::string version_string =
+            debug_get_option("CLOVER_PLATFORM_VERSION_OVERRIDE", "1.1");
+
+      buf.as_string() = "OpenCL " + version_string + " Mesa " PACKAGE_VERSION
 #ifdef MESA_GIT_SHA1
                         " (" MESA_GIT_SHA1 ")"
 #endif
                         ;
       break;
-
+   }
    case CL_PLATFORM_NAME:
       buf.as_string() = "Clover";
       break;
index 71cf4bf60af6fe0344630f67e41b3b22bd7fc8e6..0d911e375143c1aae00720b51a36673857b96014 100644 (file)
@@ -25,6 +25,7 @@
 #include "core/platform.hpp"
 #include "pipe/p_screen.h"
 #include "pipe/p_state.h"
+#include "util/u_debug.h"
 
 using namespace clover;
 
@@ -268,10 +269,14 @@ device::endianness() const {
 
 std::string
 device::device_version() const {
-    return "1.1";
+   static const std::string device_version =
+         debug_get_option("CLOVER_DEVICE_VERSION_OVERRIDE", "1.1");
+   return device_version;
 }
 
 std::string
 device::device_clc_version() const {
-    return "1.1";
+   static const std::string device_clc_version =
+         debug_get_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", "1.1");
+   return device_clc_version;
 }