summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_program.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2013-03-19 14:27:42 -0700
committerEric Anholt <eric@anholt.net>2013-03-28 11:46:01 -0700
commitd2ba1c24b440ee74436335d8e815be9b72b1ba7f (patch)
tree0bc2e955adde4d026396684fa345307be391f36c /src/mesa/drivers/dri/i965/brw_program.c
parenta19f6e880acfb8ec5b5ea0900602de5a27b12664 (diff)
downloadexternal_mesa3d-d2ba1c24b440ee74436335d8e815be9b72b1ba7f.zip
external_mesa3d-d2ba1c24b440ee74436335d8e815be9b72b1ba7f.tar.gz
external_mesa3d-d2ba1c24b440ee74436335d8e815be9b72b1ba7f.tar.bz2
i965: Track ARB program state along with GLSL state for shader_time.
This will let us do much better printouts for non-GLSL programs. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_program.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index 62954d3..7a1b3f2 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -230,7 +230,9 @@ brw_init_shader_time(struct brw_context *brw)
brw->shader_time.bo = drm_intel_bo_alloc(intel->bufmgr, "shader time",
max_entries * SHADER_TIME_STRIDE,
4096);
- brw->shader_time.programs = rzalloc_array(brw, struct gl_shader_program *,
+ brw->shader_time.shader_programs = rzalloc_array(brw, struct gl_shader_program *,
+ max_entries);
+ brw->shader_time.programs = rzalloc_array(brw, struct gl_program *,
max_entries);
brw->shader_time.types = rzalloc_array(brw, enum shader_time_shader_type,
max_entries);
@@ -369,8 +371,8 @@ brw_report_shader_time(struct brw_context *brw)
continue;
int shader_num = -1;
- if (brw->shader_time.programs[i]) {
- shader_num = brw->shader_time.programs[i]->Name;
+ if (brw->shader_time.shader_programs[i]) {
+ shader_num = brw->shader_time.shader_programs[i]->Name;
}
switch (brw->shader_time.types[i]) {
@@ -431,6 +433,36 @@ brw_collect_and_report_shader_time(struct brw_context *brw)
}
}
+/**
+ * Chooses an index in the shader_time buffer and sets up tracking information
+ * for our printouts.
+ *
+ * Note that this holds on to references to the underlying programs, which may
+ * 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)
+{
+ struct gl_context *ctx = &brw->intel.ctx;
+
+ 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;
+
+ _mesa_reference_shader_program(ctx,
+ &brw->shader_time.shader_programs[shader_time_index],
+ shader_prog);
+
+ _mesa_reference_program(ctx,
+ &brw->shader_time.programs[shader_time_index],
+ prog);
+
+ return shader_time_index;
+}
+
void
brw_destroy_shader_time(struct brw_context *brw)
{