Misc fixes.
authorAapo Tahkola <aet@rasterburn.org>
Fri, 18 Mar 2005 14:44:27 +0000 (14:44 +0000)
committerAapo Tahkola <aet@rasterburn.org>
Fri, 18 Mar 2005 14:44:27 +0000 (14:44 +0000)
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_maos.c
src/mesa/drivers/dri/r300/r300_render.c
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r300_vertexprog.c

index 9075f6321fe9c72580d0b801a9bfb8b3417fc24c..13c6fb03b912a037368e2d7a2728d55e4649d30c 100644 (file)
@@ -566,6 +566,9 @@ struct r300_vertex_shader_state {
        int unknown_ptr3;  /* pointer within program space */
        };
        
+#define VERTPROG_ACTIVE(ctx) ( ctx->VertexProgram._Enabled && (R300_CONTEXT(ctx)->current_vp != NULL) && \
+       (R300_CONTEXT(ctx)->current_vp->translated) )
+       
 /* r300_vertex_shader_state and r300_vertex_program should probably be merged together someday.
  * Keeping them them seperate for now should ensure fixed pipeline keeps functioning properly.
  */    
index 946eb31f0c4ea89eb20e5d464b81d876d8afc172..4decd1e6a204e6b33e89ff9de4b7f813b25fd026 100644 (file)
@@ -254,7 +254,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
                        exit(-1); \
                } \
                \
-               if (rmesa->current_vp == NULL) \
+               if (VERTPROG_ACTIVE(ctx) == GL_FALSE) \
                        rmesa->state.aos[nr-1].aos_reg = aa_vap_reg++; \
                rmesa->state.aos[nr-1].aos_format = f; \
                if (immd) { \
@@ -272,7 +272,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
                } \
 }
 
-       if (rmesa->current_vp != NULL && ctx->VertexProgram._Enabled) {
+       if (VERTPROG_ACTIVE(ctx)) {
                if (rmesa->current_vp->inputs[VERT_ATTRIB_POS] != -1) {
                        inputs |= _TNL_BIT_POS;
                        rmesa->state.aos[nr++].aos_reg = rmesa->current_vp->inputs[VERT_ATTRIB_POS];
@@ -497,7 +497,7 @@ drm_radeon_cmd_header_t *cmd = NULL;
 #endif
 
        /* Stage 3: VAP output */
-       if (rmesa->current_vp != NULL && ctx->VertexProgram._Enabled)
+       if (VERTPROG_ACTIVE(ctx))
                outputs = rmesa->current_vp->outputs;
        else
                outputs = inputs;
index b855c816737859cc13ed3e8a53ea5ea1aef4faaf..894d3d1b904eece06c6c819b9a98c994ccb2ce5b 100644 (file)
@@ -759,7 +759,7 @@ static void r300_check_tcl_render(GLcontext *ctx, struct tnl_pipeline_stage *sta
                stage->active = GL_FALSE;
                return;
        }
-       if((r300->current_vp != NULL) && ctx->VertexProgram._Enabled) {
+       if(VERTPROG_ACTIVE(ctx)) {
                stage->active = GL_TRUE;
                stage->inputs = ctx->VertexProgram.Current->InputsRead;
        } else {
index c10e5dbf96793b59602c66885ef3b6988149a8b4..7cdc1733bd836e4a2c8aba54f4e4a141a027fa8e 100644 (file)
@@ -1435,7 +1435,7 @@ void r300_setup_rs_unit(GLcontext *ctx)
        cur_reg = 0;
        r300->hw.rr.cmd[R300_RR_ROUTE_0] = 0;
 
-       if (r300->current_vp != NULL && ctx->VertexProgram._Enabled)
+       if (VERTPROG_ACTIVE(ctx))
                vap_outputs = r300->current_vp->outputs;
        else
                vap_outputs = r300->state.render_inputs;
@@ -1693,7 +1693,7 @@ void r300SetupVertexShader(r300ContextPtr rmesa)
           0x400 area might have something to do with pixel shaders as it appears right after pfs programming.
           0x406 is set to { 0.0, 0.0, 1.0, 0.0 } most of the time but should change with smooth points and in other rare cases. */
        //setup_vertex_shader_fragment(rmesa, 0x406, &unk4);
-       if(rmesa->current_vp != NULL && ctx->VertexProgram._Enabled){
+       if(VERTPROG_ACTIVE(ctx)){
                r300SetupVertexProgram(rmesa);
                return ;
        }
index 98bdebd2c84104aafd85c963530714c87e44af35..c94f104e19ff1746ce3eb6fd8796f181aa3bbed5 100644 (file)
@@ -357,8 +357,10 @@ void vp_dump_inputs(struct r300_vertex_program *vp, char *caller)
 {
        int i;
        
-       if(vp == NULL)
+       if(vp == NULL){
+               fprintf(stderr, "vp null in call to %s from %s\n", __FUNCTION__, caller);
                return ;
+       }
        
        fprintf(stderr, "%s:<", caller);
        for(i=0; i < VERT_ATTRIB_MAX; i++)
@@ -402,6 +404,18 @@ static unsigned long t_src(struct r300_vertex_program *vp, struct vp_src_registe
                                src->Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
 }
 
+static unsigned long t_src_scalar(struct r300_vertex_program *vp, struct vp_src_register *src)
+{
+                       
+       return MAKE_VSF_SOURCE(t_src_index(vp, src),
+                               t_swizzle(src->Swizzle[0]),
+                               t_swizzle(src->Swizzle[0]),
+                               t_swizzle(src->Swizzle[0]),
+                               t_swizzle(src->Swizzle[0]),
+                               t_src_class(src->File),
+                               src->Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+}
+
 static unsigned long t_opcode(enum vp_opcode opcode)
 {
 
@@ -461,6 +475,7 @@ static void translate_program(struct r300_vertex_program *vp)
        VERTEX_SHADER_INSTRUCTION t2rs[1024];
        VERTEX_SHADER_INSTRUCTION *o_inst;
        unsigned long operands;
+       int are_srcs_scalar;
        /* Initial value should be last tmp reg that hw supports.
           Strangely enough r300 doesnt mind even though these would be out of range.
           Smart enough to realize that it doesnt need it? */
@@ -498,6 +513,8 @@ static void translate_program(struct r300_vertex_program *vp)
        for(vpi=mesa_vp->Instructions; vpi->Opcode != VP_OPCODE_END; vpi++, o_inst++){
                
                operands=op_operands(vpi->Opcode);
+               are_srcs_scalar=operands & SCALAR_FLAG;
+               operands &= ~SCALAR_FLAG;
                
                for(i=0; i < operands; i++)
                        src[i]=vpi->SrcReg[i];
@@ -771,30 +788,57 @@ static void translate_program(struct r300_vertex_program *vp)
        
                o_inst->op=MAKE_VSF_OP(t_opcode(vpi->Opcode), vpi->DstReg.Index,
                                t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
-
-               switch(operands){
-                       case 1:
-                               o_inst->src1=t_src(vp, &src[0]);
-                               o_inst->src2=0;
-                               o_inst->src3=0;
-                       break;
+               
+               if(are_srcs_scalar){
+                       switch(operands){
+                               case 1:
+                                       o_inst->src1=t_src_scalar(vp, &src[0]);
+                                       o_inst->src2=0;
+                                       o_inst->src3=0;
+                               break;
+                               
+                               case 2:
+                                       o_inst->src1=t_src_scalar(vp, &src[0]);
+                                       o_inst->src2=t_src_scalar(vp, &src[1]);
+                                       o_inst->src3=0;
+                               break;
+                               
+                               case 3:
+                                       o_inst->src1=t_src_scalar(vp, &src[0]);
+                                       o_inst->src2=t_src_scalar(vp, &src[1]);
+                                       o_inst->src3=t_src_scalar(vp, &src[2]);
+                               break;
+                               
+                               default:
+                                       fprintf(stderr, "scalars and op RCC not handled yet");
+                                       exit(-1);
+                               break;
+                       }
+               }else{
+                       switch(operands){
+                               case 1:
+                                       o_inst->src1=t_src(vp, &src[0]);
+                                       o_inst->src2=0;
+                                       o_inst->src3=0;
+                               break;
                        
-                       case 2:
-                               o_inst->src1=t_src(vp, &src[0]);
-                               o_inst->src2=t_src(vp, &src[1]);
-                               o_inst->src3=0;
-                       break;
+                               case 2:
+                                       o_inst->src1=t_src(vp, &src[0]);
+                                       o_inst->src2=t_src(vp, &src[1]);
+                                       o_inst->src3=0;
+                               break;
                        
-                       case 3:
-                               o_inst->src1=t_src(vp, &src[0]);
-                               o_inst->src2=t_src(vp, &src[1]);
-                               o_inst->src3=t_src(vp, &src[2]);
-                       break;
+                               case 3:
+                                       o_inst->src1=t_src(vp, &src[0]);
+                                       o_inst->src2=t_src(vp, &src[1]);
+                                       o_inst->src3=t_src(vp, &src[2]);
+                               break;
                        
-                       default:
-                               fprintf(stderr, "scalars and op RCC not handled yet");
-                               exit(-1);
-                       break;
+                               default:
+                                       fprintf(stderr, "scalars and op RCC not handled yet");
+                                       exit(-1);
+                               break;
+                       }
                }
                next: ;
 #if 0                          
@@ -890,13 +934,14 @@ static void r300ProgramStringNotify(GLcontext *ctx, GLenum target,
                                struct program *prog)
 {
        struct r300_vertex_program *vp=(void *)prog;
-#if 0                  
+#if 0
        fprintf(stderr, "r300ProgramStringNotify\n");
 #endif
                
        switch(target) {
        case GL_VERTEX_PROGRAM_ARB:
                vp->translated=GL_FALSE;
+       break;
        case GL_FRAGMENT_PROGRAM_ARB:
                return ;
                break;