<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 16, 2016 at 12:56 AM, Jordan Justen <span dir="ltr"><<a href="mailto:jordan.l.justen@intel.com" target="_blank">jordan.l.justen@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Jordan Justen <<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>><br>
---<br>
src/intel/Makefile.sources | 1 +<br>
src/intel/isl/isl.h | 14 +++<br>
src/intel/isl/isl_dump.c | 217 ++++++++++++++++++++++++++++++<wbr>+++++++++++++++<br>
3 files changed, 232 insertions(+)<br>
create mode 100644 src/intel/isl/isl_dump.c<br>
<br>
diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources<br>
index c1740fe..6ea838f 100644<br>
--- a/src/intel/Makefile.sources<br>
+++ b/src/intel/Makefile.sources<br>
@@ -33,6 +33,7 @@ AUBINATOR_GENERATED_FILES = \<br>
ISL_FILES = \<br>
isl/isl.c \<br>
isl/isl.h \<br>
+ isl/isl_dump.c \<br>
isl/isl_format.c \<br>
isl/isl_priv.h \<br>
isl/isl_storage_image.c<br>
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h<br>
index 11ad891..4986137 100644<br>
--- a/src/intel/isl/isl.h<br>
+++ b/src/intel/isl/isl.h<br>
@@ -1475,6 +1475,20 @@ uint32_t<br>
isl_surf_get_depth_format(<wbr>const struct isl_device *dev,<br>
const struct isl_surf *surf);<br>
<br>
+/**<br>
+ * @brief Save the isl_surf information out to files for debug purposes.<br>
+ *<br>
+ */<br>
+void<br>
+isl_dump_surf(const struct isl_device *dev,<br>
+ const struct isl_surf *surf,<br>
+ const void *map_addr,<br>
+ unsigned int map_size,<br>
+ const struct isl_surf *aux_surf,<br>
+ const void *aux_map_addr,<br>
+ unsigned int aux_map_size,<br>
+ const char *basename);<br>
+<br>
#ifdef __cplusplus<br>
}<br>
#endif<br>
diff --git a/src/intel/isl/isl_dump.c b/src/intel/isl/isl_dump.c<br>
new file mode 100644<br>
index 0000000..21df1bb<br>
--- /dev/null<br>
+++ b/src/intel/isl/isl_dump.c<br>
@@ -0,0 +1,217 @@<br>
+/*<br>
+ * Copyright 2016 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+#include <assert.h><br>
+#include <errno.h><br>
+#include <stdio.h><br>
+#include <stdlib.h><br>
+<br>
+#include "isl.h"<br>
+#include "isl_priv.h"<br>
+#include "common/gen_device_info.h"<br>
+<br>
+#include "util/format_srgb.h"<br>
+#include "util/ralloc.h"<br>
+<br>
+#include "main/macros.h"<br>
+<br>
+/**<br>
+ * @brief Determine if a surface should be dumped.<br>
+ *<br>
+ * Since dumping a surface can produce a lot of data and be time consuming,<br>
+ * this function allows you to filter whether a surface should actually be<br>
+ * dumped. If the application is deterministic, then you can use the sequence<br>
+ * id number to filter output. Other examples are shown commented out.<br>
+ *<br>
+ * Return true when the surface should be dumped.<br>
+ */<br>
+static inline bool<br>
+filter_surface_dumping(<wbr>uint64_t sequence_id,<br>
+ const struct isl_surf *surf,<br>
+ const void *map_addr,<br>
+ unsigned int map_size,<br>
+ const struct isl_surf *aux_surf,<br>
+ const void *aux_map_addr,<br>
+ unsigned int aux_map_size,<br>
+ const char *basename)<br>
+{<br>
+ const uint64_t single_id = 0;<br>
+ const uint64_t min_id = 0;<br>
+ const uint64_t max_id = 0;<br>
+ return<br>
+ (min_id == 0 || sequence_id >= min_id) &&<br>
+ (max_id == 0 || sequence_id <= max_id) &&<br>
+ (single_id == 0 || sequence_id == single_id) &&<br>
+ /* surf->format == ISL_FORMAT_R8_UINT && */<br>
+ /* surf->msaa_layout == ISL_MSAA_LAYOUT_NONE && */<br>
+ true;<br>
+}<br>
+<br>
+static const char *<br>
+tiling_name(enum isl_tiling tiling)<br>
+{<br>
+#define TILENAME(t) case ISL_TILING_##t: return #t<br>
+ switch(tiling) {<br>
+ TILENAME(LINEAR);<br>
+ TILENAME(W);<br>
+ TILENAME(X);<br>
+ TILENAME(Y0);<br>
+ TILENAME(Yf);<br>
+ TILENAME(Ys);<br>
+ TILENAME(HIZ);<br>
+ TILENAME(CCS);<br>
+ default:<br>
+ return NULL;<br>
+ }<br>
+}<br>
+<br>
+static const char *<br>
+msaa_name(enum isl_msaa_layout layout)<br>
+{<br>
+#define MSAA_NAME(l) case ISL_MSAA_LAYOUT_##l: return #l<br>
+ switch(layout) {<br>
+ MSAA_NAME(NONE);<br>
+ MSAA_NAME(INTERLEAVED);<br>
+ MSAA_NAME(ARRAY);<br>
+ default:<br>
+ return NULL;<br>
+ }<br>
+}<br>
+<br>
+static bool<br>
+dump_surf_info(const struct isl_device *dev,<br>
+ const struct isl_surf *surf,<br>
+ const char *filename)<br>
+{<br>
+ FILE *f = fopen(filename, "w");<br>
+ if (!f)<br>
+ goto fail_open;<br>
+<br>
+ fprintf(f, "Format: %s\n", isl_format_get_name(surf-><wbr>format));<br>
+ fprintf(f, "Tiling: %s\n", tiling_name(surf->tiling));<br>
+ fprintf(f, "Row pitch: %d\n", surf->row_pitch);<br>
+ fprintf(f, "Array pitch (q-pitch): %d\n", surf->array_pitch_el_rows);<br>
+ fprintf(f, "Bit6 swizzle: %sabled\n", dev->has_bit6_swizzling ? "En" : "Dis");<br>
+ fprintf(f, "Samples: %d\n", surf->samples);<br>
+ fprintf(f, "MSAA layout: %s\n", msaa_name(surf->msaa_layout));<br>
+ fprintf(f, "Logical size LOD0: %d x %d\n",<br>
+ surf->logical_level0_px.w, surf->logical_level0_px.h);<br></blockquote><div><br></div><div>We should include units here<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ fprintf(f, "Physical size LOD0: %d x %d\n",<br>
+ surf->phys_level0_sa.w, surf->phys_level0_sa.h);<br></blockquote><div><br></div><div>and here<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ fclose(f);<br>
+ return true;<br>
+<br>
+ fail_open:<br>
+ fprintf(stderr, "%s:%s: couldn't open file: %s\n", __FILE__, __func__, filename);<br>
+ return false;<br>
+}<br>
+<br>
+static bool<br>
+dump_surf_binary(const void *map_addr,<br>
+ unsigned int map_size,<br>
+ const char *filename)<br>
+{<br>
+ FILE *f = fopen(filename, "w");<br>
+ if (!f)<br>
+ goto fail_open;<br>
+<br>
+ fwrite(map_addr, 1, map_size, f);<br>
+<br>
+ fclose(f);<br>
+ return true;<br>
+<br>
+ fail_open:<br>
+ fprintf(stderr, "%s:%s: couldn't open file: %s\n", __FILE__, __func__, filename);<br>
+ return false;<br>
+}<br>
+<br>
+void<br>
+isl_dump_surf(const struct isl_device *dev,<br>
+ const struct isl_surf *surf,<br>
+ const void *map_addr,<br>
+ unsigned int map_size,<br>
+ const struct isl_surf *aux_surf,<br>
+ const void *aux_map_addr,<br>
+ unsigned int aux_map_size,<br>
+ const char *basename)<br>
+{<br>
+ int ret;<br>
+<br>
+ char filename[1024];<br>
+ static uint64_t sequence_id = 0;<br>
+<br>
+ sequence_id++;<br>
+<br>
+ if (!filter_surface_dumping(<wbr>sequence_id, surf, map_addr, map_size, aux_surf,<br>
+ aux_map_addr, aux_map_size, basename))<br>
+ return;<br>
+<br>
+ ret = snprintf(filename, sizeof(filename), "%04lu-%s.txt",<br>
+ sequence_id, basename);<br>
+ if (ret < -1 || ret >= sizeof(filename))<br>
+ goto fail_basename_too_big;<br>
+<br>
+ if (!dump_surf_info(dev, surf, filename))<br>
+ goto fail_dump_info;<br>
+<br>
+ if (map_addr != NULL && map_size > 0) {<br>
+ ret = snprintf(filename, sizeof(filename), "%04lu-%s.bin",<br>
+ sequence_id, basename);<br>
+ if (ret < -1 || ret >= sizeof(filename))<br>
+ goto fail_basename_too_big;<br>
+<br>
+ if (!dump_surf_binary(map_addr, map_size, filename))<br>
+ goto fail_dump_info;<br>
+ }<br>
+<br>
+ if (aux_surf) {<br>
+ ret = snprintf(filename, sizeof(filename), "%04lu-%s-aux.txt",<br>
+ sequence_id, basename);<br>
+ if (ret < -1 || ret >= sizeof(filename))<br>
+ goto fail_basename_too_big;<br>
+<br>
+ if (!dump_surf_info(dev, aux_surf, filename))<br>
+ goto fail_dump_info;<br>
+<br>
+ if (aux_map_addr != NULL && aux_map_size > 0) {<br>
+ ret = snprintf(filename, sizeof(filename), "%04lu-%s-aux.bin",<br>
+ sequence_id, basename);<br>
+ if (ret < -1 || ret >= sizeof(filename))<br>
+ goto fail_basename_too_big;<br>
+<br>
+ if (!dump_surf_binary(aux_map_<wbr>addr, aux_map_size, filename))<br>
+ goto fail_dump_info;<br>
+ }<br>
+ }<br>
+<br>
+ return;<br>
+<br>
+ fail_basename_too_big:<br>
+ fprintf(stderr, "%s:%s: basename too big\n", __FILE__, __func__);<br>
+ abort();<br>
+<br>
+ fail_dump_info:<br>
+ fprintf(stderr, "%s:%s: failed to dump surface info\n", __FILE__, __func__);<br>
+ abort();<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.10.2<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>