i965/fs: Add CS shader time support
authorJordan Justen <jordan.l.justen@intel.com>
Thu, 16 Apr 2015 01:27:50 +0000 (18:27 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Sat, 2 May 2015 07:49:59 +0000 (00:49 -0700)
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_cs.cpp
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_program.c

index 106b237506bc47f019e6ce9b56d7a5c7e2cfbde5..54cb162b03fc676038aaa233e8e53ce56fe992bc 100644 (file)
@@ -834,6 +834,9 @@ enum shader_time_shader_type {
    ST_FS16,
    ST_FS16_WRITTEN,
    ST_FS16_RESET,
+   ST_CS,
+   ST_CS_WRITTEN,
+   ST_CS_RESET,
 };
 
 struct brw_vertex_buffer {
index 02bc375f98d07cc5658c0a5538a770644d7f9b97..e2f3d6310dde789b520a5ecd39151be53d92a0c0 100644 (file)
@@ -297,6 +297,14 @@ brw_upload_cs_state(struct brw_context *brw)
    struct brw_cs_prog_data *cs_prog_data = brw->cs.prog_data;
    struct brw_stage_prog_data *prog_data = &cs_prog_data->base;
 
+   if (INTEL_DEBUG & DEBUG_SHADER_TIME) {
+      brw->vtbl.emit_buffer_surface_state(
+         brw, &stage_state->surf_offset[
+                 prog_data->binding_table.shader_time_start],
+         brw->shader_time.bo, 0, BRW_SURFACEFORMAT_RAW,
+         brw->shader_time.bo->size, 1, true);
+   }
+
    uint32_t *bind = (uint32_t*) brw_state_batch(brw, AUB_TRACE_BINDING_TABLE,
                                             prog_data->binding_table.size_bytes,
                                             32, &stage_state->bind_bo_offset);
index 90a85625581f5eca1af862fa9985875147da28cd..c0abff1ba0e28d8ca90396353290c3d6efb14aec 100644 (file)
@@ -758,6 +758,11 @@ fs_visitor::emit_shader_time_end()
          reset_type = ST_FS16_RESET;
       }
       break;
+   case MESA_SHADER_COMPUTE:
+      type = ST_CS;
+      written_type = ST_CS_WRITTEN;
+      reset_type = ST_CS_RESET;
+      break;
    default:
       unreachable("fs_visitor::emit_shader_time_end missing code");
    }
@@ -4139,6 +4144,9 @@ fs_visitor::run_cs()
 
    setup_cs_payload();
 
+   if (INTEL_DEBUG & DEBUG_SHADER_TIME)
+      emit_shader_time_begin();
+
    emit_nir_code();
 
    if (failed)
@@ -4146,6 +4154,9 @@ fs_visitor::run_cs()
 
    emit_cs_terminate();
 
+   if (INTEL_DEBUG & DEBUG_SHADER_TIME)
+      emit_shader_time_end();
+
    calculate_cfg();
 
    optimize();
index 81a0c1914206d363ea5106f6b947d9ef1e046941..e5c0d3c760457c86e8e8fdbdfe3defb6dc8fcee2 100644 (file)
@@ -323,7 +323,8 @@ get_written_and_reset(struct brw_context *brw, int i,
                       uint64_t *written, uint64_t *reset)
 {
    enum shader_time_shader_type type = brw->shader_time.types[i];
-   assert(type == ST_VS || type == ST_GS || type == ST_FS8 || type == ST_FS16);
+   assert(type == ST_VS || type == ST_GS || type == ST_FS8 ||
+          type == ST_FS16 || type == ST_CS);
 
    /* Find where we recorded written and reset. */
    int wi, ri;
@@ -363,7 +364,7 @@ brw_report_shader_time(struct brw_context *brw)
 
    uint64_t scaled[brw->shader_time.num_entries];
    uint64_t *sorted[brw->shader_time.num_entries];
-   uint64_t total_by_type[ST_FS16 + 1];
+   uint64_t total_by_type[ST_CS + 1];
    memset(total_by_type, 0, sizeof(total_by_type));
    double total = 0;
    for (int i = 0; i < brw->shader_time.num_entries; i++) {
@@ -381,6 +382,8 @@ brw_report_shader_time(struct brw_context *brw)
       case ST_FS8_RESET:
       case ST_FS16_WRITTEN:
       case ST_FS16_RESET:
+      case ST_CS_WRITTEN:
+      case ST_CS_RESET:
          /* We'll handle these when along with the time. */
          scaled[i] = 0;
          continue;
@@ -389,6 +392,7 @@ brw_report_shader_time(struct brw_context *brw)
       case ST_GS:
       case ST_FS8:
       case ST_FS16:
+      case ST_CS:
          get_written_and_reset(brw, i, &written, &reset);
          break;
 
@@ -413,6 +417,7 @@ brw_report_shader_time(struct brw_context *brw)
       case ST_GS:
       case ST_FS8:
       case ST_FS16:
+      case ST_CS:
          total_by_type[type] += scaled[i];
          break;
       default:
@@ -455,6 +460,9 @@ brw_report_shader_time(struct brw_context *brw)
       case ST_FS16:
          stage = "fs16";
          break;
+      case ST_CS:
+         stage = "cs";
+         break;
       default:
          stage = "other";
          break;
@@ -469,6 +477,7 @@ brw_report_shader_time(struct brw_context *brw)
    print_shader_time_line("total", "gs", 0, total_by_type[ST_GS], total);
    print_shader_time_line("total", "fs8", 0, total_by_type[ST_FS8], total);
    print_shader_time_line("total", "fs16", 0, total_by_type[ST_FS16], total);
+   print_shader_time_line("total", "cs", 0, total_by_type[ST_CS], total);
 }
 
 static void