[virglrenderer-devel] [PATCH 10/16] vrend: Add code to dump formats

Jakob Bornecrantz jakob.bornecrantz at collabora.com
Fri Dec 22 18:57:50 UTC 2017


When debugging various drivers it is good to see what format they support.

Signed-off-by: Jakob Bornecrantz <jakob.bornecrantz at collabora.com>
---
 src/Makefile.am      |   1 +
 src/vrend_dump.c     | 196 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/vrend_renderer.c |  22 ++++++
 src/vrend_renderer.h |   4 ++
 4 files changed, 223 insertions(+)
 create mode 100644 src/vrend_dump.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 3ec8358..607044f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,6 +31,7 @@ libvrend_la_SOURCES = \
         vrend_formats.c \
         vrend_blitter.c \
         vrend_blitter.h \
+        vrend_dump.c \
         iov.c
 
 if !OS_WIN32
diff --git a/src/vrend_dump.c b/src/vrend_dump.c
new file mode 100644
index 0000000..db46714
--- /dev/null
+++ b/src/vrend_dump.c
@@ -0,0 +1,196 @@
+/**************************************************************************
+ *
+ * Copyright (C) 2014 Collabora Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <epoxy/gl.h>
+
+#include "vrend_renderer.h"
+
+#include <stdio.h>
+
+
+void vrend_dump_format(const struct vrend_format_table *format)
+{
+   bool pipe = false;
+
+   fprintf(stderr, "%s: ", vrend_dump_format_to_str(format->format));
+
+   if (format->bindings & VREND_BIND_SAMPLER) {
+      fprintf(stderr, "%sVREND_BIND_SAMPLER", pipe ? " | " : "");
+      pipe = true;
+   }
+
+   if (format->bindings & VREND_BIND_RENDER) {
+      fprintf(stderr, "%sVREND_BIND_RENDER", pipe ? " | " : "");
+      pipe = true;
+   }
+
+   if (format->bindings & VREND_BIND_DEPTHSTENCIL) {
+      fprintf(stderr, "%sVREND_BIND_DEPTHSTENCIL", pipe ? " | " : "");
+      pipe = true;
+   }
+
+   fprintf(stderr, "\n");
+}
+
+const char* vrend_dump_format_to_str(enum virgl_formats format)
+{
+   switch (format) {
+   case VIRGL_FORMAT_B8G8R8A8_UNORM:       return "VIRGL_FORMAT_B8G8R8A8_UNORM";
+   case VIRGL_FORMAT_B8G8R8X8_UNORM:       return "VIRGL_FORMAT_B8G8R8X8_UNORM";
+   case VIRGL_FORMAT_A8R8G8B8_UNORM:       return "VIRGL_FORMAT_A8R8G8B8_UNORM";
+   case VIRGL_FORMAT_X8R8G8B8_UNORM:       return "VIRGL_FORMAT_X8R8G8B8_UNORM";
+   case VIRGL_FORMAT_B5G5R5A1_UNORM:       return "VIRGL_FORMAT_B5G5R5A1_UNORM";
+   case VIRGL_FORMAT_B4G4R4A4_UNORM:       return "VIRGL_FORMAT_B4G4R4A4_UNORM";
+   case VIRGL_FORMAT_B5G6R5_UNORM:         return "VIRGL_FORMAT_B5G6R5_UNORM";
+   case VIRGL_FORMAT_L8_UNORM:             return "VIRGL_FORMAT_L8_UNORM";
+   case VIRGL_FORMAT_A8_UNORM:             return "VIRGL_FORMAT_A8_UNORM";
+   case VIRGL_FORMAT_L8A8_UNORM:           return "VIRGL_FORMAT_L8A8_UNORM";
+   case VIRGL_FORMAT_L16_UNORM:            return "VIRGL_FORMAT_L16_UNORM";
+   case VIRGL_FORMAT_Z16_UNORM:            return "VIRGL_FORMAT_Z16_UNORM";
+   case VIRGL_FORMAT_Z32_UNORM:            return "VIRGL_FORMAT_Z32_UNORM";
+   case VIRGL_FORMAT_Z32_FLOAT:            return "VIRGL_FORMAT_Z32_FLOAT";
+   case VIRGL_FORMAT_Z24_UNORM_S8_UINT:    return "VIRGL_FORMAT_Z24_UNORM_S8_UINT";
+   case VIRGL_FORMAT_S8_UINT_Z24_UNORM:    return "VIRGL_FORMAT_S8_UINT_Z24_UNORM";
+   case VIRGL_FORMAT_Z24X8_UNORM:          return "VIRGL_FORMAT_Z24X8_UNORM";
+   case VIRGL_FORMAT_S8_UINT:              return "VIRGL_FORMAT_S8_UINT";
+   case VIRGL_FORMAT_R32_FLOAT:            return "VIRGL_FORMAT_R32_FLOAT";
+   case VIRGL_FORMAT_R32G32_FLOAT:         return "VIRGL_FORMAT_R32G32_FLOAT";
+   case VIRGL_FORMAT_R32G32B32_FLOAT:      return "VIRGL_FORMAT_R32G32B32_FLOAT";
+   case VIRGL_FORMAT_R32G32B32A32_FLOAT:   return "VIRGL_FORMAT_R32G32B32A32_FLOAT";
+   case VIRGL_FORMAT_R16_UNORM:            return "VIRGL_FORMAT_R16_UNORM";
+   case VIRGL_FORMAT_R16G16_UNORM:         return "VIRGL_FORMAT_R16G16_UNORM";
+   case VIRGL_FORMAT_R16G16B16A16_UNORM:   return "VIRGL_FORMAT_R16G16B16A16_UNORM";
+   case VIRGL_FORMAT_R16_SNORM:            return "VIRGL_FORMAT_R16_SNORM";
+   case VIRGL_FORMAT_R16G16_SNORM:         return "VIRGL_FORMAT_R16G16_SNORM";
+   case VIRGL_FORMAT_R16G16B16A16_SNORM:   return "VIRGL_FORMAT_R16G16B16A16_SNORM";
+   case VIRGL_FORMAT_R8_UNORM:             return "VIRGL_FORMAT_R8_UNORM";
+   case VIRGL_FORMAT_R8G8_UNORM:           return "VIRGL_FORMAT_R8G8_UNORM";
+   case VIRGL_FORMAT_R8G8B8A8_UNORM:       return "VIRGL_FORMAT_R8G8B8A8_UNORM";
+   case VIRGL_FORMAT_R8_SNORM:             return "VIRGL_FORMAT_R8_SNORM";
+   case VIRGL_FORMAT_R8G8_SNORM:           return "VIRGL_FORMAT_R8G8_SNORM";
+   case VIRGL_FORMAT_R8G8B8_SNORM:         return "VIRGL_FORMAT_R8G8B8_SNORM";
+   case VIRGL_FORMAT_R8G8B8A8_SNORM:       return "VIRGL_FORMAT_R8G8B8A8_SNORM";
+   case VIRGL_FORMAT_R16_FLOAT:            return "VIRGL_FORMAT_R16_FLOAT";
+   case VIRGL_FORMAT_R16G16_FLOAT:         return "VIRGL_FORMAT_R16G16_FLOAT";
+   case VIRGL_FORMAT_R16G16B16_FLOAT:      return "VIRGL_FORMAT_R16G16B16_FLOAT";
+   case VIRGL_FORMAT_R16G16B16A16_FLOAT:   return "VIRGL_FORMAT_R16G16B16A16_FLOAT";
+   case VIRGL_FORMAT_L8_SRGB:              return "VIRGL_FORMAT_L8_SRGB";
+   case VIRGL_FORMAT_L8A8_SRGB:            return "VIRGL_FORMAT_L8A8_SRGB";
+   case VIRGL_FORMAT_B8G8R8A8_SRGB:        return "VIRGL_FORMAT_B8G8R8A8_SRGB";
+   case VIRGL_FORMAT_B8G8R8X8_SRGB:        return "VIRGL_FORMAT_B8G8R8X8_SRGB";
+   case VIRGL_FORMAT_DXT1_RGB:             return "VIRGL_FORMAT_DXT1_RGB";
+   case VIRGL_FORMAT_DXT1_RGBA:            return "VIRGL_FORMAT_DXT1_RGBA";
+   case VIRGL_FORMAT_DXT3_RGBA:            return "VIRGL_FORMAT_DXT3_RGBA";
+   case VIRGL_FORMAT_DXT5_RGBA:            return "VIRGL_FORMAT_DXT5_RGBA";
+   case VIRGL_FORMAT_DXT1_SRGB:            return "VIRGL_FORMAT_DXT1_SRGB";
+   case VIRGL_FORMAT_DXT1_SRGBA:           return "VIRGL_FORMAT_DXT1_SRGBA";
+   case VIRGL_FORMAT_DXT3_SRGBA:           return "VIRGL_FORMAT_DXT3_SRGBA";
+   case VIRGL_FORMAT_DXT5_SRGBA:           return "VIRGL_FORMAT_DXT5_SRGBA";
+   case VIRGL_FORMAT_RGTC1_UNORM:          return "VIRGL_FORMAT_RGTC1_UNORM";
+   case VIRGL_FORMAT_RGTC1_SNORM:          return "VIRGL_FORMAT_RGTC1_SNORM";
+   case VIRGL_FORMAT_RGTC2_UNORM:          return "VIRGL_FORMAT_RGTC2_UNORM";
+   case VIRGL_FORMAT_RGTC2_SNORM:          return "VIRGL_FORMAT_RGTC2_SNORM";
+   case VIRGL_FORMAT_A8B8G8R8_UNORM:       return "VIRGL_FORMAT_A8B8G8R8_UNORM";
+   case VIRGL_FORMAT_B5G5R5X1_UNORM:       return "VIRGL_FORMAT_B5G5R5X1_UNORM";
+   case VIRGL_FORMAT_R11G11B10_FLOAT:      return "VIRGL_FORMAT_R11G11B10_FLOAT";
+   case VIRGL_FORMAT_R9G9B9E5_FLOAT:       return "VIRGL_FORMAT_R9G9B9E5_FLOAT";
+   case VIRGL_FORMAT_Z32_FLOAT_S8X24_UINT: return "VIRGL_FORMAT_Z32_FLOAT_S8X24_UINT";
+   case VIRGL_FORMAT_B10G10R10A2_UNORM:    return "VIRGL_FORMAT_B10G10R10A2_UNORM";
+   case VIRGL_FORMAT_R8G8B8X8_UNORM:       return "VIRGL_FORMAT_R8G8B8X8_UNORM";
+   case VIRGL_FORMAT_B4G4R4X4_UNORM:       return "VIRGL_FORMAT_B4G4R4X4_UNORM";
+   case VIRGL_FORMAT_X24S8_UINT:           return "VIRGL_FORMAT_X24S8_UINT";
+   case VIRGL_FORMAT_S8X24_UINT:           return "VIRGL_FORMAT_S8X24_UINT";
+   case VIRGL_FORMAT_B2G3R3_UNORM:         return "VIRGL_FORMAT_B2G3R3_UNORM";
+   case VIRGL_FORMAT_L16A16_UNORM:         return "VIRGL_FORMAT_L16A16_UNORM";
+   case VIRGL_FORMAT_A16_UNORM:            return "VIRGL_FORMAT_A16_UNORM";
+   case VIRGL_FORMAT_A8_SNORM:             return "VIRGL_FORMAT_A8_SNORM";
+   case VIRGL_FORMAT_L8_SNORM:             return "VIRGL_FORMAT_L8_SNORM";
+   case VIRGL_FORMAT_L8A8_SNORM:           return "VIRGL_FORMAT_L8A8_SNORM";
+   case VIRGL_FORMAT_A16_SNORM:            return "VIRGL_FORMAT_A16_SNORM";
+   case VIRGL_FORMAT_L16_SNORM:            return "VIRGL_FORMAT_L16_SNORM";
+   case VIRGL_FORMAT_L16A16_SNORM:         return "VIRGL_FORMAT_L16A16_SNORM";
+   case VIRGL_FORMAT_A16_FLOAT:            return "VIRGL_FORMAT_A16_FLOAT";
+   case VIRGL_FORMAT_L16_FLOAT:            return "VIRGL_FORMAT_L16_FLOAT";
+   case VIRGL_FORMAT_L16A16_FLOAT:         return "VIRGL_FORMAT_L16A16_FLOAT";
+   case VIRGL_FORMAT_A32_FLOAT:            return "VIRGL_FORMAT_A32_FLOAT";
+   case VIRGL_FORMAT_L32_FLOAT:            return "VIRGL_FORMAT_L32_FLOAT";
+   case VIRGL_FORMAT_L32A32_FLOAT:         return "VIRGL_FORMAT_L32A32_FLOAT";
+   case VIRGL_FORMAT_R8_UINT:              return "VIRGL_FORMAT_R8_UINT";
+   case VIRGL_FORMAT_R8G8_UINT:            return "VIRGL_FORMAT_R8G8_UINT";
+   case VIRGL_FORMAT_R8G8B8_UINT:          return "VIRGL_FORMAT_R8G8B8_UINT";
+   case VIRGL_FORMAT_R8G8B8A8_UINT:        return "VIRGL_FORMAT_R8G8B8A8_UINT";
+   case VIRGL_FORMAT_R8_SINT:              return "VIRGL_FORMAT_R8_SINT";
+   case VIRGL_FORMAT_R8G8_SINT:            return "VIRGL_FORMAT_R8G8_SINT";
+   case VIRGL_FORMAT_R8G8B8_SINT:          return "VIRGL_FORMAT_R8G8B8_SINT";
+   case VIRGL_FORMAT_R8G8B8A8_SINT:        return "VIRGL_FORMAT_R8G8B8A8_SINT";
+   case VIRGL_FORMAT_R16_UINT:             return "VIRGL_FORMAT_R16_UINT";
+   case VIRGL_FORMAT_R16G16_UINT:          return "VIRGL_FORMAT_R16G16_UINT";
+   case VIRGL_FORMAT_R16G16B16_UINT:       return "VIRGL_FORMAT_R16G16B16_UINT";
+   case VIRGL_FORMAT_R16G16B16A16_UINT:    return "VIRGL_FORMAT_R16G16B16A16_UINT";
+   case VIRGL_FORMAT_R16_SINT:             return "VIRGL_FORMAT_R16_SINT";
+   case VIRGL_FORMAT_R16G16_SINT:          return "VIRGL_FORMAT_R16G16_SINT";
+   case VIRGL_FORMAT_R16G16B16_SINT:       return "VIRGL_FORMAT_R16G16B16_SINT";
+   case VIRGL_FORMAT_R16G16B16A16_SINT:    return "VIRGL_FORMAT_R16G16B16A16_SINT";
+   case VIRGL_FORMAT_R32_UINT:             return "VIRGL_FORMAT_R32_UINT";
+   case VIRGL_FORMAT_R32G32_UINT:          return "VIRGL_FORMAT_R32G32_UINT";
+   case VIRGL_FORMAT_R32G32B32_UINT:       return "VIRGL_FORMAT_R32G32B32_UINT";
+   case VIRGL_FORMAT_R32G32B32A32_UINT:    return "VIRGL_FORMAT_R32G32B32A32_UINT";
+   case VIRGL_FORMAT_R32_SINT:             return "VIRGL_FORMAT_R32_SINT";
+   case VIRGL_FORMAT_R32G32_SINT:          return "VIRGL_FORMAT_R32G32_SINT";
+   case VIRGL_FORMAT_R32G32B32_SINT:       return "VIRGL_FORMAT_R32G32B32_SINT";
+   case VIRGL_FORMAT_R32G32B32A32_SINT:    return "VIRGL_FORMAT_R32G32B32A32_SINT";
+   case VIRGL_FORMAT_A8_UINT:              return "VIRGL_FORMAT_A8_UINT";
+   case VIRGL_FORMAT_L8_UINT:              return "VIRGL_FORMAT_L8_UINT";
+   case VIRGL_FORMAT_L8A8_UINT:            return "VIRGL_FORMAT_L8A8_UINT";
+   case VIRGL_FORMAT_A8_SINT:              return "VIRGL_FORMAT_A8_SINT";
+   case VIRGL_FORMAT_L8_SINT:              return "VIRGL_FORMAT_L8_SINT";
+   case VIRGL_FORMAT_L8A8_SINT:            return "VIRGL_FORMAT_L8A8_SINT";
+   case VIRGL_FORMAT_A16_UINT:             return "VIRGL_FORMAT_A16_UINT";
+   case VIRGL_FORMAT_L16_UINT:             return "VIRGL_FORMAT_L16_UINT";
+   case VIRGL_FORMAT_L16A16_UINT:          return "VIRGL_FORMAT_L16A16_UINT";
+   case VIRGL_FORMAT_A16_SINT:             return "VIRGL_FORMAT_A16_SINT";
+   case VIRGL_FORMAT_L16_SINT:             return "VIRGL_FORMAT_L16_SINT";
+   case VIRGL_FORMAT_L16A16_SINT:          return "VIRGL_FORMAT_L16A16_SINT";
+   case VIRGL_FORMAT_A32_UINT:             return "VIRGL_FORMAT_A32_UINT";
+   case VIRGL_FORMAT_L32_UINT:             return "VIRGL_FORMAT_L32_UINT";
+   case VIRGL_FORMAT_L32A32_UINT:          return "VIRGL_FORMAT_L32A32_UINT";
+   case VIRGL_FORMAT_A32_SINT:             return "VIRGL_FORMAT_A32_SINT";
+   case VIRGL_FORMAT_L32_SINT:             return "VIRGL_FORMAT_L32_SINT";
+   case VIRGL_FORMAT_L32A32_SINT:          return "VIRGL_FORMAT_L32A32_SINT";
+   case VIRGL_FORMAT_B10G10R10A2_UINT:     return "VIRGL_FORMAT_B10G10R10A2_UINT";
+   case VIRGL_FORMAT_R8G8B8X8_SNORM:       return "VIRGL_FORMAT_R8G8B8X8_SNORM";
+   case VIRGL_FORMAT_R8G8B8X8_SRGB:        return "VIRGL_FORMAT_R8G8B8X8_SRGB";
+   case VIRGL_FORMAT_B10G10R10X2_UNORM:    return "VIRGL_FORMAT_B10G10R10X2_UNORM";
+   case VIRGL_FORMAT_R16G16B16X16_UNORM:   return "VIRGL_FORMAT_R16G16B16X16_UNORM";
+   case VIRGL_FORMAT_R16G16B16X16_SNORM:   return "VIRGL_FORMAT_R16G16B16X16_SNORM";
+   case VIRGL_FORMAT_BPTC_RGBA_UNORM:      return "VIRGL_FORMAT_BPTC_RGBA_UNORM";
+   case VIRGL_FORMAT_BPTC_SRGBA:           return "VIRGL_FORMAT_BPTC_SRGBA";
+   case VIRGL_FORMAT_BPTC_RGB_FLOAT:       return "VIRGL_FORMAT_BPTC_RGB_FLOAT";
+   case VIRGL_FORMAT_BPTC_RGB_UFLOAT:      return "VIRGL_FORMAT_BPTC_RGB_UFLOAT";
+   default:                                return NULL;
+   }
+}
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 1ca957f..9354533 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -61,6 +61,9 @@
 /* debugging aid to dump shaders */
 int vrend_dump_shaders;
 
+/* debugging aid to dump caps and formats */
+int vrend_dump_caps = 0;
+
 /* debugging via KHR_debug extension */
 int vrend_use_debug_cb = 0;
 
@@ -425,6 +428,7 @@ static void vrend_apply_sampler_state(struct vrend_context *ctx,
                                       uint32_t shader_type,
                                       int id, int sampler_id, uint32_t srgb_decode);
 void vrend_update_stencil_state(struct vrend_context *ctx);
+static void vrend_dump_formats(void);
 
 static struct vrend_format_table tex_conv_table[VIRGL_FORMAT_MAX];
 
@@ -632,6 +636,20 @@ vrend_insert_format_swizzle(int override_format, struct vrend_format_table *entr
       tex_conv_table[override_format].swizzle[i] = swizzle[i];
 }
 
+void vrend_dump_formats(void)
+{
+   for (int i = 0; i < VIRGL_FORMAT_MAX; i++) {
+      bool pipe = false;
+
+      const char *str = vrend_dump_format_to_str(i);
+      if (str == NULL) {
+        continue;
+      }
+
+      vrend_dump_format(&tex_conv_table[i]);
+   }
+}
+
 static bool vrend_is_timer_query(GLenum gltype)
 {
    return gltype == GL_TIMESTAMP ||
@@ -3943,6 +3961,10 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags)
       glDisable(GL_DEBUG_OUTPUT);
    }
 
+   if (vrend_dump_caps) {
+      vrend_dump_formats();
+   }
+
    vrend_clicbs->destroy_gl_context(gl_context);
    list_inithead(&vrend_state.fence_list);
    list_inithead(&vrend_state.fence_wait_list);
diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h
index e6131d1..9874ad2 100644
--- a/src/vrend_renderer.h
+++ b/src/vrend_renderer.h
@@ -136,6 +136,10 @@ int vrend_renderer_context_create(uint32_t handle, uint32_t nlen, const char *na
 void vrend_renderer_context_create_internal(uint32_t handle, uint32_t nlen, const char *name);
 void vrend_renderer_context_destroy(uint32_t handle);
 
+void vrend_dump_format(const struct vrend_format_table *format);
+const char* vrend_dump_format_to_str(enum virgl_formats format);
+
+
 /* virgl bind flags - these are compatible with mesa 10.5 gallium.
    but are fixed, no other should be passed to virgl either. */
 #define VREND_RES_BIND_DEPTH_STENCIL (1 << 0)
-- 
2.11.0



More information about the virglrenderer-devel mailing list