Programmable per-vertex point sizes and proper result reg assigns.
authorAapo Tahkola <aet@rasterburn.org>
Sat, 28 May 2005 01:02:00 +0000 (01:02 +0000)
committerAapo Tahkola <aet@rasterburn.org>
Sat, 28 May 2005 01:02:00 +0000 (01:02 +0000)
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_maos.c
src/mesa/drivers/dri/r300/r300_shader.c
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r300_vertexprog.c

index befb19ec9f945a6066cd910987d333ef06c3f491..723bee7548a8351d145150a3751b9ad118ed7d0f 100644 (file)
@@ -573,7 +573,7 @@ extern int hw_tcl_on;
 
 #define CURRENT_VERTEX_SHADER(ctx) (ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : ctx->_TnlProgram)
 
-//#define TMU_ENABLED(ctx, unit) (hw_tcl_on ? ctx->Texture.Unit[unit]._ReallyEnabled && (OutputsWritten & (1<<(VERT_RESULT_TEX0+(unit)))) : \
+//#define TMU_ENABLED(ctx, unit) (hw_tcl_on ? ctx->Texture.Unit[unit]._ReallyEnabled && (OutputsWritten & (1<<(VERT_RESULT_TEX0+(unit)))) : 
 //     (r300->state.render_inputs & (_TNL_BIT_TEX0<<(unit))))
 #define TMU_ENABLED(ctx, unit) (hw_tcl_on ? ctx->Texture.Unit[unit]._ReallyEnabled && OutputsWritten & (1<<(VERT_RESULT_TEX0+(unit))) : \
        ctx->Texture.Unit[unit]._ReallyEnabled && r300->state.render_inputs & (_TNL_BIT_TEX0<<(unit)))
@@ -591,7 +591,7 @@ struct r300_vertex_program {
        int pos_end;
        unsigned long num_temporaries; /* Number of temp vars used by program */
        int inputs[VERT_ATTRIB_MAX];
-       int tex_regs[8];
+       int outputs[VERT_RESULT_MAX];
 };
 
 #if USE_ARB_F_P == 1
index 301b4b7575e19b738780227f4b613fac62472372..d9a10b0a0683903ff93d9e5554f0d5a59bf3edb9 100644 (file)
@@ -396,11 +396,6 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
                }
        }
        
-
-int cmd_reserved=0;
-int cmd_written=0;
-drm_radeon_cmd_header_t *cmd = NULL;
-
 #define SHOW_INFO(n) do { \
        if (RADEON_DEBUG & DEBUG_ALL) { \
        fprintf(stderr, "RR[%d] - sz=%d, reg=%d, fmt=%d -- st=%d, of=0x%08x\n", \
@@ -529,7 +524,9 @@ drm_radeon_cmd_header_t *cmd = NULL;
                if(OutputsWritten & (1<<VERT_RESULT_BFC1))
                        r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;*/
                //if(OutputsWritten & (1<<VERT_RESULT_FOGC))
-               //if(OutputsWritten & (1<<VERT_RESULT_PSIZ))
+
+               if(OutputsWritten & (1<<VERT_RESULT_PSIZ))
+                       r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
 
                for(i=0;i < ctx->Const.MaxTextureUnits;i++)
                        if(OutputsWritten & (1<<(VERT_RESULT_TEX0+i)))
index c3e4a041d54d1e89f45c673f62e2f61c78c6a6d7..0613dd887fbae9049ae2190426ef877f83a9428f 100644 (file)
@@ -66,11 +66,8 @@ static struct program *r300NewProgram(GLcontext *ctx, GLenum target, GLuint id)
 
 static void r300DeleteProgram(GLcontext *ctx, struct program *prog)
 {
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       struct r300_vertex_program *vp=(void *)prog;
-       
-       /*if(rmesa->current_vp == vp)
-               rmesa->current_vp = NULL;*/
+       //r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       //struct r300_vertex_program *vp=(void *)prog;
        
        _mesa_delete_program(ctx, prog);
 }
@@ -99,8 +96,8 @@ void r300ProgramStringNotify(GLcontext *ctx, GLenum target,
 
 static GLboolean r300IsProgramNative(GLcontext *ctx, GLenum target, struct program *prog)
 {
-       struct r300_vertex_program *vp=(void *)prog;
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       //struct r300_vertex_program *vp=(void *)prog;
+       //r300ContextPtr rmesa = R300_CONTEXT(ctx);
 
        return 1;
 }
index 6a14231869976da110e917fdaac0740cd1ee1b87..4cadfd3f02fbae171e51be32f4907caad9ca13f5 100644 (file)
@@ -1178,6 +1178,7 @@ void r300_setup_rs_unit(GLcontext *ctx)
                        | (in_texcoords << R300_RS_CNTL_TC_CNT_SHIFT)
                        | R300_RS_CNTL_0_UNKNOWN_7
                        | R300_RS_CNTL_0_UNKNOWN_18;
+       
 
        if (r300->state.texture.tc_count > 0) {
                        r300->hw.rr.cmd[R300_RR_CMD_0] = cmducs(R300_RS_ROUTE_0, fp_reg);
index d5a466414455072b4ee5b191687b2d742bff4a9f..8a10931538c1a568e14548fc2d8c1e2f6b1bd363 100644 (file)
@@ -313,42 +313,14 @@ static unsigned long t_dst_class(enum register_file file)
 
 static unsigned long t_dst_index(struct r300_vertex_program *vp, struct vp_dst_register *dst)
 {
-       int i, high=0;
-       if(dst->File == PROGRAM_OUTPUT)
-               switch(dst->Index){
-                       case VERT_RESULT_HPOS:
-                               return 0;
-                       case VERT_RESULT_COL0:
-                               return 1;
-                       case VERT_RESULT_TEX0:
-                       case VERT_RESULT_TEX1:
-                       case VERT_RESULT_TEX2:
-                       case VERT_RESULT_TEX3:
-                       case VERT_RESULT_TEX4:
-                       case VERT_RESULT_TEX5:
-                       case VERT_RESULT_TEX6:
-                       case VERT_RESULT_TEX7:
-                               /* Awful hack to get tex coord results regs correctly packed. 
-                                  Wount work if tex coords arent written in logical order! */
-                               if(vp->tex_regs[dst->Index - VERT_RESULT_TEX0] != 1){
-                                       return vp->tex_regs[dst->Index - VERT_RESULT_TEX0];
-                               }
-                               
-                               for(i=0; i < 8; i++)
-                                       if(vp->tex_regs[i] > high)
-                                               high = vp->tex_regs[i];
-                               
-                               high++;
-                               vp->tex_regs[dst->Index - VERT_RESULT_TEX0] = high;
-                               
-                               return high;
-                       case VERT_RESULT_COL1:
-                       case VERT_RESULT_BFC0:
-                       case VERT_RESULT_BFC1:
-                       case VERT_RESULT_FOGC:
-                       case VERT_RESULT_PSIZ:
-                       default: WARN_ONCE("Unknown output\n"); return 10;
+       if(dst->File == PROGRAM_OUTPUT) {
+               if (vp->outputs[dst->Index] != -1)
+                       return vp->outputs[dst->Index];
+               else {
+                       WARN_ONCE("Unknown output %d\n", dst->Index);
+                       return 10;
                }
+       }
        return dst->Index;
 }
 
@@ -509,8 +481,7 @@ void translate_vertex_shader(struct r300_vertex_program *vp)
 {
        struct vertex_program *mesa_vp=(void *)vp;
        struct vp_instruction *vpi;
-       int operand_index, i;
-       VERTEX_SHADER_INSTRUCTION t2rs[1024];
+       int i, cur_reg=0;
        VERTEX_SHADER_INSTRUCTION *o_inst;
        unsigned long operands;
        int are_srcs_scalar;
@@ -527,11 +498,43 @@ void translate_vertex_shader(struct r300_vertex_program *vp)
        vp->pos_end=0; /* Not supported yet */
        vp->program.length=0;
        vp->num_temporaries=mesa_vp->Base.NumTemporaries;
-       for(i=0; i < 8; i++)
-               vp->tex_regs[i]=1;
        
        for(i=0; i < VERT_ATTRIB_MAX; i++)
-               vp->inputs[i]=-1;
+               vp->inputs[i] = -1;
+
+       for(i=0; i < VERT_RESULT_MAX; i++)
+               vp->outputs[i] = -1;
+       
+       assert(mesa_vp->OutputsWritten & (1 << VERT_RESULT_HPOS));
+       assert(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL0));
+       
+       /* Assign outputs */
+       if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_HPOS))
+               vp->outputs[VERT_RESULT_HPOS] = cur_reg++;
+       
+       if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_PSIZ))
+               vp->outputs[VERT_RESULT_PSIZ] = cur_reg++;
+       
+       if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL0))
+               vp->outputs[VERT_RESULT_COL0] = cur_reg++;
+       
+#if 0 /* Not supported yet */
+       if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_BFC0))
+               vp->outputs[VERT_RESULT_BFC0] = cur_reg++;
+       
+       if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL1))
+               vp->outputs[VERT_RESULT_COL1] = cur_reg++;
+       
+       if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_BFC1))
+               vp->outputs[VERT_RESULT_BFC1] = cur_reg++;
+       
+       if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_FOGC))
+               vp->outputs[VERT_RESULT_FOGC] = cur_reg++;
+#endif
+       
+       for(i=VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++)
+               if(mesa_vp->OutputsWritten & (1 << i))
+                       vp->outputs[i] = cur_reg++;
        
        o_inst=vp->program.body.i;
        for(vpi=mesa_vp->Instructions; vpi->Opcode != VP_OPCODE_END; vpi++, o_inst++){