...
 
Commits (5)
......@@ -71,6 +71,8 @@ enum mali_gl_mode {
MALI_GL_TRIANGLES = 0x8,
MALI_GL_TRIANGLE_STRIP = 0xA,
MALI_GL_TRIANGLE_FAN = 0xC,
MALI_GL_QUADS = 0xE,
MALI_GL_QUAD_STRIP = 0xF
};
#define MALI_GL_CULL_FACE_BACK 0x80
......
......@@ -65,6 +65,12 @@ panfrost_allocate_slab(struct panfrost_context *ctx,
static bool USE_TRANSACTION_ELIMINATION = false;
#define DUMP_PERFORMANCE_COUNTERS
#ifdef DUMP_PERFORMANCE_COUNTERS
static int performance_counter_number = 0;
#endif
/* Do not actually send anything to the GPU; merely generate the cmdstream as fast as possible. Disables framebuffer writes */
//#define DRY_RUN
......@@ -1445,6 +1451,14 @@ force_flush_fragment(struct panfrost_context *ctx)
last_fragment_flushed = true;
}
#ifdef DUMP_PERFORMANCE_COUNTERS
char filename[128];
snprintf(filename, sizeof(filename), "/dev/shm/frame%d.mdgprf", ++performance_counter_number);
FILE *fp = fopen(filename, "wb");
fwrite(screen->perf_counters.cpu, 4096, sizeof(uint32_t), fp);
fclose(fp);
#endif
}
/* The entire frame is in memory -- send it off to the kernel! */
......@@ -1506,6 +1520,11 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool flush_immediate)
atoms[1].core_req |= panfrost_is_scanout(ctx) ? BASE_JD_REQ_EXTERNAL_RESOURCES : BASE_JD_REQ_FS_AFBC;
#ifdef DUMP_PERFORMANCE_COUNTERS
//atoms[0].core_req |= BASE_JD_REQ_PERMON;
//atoms[1].core_req |= BASE_JD_REQ_PERMON;
#endif
/* Copy over core reqs for old kernels */
for (int i = 0; i < 2; ++i)
......@@ -1520,6 +1539,14 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool flush_immediate)
if (pandev_ioctl(screen->fd, KBASE_IOCTL_JOB_SUBMIT, &submit))
printf("Error submitting\n");
#ifdef DUMP_PERFORMANCE_COUNTERS
/* Dump the performance counters */
if (pandev_ioctl(screen->fd, KBASE_IOCTL_HWCNT_DUMP, NULL)) {
fprintf(stderr, "Error dumping counters\n");
return;
}
#endif
/* If visual, we can stall a frame */
if (panfrost_is_scanout(ctx) && !flush_immediate)
......@@ -1585,6 +1612,8 @@ g2m_draw_mode(enum pipe_prim_type mode)
DEFINE_CASE(TRIANGLES);
DEFINE_CASE(TRIANGLE_STRIP);
DEFINE_CASE(TRIANGLE_FAN);
DEFINE_CASE(QUADS);
DEFINE_CASE(QUAD_STRIP);
default:
printf("Illegal draw mode %d\n", mode);
......@@ -1693,6 +1722,7 @@ panfrost_draw_vbo(
/* Fallback for non-ES draw modes */
#if 0
if (info->mode >= PIPE_PRIM_QUADS) {
if (info->mode == PIPE_PRIM_QUADS && info->count == 4 && ctx->rasterizer && !ctx->rasterizer->base.flatshade) {
mode = PIPE_PRIM_TRIANGLE_FAN;
......@@ -1707,6 +1737,7 @@ panfrost_draw_vbo(
return;
}
}
#endif
ctx->payload_tiler.prefix.draw_mode = g2m_draw_mode(mode);
......@@ -3067,13 +3098,20 @@ panfrost_slab_free(void *priv, struct pb_slab *slab)
printf("stub: Tried to free slab\n");
}
/* While Gallium allows multiple contexts, the kernel does not. So do
* some basic state tracking */
bool kernel_already_opened = false;
static void
panfrost_setup_hardware(struct panfrost_context *ctx)
{
struct pipe_context *gallium = (struct pipe_context *) ctx;
struct panfrost_screen *screen = panfrost_screen(gallium->screen);
if (!kernel_already_opened) {
pandev_open(screen->fd);
}
pb_slabs_init(&ctx->slabs,
MIN_SLAB_ENTRY_SIZE,
......@@ -3102,6 +3140,27 @@ panfrost_setup_hardware(struct panfrost_context *ctx)
panfrost_allocate_slab(ctx, &ctx->shaders, 4096, true, BASE_MEM_PROT_GPU_EX, 0, 0);
panfrost_allocate_slab(ctx, &ctx->tiler_heap, 32768, false, BASE_MEM_GROW_ON_GPF, 1, 128);
panfrost_allocate_slab(ctx, &ctx->misc_0, 128, false, BASE_MEM_GROW_ON_GPF, 1, 128);
#ifdef DUMP_PERFORMANCE_COUNTERS
if (!kernel_already_opened) {
panfrost_allocate_slab(ctx, &screen->perf_counters, 64, true, 0, 0, 0);
struct kbase_ioctl_hwcnt_enable enable_flags = {
.dump_buffer = screen->perf_counters.gpu,
.jm_bm = ~0,
.shader_bm = ~0,
.tiler_bm = ~0,
.mmu_l2_bm = ~0
};
if (pandev_ioctl(screen->fd, KBASE_IOCTL_HWCNT_ENABLE, &enable_flags)) {
fprintf(stderr, "Error enabling performance counters\n");
return;
}
}
#endif
kernel_already_opened = true;
}
static const struct u_transfer_vtbl transfer_vtbl = {
......
......@@ -77,20 +77,9 @@ pandev_standard_allocate(int fd, int va_pages, int flags,
out_flags);
}
/* XXX: This is kind of a hack, but pandev_open can be called more than
* once (e.g. in glmark2-es2-drm), which messes up the kernel. So, do some
* basic state tracking */
bool fd_already_opened = false;
int
pandev_open(int fd)
{
if (fd_already_opened) {
/* Spurious */
return fd;
}
#ifdef USE_LEGACY_KERNEL
struct kbase_ioctl_version_check version = { .major = 11, .minor = 11 };
struct kbase_ioctl_set_flags set_flags = {};
......@@ -115,7 +104,6 @@ pandev_open(int fd)
}
#endif
fd_already_opened = true;
return fd;
}
......@@ -34,6 +34,7 @@
#include "pipe/p_screen.h"
#include "pipe/p_defines.h"
#include "renderonly/renderonly.h"
#include "pan_nondrm.h"
struct panfrost_context;
......@@ -45,6 +46,8 @@ struct panfrost_screen {
struct panfrost_context *any_context;
struct panfrost_memory perf_counters;
/* TODO: Where? */
struct panfrost_resource *display_target;
};
......
......@@ -145,6 +145,8 @@ panwrap_gl_mode_name(enum mali_gl_mode mode)
DEFINE_CASE(GL_TRIANGLE_FAN);
DEFINE_CASE(GL_LINE_STRIP);
DEFINE_CASE(GL_LINE_LOOP);
DEFINE_CASE(GL_QUADS);
DEFINE_CASE(GL_QUAD_STRIP);
default:
return "MALI_GL_TRIANGLES /* XXX: Unknown GL mode, check dump */";
......