~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/radeon/radeon_texstate.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
523
523
 
524
524
   /* Set the texture environment state.  Isn't this nice and clean?
525
525
    * The chip will automagically set the texture alpha to 0xff when
526
 
    * the texture format does not include an alpha component.  This
 
526
    * the texture format does not include an alpha component. This
527
527
    * reduces the amount of special-casing we have to do, alpha-only
528
 
    * textures being a notable exception.
 
528
    * textures being a notable exception. Doesn't work for luminance
 
529
    * textures realized with I8 and ALPHA_IN_MAP not set neither (on r100).
529
530
    */
530
531
    /* Don't cache these results.
531
532
    */
555
556
         assert(op <= 3);
556
557
         switch ( srcRGBi ) {
557
558
         case GL_TEXTURE:
558
 
            color_arg[i] = radeon_texture_color[op][unit];
 
559
            if (texUnit->_Current->Image[0][0]->_BaseFormat == GL_ALPHA)
 
560
               color_arg[i] = radeon_zero_color[op];
 
561
            else
 
562
               color_arg[i] = radeon_texture_color[op][unit];
559
563
            break;
560
564
         case GL_CONSTANT:
561
565
            color_arg[i] = radeon_tfactor_color[op];
574
578
            break;
575
579
         case GL_TEXTURE0:
576
580
         case GL_TEXTURE1:
577
 
         case GL_TEXTURE2:
 
581
         case GL_TEXTURE2: {
 
582
            GLuint txunit = srcRGBi - GL_TEXTURE0;
 
583
            if (ctx->Texture.Unit[txunit]._Current->Image[0][0]->_BaseFormat == GL_ALPHA)
 
584
               color_arg[i] = radeon_zero_color[op];
 
585
            else
578
586
         /* implement ogl 1.4/1.5 core spec here, not specification of
579
587
          * GL_ARB_texture_env_crossbar (which would require disabling blending
580
588
          * instead of undefined results when referencing not enabled texunit) */
581
 
           color_arg[i] = radeon_texture_color[op][srcRGBi - GL_TEXTURE0];
582
 
           break;
 
589
              color_arg[i] = radeon_texture_color[op][txunit];
 
590
            }
 
591
            break;
583
592
         default:
584
593
            return GL_FALSE;
585
594
         }
592
601
         assert(op <= 1);
593
602
         switch ( srcAi ) {
594
603
         case GL_TEXTURE:
595
 
            alpha_arg[i] = radeon_texture_alpha[op][unit];
 
604
            if (texUnit->_Current->Image[0][0]->_BaseFormat == GL_LUMINANCE)
 
605
               alpha_arg[i] = radeon_zero_alpha[op+1];
 
606
            else
 
607
               alpha_arg[i] = radeon_texture_alpha[op][unit];
596
608
            break;
597
609
         case GL_CONSTANT:
598
610
            alpha_arg[i] = radeon_tfactor_alpha[op];
611
623
            break;
612
624
         case GL_TEXTURE0:
613
625
         case GL_TEXTURE1:
614
 
         case GL_TEXTURE2:
615
 
           alpha_arg[i] = radeon_texture_alpha[op][srcAi - GL_TEXTURE0];
616
 
           break;
 
626
         case GL_TEXTURE2: {    
 
627
            GLuint txunit = srcAi - GL_TEXTURE0;
 
628
            if (ctx->Texture.Unit[txunit]._Current->Image[0][0]->_BaseFormat == GL_LUMINANCE)
 
629
               alpha_arg[i] = radeon_zero_alpha[op+1];
 
630
            else
 
631
               alpha_arg[i] = radeon_texture_alpha[op][txunit];
 
632
            }
 
633
            break;
617
634
         default:
618
635
            return GL_FALSE;
619
636
         }
847
864
                                  int unit,
848
865
                                  radeonTexObjPtr texobj )
849
866
{
850
 
   GLuint *cmd = RADEON_DB_STATE( tex[unit] );
 
867
/* do not use RADEON_DB_STATE to avoid stale texture caches */
 
868
   int *cmd = &rmesa->hw.tex[unit].cmd[TEX_CMD_0];
 
869
   GLuint se_coord_fmt = rmesa->hw.set.cmd[SET_SE_COORDFMT];
 
870
 
 
871
   RADEON_STATECHANGE( rmesa, tex[unit] );
851
872
 
852
873
   cmd[TEX_PP_TXFILTER] &= ~TEXOBJ_TXFILTER_MASK;
853
874
   cmd[TEX_PP_TXFILTER] |= texobj->pp_txfilter & TEXOBJ_TXFILTER_MASK;
856
877
   cmd[TEX_PP_TXOFFSET] = texobj->pp_txoffset;
857
878
   cmd[TEX_PP_BORDER_COLOR] = texobj->pp_border_color;
858
879
 
859
 
   if (texobj->base.tObj->Target == GL_TEXTURE_CUBE_MAP) {
860
 
      GLuint *cube_cmd = RADEON_DB_STATE( cube[unit] );
861
 
      GLuint bytesPerFace = texobj->base.totalSize / 6;
862
 
      ASSERT(texobj->base.totalSize % 6 == 0);
863
 
 
864
 
      cube_cmd[CUBE_PP_CUBIC_FACES] = texobj->pp_cubic_faces;
865
 
      /* dont know if this setup conforms to OpenGL.. 
866
 
       * at least it matches the behavior of mesa software renderer
867
 
       */
868
 
      cube_cmd[CUBE_PP_CUBIC_OFFSET_0] = texobj->pp_txoffset; /* right */
869
 
      cube_cmd[CUBE_PP_CUBIC_OFFSET_1] = texobj->pp_txoffset + 1 * bytesPerFace; /* left */
870
 
      cube_cmd[CUBE_PP_CUBIC_OFFSET_2] = texobj->pp_txoffset + 2 * bytesPerFace; /* top */
871
 
      cube_cmd[CUBE_PP_CUBIC_OFFSET_3] = texobj->pp_txoffset + 3 * bytesPerFace; /* bottom */
872
 
      cube_cmd[CUBE_PP_CUBIC_OFFSET_4] = texobj->pp_txoffset + 4 * bytesPerFace; /* front */
873
 
      RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.cube[unit] );
874
 
      cmd[TEX_PP_TXOFFSET] = texobj->pp_txoffset + 5 * bytesPerFace; /* back */
875
 
   }
876
 
   else if (texobj->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
 
880
   if (texobj->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
877
881
      GLuint *txr_cmd = RADEON_DB_STATE( txr[unit] );
878
882
      txr_cmd[TXR_PP_TEX_SIZE] = texobj->pp_txsize; /* NPOT only! */
879
883
      txr_cmd[TXR_PP_TEX_PITCH] = texobj->pp_txpitch; /* NPOT only! */
880
884
      RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.txr[unit] );
881
 
   }
882
 
 
883
 
   RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.tex[unit] );
 
885
      se_coord_fmt |= RADEON_VTX_ST0_NONPARAMETRIC << unit;
 
886
   }
 
887
   else {
 
888
      se_coord_fmt &= ~(RADEON_VTX_ST0_NONPARAMETRIC << unit);
 
889
 
 
890
      if (texobj->base.tObj->Target == GL_TEXTURE_CUBE_MAP) {
 
891
         int *cube_cmd = &rmesa->hw.cube[unit].cmd[CUBE_CMD_0];
 
892
         GLuint bytesPerFace = texobj->base.totalSize / 6;
 
893
         ASSERT(texobj->base.totalSize % 6 == 0);
 
894
 
 
895
         RADEON_STATECHANGE( rmesa, cube[unit] );
 
896
         cube_cmd[CUBE_PP_CUBIC_FACES] = texobj->pp_cubic_faces;
 
897
         /* dont know if this setup conforms to OpenGL.. 
 
898
          * at least it matches the behavior of mesa software renderer
 
899
          */
 
900
         cube_cmd[CUBE_PP_CUBIC_OFFSET_0] = texobj->pp_txoffset; /* right */
 
901
         cube_cmd[CUBE_PP_CUBIC_OFFSET_1] = texobj->pp_txoffset + 1 * bytesPerFace; /* left */
 
902
         cube_cmd[CUBE_PP_CUBIC_OFFSET_2] = texobj->pp_txoffset + 2 * bytesPerFace; /* top */
 
903
         cube_cmd[CUBE_PP_CUBIC_OFFSET_3] = texobj->pp_txoffset + 3 * bytesPerFace; /* bottom */
 
904
         cube_cmd[CUBE_PP_CUBIC_OFFSET_4] = texobj->pp_txoffset + 4 * bytesPerFace; /* front */
 
905
         cmd[TEX_PP_TXOFFSET] = texobj->pp_txoffset + 5 * bytesPerFace; /* back */
 
906
      }
 
907
   }
 
908
 
 
909
   if (se_coord_fmt != rmesa->hw.set.cmd[SET_SE_COORDFMT]) {
 
910
      RADEON_STATECHANGE( rmesa, set );
 
911
      rmesa->hw.set.cmd[SET_SE_COORDFMT] = se_coord_fmt;
 
912
   }
884
913
 
885
914
   texobj->dirty_state &= ~(1<<unit);
886
915
}
1197
1226
      fprintf(stderr, "%s: border\n", __FUNCTION__);
1198
1227
      return GL_FALSE;
1199
1228
   }
 
1229
   /* yuv conversion only works in first unit */
 
1230
   if (unit != 0 && (t->pp_txfilter & RADEON_YUV_TO_RGB))
 
1231
      return GL_FALSE;
1200
1232
 
1201
1233
   /* Update state if this is a different texture object to last
1202
1234
    * time.