From: Timothy Arceri Date: Tue, 20 Dec 2016 10:37:23 +0000 (+1100) Subject: i965: update brw_get_shader_time_index() not to take gl_shader_program X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6643da6d7f3c3b9bdafb4bb9b01109e482c0b083;p=mesa.git i965: update brw_get_shader_time_index() not to take gl_shader_program 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 --- diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 3146bafe598..a2817131a50 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -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); diff --git a/src/mesa/drivers/dri/i965/brw_cs.c b/src/mesa/drivers/dri/i965/brw_cs.c index d039db9e27e..e4d82cf738c 100644 --- a/src/mesa/drivers/dri/i965/brw_cs.c +++ b/src/mesa/drivers/dri/i965/brw_cs.c @@ -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, diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index c3462093441..805d88a46a8 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -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); diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index 359e04a5efb..80a87211020 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -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; } diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c index 0cfa1a6a2fc..03986a9e189 100644 --- a/src/mesa/drivers/dri/i965/brw_tcs.c +++ b/src/mesa/drivers/dri/i965/brw_tcs.c @@ -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; diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c index e0b7c89be18..ea4d7cf5d9e 100644 --- a/src/mesa/drivers/dri/i965/brw_tes.c +++ b/src/mesa/drivers/dri/i965/brw_tes.c @@ -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); diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index 8729d3acb54..bd020d890e4 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -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. */ diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 08b8b302de5..844c912ed15 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -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;