[Mesa-dev] [PATCH 10/14] i965: Add means to override individual pipeline parts

Topi Pohjolainen topi.pohjolainen at intel.com
Thu Feb 25 09:46:15 UTC 2016


This will allow meta programming to provide gl-state agnostic
emitters.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_state.h        |  7 +++++++
 src/mesa/drivers/dri/i965/brw_state_upload.c | 29 ++++++++++++++++++++--------
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index 6b85eac..655b832 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -206,6 +206,13 @@ brw_depthbuffer_format(struct brw_context *brw);
 /***********************************************************************
  * brw_state.c
  */
+void
+brw_upload_pipeline_state(struct brw_context *brw,
+                          enum brw_pipeline pipeline,
+                          void (* const * const custom_emitters)(
+                             struct brw_context *, void *),
+                          void *custom_ctx);
+
 void brw_upload_render_state(struct brw_context *brw);
 void brw_render_state_finished(struct brw_context *brw);
 void brw_upload_compute_state(struct brw_context *brw);
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
index a91d074..152f1a4 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -765,17 +765,27 @@ merge_ctx_state(struct brw_context *brw,
 static inline void
 check_and_emit_atom(struct brw_context *brw,
                     struct brw_state_flags *state,
-                    const struct brw_tracked_state *atom)
+                    const struct brw_tracked_state *atom,
+                    void (*custom_emit)(struct brw_context *, void *),
+                    void *custom_ctx)
 {
    if (check_state(state, &atom->dirty)) {
+      if (custom_emit) {
+         custom_emit(brw, custom_ctx);
+         return;
+      }
+
       atom->emit(brw);
       merge_ctx_state(brw, state);
    }
 }
 
-static inline void
+void
 brw_upload_pipeline_state(struct brw_context *brw,
-                          enum brw_pipeline pipeline)
+                          enum brw_pipeline pipeline,
+                          void (* const * const custom_emitters)(
+                             struct brw_context *, void * ),
+                          void *custom_ctx)
 {
    struct gl_context *ctx = &brw->ctx;
    int i;
@@ -860,9 +870,11 @@ brw_upload_pipeline_state(struct brw_context *brw,
 
       for (i = 0; i < num_atoms; i++) {
 	 const struct brw_tracked_state *atom = &atoms[i];
+         void (*custom_emit)(struct brw_context *, void * ) =
+            custom_emitters ? custom_emitters[i] : NULL;
 	 struct brw_state_flags generated;
 
-         check_and_emit_atom(brw, &state, atom);
+         check_and_emit_atom(brw, &state, atom, custom_emit, custom_ctx);
 
 	 accumulate_state(&examined, &atom->dirty);
 
@@ -878,8 +890,9 @@ brw_upload_pipeline_state(struct brw_context *brw,
    else {
       for (i = 0; i < num_atoms; i++) {
 	 const struct brw_tracked_state *atom = &atoms[i];
-
-         check_and_emit_atom(brw, &state, atom);
+         void (*custom_emit)(struct brw_context *, void * ) =
+            custom_emitters ? custom_emitters[i] : NULL;
+         check_and_emit_atom(brw, &state, atom, custom_emit, custom_ctx);
       }
    }
 
@@ -901,7 +914,7 @@ brw_upload_pipeline_state(struct brw_context *brw,
  */
 void brw_upload_render_state(struct brw_context *brw)
 {
-   brw_upload_pipeline_state(brw, BRW_RENDER_PIPELINE);
+   brw_upload_pipeline_state(brw, BRW_RENDER_PIPELINE, NULL, NULL);
 }
 
 static inline void
@@ -939,7 +952,7 @@ brw_render_state_finished(struct brw_context *brw)
 void
 brw_upload_compute_state(struct brw_context *brw)
 {
-   brw_upload_pipeline_state(brw, BRW_COMPUTE_PIPELINE);
+   brw_upload_pipeline_state(brw, BRW_COMPUTE_PIPELINE, NULL, NULL);
 }
 
 void
-- 
2.5.0



More information about the mesa-dev mailing list