[Mesa-dev] [PATCH 2/4] i965: Create a pointer in brw_context to the geometry output VUE map.

Paul Berry stereotype441 at gmail.com
Wed Mar 20 14:15:38 PDT 2013


Currently, the GPU pipeline has one active VUE map in effect at any
given time--the one representing the layout of vertex data coming from
the vertex shader.  However, when geometry shaders are added, they
will have their own independent VUE map.  Later pipeline stages (clip,
sf, fs) will need to consult the geometry shader VUE map if a geometry
shader is in use, and the vertex shader VUE map otherwise.

This patch adds a new field to brw_context, vue_map_geom_out, which
points to whichever VUE map should be used by later pipeline stages.
It also adds a new state flag, BRW_NEW_VUE_MAP_GEOM_OUT, which is
signalled whenever this pointer changes.

Since we don't support geometry shaders yet, vue_map_geom_out is
currently set only by the brw_vs_prog state atom.
---
 src/mesa/drivers/dri/i965/brw_context.h      | 12 ++++++++++++
 src/mesa/drivers/dri/i965/brw_state_upload.c |  1 +
 src/mesa/drivers/dri/i965/brw_vs.c           |  4 ++++
 3 files changed, 17 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index fe6e639..7ad78f5 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -153,6 +153,7 @@ enum brw_state_id {
    BRW_STATE_PROGRAM_CACHE,
    BRW_STATE_STATE_BASE_ADDRESS,
    BRW_STATE_SOL_INDICES,
+   BRW_STATE_VUE_MAP_GEOM_OUT,
 };
 
 #define BRW_NEW_URB_FENCE               (1 << BRW_STATE_URB_FENCE)
@@ -182,6 +183,7 @@ enum brw_state_id {
 #define BRW_NEW_PROGRAM_CACHE		(1 << BRW_STATE_PROGRAM_CACHE)
 #define BRW_NEW_STATE_BASE_ADDRESS	(1 << BRW_STATE_STATE_BASE_ADDRESS)
 #define BRW_NEW_SOL_INDICES		(1 << BRW_STATE_SOL_INDICES)
+#define BRW_NEW_VUE_MAP_GEOM_OUT	(1 << BRW_STATE_VUE_MAP_GEOM_OUT)
 
 struct brw_state_flags {
    /** State update flags signalled by mesa internals */
@@ -917,6 +919,16 @@ struct brw_context
       uint32_t offset;
    } sampler;
 
+   /**
+    * Layout of vertex data exiting the geometry portion of the pipleine.
+    * This comes from the geometry shader if one exists, otherwise from the
+    * vertex shader.
+    *
+    * BRW_NEW_VUE_MAP_GEOM_OUT is flagged when this pointer (or the data it
+    * points to) changes.
+    */
+   const struct brw_vue_map *vue_map_geom_out;
+
    struct {
       struct brw_vs_prog_data *prog_data;
 
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
index 41dfdc3..5c5c05e 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -376,6 +376,7 @@ static struct dirty_bit_map brw_bits[] = {
    DEFINE_BIT(BRW_NEW_PROGRAM_CACHE),
    DEFINE_BIT(BRW_NEW_STATE_BASE_ADDRESS),
    DEFINE_BIT(BRW_NEW_SOL_INDICES),
+   DEFINE_BIT(BRW_NEW_VUE_MAP_GEOM_OUT),
    {0, 0, 0}
 };
 
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index d875703..214730d 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -314,6 +314,8 @@ do_vs_prog(struct brw_context *brw,
 		    program, program_size,
 		    &c.prog_data, sizeof(c.prog_data),
 		    &brw->vs.prog_offset, &brw->vs.prog_data);
+   brw->vue_map_geom_out = &brw->vs.prog_data->vue_map;
+   brw->state.dirty.brw |= BRW_NEW_VUE_MAP_GEOM_OUT;
    ralloc_free(mem_ctx);
 
    return true;
@@ -488,6 +490,8 @@ static void brw_upload_vs_prog(struct brw_context *brw)
 
       assert(success);
    }
+   brw->vue_map_geom_out = &brw->vs.prog_data->vue_map;
+   brw->state.dirty.brw |= BRW_NEW_VUE_MAP_GEOM_OUT;
 }
 
 /* See brw_vs.c:
-- 
1.8.2



More information about the mesa-dev mailing list