iris: Convert RGBX to RGBA for rendering.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 13 Aug 2018 23:41:19 +0000 (16:41 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:08 +0000 (10:26 -0800)
Fixes a bunch of RGB bugs.

src/gallium/drivers/iris/iris_formats.c
src/gallium/drivers/iris/iris_resource.h
src/gallium/drivers/iris/iris_state.c

index 7bb227175e0b80fc4ee80f6166371d6ce2f564ca..06c48a5583b163095870891dad4d9de5ef1401c5 100644 (file)
@@ -398,6 +398,26 @@ iris_isl_format_for_pipe_format(enum pipe_format pf)
    return table[pf];
 }
 
+enum isl_format
+iris_isl_format_for_usage(const struct gen_device_info *devinfo,
+                          enum pipe_format pformat,
+                          isl_surf_usage_flags_t usage)
+{
+   enum isl_format format = iris_isl_format_for_pipe_format(pformat);
+
+   /* Convert RGBX into RGBA for rendering or typed image access. */
+   if (isl_format_is_rgbx(format) &&
+       (((usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) &&
+         !isl_format_supports_rendering(devinfo, format)) ||
+        ((usage & ISL_SURF_USAGE_STORAGE_BIT) &&
+         !(isl_format_supports_typed_writes(devinfo, format) &&
+           isl_format_supports_typed_reads(devinfo, format))))) {
+      format = isl_format_rgbx_to_rgba(format);
+   }
+
+   return format;
+}
+
 /**
  * The pscreen->is_format_supported() driver hook.
  *
index c6e1e1de174a21b6ad627e4d48080401d9a3b76c..d34b28aae1789e2e3701204c5d5679944fdc90df 100644 (file)
@@ -87,6 +87,9 @@ iris_resource_bo(struct pipe_resource *p_res)
 }
 
 enum isl_format iris_isl_format_for_pipe_format(enum pipe_format pf);
+enum isl_format iris_isl_format_for_usage(const struct gen_device_info *,
+                                          enum pipe_format,
+                                          isl_surf_usage_flags_t usage);
 
 struct pipe_resource *iris_resource_get_separate_stencil(struct pipe_resource *);
 
index c8ae43fa01dc8f80373e6d242410019a5cde1788..115b2d34655dcfa6297dbea0175a04c7c0904c31 100644 (file)
@@ -1328,24 +1328,25 @@ iris_create_surface(struct pipe_context *ctx,
    psurf->u.tex.last_layer = tmpl->u.tex.last_layer;
    psurf->u.tex.level = tmpl->u.tex.level;
 
-   enum isl_format isl_format = iris_isl_format_for_pipe_format(psurf->format);
-
-   unsigned usage = 0;
+   isl_surf_usage_flags_t usage = 0;
    if (tmpl->writable)
       usage = ISL_SURF_USAGE_STORAGE_BIT;
    else if (util_format_is_depth_or_stencil(tmpl->format))
       usage = ISL_SURF_USAGE_DEPTH_BIT;
-   else {
+   else
       usage = ISL_SURF_USAGE_RENDER_TARGET_BIT;
 
-      if (!isl_format_supports_rendering(devinfo, isl_format)) {
-         /* Framebuffer validation will reject this invalid case, but it
-          * hasn't had the opportunity yet.  In the meantime, we need to
-          * avoid hitting ISL asserts about unsupported formats below.
-          */
-         free(surf);
-         return NULL;
-      }
+   enum isl_format isl_format =
+      iris_isl_format_for_usage(devinfo, psurf->format, usage);
+
+   if ((usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) &&
+       !isl_format_supports_rendering(devinfo, isl_format)) {
+      /* Framebuffer validation will reject this invalid case, but it
+       * hasn't had the opportunity yet.  In the meantime, we need to
+       * avoid hitting ISL asserts about unsupported formats below.
+       */
+      free(surf);
+      return NULL;
    }
 
    surf->view = (struct isl_view) {