i965: update brw_get_shader_time_index() not to take gl_shader_program
authorTimothy Arceri <timothy.arceri@collabora.com>
Tue, 20 Dec 2016 10:37:23 +0000 (21:37 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Tue, 3 Jan 2017 01:20:10 +0000 (12:20 +1100)
This removes another dependency on gl_shader_program in the codegen
functions which will help allow us to use gl_program in the
CurrentProgram array rather than gl_shader_program.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_cs.c
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_tcs.c
src/mesa/drivers/dri/i965/brw_tes.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_wm.c

index 3146bafe5989b0e435d60cd904585efd9d60894e..a2817131a50326bbc56936fe3a32dae4db7bd8df 100644 (file)
@@ -1429,9 +1429,9 @@ void brw_alloc_stage_scratch(struct brw_context *brw,
                              unsigned thread_count);
 void brw_init_shader_time(struct brw_context *brw);
 int brw_get_shader_time_index(struct brw_context *brw,
-                              struct gl_shader_program *shader_prog,
                               struct gl_program *prog,
-                              enum shader_time_shader_type type);
+                              enum shader_time_shader_type type,
+                              bool is_glsl_sh);
 void brw_collect_and_report_shader_time(struct brw_context *brw);
 void brw_destroy_shader_time(struct brw_context *brw);
 
index d039db9e27e25cf4f24f8cbb0b634c9ef73259e5..e4d82cf738c5fcedd200968150d6e53b7d6ce225 100644 (file)
@@ -115,7 +115,7 @@ brw_codegen_cs_prog(struct brw_context *brw,
 
    int st_index = -1;
    if (INTEL_DEBUG & DEBUG_SHADER_TIME)
-      st_index = brw_get_shader_time_index(brw, prog, &cp->program, ST_CS);
+      st_index = brw_get_shader_time_index(brw, &cp->program, ST_CS, true);
 
    char *error_str;
    program = brw_compile_cs(brw->screen->compiler, brw, mem_ctx, key,
index c34620934415dbe16201c39024cd238525898478..805d88a46a8cd5ab6fef3688d735dae20c2575a1 100644 (file)
@@ -140,7 +140,7 @@ brw_codegen_gs_prog(struct brw_context *brw,
 
    int st_index = -1;
    if (INTEL_DEBUG & DEBUG_SHADER_TIME)
-      st_index = brw_get_shader_time_index(brw, prog, NULL, ST_GS);
+      st_index = brw_get_shader_time_index(brw, &gp->program, ST_GS, true);
 
    if (unlikely(brw->perf_debug)) {
       start_busy = brw->batch.last_bo && drm_intel_bo_busy(brw->batch.last_bo);
index 359e04a5efb837e3483fdbd7a830d6342e6be400..80a8721102030c97acda1ea6542650321eb81780 100644 (file)
@@ -605,29 +605,25 @@ brw_collect_and_report_shader_time(struct brw_context *brw)
  * change their lifetimes compared to normal operation.
  */
 int
-brw_get_shader_time_index(struct brw_context *brw,
-                          struct gl_shader_program *shader_prog,
-                          struct gl_program *prog,
-                          enum shader_time_shader_type type)
+brw_get_shader_time_index(struct brw_context *brw, struct gl_program *prog,
+                          enum shader_time_shader_type type, bool is_glsl_sh)
 {
    int shader_time_index = brw->shader_time.num_entries++;
    assert(shader_time_index < brw->shader_time.max_entries);
    brw->shader_time.types[shader_time_index] = type;
 
-   int id = shader_prog ? shader_prog->Name : prog->Id;
    const char *name;
-   if (id == 0) {
+   if (prog->Id == 0) {
       name = "ff";
-   } else if (!shader_prog) {
-      name = "prog";
-   } else if (shader_prog->Label) {
-      name = ralloc_strdup(brw->shader_time.names, shader_prog->Label);
+   } else if (is_glsl_sh) {
+      name = prog->info.label ?
+         ralloc_strdup(brw->shader_time.names, prog->info.label) : "glsl";
    } else {
-      name = "glsl";
+      name = "prog";
    }
 
    brw->shader_time.names[shader_time_index] = name;
-   brw->shader_time.ids[shader_time_index] = id;
+   brw->shader_time.ids[shader_time_index] = prog->Id;
 
    return shader_time_index;
 }
index 0cfa1a6a2fc3ed7887acaf106ad61d322decc663..03986a9e189e4729eb6ec55feb4122aedba60484 100644 (file)
@@ -167,6 +167,7 @@ static bool
 brw_codegen_tcs_prog(struct brw_context *brw,
                      struct gl_shader_program *shader_prog,
                      struct brw_program *tcp,
+                     struct brw_program *tep,
                      struct brw_tcs_prog_key *key)
 {
    struct gl_context *ctx = &brw->ctx;
@@ -250,8 +251,8 @@ brw_codegen_tcs_prog(struct brw_context *brw,
    }
 
    int st_index = -1;
-   if (unlikely(INTEL_DEBUG & DEBUG_SHADER_TIME))
-      st_index = brw_get_shader_time_index(brw, shader_prog, NULL, ST_TCS);
+   if (unlikely((INTEL_DEBUG & DEBUG_SHADER_TIME) && tep))
+      st_index = brw_get_shader_time_index(brw, &tep->program, ST_TCS, true);
 
    if (unlikely(brw->perf_debug)) {
       start_busy = brw->batch.last_bo && drm_intel_bo_busy(brw->batch.last_bo);
@@ -370,7 +371,7 @@ brw_upload_tcs_prog(struct brw_context *brw)
                          &stage_state->prog_offset,
                          &brw->tcs.base.prog_data)) {
       bool success = brw_codegen_tcs_prog(brw, current[MESA_SHADER_TESS_CTRL],
-                                          tcp, &key);
+                                          tcp, tep, &key);
       assert(success);
       (void)success;
    }
@@ -403,19 +404,22 @@ brw_tcs_precompile(struct gl_context *ctx,
          _LinkedShaders[MESA_SHADER_TESS_CTRL]->info.TessCtrl.VerticesOut;
    }
 
+   struct brw_program *btep;
    if (tes) {
+      btep = brw_program(tes->Program);
       key.tes_primitive_mode = tes->info.TessEval.PrimitiveMode;
       key.quads_workaround = brw->gen < 9 &&
                              tes->info.TessEval.PrimitiveMode == GL_QUADS &&
                              tes->info.TessEval.Spacing == GL_EQUAL;
    } else {
+      btep = NULL;
       key.tes_primitive_mode = GL_TRIANGLES;
    }
 
    key.outputs_written = prog->nir->info->outputs_written;
    key.patch_outputs_written = prog->nir->info->patch_outputs_written;
 
-   success = brw_codegen_tcs_prog(brw, shader_prog, btcp, &key);
+   success = brw_codegen_tcs_prog(brw, shader_prog, btcp, btep, &key);
 
    brw->tcs.base.prog_offset = old_prog_offset;
    brw->tcs.base.prog_data = old_prog_data;
index e0b7c89be183de2b0824cb6c839936e2f522ccdf..ea4d7cf5d9e14ae6c9ea1a5b2fdcd75efd449e62 100644 (file)
@@ -168,7 +168,7 @@ brw_codegen_tes_prog(struct brw_context *brw,
 
    int st_index = -1;
    if (unlikely(INTEL_DEBUG & DEBUG_SHADER_TIME))
-      st_index = brw_get_shader_time_index(brw, shader_prog, NULL, ST_TES);
+      st_index = brw_get_shader_time_index(brw, &tep->program, ST_TES, true);
 
    if (unlikely(brw->perf_debug)) {
       start_busy = brw->batch.last_bo && drm_intel_bo_busy(brw->batch.last_bo);
index 8729d3acb5423d63b54594e6aa7f30c2fcddb848..bd020d890e4b2f33d63b9a378070f75117f71d17 100644 (file)
@@ -175,8 +175,11 @@ brw_codegen_vs_prog(struct brw_context *brw,
    }
 
    int st_index = -1;
-   if (INTEL_DEBUG & DEBUG_SHADER_TIME)
-      st_index = brw_get_shader_time_index(brw, prog, &vp->program, ST_VS);
+   if (INTEL_DEBUG & DEBUG_SHADER_TIME) {
+      bool is_glsl_sh = prog != NULL;
+      st_index = brw_get_shader_time_index(brw, &vp->program, ST_VS,
+                                           is_glsl_sh);
+   }
 
    /* Emit GEN4 code.
     */
index 08b8b302de59fdcbf49000eb7d916da452d047eb..844c912ed153b7198bae77bde88a0f8572137c8b 100644 (file)
@@ -134,8 +134,11 @@ brw_codegen_wm_prog(struct brw_context *brw,
 
    int st_index8 = -1, st_index16 = -1;
    if (INTEL_DEBUG & DEBUG_SHADER_TIME) {
-      st_index8 = brw_get_shader_time_index(brw, prog, &fp->program, ST_FS8);
-      st_index16 = brw_get_shader_time_index(brw, prog, &fp->program, ST_FS16);
+      bool is_glsl_sh = prog != NULL;
+      st_index8 = brw_get_shader_time_index(brw, &fp->program, ST_FS8,
+                                            is_glsl_sh);
+      st_index16 = brw_get_shader_time_index(brw, &fp->program, ST_FS16,
+                                             is_glsl_sh);
    }
 
    char *error_str = NULL;