From 07bf218026f6921c0b62714df9ec441b24884537 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 3 Mar 2014 13:18:20 -0800 Subject: [PATCH] stash --- TODO | 14 ++++++++++++++ configure | 2 +- context.c | 10 +++++++++- fips-dispatch-gl.c | 14 ++++++++++++++ fips-dispatch-gl.h | 9 +++++++++ metrics.c | 31 +++++++++++++++++++++++-------- 6 files changed, 70 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index f21f052..e7f4276 100644 --- a/TODO +++ b/TODO @@ -63,3 +63,17 @@ Explore using perf/LTTng probing instead of LD_PRELOAD wrapper This has the advantage of allowing full-system, multi-process data collection. + +Things to change while replaying to isolate impact of different pieces +of the pipeline (list by Eero) +============================== + The interesting "what is a bottleneck" experiments are + (from back of 3D pipeline to front): + - Disable blend (= disable related dst reads) + - Binding 1x1 / NULL texture instead of real ones [1] + - Using simple pass-through pixel shader instead of real ones [2] + - Use kill / discard pixel shader instead of real ones + - Use 0x0 / 1x1 scissor rect + - Front+backface cull + - Disable draws + diff --git a/configure b/configure index f0f1a21..b4e7d8a 100755 --- a/configure +++ b/configure @@ -281,7 +281,7 @@ if pkg-config --exists gl; then gl_cflags=$(pkg-config --cflags gl) gl_ldflags=$(pkg-config --libs gl) else - printf"No.\n" + printf "No.\n" have_gl=0 errors=$((errors + 1)) fi diff --git a/context.c b/context.c index b18017d..764e159 100644 --- a/context.c +++ b/context.c @@ -68,6 +68,14 @@ context_destroy (context_t *ctx) void context_enter (fips_api_t api, void *system_context_id) { + /* Do nothing for a NULL system_context_id. (Don't ask me why, + * but Dota 2 likes to call MakeCurrent with a NULL context ID + * just before calling MakeCurrent with the same context it + * had been using before. We want to do nothing in this case.) + */ + if (system_context_id == NULL) + return; + /* Do nothing if the application is setting the same context * as is already current. */ if (current_context && current_context->system_id == system_context_id) @@ -91,7 +99,7 @@ context_leave (void) if (ctx == NULL) return; - metrics_destroy (ctx->metrics); + metrics_fini (ctx->metrics); } void diff --git a/fips-dispatch-gl.c b/fips-dispatch-gl.c index 0f5c251..d4f5479 100644 --- a/fips-dispatch-gl.c +++ b/fips-dispatch-gl.c @@ -357,3 +357,17 @@ stub_glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataS PFNGLGETPERFMONITORCOUNTERDATAAMDPROC fips_dispatch_glGetPerfMonitorCounterDataAMD = stub_glGetPerfMonitorCounterDataAMD; + +static void +stub_glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, + GLsizei *length, GLchar *label) +{ + check_initialized (); + resolve (fips_dispatch_glGetObjectLabel, "glGetObjectLabel"); + fips_dispatch_glGetObjectLabel (identifier, name, bufSize, + length, label); +} + +PFNGLGETOBJECTLABELPROC +fips_dispatch_glGetObjectLabel = + stub_glGetObjectLabel; diff --git a/fips-dispatch-gl.h b/fips-dispatch-gl.h index 7b354c8..d684de2 100644 --- a/fips-dispatch-gl.h +++ b/fips-dispatch-gl.h @@ -113,6 +113,8 @@ typedef void (*PFNGLENDPERFMONITORAMDPROC)(GLuint); typedef void (*PFNGLGETPERFMONITORCOUNTERDATAAMDPROC)(GLuint, GLenum, GLsizei, GLuint *, GLint *); +typedef void (*PFNGLGETOBJECTLABELPROC)(GLenum, GLuint, GLsizei, GLsizei *, GLchar *); + extern PFNGLGETINTEGERVPROC fips_dispatch_glGetIntegerv; #define glGetIntegerv fips_dispatch_glGetIntegerv @@ -202,4 +204,11 @@ extern PFNGLENDPERFMONITORAMDPROC fips_dispatch_glEndPerfMonitorAMD; extern PFNGLGETPERFMONITORCOUNTERDATAAMDPROC fips_dispatch_glGetPerfMonitorCounterDataAMD; #define glGetPerfMonitorCounterDataAMD fips_dispatch_glGetPerfMonitorCounterDataAMD +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 + +extern PFNGLGETOBJECTLABELPROC fips_dispatch_glGetObjectLabel; +#define glGetObjectLabel fips_dispatch_glGetObjectLabel + #endif /* FIPS_DISPATCH_GL_H */ diff --git a/metrics.c b/metrics.c index 8f96133..ad7ea3a 100644 --- a/metrics.c +++ b/metrics.c @@ -185,7 +185,6 @@ metrics_fini (metrics_t *metrics) /* Discard and cleanup any outstanding queries. */ if (metrics->timer_begun_id) { - glEndQuery (GL_TIME_ELAPSED); glDeleteQueries (1, &metrics->timer_begun_id); metrics->timer_begun_id = 0; } @@ -204,7 +203,6 @@ metrics_fini (metrics_t *metrics) if (metrics->info->have_perfmon) { if (metrics->monitor_begun_id) { - glEndPerfMonitorAMD (metrics->monitor_begun_id); glDeletePerfMonitorsAMD (1, &metrics->monitor_begun_id); metrics->monitor_begun_id = 0; } @@ -560,6 +558,7 @@ print_per_stage_metrics (metrics_t *metrics, const char *op_string; unsigned group_index, counter; double value; + int program_name_length = 0; /* Don't print anything for stages with no alloted time. */ if (per_stage->time_ns == 0.0) @@ -567,13 +566,29 @@ print_per_stage_metrics (metrics_t *metrics, op_string = metrics_op_string (op_metrics->op); - printf ("%21s", op_string); - if (op_metrics->op >= METRICS_OP_SHADER) { - printf (" %3d", op_metrics->op - METRICS_OP_SHADER); - } else { - printf (" "); + int program = op_metrics->op - METRICS_OP_SHADER; + glGetObjectLabel (GL_PROGRAM, program, 0, + &program_name_length, NULL); + if (program_name_length) { + char *program_name; + + program_name = malloc(program_name_length + 1); + if (program_name == 0) { + fprintf (stderr, "Out of memory.\n"); + exit (1); + } + glGetObjectLabel (GL_PROGRAM, program, + program_name_length + 1, + NULL, program_name); + printf ("%21s ", program_name); + } else { + printf ("%21s %3d", op_string, program); + } + } + else { + printf ("%21s ", op_string); } if (per_stage->stage) @@ -929,7 +944,7 @@ metrics_end_frame_post_swap (metrics_t *metrics) frames++; - if (frames % 15 == 0) { + if (frames) { double fps; gettimeofday (&tv_now, NULL); -- 2.43.0