[Mesa-dev] [PATCH 01/10] i965/sf: Reset flag_value to 0xff before emitting SF subroutines.

Kenneth Graunke kenneth at whitecape.org
Sun May 25 01:08:47 PDT 2014


When compiling any of the SF program variants, flag_value starts off as
0xff and will be modified when generating code.

brw_emit_anyprim_setup emits several subroutines, saving and restoring
flag_value across each of them.  Since it starts out as 0xff, this is
equivalent to simply setting it to 0xff at the start of each subroutine.

Resetting the value makes more logical sense; each subroutine doesn't
know whether one of the others even executed, much less what it did
to the flag register.

This also lets us to drop the brw_set_predicate_control_flag_value call
from brw_init_compile: predicate is already initialized to
BRW_PREDICATE_NONE by the memset, and the value of flag_value is
irrelevant (as it's only used by the SF compiler).

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_eu.c      |  1 -
 src/mesa/drivers/dri/i965/brw_sf_emit.c | 18 ++++--------------
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.c b/src/mesa/drivers/dri/i965/brw_eu.c
index 34f0ba5..c4ded5a 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -230,7 +230,6 @@ brw_init_compile(struct brw_context *brw, struct brw_compile *p, void *mem_ctx)
    brw_set_mask_control(p, BRW_MASK_ENABLE); /* what does this do? */
    brw_set_saturate(p, 0);
    brw_set_compression_control(p, BRW_COMPRESSION_NONE);
-   brw_set_predicate_control_flag_value(p, 0xff);
 
    /* Set up control flow stack */
    p->if_stack_depth = 0;
diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c b/src/mesa/drivers/dri/i965/brw_sf_emit.c
index 8664741..c3d3496 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c
@@ -422,6 +422,7 @@ void brw_emit_tri_setup(struct brw_sf_compile *c, bool allocate)
    struct brw_compile *p = &c->func;
    GLuint i;
 
+   p->flag_value = 0xff;
    c->nr_verts = 3;
 
    if (allocate)
@@ -508,7 +509,7 @@ void brw_emit_line_setup(struct brw_sf_compile *c, bool allocate)
    struct brw_compile *p = &c->func;
    GLuint i;
 
-
+   p->flag_value = 0xff;
    c->nr_verts = 2;
 
    if (allocate)
@@ -578,6 +579,7 @@ void brw_emit_point_sprite_setup(struct brw_sf_compile *c, bool allocate)
    struct brw_compile *p = &c->func;
    GLuint i;
 
+   p->flag_value = 0xff;
    c->nr_verts = 1;
 
    if (allocate)
@@ -668,6 +670,7 @@ void brw_emit_point_setup(struct brw_sf_compile *c, bool allocate)
    struct brw_compile *p = &c->func;
    GLuint i;
 
+   p->flag_value = 0xff;
    c->nr_verts = 1;
 
    if (allocate)
@@ -729,8 +732,6 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
    int jmp;
    struct brw_reg v1_null_ud = vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD));
 
-   GLuint saveflag;
-
    c->nr_verts = 3;
    alloc_regs(c);
 
@@ -749,15 +750,9 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
 					       (1<<_3DPRIM_TRIFAN_NOSTIPPLE)));
    jmp = brw_JMPI(p, ip, ip, brw_imm_d(0)) - p->store;
    {
-      saveflag = p->flag_value;
       brw_push_insn_state(p);
       brw_emit_tri_setup( c, false );
       brw_pop_insn_state(p);
-      p->flag_value = saveflag;
-      /* note - thread killed in subroutine, so must
-       * restore the flag which is changed when building
-       * the subroutine. fix #13240
-       */
    }
    brw_land_fwd_jump(p, jmp);
 
@@ -770,12 +765,9 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
 					       (1<<_3DPRIM_LINESTRIP_CONT_BF)));
    jmp = brw_JMPI(p, ip, ip, brw_imm_d(0)) - p->store;
    {
-      saveflag = p->flag_value;
       brw_push_insn_state(p);
       brw_emit_line_setup( c, false );
       brw_pop_insn_state(p);
-      p->flag_value = saveflag;
-      /* note - thread killed in subroutine */
    }
    brw_land_fwd_jump(p, jmp);
 
@@ -783,11 +775,9 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
    brw_AND(p, v1_null_ud, payload_attr, brw_imm_ud(1<<BRW_SPRITE_POINT_ENABLE));
    jmp = brw_JMPI(p, ip, ip, brw_imm_d(0)) - p->store;
    {
-      saveflag = p->flag_value;
       brw_push_insn_state(p);
       brw_emit_point_sprite_setup( c, false );
       brw_pop_insn_state(p);
-      p->flag_value = saveflag;
    }
    brw_land_fwd_jump(p, jmp);
 
-- 
1.9.2



More information about the mesa-dev mailing list