[Mesa-dev] [PATCH 2/4] i965/state: Allow brw->atoms[] to be used by multiple pipelines
Jordan Justen
jordan.l.justen at intel.com
Tue Mar 10 10:49:55 PDT 2015
Convert brw->num_atoms to an int array.
Adds brw_add_pipeline_atoms which copies the atoms for a pipeline, and
sets brw->num_atoms[p] for pipeline p.
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
src/mesa/drivers/dri/i965/brw_context.h | 8 +++-
src/mesa/drivers/dri/i965/brw_state_upload.c | 72 +++++++++++++++++-----------
2 files changed, 50 insertions(+), 30 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 682fbe9..fd43b07 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -149,6 +149,12 @@ struct brw_vue_prog_key;
struct brw_wm_prog_key;
struct brw_wm_prog_data;
+enum brw_pipeline {
+ BRW_RENDER_PIPELINE,
+
+ BRW_NUM_PIPELINES
+};
+
enum brw_cache_id {
BRW_CACHE_FS_PROG,
BRW_CACHE_BLORP_BLIT_PROG,
@@ -1386,7 +1392,7 @@ struct brw_context
int entries_per_oa_snapshot;
} perfmon;
- int num_atoms;
+ int num_atoms[BRW_NUM_PIPELINES];
const struct brw_tracked_state atoms[57];
/* If (INTEL_DEBUG & DEBUG_BATCH) */
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
index 3b64a05..dbfdc92 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -342,11 +342,42 @@ brw_upload_initial_gpu_state(struct brw_context *brw)
}
}
+static inline const struct brw_tracked_state *
+brw_pipeline_first_atom(struct brw_context *brw,
+ enum brw_pipeline pipeline)
+{
+ const struct brw_tracked_state *atom = &brw->atoms[0];
+ for (int i = 0; i < pipeline; i++)
+ atom += brw->num_atoms[i];
+ return atom;
+}
+
+static void
+brw_add_pipeline_atoms(struct brw_context *brw,
+ enum brw_pipeline pipeline,
+ const struct brw_tracked_state **atoms,
+ int num_atoms)
+{
+ /* This is to work around brw_context::atoms being declared const. We want
+ * it to be const, but it needs to be initialized somehow!
+ */
+ struct brw_tracked_state *context_atoms =
+ (struct brw_tracked_state *) brw_pipeline_first_atom(brw, pipeline);
+
+ assert(context_atoms + num_atoms <= brw->atoms + ARRAY_SIZE(brw->atoms));
+
+ for (int i = 0; i < num_atoms; i++) {
+ context_atoms[i] = *atoms[i];
+ assert(context_atoms[i].dirty.mesa | context_atoms[i].dirty.brw);
+ assert(context_atoms[i].emit);
+ }
+
+ brw->num_atoms[pipeline] = num_atoms;
+}
+
void brw_init_state( struct brw_context *brw )
{
struct gl_context *ctx = &brw->ctx;
- const struct brw_tracked_state **atoms;
- int num_atoms;
STATIC_ASSERT(ARRAY_SIZE(gen4_atoms) <= ARRAY_SIZE(brw->atoms));
STATIC_ASSERT(ARRAY_SIZE(gen6_atoms) <= ARRAY_SIZE(brw->atoms));
@@ -356,34 +387,17 @@ void brw_init_state( struct brw_context *brw )
brw_init_caches(brw);
if (brw->gen >= 8) {
- atoms = gen8_atoms;
- num_atoms = ARRAY_SIZE(gen8_atoms);
+ brw_add_pipeline_atoms(brw, BRW_RENDER_PIPELINE,
+ gen8_atoms, ARRAY_SIZE(gen8_atoms));
} else if (brw->gen == 7) {
- atoms = gen7_atoms;
- num_atoms = ARRAY_SIZE(gen7_atoms);
+ brw_add_pipeline_atoms(brw, BRW_RENDER_PIPELINE,
+ gen7_atoms, ARRAY_SIZE(gen7_atoms));
} else if (brw->gen == 6) {
- atoms = gen6_atoms;
- num_atoms = ARRAY_SIZE(gen6_atoms);
+ brw_add_pipeline_atoms(brw, BRW_RENDER_PIPELINE,
+ gen6_atoms, ARRAY_SIZE(gen6_atoms));
} else {
- atoms = gen4_atoms;
- num_atoms = ARRAY_SIZE(gen4_atoms);
- }
-
- brw->num_atoms = num_atoms;
-
- /* This is to work around brw_context::atoms being declared const. We want
- * it to be const, but it needs to be initialized somehow!
- */
- struct brw_tracked_state *context_atoms =
- (struct brw_tracked_state *) &brw->atoms[0];
-
- for (int i = 0; i < num_atoms; i++)
- context_atoms[i] = *atoms[i];
-
- while (num_atoms--) {
- assert((*atoms)->dirty.mesa | (*atoms)->dirty.brw);
- assert((*atoms)->emit);
- atoms++;
+ brw_add_pipeline_atoms(brw, BRW_RENDER_PIPELINE,
+ gen4_atoms, ARRAY_SIZE(gen4_atoms));
}
brw_upload_initial_gpu_state(brw);
@@ -631,7 +645,7 @@ void brw_upload_render_state(struct brw_context *brw)
memset(&examined, 0, sizeof(examined));
prev = *state;
- for (i = 0; i < brw->num_atoms; i++) {
+ for (i = 0; i < brw->num_atoms[BRW_RENDER_PIPELINE]; i++) {
const struct brw_tracked_state *atom = &brw->atoms[i];
struct brw_state_flags generated;
@@ -651,7 +665,7 @@ void brw_upload_render_state(struct brw_context *brw)
}
}
else {
- for (i = 0; i < brw->num_atoms; i++) {
+ for (i = 0; i < brw->num_atoms[BRW_RENDER_PIPELINE]; i++) {
const struct brw_tracked_state *atom = &brw->atoms[i];
if (check_state(state, &atom->dirty)) {
--
2.1.4
More information about the mesa-dev
mailing list