i965g: don't set up vs stack register for non-branching shaders
authorKeith Whitwell <keithw@vmware.com>
Fri, 6 Nov 2009 10:24:19 +0000 (10:24 +0000)
committerKeith Whitwell <keithw@vmware.com>
Fri, 6 Nov 2009 10:24:19 +0000 (10:24 +0000)
src/gallium/drivers/i965/brw_context.h
src/gallium/drivers/i965/brw_pipe_shader.c
src/gallium/drivers/i965/brw_vs_emit.c
src/gallium/drivers/i965/brw_wm.c
src/gallium/drivers/i965/brw_wm.h

index 34799d52114bdabea79416ef85719b0a118652e4..b81dff0aa058af0fd9d7ee0ab75b12b92aa2bfaf 100644 (file)
@@ -154,6 +154,8 @@ struct brw_vertex_shader {
    const struct tgsi_token *tokens;
    struct tgsi_shader_info info;
 
+   unsigned  has_flow_control:1;
+
    unsigned id;
    struct brw_winsys_buffer *const_buffer;    /** Program constant buffer/surface */
    GLboolean use_const_buffer;
index 662c43c3e5f2ab20d5f3c90de636a39c16e74cbd..44f9ad6f9cd18256083f5c56d9211ced6cf45d1b 100644 (file)
  * Determine if the given shader uses complex features such as flow
  * conditionals, loops, subroutines.
  */
-GLboolean brw_wm_has_flow_control(const struct brw_fragment_shader *fp)
+static GLboolean has_flow_control(const struct tgsi_shader_info *info)
 {
-    return (fp->info.opcode_count[TGSI_OPCODE_ARL] > 0 ||
-           fp->info.opcode_count[TGSI_OPCODE_IF] > 0 ||
-           fp->info.opcode_count[TGSI_OPCODE_ENDIF] > 0 || /* redundant - IF */
-           fp->info.opcode_count[TGSI_OPCODE_CAL] > 0 ||
-           fp->info.opcode_count[TGSI_OPCODE_BRK] > 0 ||   /* redundant - BGNLOOP */
-           fp->info.opcode_count[TGSI_OPCODE_RET] > 0 ||   /* redundant - CAL */
-           fp->info.opcode_count[TGSI_OPCODE_BGNLOOP] > 0);
+    return (info->opcode_count[TGSI_OPCODE_ARL] > 0 ||
+           info->opcode_count[TGSI_OPCODE_IF] > 0 ||
+           info->opcode_count[TGSI_OPCODE_ENDIF] > 0 || /* redundant - IF */
+           info->opcode_count[TGSI_OPCODE_CAL] > 0 ||
+           info->opcode_count[TGSI_OPCODE_BRK] > 0 ||   /* redundant - BGNLOOP */
+           info->opcode_count[TGSI_OPCODE_RET] > 0 ||   /* redundant - CAL */
+           info->opcode_count[TGSI_OPCODE_BGNLOOP] > 0);
 }
 
 
@@ -88,7 +88,7 @@ static void *brw_create_fs_state( struct pipe_context *pipe,
    /* Duplicate tokens, scan shader
     */
    fs->id = brw->program_id++;
-   fs->has_flow_control = brw_wm_has_flow_control(fs);
+   fs->has_flow_control = has_flow_control(&fs->info);
 
    fs->tokens = tgsi_dup_tokens(shader->tokens);
    if (fs->tokens == NULL)
@@ -126,7 +126,7 @@ static void *brw_create_vs_state( struct pipe_context *pipe,
    /* Duplicate tokens, scan shader
     */
    vs->id = brw->program_id++;
-   //vs->has_flow_control = brw_wm_has_flow_control(vs);
+   vs->has_flow_control = has_flow_control(&vs->info);
 
    vs->tokens = tgsi_dup_tokens(shader->tokens);
    if (vs->tokens == NULL)
index 25aea87b8f9f855bc4f3e91a265dccc61e0e9d59..e0fadc8dce70b38eae55cea7bb4f5e7fe4c355c4 100644 (file)
@@ -252,8 +252,10 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
    }
 #endif
 
-   c->stack =  brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg, 0);
-   reg += 2;
+   if (c->vp->has_flow_control) {
+      c->stack =  brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg, 0);
+      reg += 2;
+   }
 
    /* Some opcodes need an internal temporary:
     */
@@ -1592,7 +1594,10 @@ void brw_vs_emit(struct brw_vs_compile *c)
    /* Static register allocation
     */
    brw_vs_alloc_regs(c);
-   brw_MOV(p, get_addr_reg(c->stack_index), brw_address(c->stack));
+
+   if (c->vp->has_flow_control) {
+      brw_MOV(p, get_addr_reg(c->stack_index), brw_address(c->stack));
+   }
 
    /* Instructions
     */
index 93f90bf32981d60d57c435db559d8668cb1031cf..7f2cb152563172c3d1bab896f3622e348105e575 100644 (file)
@@ -162,9 +162,6 @@ static enum pipe_error do_wm_prog( struct brw_context *brw,
 
    brw_init_compile(brw, &c->func);
 
-   /* temporary sanity check assertion */
-   assert(fp->has_flow_control == brw_wm_has_flow_control(c->fp));
-
    /*
     * Shader which use GLSL features such as flow control are handled
     * differently from "simple" shaders.
index 48dac397561880cd1d50fceeb20758de78a02994..28d216260e52d363a1b2c97efa637fba3b08ff38 100644 (file)
@@ -338,7 +338,6 @@ void brw_wm_lookup_iz( GLuint line_aa,
                       GLboolean ps_uses_depth,
                       struct brw_wm_prog_key *key );
 
-GLboolean brw_wm_has_flow_control(const struct brw_fragment_shader *fp);
 void brw_wm_branching_shader_emit(struct brw_context *brw, struct brw_wm_compile *c);
 
 void emit_ddxy(struct brw_compile *p,