summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h7
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.cpp14
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.h2
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.c38
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4.cpp13
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4.h2
6 files changed, 47 insertions, 29 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 8ff70c96acb..1e2b8fc4234 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1123,7 +1123,8 @@ struct brw_context
struct {
drm_intel_bo *bo;
- struct gl_shader_program **programs;
+ struct gl_shader_program **shader_programs;
+ struct gl_program **programs;
enum shader_time_shader_type *types;
uint64_t *cumulative;
int num_entries;
@@ -1187,6 +1188,10 @@ int brw_get_scratch_size(int size);
void brw_get_scratch_bo(struct intel_context *intel,
drm_intel_bo **scratch_bo, int size);
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);
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_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index ecce66bc090..01a1ec06ac0 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -605,18 +605,8 @@ void
fs_visitor::emit_shader_time_write(enum shader_time_shader_type type,
fs_reg value)
{
- /* Choose an index in the buffer and set up tracking information for our
- * printouts.
- */
- 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;
- if (prog) {
- _mesa_reference_shader_program(ctx,
- &brw->shader_time.programs[shader_time_index],
- prog);
- }
-
+ int shader_time_index = brw_get_shader_time_index(brw, prog, &fp->Base,
+ type);
int base_mrf = 6;
fs_reg offset_mrf = fs_reg(MRF, base_mrf);
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 254a53432c8..1fabec45cf8 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -424,7 +424,7 @@ public:
void dump_instructions();
void dump_instruction(fs_inst *inst);
- const struct gl_fragment_program *fp;
+ struct gl_fragment_program *fp;
struct brw_wm_compile *c;
unsigned int sanity_param_count;
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index 62954d3cf78..7a1b3f22853 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)
{
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 9ab599f4b21..2756b71d9fc 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1225,17 +1225,8 @@ void
vec4_visitor::emit_shader_time_write(enum shader_time_shader_type type,
src_reg value)
{
- /* Choose an index in the buffer and set up tracking information for our
- * printouts.
- */
- 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;
- if (prog) {
- _mesa_reference_shader_program(ctx,
- &brw->shader_time.programs[shader_time_index],
- prog);
- }
+ int shader_time_index = brw_get_shader_time_index(brw, prog, &vp->Base,
+ type);
int base_mrf = 6;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 7d4ade50ccb..61e18a66a40 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -224,7 +224,7 @@ public:
return dst_reg(retype(brw_null_reg(), BRW_REGISTER_TYPE_D));
}
- const struct gl_vertex_program *vp;
+ struct gl_vertex_program *vp;
struct brw_vs_compile *c;
struct brw_vs_prog_data *prog_data;
unsigned int sanity_param_count;