Mesa (master): i965: Don't make consumers of brw_CONT/ brw_WHILE track if depth in loop.

2011-12-21 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: f1d89638c02afafbf82ef657cd6ba9965dad6738
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1d89638c02afafbf82ef657cd6ba9965dad6738

Author: Eric Anholt 
Date:   Tue Dec  6 12:44:41 2011 -0800

i965: Don't make consumers of brw_CONT/brw_WHILE track if depth in loop.

The codegen backends all had this same tracking, so just do it at the
EU level.

Reviewed-by: Yuanhan Liu 

---

 src/mesa/drivers/dri/i965/brw_eu.c  |1 +
 src/mesa/drivers/dri/i965/brw_eu.h  |   10 --
 src/mesa/drivers/dri/i965/brw_eu_emit.c |   13 +
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp   |   23 ++-
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp |   23 ++-
 src/mesa/drivers/dri/i965/brw_vs_emit.c |   13 +++--
 6 files changed, 25 insertions(+), 58 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
b/src/mesa/drivers/dri/i965/brw_eu.c
index c0126ff..83aae3b 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -197,6 +197,7 @@ brw_init_compile(struct brw_context *brw, struct 
brw_compile *p, void *mem_ctx)
p->loop_stack_depth = 0;
p->loop_stack_array_size = 16;
p->loop_stack = rzalloc_array(mem_ctx, int, p->loop_stack_array_size);
+   p->if_depth_in_loop = rzalloc_array(mem_ctx, int, p->loop_stack_array_size);
 }
 
 
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h 
b/src/mesa/drivers/dri/i965/brw_eu.h
index 8d06fef..11e7161 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -134,6 +134,12 @@ struct brw_compile {
 * encountered.
 */
int *loop_stack;
+   /**
+* pre-gen6, the BREAK and CONT instructions had to tell how many IF/ENDIF
+* blocks they were popping out of, to fix up the mask stack.  This tracks
+* the IF/ENDIF nesting in each current nested loop level.
+*/
+   int *if_depth_in_loop;
int loop_stack_depth;
int loop_stack_array_size;
 
@@ -1026,8 +1032,8 @@ struct brw_instruction *brw_DO(struct brw_compile *p,
 
 struct brw_instruction *brw_WHILE(struct brw_compile *p);
 
-struct brw_instruction *brw_BREAK(struct brw_compile *p, int pop_count);
-struct brw_instruction *brw_CONT(struct brw_compile *p, int pop_count);
+struct brw_instruction *brw_BREAK(struct brw_compile *p);
+struct brw_instruction *brw_CONT(struct brw_compile *p);
 struct brw_instruction *gen6_CONT(struct brw_compile *p);
 /* Forward jumps:
  */
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 30ae3bb..11f4080 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -918,10 +918,13 @@ push_loop_stack(struct brw_compile *p, struct 
brw_instruction *inst)
   p->loop_stack_array_size *= 2;
   p->loop_stack = reralloc(p->mem_ctx, p->loop_stack, int,
   p->loop_stack_array_size);
+  p->if_depth_in_loop = reralloc(p->mem_ctx, p->if_depth_in_loop, int,
+p->loop_stack_array_size);
}
 
p->loop_stack[p->loop_stack_depth] = inst - p->store;
p->loop_stack_depth++;
+   p->if_depth_in_loop[p->loop_stack_depth] = 0;
 }
 
 static struct brw_instruction *
@@ -980,6 +983,7 @@ brw_IF(struct brw_compile *p, GLuint execute_size)
p->current->header.predicate_control = BRW_PREDICATE_NONE;
 
push_if_stack(p, insn);
+   p->if_depth_in_loop[p->loop_stack_depth]++;
return insn;
 }
 
@@ -1187,6 +1191,7 @@ brw_ENDIF(struct brw_compile *p)
struct brw_instruction *if_inst = NULL;
 
/* Pop the IF and (optional) ELSE instructions from the stack */
+   p->if_depth_in_loop[p->loop_stack_depth]--;
p->if_stack_depth--;
if (p->if_stack[p->if_stack_depth]->header.opcode == BRW_OPCODE_ELSE) {
   else_inst = p->if_stack[p->if_stack_depth];
@@ -1245,7 +1250,7 @@ brw_ENDIF(struct brw_compile *p)
patch_IF_ELSE(p, if_inst, else_inst, insn);
 }
 
-struct brw_instruction *brw_BREAK(struct brw_compile *p, int pop_count)
+struct brw_instruction *brw_BREAK(struct brw_compile *p)
 {
struct intel_context *intel = &p->brw->intel;
struct brw_instruction *insn;
@@ -1260,7 +1265,7 @@ struct brw_instruction *brw_BREAK(struct brw_compile *p, 
int pop_count)
   brw_set_src0(p, insn, brw_ip_reg());
   brw_set_src1(p, insn, brw_imm_d(0x0));
   insn->bits3.if_else.pad0 = 0;
-  insn->bits3.if_else.pop_count = pop_count;
+  insn->bits3.if_else.pop_count = p->if_depth_in_loop[p->loop_stack_depth];
}
insn->header.compression_control = BRW_COMPRESSION_NONE;
insn->header.execution_size = BRW_EXECUTE_8;
@@ -1284,7 +1289,7 @@ struct brw_instruction *gen6_CONT(struct brw_compile *p)
return insn;
 }
 
-struct brw_instruction *brw_CONT(struct brw_compile *p, int pop_count)
+struct brw_instruction *brw_CONT(struct brw_compile *p)
 {
struct brw_instruction *insn;
insn = next_insn(p, BRW_OPCODE_CONT

Mesa (master): i965: Don't make consumers of brw_WHILE do pre-gen6 BREAK/ CONT patching.

2011-12-21 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: ce6be334bbf7f44c71ad5d190f9fb075d2f9a38c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce6be334bbf7f44c71ad5d190f9fb075d2f9a38c

Author: Eric Anholt 
Date:   Tue Dec  6 12:30:03 2011 -0800

i965: Don't make consumers of brw_WHILE do pre-gen6 BREAK/CONT patching.

The EU code itself can just do this work, since all the consumers were
duplicating it.

Reviewed-by: Yuanhan Liu 

---

 src/mesa/drivers/dri/i965/brw_eu_emit.c |   35 +-
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp   |   33 +++--
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp |   33 +++--
 src/mesa/drivers/dri/i965/brw_vs_emit.c |   30 +++
 4 files changed, 45 insertions(+), 86 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 5f92075..30ae3bb 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -1343,7 +1343,35 @@ struct brw_instruction *brw_DO(struct brw_compile *p, 
GLuint execute_size)
}
 }
 
-
+/**
+ * For pre-gen6, we patch BREAK/CONT instructions to point at the WHILE
+ * instruction here.
+ *
+ * For gen6+, see brw_set_uip_jip(), which doesn't care so much about the loop
+ * nesting, since it can always just point to the end of the block/current 
loop.
+ */
+static void
+brw_patch_break_cont(struct brw_compile *p, struct brw_instruction *while_inst)
+{
+   struct intel_context *intel = &p->brw->intel;
+   struct brw_instruction *do_inst = get_inner_do_insn(p);
+   struct brw_instruction *inst;
+   int br = (intel->gen == 5) ? 2 : 1;
+
+   for (inst = while_inst - 1; inst != do_inst; inst--) {
+  /* If the jump count is != 0, that means that this instruction has 
already
+   * been patched because it's part of a loop inside of the one we're
+   * patching.
+   */
+  if (inst->header.opcode == BRW_OPCODE_BREAK &&
+ inst->bits3.if_else.jump_count == 0) {
+inst->bits3.if_else.jump_count = br * ((while_inst - inst) + 1);
+  } else if (inst->header.opcode == BRW_OPCODE_CONTINUE &&
+inst->bits3.if_else.jump_count == 0) {
+inst->bits3.if_else.jump_count = br * (while_inst - inst);
+  }
+   }
+}
 
 struct brw_instruction *brw_WHILE(struct brw_compile *p)
 {
@@ -1352,7 +1380,6 @@ struct brw_instruction *brw_WHILE(struct brw_compile *p)
GLuint br = 1;
 
do_insn = get_inner_do_insn(p);
-   p->loop_stack_depth--;
 
if (intel->gen >= 5)
   br = 2;
@@ -1396,11 +1423,15 @@ struct brw_instruction *brw_WHILE(struct brw_compile *p)
 insn->bits3.if_else.jump_count = br * (do_insn - insn + 1);
 insn->bits3.if_else.pop_count = 0;
 insn->bits3.if_else.pad0 = 0;
+
+brw_patch_break_cont(p, insn);
   }
}
insn->header.compression_control = BRW_COMPRESSION_NONE;
p->current->header.predicate_control = BRW_PREDICATE_NONE;
 
+   p->loop_stack_depth--;
+
return insn;
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
index ded58a2..91e6961 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
@@ -658,8 +658,6 @@ fs_visitor::generate_code()
 
int loop_stack_array_size = 16;
int loop_stack_depth = 0;
-   brw_instruction **loop_stack =
-  rzalloc_array(this->mem_ctx, brw_instruction *, loop_stack_array_size);
int *if_depth_in_loop =
   rzalloc_array(this->mem_ctx, int, loop_stack_array_size);
 
@@ -795,11 +793,10 @@ fs_visitor::generate_code()
 break;
 
   case BRW_OPCODE_DO:
-loop_stack[loop_stack_depth++] = brw_DO(p, BRW_EXECUTE_8);
+brw_DO(p, BRW_EXECUTE_8);
+loop_stack_depth++;
 if (loop_stack_array_size <= loop_stack_depth) {
loop_stack_array_size *= 2;
-   loop_stack = reralloc(this->mem_ctx, loop_stack, brw_instruction *,
- loop_stack_array_size);
if_depth_in_loop = reralloc(this->mem_ctx, if_depth_in_loop, int,
loop_stack_array_size);
 }
@@ -819,31 +816,10 @@ fs_visitor::generate_code()
 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
 break;
 
-  case BRW_OPCODE_WHILE: {
-struct brw_instruction *inst0, *inst1;
-GLuint br = 1;
-
-if (intel->gen >= 5)
-   br = 2;
-
+  case BRW_OPCODE_WHILE:
 assert(loop_stack_depth > 0);
 loop_stack_depth--;
-inst0 = inst1 = brw_WHILE(p);
-if (intel->gen < 6) {
-   /* patch all the BREAK/CONT instructions from last BGNLOOP */
-   while (inst0 > loop_stack[loop_stack_depth]) {
-  inst0--;
-  if (inst0->header.opcode == BRW_OPCODE_BREAK &&
-  inst0->bits3.if_else.jump_count == 0) {
- inst0->bits3.if_else.jump_count = b

Mesa (master): i965: Don't make consumers of brw_DO()/brw_WHILE() track loop start.

2011-12-21 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 32118cfe37495738ed5931c6b1a71b8ee2ad189c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=32118cfe37495738ed5931c6b1a71b8ee2ad189c

Author: Eric Anholt 
Date:   Tue Dec  6 12:13:32 2011 -0800

i965: Don't make consumers of brw_DO()/brw_WHILE() track loop start.

This is a similar cleanup to what we did for brw_IF(), brw_ELSE(),
brw_ENDIF() handling.

Reviewed-by: Yuanhan Liu 

---

 src/mesa/drivers/dri/i965/brw_clip_line.c |5 +--
 src/mesa/drivers/dri/i965/brw_clip_tri.c  |   15 +---
 src/mesa/drivers/dri/i965/brw_clip_unfilled.c |   14 +--
 src/mesa/drivers/dri/i965/brw_eu.c|4 +++
 src/mesa/drivers/dri/i965/brw_eu.h|   12 -
 src/mesa/drivers/dri/i965/brw_eu_emit.c   |   30 ++--
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp |2 +-
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp   |2 +-
 src/mesa/drivers/dri/i965/brw_vs_emit.c   |2 +-
 9 files changed, 58 insertions(+), 28 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clip_line.c 
b/src/mesa/drivers/dri/i965/brw_clip_line.c
index 614849a..6cf2bd2 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_line.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_line.c
@@ -132,7 +132,6 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
struct brw_indirect newvtx0   = brw_indirect(2, 0);
struct brw_indirect newvtx1   = brw_indirect(3, 0);
struct brw_indirect plane_ptr = brw_indirect(4, 0);
-   struct brw_instruction *plane_loop;
struct brw_reg v1_null_ud = retype(vec1(brw_null_reg()), 
BRW_REGISTER_TYPE_UD);
GLuint hpos_offset = brw_vert_result_to_offset(&c->vue_map,
   VERT_RESULT_HPOS);
@@ -160,7 +159,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
 
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
 
-   plane_loop = brw_DO(p, BRW_EXECUTE_1);
+   brw_DO(p, BRW_EXECUTE_1);
{
   /* if (planemask & 1)
*/
@@ -245,7 +244,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
   brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
   brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(1));
}
-   brw_WHILE(p, plane_loop);
+   brw_WHILE(p);
 
brw_ADD(p, c->reg.t, c->reg.t0, c->reg.t1);
brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.t, 
brw_imm_f(1.0));
diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c 
b/src/mesa/drivers/dri/i965/brw_clip_tri.c
index 12d6724..a29f8e0 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_tri.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c
@@ -232,8 +232,6 @@ void brw_clip_tri( struct brw_clip_compile *c )
struct brw_indirect inlist_ptr = brw_indirect(4, 0);
struct brw_indirect outlist_ptr = brw_indirect(5, 0);
struct brw_indirect freelist_ptr = brw_indirect(6, 0);
-   struct brw_instruction *plane_loop;
-   struct brw_instruction *vertex_loop;
GLuint hpos_offset = brw_vert_result_to_offset(&c->vue_map,
   VERT_RESULT_HPOS);

@@ -244,7 +242,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
 
brw_MOV(p, get_addr_reg(freelist_ptr), brw_address(c->reg.vertex[3]) );
 
-   plane_loop = brw_DO(p, BRW_EXECUTE_1);
+   brw_DO(p, BRW_EXECUTE_1);
{
   /* if (planemask & 1)
*/
@@ -266,7 +264,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
 brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
 brw_MOV(p, c->reg.nr_verts, brw_imm_ud(0));
 
-vertex_loop = brw_DO(p, BRW_EXECUTE_1);
+brw_DO(p, BRW_EXECUTE_1);
 {
/* vtx = *input_ptr;
 */
@@ -364,7 +362,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
 } 
-brw_WHILE(p, vertex_loop);
+brw_WHILE(p);
 
 /* vtxPrev = *(outlist_ptr-1)  OR: outlist[nr_verts-1]
  * inlist = outlist
@@ -396,7 +394,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
   brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
   brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(1));
}
-   brw_WHILE(p, plane_loop);
+   brw_WHILE(p);
 }
 
 
@@ -404,7 +402,6 @@ void brw_clip_tri( struct brw_clip_compile *c )
 void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
 {
struct brw_compile *p = &c->func;
-   struct brw_instruction *loop;
 
/* for (loopcount = nr_verts-2; loopcount > 0; loopcount--)
 */
@@ -429,7 +426,7 @@ void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
   brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2));
   brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
 
-  loop = brw_DO(p, BRW_EXECUTE_1);
+  brw_DO(p, BRW_EXECUTE_1);
   {
 brw_clip_emit_vue(c, v0, 1, 0,
(_3DPRIM_TRIFAN << URB_WRITE_PRIM_

Mesa (master): i965: Drop unused do_insn argument from gen6_CONT().

2011-12-21 Thread Eric Anholt
Module: Mesa
Branch: master
Commit: 9f8814752f306cb9a26d283f0b7cf876639e10f7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f8814752f306cb9a26d283f0b7cf876639e10f7

Author: Eric Anholt 
Date:   Tue Dec  6 12:09:58 2011 -0800

i965: Drop unused do_insn argument from gen6_CONT().

The branch distances get patched up later at the WHILE instruction.

Reviewed-by: Yuanhan Liu 

---

 src/mesa/drivers/dri/i965/brw_eu.h  |3 +--
 src/mesa/drivers/dri/i965/brw_eu_emit.c |3 +--
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp   |2 +-
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp |2 +-
 src/mesa/drivers/dri/i965/brw_vs_emit.c |2 +-
 5 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.h 
b/src/mesa/drivers/dri/i965/brw_eu.h
index 1529ec6..481fbf1 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -1020,8 +1020,7 @@ struct brw_instruction *brw_WHILE(struct brw_compile *p,
 
 struct brw_instruction *brw_BREAK(struct brw_compile *p, int pop_count);
 struct brw_instruction *brw_CONT(struct brw_compile *p, int pop_count);
-struct brw_instruction *gen6_CONT(struct brw_compile *p,
- struct brw_instruction *do_insn);
+struct brw_instruction *gen6_CONT(struct brw_compile *p);
 /* Forward jumps:
  */
 void brw_land_fwd_jump(struct brw_compile *p, 
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index f6726fc..6247e4c 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -1249,8 +1249,7 @@ struct brw_instruction *brw_BREAK(struct brw_compile *p, 
int pop_count)
return insn;
 }
 
-struct brw_instruction *gen6_CONT(struct brw_compile *p,
- struct brw_instruction *do_insn)
+struct brw_instruction *gen6_CONT(struct brw_compile *p)
 {
struct brw_instruction *insn;
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
index 7f0e58e..2f5a026 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
@@ -813,7 +813,7 @@ fs_visitor::generate_code()
   case BRW_OPCODE_CONTINUE:
 /* FINISHME: We need to write the loop instruction support still. */
 if (intel->gen >= 6)
-   gen6_CONT(p, loop_stack[loop_stack_depth - 1]);
+   gen6_CONT(p);
 else
brw_CONT(p, if_depth_in_loop[loop_stack_depth]);
 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index b2427da..ef1ca3d 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -949,7 +949,7 @@ vec4_visitor::generate_code()
   case BRW_OPCODE_CONTINUE:
 /* FINISHME: We need to write the loop instruction support still. */
 if (intel->gen >= 6)
-   gen6_CONT(p, loop_stack[loop_stack_depth - 1]);
+   gen6_CONT(p);
 else
brw_CONT(p, if_depth_in_loop[loop_stack_depth]);
 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c 
b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index bcaef04..6c96a48 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -2106,7 +2106,7 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
   case OPCODE_CONT:
 brw_set_predicate_control(p, get_predicate(inst));
 if (intel->gen >= 6) {
-   gen6_CONT(p, loop_inst[loop_depth - 1]);
+   gen6_CONT(p);
 } else {
brw_CONT(p, if_depth_in_loop[loop_depth]);
 }

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Add _NEW_RASTERIZER_DISCARD as synonym for _NEW_TRANSFORM.

2011-12-21 Thread Paul Berry
Module: Mesa
Branch: master
Commit: d44878e754e65550c0725feb76fe0cbab0ae5d93
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d44878e754e65550c0725feb76fe0cbab0ae5d93

Author: Paul Berry 
Date:   Tue Dec 20 16:23:17 2011 -0800

mesa: Add _NEW_RASTERIZER_DISCARD as synonym for _NEW_TRANSFORM.

This makes it easier to keep track of which dirty bits correspond to
which pieces of context, since it makes _NEW_RASTERIZER_DISCARD
correspond with ctx->RasterDiscard.

Reviewed-by: Kenneth Graunke 
Reviewed-by: Ian Romanick 
Reviewed-by: Marek Olšák 

---

 src/mesa/drivers/dri/i965/brw_gs.c  |5 +++--
 src/mesa/main/enable.c  |2 +-
 src/mesa/main/mtypes.h  |6 ++
 src/mesa/state_tracker/st_atom_rasterizer.c |4 ++--
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_gs.c 
b/src/mesa/drivers/dri/i965/brw_gs.c
index 2495ad5..886bf98 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -209,7 +209,7 @@ static void populate_key( struct brw_context *brw,
  }
   }
   /* On Gen6, GS is also used for rasterizer discard. */
-  /* _NEW_TRANSFORM_FEEDBACK */
+  /* _NEW_RASTERIZER_DISCARD */
   if (ctx->RasterDiscard) {
  key->need_gs_prog = true;
  key->rasterizer_discard = true;
@@ -258,7 +258,8 @@ const struct brw_tracked_state brw_gs_prog = {
.dirty = {
   .mesa  = (_NEW_LIGHT |
 _NEW_TRANSFORM |
-_NEW_TRANSFORM_FEEDBACK),
+_NEW_TRANSFORM_FEEDBACK |
+_NEW_RASTERIZER_DISCARD),
   .brw   = BRW_NEW_PRIMITIVE,
   .cache = CACHE_NEW_VS_PROG
},
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 749ae98..270b240 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -890,7 +890,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, 
GLboolean state)
   case GL_RASTERIZER_DISCARD:
 CHECK_EXTENSION(EXT_transform_feedback, cap);
  if (ctx->RasterDiscard != state) {
-FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+FLUSH_VERTICES(ctx, _NEW_RASTERIZER_DISCARD);
 ctx->RasterDiscard = state;
  }
  break;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ff97ea9..3d3b006 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3073,6 +3073,12 @@ struct gl_matrix_stack
 #define _NEW_FRAG_CLAMP(1 << 29)
 #define _NEW_TRANSFORM_FEEDBACK (1 << 30) /**< gl_context::TransformFeedback */
 #define _NEW_ALL ~0
+
+/**
+ * We use _NEW_TRANSFORM for GL_RASTERIZER_DISCARD.  This #define is for
+ * clarity.
+ */
+#define _NEW_RASTERIZER_DISCARD _NEW_TRANSFORM
 /*@}*/
 
 
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c 
b/src/mesa/state_tracker/st_atom_rasterizer.c
index 7ebc872..2d6ad45 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -258,7 +258,7 @@ static void update_raster_state( struct st_context *st )
raster->clamp_fragment_color = ctx->Color._ClampFragmentColor;
raster->gl_rasterization_rules = 1;
 
-   /* _NEW_TRANSFORM */
+   /* _NEW_RASTERIZER_DISCARD */
raster->rasterizer_discard = ctx->RasterDiscard;
 
cso_set_rasterizer(st->cso_context, raster);
@@ -276,7 +276,7 @@ const struct st_tracked_state st_update_rasterizer = {
_NEW_PROGRAM |
_NEW_SCISSOR |
_NEW_FRAG_CLAMP |
-   _NEW_TRANSFORM),  /* mesa state dependencies*/
+   _NEW_RASTERIZER_DISCARD),  /* mesa state dependencies*/
   ST_NEW_VERTEX_PROGRAM,  /* state tracker dependencies */
},
update_raster_state /* update function */

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Move RasterDiscard to toplevel of gl_context.

2011-12-21 Thread Paul Berry
Module: Mesa
Branch: master
Commit: aee96806f049c17384a8edc11acce76257d98a57
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=aee96806f049c17384a8edc11acce76257d98a57

Author: Paul Berry 
Date:   Tue Dec 20 16:18:39 2011 -0800

mesa: Move RasterDiscard to toplevel of gl_context.

Previously we were storing the RasterDiscard flag (for
GL_RASTERIZER_DISCARD) in gl_context::TransformFeedback.  This was
confusing, because we use the _NEW_TRANSFORM flag (not
_NEW_TRANSFORM_FEEDBACK) to track state updates to it, and because
rasterizer discard has effects even when transform feedback is not in
use.

This patch makes RasterDiscard a toplevel element in gl_context rather
than a subfield of gl_context::TransformFeedback.

Note: We can't put RasterDiscard inside gl_context::Transform, since
all items inside gl_context::Transform need to be pieces of state that
are saved and restored using PushAttrib and PopAttrib.

Reviewed-by: Kenneth Graunke 
Reviewed-by: Ian Romanick 
Reviewed-by: Marek Olšák 

---

 src/mesa/drivers/dri/i965/brw_gs.c  |2 +-
 src/mesa/main/accum.c   |2 +-
 src/mesa/main/clear.c   |   14 +++---
 src/mesa/main/drawpix.c |6 +++---
 src/mesa/main/enable.c  |6 +++---
 src/mesa/main/get.c |2 +-
 src/mesa/main/mtypes.h  |4 ++--
 src/mesa/state_tracker/st_atom_rasterizer.c |2 +-
 8 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_gs.c 
b/src/mesa/drivers/dri/i965/brw_gs.c
index ee3f94c..2495ad5 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -210,7 +210,7 @@ static void populate_key( struct brw_context *brw,
   }
   /* On Gen6, GS is also used for rasterizer discard. */
   /* _NEW_TRANSFORM_FEEDBACK */
-  if (ctx->TransformFeedback.RasterDiscard) {
+  if (ctx->RasterDiscard) {
  key->need_gs_prog = true;
  key->rasterizer_discard = true;
   }
diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
index eb06bbb..a8c30c2 100644
--- a/src/mesa/main/accum.c
+++ b/src/mesa/main/accum.c
@@ -100,7 +100,7 @@ _mesa_Accum( GLenum op, GLfloat value )
   return;
}
 
-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)
   return;
 
if (ctx->RenderMode == GL_RENDER) {
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 2e27c95..bd5c012 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -200,7 +200,7 @@ _mesa_Clear( GLbitfield mask )
ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax)
   return;
 
-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)
   return;
 
if (ctx->RenderMode == GL_RENDER) {
@@ -338,7 +338,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const 
GLint *value)
  drawbuffer);
  return;
   }
-  else if (!ctx->TransformFeedback.RasterDiscard) {
+  else if (!ctx->RasterDiscard) {
  /* Save current stencil clear value, set to 'value', do the
   * stencil clear and restore the clear value.
   * XXX in the future we may have a new ctx->Driver.ClearBuffer()
@@ -362,7 +362,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const 
GLint *value)
 drawbuffer);
 return;
  }
- else if (mask && !ctx->TransformFeedback.RasterDiscard) {
+ else if (mask && !ctx->RasterDiscard) {
 union gl_color_union clearSave;
 
 /* save color */
@@ -432,7 +432,7 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const 
GLuint *value)
 drawbuffer);
 return;
  }
- else if (mask && !ctx->TransformFeedback.RasterDiscard) {
+ else if (mask && !ctx->RasterDiscard) {
 union gl_color_union clearSave;
 
 /* save color */
@@ -513,7 +513,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const 
GLfloat *value)
  drawbuffer);
  return;
   }
-  else if (!ctx->TransformFeedback.RasterDiscard) {
+  else if (!ctx->RasterDiscard) {
  /* Save current depth clear value, set to 'value', do the
   * depth clear and restore the clear value.
   * XXX in the future we may have a new ctx->Driver.ClearBuffer()
@@ -538,7 +538,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const 
GLfloat *value)
 drawbuffer);
 return;
  }
- else if (mask && !ctx->TransformFeedback.RasterDiscard) {
+ else if (mask && !ctx->RasterDiscard) {
 union gl_color_union clearSave;
 
 /* save color */
@@ -615,7 +615,7 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
   return;
}
 
-   if (ctx->TransformFeedback.RasterDiscard)
+   if (ctx->RasterDiscard)

Mesa (master): egl/x11: Merge the right version of Frederiks change

2011-12-21 Thread Kristian Høgsberg
Module: Mesa
Branch: master
Commit: 636f2fc46c83d471b60b96bca1ced0c78b3415b5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=636f2fc46c83d471b60b96bca1ced0c78b3415b5

Author: Kristian Høgsberg 
Date:   Wed Dec 21 10:29:04 2011 -0500

egl/x11: Merge the right version of Frederiks change

Argh, I merged an older broken version of the swapbuffer change instead of
Frederiks fixed version.  This diffs gets us back to the right version.

---

 src/egl/drivers/dri2/platform_x11.c |   29 -
 1 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index a00e3fe..a100f4d 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -740,23 +740,12 @@ dri2_swap_buffers_msc(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *draw,
 #endif
 
return swap_count;
-#else /* XCB_DRI2_MINOR_VERSION >= 3 */
-   return dri2_copy_region(drv, disp, draw, dri2_surf->region) ? 0 : -1;
-#endif
-}
-
-static void
-dri2_flush_if_current(_EGLDriver *drv, _EGLSurface *draw)
-{
-   struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
+#else
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
 
-   if (dri2_drv->glFlush) {
-  _EGLContext *ctx = _eglGetCurrentContext();
+   return dri2_copy_region(drv, disp, draw, dri2_surf->region) ? 0 : -1;
+#endif /* XCB_DRI2_MINOR_VERSION >= 3 */
 
-  if (ctx && ctx->DrawSurface == &dri2_surf->base)
- dri2_drv->glFlush();
-   }
 }
 
 static EGLBoolean
@@ -766,8 +755,6 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *draw)
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
 
if (dri2_dpy->dri2) {
-  dri2_flush_if_current(drv, draw);
-
   return dri2_swap_buffers_msc(drv, disp, draw, 0, 0, 0) != -1;
} else {
   assert(dri2_dpy->swrast);
@@ -788,8 +775,6 @@ dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay 
*disp, _EGLSurface *draw,
xcb_rectangle_t rectangles[16];
int i;
 
-   dri2_flush_if_current(drv, draw);
-
if (numRects > (int)ARRAY_SIZE(rectangles))
   return dri2_copy_region(drv, disp, draw, dri2_surf->region);
 
@@ -827,6 +812,7 @@ dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *surf, EGLint
 #if XCB_DRI2_MINOR_VERSION >= 3
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+#endif
 
/* XXX Check vblank_mode here? */
 
@@ -835,15 +821,14 @@ dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *surf, EGLint
else if (interval < surf->Config->MinSwapInterval)
   interval = surf->Config->MinSwapInterval;
 
+#if XCB_DRI2_MINOR_VERSION >= 3
if (interval != surf->SwapInterval && dri2_dpy->swap_available)
   xcb_dri2_swap_interval(dri2_dpy->conn, dri2_surf->drawable, interval);
+#endif
 
surf->SwapInterval = interval;
 
return EGL_TRUE;
-#else
-   return EGL_FALSE;
-#endif
 }
 
 static EGLBoolean
@@ -1130,8 +1115,10 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay 
*disp)
dri2_dpy->extensions[1] = &image_lookup_extension.base;
dri2_dpy->extensions[2] = NULL;
 
+#if XCB_DRI2_MINOR_VERSION >= 3
dri2_dpy->swap_available = (dri2_dpy->dri2_minor >= 2);
dri2_dpy->invalidate_available = (dri2_dpy->dri2_minor >= 3);
+#endif
 
if (!dri2_create_screen(disp))
   goto cleanup_fd;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit