[Mesa-dev] [RFC PATCH 13/40] i965: Enable gather push constants
Abdiel Janulgue
abdiel.janulgue at linux.intel.com
Sun Jan 4 06:04:27 PST 2015
The 3DSTATE_GATHER_POOL_ALLOC is used to enable or disable the gather
push constants feature within a context. This patch provides the toggle
functionality of using gather push constants to program constant data
within a batch.
In addition, using gather push constants require that a gather pool be
allocated so that the resource streamer can flush the packed constants it
gathered. The pool is later referenced by the 3DSTATE_CONSTANT_* command
to program the push constant data. This patch initializes the gather
pool as well.
Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
src/mesa/drivers/dri/i965/brw_binding_tables.c | 40 +++++++++++++++++++++++++-
src/mesa/drivers/dri/i965/brw_context.c | 7 +++++
src/mesa/drivers/dri/i965/brw_context.h | 7 +++++
src/mesa/drivers/dri/i965/brw_state.h | 1 +
4 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/src/mesa/drivers/dri/i965/brw_binding_tables.c b/src/mesa/drivers/dri/i965/brw_binding_tables.c
index 03e7a4a..b91e5d9 100644
--- a/src/mesa/drivers/dri/i965/brw_binding_tables.c
+++ b/src/mesa/drivers/dri/i965/brw_binding_tables.c
@@ -222,9 +222,44 @@ gen7_update_binding_table_from_array(struct brw_context *brw,
ADVANCE_BATCH();
}
+static void
+gen7_init_gather_pool(struct brw_context *brw)
+{
+ if (!brw->has_resource_streamer || !brw->use_gather_constants)
+ return;
+
+ if (!brw->gather_pool.bo) {
+ brw->gather_pool.bo = drm_intel_bo_alloc(brw->bufmgr, "gather_pool",
+ 131072, 4096);
+ brw->gather_pool.next_offset = 0;
+ }
+}
+
+void
+gen7_toggle_gather_constants(struct brw_context *brw, bool enable)
+{
+ if (enable && (!brw->has_resource_streamer || !brw->use_gather_constants))
+ return;
+
+ BEGIN_BATCH(3);
+ OUT_BATCH(_3DSTATE_GATHER_POOL_ALLOC << 16 | (3 - 2));
+ if (enable) {
+ OUT_RELOC(brw->gather_pool.bo, I915_GEM_DOMAIN_SAMPLER, 0,
+ (1 << 11) | (3 << 4) | GEN7_MOCS_L3);
+ OUT_RELOC(brw->gather_pool.bo, I915_GEM_DOMAIN_SAMPLER, 0,
+ brw->gather_pool.bo->size);
+ } else {
+ OUT_BATCH((3 << 4));
+ OUT_BATCH(0);
+ }
+ ADVANCE_BATCH();
+}
+
void
gen7_disable_hw_binding_tables(struct brw_context *brw)
{
+ gen7_toggle_gather_constants(brw, false);
+
BEGIN_BATCH(3);
OUT_BATCH(_3DSTATE_BINDING_TABLE_POOL_ALLOC << 16 | (3 - 2));
OUT_BATCH(3 << 5); /* only in HSW */
@@ -262,6 +297,9 @@ gen7_enable_hw_binding_tables(struct brw_context *brw)
brw->hw_bt_pool.bo->size);
ADVANCE_BATCH();
+ gen7_init_gather_pool(brw);
+ gen7_toggle_gather_constants(brw, true);
+
/* Pipe control workaround */
BEGIN_BATCH(4);
OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2));
@@ -275,6 +313,7 @@ void
gen7_reset_rs_pool_offsets(struct brw_context *brw)
{
brw->hw_bt_pool.next_offset = bt_size;
+ brw->gather_pool.next_offset = 0;
}
const struct brw_tracked_state gen7_hw_binding_tables = {
@@ -358,5 +397,4 @@ const struct brw_tracked_state gen6_binding_table_pointers = {
},
.emit = gen6_upload_binding_table_pointers,
};
-
/** @} */
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index b962103..32bbdc2 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -711,6 +711,12 @@ brwCreateContext(gl_api api,
brw->has_resource_streamer = false;
}
+ if (getenv("INTEL_GATHER")) {
+ brw->use_gather_constants = brw->has_resource_streamer;
+ } else {
+ brw->use_gather_constants = false;
+ }
+
brw->vs.base.stage = MESA_SHADER_VERTEX;
brw->gs.base.stage = MESA_SHADER_GEOMETRY;
brw->wm.base.stage = MESA_SHADER_FRAGMENT;
@@ -853,6 +859,7 @@ brwCreateContext(gl_api api,
ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB;
brw->hw_bt_pool.bo = 0;
+ brw->gather_pool.bo = 0;
if (INTEL_DEBUG & DEBUG_SHADER_TIME)
brw_init_shader_time(brw);
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 17fea5b..b205773 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1081,6 +1081,7 @@ struct brw_context
bool use_rep_send;
bool scalar_vs;
bool has_resource_streamer;
+ bool use_gather_constants;
/**
* Some versions of Gen hardware don't do centroid interpolation correctly
@@ -1340,6 +1341,12 @@ struct brw_context
uint32_t next_offset;
} hw_bt_pool;
+ /* Internal storage used by the resource streamer to flush and refer to constant data*/
+ struct {
+ drm_intel_bo *bo;
+ uint32_t next_offset;
+ } gather_pool;
+
struct {
uint32_t state_offset;
uint32_t blend_state_offset;
diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index f985a3a..16355bd 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -309,6 +309,7 @@ void gen7_update_binding_table_from_array(struct brw_context *brw,
void gen7_enable_hw_binding_tables(struct brw_context *brw);
void gen7_disable_hw_binding_tables(struct brw_context *brw);
void gen7_reset_rs_pool_offsets(struct brw_context *brw);
+void gen7_toggle_gather_constants(struct brw_context *brw, bool enable);
#ifdef __cplusplus
}
--
1.9.1
More information about the mesa-dev
mailing list