aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-04-15 00:50:20 +0200
committerMarek Olšák <[email protected]>2013-04-24 03:23:23 +0200
commitb95cbe5e800e95d888d148e20e6a4e34c8857a9e (patch)
treeae6f5de49fd974c8ab83116a331b4325f623fe9b
parentef39bc4f2ee09ee020b52fff9a9c8dc680fc252e (diff)
mesa,i965: use NewDriverState to communicate TFB state changes with the driver
_NEW_TRANSFORM_FEEDBACK is not used by core Mesa, so it can be removed. Instead, an new private flag is added to i965 to serve the same purpose. If you're new to this: * When creating a context. you can set private dirty flags in gl_context::DriverFlags, eg.: ctx->DriverFlags.NewStateX = BRW_NEW_STATE_X; * When StateX is changed, core Mesa does: ctx->NewDriverState |= ctx->DriverFlags.NewStateX; * When you have to draw, read and clear ctx->NewDriverState. * Pros: not touching NewState, the driver decides the mapping between GL states and hw state groups, unlimited number of flags in core Mesa (still limited number of flags in the driver though) Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h2
-rw-r--r--src/mesa/drivers/dri/i965/brw_gs.c6
-rw-r--r--src/mesa/drivers/dri/i965/brw_state_upload.c5
-rw-r--r--src/mesa/drivers/dri/i965/gen6_sol.c7
-rw-r--r--src/mesa/drivers/dri/i965/gen7_sol_state.c14
-rw-r--r--src/mesa/main/mtypes.h8
-rw-r--r--src/mesa/main/transformfeedback.c20
8 files changed, 42 insertions, 22 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index ceaf325e25b..04d6943352e 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -153,6 +153,8 @@ brwCreateContext(int api,
if (tnl)
tnl->Driver.RunPipeline = _tnl_run_pipeline;
+ ctx->DriverFlags.NewTransformFeedback = BRW_NEW_TRANSFORM_FEEDBACK;
+
ctx->Const.MaxDualSourceDrawBuffers = 1;
ctx->Const.MaxDrawBuffers = BRW_MAX_DRAW_BUFFERS;
ctx->Const.MaxTextureImageUnits = BRW_MAX_TEX_UNIT;
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 114c369f821..e4fd0714c33 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -150,6 +150,7 @@ enum brw_state_id {
BRW_STATE_STATE_BASE_ADDRESS,
BRW_STATE_SOL_INDICES,
BRW_STATE_VUE_MAP_GEOM_OUT,
+ BRW_STATE_TRANSFORM_FEEDBACK,
};
#define BRW_NEW_URB_FENCE (1 << BRW_STATE_URB_FENCE)
@@ -178,6 +179,7 @@ enum brw_state_id {
#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)
+#define BRW_NEW_TRANSFORM_FEEDBACK (1 << BRW_STATE_TRANSFORM_FEEDBACK)
struct brw_state_flags {
/** State update flags signalled by mesa internals */
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
index caa3b3efdd6..59053d4c6c9 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -186,7 +186,7 @@ static void populate_key( struct brw_context *brw,
key->need_gs_prog = false;
} else if (intel->gen == 6) {
/* On Gen6, GS is used for transform feedback. */
- /* _NEW_TRANSFORM_FEEDBACK */
+ /* BRW_NEW_TRANSFORM_FEEDBACK */
if (_mesa_is_xfb_active_and_unpaused(ctx)) {
const struct gl_shader_program *shaderprog =
ctx->Shader.CurrentVertexProgram;
@@ -258,9 +258,9 @@ brw_upload_gs_prog(struct brw_context *brw)
const struct brw_tracked_state brw_gs_prog = {
.dirty = {
.mesa = (_NEW_LIGHT |
- _NEW_TRANSFORM_FEEDBACK |
_NEW_RASTERIZER_DISCARD),
- .brw = BRW_NEW_PRIMITIVE,
+ .brw = (BRW_NEW_PRIMITIVE |
+ BRW_NEW_TRANSFORM_FEEDBACK),
.cache = CACHE_NEW_VS_PROG
},
.emit = brw_upload_gs_prog
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
index 8c562455d8e..843324f8c9f 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -345,7 +345,6 @@ static struct dirty_bit_map mesa_bits[] = {
DEFINE_BIT(_NEW_PROGRAM_CONSTANTS),
DEFINE_BIT(_NEW_BUFFER_OBJECT),
DEFINE_BIT(_NEW_FRAG_CLAMP),
- DEFINE_BIT(_NEW_TRANSFORM_FEEDBACK),
DEFINE_BIT(_NEW_VARYING_VP_INPUTS),
{0, 0, 0}
};
@@ -372,6 +371,7 @@ static struct dirty_bit_map brw_bits[] = {
DEFINE_BIT(BRW_NEW_STATE_BASE_ADDRESS),
DEFINE_BIT(BRW_NEW_SOL_INDICES),
DEFINE_BIT(BRW_NEW_VUE_MAP_GEOM_OUT),
+ DEFINE_BIT(BRW_NEW_TRANSFORM_FEEDBACK),
{0, 0, 0}
};
@@ -440,6 +440,9 @@ void brw_upload_state(struct brw_context *brw)
state->mesa |= brw->intel.NewGLState;
brw->intel.NewGLState = 0;
+ state->brw |= ctx->NewDriverState;
+ ctx->NewDriverState = 0;
+
if (brw->emit_state_always) {
state->mesa |= ~0;
state->brw |= ~0;
diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c
index cf7a60db6be..3cbf28e7dc4 100644
--- a/src/mesa/drivers/dri/i965/gen6_sol.c
+++ b/src/mesa/drivers/dri/i965/gen6_sol.c
@@ -37,7 +37,7 @@ static void
gen6_update_sol_surfaces(struct brw_context *brw)
{
struct gl_context *ctx = &brw->intel.ctx;
- /* _NEW_TRANSFORM_FEEDBACK */
+ /* BRW_NEW_TRANSFORM_FEEDBACK */
struct gl_transform_feedback_object *xfb_obj =
ctx->TransformFeedback.CurrentObject;
/* BRW_NEW_VERTEX_PROGRAM */
@@ -69,9 +69,10 @@ gen6_update_sol_surfaces(struct brw_context *brw)
const struct brw_tracked_state gen6_sol_surface = {
.dirty = {
- .mesa = _NEW_TRANSFORM_FEEDBACK,
+ .mesa = 0,
.brw = (BRW_NEW_BATCH |
- BRW_NEW_VERTEX_PROGRAM),
+ BRW_NEW_VERTEX_PROGRAM |
+ BRW_NEW_TRANSFORM_FEEDBACK),
.cache = 0
},
.emit = gen6_update_sol_surfaces,
diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c
index 03709eafba9..a404e2be3d4 100644
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
@@ -45,7 +45,7 @@ upload_3dstate_so_buffers(struct brw_context *brw)
ctx->Shader.CurrentVertexProgram;
const struct gl_transform_feedback_info *linked_xfb_info =
&vs_prog->LinkedTransformFeedback;
- /* _NEW_TRANSFORM_FEEDBACK */
+ /* BRW_NEW_TRANSFORM_FEEDBACK */
struct gl_transform_feedback_object *xfb_obj =
ctx->TransformFeedback.CurrentObject;
int i;
@@ -116,7 +116,7 @@ upload_3dstate_so_decl_list(struct brw_context *brw,
/* BRW_NEW_VERTEX_PROGRAM */
const struct gl_shader_program *vs_prog =
ctx->Shader.CurrentVertexProgram;
- /* _NEW_TRANSFORM_FEEDBACK */
+ /* BRW_NEW_TRANSFORM_FEEDBACK */
const struct gl_transform_feedback_info *linked_xfb_info =
&vs_prog->LinkedTransformFeedback;
int i;
@@ -189,7 +189,7 @@ upload_3dstate_streamout(struct brw_context *brw, bool active,
{
struct intel_context *intel = &brw->intel;
struct gl_context *ctx = &intel->ctx;
- /* _NEW_TRANSFORM_FEEDBACK */
+ /* BRW_NEW_TRANSFORM_FEEDBACK */
struct gl_transform_feedback_object *xfb_obj =
ctx->TransformFeedback.CurrentObject;
uint32_t dw1 = 0, dw2 = 0;
@@ -238,7 +238,7 @@ upload_sol_state(struct brw_context *brw)
{
struct intel_context *intel = &brw->intel;
struct gl_context *ctx = &intel->ctx;
- /* _NEW_TRANSFORM_FEEDBACK */
+ /* BRW_NEW_TRANSFORM_FEEDBACK */
bool active = _mesa_is_xfb_active_and_unpaused(ctx);
if (active) {
@@ -264,11 +264,11 @@ upload_sol_state(struct brw_context *brw)
const struct brw_tracked_state gen7_sol_state = {
.dirty = {
.mesa = (_NEW_RASTERIZER_DISCARD |
- _NEW_LIGHT |
- _NEW_TRANSFORM_FEEDBACK),
+ _NEW_LIGHT),
.brw = (BRW_NEW_BATCH |
BRW_NEW_VERTEX_PROGRAM |
- BRW_NEW_VUE_MAP_GEOM_OUT)
+ BRW_NEW_VUE_MAP_GEOM_OUT |
+ BRW_NEW_TRANSFORM_FEEDBACK)
},
.emit = upload_sol_state,
};
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 6108a35fd80..8d8622e9e1b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3148,7 +3148,7 @@ struct gl_matrix_stack
#define _NEW_PROGRAM_CONSTANTS (1 << 27)
#define _NEW_BUFFER_OBJECT (1 << 28)
#define _NEW_FRAG_CLAMP (1 << 29)
-#define _NEW_TRANSFORM_FEEDBACK (1 << 30) /**< gl_context::TransformFeedback */
+/* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
#define _NEW_VARYING_VP_INPUTS (1 << 31) /**< gl_context::varying_vp_inputs */
#define _NEW_ALL ~0
@@ -3333,7 +3333,11 @@ typedef enum
*/
struct gl_driver_flags
{
- GLbitfield NewArray; /**< Vertex array state */
+ /** gl_context::Array::_DrawArrays (vertex array state) */
+ GLbitfield NewArray;
+
+ /** gl_context::TransformFeedback::CurrentObject */
+ GLbitfield NewTransformFeedback;
};
struct gl_uniform_buffer_binding
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index d0118c5f7c7..9967fbf6c8f 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -384,7 +384,9 @@ _mesa_BeginTransformFeedback(GLenum mode)
}
}
- FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);
+ FLUSH_VERTICES(ctx, 0);
+ ctx->NewDriverState |= ctx->DriverFlags.NewTransformFeedback;
+
obj->Active = GL_TRUE;
ctx->TransformFeedback.Mode = mode;
@@ -421,7 +423,9 @@ _mesa_EndTransformFeedback(void)
return;
}
- FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);
+ FLUSH_VERTICES(ctx, 0);
+ ctx->NewDriverState |= ctx->DriverFlags.NewTransformFeedback;
+
ctx->TransformFeedback.CurrentObject->Active = GL_FALSE;
ctx->TransformFeedback.CurrentObject->Paused = GL_FALSE;
ctx->TransformFeedback.CurrentObject->EndedAnytime = GL_TRUE;
@@ -442,7 +446,7 @@ bind_buffer_range(struct gl_context *ctx, GLuint index,
struct gl_transform_feedback_object *obj =
ctx->TransformFeedback.CurrentObject;
- /* Note: no need to FLUSH_VERTICES or flag _NEW_TRANSFORM_FEEDBACK, because
+ /* Note: no need to FLUSH_VERTICES or flag NewTransformFeedback, because
* transform feedback buffers can't be changed while transform feedback is
* active.
*/
@@ -686,7 +690,7 @@ _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
shProg->TransformFeedback.BufferMode = bufferMode;
- /* No need to set _NEW_TRANSFORM_FEEDBACK (or invoke FLUSH_VERTICES) since
+ /* No need to invoke FLUSH_VERTICES or flag NewTransformFeedback since
* the varyings won't be used until shader link time.
*/
}
@@ -897,7 +901,9 @@ _mesa_PauseTransformFeedback(void)
return;
}
- FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);
+ FLUSH_VERTICES(ctx, 0);
+ ctx->NewDriverState |= ctx->DriverFlags.NewTransformFeedback;
+
obj->Paused = GL_TRUE;
assert(ctx->Driver.PauseTransformFeedback);
@@ -923,7 +929,9 @@ _mesa_ResumeTransformFeedback(void)
return;
}
- FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);
+ FLUSH_VERTICES(ctx, 0);
+ ctx->NewDriverState |= ctx->DriverFlags.NewTransformFeedback;
+
obj->Paused = GL_FALSE;
assert(ctx->Driver.ResumeTransformFeedback);