llvmpipe: Add lp_storage_render_image_format_supported
authorKonstantin Seurer <konstantin.seurer@gmail.com>
Fri, 21 Apr 2023 09:43:53 +0000 (11:43 +0200)
committerMarge Bot <emma+marge@anholt.net>
Thu, 8 Jun 2023 06:07:37 +0000 (06:07 +0000)
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23515>

src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_screen.h

index 56b515d..e0940c3 100644 (file)
@@ -673,6 +673,37 @@ llvmpipe_get_compiler_options(struct pipe_screen *screen,
 
 
 bool
+lp_storage_render_image_format_supported(enum pipe_format format)
+{
+   const struct util_format_description *format_desc = util_format_description(format);
+
+   if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
+      /* this is a lie actually other formats COULD exist where we would fail */
+      if (format_desc->nr_channels < 3)
+         return false;
+   } else if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB) {
+      return false;
+   }
+
+   if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN &&
+       format != PIPE_FORMAT_R11G11B10_FLOAT)
+      return false;
+
+   assert(format_desc->block.width == 1);
+   assert(format_desc->block.height == 1);
+
+   if (format_desc->is_mixed)
+      return false;
+
+   if (!format_desc->is_array && !format_desc->is_bitmask &&
+       format != PIPE_FORMAT_R11G11B10_FLOAT)
+      return false;
+
+   return true;
+}
+
+
+bool
 lp_storage_image_format_supported(enum pipe_format format)
 {
    switch (format) {
@@ -754,30 +785,10 @@ llvmpipe_is_format_supported(struct pipe_screen *_screen,
    if (sample_count != 0 && sample_count != 1 && sample_count != 4)
       return false;
 
-   if (bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SHADER_IMAGE)) {
-      if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
-         /* this is a lie actually other formats COULD exist where we would fail */
-         if (format_desc->nr_channels < 3)
-            return false;
-      } else if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB) {
-         return false;
-      }
-
-      if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN &&
-          format != PIPE_FORMAT_R11G11B10_FLOAT)
-         return false;
-
-      assert(format_desc->block.width == 1);
-      assert(format_desc->block.height == 1);
-
-      if (format_desc->is_mixed)
+   if (bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SHADER_IMAGE))
+      if (!lp_storage_render_image_format_supported(format))
          return false;
 
-      if (!format_desc->is_array && !format_desc->is_bitmask &&
-          format != PIPE_FORMAT_R11G11B10_FLOAT)
-         return false;
-   }
-
    if (bind & PIPE_BIND_SHADER_IMAGE) {
       if (!lp_storage_image_format_supported(format))
          return false;
index 82aeb3d..0480dfa 100644 (file)
@@ -108,6 +108,10 @@ lp_get_constant_buffer_stride(struct pipe_screen *_screen)
 
 
 bool
+lp_storage_render_image_format_supported(enum pipe_format format);
+
+
+bool
 lp_storage_image_format_supported(enum pipe_format format);