gallium/auxiliary: Add util_format_get_depth_only() helper.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 30 Jul 2018 22:20:47 +0000 (15:20 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 15 Oct 2018 06:36:28 +0000 (23:36 -0700)
This will be used by u_transfer_helper.c shortly, in order to split
packed depth-stencil into separate resources.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/gallium/auxiliary/util/u_format.h

index f421222f85460a0ed054998a1633850496831d50..e66849c16b1589555a385726a713d077d1ef5d16 100644 (file)
@@ -557,6 +557,27 @@ util_format_is_depth_and_stencil(enum pipe_format format)
           util_format_has_stencil(desc);
 }
 
+/**
+ * For depth-stencil formats, return the equivalent depth-only format.
+ */
+static inline boolean
+util_format_get_depth_only(enum pipe_format format)
+{
+   switch (format) {
+   case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+      return PIPE_FORMAT_Z24X8_UNORM;
+
+   case PIPE_FORMAT_S8_UINT_Z24_UNORM:
+      return PIPE_FORMAT_X8Z24_UNORM;
+
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
+      return PIPE_FORMAT_Z32_FLOAT;
+
+   default:
+      return format;
+   }
+}
+
 static inline boolean
 util_format_is_yuv(enum pipe_format format)
 {