From: Carl Worth Date: Thu, 31 Oct 2013 22:35:39 +0000 (-0700) Subject: Fix to print metrics for operations with no per-stage cycle counts X-Git-Url: https://git.cworth.org/git?p=fips;a=commitdiff_plain;h=e158c5bc10001bb9c6bd8c5e6e2ace6ac0f328c3 Fix to print metrics for operations with no per-stage cycle counts Operations like glTexImage* get a valid time from the timer query, but get performance counter numbers of zero, (since the operation is performed in a blit batch which cannot have performance-monitor operations in it). We had code in place to protect any divide-by-zero in this case, but that case was mistakenly setting the resulting time to 0, so any operations like this were not having their time reported. To fix this, we can't compute any per-stage time, so we arbitrarily use stage 0 as the place to store 100% of the time spent, but we update this per-stage metric value to point to a NULL per-stage name to avoid any lie in the report. --- diff --git a/metrics.c b/metrics.c index bb22c4e..0409c9e 100644 --- a/metrics.c +++ b/metrics.c @@ -662,7 +662,11 @@ print_per_stage_metrics (context_t *ctx, printf (" "); } - printf (" %cS:", per_stage->stage->name[0]); + + if (per_stage->stage) + printf (" %cS:", per_stage->stage->name[0]); + else + printf (" :"); printf ("\t%7.2f ms (%4.1f%%)", per_stage->time_ns / 1e6, @@ -774,15 +778,30 @@ print_program_metrics (void) per_stage = &sorted[i * num_shader_stages + j]; per_stage->metrics = op; - per_stage->stage = &info->stages[j]; - if (op_cycles) + + if (op_cycles) { + per_stage->stage = &info->stages[j]; per_stage->time_ns = op->time_ns * (stage_cycles / op_cycles); - else - per_stage->time_ns = 0.0; - if (stage_cycles) + } else { + /* If we don't have any per-stage cycle counts + * for this operation, then use the first + * stage as a placeholder for all the time, + * but NULL-ify the stage info so that the + * report doesn't lie about this time being + * from any particular stage. */ + per_stage->stage = NULL; + if (j == 0) { + per_stage->time_ns = op->time_ns; + } else { + per_stage->time_ns = 0.0; + } + } + + if (stage_cycles) { per_stage->active = active_cycles / stage_cycles; - else + } else { per_stage->active = 0.0; + } } }