Merge branch 'master' of git+ssh://znh@git.freedesktop.org/git/mesa/mesa into 965...
authorZou Nan hai <nanhai.zou@intel.com>
Tue, 17 Jul 2007 07:42:39 +0000 (15:42 +0800)
committerZou Nan hai <nanhai.zou@intel.com>
Tue, 17 Jul 2007 07:42:39 +0000 (15:42 +0800)
111 files changed:
Makefile
progs/demos/geartrain.c
progs/demos/gltestperf.c
progs/demos/isosurf.c
progs/demos/morph3d.c
progs/demos/winpos.c
progs/fbdev/glfbdevtest.c
progs/xdemos/offset.c
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/i915/i915_vtbl.c
src/mesa/drivers/dri/i915/intel_pixel.c
src/mesa/drivers/dri/i915tex/i915_vtbl.c
src/mesa/drivers/dri/i915tex/intel_buffers.c
src/mesa/drivers/dri/i915tex/intel_context.c
src/mesa/drivers/dri/i915tex/intel_pixel_draw.c
src/mesa/drivers/dri/i965/intel_blit.c
src/mesa/drivers/dri/i965/intel_blit.h
src/mesa/drivers/dri/i965/intel_pixel_bitmap.c
src/mesa/drivers/dri/nouveau/nouveau_buffers.c
src/mesa/drivers/dri/nouveau/nouveau_context.c
src/mesa/drivers/dri/nouveau/nouveau_context.h
src/mesa/drivers/dri/nouveau/nouveau_driver.c
src/mesa/drivers/dri/nouveau/nouveau_fifo.c
src/mesa/drivers/dri/nouveau/nouveau_lock.c
src/mesa/drivers/dri/nouveau/nouveau_object.c
src/mesa/drivers/dri/nouveau/nouveau_screen.c
src/mesa/drivers/dri/nouveau/nouveau_state.c
src/mesa/drivers/dri/nouveau/nouveau_sync.c
src/mesa/drivers/dri/nouveau/nouveau_sync.h
src/mesa/drivers/dri/nouveau/nv10_state.c
src/mesa/drivers/dri/nouveau/nv10_swtcl.c
src/mesa/drivers/dri/nouveau/nv20_state.c
src/mesa/drivers/dri/r300/r300_context.c
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_emit.c
src/mesa/drivers/dri/r300/r300_reg.h
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r300_swtcl.c
src/mesa/drivers/dri/r300/r300_vertprog.c
src/mesa/drivers/dri/r300/r300_vertprog.h
src/mesa/drivers/fbdev/glfbdev.c
src/mesa/main/api_arrayelt.c
src/mesa/main/api_loopback.c
src/mesa/main/api_noop.c
src/mesa/main/api_validate.c
src/mesa/main/arrayobj.c
src/mesa/main/context.c
src/mesa/main/context.h
src/mesa/main/dlist.c
src/mesa/main/execmem.c
src/mesa/main/framebuffer.c
src/mesa/main/hash.c
src/mesa/main/image.c
src/mesa/main/image.h
src/mesa/main/mtypes.h
src/mesa/main/state.c
src/mesa/main/texenvprogram.c
src/mesa/main/teximage.c
src/mesa/main/texstore.c
src/mesa/main/varray.c
src/mesa/main/vtxfmt_tmp.h
src/mesa/math/m_eval.c
src/mesa/math/m_eval.h
src/mesa/math/m_translate.h
src/mesa/math/m_xform.c
src/mesa/shader/arbprogparse.c
src/mesa/shader/prog_execute.c
src/mesa/shader/shader_api.c
src/mesa/shader/slang/slang_builtin.c
src/mesa/shader/slang/slang_builtin.h
src/mesa/shader/slang/slang_codegen.c
src/mesa/shader/slang/slang_compile.c
src/mesa/shader/slang/slang_emit.c
src/mesa/shader/slang/slang_ir.c
src/mesa/shader/slang/slang_label.h
src/mesa/shader/slang/slang_link.c
src/mesa/shader/slang/slang_preprocess.c
src/mesa/shader/slang/slang_typeinfo.c
src/mesa/shader/slang/slang_vartable.c
src/mesa/swrast/s_atifragshader.c
src/mesa/swrast/s_context.c
src/mesa/swrast/s_context.h
src/mesa/swrast/s_drawpix.c
src/mesa/swrast/s_fragprog.c
src/mesa/swrast/s_stencil.c
src/mesa/swrast/swrast.h
src/mesa/swrast_setup/ss_context.c
src/mesa/swrast_setup/ss_tritmp.h
src/mesa/tnl/t_context.c
src/mesa/tnl/t_context.h
src/mesa/tnl/t_pipeline.c
src/mesa/tnl/t_vb_program.c
src/mesa/tnl/t_vp_build.c
src/mesa/tnl/tnl.h
src/mesa/vbo/vbo.h
src/mesa/vbo/vbo_context.c
src/mesa/vbo/vbo_exec.c
src/mesa/vbo/vbo_exec.h
src/mesa/vbo/vbo_exec_api.c
src/mesa/vbo/vbo_exec_array.c
src/mesa/vbo/vbo_exec_draw.c
src/mesa/vbo/vbo_exec_eval.c
src/mesa/vbo/vbo_rebase.c
src/mesa/vbo/vbo_save.c
src/mesa/vbo/vbo_save.h
src/mesa/vbo/vbo_save_api.c
src/mesa/vbo/vbo_save_draw.c
src/mesa/vbo/vbo_save_loopback.c
src/mesa/vbo/vbo_split.c
src/mesa/vbo/vbo_split_copy.c
src/mesa/vbo/vbo_split_inplace.c

index ea86787cebe7aa0f84a2b18aede0ce4fd9fb1103..60a14665cca1ad4e1a2661b589db7946a2b00188 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -372,6 +372,8 @@ DEMO_FILES = \
        $(DIRECTORY)/progs/demos/*.cxx                  \
        $(DIRECTORY)/progs/demos/*.dat                  \
        $(DIRECTORY)/progs/demos/README                 \
+       $(DIRECTORY)/progs/fbdev/Makefile               \
+       $(DIRECTORY)/progs/fbdev/glfbdevtest.c          \
        $(DIRECTORY)/progs/osdemos/Makefile             \
        $(DIRECTORY)/progs/osdemos/*.c                  \
        $(DIRECTORY)/progs/xdemos/Makefile*             \
index 3feb2a0524b4a182a212fac84fe89327c616e9bb..8363f2abc6d361ceb44fbde121cb40bf871093ef 100644 (file)
@@ -1053,6 +1053,7 @@ main (int argc, char *argv[])
     else
        file = argv[1];
 
+    glutInit(&argc, argv); 
     glutInitWindowPosition (0, 0);
     glutInitWindowSize(640,480);
     glutInitDisplayMode (GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
index be953901014ecce4ad13257b494e2f92adb7ada3..2188b0241924034f42f545c3f45237df9b8b1462 100644 (file)
@@ -569,6 +569,7 @@ main(int ac, char **av)
    if (ac == 2)
       frontbuffer = 0;
 
+   glutInit(&ac, av);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowPosition(0, 0);
    glutInitWindowSize(640, 480);
index 0710bc6047bad5a82dbfdff76e9f972d44e38b69..10f94b6ace236081c914ca8ca825490a190bdb3a 100644 (file)
@@ -1042,6 +1042,7 @@ int main(int argc, char **argv)
 
    read_surface( "isosurf.dat" );
 
+   glutInit( &argc, argv);
    glutInitWindowPosition(0, 0);
    glutInitWindowSize(400, 400);
 
index 162a6ff847eb18a2133968ff5230fb646bf87b34..6aca8270ff515a250505fc44759dbc2b0a674797 100644 (file)
@@ -826,7 +826,7 @@ static void pinit(void)
 
 }
 
-static void INIT(void)
+int main(int argc, char **argv)
 {
   printf("Morph 3D - Shows morphing platonic polyhedra\n");
   printf("Author: Marcelo Fernandes Vianna (vianna@cat.cbpf.br)\n\n");
@@ -841,6 +841,7 @@ static void INIT(void)
 
   object=1;
 
+  glutInit(&argc, argv);
   glutInitWindowPosition(0,0);
   glutInitWindowSize(640,480);
 
@@ -888,9 +889,3 @@ static void INIT(void)
   glutMainLoop();
   
 }
-
-int main(int argc, char **argv)
-{
-  INIT();
-  return(0);
-}
index 3a1a19ecdb919bead0f05d51f9cb3ce1943c2699..b58e33086434ec48f60d31672c4c1d21e8f502b0 100644 (file)
@@ -100,6 +100,7 @@ static void init( void )
 
 int main( int argc, char *argv[] )
 {
+   glutInit(&argc, argv);
    glutInitWindowPosition(0, 0);
    glutInitWindowSize(500, 500);
    glutInitDisplayMode( GLUT_RGB );
index a461c55e2f86337f457449b0c57f3ba6f6d6f0d1..6d9f80703027bcb1fe5e9680cde62e6636e30f39 100644 (file)
 #include <GL/glfbdev.h>
 #include <math.h>
 
-#define DEFAULT_DEPTH 8
+
+/**
+ * Choose one of these modes
+ */
+/*static const int XRes = 1280, YRes = 1024, Hz = 75;*/
+/*static const int XRes = 1280, YRes = 1024, Hz = 70;*/
+/*static const int XRes = 1280, YRes = 1024, Hz = 60;*/
+static const int XRes = 1024, YRes = 768, Hz = 70;
+
+static int DesiredDepth = 32;
+
+static int NumFrames = 100;
 
 static struct fb_fix_screeninfo FixedInfo;
 static struct fb_var_screeninfo VarInfo, OrigVarInfo;
-static int DesiredDepth = 0;
 static int OriginalVT = -1;
 static int ConsoleFD = -1;
 static int FrameBufferFD = -1;
@@ -227,7 +237,6 @@ initialize_fbdev( void )
    VarInfo = OrigVarInfo;
 
    /* set the depth, resolution, etc */
-   DesiredDepth = 32;
    if (DesiredDepth)
       VarInfo.bits_per_pixel = DesiredDepth;
 
@@ -251,16 +260,60 @@ initialize_fbdev( void )
       VarInfo.blue.length = 8;
       VarInfo.transp.length = 8;
    }
-   /* timing values taken from /etc/fb.modes (1280x1024 @ 75Hz) */
-   VarInfo.xres_virtual = VarInfo.xres = 1280;
-   VarInfo.yres_virtual = VarInfo.yres = 1024;
-   VarInfo.pixclock = 7408;
-   VarInfo.left_margin = 248;
-   VarInfo.right_margin = 16;
-   VarInfo.upper_margin = 38;
-   VarInfo.lower_margin = 1;
-   VarInfo.hsync_len = 144;
-   VarInfo.vsync_len = 3;
+
+   /* timing values taken from /etc/fb.modes */
+   if (XRes == 1280 && YRes == 1024) {
+      VarInfo.xres_virtual = VarInfo.xres = XRes;
+      VarInfo.yres_virtual = VarInfo.yres = YRes;
+      if (Hz == 75) {
+         VarInfo.pixclock = 7408;
+         VarInfo.left_margin = 248;
+         VarInfo.right_margin = 16;
+         VarInfo.upper_margin = 38;
+         VarInfo.lower_margin = 1;
+         VarInfo.hsync_len = 144;
+         VarInfo.vsync_len = 3;
+      }
+      else if (Hz == 70) {
+         VarInfo.pixclock = 7937;
+         VarInfo.left_margin = 216;
+         VarInfo.right_margin = 80;
+         VarInfo.upper_margin = 36;
+         VarInfo.lower_margin = 1;
+         VarInfo.hsync_len = 112;
+         VarInfo.vsync_len = 5;
+      }
+      else if (Hz == 60) {
+         VarInfo.pixclock = 9260;
+         VarInfo.left_margin = 248;
+         VarInfo.right_margin = 48;
+         VarInfo.upper_margin = 38;
+         VarInfo.lower_margin = 1;
+         VarInfo.hsync_len = 112;
+         VarInfo.vsync_len = 3;
+      }
+      else {
+         fprintf(stderr, "invalid rate for 1280x1024\n");
+         exit(1);
+      }
+   }
+   else if (XRes == 1024 && YRes == 768 && Hz == 70) {
+      VarInfo.xres_virtual = VarInfo.xres = XRes;
+      VarInfo.yres_virtual = VarInfo.yres = YRes;
+      if (Hz == 70) {
+         VarInfo.pixclock = 13334;
+         VarInfo.left_margin = 144;
+         VarInfo.right_margin = 24;
+         VarInfo.upper_margin = 29;
+         VarInfo.lower_margin = 3;
+         VarInfo.hsync_len = 136;
+         VarInfo.vsync_len = 6;
+      }
+      else {
+         fprintf(stderr, "invalid rate for 1024x768\n");
+         exit(1);
+      }
+   }
 
    VarInfo.xoffset = 0;
    VarInfo.yoffset = 0;
@@ -338,7 +391,7 @@ initialize_fbdev( void )
    printf("MMIOAddress = %p\n", MMIOAddress);
 
    /* try out some simple MMIO register reads */
-   if (1)
+   if (0)
    {
       typedef unsigned int CARD32;
       typedef unsigned char CARD8;
@@ -452,6 +505,7 @@ gltest( void )
    GLFBDevVisualPtr vis;
    int bytes, r, g, b, a;
    float ang;
+   int i;
 
    printf("GLFBDEV_VENDOR = %s\n", glFBDevGetString(GLFBDEV_VENDOR));
    printf("GLFBDEV_VERSION = %s\n", glFBDevGetString(GLFBDEV_VERSION));
@@ -491,13 +545,17 @@ gltest( void )
    glEnable(GL_LIGHT0);
    glEnable(GL_DEPTH_TEST);
 
-   for (ang = 0; ang <= 180; ang += 15) {
+   printf("Drawing %d frames...\n", NumFrames);
+
+   ang = 0.0;
+   for (i = 0; i < NumFrames; i++) {
       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
       glPushMatrix();
       glRotatef(ang, 1, 0, 0);
       doughnut(1, 3, 40, 20);
       glPopMatrix();
       glFBDevSwapBuffers(buf);
+      ang += 15.0;
    }
 
    /* clean up */
@@ -510,12 +568,29 @@ gltest( void )
 }
 
 
+static void
+parse_args(int argc, char *argv[])
+{
+   int i;
+
+   for (i = 1; i < argc; i++) {
+      if (strcmp(argv[i], "-f") == 0) {
+         NumFrames = atoi(argv[i+1]);
+         i++;
+      }
+   }
+}
+
+
 int
 main( int argc, char *argv[] )
 {
    signal(SIGUSR1, signal_handler);  /* exit if someone tries a vt switch */
    signal(SIGSEGV, signal_handler);  /* catch segfaults */
 
+   parse_args(argc, argv);
+
+   printf("Setting mode to %d x %d @ %d Hz, %d bpp\n", XRes, YRes, Hz, DesiredDepth);
    initialize_fbdev();
    gltest();
    shutdown_fbdev();
index 3e92e68daa7a5a6556df274851b771ec4b759c9f..0ad9147aea6d9be65775353a652189cf4198752e 100644 (file)
@@ -71,12 +71,12 @@ typedef Vertex Quad[4];
 
 /* data to define the six faces of a unit cube */
 Quad quads[MAXQUAD] = {
-   { {0,0,0}, {1,0,0}, {1,1,0}, {0,1,0} },
-   { {0,0,1}, {1,0,1}, {1,1,1}, {0,1,1} },
-   { {0,0,0}, {1,0,0}, {1,0,1}, {0,0,1} },
-   { {0,1,0}, {1,1,0}, {1,1,1}, {0,1,1} },
-   { {0,0,0}, {0,0,1}, {0,1,1}, {0,1,0} },
-   { {1,0,0}, {1,0,1}, {1,1,1}, {1,1,0} }
+   { {0,0,0}, {0,0,1}, {0,1,1}, {0,1,0} }, /* x = 0 */
+   { {0,0,0}, {1,0,0}, {1,0,1}, {0,0,1} }, /* y = 0 */
+   { {0,0,0}, {1,0,0}, {1,1,0}, {0,1,0} }, /* z = 0 */
+   { {1,0,0}, {1,0,1}, {1,1,1}, {1,1,0} }, /* x = 1 */
+   { {0,1,0}, {1,1,0}, {1,1,1}, {0,1,1} }, /* y = 1 */
+   { {0,0,1}, {1,0,1}, {1,1,1}, {0,1,1} }  /* z = 1 */
 };
 
 #define WIREFRAME      0
@@ -86,7 +86,7 @@ static void error(const char* prog, const char* msg);
 static void cubes(int mx, int my, int mode);
 static void fill(Quad quad);
 static void outline(Quad quad);
-static void draw_hidden(Quad quad, int mode);
+static void draw_hidden(Quad quad, int mode, int face);
 static void process_input(Display *dpy, Window win);
 static int query_extension(char* extName);
 
@@ -101,6 +101,7 @@ int main(int argc, char** argv) {
     XSetWindowAttributes swa;
     Window win;
     GLXContext cx;
+    GLint z;
 
     dpy = XOpenDisplay(0);
     if (!dpy) error(argv[0], "can't open display");
@@ -134,13 +135,16 @@ int main(int argc, char** argv) {
 
     /* set up viewing parameters */
     glMatrixMode(GL_PROJECTION);
-    gluPerspective(20, 1, 0.1, 20);
+    gluPerspective(20, 1, 10, 20);
     glMatrixMode(GL_MODELVIEW);
     glTranslatef(0, 0, -15);
 
     /* set other relevant state information */
     glEnable(GL_DEPTH_TEST);
 
+    glGetIntegerv(GL_DEPTH_BITS, &z);
+    printf("GL_DEPTH_BITS = %d\n", z);
+
 #ifdef GL_EXT_polygon_offset
     printf("using 1.0 offset extension\n");
     glPolygonOffsetEXT( 1.0, 0.00001 );
@@ -160,6 +164,7 @@ int main(int argc, char** argv) {
 
 static void
 draw_scene(int mx, int my) {
+   glClearColor(0.25, 0.25, 0.25, 0);
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
     glPushMatrix();
@@ -206,7 +211,7 @@ cubes(int mx, int my, int mode) {
                glTranslatef(x, y, z);
                glScalef(0.8, 0.8, 0.8);
                for (i = 0; i < MAXQUAD; i++)
-                   draw_hidden(quads[i], mode);
+                    draw_hidden(quads[i], mode, i);
                glPopMatrix();
            }
        }
@@ -236,13 +241,18 @@ outline(Quad quad) {
 }
 
 static void
-draw_hidden(Quad quad, int mode) {
+draw_hidden(Quad quad, int mode, int face) {
+    static const GLfloat colors[3][3] = {
+        {0.5, 0.5, 0.0},
+        {0.8, 0.5, 0.0},
+        {0.0, 0.5, 0.8}
+    };
     if (mode == HIDDEN_LINE) {
-       glColor3f(0, 0, 0);
+        glColor3fv(colors[face % 3]);
        fill(quad);
     }
 
-    /* draw the outline using white, optionally fill the interior with black */
+    /* draw the outline using white */
     glColor3f(1, 1, 1);
     outline(quad);
 }
index dd52f7e915139458961190c6e2b9a29b5364278c..c30e66f1722c11b025b3ab3faa94f5155cb4fe1b 100644 (file)
@@ -428,10 +428,12 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
 
     if (pdp->pClipRects) {
        _mesa_free(pdp->pClipRects); 
+       pdp->pClipRects = NULL;
     }
 
     if (pdp->pBackClipRects) {
        _mesa_free(pdp->pBackClipRects); 
+       pdp->pBackClipRects = NULL;
     }
 
     DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
index b0e5f87fc75cc996d469025330aa1951f2536660..cc8a605e50537c21868f96b1e4dd18035b84eb89 100644 (file)
@@ -64,6 +64,7 @@ static void i915_reduced_primitive_state( intelContextPtr intel,
     st1 &= ~ST1_ENABLE;
 
     switch (rprim) {
+    case GL_QUADS: /* from RASTERIZE(GL_QUADS) in t_dd_tritemp.h */
     case GL_TRIANGLES:
        if (intel->ctx.Polygon.StippleFlag &&
           intel->hw_stipple)
index d175870a0c5e3c48bc660049afb70ffd6d98620a..c3030d42b04801944f3124c1eaf87d0d80715b62 100644 (file)
@@ -450,10 +450,16 @@ intelDrawPixels( GLcontext *ctx,
        * wise happily run the fragment program on each pixel in the image).
        */
       struct gl_fragment_program *fpSave = ctx->FragmentProgram._Current;
+   /* can't just set current frag prog to 0 here as on buffer resize
+      we'll get new state checks which will segfault. Remains a hack. */
       ctx->FragmentProgram._Current = NULL;
+      ctx->FragmentProgram._UseTexEnvProgram = GL_FALSE;
+      ctx->FragmentProgram._Active = GL_FALSE;
       _swrast_DrawPixels( ctx, x, y, width, height, format, type,
                           unpack, pixels );
       ctx->FragmentProgram._Current = fpSave;
+      ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
+      ctx->FragmentProgram._Active = GL_TRUE;
    }
    else {
       _swrast_DrawPixels( ctx, x, y, width, height, format, type,
index f80e8d6327f3dc071a8b04af47334f204d9a5599..ad333b490b78ef4b808a6e36884fb8ab6aba2849 100644 (file)
@@ -61,6 +61,7 @@ i915_reduced_primitive_state(struct intel_context *intel, GLenum rprim)
    st1 &= ~ST1_ENABLE;
 
    switch (rprim) {
+   case GL_QUADS: /* from RASTERIZE(GL_QUADS) in t_dd_tritemp.h */
    case GL_TRIANGLES:
       if (intel->ctx.Polygon.StippleFlag && intel->hw_stipple)
          st1 |= ST1_ENABLE;
index 62ff54b00751c3241967742edd1a6375205bba99..15d02f8e2cf0771619309c5c6ab4b68ea9d4524c 100644 (file)
@@ -316,7 +316,8 @@ intelWindowMoved(struct intel_context *intel)
         flags = intel_fb->vblank_flags & ~VBLANK_FLAG_SECONDARY;
       }
 
-      if (flags != intel_fb->vblank_flags) {
+      if (flags != intel_fb->vblank_flags && intel_fb->vblank_flags &&
+         !(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ)) {
         drmVBlank vbl;
         int i;
 
@@ -327,7 +328,9 @@ intelWindowMoved(struct intel_context *intel)
         }
 
         for (i = 0; i < intel_fb->pf_num_pages; i++) {
-           if (!intel_fb->color_rb[i])
+           if (!intel_fb->color_rb[i] ||
+               (intel_fb->vbl_waited - intel_fb->color_rb[i]->vbl_pending) <=
+               (1<<23))
               continue;
 
            vbl.request.sequence = intel_fb->color_rb[i]->vbl_pending;
@@ -828,7 +831,8 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target)
    drm_i915_vblank_swap_t swap;
    GLboolean ret;
 
-   if ((intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) ||
+   if (!intel_fb->vblank_flags ||
+       (intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) ||
        intelScreen->current_rotation != 0 ||
        intelScreen->drmMinor < (intel_fb->pf_active ? 9 : 6))
       return GL_FALSE;
index c927dca8e5aab4f7f40c808044ed10fc2c074814..40ea7564126712310578c6929d2fba98b9303f6e 100644 (file)
@@ -619,12 +619,23 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
       if (intel->ctx.DrawBuffer == &intel_fb->Base) {
 
         if (intel->driDrawable != driDrawPriv) {
-           intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0)
-              ? driGetDefaultVBlankFlags(&intel->optionCache)
-              : VBLANK_FLAG_NO_IRQ;
-           (*dri_interface->getUST) (&intel_fb->swap_ust);
-           driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags,
-                                 &intel_fb->vbl_seq);
+           if (driDrawPriv->pdraw->swap_interval == (unsigned)-1) {
+              int i;
+
+              intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0)
+                 ? driGetDefaultVBlankFlags(&intel->optionCache)
+                : VBLANK_FLAG_NO_IRQ;
+
+              (*dri_interface->getUST) (&intel_fb->swap_ust);
+              driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags,
+                                    &intel_fb->vbl_seq);
+              intel_fb->vbl_waited = intel_fb->vbl_seq;
+
+              for (i = 0; i < (intel->intelScreen->third.handle ? 3 : 2); i++) {
+                 if (intel_fb->color_rb[i])
+                    intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_seq;
+              }
+           }
            intel->driDrawable = driDrawPriv;
            intelWindowMoved(intel);
         }
@@ -670,37 +681,27 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
    if (sarea->width != intel->width ||
        sarea->height != intel->height ||
        sarea->rotation != intel->current_rotation) {
-      
-      void *batchMap = intel->batch->map;
-      
+      int numClipRects = intel->numClipRects;
+
       /*
        * FIXME: Really only need to do this when drawing to a
        * common back- or front buffer.
        */
 
       /*
-       * This will drop the outstanding batchbuffer on the floor
+       * This will essentially drop the outstanding batchbuffer on the floor.
        */
+      intel->numClipRects = 0;
 
-      if (batchMap != NULL) {
-        driBOUnmap(intel->batch->buffer);
-        intel->batch->map = NULL;
-      }
-
-      intel_batchbuffer_reset(intel->batch);
+      if (intel->Fallback)
+        _swrast_flush(&intel->ctx);
 
-      if (batchMap == NULL) {
-        driBOUnmap(intel->batch->buffer);
-        intel->batch->map = NULL;
-      }
+      INTEL_FIREVERTICES(intel);
 
-      /* lose all primitives */
-      intel->prim.primitive = ~0;
-      intel->prim.start_ptr = 0;
-      intel->prim.flush = 0;
+      if (intel->batch->map != intel->batch->ptr)
+        intel_batchbuffer_flush(intel->batch);
 
-      /* re-emit all state */
-      intel->vtbl.lost_hardware(intel);
+      intel->numClipRects = numClipRects;
 
       /* force window update */
       intel->lastStamp = 0;
@@ -741,7 +742,9 @@ void LOCK_HARDWARE( struct intel_context *intel )
                                    BUFFER_BACK_LEFT);
     }
 
-    if (intel_rb && (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) {
+    if (intel_rb && intel_fb->vblank_flags &&
+       !(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) &&
+       (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) {
        drmVBlank vbl;
 
        vbl.request.type = DRM_VBLANK_ABSOLUTE;
index 77c67c821eb07118df3fac7e85ba6bdf0af669c1..e4e57cb3a7e28c3bddbeb7c1a99d99a650be04d6 100644 (file)
@@ -370,10 +370,16 @@ intelDrawPixels(GLcontext * ctx,
        * wise happily run the fragment program on each pixel in the image).
        */
       struct gl_fragment_program *fpSave = ctx->FragmentProgram._Current;
+   /* can't just set current frag prog to 0 here as on buffer resize
+      we'll get new state checks which will segfault. Remains a hack. */
       ctx->FragmentProgram._Current = NULL;
+      ctx->FragmentProgram._UseTexEnvProgram = GL_FALSE;
+      ctx->FragmentProgram._Active = GL_FALSE;
       _swrast_DrawPixels( ctx, x, y, width, height, format, type,
                           unpack, pixels );
       ctx->FragmentProgram._Current = fpSave;
+      ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
+      ctx->FragmentProgram._Active = GL_TRUE;
    }
    else {
       _swrast_DrawPixels( ctx, x, y, width, height, format, type,
index 173d1d5b6c232f8a7491a2be5d4ac2272ccba011..f88cbb2328dfc3e2a35bff2d6da2ee97ba966000 100644 (file)
@@ -532,12 +532,15 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
                                  GLuint dst_offset,
                                  GLboolean dst_tiled,
                                  GLshort x, GLshort y, 
-                                 GLshort w, GLshort h)
+                                 GLshort w, GLshort h,
+                                 GLenum logic_op)
 {
    struct xy_setup_blit setup;
    struct xy_text_immediate_blit text;
    int dwords = ((src_size + 7) & ~7) / 4;
 
+   assert( logic_op - GL_CLEAR >= 0 );
+   assert( logic_op - GL_CLEAR < 0x10 );
 
    if (w < 0 || h < 0) 
       return;
@@ -561,7 +564,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
    setup.br0.length = (sizeof(setup) / sizeof(int)) - 2;
       
    setup.br13.dest_pitch = dst_pitch;
-   setup.br13.rop = 0xcc;
+   setup.br13.rop = translate_raster_op(logic_op);
    setup.br13.color_depth = (cpp == 4) ? BR13_8888 : BR13_565;
    setup.br13.clipping_enable = 0;
    setup.br13.mono_source_transparency = 1;
index 8b0cc65243cc617fba93e269387a8e4625acdfe9..e361545c8fab316c2e4315734fd69a1ec7a82642 100644 (file)
@@ -72,6 +72,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
                                  GLuint dst_offset,
                                  GLboolean dst_tiled,
                                  GLshort dst_x, GLshort dst_y, 
-                                 GLshort w, GLshort h);
+                                 GLshort w, GLshort h,
+                                 GLenum logic_op );
 
 #endif
index 5841afaa3ef9ec6395d76901addf1a9b92af363a..421fcc5e511651ae96845a1f5ccdf0bf53ad686d 100644 (file)
@@ -260,7 +260,9 @@ do_blit_bitmap( GLcontext *ctx,
               int h = MIN2(DY, box_h - py);
               int w = MIN2(DX, box_w - px); 
               GLuint sz = align(align(w,8) * h, 64)/8;
-           
+              GLenum logic_op = ctx->Color.ColorLogicOpEnabled ?
+                 ctx->Color.LogicOp : GL_COPY;
+
               assert(sz <= sizeof(stipple));
               memset(stipple, 0, sz);
 
@@ -288,7 +290,8 @@ do_blit_bitmap( GLcontext *ctx,
                                                  dst->tiled,
                                                  rect.x1 + px,
                                                  rect.y2 - (py + h),
-                                                 w, h);
+                                                 w, h,
+                                                 logic_op);
            } 
         } 
       }
index 857cd30584ccad91be8779257eb66a310adf31e4..f98d66656355716319db2de7ad4bb94408a6553e 100644 (file)
@@ -69,7 +69,7 @@ void
 nouveau_mem_free(GLcontext *ctx, nouveau_mem *mem)
 {
    nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   drm_nouveau_mem_free_t memf;
+   struct drm_nouveau_mem_free memf;
 
    if (NOUVEAU_DEBUG & DEBUG_MEM)  {
       fprintf(stderr, "%s: type=0x%x, offset=0x%x, size=0x%x\n",
@@ -78,8 +78,8 @@ nouveau_mem_free(GLcontext *ctx, nouveau_mem *mem)
 
    if (mem->map)
       drmUnmap(mem->map, mem->size);
-   memf.flags         = mem->type;
-   memf.region_offset = mem->offset;
+   memf.flags  = mem->type;
+   memf.offset = mem->offset;
    drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_MEM_FREE, &memf, sizeof(memf));
    FREE(mem);
 }
@@ -88,7 +88,7 @@ nouveau_mem *
 nouveau_mem_alloc(GLcontext *ctx, int type, GLuint size, GLuint align)
 {
    nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   drm_nouveau_mem_alloc_t mema;
+   struct drm_nouveau_mem_alloc mema;
    nouveau_mem *mem;
    int ret;
 
@@ -111,7 +111,7 @@ nouveau_mem_alloc(GLcontext *ctx, int type, GLuint size, GLuint align)
       FREE(mem);
       return NULL;
    }
-   mem->offset = mema.region_offset;
+   mem->offset = mema.offset;
    mem->type   = mema.flags;
 
    if (NOUVEAU_DEBUG & DEBUG_MEM)  {
@@ -120,7 +120,7 @@ nouveau_mem_alloc(GLcontext *ctx, int type, GLuint size, GLuint align)
    }
 
    if (type & NOUVEAU_MEM_MAPPED)
-      ret = drmMap(nmesa->driFd, mem->offset, mem->size, &mem->map);
+      ret = drmMap(nmesa->driFd, mema.map_handle, mem->size, &mem->map);
    if (ret) {
       mem->map = NULL;
       nouveau_mem_free(ctx, mem);
@@ -135,12 +135,7 @@ nouveau_mem_gpu_offset_get(GLcontext *ctx, nouveau_mem *mem)
 {
    nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
 
-   if (mem->type & NOUVEAU_MEM_FB)
-      return (uint32_t)mem->offset - nmesa->vram_phys;
-   else if (mem->type & NOUVEAU_MEM_AGP)
-      return (uint32_t)mem->offset - nmesa->gart_phys;
-   else
-      return 0xDEADF00D;
+   return mem->offset;
 }
 
 static GLboolean
index d96b00242cd3be6ef3cc171abd2a98e80a74149d..44392c0267cd25d2415102e13a942efa208547b2 100644 (file)
@@ -180,7 +180,7 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual,
        driParseConfigFiles (&nmesa->optionCache, &screen->optionCache,
                        screen->driScreen->myNum, "nouveau");
 
-       nmesa->sarea = (drm_nouveau_sarea_t *)((char *)sPriv->pSAREA +
+       nmesa->sarea = (struct drm_nouveau_sarea *)((char *)sPriv->pSAREA +
                        screen->sarea_priv_offset);
 
        /* Enable any supported extensions */
@@ -224,6 +224,8 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual,
                        nv04TriInitFunctions( ctx );
                        break;
                case NV_10:
+               case NV_11:
+               case NV_17:
                case NV_20:
                case NV_30:
                case NV_40:
index 10d2ed6e172fbc37eee6f442fe762fb183f2d102..9a0be2cb2a57dee36d38c7611e31a899333b7bea 100644 (file)
@@ -109,12 +109,12 @@ typedef struct nouveau_context {
        uint64_t gart_size;
 
        /* Channel synchronisation */
-       drm_nouveau_notifier_alloc_t *syncNotifier;
+       struct drm_nouveau_notifier_alloc *syncNotifier;
 
        /* ARB_occlusion_query / EXT_timer_query */
        GLuint            query_object_max;
        GLboolean *       query_alloc;
-       drm_nouveau_notifier_alloc_t *queryNotifier;
+       struct drm_nouveau_notifier_alloc *queryNotifier;
 
        /* Additional hw-specific functions */
        nouveau_hw_func hw_func;
@@ -168,7 +168,7 @@ typedef struct nouveau_context {
        nouveauShader *passthrough_fp;
 
        nouveauScreenRec *screen;
-       drm_nouveau_sarea_t *sarea;
+       struct drm_nouveau_sarea *sarea;
 
        __DRIcontextPrivate  *driContext;    /* DRI context */
        __DRIscreenPrivate   *driScreen;     /* DRI screen */
index 00956aa8f8b312655083a2e66c9f638d65663c5d..ddc9535624b80f2394982a5833da396e56511abf 100644 (file)
@@ -41,7 +41,7 @@ GLboolean nouveauDRMGetParam(nouveauContextPtr nmesa,
                             unsigned int      param,
                             uint64_t*         value)
 {
-       drm_nouveau_getparam_t getp;
+       struct drm_nouveau_getparam getp;
 
        getp.param = param;
        if (!value || drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_GETPARAM,
@@ -56,7 +56,7 @@ GLboolean nouveauDRMSetParam(nouveauContextPtr nmesa,
                             unsigned int      param,
                             uint64_t          value)
 {
-       drm_nouveau_setparam_t setp;
+       struct drm_nouveau_setparam setp;
 
        setp.param = param;
        setp.value = value;
index e9320918f9fca480f84aab7f93a14df64433abba..7b5e96b4c2615e764fc3b9b92634056fa85fc2be 100644 (file)
@@ -98,7 +98,7 @@ void nouveauWaitForIdle(nouveauContextPtr nmesa)
 // here we call the fifo initialization ioctl and fill in stuff accordingly
 GLboolean nouveauFifoInit(nouveauContextPtr nmesa)
 {
-       drm_nouveau_fifo_alloc_t fifo_init;
+       struct drm_nouveau_fifo_alloc fifo_init;
        int i, ret;
 
 #ifdef NOUVEAU_RING_DEBUG
index c119d14dd751407169e5d83f42999587e5d72598..aa86c9e783841fa44d6e97c9d7451bf84a99bd31 100644 (file)
@@ -44,7 +44,7 @@ void nouveauGetLock( nouveauContextPtr nmesa, GLuint flags )
 {
    __DRIdrawablePrivate *dPriv = nmesa->driDrawable;
    __DRIscreenPrivate *sPriv = nmesa->driScreen;
-   drm_nouveau_sarea_t *sarea = nmesa->sarea;
+   struct drm_nouveau_sarea *sarea = nmesa->sarea;
 
    drmGetLock( nmesa->driFd, nmesa->hHWContext, flags );
 
index 69f8dbf7946499f2edb268af04e50bf2f04040d6..a143488e8d5913e66197a9b4baad3dc5dcee4033 100644 (file)
@@ -7,7 +7,7 @@
 GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa,
                                     uint32_t handle, int class)
 {
-       drm_nouveau_grobj_alloc_t cto;
+       struct drm_nouveau_grobj_alloc cto;
        int ret;
 
        cto.channel = nmesa->fifo.channel;
@@ -34,10 +34,13 @@ void nouveauObjectInit(nouveauContextPtr nmesa)
        nouveauCreateContextObject(nmesa, Nv3D, nmesa->screen->card->class_3d);
        if (nmesa->screen->card->type>=NV_10) {
                nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV10_CONTEXT_SURFACES_2D);
-               nouveauCreateContextObject(nmesa, NvImageBlit, NV10_IMAGE_BLIT);
        } else {
                nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV04_CONTEXT_SURFACES_2D);
                nouveauCreateContextObject(nmesa, NvCtxSurf3D, NV04_CONTEXT_SURFACES_3D);
+       }
+       if (nmesa->screen->card->type>=NV_11) {
+               nouveauCreateContextObject(nmesa, NvImageBlit, NV10_IMAGE_BLIT);
+       } else {
                nouveauCreateContextObject(nmesa, NvImageBlit, NV_IMAGE_BLIT);
        }
        nouveauCreateContextObject(nmesa, NvMemFormat, NV_MEMORY_TO_MEMORY_FORMAT);
index bc7f39b042a6f4d42f34bf4fd33ad9c486a89340..69b0691bb7b49f53e8c6f8e719b1d47f3efc49a5 100644 (file)
@@ -328,7 +328,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc
        static const __DRIversion ddx_expected = { 1, 2, 0 };
        static const __DRIversion dri_expected = { 4, 0, 0 };
        static const __DRIversion drm_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL };
-#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 7
+#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 9
 #error nouveau_drm.h version doesn't match expected version
 #endif
        dri_interface = interface;
index 7cb805902a7553708aae3e217e530743f94444f0..f618dcfc99b5b5f079c5551c8cd72bade8d6c045 100644 (file)
@@ -162,6 +162,8 @@ void nouveauDDInitState(nouveauContextPtr nmesa)
             nv04InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver);
             break;
         case NV_10:
+        case NV_11:
+        case NV_17:
             nv10InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver);
             break;
         case NV_20:
index 1d1eeede18b650b4037ec354fe8fa8edfd0c607f..8abc847e1e2f1845e91e9f2f8f7c3c89eeca3028 100644 (file)
        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \
        volatile uint32_t *__v = (void*)nmesa->notifier_block + notifier->offset
 
-drm_nouveau_notifier_alloc_t *
+struct drm_nouveau_notifier_alloc *
 nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count)
 {
        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       drm_nouveau_notifier_alloc_t *notifier;
+       struct drm_nouveau_notifier_alloc *notifier;
        int ret;
 
 #ifdef NOUVEAU_RING_DEBUG
@@ -69,14 +69,16 @@ nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count)
 }
 
 void
-nouveau_notifier_destroy(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier)
+nouveau_notifier_destroy(GLcontext *ctx,
+                        struct drm_nouveau_notifier_alloc *notifier)
 {
        /*XXX: free notifier object.. */
        FREE(notifier);
 }
 
 void
-nouveau_notifier_reset(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier,
+nouveau_notifier_reset(GLcontext *ctx,
+                      struct drm_nouveau_notifier_alloc *notifier,
                       GLuint id)
 {
        NOTIFIER(n);
@@ -93,7 +95,8 @@ nouveau_notifier_reset(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier,
 }
 
 GLuint
-nouveau_notifier_status(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier,
+nouveau_notifier_status(GLcontext *ctx,
+                       struct drm_nouveau_notifier_alloc *notifier,
                        GLuint id)
 {
        NOTIFIER(n);
@@ -103,7 +106,8 @@ nouveau_notifier_status(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier,
 
 GLuint
 nouveau_notifier_return_val(GLcontext *ctx,
-                           drm_nouveau_notifier_alloc_t *notifier, GLuint id)
+                           struct drm_nouveau_notifier_alloc *notifier,
+                           GLuint id)
 {
        NOTIFIER(n);
 
@@ -112,8 +116,8 @@ nouveau_notifier_return_val(GLcontext *ctx,
 
 GLboolean
 nouveau_notifier_wait_status(GLcontext *ctx,
-                            drm_nouveau_notifier_alloc_t *notifier, GLuint id,
-                            GLuint status, GLuint timeout)
+                            struct drm_nouveau_notifier_alloc *notifier,
+                            GLuint id, GLuint status, GLuint timeout)
 {
        NOTIFIER(n);
        unsigned int time = 0;
@@ -146,7 +150,8 @@ nouveau_notifier_wait_status(GLcontext *ctx,
 
 void
 nouveau_notifier_wait_nop(GLcontext *ctx,
-                         drm_nouveau_notifier_alloc_t *notifier, GLuint subc)
+                         struct drm_nouveau_notifier_alloc *notifier,
+                         GLuint subc)
 {
        NOTIFIER(n);
        GLboolean ret;
index b56cc5fb544a14483af7ce018dd97ea0a4d83cb6..b76af172762d6537b53dfe767c889744f8cee6ce 100644 (file)
 #define NV_NOTIFY                                                     0x00000104
 #define NV_NOTIFY_STYLE_WRITE_ONLY                                             0
 
-extern drm_nouveau_notifier_alloc_t *
+extern struct drm_nouveau_notifier_alloc *
 nouveau_notifier_new(GLcontext *, GLuint handle, GLuint count);
 extern void 
-nouveau_notifier_destroy(GLcontext *, drm_nouveau_notifier_alloc_t *);
+nouveau_notifier_destroy(GLcontext *, struct drm_nouveau_notifier_alloc *);
 extern void
-nouveau_notifier_reset(GLcontext *, drm_nouveau_notifier_alloc_t *, GLuint id);
+nouveau_notifier_reset(GLcontext *, struct drm_nouveau_notifier_alloc *,
+                      GLuint id);
 extern GLuint
-nouveau_notifier_status(GLcontext *, drm_nouveau_notifier_alloc_t *, GLuint id);
+nouveau_notifier_status(GLcontext *, struct drm_nouveau_notifier_alloc *,
+                       GLuint id);
 extern GLuint
-nouveau_notifier_return_val(GLcontext *, drm_nouveau_notifier_alloc_t *,
+nouveau_notifier_return_val(GLcontext *, struct drm_nouveau_notifier_alloc *,
                            GLuint id);
 extern GLboolean
-nouveau_notifier_wait_status(GLcontext *, drm_nouveau_notifier_alloc_t *,
+nouveau_notifier_wait_status(GLcontext *, struct drm_nouveau_notifier_alloc *,
                             GLuint id, GLuint status, GLuint timeout);
 extern void
-nouveau_notifier_wait_nop(GLcontext *ctx, drm_nouveau_notifier_alloc_t *,
+nouveau_notifier_wait_nop(GLcontext *ctx, struct drm_nouveau_notifier_alloc *,
                          GLuint subc);
 
 extern GLboolean nouveauSyncInitFuncs(GLcontext *ctx);
index 5f304ccab9251db3530b1d583e757591684802ef..47c4b14ba6b68fc4dc4ea5205d2b53e7ca39e795 100644 (file)
@@ -697,8 +697,7 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa)
        BEGIN_RING_SIZE(NvSub3D, 0x03f4, 1);
        OUT_RING(0);
 
-       /* not for nv10, only for >= nv11 */
-       if ((nmesa->screen->card->id>>4) >= 0x11) {
+       if (nmesa->screen->card->type >= NV_11) {
                BEGIN_RING_SIZE(NvSub3D, 0x120, 3);
                OUT_RING(0);
                OUT_RING(1);
@@ -739,11 +738,11 @@ static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color,
        OUT_RING_CACHE(depth ? depth->offset : color[0]->offset);
 
        /* Always set to bottom left of buffer */
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4);
+       /*BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4);
        OUT_RING_CACHEf (0.0);
        OUT_RING_CACHEf ((GLfloat) h);
        OUT_RING_CACHEf (0.0);
-       OUT_RING_CACHEf (0.0);
+       OUT_RING_CACHEf (0.0);*/
 
        return GL_TRUE;
 }
index 4576c1ede4d1273184b8fe25f8621fe8a5634660..611469b6e413c2f01b81141ba86a395643c45421 100644 (file)
@@ -58,7 +58,7 @@ static void nv10ResetLineStipple( GLcontext *ctx );
 
 static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t primitive,uint32_t size)
 {
-       if (nmesa->screen->card->type==NV_10)
+       if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17))
                BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1);
        else if (nmesa->screen->card->type==NV_20)
                BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_BEGIN_END,1);
@@ -66,7 +66,7 @@ static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t pri
                BEGIN_RING_SIZE(NvSub3D,NV30_TCL_PRIMITIVE_3D_BEGIN_END,1);
        OUT_RING(primitive);
 
-       if (nmesa->screen->card->type==NV_10)
+       if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17))
                BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_DATA|NONINC_METHOD,size);
        else if (nmesa->screen->card->type==NV_20)
                BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_VERTEX_DATA|NONINC_METHOD,size);
@@ -76,7 +76,7 @@ static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t pri
 
 inline void nv10FinishPrimitive(struct nouveau_context *nmesa)
 {
-       if (nmesa->screen->card->type==NV_10)
+       if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17))
                BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1);
        else if (nmesa->screen->card->type==NV_20)
                BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_BEGIN_END,1);
@@ -454,7 +454,7 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa)
        /* 
         * Tell the hardware about the vertex format
         */
-       if (nmesa->screen->card->type==NV_10) {
+       if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) {
                int size;
 
 #define NV_VERTEX_ATTRIBUTE_TYPE_FLOAT 2
index 3d8d83a865ac3afec9f834591a440482c2042c94..ccf2f6148b4908d41403dc3276eb3feaeb628eb8 100644 (file)
@@ -568,10 +568,10 @@ static void nv20Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
           y += nmesa->drawY;
        }
 
-        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_X2_X1, 1);
+        /*BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_X2_X1, 1);
         OUT_RING_CACHE((w << 16) | x );
         BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_Y2_Y1, 1);
-        OUT_RING_CACHE((h << 16) | y );
+        OUT_RING_CACHE((h << 16) | y );*/
 
 }
 
@@ -764,11 +764,11 @@ static GLboolean nv20BindBuffers(nouveauContextPtr nmesa, int num_color,
        }
 
        /* Always set to bottom left of buffer */
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4);
+       /*BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4);
        OUT_RING_CACHEf (0.0);
        OUT_RING_CACHEf ((GLfloat) h);
        OUT_RING_CACHEf (0.0);
-       OUT_RING_CACHEf (0.0);
+       OUT_RING_CACHEf (0.0);*/
 
        return GL_TRUE;
 }
index 04e3fffa5df681c81014685ec60d0651d508dfb8..14e0f052fd57aec1b6f7b038c5cb5bcffc7896f0 100644 (file)
@@ -318,15 +318,17 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        _tnl_allow_vertex_fog(ctx, GL_TRUE);
 
        /* currently bogus data */
-       ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4;
-       ctx->Const.VertexProgram.MaxNativeInstructions =
-           VSF_MAX_FRAGMENT_LENGTH / 4;
-       ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */
-       ctx->Const.VertexProgram.MaxTemps = 32;
-       ctx->Const.VertexProgram.MaxNativeTemps =
-           /*VSF_MAX_FRAGMENT_TEMPS */ 32;
-       ctx->Const.VertexProgram.MaxNativeParameters = 256;     /* r420 */
-       ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
+       if (screen->chip_flags & RADEON_CHIPSET_TCL) {
+               ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4;
+               ctx->Const.VertexProgram.MaxNativeInstructions =
+                 VSF_MAX_FRAGMENT_LENGTH / 4;
+               ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */
+               ctx->Const.VertexProgram.MaxTemps = 32;
+               ctx->Const.VertexProgram.MaxNativeTemps =
+                 /*VSF_MAX_FRAGMENT_TEMPS */ 32;
+               ctx->Const.VertexProgram.MaxNativeParameters = 256;     /* r420 */
+               ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
+       }
 
        ctx->Const.FragmentProgram.MaxNativeTemps = PFS_NUM_TEMP_REGS;
        ctx->Const.FragmentProgram.MaxNativeAttribs = 11;       /* copy i915... */
@@ -364,7 +366,8 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        radeonInitSpanFuncs(ctx);
        r300InitCmdBuf(r300);
        r300InitState(r300);
-       r300InitSwtcl(ctx);
+       if (!(screen->chip_flags & RADEON_CHIPSET_TCL))
+               r300InitSwtcl(ctx);
 
        TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
 
index 6615bc79fb3edc10153d12a37665dea909c12a0d..0349bac9a26a69ec838388eccf7b1bcd2575c1e5 100644 (file)
@@ -568,19 +568,10 @@ struct r300_vertex_shader_fragment {
        union {
                GLuint d[VSF_MAX_FRAGMENT_LENGTH];
                float f[VSF_MAX_FRAGMENT_LENGTH];
-               VERTEX_SHADER_INSTRUCTION i[VSF_MAX_FRAGMENT_LENGTH / 4];
+               struct r300_vertprog_instruction i[VSF_MAX_FRAGMENT_LENGTH / 4];
        } body;
 };
 
-#define VSF_DEST_PROGRAM       0x0
-#define VSF_DEST_MATRIX0       0x200
-#define VSF_DEST_MATRIX1       0x204
-#define VSF_DEST_MATRIX2       0x208
-#define VSF_DEST_VECTOR0       0x20c
-#define VSF_DEST_VECTOR1       0x20d
-#define VSF_DEST_UNKNOWN1      0x400
-#define VSF_DEST_UNKNOWN2      0x406
-
 struct r300_vertex_shader_state {
        struct r300_vertex_shader_fragment program;
 };
index 229439dfa871e6673a544133283b0d90774b0a29..424bf44e595159dbe48d59d733bc2f1ca087cc93 100644 (file)
@@ -299,13 +299,14 @@ GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten)
        if (OutputsWritten & (1 << VERT_RESULT_COL1))
                ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
 
-#if 0
-       if (OutputsWritten & (1 << VERT_RESULT_BFC0))
-               ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT;
-
-       if (OutputsWritten & (1 << VERT_RESULT_BFC1))
-               ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;
+       if (OutputsWritten & (1 << VERT_RESULT_BFC0)
+           || OutputsWritten & (1 << VERT_RESULT_BFC1))
+               ret |=
+                   R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT |
+                   R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT |
+                   R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;
 
+#if 0
        if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ;
 #endif
 
index e59919be493cc1e3724e157af2e62800f42bdce3..1baa74c5269e6d929d2381aa03db653cdc8c1533 100644 (file)
@@ -282,9 +282,32 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #define R300_VAP_PVS_UPLOAD_ADDRESS         0x2200
 #       define R300_PVS_UPLOAD_PROGRAM           0x00000000
+/* gap */
 #       define R300_PVS_UPLOAD_PARAMETERS        0x00000200
+/* gap */
+#       define R300_PVS_UPLOAD_CLIP_PLANE0       0x00000400
+#       define R300_PVS_UPLOAD_CLIP_PLANE1       0x00000401
+#       define R300_PVS_UPLOAD_CLIP_PLANE2       0x00000402
+#       define R300_PVS_UPLOAD_CLIP_PLANE3       0x00000403
+#       define R300_PVS_UPLOAD_CLIP_PLANE4       0x00000404
+#       define R300_PVS_UPLOAD_CLIP_PLANE5       0x00000405
 #       define R300_PVS_UPLOAD_POINTSIZE         0x00000406
 
+/*
+ * These are obsolete defines form r300_context.h, but they might give some
+ * clues when investigating the addresses further...
+ */
+#if 0
+#define VSF_DEST_PROGRAM        0x0
+#define VSF_DEST_MATRIX0        0x200
+#define VSF_DEST_MATRIX1        0x204
+#define VSF_DEST_MATRIX2        0x208
+#define VSF_DEST_VECTOR0        0x20c
+#define VSF_DEST_VECTOR1        0x20d
+#define VSF_DEST_UNKNOWN1       0x400
+#define VSF_DEST_UNKNOWN2       0x406
+#endif
+
 /* gap */
 
 #define R300_VAP_PVS_UPLOAD_DATA            0x2208
index b5cf21d644a32afe1a84f27a1c3467d67766129a..6789efd428121dcf42a41a95bfa435d1156548f6 100644 (file)
@@ -82,6 +82,8 @@ static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
 
        rmesa->hw.blend_color.cmd[1] = PACK_COLOR_8888(color[3], color[0],
                                                       color[1], color[2]);
+       rmesa->hw.blend_color.cmd[2] = 0;
+       rmesa->hw.blend_color.cmd[3] = 0;
 }
 
 /**
@@ -317,20 +319,34 @@ static void r300UpdateCulling(GLcontext * ctx)
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        uint32_t val = 0;
 
-       R300_STATECHANGE(r300, cul);
        if (ctx->Polygon.CullFlag) {
-               if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
-                       val = R300_CULL_FRONT | R300_CULL_BACK;
-               else if (ctx->Polygon.CullFaceMode == GL_FRONT)
+               switch (ctx->Polygon.CullFaceMode) {
+               case GL_FRONT:
                        val = R300_CULL_FRONT;
-               else
+                       break;
+               case GL_BACK:
                        val = R300_CULL_BACK;
+                       break;
+               case GL_FRONT_AND_BACK:
+                       val = R300_CULL_FRONT | R300_CULL_BACK;
+                       break;
+               default:
+                       break;
+               }
+       }
 
-               if (ctx->Polygon.FrontFace == GL_CW)
-                       val |= R300_FRONT_FACE_CW;
-               else
-                       val |= R300_FRONT_FACE_CCW;
+       switch (ctx->Polygon.FrontFace) {
+       case GL_CW:
+               val |= R300_FRONT_FACE_CW;
+               break;
+       case GL_CCW:
+               val |= R300_FRONT_FACE_CCW;
+               break;
+       default:
+               break;
        }
+
+       R300_STATECHANGE(r300, cul);
        r300->hw.cul.cmd[R300_CUL_CULL] = val;
 }
 
@@ -344,6 +360,20 @@ static void r300SetEarlyZState(GLcontext * ctx)
        r300ContextPtr r300 = R300_CONTEXT(ctx);
 
        R300_STATECHANGE(r300, zstencil_format);
+       switch (ctx->Visual.depthBits) {
+       case 16:
+               r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_16BIT_INT_Z;
+               break;
+       case 24:
+               r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_24BIT_INT_Z;
+               break;
+       default:
+               fprintf(stderr, "Error: Unsupported depth %d... exiting\n", ctx->Visual.depthBits);
+               _mesa_exit(-1);
+       }
+
+       // r300->hw.zstencil_format.cmd[1] |= R300_DEPTH_FORMAT_UNK32;
+
        if (ctx->Color.AlphaEnabled && ctx->Color.AlphaFunc != GL_ALWAYS)
                /* disable early Z */
                r300->hw.zstencil_format.cmd[2] = R300_EARLY_Z_DISABLE;
@@ -355,6 +385,9 @@ static void r300SetEarlyZState(GLcontext * ctx)
                        /* disable early Z */
                        r300->hw.zstencil_format.cmd[2] = R300_EARLY_Z_DISABLE;
        }
+
+       r300->hw.zstencil_format.cmd[3] = 0x00000003;
+       r300->hw.zstencil_format.cmd[4] = 0x00000000;
 }
 
 static void r300SetAlphaState(GLcontext * ctx)
@@ -403,6 +436,7 @@ static void r300SetAlphaState(GLcontext * ctx)
 
        R300_STATECHANGE(r300, at);
        r300->hw.at.cmd[R300_AT_ALPHA_TEST] = pp_misc;
+       r300->hw.at.cmd[R300_AT_UNKNOWN] = 0;
 
        r300SetEarlyZState(ctx);
 }
@@ -513,6 +547,9 @@ static void r300UpdatePolygonMode(GLcontext * ctx)
                R300_STATECHANGE(r300, polygon_mode);
                r300->hw.polygon_mode.cmd[1] = hw_mode;
        }
+
+       r300->hw.polygon_mode.cmd[2] = 0x00000001;
+       r300->hw.polygon_mode.cmd[3] = 0x00000000;
 }
 
 /**
@@ -762,6 +799,7 @@ static void r300ShadeModel(GLcontext * ctx, GLenum mode)
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
 
        R300_STATECHANGE(rmesa, shade);
+       rmesa->hw.shade.cmd[1] = 0x00000002;
        switch (mode) {
        case GL_FLAT:
                rmesa->hw.shade.cmd[2] = R300_RE_SHADE_MODEL_FLAT;
@@ -772,6 +810,8 @@ static void r300ShadeModel(GLcontext * ctx, GLenum mode)
        default:
                return;
        }
+       rmesa->hw.shade.cmd[3] = 0x00000000;
+       rmesa->hw.shade.cmd[4] = 0x00000000;
 }
 
 static void r300StencilFuncSeparate(GLcontext * ctx, GLenum face,
@@ -1526,7 +1566,7 @@ static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa)
 
        for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_MAX; i++) {
                if (rmesa->state.sw_tcl_inputs[i] != -1) {
-                       prog->program.body.i[program_end].op = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT);
+                       prog->program.body.i[program_end].opcode = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT);
                        prog->program.body.i[program_end].src[0] = VSF_REG(rmesa->state.sw_tcl_inputs[i]);
                        prog->program.body.i[program_end].src[1] = VSF_ATTR_UNITY(rmesa->state.sw_tcl_inputs[i]);
                        prog->program.body.i[program_end].src[2] = VSF_UNITY(rmesa->state.sw_tcl_inputs[i]);
@@ -1536,7 +1576,7 @@ static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa)
 
        prog->program.length = program_end * 4;
 
-       r300SetupVertexProgramFragment(rmesa, VSF_DEST_PROGRAM, &(prog->program));
+       r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, &(prog->program));
        inst_count = (prog->program.length / 4) - 1;
 
        R300_STATECHANGE(rmesa, pvs);
@@ -1570,7 +1610,7 @@ static void r300SetupRealVertexProgram(r300ContextPtr rmesa)
        bump_vpu_count(rmesa->hw.vpp.cmd, param_count);
        param_count /= 4;
 
-       r300SetupVertexProgramFragment(rmesa, VSF_DEST_PROGRAM, &(prog->program));
+       r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, &(prog->program));
        inst_count = (prog->program.length / 4) - 1;
 
        R300_STATECHANGE(rmesa, pvs);
@@ -1848,15 +1888,10 @@ static void r300ResetHwState(r300ContextPtr r300)
        r300->hw.unk4260.cmd[2] = r300PackFloat32(0.0);
        r300->hw.unk4260.cmd[3] = r300PackFloat32(1.0);
 
-       r300->hw.shade.cmd[1] = 0x00000002;
        r300ShadeModel(ctx, ctx->Light.ShadeModel);
-       r300->hw.shade.cmd[3] = 0x00000000;
-       r300->hw.shade.cmd[4] = 0x00000000;
 
        r300PolygonMode(ctx, GL_FRONT, ctx->Polygon.FrontMode);
        r300PolygonMode(ctx, GL_BACK, ctx->Polygon.BackMode);
-       r300->hw.polygon_mode.cmd[2] = 0x00000001;
-       r300->hw.polygon_mode.cmd[3] = 0x00000000;
        r300->hw.zbias_cntl.cmd[1] = 0x00000000;
 
        r300PolygonOffset(ctx, ctx->Polygon.OffsetFactor,
@@ -1887,14 +1922,11 @@ static void r300ResetHwState(r300ContextPtr r300)
        r300Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
        r300Fogfv(ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL);
 
-       r300->hw.at.cmd[R300_AT_UNKNOWN] = 0;
        r300->hw.unk4BD8.cmd[1] = 0;
 
        r300->hw.unk4E00.cmd[1] = 0;
 
        r300BlendColor(ctx, ctx->Color.BlendColor);
-       r300->hw.blend_color.cmd[2] = 0;
-       r300->hw.blend_color.cmd[3] = 0;
 
        /* Again, r300ClearBuffer uses this */
        r300->hw.cb.cmd[R300_CB_OFFSET] =
@@ -1925,25 +1957,6 @@ static void r300ResetHwState(r300ContextPtr r300)
        r300->hw.unk4EA0.cmd[1] = 0x00000000;
        r300->hw.unk4EA0.cmd[2] = 0xffffffff;
 
-       switch (ctx->Visual.depthBits) {
-       case 16:
-               r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_16BIT_INT_Z;
-               break;
-       case 24:
-               r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_24BIT_INT_Z;
-               break;
-       default:
-               fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
-                       ctx->Visual.depthBits);
-               _mesa_exit(-1);
-
-       }
-       /* z compress? */
-       //r300->hw.zstencil_format.cmd[1] |= R300_DEPTH_FORMAT_UNK32;
-
-       r300->hw.zstencil_format.cmd[3] = 0x00000003;
-       r300->hw.zstencil_format.cmd[4] = 0x00000000;
-
        r300->hw.zb.cmd[R300_ZB_OFFSET] =
            r300->radeon.radeonScreen->depthOffset +
            r300->radeon.radeonScreen->fbLocation;
index 7aea063447a0e6a4d68a44c14500e20cee39b7e9..c949f33bf33eb348432555c2aa15971258073408 100644 (file)
@@ -668,6 +668,11 @@ void r300InitSwtcl(GLcontext *ctx)
 
        _tnl_need_projected_coords( ctx, GL_FALSE );
        r300ChooseRenderState(ctx);
+
+       _mesa_validate_all_lighting_tables( ctx ); 
+
+       tnl->Driver.NotifyMaterialChange = 
+         _mesa_validate_all_lighting_tables;
 }
 
 void r300DestroySwtcl(GLcontext *ctx)
index 16dddf6557d5317ed539a9f17ed244cb4070d688..0fb6110494be23f1351db7a12b9bcab4cc25870d 100644 (file)
@@ -29,6 +29,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * \file
  *
  * \author Aapo Tahkola <aet@rasterburn.org>
+ *
+ * \author Oliver McFadden <z3ro.geek@gmail.com>
  */
 
 #include "glheader.h"
@@ -55,54 +57,58 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #error Cannot change these!
 #endif
 
-#define SCALAR_FLAG (1<<31)
-#define FLAG_MASK (1<<31)
-#define OP_MASK        (0xf)           /* we are unlikely to have more than 15 */
-#define OPN(operator, ip) {#operator, OPCODE_##operator, ip}
-
-static struct {
-       char *name;
-       int opcode;
-       unsigned long ip;       /* number of input operands and flags */
-} op_names[] = {
-       /* *INDENT-OFF* */
-       OPN(ABS, 1),
-       OPN(ADD, 2),
-       OPN(ARL, 1 | SCALAR_FLAG),
-       OPN(DP3, 2),
-       OPN(DP4, 2),
-       OPN(DPH, 2),
-       OPN(DST, 2),
-       OPN(EX2, 1 | SCALAR_FLAG),
-       OPN(EXP, 1 | SCALAR_FLAG),
-       OPN(FLR, 1),
-       OPN(FRC, 1),
-       OPN(LG2, 1 | SCALAR_FLAG),
-       OPN(LIT, 1),
-       OPN(LOG, 1 | SCALAR_FLAG),
-       OPN(MAD, 3),
-       OPN(MAX, 2),
-       OPN(MIN, 2),
-       OPN(MOV, 1),
-       OPN(MUL, 2),
-       OPN(POW, 2 | SCALAR_FLAG),
-       OPN(RCP, 1 | SCALAR_FLAG),
-       OPN(RSQ, 1 | SCALAR_FLAG),
-       OPN(SGE, 2),
-       OPN(SLT, 2),
-       OPN(SUB, 2),
-       OPN(SWZ, 1),
-       OPN(XPD, 2),
-       OPN(RCC, 0),    //extra
-       OPN(PRINT, 0),
-       OPN(END, 0)
-       /* *INDENT-ON* */
-};
-
-#undef OPN
+/* TODO: Get rid of t_src_class call */
+#define CMP_SRCS(a, b) ((a.RelAddr != b.RelAddr) || (a.Index != b.Index && \
+                      ((t_src_class(a.File) == VSF_IN_CLASS_PARAM && \
+                        t_src_class(b.File) == VSF_IN_CLASS_PARAM) || \
+                       (t_src_class(a.File) == VSF_IN_CLASS_ATTR && \
+                        t_src_class(b.File) == VSF_IN_CLASS_ATTR)))) \
+
+#define ZERO_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
+                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
+                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
+                                   t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
+
+#define ZERO_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
+                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
+                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
+                                   t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
+
+#define ZERO_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
+                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
+                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
+                                   t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
+
+#define ONE_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
+                                   SWIZZLE_ONE, SWIZZLE_ONE, \
+                                   SWIZZLE_ONE, SWIZZLE_ONE, \
+                                   t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
+
+#define ONE_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
+                                   SWIZZLE_ONE, SWIZZLE_ONE, \
+                                   SWIZZLE_ONE, SWIZZLE_ONE, \
+                                   t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
+
+#define ONE_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
+                                   SWIZZLE_ONE, SWIZZLE_ONE, \
+                                   SWIZZLE_ONE, SWIZZLE_ONE, \
+                                   t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
+
+/* DP4 version seems to trigger some hw peculiarity */
+//#define PREFER_DP4
+
+#define FREE_TEMPS() \
+       do { \
+               if(u_temp_i < vp->num_temporaries) { \
+                       WARN_ONCE("Ran out of temps, num temps %d, us %d\n", vp->num_temporaries, u_temp_i); \
+                       vp->native = GL_FALSE; \
+               } \
+               u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \
+       } while (0)
 
 int r300VertexProgUpdateParams(GLcontext * ctx,
-                              struct r300_vertex_program_cont *vp, float *dst)
+                              struct r300_vertex_program_cont *vp,
+                              float *dst)
 {
        int pi;
        struct gl_vertex_program *mesa_vp = &vp->mesa_program;
@@ -234,8 +240,8 @@ static void vp_dump_inputs(struct r300_vertex_program *vp, char *caller)
        int i;
 
        if (vp == NULL) {
-               fprintf(stderr, "vp null in call to %s from %s\n", __FUNCTION__,
-                       caller);
+               fprintf(stderr, "vp null in call to %s from %s\n",
+                       __FUNCTION__, caller);
                return;
        }
 
@@ -276,6 +282,8 @@ static unsigned long t_src_index(struct r300_vertex_program *vp,
        }
 }
 
+/* these two functions should probably be merged... */
+
 static unsigned long t_src(struct r300_vertex_program *vp,
                           struct prog_src_register *src)
 {
@@ -294,7 +302,9 @@ static unsigned long t_src(struct r300_vertex_program *vp,
 static unsigned long t_src_scalar(struct r300_vertex_program *vp,
                                  struct prog_src_register *src)
 {
-
+       /* src->NegateBase uses the NEGATE_ flags from program_instruction.h,
+        * which equal our VSF_FLAGS_ values, so it's safe to just pass it here.
+        */
        return MAKE_VSF_SOURCE(t_src_index(vp, src),
                               t_swizzle(GET_SWZ(src->Swizzle, 0)),
                               t_swizzle(GET_SWZ(src->Swizzle, 0)),
@@ -306,128 +316,727 @@ static unsigned long t_src_scalar(struct r300_vertex_program *vp,
            (src->RelAddr << 4);
 }
 
-static unsigned long t_opcode(enum prog_opcode opcode)
+static GLboolean valid_dst(struct r300_vertex_program *vp,
+                          struct prog_dst_register *dst)
 {
+       if (dst->File == PROGRAM_OUTPUT && vp->outputs[dst->Index] == -1) {
+               return GL_FALSE;
+       } else if (dst->File == PROGRAM_ADDRESS) {
+               assert(dst->Index == 0);
+       }
+
+       return GL_TRUE;
+}
 
-       switch (opcode) {
-       /* *INDENT-OFF* */
-       case OPCODE_ARL: return R300_VPI_OUT_OP_ARL;
-       case OPCODE_DST: return R300_VPI_OUT_OP_DST;
-       case OPCODE_EX2: return R300_VPI_OUT_OP_EX2;
-       case OPCODE_EXP: return R300_VPI_OUT_OP_EXP;
-       case OPCODE_FRC: return R300_VPI_OUT_OP_FRC;
-       case OPCODE_LG2: return R300_VPI_OUT_OP_LG2;
-       case OPCODE_LOG: return R300_VPI_OUT_OP_LOG;
-       case OPCODE_MAX: return R300_VPI_OUT_OP_MAX;
-       case OPCODE_MIN: return R300_VPI_OUT_OP_MIN;
-       case OPCODE_MUL: return R300_VPI_OUT_OP_MUL;
-       case OPCODE_RCP: return R300_VPI_OUT_OP_RCP;
-       case OPCODE_RSQ: return R300_VPI_OUT_OP_RSQ;
-       case OPCODE_SGE: return R300_VPI_OUT_OP_SGE;
-       case OPCODE_SLT: return R300_VPI_OUT_OP_SLT;
-       case OPCODE_DP4: return R300_VPI_OUT_OP_DOT;
-       /* *INDENT-ON* */
+/*
+ * Instruction    Inputs  Output   Description
+ * -----------    ------  ------   --------------------------------
+ * ABS            v       v        absolute value
+ * ADD            v,v     v        add
+ * ARL            s       a        address register load
+ * DP3            v,v     ssss     3-component dot product
+ * DP4            v,v     ssss     4-component dot product
+ * DPH            v,v     ssss     homogeneous dot product
+ * DST            v,v     v        distance vector
+ * EX2            s       ssss     exponential base 2
+ * EXP            s       v        exponential base 2 (approximate)
+ * FLR            v       v        floor
+ * FRC            v       v        fraction
+ * LG2            s       ssss     logarithm base 2
+ * LIT            v       v        compute light coefficients
+ * LOG            s       v        logarithm base 2 (approximate)
+ * MAD            v,v,v   v        multiply and add
+ * MAX            v,v     v        maximum
+ * MIN            v,v     v        minimum
+ * MOV            v       v        move
+ * MUL            v,v     v        multiply
+ * POW            s,s     ssss     exponentiate
+ * RCP            s       ssss     reciprocal
+ * RSQ            s       ssss     reciprocal square root
+ * SGE            v,v     v        set on greater than or equal
+ * SLT            v,v     v        set on less than
+ * SUB            v,v     v        subtract
+ * SWZ            v       v        extended swizzle
+ * XPD            v,v     v        cross product
+ *
+ * Table X.5:  Summary of vertex program instructions.  "v" indicates a
+ * floating-point vector input or output, "s" indicates a floating-point
+ * scalar input, "ssss" indicates a scalar output replicated across a
+ * 4-component result vector, and "a" indicates a single address register
+ * component.
+ */
 
-       default:
-               fprintf(stderr, "%s: Should not be called with opcode %d!",
-                       __FUNCTION__, opcode);
-       }
-       _mesa_exit(-1);
-       return 0;
+static void t_opcode_abs(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
+
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] =
+           MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 3)),
+                           t_src_class(src[0].File),
+                           (!src[0].
+                            NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+           (src[0].RelAddr << 4);
+       o_inst->src[2] = 0;
 }
 
-static unsigned long op_operands(enum prog_opcode opcode)
+static void t_opcode_add(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
 {
-       int i;
+       unsigned long hw_op;
 
-       /* Can we trust mesas opcodes to be in order ? */
-       for (i = 0; i < sizeof(op_names) / sizeof(*op_names); i++)
-               if (op_names[i].opcode == opcode)
-                       return op_names[i].ip;
+#if 1
+       hw_op = (src[0].File == PROGRAM_TEMPORARY
+                && src[1].File ==
+                PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+           R300_VPI_OUT_OP_MAD;
+
+       o_inst->opcode =
+           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+       o_inst->src[0] = ONE_SRC_0;
+       o_inst->src[1] = t_src(vp, &src[0]);
+       o_inst->src[2] = t_src(vp, &src[1]);
+#else
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = t_src(vp, &src[1]);
+       o_inst->src[2] = ZERO_SRC_1;
 
-       fprintf(stderr, "op %d not found in op_names\n", opcode);
-       _mesa_exit(-1);
-       return 0;
+#endif
 }
 
-static GLboolean valid_dst(struct r300_vertex_program *vp,
-                          struct prog_dst_register *dst)
+static void t_opcode_arl(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
 {
-       if (dst->File == PROGRAM_OUTPUT && vp->outputs[dst->Index] == -1) {
-               return GL_FALSE;
-       } else if (dst->File == PROGRAM_ADDRESS) {
-               assert(dst->Index == 0);
-       }
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_ARL, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+}
 
-       return GL_TRUE;
+static void t_opcode_dp3(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO}
+
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] =
+           MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
+                           SWIZZLE_ZERO, t_src_class(src[0].File),
+                           src[0].
+                           NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
+           (src[0].RelAddr << 4);
+
+       o_inst->src[1] =
+           MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
+                           SWIZZLE_ZERO, t_src_class(src[1].File),
+                           src[1].
+                           NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
+           (src[1].RelAddr << 4);
+
+       o_inst->src[2] = ZERO_SRC_1;
 }
 
-/* TODO: Get rid of t_src_class call */
-#define CMP_SRCS(a, b) ((a.RelAddr != b.RelAddr) || (a.Index != b.Index && \
-                      ((t_src_class(a.File) == VSF_IN_CLASS_PARAM && \
-                        t_src_class(b.File) == VSF_IN_CLASS_PARAM) || \
-                       (t_src_class(a.File) == VSF_IN_CLASS_ATTR && \
-                        t_src_class(b.File) == VSF_IN_CLASS_ATTR)))) \
+static void t_opcode_dp4(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = t_src(vp, &src[1]);
+       o_inst->src[2] = ZERO_SRC_1;
+}
 
-#define ZERO_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
-                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
-                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
-                                   t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
+static void t_opcode_dph(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W}
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] =
+           MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
+                           VSF_IN_COMPONENT_ONE, t_src_class(src[0].File),
+                           src[0].
+                           NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
+           (src[0].RelAddr << 4);
+       o_inst->src[1] = t_src(vp, &src[1]);
+       o_inst->src[2] = ZERO_SRC_1;
+}
 
-#define ZERO_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
-                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
-                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
-                                   t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
+static void t_opcode_dst(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_DST, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = t_src(vp, &src[1]);
+       o_inst->src[2] = ZERO_SRC_1;
+}
 
-#define ZERO_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
-                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
-                                   SWIZZLE_ZERO, SWIZZLE_ZERO, \
-                                   t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
+static void t_opcode_ex2(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_EX2, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src_scalar(vp, &src[0]);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+}
 
-#define ONE_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
-                                   SWIZZLE_ONE, SWIZZLE_ONE, \
-                                   SWIZZLE_ONE, SWIZZLE_ONE, \
-                                   t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
+static void t_opcode_exp(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_EXP, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src_scalar(vp, &src[0]);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+}
 
-#define ONE_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
-                                   SWIZZLE_ONE, SWIZZLE_ONE, \
-                                   SWIZZLE_ONE, SWIZZLE_ONE, \
-                                   t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
+static struct r300_vertprog_instruction *t_opcode_flr(struct r300_vertex_program *vp,
+                                                     struct prog_instruction *vpi,
+                                                     struct r300_vertprog_instruction *o_inst,
+                                                     struct prog_src_register src[3],
+                                                     int *u_temp_i)
+{
+       /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W}
+          ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */
+
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, *u_temp_i,
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       VSF_OUT_CLASS_TMP);
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+       o_inst++;
+
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] =
+           MAKE_VSF_SOURCE(*u_temp_i, VSF_IN_COMPONENT_X,
+                           VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z,
+                           VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP,
+                           /* Not 100% sure about this */
+                           (!src[0].
+                            NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE
+                           /*VSF_FLAG_ALL */ );
+
+       o_inst->src[2] = ZERO_SRC_0;
+       (*u_temp_i)--;
+
+       return o_inst;
+}
 
-#define ONE_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
-                                   SWIZZLE_ONE, SWIZZLE_ONE, \
-                                   SWIZZLE_ONE, SWIZZLE_ONE, \
-                                   t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
+static void t_opcode_frc(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+}
 
-/* DP4 version seems to trigger some hw peculiarity */
-//#define PREFER_DP4
+static void t_opcode_lg2(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X}
+
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_LG2, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] =
+           MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+                           t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+                           t_src_class(src[0].File),
+                           src[0].
+                           NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+           (src[0].RelAddr << 4);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+}
 
-#define FREE_TEMPS() \
-       do { \
-               if(u_temp_i < vp->num_temporaries) { \
-                       WARN_ONCE("Ran out of temps, num temps %d, us %d\n", vp->num_temporaries, u_temp_i); \
-                       vp->native = GL_FALSE; \
-               } \
-               u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \
-       } while (0)
+static void t_opcode_lit(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W}
+
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_LIT, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+       /* NOTE: Users swizzling might not work. */
+       o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)),       // x
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+                                        VSF_IN_COMPONENT_ZERO, // z
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+                                        t_src_class(src[0].File),
+                                        src[0].
+                                        NegateBase ? VSF_FLAG_ALL :
+                                        VSF_FLAG_NONE) | (src[0].
+                                                          RelAddr << 4);
+       o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)),       // y
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+                                        VSF_IN_COMPONENT_ZERO, // z
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+                                        t_src_class(src[0].File),
+                                        src[0].
+                                        NegateBase ? VSF_FLAG_ALL :
+                                        VSF_FLAG_NONE) | (src[0].
+                                                          RelAddr << 4);
+       o_inst->src[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)),       // y
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+                                        VSF_IN_COMPONENT_ZERO, // z
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+                                        t_src_class(src[0].File),
+                                        src[0].
+                                        NegateBase ? VSF_FLAG_ALL :
+                                        VSF_FLAG_NONE) | (src[0].
+                                                          RelAddr << 4);
+}
 
-static void r300TranslateVertexShader(struct r300_vertex_program *vp,
-                                     struct prog_instruction *vpi)
+static void t_opcode_log(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_LOG, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src_scalar(vp, &src[0]);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+}
+
+static void t_opcode_mad(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
 {
-       int i, cur_reg = 0;
-       VERTEX_SHADER_INSTRUCTION *o_inst;
-       unsigned long operands;
-       int are_srcs_scalar;
        unsigned long hw_op;
-       /* 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? */
-       int u_temp_i = VSF_MAX_FRAGMENT_TEMPS - 1;
-       struct prog_src_register src[3];
 
-       vp->pos_end = 0;        /* Not supported yet */
-       vp->program.length = 0;
-       /*vp->num_temporaries=mesa_vp->Base.NumTemporaries; */
+       hw_op = (src[0].File == PROGRAM_TEMPORARY
+                && src[1].File == PROGRAM_TEMPORARY
+                && src[2].File ==
+                PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+           R300_VPI_OUT_OP_MAD;
+
+       o_inst->opcode =
+           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = t_src(vp, &src[1]);
+       o_inst->src[2] = t_src(vp, &src[2]);
+}
+
+static void t_opcode_max(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = t_src(vp, &src[1]);
+       o_inst->src[2] = ZERO_SRC_1;
+}
+
+static void t_opcode_min(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_MIN, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = t_src(vp, &src[1]);
+       o_inst->src[2] = ZERO_SRC_1;
+}
+
+static void t_opcode_mov(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
+
+#if 1
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+#else
+       hw_op =
+           (src[0].File ==
+            PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+           R300_VPI_OUT_OP_MAD;
+
+       o_inst->opcode =
+           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = ONE_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+#endif
+}
+
+static void t_opcode_mul(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       unsigned long hw_op;
+
+       // HW mul can take third arg but appears to have some other limitations.
+
+       hw_op = (src[0].File == PROGRAM_TEMPORARY
+                && src[1].File ==
+                PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+           R300_VPI_OUT_OP_MAD;
+
+       o_inst->opcode =
+           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = t_src(vp, &src[1]);
+
+       o_inst->src[2] = ZERO_SRC_1;
+}
+
+static void t_opcode_pow(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_POW, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+       o_inst->src[0] = t_src_scalar(vp, &src[0]);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = t_src_scalar(vp, &src[1]);
+}
+
+static void t_opcode_rcp(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_RCP, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src_scalar(vp, &src[0]);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+}
+
+static void t_opcode_rsq(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_RSQ, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src_scalar(vp, &src[0]);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+}
+
+static void t_opcode_sge(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_SGE, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = t_src(vp, &src[1]);
+       o_inst->src[2] = ZERO_SRC_1;
+}
+
+static void t_opcode_slt(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_SLT, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = t_src(vp, &src[1]);
+       o_inst->src[2] = ZERO_SRC_1;
+}
+
+static void t_opcode_sub(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       unsigned long hw_op;
+
+       //ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
+
+#if 1
+       hw_op = (src[0].File == PROGRAM_TEMPORARY
+                && src[1].File ==
+                PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+           R300_VPI_OUT_OP_MAD;
+
+       o_inst->opcode =
+           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = ONE_SRC_0;
+       o_inst->src[2] =
+           MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
+                           t_src_class(src[1].File),
+                           (!src[1].
+                            NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+           (src[1].RelAddr << 4);
+#else
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] =
+           MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
+                           t_src_class(src[1].File),
+                           (!src[1].
+                            NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+           (src[1].RelAddr << 4);
+       o_inst->src[2] = 0;
+#endif
+}
+
+static void t_opcode_swz(struct r300_vertex_program *vp,
+                        struct prog_instruction *vpi,
+                        struct r300_vertprog_instruction *o_inst,
+                        struct prog_src_register src[3])
+{
+       //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
+
+#if 1
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = ZERO_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+#else
+       hw_op =
+           (src[0].File ==
+            PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+           R300_VPI_OUT_OP_MAD;
+
+       o_inst->opcode =
+           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+       o_inst->src[0] = t_src(vp, &src[0]);
+       o_inst->src[1] = ONE_SRC_0;
+       o_inst->src[2] = ZERO_SRC_0;
+#endif
+}
+
+static struct r300_vertprog_instruction *t_opcode_xpd(struct r300_vertex_program *vp,
+                                                     struct prog_instruction *vpi,
+                                                     struct r300_vertprog_instruction *o_inst,
+                                                     struct prog_src_register src[3],
+                                                     int *u_temp_i)
+{
+       /* mul r0, r1.yzxw, r2.zxyw
+          mad r0, -r2.yzxw, r1.zxyw, r0
+          NOTE: might need MAD_2
+        */
+
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, *u_temp_i,
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       VSF_OUT_CLASS_TMP);
+
+       o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)),       // y
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+                                        t_src_class(src[0].File),
+                                        src[0].
+                                        NegateBase ? VSF_FLAG_ALL :
+                                        VSF_FLAG_NONE) | (src[0].
+                                                          RelAddr << 4);
+
+       o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)),       // z
+                                        t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
+                                        t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
+                                        t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
+                                        t_src_class(src[1].File),
+                                        src[1].
+                                        NegateBase ? VSF_FLAG_ALL :
+                                        VSF_FLAG_NONE) | (src[1].
+                                                          RelAddr << 4);
+
+       o_inst->src[2] = ZERO_SRC_1;
+       o_inst++;
+       (*u_temp_i)--;
+
+       o_inst->opcode =
+           MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, t_dst_index(vp, &vpi->DstReg),
+                       t_dst_mask(vpi->DstReg.WriteMask),
+                       t_dst_class(vpi->DstReg.File));
+
+       o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)),       // y
+                                        t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
+                                        t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
+                                        t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
+                                        t_src_class(src[1].File),
+                                        (!src[1].
+                                         NegateBase) ? VSF_FLAG_ALL :
+                                        VSF_FLAG_NONE) | (src[1].
+                                                          RelAddr << 4);
+
+       o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)),       // z
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+                                        t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+                                        t_src_class(src[0].File),
+                                        src[0].
+                                        NegateBase ? VSF_FLAG_ALL :
+                                        VSF_FLAG_NONE) | (src[0].
+                                                          RelAddr << 4);
+
+       o_inst->src[2] =
+           MAKE_VSF_SOURCE(*u_temp_i + 1, VSF_IN_COMPONENT_X,
+                           VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z,
+                           VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP,
+                           VSF_FLAG_NONE);
+
+       return o_inst;
+}
+
+static void t_inputs_outputs(struct r300_vertex_program *vp)
+{
+       int i;
+       int cur_reg = 0;
 
        for (i = 0; i < VERT_ATTRIB_MAX; i++)
                vp->inputs[i] = -1;
@@ -437,39 +1046,71 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
 
        assert(vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS));
 
-       /* Assign outputs */
-       if (vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS))
+       if (vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS)) {
                vp->outputs[VERT_RESULT_HPOS] = cur_reg++;
+       }
 
-       if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ))
+       if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ)) {
                vp->outputs[VERT_RESULT_PSIZ] = cur_reg++;
+       }
 
-       if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL0))
+       if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL0)) {
                vp->outputs[VERT_RESULT_COL0] = cur_reg++;
+       }
 
-       if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1))
-               vp->outputs[VERT_RESULT_COL1] = cur_reg++;
-
-#if 0                          /* Not supported yet */
-       if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0))
-               vp->outputs[VERT_RESULT_BFC0] = cur_reg++;
+       if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1)) {
+               vp->outputs[VERT_RESULT_COL1] =
+                   vp->outputs[VERT_RESULT_COL0] + 1;
+               cur_reg = vp->outputs[VERT_RESULT_COL1] + 1;
+       }
 
-       if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1))
-               vp->outputs[VERT_RESULT_BFC1] = cur_reg++;
+       if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) {
+               vp->outputs[VERT_RESULT_BFC0] =
+                   vp->outputs[VERT_RESULT_COL0] + 2;
+               cur_reg = vp->outputs[VERT_RESULT_BFC0] + 1;
+       }
 
-       if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC))
+       if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) {
+               vp->outputs[VERT_RESULT_BFC1] =
+                   vp->outputs[VERT_RESULT_COL0] + 3;
+               cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1;
+       }
+#if 0
+       if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) {
                vp->outputs[VERT_RESULT_FOGC] = cur_reg++;
+       }
 #endif
 
-       for (i = VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++)
-               if (vp->key.OutputsWritten & (1 << i))
+       for (i = VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++) {
+               if (vp->key.OutputsWritten & (1 << i)) {
                        vp->outputs[i] = cur_reg++;
+               }
+       }
+}
+
+static void r300TranslateVertexShader(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi)
+{
+       int i;
+       struct r300_vertprog_instruction *o_inst;
+       unsigned long num_operands;
+       /* 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? */
+       int u_temp_i = VSF_MAX_FRAGMENT_TEMPS - 1;
+       struct prog_src_register src[3];
 
+       vp->pos_end = 0;        /* Not supported yet */
+       vp->program.length = 0;
+       /*vp->num_temporaries=mesa_vp->Base.NumTemporaries; */
        vp->translated = GL_TRUE;
        vp->native = GL_TRUE;
 
-       o_inst = vp->program.body.i;
-       for (; vpi->Opcode != OPCODE_END; vpi++, o_inst++) {
+       t_inputs_outputs(vp);
+
+       for (o_inst = vp->program.body.i; vpi->Opcode != OPCODE_END;
+            vpi++, o_inst++) {
+
                FREE_TEMPS();
 
                if (!valid_dst(vp, &vpi->DstReg)) {
@@ -478,29 +1119,30 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
                        vpi->DstReg.Index = u_temp_i;
                }
 
-               operands = op_operands(vpi->Opcode);
-               are_srcs_scalar = operands & SCALAR_FLAG;
-               operands &= OP_MASK;
+               num_operands = _mesa_num_inst_src_regs(vpi->Opcode);
 
-               for (i = 0; i < operands; i++)
+               /* copy the sources (src) from mesa into a local variable... is this needed? */
+               for (i = 0; i < num_operands; i++) {
                        src[i] = vpi->SrcReg[i];
+               }
 
-               if (operands == 3) {    /* TODO: scalars */
+               if (num_operands == 3) {        /* TODO: scalars */
                        if (CMP_SRCS(src[1], src[2])
                            || CMP_SRCS(src[0], src[2])) {
-                               o_inst->op =
-                                   MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i,
-                                               VSF_FLAG_ALL,
+                               o_inst->opcode =
+                                   MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
+                                               u_temp_i, VSF_FLAG_ALL,
                                                VSF_OUT_CLASS_TMP);
 
                                o_inst->src[0] =
-                                   MAKE_VSF_SOURCE(t_src_index(vp, &src[2]),
+                                   MAKE_VSF_SOURCE(t_src_index
+                                                   (vp, &src[2]),
                                                    SWIZZLE_X, SWIZZLE_Y,
                                                    SWIZZLE_Z, SWIZZLE_W,
-                                                   t_src_class(src[2].File),
-                                                   VSF_FLAG_NONE) | (src[2].
-                                                                     RelAddr <<
-                                                                     4);
+                                                   t_src_class(src[2].
+                                                               File),
+                                                   VSF_FLAG_NONE) |
+                                   (src[2].RelAddr << 4);
 
                                o_inst->src[1] = ZERO_SRC_2;
                                o_inst->src[2] = ZERO_SRC_2;
@@ -511,24 +1153,24 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
                                src[2].RelAddr = 0;
                                u_temp_i--;
                        }
-
                }
 
-               if (operands >= 2) {
+               if (num_operands >= 2) {
                        if (CMP_SRCS(src[1], src[0])) {
-                               o_inst->op =
-                                   MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i,
-                                               VSF_FLAG_ALL,
+                               o_inst->opcode =
+                                   MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
+                                               u_temp_i, VSF_FLAG_ALL,
                                                VSF_OUT_CLASS_TMP);
 
                                o_inst->src[0] =
-                                   MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+                                   MAKE_VSF_SOURCE(t_src_index
+                                                   (vp, &src[0]),
                                                    SWIZZLE_X, SWIZZLE_Y,
                                                    SWIZZLE_Z, SWIZZLE_W,
-                                                   t_src_class(src[0].File),
-                                                   VSF_FLAG_NONE) | (src[0].
-                                                                     RelAddr <<
-                                                                     4);
+                                                   t_src_class(src[0].
+                                                               File),
+                                                   VSF_FLAG_NONE) |
+                                   (src[0].RelAddr << 4);
 
                                o_inst->src[1] = ZERO_SRC_0;
                                o_inst->src[2] = ZERO_SRC_0;
@@ -541,517 +1183,101 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
                        }
                }
 
-               /* These ops need special handling. */
                switch (vpi->Opcode) {
-               case OPCODE_POW:
-                       o_inst->op =
-                           MAKE_VSF_OP(R300_VPI_OUT_OP_POW,
-                                       t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-                       o_inst->src[0] = t_src_scalar(vp, &src[0]);
-                       o_inst->src[1] = ZERO_SRC_0;
-                       o_inst->src[2] = t_src_scalar(vp, &src[1]);
-                       goto next;
-
-               case OPCODE_MOV:        //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
-               case OPCODE_SWZ:
-#if 1
-                       o_inst->op =
-                           MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-                                       t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-                       o_inst->src[0] = t_src(vp, &src[0]);
-                       o_inst->src[1] = ZERO_SRC_0;
-                       o_inst->src[2] = ZERO_SRC_0;
-#else
-                       hw_op =
-                           (src[0].File ==
-                            PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-                           R300_VPI_OUT_OP_MAD;
-
-                       o_inst->op =
-                           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-                       o_inst->src[0] = t_src(vp, &src[0]);
-                       o_inst->src[1] = ONE_SRC_0;
-                       o_inst->src[2] = ZERO_SRC_0;
-#endif
-
-                       goto next;
-
+               case OPCODE_ABS:
+                       t_opcode_abs(vp, vpi, o_inst, src);
+                       break;
                case OPCODE_ADD:
-#if 1
-                       hw_op = (src[0].File == PROGRAM_TEMPORARY &&
-                                src[1].File ==
-                                PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-                           R300_VPI_OUT_OP_MAD;
-
-                       o_inst->op =
-                           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-                       o_inst->src[0] = ONE_SRC_0;
-                       o_inst->src[1] = t_src(vp, &src[0]);
-                       o_inst->src[2] = t_src(vp, &src[1]);
-#else
-                       o_inst->op =
-                           MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-                                       t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-                       o_inst->src[0] = t_src(vp, &src[0]);
-                       o_inst->src[1] = t_src(vp, &src[1]);
-                       o_inst->src[2] = ZERO_SRC_1;
-
-#endif
-                       goto next;
-
-               case OPCODE_MAD:
-                       hw_op = (src[0].File == PROGRAM_TEMPORARY &&
-                                src[1].File == PROGRAM_TEMPORARY &&
-                                src[2].File ==
-                                PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-                           R300_VPI_OUT_OP_MAD;
-
-                       o_inst->op =
-                           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-                       o_inst->src[0] = t_src(vp, &src[0]);
-                       o_inst->src[1] = t_src(vp, &src[1]);
-                       o_inst->src[2] = t_src(vp, &src[2]);
-                       goto next;
-
-               case OPCODE_MUL:        /* HW mul can take third arg but appears to have some other limitations. */
-                       hw_op = (src[0].File == PROGRAM_TEMPORARY &&
-                                src[1].File ==
-                                PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-                           R300_VPI_OUT_OP_MAD;
-
-                       o_inst->op =
-                           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-                       o_inst->src[0] = t_src(vp, &src[0]);
-                       o_inst->src[1] = t_src(vp, &src[1]);
-
-                       o_inst->src[2] = ZERO_SRC_1;
-                       goto next;
-
-               case OPCODE_DP3:        //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO}
-                       o_inst->op =
-                           MAKE_VSF_OP(R300_VPI_OUT_OP_DOT,
-                                       t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-
-                       o_inst->src[0] =
-                           MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 0)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 1)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 2)),
-                                           SWIZZLE_ZERO,
-                                           t_src_class(src[0].File),
-                                           src[0].
-                                           NegateBase ? VSF_FLAG_XYZ :
-                                           VSF_FLAG_NONE) | (src[0].
-                                                             RelAddr << 4);
-
-                       o_inst->src[1] =
-                           MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
-                                           t_swizzle(GET_SWZ
-                                                     (src[1].Swizzle, 0)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[1].Swizzle, 1)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[1].Swizzle, 2)),
-                                           SWIZZLE_ZERO,
-                                           t_src_class(src[1].File),
-                                           src[1].
-                                           NegateBase ? VSF_FLAG_XYZ :
-                                           VSF_FLAG_NONE) | (src[1].
-                                                             RelAddr << 4);
-
-                       o_inst->src[2] = ZERO_SRC_1;
-                       goto next;
-
-               case OPCODE_SUB:        //ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
-#if 1
-                       hw_op = (src[0].File == PROGRAM_TEMPORARY &&
-                                src[1].File ==
-                                PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-                           R300_VPI_OUT_OP_MAD;
-
-                       o_inst->op =
-                           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-                       o_inst->src[0] = t_src(vp, &src[0]);
-                       o_inst->src[1] = ONE_SRC_0;
-                       o_inst->src[2] =
-                           MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
-                                           t_swizzle(GET_SWZ
-                                                     (src[1].Swizzle, 0)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[1].Swizzle, 1)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[1].Swizzle, 2)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[1].Swizzle, 3)),
-                                           t_src_class(src[1].File),
-                                           (!src[1].
-                                            NegateBase) ? VSF_FLAG_ALL :
-                                           VSF_FLAG_NONE) | (src[1].
-                                                             RelAddr << 4);
-#else
-                       o_inst->op =
-                           MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-                                       t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-
-                       o_inst->src[0] = t_src(vp, &src[0]);
-                       o_inst->src[1] =
-                           MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
-                                           t_swizzle(GET_SWZ
-                                                     (src[1].Swizzle, 0)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[1].Swizzle, 1)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[1].Swizzle, 2)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[1].Swizzle, 3)),
-                                           t_src_class(src[1].File),
-                                           (!src[1].
-                                            NegateBase) ? VSF_FLAG_ALL :
-                                           VSF_FLAG_NONE) | (src[1].
-                                                             RelAddr << 4);
-                       o_inst->src[2] = 0;
-#endif
-                       goto next;
-
-               case OPCODE_ABS:        //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
-                       o_inst->op =
-                           MAKE_VSF_OP(R300_VPI_OUT_OP_MAX,
-                                       t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-
-                       o_inst->src[0] = t_src(vp, &src[0]);
-                       o_inst->src[1] =
-                           MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 0)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 1)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 2)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 3)),
-                                           t_src_class(src[0].File),
-                                           (!src[0].
-                                            NegateBase) ? VSF_FLAG_ALL :
-                                           VSF_FLAG_NONE) | (src[0].
-                                                             RelAddr << 4);
-                       o_inst->src[2] = 0;
-                       goto next;
-
+                       t_opcode_add(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_ARL:
+                       t_opcode_arl(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_DP3:
+                       t_opcode_dp3(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_DP4:
+                       t_opcode_dp4(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_DPH:
+                       t_opcode_dph(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_DST:
+                       t_opcode_dst(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_EX2:
+                       t_opcode_ex2(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_EXP:
+                       t_opcode_exp(vp, vpi, o_inst, src);
+                       break;
                case OPCODE_FLR:
-                       /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W}
-                          ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */
-
-                       o_inst->op = MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, u_temp_i,
-                                                t_dst_mask(vpi->DstReg.
-                                                           WriteMask),
-                                                VSF_OUT_CLASS_TMP);
-
-                       o_inst->src[0] = t_src(vp, &src[0]);
-                       o_inst->src[1] = ZERO_SRC_0;
-                       o_inst->src[2] = ZERO_SRC_0;
-                       o_inst++;
-
-                       o_inst->op =
-                           MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-                                       t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-
-                       o_inst->src[0] = t_src(vp, &src[0]);
-                       o_inst->src[1] = MAKE_VSF_SOURCE(u_temp_i,
-                                                        VSF_IN_COMPONENT_X,
-                                                        VSF_IN_COMPONENT_Y,
-                                                        VSF_IN_COMPONENT_Z,
-                                                        VSF_IN_COMPONENT_W,
-                                                        VSF_IN_CLASS_TMP,
-                                                        /* Not 100% sure about this */
-                                                        (!src[0].
-                                                         NegateBase) ?
-                                                        VSF_FLAG_ALL :
-                                                        VSF_FLAG_NONE
-                                                        /*VSF_FLAG_ALL */ );
-
-                       o_inst->src[2] = ZERO_SRC_0;
-                       u_temp_i--;
-                       goto next;
-
-               case OPCODE_LG2:        // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X}
-                       o_inst->op =
-                           MAKE_VSF_OP(R300_VPI_OUT_OP_LG2,
-                                       t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-
-                       o_inst->src[0] =
-                           MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 0)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 0)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 0)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 0)),
-                                           t_src_class(src[0].File),
-                                           src[0].
-                                           NegateBase ? VSF_FLAG_ALL :
-                                           VSF_FLAG_NONE) | (src[0].
-                                                             RelAddr << 4);
-                       o_inst->src[1] = ZERO_SRC_0;
-                       o_inst->src[2] = ZERO_SRC_0;
-                       goto next;
-
-               case OPCODE_LIT:        //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W}
-                       o_inst->op =
-                           MAKE_VSF_OP(R300_VPI_OUT_OP_LIT,
-                                       t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-                       /* NOTE: Users swizzling might not work. */
-                       o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)),       // x
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-                                                        VSF_IN_COMPONENT_ZERO, // z
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-                                                        t_src_class(src[0].
-                                                                    File),
-                                                        src[0].
-                                                        NegateBase ?
-                                                        VSF_FLAG_ALL :
-                                                        VSF_FLAG_NONE) |
-                           (src[0].RelAddr << 4);
-                       o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)),       // y
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-                                                        VSF_IN_COMPONENT_ZERO, // z
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-                                                        t_src_class(src[0].
-                                                                    File),
-                                                        src[0].
-                                                        NegateBase ?
-                                                        VSF_FLAG_ALL :
-                                                        VSF_FLAG_NONE) |
-                           (src[0].RelAddr << 4);
-                       o_inst->src[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)),       // y
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-                                                        VSF_IN_COMPONENT_ZERO, // z
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-                                                        t_src_class(src[0].
-                                                                    File),
-                                                        src[0].
-                                                        NegateBase ?
-                                                        VSF_FLAG_ALL :
-                                                        VSF_FLAG_NONE) |
-                           (src[0].RelAddr << 4);
-                       goto next;
-
-               case OPCODE_DPH:        //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W}
-                       o_inst->op =
-                           MAKE_VSF_OP(R300_VPI_OUT_OP_DOT,
-                                       t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-
-                       o_inst->src[0] =
-                           MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 0)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 1)),
-                                           t_swizzle(GET_SWZ
-                                                     (src[0].Swizzle, 2)),
-                                           VSF_IN_COMPONENT_ONE,
-                                           t_src_class(src[0].File),
-                                           src[0].
-                                           NegateBase ? VSF_FLAG_XYZ :
-                                           VSF_FLAG_NONE) | (src[0].
-                                                             RelAddr << 4);
-                       o_inst->src[1] = t_src(vp, &src[1]);
-                       o_inst->src[2] = ZERO_SRC_1;
-                       goto next;
-
-               case OPCODE_XPD:
-                       /* mul r0, r1.yzxw, r2.zxyw
-                          mad r0, -r2.yzxw, r1.zxyw, r0
-                          NOTE: might need MAD_2
-                        */
-
-                       o_inst->op = MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, u_temp_i,
-                                                t_dst_mask(vpi->DstReg.
-                                                           WriteMask),
-                                                VSF_OUT_CLASS_TMP);
-
-                       o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)),       // y
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-                                                        t_src_class(src[0].
-                                                                    File),
-                                                        src[0].
-                                                        NegateBase ?
-                                                        VSF_FLAG_ALL :
-                                                        VSF_FLAG_NONE) |
-                           (src[0].RelAddr << 4);
-
-                       o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)),       // z
-                                                        t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
-                                                        t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
-                                                        t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
-                                                        t_src_class(src[1].
-                                                                    File),
-                                                        src[1].
-                                                        NegateBase ?
-                                                        VSF_FLAG_ALL :
-                                                        VSF_FLAG_NONE) |
-                           (src[1].RelAddr << 4);
-
-                       o_inst->src[2] = ZERO_SRC_1;
-                       o_inst++;
-                       u_temp_i--;
-
-                       o_inst->op =
-                           MAKE_VSF_OP(R300_VPI_OUT_OP_MAD,
-                                       t_dst_index(vp, &vpi->DstReg),
-                                       t_dst_mask(vpi->DstReg.WriteMask),
-                                       t_dst_class(vpi->DstReg.File));
-
-                       o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)),       // y
-                                                        t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
-                                                        t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
-                                                        t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
-                                                        t_src_class(src[1].
-                                                                    File),
-                                                        (!src[1].
-                                                         NegateBase) ?
-                                                        VSF_FLAG_ALL :
-                                                        VSF_FLAG_NONE) |
-                           (src[1].RelAddr << 4);
-
-                       o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)),       // z
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
-                                                        t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
-                                                        t_src_class(src[0].
-                                                                    File),
-                                                        src[0].
-                                                        NegateBase ?
-                                                        VSF_FLAG_ALL :
-                                                        VSF_FLAG_NONE) |
-                           (src[0].RelAddr << 4);
-
-                       o_inst->src[2] = MAKE_VSF_SOURCE(u_temp_i + 1,
-                                                        VSF_IN_COMPONENT_X,
-                                                        VSF_IN_COMPONENT_Y,
-                                                        VSF_IN_COMPONENT_Z,
-                                                        VSF_IN_COMPONENT_W,
-                                                        VSF_IN_CLASS_TMP,
-                                                        VSF_FLAG_NONE);
-
-                       goto next;
-
-               case OPCODE_RCC:
-                       fprintf(stderr, "Dont know how to handle op %d yet\n",
-                               vpi->Opcode);
-                       _mesa_exit(-1);
+                       /* FIXME */
+                       o_inst = t_opcode_flr(vp, vpi, o_inst, src, &u_temp_i);
+                       break;
+               case OPCODE_FRC:
+                       t_opcode_frc(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_LG2:
+                       t_opcode_lg2(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_LIT:
+                       t_opcode_lit(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_LOG:
+                       t_opcode_log(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_MAD:
+                       t_opcode_mad(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_MAX:
+                       t_opcode_max(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_MIN:
+                       t_opcode_min(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_MOV:
+                       t_opcode_mov(vp, vpi, o_inst, src);
                        break;
-               case OPCODE_END:
+               case OPCODE_MUL:
+                       t_opcode_mul(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_POW:
+                       t_opcode_pow(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_RCP:
+                       t_opcode_rcp(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_RSQ:
+                       t_opcode_rsq(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_SGE:
+                       t_opcode_sge(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_SLT:
+                       t_opcode_slt(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_SUB:
+                       t_opcode_sub(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_SWZ:
+                       t_opcode_swz(vp, vpi, o_inst, src);
+                       break;
+               case OPCODE_XPD:
+                       /* FIXME */
+                       o_inst = t_opcode_xpd(vp, vpi, o_inst, src, &u_temp_i);
                        break;
                default:
+                       assert(0);
                        break;
                }
-
-               o_inst->op =
-                   MAKE_VSF_OP(t_opcode(vpi->Opcode),
-                               t_dst_index(vp, &vpi->DstReg),
-                               t_dst_mask(vpi->DstReg.WriteMask),
-                               t_dst_class(vpi->DstReg.File));
-
-               if (are_srcs_scalar) {
-                       switch (operands) {
-                       case 1:
-                               o_inst->src[0] = t_src_scalar(vp, &src[0]);
-                               o_inst->src[1] = ZERO_SRC_0;
-                               o_inst->src[2] = ZERO_SRC_0;
-                               break;
-
-                       case 2:
-                               o_inst->src[0] = t_src_scalar(vp, &src[0]);
-                               o_inst->src[1] = t_src_scalar(vp, &src[1]);
-                               o_inst->src[2] = ZERO_SRC_1;
-                               break;
-
-                       case 3:
-                               o_inst->src[0] = t_src_scalar(vp, &src[0]);
-                               o_inst->src[1] = t_src_scalar(vp, &src[1]);
-                               o_inst->src[2] = t_src_scalar(vp, &src[2]);
-                               break;
-
-                       default:
-                               fprintf(stderr,
-                                       "scalars and op RCC not handled yet");
-                               _mesa_exit(-1);
-                               break;
-                       }
-               } else {
-                       switch (operands) {
-                       case 1:
-                               o_inst->src[0] = t_src(vp, &src[0]);
-                               o_inst->src[1] = ZERO_SRC_0;
-                               o_inst->src[2] = ZERO_SRC_0;
-                               break;
-
-                       case 2:
-                               o_inst->src[0] = t_src(vp, &src[0]);
-                               o_inst->src[1] = t_src(vp, &src[1]);
-                               o_inst->src[2] = ZERO_SRC_1;
-                               break;
-
-                       case 3:
-                               o_inst->src[0] = t_src(vp, &src[0]);
-                               o_inst->src[1] = t_src(vp, &src[1]);
-                               o_inst->src[2] = t_src(vp, &src[2]);
-                               break;
-
-                       default:
-                               fprintf(stderr,
-                                       "scalars and op RCC not handled yet");
-                               _mesa_exit(-1);
-                               break;
-                       }
-               }
-             next:;
        }
 
-       /* Will most likely segfault before we get here... fix later. */
-       if (o_inst - vp->program.body.i >= VSF_MAX_FRAGMENT_LENGTH / 4) {
+       vp->program.length = (o_inst - vp->program.body.i) * 4;
+       if (vp->program.length >= VSF_MAX_FRAGMENT_LENGTH) {
                vp->program.length = 0;
                vp->native = GL_FALSE;
-               return;
        }
-       vp->program.length = (o_inst - vp->program.body.i) * 4;
 #if 0
        fprintf(stderr, "hw program:\n");
        for (i = 0; i < vp->program.length; i++)
@@ -1065,7 +1291,8 @@ static void position_invariant(struct gl_program *prog)
        struct gl_program_parameter_list *paramList;
        int i;
 
-       gl_state_index tokens[STATE_LENGTH] = { STATE_MVP_MATRIX, 0, 0, 0, 0 };
+       gl_state_index tokens[STATE_LENGTH] =
+           { STATE_MVP_MATRIX, 0, 0, 0, 0 };
 
        /* tokens[4] = matrix modifier */
 #ifdef PREFER_DP4
@@ -1159,8 +1386,8 @@ static void insert_wpos(struct r300_vertex_program *vp,
                                prog->NumInstructions - 1);
        /* END */
        _mesa_copy_instructions(&vpi[prog->NumInstructions + 1],
-                               &prog->Instructions[prog->NumInstructions - 1],
-                               1);
+                               &prog->Instructions[prog->NumInstructions -
+                                                   1], 1);
        vpi_insert = &vpi[prog->NumInstructions - 1];
 
        vpi_insert[i].Opcode = OPCODE_MOV;
@@ -1206,8 +1433,8 @@ static void pos_as_texcoord(struct r300_vertex_program *vp,
        prog->NumTemporaries++;
 
        for (vpi = prog->Instructions; vpi->Opcode != OPCODE_END; vpi++) {
-               if (vpi->DstReg.File == PROGRAM_OUTPUT &&
-                   vpi->DstReg.Index == VERT_RESULT_HPOS) {
+               if (vpi->DstReg.File == PROGRAM_OUTPUT
+                   && vpi->DstReg.Index == VERT_RESULT_HPOS) {
                        vpi->DstReg.File = PROGRAM_TEMPORARY;
                        vpi->DstReg.Index = tempregi;
                }
@@ -1223,20 +1450,18 @@ static struct r300_vertex_program *build_program(struct r300_vertex_program_key
 
        vp = _mesa_calloc(sizeof(*vp));
        _mesa_memcpy(&vp->key, wanted_key, sizeof(vp->key));
-
        vp->wpos_idx = wpos_idx;
 
        if (mesa_vp->IsPositionInvariant) {
                position_invariant(&mesa_vp->Base);
        }
 
-       if (wpos_idx > -1)
+       if (wpos_idx > -1) {
                pos_as_texcoord(vp, &mesa_vp->Base);
+       }
 
        assert(mesa_vp->Base.NumInstructions);
-
        vp->num_temporaries = mesa_vp->Base.NumTemporaries;
-
        r300TranslateVertexShader(vp, mesa_vp->Base.Instructions);
 
        return vp;
@@ -1252,11 +1477,10 @@ void r300SelectVertexShader(r300ContextPtr r300)
        struct r300_vertex_program *vp;
        GLint wpos_idx;
 
-       vpc = (struct r300_vertex_program_cont *)ctx->VertexProgram._Current;
+       vpc =
+           (struct r300_vertex_program_cont *)ctx->VertexProgram._Current;
        InputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
 
-       wanted_key.OutputsWritten |= 1 << VERT_RESULT_HPOS;
-
        wpos_idx = -1;
        if (InputsRead & FRAG_BIT_WPOS) {
                for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
@@ -1271,28 +1495,35 @@ void r300SelectVertexShader(r300ContextPtr r300)
                InputsRead |= (FRAG_BIT_TEX0 << i);
                wpos_idx = i;
        }
+       wanted_key.InputsRead = vpc->mesa_program.Base.InputsRead;
+       wanted_key.OutputsWritten = vpc->mesa_program.Base.OutputsWritten;
+
+       wanted_key.OutputsWritten |= 1 << VERT_RESULT_HPOS;
 
-       if (InputsRead & FRAG_BIT_COL0)
+       if (InputsRead & FRAG_BIT_COL0) {
                wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL0;
+       }
 
-       if ((InputsRead & FRAG_BIT_COL1)        /*||
-                                                  (InputsRead & FRAG_BIT_FOGC) */ )
+       if ((InputsRead & FRAG_BIT_COL1)) {
                wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL1;
+       }
 
-       for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
-               if (InputsRead & (FRAG_BIT_TEX0 << i))
+       for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+               if (InputsRead & (FRAG_BIT_TEX0 << i)) {
                        wanted_key.OutputsWritten |=
                            1 << (VERT_RESULT_TEX0 + i);
+               }
+       }
 
-       wanted_key.InputsRead = vpc->mesa_program.Base.InputsRead;
        if (vpc->mesa_program.IsPositionInvariant) {
                /* we wan't position don't we ? */
                wanted_key.InputsRead |= (1 << VERT_ATTRIB_POS);
+               wanted_key.OutputsWritten |= (1 << VERT_RESULT_HPOS);
        }
 
        for (vp = vpc->progs; vp; vp = vp->next)
-               if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key)) ==
-                   0) {
+               if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key))
+                   == 0) {
                        r300->selected_vp = vp;
                        return;
                }
index 252d5a901f41b7c630282faf468ded5b2bb8e14f..2d399e243a89bebb5f71af36393494c8d68cc9b6 100644 (file)
@@ -3,10 +3,10 @@
 
 #include "r300_reg.h"
 
-typedef struct {
-       GLuint op;
+struct r300_vertprog_instruction {
+       GLuint opcode;
        GLuint src[3];
-} VERTEX_SHADER_INSTRUCTION;
+};
 
 #define VSF_FLAG_X     1
 #define VSF_FLAG_Y     2
index 6c6511b7e53ab189311ce87ea2db6df6a7d36c6a..e95a424698c4d41928d162d158864a93adb6a8a4 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -63,6 +63,9 @@
 #include "drivers/common/driverfuncs.h"
 
 
+/**
+ * Pixel formats we support:
+ */
 #define PF_B8G8R8     1
 #define PF_B8G8R8A8   2
 #define PF_B5G6R5     3
@@ -70,7 +73,7 @@
 #define PF_CI8        5
 
 
-/*
+/**
  * Derived from Mesa's GLvisual class.
  */
 struct GLFBDevVisualRec {
@@ -80,7 +83,7 @@ struct GLFBDevVisualRec {
    int pixelFormat;
 };
 
-/*
+/**
  * Derived from Mesa's GLframebuffer class.
  */
 struct GLFBDevBufferRec {
@@ -92,7 +95,7 @@ struct GLFBDevBufferRec {
    GLuint bytesPerPixel;
 };
 
-/*
+/**
  * Derived from Mesa's GLcontext class.
  */
 struct GLFBDevContextRec {
@@ -103,7 +106,7 @@ struct GLFBDevContextRec {
    GLFBDevBufferPtr curBuffer;
 };
 
-/*
+/**
  * Derived from Mesa's gl_renderbuffer class.
  */
 struct GLFBDevRenderbufferRec {
@@ -114,11 +117,6 @@ struct GLFBDevRenderbufferRec {
 };
 
 
-
-#define GLFBDEV_CONTEXT(CTX)  ((GLFBDevContextPtr) (CTX))
-#define GLFBDEV_BUFFER(BUF)  ((GLFBDevBufferPtr) (BUF))
-
-
 /**********************************************************************/
 /* Internal device driver functions                                   */
 /**********************************************************************/
@@ -151,7 +149,7 @@ update_state( GLcontext *ctx, GLuint new_state )
 static void
 get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
 {
-   const GLFBDevBufferPtr fbdevbuffer = GLFBDEV_BUFFER(buffer);
+   const GLFBDevBufferPtr fbdevbuffer = (GLFBDevBufferPtr) buffer;
    *width = fbdevbuffer->var.xres;
    *height = fbdevbuffer->var.yres;
 }
@@ -389,8 +387,8 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo,
          /* ignored for now */
          break;
       case GLFBDEV_MULTISAMPLE:
-        numSamples = attrib[1];
-        attrib++;
+         numSamples = attrib[1];
+         attrib++;
          break;
       default:
          /* unexpected token */
@@ -406,36 +404,36 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo,
       alphaBits = varInfo->transp.length;
 
       if (fixInfo->visual == FB_VISUAL_TRUECOLOR ||
-         fixInfo->visual == FB_VISUAL_DIRECTCOLOR) {
-        if(varInfo->bits_per_pixel == 24
-           && varInfo->red.offset == 16
-           && varInfo->green.offset == 8
-           && varInfo->blue.offset == 0)
-           vis->pixelFormat = PF_B8G8R8;
-
-        else if(varInfo->bits_per_pixel == 32
-                && varInfo->red.offset == 16
-                && varInfo->green.offset == 8
-                && varInfo->blue.offset == 0)
-           vis->pixelFormat = PF_B8G8R8A8;
-
-        else if(varInfo->bits_per_pixel == 16
-                && varInfo->red.offset == 11
-                && varInfo->green.offset == 5
-                && varInfo->blue.offset == 0)
-           vis->pixelFormat = PF_B5G6R5;
-
-        else if(varInfo->bits_per_pixel == 16
-                && varInfo->red.offset == 10
-                && varInfo->green.offset == 5
-                && varInfo->blue.offset == 0)
-           vis->pixelFormat = PF_B5G5R5;
-
-        else {
-           _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n");
-           _mesa_free(vis);
-           return NULL;
-        }
+          fixInfo->visual == FB_VISUAL_DIRECTCOLOR) {
+         if (varInfo->bits_per_pixel == 24
+             && varInfo->red.offset == 16
+             && varInfo->green.offset == 8
+             && varInfo->blue.offset == 0) {
+            vis->pixelFormat = PF_B8G8R8;
+         }
+         else if (varInfo->bits_per_pixel == 32
+                  && varInfo->red.offset == 16
+                  && varInfo->green.offset == 8
+                  && varInfo->blue.offset == 0) {
+            vis->pixelFormat = PF_B8G8R8A8;
+         }
+         else if (varInfo->bits_per_pixel == 16
+                  && varInfo->red.offset == 11
+                  && varInfo->green.offset == 5
+                  && varInfo->blue.offset == 0) {
+            vis->pixelFormat = PF_B5G6R5;
+         }
+         else if (varInfo->bits_per_pixel == 16
+                  && varInfo->red.offset == 10
+                  && varInfo->green.offset == 5
+                  && varInfo->blue.offset == 0) {
+            vis->pixelFormat = PF_B5G5R5;
+         }
+         else {
+            _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n");
+            _mesa_free(vis);
+            return NULL;
+         }
       }
    }
    else {
@@ -578,7 +576,7 @@ new_glfbdev_renderbuffer(void *bufferStart, const GLFBDevVisualPtr visual)
 
       rb->rowStride = visual->var.xres_virtual * visual->var.bits_per_pixel / 8;
       rb->bottom = (GLubyte *) bufferStart
-         + (visual->var.yres - 1) * rb->rowStride;
+                 + (visual->var.yres - 1) * rb->rowStride;
 
       rb->Base.Width = visual->var.xres;
       rb->Base.Height = visual->var.yres;
@@ -635,7 +633,7 @@ glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo,
                           &frontrb->Base);
    /* add back renderbuffer */
    if (visual->glvisual.doubleBufferMode) {
-      int malloced = !backBuffer;
+      const int malloced = !backBuffer;
       if (malloced) {
          /* malloc a back buffer */
          backBuffer = _mesa_malloc(size);
@@ -647,8 +645,11 @@ glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo,
       }
 
       backrb = new_glfbdev_renderbuffer(backBuffer, visual);
-      if(malloced)
-        backrb->mallocedBuffer = GL_TRUE;
+      if (!backrb) {
+         /* out of mem */
+         return NULL;
+      }
+      backrb->mallocedBuffer = malloced;
 
       _mesa_add_renderbuffer(&buf->glframebuffer, BUFFER_BACK_LEFT,
                              &backrb->Base);
@@ -682,16 +683,10 @@ glFBDevDestroyBuffer( GLFBDevBufferPtr buffer )
       if (buffer == curDraw || buffer == curRead) {
          glFBDevMakeCurrent( NULL, NULL, NULL);
       }
-#if 0
-      /* free the software depth, stencil, accum buffers */
-      _mesa_free_framebuffer_data(&buffer->glframebuffer);
-      _mesa_free(buffer);
-#else
       {
          struct gl_framebuffer *fb = &buffer->glframebuffer;
          _mesa_unreference_framebuffer(&fb);
       }
-#endif
    }
 }
 
index 1899975213f6be6f7f0a799ae46740ab767fe9ab..72091b0789c4727aa485d84dda1524534dfd059a 100644 (file)
@@ -31,8 +31,8 @@
 #include "context.h"
 #include "imports.h"
 #include "macros.h"
-#include "glapioffsets.h"
-#include "dispatch.h"
+#include "glapi/glapioffsets.h"
+#include "glapi/dispatch.h"
 
 typedef void (GLAPIENTRY *array_func)( const void * );
 
index efe5a77d5811af1c4d3d6e7bb1cc3133d47e347f..924d7134a2701fbd38fb695c6c055c308f4fd48b 100644 (file)
 
 
 #include "glheader.h"
-#include "glapi.h"
-#include "glapitable.h"
 #include "macros.h"
 #include "colormac.h"
 #include "api_loopback.h"
-#include "glthread.h"
 #include "mtypes.h"
-#include "dispatch.h"
+#include "glapi/glapi.h"
+#include "glapi/glapitable.h"
+#include "glapi/glthread.h"
+#include "glapi/dispatch.h"
 
 /* KW: A set of functions to convert unusual Color/Normal/Vertex/etc
  * calls to a smaller set of driver-provided formats.  Currently just
index 0c1a35361f16ab9d36d5e546621122b377e6377f..3df64362eab691ad658da83d0bba62e7ca42825e 100644 (file)
@@ -31,7 +31,7 @@
 #include "light.h"
 #include "macros.h"
 #include "dlist.h"
-#include "dispatch.h"
+#include "glapi/dispatch.h"
 
 
 /**
index 3d20ba7d1443c83ad7ff3e4791cf4365870ca0ef..841c6a530263e40984aa8b31421192a2bf5bb237 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.1
+ * Version:  7.0.1
  *
- * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -100,6 +100,11 @@ _mesa_validate_DrawElements(GLcontext *ctx,
                          (const GLubyte *) indices);
       }
    }
+   else {
+      /* not using a VBO */
+      if (!indices)
+         return GL_FALSE;
+   }
 
    if (ctx->Const.CheckArrayBounds) {
       /* find max array index */
@@ -170,6 +175,16 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
        && !(ctx->VertexProgram._Enabled && ctx->Array.ArrayObj->VertexAttrib[0].Enabled))
       return GL_FALSE;
 
+   /* Vertex buffer object tests */
+   if (ctx->Array.ElementArrayBufferObj->Name) {
+      /* XXX re-use code from above? */
+   }
+   else {
+      /* not using VBO */
+      if (!indices)
+         return GL_FALSE;
+   }
+
    if (ctx->Const.CheckArrayBounds) {
       /* Find max array index.
        * We don't trust the user's start and end values.
index d601ee461e69c6c9d5b2d381ac4e9ca1457e55bc..f08f99d8e17fb5e62dca9851f1c835d94c435749 100644 (file)
@@ -46,7 +46,7 @@
 #include "bufferobj.h"
 #endif
 #include "arrayobj.h"
-#include "dispatch.h"
+#include "glapi/dispatch.h"
 
 
 /**
index 255023c0fa973ec26e1a31fd4a713486bdef5f19..2ad1badac7095137cccf7e8a24c241d524a1224c 100644 (file)
 #include "fog.h"
 #include "framebuffer.h"
 #include "get.h"
-#include "glthread.h"
-#include "glapioffsets.h"
 #include "histogram.h"
 #include "hint.h"
 #include "hash.h"
-#include "atifragshader.h"
 #include "light.h"
 #include "lines.h"
 #include "macros.h"
 #include "pixel.h"
 #include "points.h"
 #include "polygon.h"
-#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
-#include "program.h"
-#endif
 #include "queryobj.h"
 #include "rastpos.h"
 #include "simple_list.h"
 #include "varray.h"
 #include "version.h"
 #include "vtxfmt.h"
+#include "glapi/glthread.h"
+#include "glapi/glapioffsets.h"
+#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
+#include "shader/program.h"
+#endif
+#include "shader/shader_api.h"
+#include "shader/atifragshader.h"
 #if _HAVE_FULL_GL
 #include "math/m_translate.h"
 #include "math/m_matrix.h"
 #include "math/m_xform.h"
 #include "math/mathmod.h"
 #endif
-#include "shader_api.h"
 
 #ifdef USE_SPARC_ASM
 #include "sparc/sparc.h"
@@ -1495,9 +1495,20 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
           */
          if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
             _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer);
+         /* fix up the fb fields - these will end up wrong otherwise
+            if the DRIdrawable changes, and someone may rely on them.
+          */
+            /* What a mess!?! */
+            int i;
+            GLenum buffers[MAX_DRAW_BUFFERS];
+            for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) {
+               buffers[i] = newCtx->Color.DrawBuffer[i];
+            }
+            _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers, buffers, NULL);
          }
          if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) {
             _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
+            _mesa_ReadBuffer(newCtx->Pixel.ReadBuffer);
          }
 
         newCtx->NewState |= _NEW_BUFFERS;
index b6a9d1314932648c874665915f72d4688ff882e0..099912aa15259d707cc5c2977b0d15ba092b17ac 100644 (file)
@@ -49,7 +49,7 @@
 #define CONTEXT_H
 
 
-#include "glapi.h"
+#include "glapi/glapi.h"
 #include "imports.h"
 #include "mtypes.h"
 
index 91ddcbf9ed6c47f79df0a0ea3907dfe0178cb541..293ee5fa349dd9a148a5c445ee57faf1ca5f85d2 100644 (file)
 #include "api_arrayelt.h"
 #include "api_loopback.h"
 #include "config.h"
-#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
-#include "arbprogram.h"
-#include "program.h"
-#endif
 #include "attrib.h"
 #include "blend.h"
 #include "buffers.h"
@@ -57,7 +53,7 @@
 #include "extensions.h"
 #include "feedback.h"
 #include "get.h"
-#include "glapi.h"
+#include "glapi/glapi.h"
 #include "hash.h"
 #include "histogram.h"
 #include "image.h"
 #include "texstate.h"
 #include "mtypes.h"
 #include "varray.h"
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+#include "shader/arbprogram.h"
+#include "shader/program.h"
+#endif
 #if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
-#include "nvprogram.h"
-#include "program.h"
+#include "shader/nvprogram.h"
+#include "shader/program.h"
 #endif
 #if FEATURE_ATI_fragment_shader
-#include "atifragshader.h"
+#include "shader/atifragshader.h"
 #endif
 
 #include "math/m_matrix.h"
 #include "math/m_xform.h"
 
-#include "dispatch.h"
+#include "glapi/dispatch.h"
 
 
 /**
index df3095232de470d2447b6726765e25f1244ed536..40f66d7da2d5d64b94ece7cd14908694630239e4 100644 (file)
@@ -32,7 +32,7 @@
 
 
 #include "imports.h"
-#include "glthread.h"
+#include "glapi/glthread.h"
 
 
 
index 1fd31a53211af37cac3416824c1e8cc86cc01e39..dc10d9ffbc8ec851f4d07ea2f4813962942165eb 100644 (file)
@@ -65,7 +65,9 @@ compute_depth_max(struct gl_framebuffer *fb)
       fb->_DepthMax = 0xffffffff;
    }
    fb->_DepthMaxF = (GLfloat) fb->_DepthMax;
-   fb->_MRD = 1.0;  /* Minimum resolvable depth value, for polygon offset */
+
+   /* Minimum resolvable depth value, for polygon offset */
+   fb->_MRD = 1.0 / fb->_DepthMaxF;
 }
 
 
index 2d5bcc3e01e9c0f28fb555d881978d05d13376d5..ffb2c4d946e47024471f8a84ca15d1651e77989c 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "glheader.h"
 #include "imports.h"
-#include "glthread.h"
+#include "glapi/glthread.h"
 #include "hash.h"
 
 
index e2e7f806ab165349386c6ecf2a2512932be8d1a3..ba46cdc1b1709d2bc0b13ee54a1cc48a61073cc4 100644 (file)
@@ -3648,11 +3648,13 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
     * Try simple cases first
     */
    if (transferOps == 0 &&
+       !ctx->Pixel.MapStencilFlag &&
        srcType == GL_UNSIGNED_BYTE &&
        dstType == GL_UNSIGNED_BYTE) {
       _mesa_memcpy(dest, source, n * sizeof(GLubyte));
    }
    else if (transferOps == 0 &&
+            !ctx->Pixel.MapStencilFlag &&
             srcType == GL_UNSIGNED_INT &&
             dstType == GL_UNSIGNED_INT &&
             !srcPacking->SwapBytes) {
@@ -3668,19 +3670,17 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
       extract_uint_indexes(n, indexes, GL_STENCIL_INDEX, srcType, source,
                            srcPacking);
 
-      if (transferOps) {
-         if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
-            /* shift and offset indexes */
-            shift_and_offset_ci(ctx, n, indexes);
-         }
+      if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
+         /* shift and offset indexes */
+         shift_and_offset_ci(ctx, n, indexes);
+      }
 
-         if (ctx->Pixel.MapStencilFlag) {
-            /* Apply stencil lookup table */
-            GLuint mask = ctx->PixelMaps.StoS.Size - 1;
-            GLuint i;
-            for (i=0;i<n;i++) {
-               indexes[i] = ctx->PixelMaps.StoS.Map[ indexes[i] & mask ];
-            }
+      if (ctx->Pixel.MapStencilFlag) {
+         /* Apply stencil lookup table */
+         const GLuint mask = ctx->PixelMaps.StoS.Size - 1;
+         GLuint i;
+         for (i = 0; i < n; i++) {
+            indexes[i] = ctx->PixelMaps.StoS.Map[ indexes[i] & mask ];
          }
       }
 
@@ -3882,9 +3882,19 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
         }                                                               \
     } while (0)
 
+
+/**
+ * Unpack a row of depth/z values from memory, returning GLushort, GLuint
+ * or GLfloat values.
+ * The glPixelTransfer (scale/bias) params will be applied.
+ *
+ * \param dstType  one of GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, GL_FLOAT
+ * \param depthMax  max value for returned GLushort or GLuint values
+ *                  (ignored for GLfloat).
+ */
 void
 _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
-                         GLenum dstType, GLvoid *dest, GLfloat depthScale,
+                         GLenum dstType, GLvoid *dest, GLuint depthMax,
                          GLenum srcType, const GLvoid *source,
                          const struct gl_pixelstore_attrib *srcPacking )
 {
@@ -3907,7 +3917,9 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
          }
          return;
       }
-      if (srcType == GL_UNSIGNED_SHORT && dstType == GL_UNSIGNED_INT) {
+      if (srcType == GL_UNSIGNED_SHORT
+          && dstType == GL_UNSIGNED_INT
+          && depthMax == 0xffffffff) {
          const GLushort *src = (const GLushort *) source;
          GLuint *dst = (GLuint *) dest;
          GLuint i;
@@ -3955,7 +3967,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
          break;
       case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */
          if (dstType == GL_UNSIGNED_INT &&
-             depthScale == (GLfloat) 0xffffff &&
+             depthMax == 0xffffff &&
              ctx->Pixel.DepthScale == 1.0 &&
              ctx->Pixel.DepthBias == 0.0) {
             const GLuint *src = (const GLuint *) source;
@@ -4033,16 +4045,16 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
    if (dstType == GL_UNSIGNED_INT) {
       GLuint *zValues = (GLuint *) dest;
       GLuint i;
-      if (depthScale <= (GLfloat) 0xffffff) {
+      if (depthMax <= 0xffffff) {
          /* no overflow worries */
          for (i = 0; i < n; i++) {
-            zValues[i] = (GLuint) (depthValues[i] * depthScale);
+            zValues[i] = (GLuint) (depthValues[i] * (GLfloat) depthMax);
          }
       }
       else {
          /* need to use double precision to prevent overflow problems */
          for (i = 0; i < n; i++) {
-            GLdouble z = depthValues[i] * depthScale;
+            GLdouble z = depthValues[i] * (GLfloat) depthMax;
             if (z >= (GLdouble) 0xffffffff)
                zValues[i] = 0xffffffff;
             else
@@ -4053,14 +4065,14 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
    else if (dstType == GL_UNSIGNED_SHORT) {
       GLushort *zValues = (GLushort *) dest;
       GLuint i;
-      ASSERT(depthScale <= 65535.0);
+      ASSERT(depthMax <= 0xffff);
       for (i = 0; i < n; i++) {
-         zValues[i] = (GLushort) (depthValues[i] * depthScale);
+         zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax);
       }
    }
    else {
       ASSERT(dstType == GL_FLOAT);
-      ASSERT(depthScale == 1.0F);
+      /*ASSERT(depthMax == 1.0F);*/
    }
 }
 
index 990398a7c45fb6d7b442bc98b0df432c1cc467e1..2a16989fa7edc422aa512e6d4e037196b3413632 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.2
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -181,7 +181,7 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
 
 extern void
 _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
-                         GLenum dstType, GLvoid *dest, GLfloat depthScale,
+                         GLenum dstType, GLvoid *dest, GLuint depthMax,
                          GLenum srcType, const GLvoid *source,
                          const struct gl_pixelstore_attrib *srcPacking );
 
index 05c08c19fec8398a8dcfa009d88f2651886e2d1c..709b88d2ef554beb58cfb46157575816afea9733 100644 (file)
@@ -38,8 +38,8 @@
 #include "glheader.h"
 #include <GL/internal/glcore.h>        /* __GLcontextModes (GLvisual) */
 #include "config.h"            /* Hardwired parameters */
-#include "glapitable.h"
-#include "glthread.h"
+#include "glapi/glapitable.h"
+#include "glapi/glthread.h"
 #include "math/m_matrix.h"     /* GLmatrix */
 #include "bitset.h"
 
index 0a83abc7ddac587cb6f8edacf2d9bbe920f863aa..66f8ac64088a33abb1a156307f6d2c04cf9bdec6 100644 (file)
 #include "accum.h"
 #include "api_loopback.h"
 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
-#include "arbprogram.h"
+#include "shader/arbprogram.h"
 #endif
 #if FEATURE_ATI_fragment_shader
-#include "atifragshader.h"
+#include "shader/atifragshader.h"
 #endif
 #include "attrib.h"
 #include "blend.h"
 #include "mtypes.h"
 #include "varray.h"
 #if FEATURE_NV_vertex_program
-#include "nvprogram.h"
+#include "shader/nvprogram.h"
 #endif
 #if FEATURE_NV_fragment_program
-#include "nvprogram.h"
-#include "program.h"
+#include "shader/nvprogram.h"
+#include "shader/program.h"
 #include "texenvprogram.h"
 #endif
 #if FEATURE_ARB_shader_objects
 #include "shaders.h"
 #endif
 #include "debug.h"
-#include "dispatch.h"
+#include "glapi/dispatch.h"
 
 
 
index 1a46c10ffa319f9ba84ece6ea89e0007701dea44..72b54b27d9a6a61d2c42adc1b74a1ce3031717a4 100644 (file)
 #include "glheader.h"
 #include "macros.h"
 #include "enums.h"
-#include "prog_parameter.h"
-#include "prog_instruction.h"
-#include "prog_print.h"
-#include "prog_statevars.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_print.h"
+#include "shader/prog_statevars.h"
 #include "texenvprogram.h"
 
 /**
index f902365b9bd9b37718832013a723b8a6e333114e..3420d8e2bafd675a6dfa5c4dd679ddf135dd97dc 100644 (file)
@@ -1264,6 +1264,10 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
  * A hardware driver might override this function if, for example, the
  * max 3D texture size is 512x512x64 (i.e. not a cube).
  *
+ * Note that width, height, depth == 0 is not an error.  However, a
+ * texture with zero width/height/depth will be considered "incomplete"
+ * and texturing will effectively be disabled.
+ *
  * \param target  one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D,
  *                GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV,
  *                GL_PROXY_TEXTURE_CUBE_MAP_ARB.
@@ -1293,7 +1297,7 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
       maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
       if (width < 2 * border || width > 2 + maxSize ||
           (!ctx->Extensions.ARB_texture_non_power_of_two &&
-           _mesa_bitcount(width - 2 * border) != 1) ||
+           width >0 && _mesa_bitcount(width - 2 * border) != 1) ||
           level >= ctx->Const.MaxTextureLevels) {
          /* bad width or level */
          return GL_FALSE;
@@ -1303,10 +1307,10 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
       maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
       if (width < 2 * border || width > 2 + maxSize ||
           (!ctx->Extensions.ARB_texture_non_power_of_two &&
-           _mesa_bitcount(width - 2 * border) != 1) ||
+           width > 0 && _mesa_bitcount(width - 2 * border) != 1) ||
           height < 2 * border || height > 2 + maxSize ||
           (!ctx->Extensions.ARB_texture_non_power_of_two &&
-           _mesa_bitcount(height - 2 * border) != 1) ||
+           height > 0 && _mesa_bitcount(height - 2 * border) != 1) ||
           level >= ctx->Const.MaxTextureLevels) {
          /* bad width or height or level */
          return GL_FALSE;
@@ -1316,21 +1320,21 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
       maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
       if (width < 2 * border || width > 2 + maxSize ||
           (!ctx->Extensions.ARB_texture_non_power_of_two &&
-           _mesa_bitcount(width - 2 * border) != 1) ||
+           width > 0 && _mesa_bitcount(width - 2 * border) != 1) ||
           height < 2 * border || height > 2 + maxSize ||
           (!ctx->Extensions.ARB_texture_non_power_of_two &&
-           _mesa_bitcount(height - 2 * border) != 1) ||
+           height > 0 && _mesa_bitcount(height - 2 * border) != 1) ||
           depth < 2 * border || depth > 2 + maxSize ||
           (!ctx->Extensions.ARB_texture_non_power_of_two &&
-           _mesa_bitcount(depth - 2 * border) != 1) ||
+           depth > 0 && _mesa_bitcount(depth - 2 * border) != 1) ||
           level >= ctx->Const.Max3DTextureLevels) {
          /* bad width or height or depth or level */
          return GL_FALSE;
       }
       return GL_TRUE;
    case GL_PROXY_TEXTURE_RECTANGLE_NV:
-      if (width < 1 || width > ctx->Const.MaxTextureRectSize ||
-          height < 1 || height > ctx->Const.MaxTextureRectSize ||
+      if (width < 0 || width > ctx->Const.MaxTextureRectSize ||
+          height < 0 || height > ctx->Const.MaxTextureRectSize ||
           level != 0) {
          /* bad width or height or level */
          return GL_FALSE;
@@ -1340,10 +1344,10 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
       maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1);
       if (width < 2 * border || width > 2 + maxSize ||
           (!ctx->Extensions.ARB_texture_non_power_of_two &&
-           _mesa_bitcount(width - 2 * border) != 1) ||
+           width > 0 && _mesa_bitcount(width - 2 * border) != 1) ||
           height < 2 * border || height > 2 + maxSize ||
           (!ctx->Extensions.ARB_texture_non_power_of_two &&
-           _mesa_bitcount(height - 2 * border) != 1) ||
+           height > 0 && _mesa_bitcount(height - 2 * border) != 1) ||
           level >= ctx->Const.MaxCubeTextureLevels) {
          /* bad width or height */
          return GL_FALSE;
@@ -1353,7 +1357,7 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
       maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
       if (width < 2 * border || width > 2 + maxSize ||
           (!ctx->Extensions.ARB_texture_non_power_of_two &&
-           _mesa_bitcount(width - 2 * border) != 1) ||
+           width > 0 && _mesa_bitcount(width - 2 * border) != 1) ||
           level >= ctx->Const.MaxTextureLevels) {
          /* bad width or level */
          return GL_FALSE;
@@ -1367,10 +1371,10 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
       maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
       if (width < 2 * border || width > 2 + maxSize ||
           (!ctx->Extensions.ARB_texture_non_power_of_two &&
-           _mesa_bitcount(width - 2 * border) != 1) ||
+           width > 0 && _mesa_bitcount(width - 2 * border) != 1) ||
           height < 2 * border || height > 2 + maxSize ||
           (!ctx->Extensions.ARB_texture_non_power_of_two &&
-           _mesa_bitcount(height - 2 * border) != 1) ||
+           height > 0 && _mesa_bitcount(height - 2 * border) != 1) ||
           level >= ctx->Const.MaxTextureLevels) {
          /* bad width or height or level */
          return GL_FALSE;
@@ -1472,7 +1476,7 @@ texture_error_check( GLcontext *ctx, GLenum target,
       if (target == GL_PROXY_TEXTURE_1D || target == GL_TEXTURE_1D) {
          proxy_target = GL_PROXY_TEXTURE_1D;
          height = 1;
-         width = 1;
+         depth = 1;
       }
       else {
          _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" );
index 9b8a06df1452ff902f93c8b2ca76df28e39dfef2..3b5151ed17135f95e89a74e7b648dfdc52d4c99b 100644 (file)
@@ -1077,7 +1077,7 @@ _mesa_texstore_rgba(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_z32(TEXSTORE_PARAMS)
 {
-   const GLfloat depthScale = (GLfloat) 0xffffffff;
+   const GLuint depthScale = 0xffffffff;
    (void) dims;
    ASSERT(dstFormat == &_mesa_texformat_z32);
    ASSERT(dstFormat->TexelBytes == sizeof(GLuint));
@@ -1124,7 +1124,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_z16(TEXSTORE_PARAMS)
 {
-   const GLfloat depthScale = 65535.0f;
+   const GLuint depthScale = 0xffff;
    (void) dims;
    ASSERT(dstFormat == &_mesa_texformat_z16);
    ASSERT(dstFormat->TexelBytes == sizeof(GLushort));
@@ -2319,6 +2319,8 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
 {
+   const GLuint depthScale = 0xffffff;
+
    ASSERT(dstFormat == &_mesa_texformat_z24_s8);
    ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT);
    ASSERT(srcType == GL_UNSIGNED_INT_24_8_EXT);
@@ -2357,7 +2359,7 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
             _mesa_unpack_depth_span(ctx, srcWidth,
                                     GL_UNSIGNED_INT, /* dst type */
                                     dstRow, /* dst addr */
-                                    (GLfloat) 0xffffff, /* depthScale */
+                                    depthScale,
                                     srcType, src, srcPacking);
             /* get the 8-bit stencil values */
             _mesa_unpack_stencil_span(ctx, srcWidth,
index bf1ad0165e66e8fd1a5b89c1fa2b9f1d433edb96..fe4a7c684f6344bd84aa8cb94324de71e3953419 100644 (file)
@@ -32,7 +32,7 @@
 #include "mtypes.h"
 #include "varray.h"
 #include "arrayobj.h"
-#include "dispatch.h"
+#include "glapi/dispatch.h"
 
 
 /**
index 783b06558d516f642da5f8ee6722c8a4f8e40cdb..6f5d01e40f2d9ad8e5e4ebf2f1584645456e401c 100644 (file)
@@ -29,8 +29,8 @@
 #define PRE_LOOPBACK( FUNC )
 #endif
 
-#include "dispatch.h"
-#include "glapioffsets.h"
+#include "glapi/dispatch.h"
+#include "glapi/glapioffsets.h"
 
 static void GLAPIENTRY TAG(ArrayElement)( GLint i )
 {
index 42ffd4133d3ad0c07a6ebb80669384b90888691e..d324673c5d772714a79be38240e7ac3d47884648 100644 (file)
@@ -37,8 +37,8 @@
  */
 
 
-#include "glheader.h"
-#include "config.h"
+#include "main/glheader.h"
+#include "main/config.h"
 #include "m_eval.h"
 
 static GLfloat inv_tab[MAX_EVAL_ORDER];
index a23cbd402e69aff17c2d5b0e11d6799371b198f4..d73ecaafb28f2b4b47fd59b4e869ded6f6b9b9ef 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef _M_EVAL_H
 #define _M_EVAL_H
 
-#include "glheader.h"
+#include "main/glheader.h"
 
 void _math_init_eval( void );
 
index 0bcf96005c79213251899d12148b7c0376e9dedb..c677682d5060d616f8777b384d68190284fc2339 100644 (file)
@@ -26,8 +26,8 @@
 #ifndef _M_TRANSLATE_H_
 #define _M_TRANSLATE_H_
 
-#include "config.h"
-#include "mtypes.h"            /* hack for GLchan */
+#include "main/config.h"
+#include "main/mtypes.h"               /* hack for GLchan */
 
 
 /**
index fa3f57a8e5a8e7d458cf3f79e3c1f692b2bab9dd..901ae5b416ab4d392544609fb60e978ff2b3abc7 100644 (file)
@@ -33,8 +33,8 @@
  * 3. Transformation of a point p by a matrix M is: p' = M * p
  */
 
-#include "glheader.h"
-#include "macros.h"
+#include "main/glheader.h"
+#include "main/macros.h"
 
 #include "m_eval.h"
 #include "m_matrix.h"
index 5d8f763741fabcb6dc00e47d9684bcfaa3eaae89..9a5290d920e35685f16bbac4333d3f92c375af89 100644 (file)
  * \author Karl Rasche
  */
 
-#include "glheader.h"
-#include "imports.h"
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "shader/grammar/grammar_mesa.h"
 #include "arbprogparse.h"
-#include "grammar_mesa.h"
 #include "program.h"
 #include "prog_parameter.h"
 #include "prog_statevars.h"
@@ -3573,7 +3573,7 @@ parse_instructions(GLcontext * ctx, const GLubyte * inst,
 
 /* XXX temporary */
 LONGSTRING static char core_grammar_text[] =
-#include "grammar_syn.h"
+#include "shader/grammar/grammar_syn.h"
 ;
 
 
index 9faf9d86134e91d47c5fd409285710f3173c0d6e..28d195d0ee95393db885dc8c4a0f73eeea7879fd 100644 (file)
@@ -43,7 +43,7 @@
 #include "prog_instruction.h"
 #include "prog_parameter.h"
 #include "prog_print.h"
-#include "slang_library_noise.h"
+#include "shader/slang/slang_library_noise.h"
 
 
 /* See comments below for info about this */
index 3a54e68d0de8374fb31a2aca2dd6efc0b21fcfe0..1a931326afa3a9d5117429fb32c85ebce5368bdd 100644 (file)
 #include "prog_parameter.h"
 #include "prog_print.h"
 #include "prog_statevars.h"
-#include "shader_api.h"
-
-#include "slang_compile.h"
-#include "slang_link.h"
+#include "shader/shader_api.h"
+#include "shader/slang/slang_compile.h"
+#include "shader/slang/slang_link.h"
 
 
 
@@ -780,7 +779,7 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program,
       *params = shProg->Validated;
       break;
    case GL_INFO_LOG_LENGTH:
-      *params = shProg->InfoLog ? strlen(shProg->InfoLog) : 0;
+      *params = shProg->InfoLog ? strlen(shProg->InfoLog) + 1 : 0;
       break;
    case GL_ATTACHED_SHADERS:
       *params = shProg->NumShaders;
@@ -832,10 +831,10 @@ _mesa_get_shaderiv(GLcontext *ctx, GLuint name, GLenum pname, GLint *params)
       *params = shader->CompileStatus;
       break;
    case GL_INFO_LOG_LENGTH:
-      *params = shader->InfoLog ? strlen(shader->InfoLog) : 0;
+      *params = shader->InfoLog ? strlen(shader->InfoLog) + 1 : 0;
       break;
    case GL_SHADER_SOURCE_LENGTH:
-      *params = shader->Source ? strlen((char *) shader->Source) : 0;
+      *params = shader->Source ? strlen((char *) shader->Source) + 1 : 0;
       break;
    default:
       _mesa_error(ctx, GL_INVALID_ENUM, "glGetShaderiv(pname)");
index 6ee0fd33b6a1f977fd4589a7d801091ec1cf69af..1081d8ff8db744d06fc58069f4d2e262ad76b7e4 100644 (file)
  * \author Brian Paul
  */
 
-#include "imports.h"
-#include "slang_builtin.h"
-#include "slang_ir.h"
-#include "mtypes.h"
-#include "program.h"
-#include "prog_instruction.h"
-#include "prog_parameter.h"
-#include "prog_statevars.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
+#include "shader/program.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_statevars.h"
+#include "shader/slang/slang_ir.h"
+#include "shader/slang/slang_builtin.h"
 
 
 /**
index ae20c844d5872002e1989f4abc3152b6923d97d9..58629f4f7fe3a1a7ccdc2612809f32c4cf484a98 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef SLANG_BUILTIN_H
 #define SLANG_BUILTIN_H
 
-#include "prog_parameter.h"
+#include "shader/prog_parameter.h"
 #include "slang_utility.h"
 #include "slang_ir.h"
 
index 488c093833bc8269863a7f1e3760e4b3078e18e4..eae12f2ae9c59999252e77d7d680e039fab131e8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.3
+ * Version:  7.1
  *
  * Copyright (C) 2005-2007  Brian Paul   All Rights Reserved.
  *
 
 
 
-#include "imports.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "program.h"
-#include "prog_instruction.h"
-#include "prog_parameter.h"
-#include "prog_statevars.h"
+#include "main/imports.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
+#include "shader/program.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_statevars.h"
 #include "slang_typeinfo.h"
 #include "slang_codegen.h"
 #include "slang_compile.h"
@@ -2329,7 +2329,8 @@ _slang_gen_field(slang_assemble_ctx * A, slang_operation *oper)
          n = _slang_gen_swizzle(n, swizzle);
       return n;
    }
-   else if (ti.spec.type == SLANG_SPEC_FLOAT) {
+   else if (   ti.spec.type == SLANG_SPEC_FLOAT
+            || ti.spec.type == SLANG_SPEC_INT) {
       const GLuint rows = 1;
       slang_swizzle swz;
       slang_ir_node *n;
index a4dd5b8b4ae237d8400a2d85b530cd6f1308213f..70f5aac16d484ba36974c7b1a78e872cc81540a4 100644 (file)
  * \author Michal Krol
  */
 
-#include "imports.h"
-#include "context.h"
-#include "program.h"
-#include "prog_parameter.h"
-#include "grammar_mesa.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "shader/program.h"
+#include "shader/prog_parameter.h"
+#include "shader/grammar/grammar_mesa.h"
 #include "slang_codegen.h"
 #include "slang_compile.h"
 #include "slang_preprocess.h"
index 7804e192360a9d47514f217bc2716bad74216c48..02c74095a9e500b4f003ce7dca4061e32cb2e064 100644 (file)
  ***/
 
 
-#include "imports.h"
-#include "context.h"
-#include "macros.h"
-#include "program.h"
-#include "prog_instruction.h"
-#include "prog_parameter.h"
-#include "prog_print.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "shader/program.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
 #include "slang_builtin.h"
 #include "slang_emit.h"
 #include "slang_mem.h"
index a6903cc8b625211be165411c97e677aed0e0a45b..a29f3026873573d99c0152aeac80dacc05c4761c 100644 (file)
@@ -27,7 +27,7 @@
 #include "context.h"
 #include "slang_ir.h"
 #include "slang_mem.h"
-#include "prog_print.h"
+#include "shader/prog_print.h"
 
 
 static const slang_ir_info IrInfo[] = {
index 0f1a45b30f9febeda921144855434507a94ea214..87068ae7a7fefb04dfe207f9353b65f003963e17 100644 (file)
@@ -1,9 +1,9 @@
 #ifndef SLANG_LABEL_H
 #define SLANG_LABEL_H 1
 
-#include "imports.h"
-#include "mtypes.h"
-#include "prog_instruction.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
+#include "shader/prog_instruction.h"
 
 
 struct slang_label_
index d6d1c7523e5d94adffc8b6967fa32b8433c9f772..eaa29ba094e6463ac16042789c0e6e59348d9d36 100644 (file)
  * \author Brian Paul
  */
 
-#include "imports.h"
-#include "context.h"
-#include "hash.h"
-#include "macros.h"
-#include "program.h"
-#include "prog_instruction.h"
-#include "prog_parameter.h"
-#include "prog_print.h"
-#include "prog_statevars.h"
-#include "shader_api.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/hash.h"
+#include "main/macros.h"
+#include "shader/program.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
+#include "shader/prog_statevars.h"
+#include "shader/shader_api.h"
 #include "slang_link.h"
 
 
index 72281eda57de9db59fd2aa9163898a95aabbbf4d..076e982f8f29d5bd6f70fdf9fe4337ff330249ff 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 #include "imports.h"
-#include "grammar_mesa.h"
+#include "shader/grammar/grammar_mesa.h"
 #include "slang_preprocess.h"
 
 LONGSTRING static const char *slang_pp_directives_syn =
index da0b32bc44467d3a5675f548fffc67aa9cdd0329..8a1c3abf4807df21510511cf62f0af37fa05e808 100644 (file)
  * \author Michal Krol
  */
 
-#include "imports.h"
+#include "main/imports.h"
+#include "shader/prog_instruction.h"
 #include "slang_typeinfo.h"
 #include "slang_compile.h"
 #include "slang_log.h"
 #include "slang_mem.h"
-#include "prog_instruction.h"
 
 
 /**
index 8a3c299d19cad48c6fe33975f785e45d82f21fe7..1d817000c60b0b3fcd0be52ef0e3976ec348b7d8 100644 (file)
@@ -1,11 +1,11 @@
 
-#include "imports.h"
+#include "main/imports.h"
+#include "shader/prog_instruction.h"
 #include "slang_compile.h"
 #include "slang_compile_variable.h"
 #include "slang_mem.h"
 #include "slang_vartable.h"
 #include "slang_ir.h"
-#include "prog_instruction.h"
 
 
 static int dbg = 0;
index 947054faa3053fca17463af6a37e6cc2bd6b72db..55ec757ee069b67f8aa1ce1c999da90e819709cb 100644 (file)
 #include "glheader.h"
 #include "colormac.h"
 #include "context.h"
-#include "atifragshader.h"
 #include "macros.h"
-#include "program.h"
-
-#include "s_atifragshader.h"
+#include "shader/program.h"
+#include "shader/atifragshader.h"
+#include "swrast/s_atifragshader.h"
 
 
 /**
index 791850cb5028fa7c55d2917f96473a23796e6149..395692565148856f0ea49dbb429c95862509e8ef 100644 (file)
@@ -31,9 +31,9 @@
 #include "context.h"
 #include "colormac.h"
 #include "mtypes.h"
-#include "prog_statevars.h"
 #include "teximage.h"
 #include "swrast.h"
+#include "shader/prog_statevars.h"
 #include "s_blend.h"
 #include "s_context.h"
 #include "s_lines.h"
index f118eb92ca463718164f07283686c7ec1241a4bf..daa07e15783af7dfd0cd555c8d7390c65d8cf122 100644 (file)
 #ifndef S_CONTEXT_H
 #define S_CONTEXT_H
 
-#include "mtypes.h"
+#include "main/mtypes.h"
+#include "shader/prog_execute.h"
 #include "swrast.h"
 #include "s_span.h"
-#include "prog_execute.h"
 
 
 typedef void (*texture_sample_func)(GLcontext *ctx,
index 1c9f64b275e755669720c893872b88929c2ebb4d..0cf425e1c62a588e270b4cdede692661678512ef 100644 (file)
@@ -484,7 +484,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
    }
    else {
       /* General case */
-      const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
+      const GLuint depthMax = ctx->DrawBuffer->_DepthMax;
       GLint skipPixels = 0;
 
       /* in case width > MAX_WIDTH do the copy in chunks */
@@ -695,7 +695,7 @@ draw_depth_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
    const GLint imgX = x, imgY = y;
    const GLboolean scaleOrBias
       = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
-   const GLfloat depthScale = ctx->DrawBuffer->_DepthMaxF;
+   const GLuint depthMax = ctx->DrawBuffer->_DepthMax;
    const GLuint stencilMask = ctx->Stencil.WriteMask[0];
    const GLuint stencilType = (STENCIL_BITS == 8) ? 
       GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT;
@@ -783,7 +783,7 @@ draw_depth_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
                /* general case */
                GLuint zValues[MAX_WIDTH];  /* 16 or 32-bit Z value storage */
                _mesa_unpack_depth_span(ctx, width,
-                                       depthRb->DataType, zValues, depthScale,
+                                       depthRb->DataType, zValues, depthMax,
                                        type, depthStencilSrc, &clippedUnpack);
                if (zoom) {
                   _swrast_write_zoomed_z_span(ctx, imgX, imgY, width, x,
index 923b67e78e6c44102826c1a89475b3574f127f43..14c9868c1803ba4adfef8acc5757d56438614e30 100644 (file)
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "prog_instruction.h"
-#include "texstate.h"
+#include "main/glheader.h"
+#include "main/colormac.h"
+#include "main/context.h"
+#include "main/texstate.h"
+#include "shader/prog_instruction.h"
 
 #include "s_fragprog.h"
 #include "s_span.h"
index 89991fad02d6a4d605d922efecc729fa121a5ddf..d0cbdd6917d837bf3b1c0ff88f123f0a1b4ec1a9 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  7.1
  *
- * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -392,6 +392,23 @@ do_stencil_test( GLcontext *ctx, GLuint face, GLuint n, GLstencil stencil[],
 }
 
 
+/**
+ * Compute the zpass/zfail masks by comparing the pre- and post-depth test
+ * masks.
+ */
+static INLINE void
+compute_pass_fail_masks(GLuint n, const GLubyte origMask[],
+                        const GLubyte newMask[],
+                        GLubyte passMask[], GLubyte failMask[])
+{
+   GLuint i;
+   for (i = 0; i < n; i++) {
+      ASSERT(newMask[i] == 0 || newMask[i] == 1);
+      passMask[i] = origMask[i] & newMask[i];
+      failMask[i] = origMask[i] & (newMask[i] ^ 1);
+   }
+}
+
 
 /**
  * Apply stencil and depth testing to the span of pixels.
@@ -460,39 +477,24 @@ stencil_and_ztest_span(GLcontext *ctx, SWspan *span, GLuint face)
       /*
        * Perform depth buffering, then apply zpass or zfail stencil function.
        */
-      GLubyte passmask[MAX_WIDTH], failmask[MAX_WIDTH], oldmask[MAX_WIDTH];
-      GLuint i;
+      GLubyte passMask[MAX_WIDTH], failMask[MAX_WIDTH], origMask[MAX_WIDTH];
 
       /* save the current mask bits */
-      _mesa_memcpy(oldmask, mask, n * sizeof(GLubyte));
+      _mesa_memcpy(origMask, mask, n * sizeof(GLubyte));
 
       /* apply the depth test */
       _swrast_depth_test_span(ctx, span);
 
-      /* Set the stencil pass/fail flags according to result of depth testing.
-       * if oldmask[i] == 0 then
-       *    Don't touch the stencil value
-       * else if oldmask[i] and newmask[i] then
-       *    Depth test passed
-       * else
-       *    assert(oldmask[i] && !newmask[i])
-       *    Depth test failed
-       * endif
-       */
-      for (i=0;i<n;i++) {
-         ASSERT(mask[i] == 0 || mask[i] == 1);
-         passmask[i] = oldmask[i] & mask[i];
-         failmask[i] = oldmask[i] & (mask[i] ^ 1);
-      }
+      compute_pass_fail_masks(n, origMask, mask, passMask, failMask);
 
       /* apply the pass and fail operations */
       if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) {
          apply_stencil_op( ctx, ctx->Stencil.ZFailFunc[face], face,
-                           n, stencil, failmask );
+                           n, stencil, failMask );
       }
       if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) {
          apply_stencil_op( ctx, ctx->Stencil.ZPassFunc[face], face,
-                           n, stencil, passmask );
+                           n, stencil, passMask );
       }
    }
 
@@ -902,6 +904,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n,
 static GLboolean
 stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face )
 {
+   GLubyte passMask[MAX_WIDTH], failMask[MAX_WIDTH], origMask[MAX_WIDTH];
    struct gl_framebuffer *fb = ctx->DrawBuffer;
    struct gl_renderbuffer *rb = fb->_StencilBuffer;
    const GLuint n = span->end;
@@ -916,13 +919,10 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face )
    if (!rb->GetPointer(ctx, rb, 0, 0)) {
       /* No direct access */
       GLstencil stencil[MAX_WIDTH];
-      GLubyte origMask[MAX_WIDTH];
 
       ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
       _swrast_get_values(ctx, rb, n, x, y, stencil, sizeof(GLubyte));
 
-      _mesa_memcpy(origMask, mask, n * sizeof(GLubyte));
-
       (void) do_stencil_test(ctx, face, n, stencil, mask);
 
       if (ctx->Depth.Test == GL_FALSE) {
@@ -930,27 +930,19 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face )
                           n, stencil, mask);
       }
       else {
+         _mesa_memcpy(origMask, mask, n * sizeof(GLubyte));
+
          _swrast_depth_test_span(ctx, span);
 
+         compute_pass_fail_masks(n, origMask, mask, passMask, failMask);
+
          if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) {
-            GLubyte failmask[MAX_WIDTH];
-            GLuint i;
-            for (i = 0; i < n; i++) {
-               ASSERT(mask[i] == 0 || mask[i] == 1);
-               failmask[i] = origMask[i] & (mask[i] ^ 1);
-            }
             apply_stencil_op(ctx, ctx->Stencil.ZFailFunc[face], face,
-                             n, stencil, failmask);
+                             n, stencil, failMask);
          }
          if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) {
-            GLubyte passmask[MAX_WIDTH];
-            GLuint i;
-            for (i = 0; i < n; i++) {
-               ASSERT(mask[i] == 0 || mask[i] == 1);
-               passmask[i] = origMask[i] & mask[i];
-            }
             apply_stencil_op(ctx, ctx->Stencil.ZPassFunc[face], face,
-                             n, stencil, passmask);
+                             n, stencil, passMask);
          }
       }
 
@@ -972,28 +964,21 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face )
                                     ctx->Stencil.ZPassFunc[face], face, mask);
       }
       else {
-         GLubyte passmask[MAX_WIDTH], failmask[MAX_WIDTH], oldmask[MAX_WIDTH];
-         GLuint i;
-
-         _mesa_memcpy(oldmask, mask, n * sizeof(GLubyte));
+         _mesa_memcpy(origMask, mask, n * sizeof(GLubyte));
 
          _swrast_depth_test_span(ctx, span);
 
-         for (i=0;i<n;i++) {
-            ASSERT(mask[i] == 0 || mask[i] == 1);
-            passmask[i] = oldmask[i] & mask[i];
-            failmask[i] = oldmask[i] & (mask[i] ^ 1);
-         }
+         compute_pass_fail_masks(n, origMask, mask, passMask, failMask);
 
          if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) {
             apply_stencil_op_to_pixels(ctx, n, x, y,
                                        ctx->Stencil.ZFailFunc[face],
-                                       face, failmask);
+                                       face, failMask);
          }
          if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) {
             apply_stencil_op_to_pixels(ctx, n, x, y,
                                        ctx->Stencil.ZPassFunc[face],
-                                       face, passmask);
+                                       face, passMask);
          }
       }
 
index d101a9e2ae256deb305b95dab0bee2a5fffd63ca..85a27fd55bf534cdce0011fa63f525cf7c4fcf6d 100644 (file)
@@ -32,7 +32,7 @@
 #ifndef SWRAST_H
 #define SWRAST_H
 
-#include "mtypes.h"
+#include "main/mtypes.h"
 
 /**
  * \struct SWvertex
index f8a1cadfa5a01e5af9fb961c7dfccd6267272a69..a9c7d941e5b17e09d6b95a449025ffaf8df00646 100644 (file)
@@ -280,26 +280,29 @@ _swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest )
 
    /** XXX try to limit these loops someday */
    for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
-      _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0+i,
+      _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0 + i,
                      dest->attrib[FRAG_ATTRIB_TEX0 + i] );
 
    for (i = 0 ; i < ctx->Const.MaxVarying ; i++)
-      _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_GENERIC0+i,
+      _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_GENERIC0 + i,
                      dest->attrib[FRAG_ATTRIB_VAR0 + i] );
 
-   _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0, tmp );
-   /* XXX need float color FRAG_ATTRIB_COL0?? */
-   UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp );
+   if (ctx->Visual.rgbMode) {
+      _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0,
+                     dest->attrib[FRAG_ATTRIB_COL0] );
+      UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp );
 
-   _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1, tmp );
-   COPY_4V(dest->attrib[FRAG_ATTRIB_COL1], tmp);
+      _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1,
+                     dest->attrib[FRAG_ATTRIB_COL1]);
+   }
+   else {
+      _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR_INDEX, tmp );
+      dest->attrib[FRAG_ATTRIB_CI][0] = tmp[0];
+   }
 
    _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_FOG, tmp );
    dest->attrib[FRAG_ATTRIB_FOGC][0] = tmp[0];
 
-   _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR_INDEX, tmp );
-   dest->attrib[FRAG_ATTRIB_CI][0] = tmp[0];
-
    /* XXX See _tnl_get_attr about pointsize ... */
    _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POINTSIZE, tmp );
    dest->pointSize = tmp[0];
index c14468e9514be5f213b461c53d895f43988630b2..f6b738d60dfc2d3ffb383faaf65ddb885c059cc6 100644 (file)
@@ -37,7 +37,7 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
    SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
    SWvertex *v[3];
    GLfloat z[3];
-   GLfloat offset;
+   GLfloat offset, oz0, oz1, oz2;
    GLenum mode = GL_FILL;
    GLuint facing = 0;
    GLchan saved_color[3][4];
@@ -142,12 +142,16 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
         }
       }
 
-      if (IND & SS_OFFSET_BIT)
-      {
-        offset = ctx->Polygon.OffsetUnits * ctx->DrawBuffer->_MRD;
+      if (IND & SS_OFFSET_BIT) {
+         const GLfloat max = ctx->DrawBuffer->_DepthMaxF;
+         /* save original Z values (restored later) */
         z[0] = v[0]->attrib[FRAG_ATTRIB_WPOS][2];
         z[1] = v[1]->attrib[FRAG_ATTRIB_WPOS][2];
         z[2] = v[2]->attrib[FRAG_ATTRIB_WPOS][2];
+         /* Note that Z values are already scaled to [0,65535] (for example)
+          * so no MRD value is used here.
+          */
+        offset = ctx->Polygon.OffsetUnits;
         if (cc * cc > 1e-16) {
            const GLfloat ez = z[0] - z[2];
            const GLfloat fz = z[1] - z[2];
@@ -155,35 +159,33 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
            const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea);
            const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea);
            offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor;
-            /* Unfortunately, we need to clamp to prevent negative Zs below.
-             * Technically, we should do the clamping per-fragment.
-             */
-            offset = MAX2(offset, -v[0]->attrib[FRAG_ATTRIB_WPOS][2]);
-            offset = MAX2(offset, -v[1]->attrib[FRAG_ATTRIB_WPOS][2]);
-            offset = MAX2(offset, -v[2]->attrib[FRAG_ATTRIB_WPOS][2]);
         }
+         /* new Z values */
+         oz0 = CLAMP(v[0]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
+         oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
+         oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
       }
    }
 
    if (mode == GL_POINT) {
       if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) {
-        v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
-        v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
-        v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
+        v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0;
+        v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1;
+        v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2;
       }
       _swsetup_render_point_tri( ctx, e0, e1, e2, facing );
    } else if (mode == GL_LINE) {
       if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) {
-        v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
-        v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
-        v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
+        v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0;
+        v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1;
+        v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2;
       }
       _swsetup_render_line_tri( ctx, e0, e1, e2, facing );
    } else {
       if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) {
-        v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
-        v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
-        v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
+        v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0;
+        v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1;
+        v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2;
       }
       _swrast_Triangle( ctx, v[0], v[1], v[2] );
    }
index 3017c73cf1f828beb9229697e306921fbc44dc85..3b8dd18bbb2bb53a9e6cbb7d039fd510a1cacb71 100644 (file)
  */
 
 
-#include "glheader.h"
-#include "imports.h"
-#include "context.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "light.h"
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/light.h"
 
 #include "tnl.h"
 #include "t_context.h"
index 31b89aca41f2bc344e0f23c4fbbd2a7179cf727c..baf283ef0f61fbd1e865c8c74015d1690bae3300 100644 (file)
@@ -49,8 +49,8 @@
 #ifndef _T_CONTEXT_H
 #define _T_CONTEXT_H
 
-#include "glheader.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/mtypes.h"
 
 #include "math/m_matrix.h"
 #include "math/m_vector.h"
index c7188da34aaaa25a39f1aed7d1a5f548fc219009..2a0ed8852a2b027ba986da59cc85b199622d1308 100644 (file)
  *    Keith Whitwell <keith@tungstengraphics.com>
  */
 
-#include "glheader.h"
-#include "context.h"
-#include "imports.h"
-#include "state.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/imports.h"
+#include "main/state.h"
+#include "main/mtypes.h"
 
 #include "t_context.h"
 #include "t_pipeline.h"
index 9961af70ce7e1ce534e956b0af4fed6a141f7aae..f8e561ac57e3389e5307364de469949ca9697a20 100644 (file)
 #include "context.h"
 #include "macros.h"
 #include "imports.h"
-#include "prog_instruction.h"
-#include "prog_statevars.h"
-#include "prog_execute.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_statevars.h"
+#include "shader/prog_execute.h"
+#include "swrast/s_context.h"
+#include "swrast/s_texfilter.h"
 
 #include "tnl.h"
 #include "t_context.h"
 #include "t_pipeline.h"
 
-#include "swrast/s_context.h"
-#include "swrast/s_texfilter.h"
 
 /**
  * XXX the texture sampling code in this module is a bit of a hack.
index 2a1cae77f29feda7c9379d358158d1e1d865dfde..ee1a2498b320e400057040d19aebb79e7724e16a 100644 (file)
 #include "glheader.h"
 #include "macros.h"
 #include "enums.h"
-#include "program.h"
-#include "prog_instruction.h"
-#include "prog_parameter.h"
-#include "prog_print.h"
-#include "prog_statevars.h"
+#include "shader/program.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
+#include "shader/prog_statevars.h"
 #include "t_context.h" /* NOTE: very light dependency on this */
 #include "t_vp_build.h"
 
index 20bed5546de575a227988434f55a4cec335928e4..047b764dcba88602047b63a69abfb2874b57e2df 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef _TNL_H
 #define _TNL_H
 
-#include "mtypes.h"
+#include "main/mtypes.h"
 
 
 
index 874a5f9e0e26a853751fb218b1a496d2262d08a2..04c59c05b277027281d91b4bcae52d39627b4250 100644 (file)
@@ -32,7 +32,7 @@
 #ifndef _VBO_H
 #define _VBO_H
 
-#include "mtypes.h"
+#include "main/mtypes.h"
 
 struct _mesa_prim {
    GLuint mode:8;
index f64f59d11ec17ebe400c2a2f5e39b98ffb75f953..ad4556c500b1274a022c5fb48b7cfe7dc0862c6a 100644 (file)
  *    Keith Whitwell <keith@tungstengraphics.com>
  */
 
-#include "mtypes.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
+#include "main/api_arrayelt.h"
 #include "vbo.h"
 #include "vbo_context.h"
-#include "imports.h"
-#include "api_arrayelt.h"
 
 /* Reach out and grab this to use as the default:
  */
index 7d958732479f90c1c618208b94bca5e3a7f2e03a..1efa74945dd73afd9f5bcc8072cfd83773fb6c51 100644 (file)
  */
 
 
-#include "api_arrayelt.h"
-#include "glheader.h"
-#include "imports.h"
-#include "context.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "dlist.h"
-#include "vtxfmt.h"
+#include "main/api_arrayelt.h"
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/dlist.h"
+#include "main/vtxfmt.h"
 
 #include "vbo_context.h"
 
index a9b01e08e6aa26a92d31691af100ce004eb1efb1..b7e8c9fe79f3bc8ee70fd5b3ddcc067705588485 100644 (file)
@@ -34,7 +34,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef __VBO_EXEC_H__
 #define __VBO_EXEC_H__
 
-#include "mtypes.h"
+#include "main/mtypes.h"
 #include "vbo.h"
 #include "vbo_attrib.h"
 
index 2d4ded0f984a2601bf5530e12921a15944d66ba6..7f56b3b62930d50be10ac8b2a053650dc590c3f2 100644 (file)
@@ -30,16 +30,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  *   Keith Whitwell <keith@tungstengraphics.com>
  */
 
-#include "glheader.h"
-#include "context.h"
-#include "macros.h"
-#include "vtxfmt.h"
-#include "dlist.h"
-#include "state.h"
-#include "light.h"
-#include "api_arrayelt.h"
-#include "api_noop.h"
-#include "dispatch.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/vtxfmt.h"
+#include "main/dlist.h"
+#include "main/state.h"
+#include "main/light.h"
+#include "main/api_arrayelt.h"
+#include "main/api_noop.h"
+#include "glapi/dispatch.h"
 
 #include "vbo_context.h"
 
index 1e4c310203beec335762ae9412326c16c5e8c6cc..77f3cf1455bc04a46f2c7d755cc1156ca85aada1 100644 (file)
  * 
  **************************************************************************/
 
-#include "glheader.h"
-#include "context.h"
-#include "state.h"
-#include "api_validate.h"
-#include "api_noop.h"
-#include "dispatch.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/state.h"
+#include "main/api_validate.h"
+#include "main/api_noop.h"
+#include "glapi/dispatch.h"
 
 #include "vbo_context.h"
 
index d8f167b3577c7a0381a1ea6c9527b4d5054ca3b7..0ef26cdfe3676fad824faf4ca997e10188c086b0 100644 (file)
  *    Keith Whitwell <keith@tungstengraphics.com>
  */
 
-#include "glheader.h"
-#include "context.h"
-#include "enums.h"
-#include "state.h"
-#include "macros.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/enums.h"
+#include "main/state.h"
+#include "main/macros.h"
 
 #include "vbo_context.h"
 
index fe533290bd18605f1072d1b0a20513b91e1d955c..0ba5585d246a9321debfb574fc50836bfe04b77e 100644 (file)
  *    Keith Whitwell <keith@tungstengraphics.com>
  */
 
-#include "glheader.h"
-#include "api_eval.h"
-#include "context.h"
-#include "macros.h"
+#include "main/glheader.h"
+#include "main/api_eval.h"
+#include "main/context.h"
+#include "main/macros.h"
 #include "math/m_eval.h"
+#include "glapi/dispatch.h"
 #include "vbo_exec.h"
-#include "dispatch.h"
 
 
 static void clear_active_eval1( struct vbo_exec_context *exec, GLuint attr ) 
index bc4211d8529f18e773d07ee40e25cb69ea38bcd9..dae778e741ee02f91fba9f42eab0eb28cf8489e6 100644 (file)
@@ -46,9 +46,9 @@
  * of zero.
  */
 
-#include "glheader.h"
-#include "imports.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
 
 #include "vbo.h"
 
index e7f46879639c4eea88c92ca07dfb4d14212836b4..87248e10f3bc30e8b5e8ec89cbefef38bf797052 100644 (file)
  */
 
 
-#include "mtypes.h"
-#include "dlist.h"
-#include "vtxfmt.h"
-#include "imports.h"
+#include "main/mtypes.h"
+#include "main/dlist.h"
+#include "main/vtxfmt.h"
+#include "main/imports.h"
 
 #include "vbo_context.h"
 
index b81f275a6029ddcb606dd50b85c67a2f6b03b675..b7e9baabf8100e8f4a22d79deaea8a3c573051f1 100644 (file)
@@ -34,7 +34,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef VBO_SAVE_H
 #define VBO_SAVE_H
 
-#include "mtypes.h"
+#include "main/mtypes.h"
 #include "vbo.h"
 #include "vbo_attrib.h"
 
index e7794c2a6ccaaf257e244eeef0363fd0eb4dda91..aded73814361e462aac8897bd68b2bf6fde48f71 100644 (file)
@@ -67,15 +67,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
 
-#include "glheader.h"
-#include "context.h"
-#include "dlist.h"
-#include "enums.h"
-#include "macros.h"
-#include "api_validate.h"
-#include "api_arrayelt.h"
-#include "vtxfmt.h"
-#include "dispatch.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/dlist.h"
+#include "main/enums.h"
+#include "main/macros.h"
+#include "main/api_validate.h"
+#include "main/api_arrayelt.h"
+#include "main/vtxfmt.h"
+#include "glapi/dispatch.h"
 
 #include "vbo_context.h"
 
index 8940551d08b1ca416a5bfeccc2a92d197a48c540..3c6f0fccd98e41c51d311f37537f65e75e1c29fe 100644 (file)
  *    Keith Whitwell <keith@tungstengraphics.com>
  */
 
-#include "glheader.h"
-#include "context.h"
-#include "imports.h"
-#include "mtypes.h"
-#include "macros.h"
-#include "light.h"
-#include "state.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/light.h"
+#include "main/state.h"
 
 #include "vbo_context.h"
 
index 430333b84dd002bfe88558df486882627bfd0f43..f2cef698fbedaab9938cfde6f0109b2029960f53 100644 (file)
 #include "swrast_setup/swrast_setup.h"
 #include "swrast/swrast.h"
 #include "tnl/tnl.h"
-#include "context.h"
+#include "main/context.h"
+#include "main/glheader.h"
+#include "main/enums.h"
+#include "main/imports.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
+#include "glapi/dispatch.h"
+#include "glapi/glapi.h"
 
 #include "vbo_context.h"
 
-#include "glheader.h"
-#include "enums.h"
-#include "glapi.h"
-#include "imports.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "dispatch.h"
 
 
 typedef void (*attr_func)( GLcontext *ctx, GLint target, const GLfloat * );
index ef205a3bb1fb47532131c6cc638eb2cc4a81f697..58e879628dea28cc2a594bae6e28fc78222258ff 100644 (file)
@@ -47,9 +47,9 @@
  * limitations on drivers which want to use it as a fallback path.
  */
 
-#include "glheader.h"
-#include "imports.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
 
 #include "vbo_split.h"
 #include "vbo.h"
index e142dde6803762c6cb85999505c31ef207e6fdfd..e5c4429350e49e99a33df34c7ad8f84b5db8ed97 100644 (file)
 /* Split indexed primitives with per-vertex copying.
  */
 
-#include "glheader.h"
-#include "imports.h"
-#include "macros.h"
-#include "enums.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/macros.h"
+#include "main/enums.h"
+#include "main/mtypes.h"
 
 #include "vbo_split.h"
 #include "vbo.h"
index ea62866e7c93fee5f66f713b2a2bf55861ec0a45..958afccd0c0a278e2c30a5288a6cc2a5f64e89a0 100644 (file)
@@ -27,9 +27,9 @@
  */
 
 
-#include "mtypes.h"
-#include "macros.h"
-#include "enums.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
+#include "main/enums.h"
 #include "vbo_split.h"