#include <stdio.h>
#include "pan_blend_shaders.h"
+#include "pan_util.h"
#include "midgard/midgard_compile.h"
#include "compiler/nir/nir_builder.h"
//#include "gallium/auxiliary/nir/nir_lower_blend.h"
/* Build a trivial blend shader */
nir_store_var(b, c_out, nir_blending_f(blend, b, s_src, s_dst, s_con), 0xFF);
- nir_print_shader(shader, stdout);
+ if (pan_debug & PAN_DBG_SHADERS)
+ nir_print_shader(shader, stdout);
/* Compile the built shader */
#include "pan_screen.h"
#include "pan_blending.h"
#include "pan_blend_shaders.h"
+#include "pan_util.h"
#include "pan_wallpaper.h"
static int performance_counter_number = 0;
panfrost_enable_afbc(struct panfrost_context *ctx, struct panfrost_resource *rsrc, bool ds)
{
if (ctx->require_sfbd) {
- printf("AFBC not supported yet on SFBD\n");
+ DBG("AFBC not supported yet on SFBD\n");
assert(0);
}
continue;
if (ctx->require_sfbd) {
- fprintf(stderr, "Color AFBC not supported on SFBD\n");
+ DBG("Color AFBC not supported on SFBD\n");
assert(0);
}
if (rsrc->bo->has_afbc) {
if (ctx->require_sfbd) {
- fprintf(stderr, "Depth AFBC not supported on SFBD\n");
+ DBG("Depth AFBC not supported on SFBD\n");
assert(0);
}
if (ctx->pipe_framebuffer.nr_cbufs == 0) {
if (ctx->require_sfbd) {
- fprintf(stderr, "Depth-only FBO not supported on SFBD\n");
+ DBG("Depth-only FBO not supported on SFBD\n");
assert(0);
}
panfrost_invalidate_frame(struct panfrost_context *ctx)
{
unsigned transient_count = ctx->transient_pools[ctx->cmdstream_i].entry_index*ctx->transient_pools[0].entry_size + ctx->transient_pools[ctx->cmdstream_i].entry_offset;
- printf("Uploaded transient %d bytes\n", transient_count);
+ DBG("Uploaded transient %d bytes\n", transient_count);
/* Rotate cmdstream */
if ((++ctx->cmdstream_i) == (sizeof(ctx->transient_pools) / sizeof(ctx->transient_pools[0])))
if (rsrc->bo->has_checksum) {
if (ctx->require_sfbd) {
- fprintf(stderr, "Checksumming not supported on SFBD\n");
+ DBG("Checksumming not supported on SFBD\n");
assert(0);
}
break;
default:
- printf("Unknown shader stage %d in uniform upload\n", i);
+ DBG("Unknown shader stage %d in uniform upload\n", i);
assert(0);
}
{
/* TODO: Expand the array? */
if (ctx->draw_count >= MAX_DRAW_CALLS) {
- printf("Job buffer overflow, ignoring draw\n");
+ DBG("Job buffer overflow, ignoring draw\n");
assert(0);
}
DEFINE_CASE(POLYGON);
default:
- printf("Illegal draw mode %d\n", mode);
+ DBG("Illegal draw mode %d\n", mode);
assert(0);
return MALI_LINE_LOOP;
}
return MALI_DRAW_INDEXED_UINT32;
default:
- printf("Unknown index size %d\n", size);
+ DBG("Unknown index size %d\n", size);
assert(0);
return 0;
}
{
struct panfrost_vertex_state *so = (struct panfrost_vertex_state *) hwcso;
unsigned bytes = sizeof(struct mali_attr_meta) * so->num_elements;
- printf("Vertex elements delete leaks descriptor (%d bytes)\n", bytes);
+ DBG("Vertex elements delete leaks descriptor (%d bytes)\n", bytes);
free(hwcso);
}
struct panfrost_shader_variants *cso = (struct panfrost_shader_variants *) so;
if (cso->base.type == PIPE_SHADER_IR_TGSI) {
- printf("Deleting TGSI shader leaks duplicated tokens\n");
+ DBG("Deleting TGSI shader leaks duplicated tokens\n");
}
unsigned leak = cso->variant_count * sizeof(struct mali_shader_meta);
- printf("Deleting shader state leaks descriptors (%d bytes), and shader bytecode\n", leak);
+ DBG("Deleting shader state leaks descriptors (%d bytes), and shader bytecode\n", leak);
free(so);
}
} else if (buf->user_buffer) {
cpu = buf->user_buffer;
} else {
- printf("No constant buffer?\n");
+ DBG("No constant buffer?\n");
return;
}
if (ctx->pipe_framebuffer.cbufs[i] == cb) continue;
if (cb && (i != 0)) {
- printf("XXX: Multiple render targets not supported before t7xx!\n");
+ DBG("XXX: Multiple render targets not supported before t7xx!\n");
assert(0);
}
struct panfrost_blend_state *so = (struct panfrost_blend_state *) blend;
if (so->has_blend_shader) {
- printf("Deleting blend state leak blend shaders bytecode\n");
+ DBG("Deleting blend state leak blend shaders bytecode\n");
}
free(blend);
}
default:
- fprintf(stderr, "Skipping query %d\n", query->type);
+ DBG("Skipping query %d\n", query->type);
break;
}
break;
}
default:
- fprintf(stderr, "Skipped query get %d\n", query->type);
+ DBG("Skipped query get %d\n", query->type);
break;
}
#include "pan_screen.h"
#include "pan_resource.h"
#include "pan_swizzle.h"
+#include "pan_util.h"
static struct pipe_resource *
panfrost_resource_from_handle(struct pipe_screen *pscreen,
static void
panfrost_flush_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
{
- //fprintf(stderr, "TODO %s\n", __func__);
+ //DBG("TODO %s\n", __func__);
}
static void
const struct pipe_blit_info *info)
{
/* STUB */
- printf("Skipping blit XXX\n");
+ DBG("Skipping blit XXX\n");
return;
}
case PIPE_TEXTURE_RECT:
break;
default:
- fprintf(stderr, "Unknown texture target %d\n", template->target);
+ DBG("Unknown texture target %d\n", template->target);
assert(0);
}
if (bo->has_afbc) {
/* TODO */
- printf("--leaking afbc (%d bytes)--\n", bo->afbc_metadata_size);
+ DBG("--leaking afbc (%d bytes)--\n", bo->afbc_metadata_size);
}
if (bo->has_checksum) {
/* TODO */
- printf("--leaking checksum (%zd bytes)--\n", bo->checksum_slab.size);
+ DBG("--leaking checksum (%zd bytes)--\n", bo->checksum_slab.size);
}
if (bo->imported) {
/* Gallium thinks writeback happens here; instead, this is our cue to tile */
if (bo->has_afbc) {
- printf("Warning: writes to afbc surface can't possibly work out well for you...\n");
+ DBG("Warning: writes to afbc surface can't possibly work out well for you...\n");
} else if (bo->tiled) {
struct pipe_context *gallium = (struct pipe_context *) ctx;
struct panfrost_screen *screen = pan_screen(gallium->screen);
static void
panfrost_invalidate_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
{
- //fprintf(stderr, "TODO %s\n", __func__);
+ //DBG("TODO %s\n", __func__);
}
static enum pipe_format
**************************************************************************/
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_format.h"
#include "util/u_format_s3tc.h"
#include "pan_screen.h"
#include "pan_resource.h"
#include "pan_public.h"
+#include "pan_util.h"
#include "pan_context.h"
#include "midgard/midgard_compile.h"
+static const struct debug_named_value debug_options[] = {
+ {"msgs", PAN_DBG_MSGS, "Print debug messages"},
+ {"shaders", PAN_DBG_SHADERS, "Dump shaders in NIR"},
+ DEBUG_NAMED_VALUE_END
+};
+
+DEBUG_GET_ONCE_FLAGS_OPTION(pan_debug, "PAN_MESA_DEBUG", debug_options, 0)
+
+int pan_debug = 0;
+
struct panfrost_driver *panfrost_create_drm_driver(int fd);
struct panfrost_driver *panfrost_create_nondrm_driver(int fd);
{
struct panfrost_screen *screen = CALLOC_STRUCT(panfrost_screen);
+ pan_debug = debug_get_option_pan_debug();
+
if (!screen)
return NULL;
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2019 Collabora
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+#ifndef PAN_UTIL_H
+#define PAN_UTIL_H
+
+#define PAN_DBG_MSGS 0x0001
+#define PAN_DBG_SHADERS 0x0002
+
+extern int pan_debug;
+
+#define DBG(fmt, ...) \
+ do { if (pan_debug & PAN_DBG_MSGS) \
+ fprintf(stderr, "%s:%d: "fmt, \
+ __FUNCTION__, __LINE__, ##__VA_ARGS__); } while (0)
+
+#endif /* PAN_UTIL_H */
#include "pan_wallpaper.h"
#include "pan_context.h"
#include "pan_screen.h"
+#include "pan_util.h"
//#include "include/panfrost-job.h"
#include "midgard/midgard_compile.h"
#include "compiler/nir/nir_builder.h"
nir_store_var(b, c_out, texel, 0xFF);
- nir_print_shader(shader, stdout);
+ if (pan_debug & PAN_DBG_SHADERS)
+ nir_print_shader(shader, stdout);
return shader;
}