[Mesa-dev] [PATCH 1/2] i965: Remove vestiges of function call support from the old VS backend.

Kenneth Graunke kenneth at whitecape.org
Mon Apr 2 14:30:52 PDT 2012


This never worked.  brwProgramStringNotify also explicitly rejects
programs that use CAL and RET.  So there's no need for this to exist.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_eu.c      |  124 -------------------------------
 src/mesa/drivers/dri/i965/brw_eu.h      |   20 -----
 src/mesa/drivers/dri/i965/brw_vs.h      |    3 -
 src/mesa/drivers/dri/i965/brw_vs_emit.c |   41 ----------
 4 files changed, 0 insertions(+), 188 deletions(-)

Note: these patches were only compile tested.

diff --git a/src/mesa/drivers/dri/i965/brw_eu.c b/src/mesa/drivers/dri/i965/brw_eu.c
index 2b0593a..00b9671 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -218,127 +218,3 @@ const GLuint *brw_get_program( struct brw_compile *p,
    *sz = p->nr_insn * sizeof(struct brw_instruction);
    return (const GLuint *)p->store;
 }
-
-
-
-/**
- * Subroutine calls require special attention.
- * Mesa instructions may be expanded into multiple hardware instructions
- * so the prog_instruction::BranchTarget field can't be used as an index
- * into the hardware instructions.
- *
- * The BranchTarget field isn't needed, however.  Mesa's GLSL compiler
- * emits CAL and BGNSUB instructions with labels that can be used to map
- * subroutine calls to actual subroutine code blocks.
- *
- * The structures and function here implement patching of CAL instructions
- * so they jump to the right subroutine code...
- */
-
-
-/**
- * For each OPCODE_BGNSUB we create one of these.
- */
-struct brw_glsl_label
-{
-   const char *name; /**< the label string */
-   GLuint position;  /**< the position of the brw instruction for this label */
-   struct brw_glsl_label *next;  /**< next in linked list */
-};
-
-
-/**
- * For each OPCODE_CAL we create one of these.
- */
-struct brw_glsl_call
-{
-   GLuint call_inst_pos;  /**< location of the CAL instruction */
-   const char *sub_name;  /**< name of subroutine to call */
-   struct brw_glsl_call *next;  /**< next in linked list */
-};
-
-
-/**
- * Called for each OPCODE_BGNSUB.
- */
-void
-brw_save_label(struct brw_compile *c, const char *name, GLuint position)
-{
-   struct brw_glsl_label *label = CALLOC_STRUCT(brw_glsl_label);
-   label->name = name;
-   label->position = position;
-   label->next = c->first_label;
-   c->first_label = label;
-}
-
-
-/**
- * Called for each OPCODE_CAL.
- */
-void
-brw_save_call(struct brw_compile *c, const char *name, GLuint call_pos)
-{
-   struct brw_glsl_call *call = CALLOC_STRUCT(brw_glsl_call);
-   call->call_inst_pos = call_pos;
-   call->sub_name = name;
-   call->next = c->first_call;
-   c->first_call = call;
-}
-
-
-/**
- * Lookup a label, return label's position/offset.
- */
-static GLuint
-brw_lookup_label(struct brw_compile *c, const char *name)
-{
-   const struct brw_glsl_label *label;
-   for (label = c->first_label; label; label = label->next) {
-      if (strcmp(name, label->name) == 0) {
-         return label->position;
-      }
-   }
-   abort();  /* should never happen */
-   return ~0;
-}
-
-
-/**
- * When we're done generating code, this function is called to resolve
- * subroutine calls.
- */
-void
-brw_resolve_cals(struct brw_compile *c)
-{
-    const struct brw_glsl_call *call;
-
-    for (call = c->first_call; call; call = call->next) {
-        const GLuint sub_loc = brw_lookup_label(c, call->sub_name);
-	struct brw_instruction *brw_call_inst = &c->store[call->call_inst_pos];
-	struct brw_instruction *brw_sub_inst = &c->store[sub_loc];
-	GLint offset = brw_sub_inst - brw_call_inst;
-
-	/* patch brw_inst1 to point to brw_inst2 */
-	brw_set_src1(c, brw_call_inst, brw_imm_d(offset * 16));
-    }
-
-    /* free linked list of calls */
-    {
-        struct brw_glsl_call *call, *next;
-        for (call = c->first_call; call; call = next) {
-	    next = call->next;
-	    free(call);
-	}
-	c->first_call = NULL;
-    }
-
-    /* free linked list of labels */
-    {
-        struct brw_glsl_label *label, *next;
-	for (label = c->first_label; label; label = next) {
-	    next = label->next;
-	    free(label);
-	}
-	c->first_label = NULL;
-    }
-}
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
index 373f2ab..c4c62b2 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -102,11 +102,6 @@ struct brw_indirect {
 };
 
 
-struct brw_glsl_label;
-struct brw_glsl_call;
-
-
-
 #define BRW_EU_MAX_INSN_STACK 5
 
 struct brw_compile {
@@ -151,23 +146,8 @@ struct brw_compile {
    int *if_depth_in_loop;
    int loop_stack_depth;
    int loop_stack_array_size;
-
-   struct brw_glsl_label *first_label;  /**< linked list of labels */
-   struct brw_glsl_call *first_call;    /**< linked list of CALs */
 };
 
-
-void
-brw_save_label(struct brw_compile *c, const char *name, GLuint position);
-
-void
-brw_save_call(struct brw_compile *c, const char *name, GLuint call_pos);
-
-void
-brw_resolve_cals(struct brw_compile *c);
-
-
-
 static INLINE int type_sz( GLuint type )
 {
    switch( type ) {
diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h
index 490fcc0..6d3b6ce 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.h
+++ b/src/mesa/drivers/dri/i965/brw_vs.h
@@ -102,7 +102,6 @@ struct brw_vs_compile {
    struct brw_reg r1;
    struct brw_reg regs[PROGRAM_ADDRESS+1][128];
    struct brw_reg tmp;
-   struct brw_reg stack;
 
    struct {	
        bool used_in_src;
@@ -116,8 +115,6 @@ struct brw_vs_compile {
       GLint index;
       struct brw_reg reg;
    } current_const[3];
-
-   bool needs_stack;
 };
 
 bool brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c);
diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index 4bdd366..d0ee5f3 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -378,11 +378,6 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
       }
    }
 
-   if (c->needs_stack) {
-      c->stack =  brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg, 0);
-      reg += 2;
-   }
-
    /* Some opcodes need an internal temporary:
     */
    c->first_tmp = reg;
@@ -1842,7 +1837,6 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
    struct intel_context *intel = &brw->intel;
    const GLuint nr_insns = c->vp->program.Base.NumInstructions;
    GLuint insn;
-   const struct brw_indirect stack_index = brw_indirect(0, 0);   
    GLuint index;
    GLuint file;
 
@@ -1872,15 +1866,6 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
 	   if (file == PROGRAM_OUTPUT && index != VERT_RESULT_HPOS)
 	       c->output_regs[index].used_in_src = true;
        }
-
-       switch (inst->Opcode) {
-       case OPCODE_CAL:
-       case OPCODE_RET:
-	  c->needs_stack = true;
-	  break;
-       default:
-	  break;
-       }
    }
 
    /* Static register allocation
@@ -1889,9 +1874,6 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
 
    brw_vs_rescale_gl_fixed(c);
 
-   if (c->needs_stack)
-      brw_MOV(p, get_addr_reg(stack_index), brw_address(c->stack));
-
    for (insn = 0; insn < nr_insns; insn++) {
 
       const struct prog_instruction *inst = &c->vp->program.Base.Instructions[insn];
@@ -2115,34 +2097,12 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
          brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
 	 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
          break;
-      case OPCODE_CAL:
-	 brw_set_access_mode(p, BRW_ALIGN_1);
-	 brw_ADD(p, deref_1d(stack_index, 0), brw_ip_reg(), brw_imm_d(3*16));
-	 brw_set_access_mode(p, BRW_ALIGN_16);
-	 brw_ADD(p, get_addr_reg(stack_index),
-			 get_addr_reg(stack_index), brw_imm_d(4));
-         brw_save_call(p, inst->Comment, p->nr_insn);
-	 brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
-         break;
-      case OPCODE_RET:
-	 brw_ADD(p, get_addr_reg(stack_index),
-			 get_addr_reg(stack_index), brw_imm_d(-4));
-	 brw_set_access_mode(p, BRW_ALIGN_1);
-         brw_MOV(p, brw_ip_reg(), deref_1d(stack_index, 0));
-	 brw_set_access_mode(p, BRW_ALIGN_16);
-	 break;
       case OPCODE_END:
 	 emit_vertex_write(c);
          break;
       case OPCODE_PRINT:
          /* no-op */
          break;
-      case OPCODE_BGNSUB:
-         brw_save_label(p, inst->Comment, p->nr_insn);
-         break;
-      case OPCODE_ENDSUB:
-         /* no-op */
-         break;
       default:
 	 _mesa_problem(NULL, "Unsupported opcode %i (%s) in vertex shader",
                        inst->Opcode, inst->Opcode < MAX_OPCODE ?
@@ -2200,7 +2160,6 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
       release_tmps(c);
    }
 
-   brw_resolve_cals(p);
    brw_set_uip_jip(p);
 
    brw_optimize(p);
-- 
1.7.7.6



More information about the mesa-dev mailing list