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

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/i915/intel_tris.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:
43
43
#include "intel_reg.h"
44
44
#include "intel_span.h"
45
45
 
 
46
/* XXX we shouldn't include these headers in this file, but we need them
 
47
 * for fallbackStrings, below.
 
48
 */
 
49
#include "i830_context.h"
 
50
#include "i915_context.h"
 
51
 
46
52
static void intelRenderPrimitive( GLcontext *ctx, GLenum prim );
47
53
static void intelRasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
48
54
 
792
798
}
793
799
 
794
800
 
795
 
 /* 
796
 
  */
797
 
 static void intelRenderPrimitive( GLcontext *ctx, GLenum prim )
798
 
 {
799
 
    intelContextPtr intel = INTEL_CONTEXT(ctx);
800
 
 
801
 
    if (0)
802
 
       fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim));
803
 
 
804
 
    /* Let some clipping routines know which primitive they're dealing
805
 
     * with.
806
 
     */
807
 
    intel->render_primitive = prim;
808
 
 
809
 
    /* Shortcircuit this when called from t_dd_rendertmp.h for unfilled
810
 
     * triangles.  The rasterized primitive will always be reset by
811
 
     * lower level functions in that case, potentially pingponging the
812
 
     * state:
813
 
     */
814
 
    if (reduced_prim[prim] == GL_TRIANGLES && 
815
 
        (ctx->_TriangleCaps & DD_TRI_UNFILLED))
816
 
       return;
817
 
 
818
 
    /* Set some primitive-dependent state and Start? a new primitive.
819
 
     */
820
 
    intelRasterPrimitive( ctx, reduced_prim[prim], hw_prim[prim] );
821
 
 }
822
 
 
823
 
 
824
 
 /**********************************************************************/
825
 
 /*           Transition to/from hardware rasterization.               */
826
 
 /**********************************************************************/
827
 
 
828
 
 static char *fallbackStrings[] = {
829
 
    "Texture",
830
 
    "Draw buffer",
831
 
    "Read buffer",
832
 
    "Color mask",
833
 
    "Render mode",
834
 
    "Stencil",
835
 
    "Stipple",
836
 
    "User disable"
837
 
 };
838
 
 
839
 
 
840
 
 static char *getFallbackString(GLuint bit)
841
 
 {
842
 
    int i = 0;
843
 
    while (bit > 1) {
844
 
       i++;
845
 
       bit >>= 1;
846
 
    }
847
 
    return fallbackStrings[i];
848
 
 }
849
 
 
850
 
 
851
 
 
852
 
 void intelFallback( intelContextPtr intel, GLuint bit, GLboolean mode )
853
 
 {
854
 
    GLcontext *ctx = &intel->ctx;
855
 
    TNLcontext *tnl = TNL_CONTEXT(ctx);
856
 
    GLuint oldfallback = intel->Fallback;
857
 
 
858
 
    if (mode) {
859
 
       intel->Fallback |= bit;
860
 
       if (oldfallback == 0) {
861
 
          intelFlush(ctx);
862
 
          if (INTEL_DEBUG & DEBUG_FALLBACKS) 
863
 
             fprintf(stderr, "ENTER FALLBACK %x: %s\n",
864
 
                     bit, getFallbackString( bit ));
865
 
          _swsetup_Wakeup( ctx );
866
 
          intel->RenderIndex = ~0;
867
 
       }
868
 
    }
869
 
    else {
870
 
       intel->Fallback &= ~bit;
871
 
       if (oldfallback == bit) {
872
 
          _swrast_flush( ctx );
873
 
          if (INTEL_DEBUG & DEBUG_FALLBACKS) 
874
 
             fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString( bit ));
875
 
          tnl->Driver.Render.Start = intelRenderStart;
876
 
          tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive;
877
 
          tnl->Driver.Render.Finish = intelRenderFinish;
878
 
          tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
879
 
          tnl->Driver.Render.CopyPV = _tnl_copy_pv;
880
 
          tnl->Driver.Render.Interp = _tnl_interp;
881
 
 
882
 
          _tnl_invalidate_vertex_state( ctx, ~0 );
883
 
          _tnl_invalidate_vertices( ctx, ~0 );
884
 
          _tnl_install_attrs( ctx, 
885
 
                              intel->vertex_attrs, 
886
 
                              intel->vertex_attr_count,
887
 
                              intel->ViewportMatrix.m, 0 ); 
888
 
 
889
 
          intel->NewGLState |= _INTEL_NEW_RENDERSTATE;
890
 
       }
891
 
    }
892
 
 }
 
801
/* 
 
802
 */
 
803
static void intelRenderPrimitive( GLcontext *ctx, GLenum prim )
 
804
{
 
805
   intelContextPtr intel = INTEL_CONTEXT(ctx);
 
806
 
 
807
   if (0)
 
808
      fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim));
 
809
 
 
810
   /* Let some clipping routines know which primitive they're dealing
 
811
    * with.
 
812
    */
 
813
   intel->render_primitive = prim;
 
814
 
 
815
   /* Shortcircuit this when called from t_dd_rendertmp.h for unfilled
 
816
    * triangles.  The rasterized primitive will always be reset by
 
817
    * lower level functions in that case, potentially pingponging the
 
818
    * state:
 
819
    */
 
820
   if (reduced_prim[prim] == GL_TRIANGLES && 
 
821
       (ctx->_TriangleCaps & DD_TRI_UNFILLED))
 
822
      return;
 
823
 
 
824
   /* Set some primitive-dependent state and Start? a new primitive.
 
825
    */
 
826
   intelRasterPrimitive( ctx, reduced_prim[prim], hw_prim[prim] );
 
827
}
 
828
 
 
829
 
 
830
/**********************************************************************/
 
831
/*           Transition to/from hardware rasterization.               */
 
832
/**********************************************************************/
 
833
 
 
834
static struct {
 
835
   GLuint bit;
 
836
   const char *str;
 
837
} fallbackStrings[] = {
 
838
   { INTEL_FALLBACK_DRAW_BUFFER, "Draw buffer" },
 
839
   { INTEL_FALLBACK_READ_BUFFER, "Read buffer" },
 
840
   { INTEL_FALLBACK_USER, "User" },
 
841
   { INTEL_FALLBACK_NO_BATCHBUFFER, "No Batchbuffer" },
 
842
   { INTEL_FALLBACK_NO_TEXMEM, "No Texmem" },
 
843
   { INTEL_FALLBACK_RENDERMODE, "Rendermode" },
 
844
 
 
845
   { I830_FALLBACK_TEXTURE, "i830 texture" },
 
846
   { I830_FALLBACK_COLORMASK, "i830 colormask" },
 
847
   { I830_FALLBACK_STENCIL, "i830 stencil" },
 
848
   { I830_FALLBACK_STIPPLE, "i830 stipple" },
 
849
   { I830_FALLBACK_LOGICOP, "i830 logicop" },
 
850
 
 
851
   { I915_FALLBACK_TEXTURE, "i915 texture" },
 
852
   { I915_FALLBACK_COLORMASK, "i915 colormask" },
 
853
   { I915_FALLBACK_STENCIL, "i915 stencil" },
 
854
   { I915_FALLBACK_STIPPLE, "i915 stipple" },
 
855
   { I915_FALLBACK_PROGRAM, "i915 program" },
 
856
   { I915_FALLBACK_LOGICOP, "i915 logicop" },
 
857
   { I915_FALLBACK_POLYGON_SMOOTH, "i915 polygon smooth" },
 
858
   { I915_FALLBACK_POINT_SMOOTH, "i915 point smooth" },
 
859
 
 
860
   { 0, NULL }
 
861
};
 
862
 
 
863
 
 
864
static const char *
 
865
getFallbackString(GLuint bit)
 
866
{
 
867
   int i;
 
868
   for (i = 0; fallbackStrings[i].bit; i++) {
 
869
      if (fallbackStrings[i].bit == bit)
 
870
         return fallbackStrings[i].str;
 
871
   }
 
872
   return "unknown fallback bit";
 
873
}
 
874
 
 
875
 
 
876
void intelFallback( intelContextPtr intel, GLuint bit, GLboolean mode )
 
877
{
 
878
   GLcontext *ctx = &intel->ctx;
 
879
   TNLcontext *tnl = TNL_CONTEXT(ctx);
 
880
   GLuint oldfallback = intel->Fallback;
 
881
 
 
882
   if (mode) {
 
883
      intel->Fallback |= bit;
 
884
      if (oldfallback == 0) {
 
885
         intelFlush(ctx);
 
886
         if (INTEL_DEBUG & DEBUG_FALLBACKS) 
 
887
            fprintf(stderr, "ENTER FALLBACK 0x%x: %s\n",
 
888
                    bit, getFallbackString(bit));
 
889
         _swsetup_Wakeup( ctx );
 
890
         intel->RenderIndex = ~0;
 
891
      }
 
892
   }
 
893
   else {
 
894
      intel->Fallback &= ~bit;
 
895
      if (oldfallback == bit) {
 
896
         _swrast_flush( ctx );
 
897
         if (INTEL_DEBUG & DEBUG_FALLBACKS) 
 
898
            fprintf(stderr, "LEAVE FALLBACK 0x%x: %s\n",
 
899
                    bit, getFallbackString(bit));
 
900
         tnl->Driver.Render.Start = intelRenderStart;
 
901
         tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive;
 
902
         tnl->Driver.Render.Finish = intelRenderFinish;
 
903
         tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
 
904
         tnl->Driver.Render.CopyPV = _tnl_copy_pv;
 
905
         tnl->Driver.Render.Interp = _tnl_interp;
 
906
 
 
907
         _tnl_invalidate_vertex_state( ctx, ~0 );
 
908
         _tnl_invalidate_vertices( ctx, ~0 );
 
909
         _tnl_install_attrs( ctx, 
 
910
                             intel->vertex_attrs, 
 
911
                             intel->vertex_attr_count,
 
912
                             intel->ViewportMatrix.m, 0 ); 
 
913
 
 
914
         intel->NewGLState |= _INTEL_NEW_RENDERSTATE;
 
915
      }
 
916
   }
 
917
}
893
918
 
894
919
 
895
920