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 <eric@anholt.net>
This commit is contained in:
Timothy Arceri 2016-12-20 21:37:23 +11:00
parent cb6f49a902
commit 6643da6d7f
8 changed files with 31 additions and 25 deletions

View 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);

View 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,

View 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);

View 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;
}

View 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;

View 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);

View 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.
*/

View 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;