etnaviv: Rework resource status tracking
[mesa.git] / src / gallium / drivers / freedreno / freedreno_util.c
index c8f2127c9100203df7d06fd03f7b11d887b0ba44..74e9f9a7187c8c818b7b40a206e3059b51790cca 100644 (file)
@@ -1,5 +1,3 @@
-/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
-
 /*
  * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
  *
@@ -67,6 +65,26 @@ fd_pipe2index(enum pipe_format format)
        }
 }
 
+/* we need to special case a bit the depth/stencil restore, because we are
+ * using the texture sampler to blit into the depth/stencil buffer, *not*
+ * into a color buffer.  Otherwise fdN_tex_swiz() will do the wrong thing,
+ * as it is assuming that you are sampling into normal render target..
+ */
+enum pipe_format
+fd_gmem_restore_format(enum pipe_format format)
+{
+       switch (format) {
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+               return PIPE_FORMAT_R8G8B8A8_UNORM;
+       case PIPE_FORMAT_Z16_UNORM:
+               return PIPE_FORMAT_R8G8_UNORM;
+       case PIPE_FORMAT_S8_UINT:
+               return PIPE_FORMAT_R8_UNORM;
+       default:
+               return format;
+       }
+}
 
 enum adreno_rb_blend_factor
 fd_blend_factor(unsigned factor)