clover: Move min image support check
authorRob Clark <robdclark@chromium.org>
Sun, 26 Dec 2021 20:45:49 +0000 (12:45 -0800)
committerMarge Bot <emma+marge@anholt.net>
Tue, 4 Jan 2022 16:56:25 +0000 (16:56 +0000)
If the gallium driver supports images, but not the minimum image
requirements for CL, then simply don't claim to support images.  This
is better than not claiming to support CL at all.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14310>

src/gallium/frontends/clover/core/device.cpp

index 2e3d77d..f7183b5 100644 (file)
@@ -76,13 +76,7 @@ namespace {
           dev.max_const_buffer_size() < 64 * 1024 ||
           dev.max_const_buffers() < 8 ||
           dev.max_mem_local() < 16 * 1024 ||
-          dev.clc_version < CL_MAKE_VERSION(1, 0, 0) ||
-          (supports_images &&
-           (dev.max_images_read() < 128 ||
-            dev.max_images_write() < 8 ||
-            dev.max_image_size() < 8192 ||
-            dev.max_image_size_3d() < 2048 ||
-            dev.max_samplers() < 16))) {
+          dev.clc_version < CL_MAKE_VERSION(1, 0, 0)) {
          return version;
       }
       version = CL_MAKE_VERSION(1, 0, 0);
@@ -318,8 +312,23 @@ device::max_printf_buffer_size() const {
 
 bool
 device::image_support() const {
-   return get_compute_param<uint32_t>(pipe, ir_format(),
-                                      PIPE_COMPUTE_CAP_IMAGES_SUPPORTED)[0];
+   bool supports_images = get_compute_param<uint32_t>(pipe, ir_format(),
+                                                      PIPE_COMPUTE_CAP_IMAGES_SUPPORTED)[0];
+   if (!supports_images)
+      return false;
+
+   /* If the gallium driver supports images, but does not support the
+    * minimum requirements for opencl 1.0 images, then don't claim to
+    * support images.
+    */
+   if (max_images_read() < 128 ||
+       max_images_write() < 8 ||
+       max_image_size() < 8192 ||
+       max_image_size_3d() < 2048 ||
+       max_samplers() < 16)
+      return false;
+
+   return true;
 }
 
 bool