gallium/util: Move the Z/S handling to the outside of get_tile().
authorEric Anholt <eric@anholt.net>
Wed, 1 Jul 2020 23:48:54 +0000 (16:48 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 7 Jul 2020 18:19:22 +0000 (18:19 +0000)
This lets us drop the special case for S8_UINT, and makes our read_4 path
just like other callers.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5728>

src/gallium/auxiliary/util/u_tile.c

index c7cea07c8703e59ff4287d369735dcbbf12e1c62..58be4f1526fb21e33e07af15c5bedb5909132c1a 100644 (file)
@@ -414,60 +414,55 @@ pipe_get_tile_rgba(struct pipe_transfer *pt,
 
    pipe_get_tile_raw(pt, src, x, y, w, h, packed, 0);
 
-   /* softpipe's S8_UINT texture cache fetch needs to take the rgba_format
-    * path, not ui (since there's no ui unpack for s8, but it's technically
-    * pure integer).
-    */
-   if (util_format_is_pure_uint(format) &&
-       !util_format_is_depth_or_stencil(format)) {
-      util_format_read_4ui(format,
-                           dst, dst_stride * sizeof(float),
-                           packed, util_format_get_stride(format, w),
-                           0, 0, w, h);
-   } else if (util_format_is_pure_sint(format)) {
-      util_format_read_4i(format,
-                          dst, dst_stride * sizeof(float),
-                          packed, util_format_get_stride(format, w),
-                          0, 0, w, h);
-   } else {
-      switch (format) {
-      case PIPE_FORMAT_Z16_UNORM:
-         z16_get_tile_rgba((ushort *) packed, w, h, dst, dst_stride);
-         break;
-      case PIPE_FORMAT_Z32_UNORM:
-         z32_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
-         break;
-      case PIPE_FORMAT_Z24_UNORM_S8_UINT:
-      case PIPE_FORMAT_Z24X8_UNORM:
-         s8z24_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
-         break;
-      case PIPE_FORMAT_S8_UINT:
-         s8_get_tile_rgba((unsigned char *) packed, w, h, dst, dst_stride);
-         break;
-      case PIPE_FORMAT_X24S8_UINT:
-         s8x24_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
-         break;
-      case PIPE_FORMAT_S8_UINT_Z24_UNORM:
-      case PIPE_FORMAT_X8Z24_UNORM:
-         z24s8_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
-         break;
-      case PIPE_FORMAT_S8X24_UINT:
-         x24s8_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
-         break;
-      case PIPE_FORMAT_Z32_FLOAT:
-         z32f_get_tile_rgba((float *) packed, w, h, dst, dst_stride);
-         break;
-      case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
-         z32f_x24s8_get_tile_rgba((float *) packed, w, h, dst, dst_stride);
-         break;
-      case PIPE_FORMAT_X32_S8X24_UINT:
-         x32_s8_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
-         break;
-      default:
-         util_format_read_4f(format,
+   switch (format) {
+   case PIPE_FORMAT_Z16_UNORM:
+      z16_get_tile_rgba((ushort *) packed, w, h, dst, dst_stride);
+      break;
+   case PIPE_FORMAT_Z32_UNORM:
+      z32_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
+      break;
+   case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+   case PIPE_FORMAT_Z24X8_UNORM:
+      s8z24_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
+      break;
+   case PIPE_FORMAT_S8_UINT:
+      s8_get_tile_rgba((unsigned char *) packed, w, h, dst, dst_stride);
+      break;
+   case PIPE_FORMAT_X24S8_UINT:
+      s8x24_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
+      break;
+   case PIPE_FORMAT_S8_UINT_Z24_UNORM:
+   case PIPE_FORMAT_X8Z24_UNORM:
+      z24s8_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
+      break;
+   case PIPE_FORMAT_S8X24_UINT:
+      x24s8_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
+      break;
+   case PIPE_FORMAT_Z32_FLOAT:
+      z32f_get_tile_rgba((float *) packed, w, h, dst, dst_stride);
+      break;
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
+      z32f_x24s8_get_tile_rgba((float *) packed, w, h, dst, dst_stride);
+      break;
+   case PIPE_FORMAT_X32_S8X24_UINT:
+      x32_s8_get_tile_rgba((unsigned *) packed, w, h, dst, dst_stride);
+      break;
+   default:
+      if (util_format_is_pure_uint(format)) {
+         util_format_read_4ui(format,
+                              dst, dst_stride * sizeof(float),
+                              packed, util_format_get_stride(format, w),
+                              0, 0, w, h);
+      } else if (util_format_is_pure_sint(format)) {
+         util_format_read_4i(format,
                              dst, dst_stride * sizeof(float),
                              packed, util_format_get_stride(format, w),
                              0, 0, w, h);
+      } else {
+            util_format_read_4f(format,
+                                dst, dst_stride * sizeof(float),
+                                packed, util_format_get_stride(format, w),
+                                0, 0, w, h);
       }
    }