]> git.cworth.org Git - fips/commitdiff
stash frame-timings
authorCarl Worth <cworth@cworth.org>
Mon, 3 Mar 2014 21:18:20 +0000 (13:18 -0800)
committerCarl Worth <cworth@cworth.org>
Mon, 3 Mar 2014 21:18:20 +0000 (13:18 -0800)
TODO
configure
context.c
fips-dispatch-gl.c
fips-dispatch-gl.h
metrics.c

diff --git a/TODO b/TODO
index f21f05230d68b1f0d13ffc405d1a67cd103467c7..e7f4276772d3fe8f1d3700721d51b157825162e8 100644 (file)
--- 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
+
index f0f1a2188eeed82d9a3468f1374b33771fbf0da7..b4e7d8a88a771bb00825062a87e905ea07a9a46a 100755 (executable)
--- 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
index b18017da9b55b5d8d345e9399c5af5728a948df3..764e159f25cc9989722160bfc4cc6419d58bf979 100644 (file)
--- 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
index 0f5c251b0dcd82f2af344d823a2e56a69cd9a85a..d4f5479c37e86b8e8fadbb0c4b6e8f80dea9e791 100644 (file)
@@ -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;
index 7b354c8d525e8319c09431c9d128f9ea0df85ee5..d684de2dda55ba130cf3f8967c7c5ae25b7e8f23 100644 (file)
@@ -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 */
index 8f961331707569e0759bb635e3826af94bb1697a..ad7ea3a330cc27b6354e13a8070209b0b406bd13 100644 (file)
--- 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);