[Mesa-dev] [PATCH 09/16] i965/gen7.5: Implement opcodes for the hw-generated binding table EDIT commands
Abdiel Janulgue
abdiel.janulgue at linux.intel.com
Tue Oct 8 14:41:46 PDT 2013
Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
src/mesa/drivers/dri/i965/brw_binding_tables.c | 36 ++++++++++++++++++++++++
src/mesa/drivers/dri/i965/brw_defines.h | 5 ++++
src/mesa/drivers/dri/i965/brw_state.h | 15 +++++++++-
3 files changed, 55 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 2160be8..4a80a9b 100644
--- a/src/mesa/drivers/dri/i965/brw_binding_tables.c
+++ b/src/mesa/drivers/dri/i965/brw_binding_tables.c
@@ -176,6 +176,42 @@ const struct brw_tracked_state brw_gs_binding_table = {
* Hardware-generated binding tables for the resource streamer
*/
void
+gen7_update_binding_table(struct brw_context *brw,
+ enum stage_shader_edit_type stage,
+ uint32_t index,
+ uint32_t surf_offset)
+{
+ GLuint cmd_binding_table_edit;
+ GLbitfield brw_new_binding_table;
+
+ switch(stage) {
+ case STAGE_VERTEX_SHADER:
+ cmd_binding_table_edit = _3DSTATE_BINDING_TABLE_EDIT_VS;
+ brw_new_binding_table = BRW_NEW_VS_BINDING_TABLE;
+ break;
+ case STAGE_GEOMETRY_SHADER:
+ cmd_binding_table_edit = _3DSTATE_BINDING_TABLE_EDIT_GS;
+ brw_new_binding_table = BRW_NEW_GS_BINDING_TABLE;
+ break;
+ case STAGE_FRAGMENT_SHADER:
+ cmd_binding_table_edit = _3DSTATE_BINDING_TABLE_EDIT_PS;
+ brw_new_binding_table = BRW_NEW_PS_BINDING_TABLE;
+ break;
+ default:
+ assert(!"Unimplemented binding table edit command");
+ break;
+ }
+
+ BEGIN_BATCH(3);
+ OUT_BATCH(cmd_binding_table_edit << 16 | (3 - 2));
+ OUT_BATCH(0x3);
+ OUT_BATCH(index << 16 | (surf_offset >> 5));
+ ADVANCE_BATCH();
+
+ brw->state.dirty.brw |= brw_new_binding_table;
+}
+
+void
gen7_enable_hw_binding_tables(struct brw_context *brw)
{
if (!brw->has_resource_streamer)
diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h
index 3530bbf..a66027e 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -1246,6 +1246,11 @@ enum brw_message_target {
#define _3DSTATE_BINDING_TABLE_POOL_ALLOC 0x7919 /* GEN7.5+ */
# define HSW_BINDING_TABLE_ALLOC_OFFSET 0x860 /* GEN7.5+ */
+#define _3DSTATE_BINDING_TABLE_EDIT_VS 0x7843 /* GEN7.5 */
+#define _3DSTATE_BINDING_TABLE_EDIT_GS 0x7844 /* GEN7.5 */
+#define _3DSTATE_BINDING_TABLE_EDIT_HS 0x7845 /* GEN7.5 */
+#define _3DSTATE_BINDING_TABLE_EDIT_DS 0x7846 /* GEN7.5 */
+#define _3DSTATE_BINDING_TABLE_EDIT_PS 0x7847 /* GEN7.5 */
#define _3DSTATE_SAMPLER_STATE_POINTERS 0x7802 /* GEN6+ */
# define PS_SAMPLER_STATE_CHANGE (1 << 12)
diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index 0e08e03..b9509f4 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -256,7 +256,20 @@ gen7_upload_constant_state(struct brw_context *brw,
/* gen7_misc_state.c */
void gen7_rs_control(struct brw_context *brw, int enable);
-
+/**
+ * Enum to specify stages on binding table edit
+ */
+enum stage_shader_edit_type
+{
+ STAGE_VERTEX_SHADER,
+ STAGE_GEOMETRY_SHADER,
+ STAGE_FRAGMENT_SHADER,
+};
+
+void gen7_update_binding_table(struct brw_context *brw,
+ enum stage_shader_edit_type stage,
+ uint32_t index,
+ uint32_t surf_offset);
void gen7_update_hw_bt(struct brw_context *brw);
void gen7_enable_hw_binding_tables(struct brw_context *brw);
--
1.7.9.5
More information about the mesa-dev
mailing list