summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2011-09-29 15:36:41 -0700
committerPaul Berry <[email protected]>2011-10-06 19:29:10 -0700
commitf4f686e825ad2d64e50fb9e2491ef60507d59c38 (patch)
treef621b1b90aefbeac175e9b855756634eb0aa47c8 /src/mesa/drivers/dri/i965
parent18e2e19b07b312c978dfbb6d336f69fa84b3ffe2 (diff)
i965 VS: Change nr_userclip to nr_userclip_planes.
The only remaining uses of brw_vs_prog_key::nr_userclip only occurred when using clip planes (as opposed to gl_ClipDistance). This patch renames the value to nr_userclip_planes and sets it to zero when gl_ClipDistance is in use. This avoids unnecessary VS recompiles. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965')
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp4
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs.c6
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs.h5
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_emit.c14
4 files changed, 16 insertions, 13 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 71053060cbc..680bd7d0520 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -1807,7 +1807,7 @@ vec4_visitor::emit_psiz_and_flags(struct brw_reg reg)
}
current_annotation = "Clipping flags";
- for (i = 0; i < c->key.nr_userclip; i++) {
+ for (i = 0; i < c->key.nr_userclip_planes; i++) {
vec4_instruction *inst;
inst = emit(DP4(dst_null_f(), src_reg(output_reg[VERT_RESULT_HPOS]),
@@ -1883,7 +1883,7 @@ vec4_visitor::emit_clip_distances(struct brw_reg reg, int offset)
clip_vertex = VERT_RESULT_HPOS;
}
- for (int i = 0; i + offset < c->key.nr_userclip && i < 4; ++i) {
+ for (int i = 0; i + offset < c->key.nr_userclip_planes && i < 4; ++i) {
emit(DP4(dst_reg(brw_writemask(reg, 1 << i)),
src_reg(output_reg[clip_vertex]),
src_reg(this->userplane[i + offset])));
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index e01752cdb71..14e91d87b2d 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -289,10 +289,12 @@ static void brw_upload_vs_prog(struct brw_context *brw)
*/
key.program_string_id = vp->id;
key.userclip_active = (ctx->Transform.ClipPlanesEnabled != 0);
- key.nr_userclip = _mesa_bitcount_64(ctx->Transform.ClipPlanesEnabled);
key.uses_clip_distance = vp->program.UsesClipDistance;
- if (!key.uses_clip_distance)
+ if (!key.uses_clip_distance) {
key.userclip_planes_enabled = ctx->Transform.ClipPlanesEnabled;
+ key.nr_userclip_planes
+ = _mesa_bitcount_64(ctx->Transform.ClipPlanesEnabled);
+ }
key.copy_edgeflag = (ctx->Polygon.FrontMode != GL_FILL ||
ctx->Polygon.BackMode != GL_FILL);
diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h
index bd81764cb99..b8d11dfa954 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.h
+++ b/src/mesa/drivers/dri/i965/brw_vs.h
@@ -53,9 +53,10 @@ struct brw_vs_prog_key {
GLuint userclip_active:1;
/**
- * Number of user clip planes (or clip distances) that are active.
+ * Number of user clip planes active. Zero if the shader uses
+ * gl_ClipDistance.
*/
- GLuint nr_userclip:4;
+ GLuint nr_userclip_planes:4;
/**
* True if the shader uses gl_ClipDistance, regardless of whether any clip
diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index e78cb6c60d4..88455807ba3 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -204,17 +204,17 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
*/
if (c->key.userclip_active) {
if (intel->gen >= 6) {
- for (i = 0; i < c->key.nr_userclip; i++) {
+ for (i = 0; i < c->key.nr_userclip_planes; i++) {
c->userplane[i] = stride(brw_vec4_grf(reg + i / 2,
(i % 2) * 4), 0, 4, 1);
}
- reg += ALIGN(c->key.nr_userclip, 2) / 2;
+ reg += ALIGN(c->key.nr_userclip_planes, 2) / 2;
} else {
- for (i = 0; i < c->key.nr_userclip; i++) {
+ for (i = 0; i < c->key.nr_userclip_planes; i++) {
c->userplane[i] = stride(brw_vec4_grf(reg + (6 + i) / 2,
(i % 2) * 4), 0, 4, 1);
}
- reg += (ALIGN(6 + c->key.nr_userclip, 4) / 4) * 2;
+ reg += (ALIGN(6 + c->key.nr_userclip_planes, 4) / 4) * 2;
}
}
@@ -239,7 +239,7 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
*/
if (intel->gen >= 6) {
/* We can only load 32 regs of push constants. */
- max_constant = 32 * 2 - c->key.nr_userclip;
+ max_constant = 32 * 2 - c->key.nr_userclip_planes;
} else {
max_constant = BRW_MAX_GRF - 20 - c->vp->program.Base.NumTemporaries;
}
@@ -1565,7 +1565,7 @@ static void emit_vertex_write( struct brw_vs_compile *c)
/* Set the user clip distances in dword 8-15. (m3-4)*/
if (c->key.userclip_active) {
- for (i = 0; i < c->key.nr_userclip; i++) {
+ for (i = 0; i < c->key.nr_userclip_planes; i++) {
struct brw_reg m;
if (i < 4)
m = brw_message_reg(3);
@@ -1593,7 +1593,7 @@ static void emit_vertex_write( struct brw_vs_compile *c)
header1, brw_imm_ud(0x7ff<<8));
}
- for (i = 0; i < c->key.nr_userclip; i++) {
+ for (i = 0; i < c->key.nr_userclip_planes; i++) {
brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
brw_DP4(p, brw_null_reg(), pos, c->userplane[i]);
brw_OR(p, brw_writemask(header1, WRITEMASK_W), header1, brw_imm_ud(1<<i));