Merge branch 'mesa_7_5_branch'
authorBrian Paul <brianp@vmware.com>
Thu, 4 Jun 2009 19:16:13 +0000 (13:16 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 4 Jun 2009 19:16:13 +0000 (13:16 -0600)
Conflicts:

src/mesa/main/context.c

17 files changed:
common.py
progs/trivial/tri-z.c
progs/vpglsl/psiz-imm.glsl [new file with mode: 0644]
progs/vpglsl/psiz-mul.glsl [new file with mode: 0644]
progs/vpglsl/vp-tris.c
progs/wgl/wglinfo.c
scons/gallium.py
src/gallium/auxiliary/draw/draw_pipe_aaline.c
src/gallium/auxiliary/draw/draw_pipe_aapoint.c
src/gallium/auxiliary/draw/draw_pipe_pstipple.c
src/gallium/auxiliary/tgsi/tgsi_exec.h
src/gallium/auxiliary/util/u_tile.c
src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
src/mesa/main/context.c
src/mesa/main/mfeatures.h
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_program.c

index e57429e..a687efc 100644 (file)
--- a/common.py
+++ b/common.py
@@ -55,7 +55,7 @@ def AddOptions(opts):
                from SCons.Options.EnumOption import EnumOption
        opts.Add(BoolOption('debug', 'debug build', 'no'))
        opts.Add(BoolOption('profile', 'profile build', 'no'))
-       #opts.Add(BoolOption('quiet', 'quiet command lines', 'no'))
+       opts.Add(BoolOption('quiet', 'quiet command lines', 'yes'))
        opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
                                                                                         allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
        opts.Add(EnumOption('platform', 'target platform', default_platform,
index 335d2b9..014aaa0 100644 (file)
@@ -57,13 +57,19 @@ static struct { GLenum func; const char *str; } funcs[] =
 
 static int curFunc = 0;
 static double clearVal = 1.0;
-
+static float minZ = 0.0;
+static float maxZ = 1.0;
 
 static void usage(void)
 {
-   printf("t - toggle rendering order of triangles\n");
-   printf("c - toggle Z clear value between 0, 1\n");
-   printf("f - cycle through depth test functions\n");
+   printf("t   - toggle rendering order of triangles\n");
+   printf("c   - toggle Z clear value between 0, 1\n");
+   printf("f   - cycle through depth test functions\n");
+   printf("n/N - decrease/increase depthrange minZ\n");
+   printf("x/X - decrease/increase depthrange maxZ\n");
+   printf("spc - reset\n");
+   printf("z   - set to reverse-direction (ztrick) mode\n");
+   fflush(stdout);
 }
 
 
@@ -97,9 +103,11 @@ static void drawRightTriangle(void)
 
 void display(void)
 {
-   printf("GL_CLEAR_DEPTH = %f  GL_DEPTH_FUNC = %s\n",
-          clearVal, funcs[curFunc].str);
+   printf("GL_CLEAR_DEPTH = %.2f,  GL_DEPTH_FUNC = %s,  DepthRange(%.1f, %.1f)\n",
+          clearVal, funcs[curFunc].str, minZ, maxZ);
+   fflush(stdout);
    glClearDepth(clearVal);
+   glDepthRange(minZ, maxZ);
    glDepthFunc(funcs[curFunc].func);
 
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -131,27 +139,49 @@ void reshape(int w, int h)
 void keyboard(unsigned char key, int x, int y)
 {
    switch (key) {
+      case 'n':
+         minZ -= .1;
+         break;
+      case 'N':
+         minZ += .1;
+         break;
+      case 'x':
+         maxZ -= .1;
+         break;
+      case 'X':
+         maxZ += .1;
+         break;
       case 'c':
       case 'C':
          clearVal = 1.0 - clearVal;
-         glutPostRedisplay();  
          break;
       case 'f':
       case 'F':
          curFunc = (curFunc + 1) % NUM_FUNCS;
-         glutPostRedisplay();  
          break;
       case 't':
       case 'T':
          leftFirst = !leftFirst;
-         glutPostRedisplay();  
+         break;
+      case ' ':
+         curFunc = 0;
+         clearVal = 1.0;
+         minZ = 0.0;
+         maxZ = 1.0;
+         break;
+      case 'z':
+         curFunc = 2;
+         clearVal = 0.0;
+         minZ = 1.0;
+         maxZ = 0.0;
          break;
       case 27:  /*  Escape key  */
          exit(0);
          break;
       default:
-         break;
+         return;
    }
+   glutPostRedisplay();        
 }
 
 /*  Main Loop
diff --git a/progs/vpglsl/psiz-imm.glsl b/progs/vpglsl/psiz-imm.glsl
new file mode 100644 (file)
index 0000000..101d314
--- /dev/null
@@ -0,0 +1,6 @@
+
+void main() {
+    gl_FrontColor = gl_Color;
+    gl_PointSize = 2.0;
+    gl_Position = gl_Vertex;
+}
diff --git a/progs/vpglsl/psiz-mul.glsl b/progs/vpglsl/psiz-mul.glsl
new file mode 100644 (file)
index 0000000..77f4a46
--- /dev/null
@@ -0,0 +1,6 @@
+
+void main() {
+    gl_FrontColor = gl_Color;
+    gl_PointSize = 10 * gl_Color.x;
+    gl_Position = gl_Vertex;
+}
index 9ae410b..b2b0508 100644 (file)
 
 static const char *filename = NULL;
 static GLuint nr_steps = 4;
+static GLuint prim = GL_TRIANGLES;
+static GLfloat psz = 1.0;
+static GLboolean pointsmooth = 0;
+static GLboolean program_point_size = 0;
 
 static GLuint fragShader;
 static GLuint vertShader;
@@ -229,6 +233,14 @@ static void subdiv( union vert *v0,
    }
 }
 
+static void enable( GLenum value, GLboolean flag )
+{
+   if (flag)
+      glEnable(value);
+   else
+      glDisable(value);
+}
+
 /** Assignment */
 #define ASSIGN_3V( V, V0, V1, V2 )  \
 do {                                \
@@ -241,10 +253,13 @@ static void Display( void )
 {
    glClearColor(0.3, 0.3, 0.3, 1);
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+   glPointSize(psz);
 
    glUseProgram(program);
+   enable( GL_POINT_SMOOTH, pointsmooth );
+   enable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB, program_point_size );
 
-   glBegin(GL_TRIANGLES);
+   glBegin(prim);
 
 
    {
@@ -291,10 +306,41 @@ static void Key( unsigned char key, int x, int y )
    (void) x;
    (void) y;
    switch (key) {
-      case 27:
-         CleanUp();
-         exit(0);
-         break;
+   case 'p':
+      prim = GL_POINTS;
+      break;
+   case 't':
+      prim = GL_TRIANGLES;
+      break;
+   case 's':
+      psz += .5;
+      break;
+   case 'S':
+      if (psz > .5)
+         psz -= .5;
+      break;
+   case 'm':
+      pointsmooth = !pointsmooth;
+      break;
+   case 'z':
+      program_point_size = !program_point_size;
+      break;
+   case '+':
+      nr_steps++;
+      break; 
+   case '-':
+      if (nr_steps) 
+         nr_steps--;
+      break;
+   case ' ':
+      psz = 1.0;
+      prim = GL_TRIANGLES;
+      nr_steps = 4;
+      break;
+   case 27:
+      CleanUp();
+      exit(0);
+      break;
    }
    glutPostRedisplay();
 }
@@ -305,7 +351,7 @@ int main( int argc, char *argv[] )
    glutInitWindowPosition( 0, 0 );
    glutInitWindowSize( 250, 250 );
    glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH );
-   glutCreateWindow(argv[0]);
+   glutCreateWindow(argv[argc-1]);
    glewInit();
    glutReshapeFunc( Reshape );
    glutKeyboardFunc( Key );
index 881d35b..864372c 100644 (file)
@@ -348,7 +348,6 @@ print_screen_info(HDC _hdc, GLboolean limits)
    HWND win;
    HGLRC ctx;
    int visinfo;
-   int width = 100, height = 100;
    HDC hdc;
    PIXELFORMATDESCRIPTOR pfd;
 
@@ -364,18 +363,18 @@ print_screen_info(HDC _hdc, GLboolean limits)
    win = CreateWindowEx(0,
                         wc.lpszClassName,
                         "wglinfo",
-                        WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+                        WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+                        CW_USEDEFAULT,
+                        CW_USEDEFAULT,
                         CW_USEDEFAULT,
                         CW_USEDEFAULT,
-                        width,
-                        height,
                         NULL,
                         NULL,
                         wc.hInstance,
                         NULL);
    if (!win) {
       fprintf(stderr, "Couldn't create window");
-      exit(1);
+      return;
    }
 
    hdc = GetDC(win);
@@ -476,7 +475,7 @@ print_visual_attribs_verbose(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
           ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0);
    printf("    bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
           0 /* ppfd->bufferSize */, 0 /* ppfd->level */,
-         visual_render_type_name(ppfd->dwFlags),
+         visual_render_type_name(ppfd->iPixelType),
           ppfd->dwFlags & PFD_DOUBLEBUFFER ? 1 : 0, 
           ppfd->dwFlags & PFD_STEREO ? 1 : 0);
    printf("    rgba: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",
index c7e74d7..0d58436 100644 (file)
@@ -42,11 +42,17 @@ import SCons.Scanner
 def quietCommandLines(env):
     # Quiet command lines
     # See also http://www.scons.org/wiki/HidingCommandLinesInOutput
+    env['ASCOMSTR'] = "Assembling $SOURCE ..."
     env['CCCOMSTR'] = "Compiling $SOURCE ..."
+    env['SHCCCOMSTR'] = "Compiling $SOURCE ..."
     env['CXXCOMSTR'] = "Compiling $SOURCE ..."
+    env['SHCXXCOMSTR'] = "Compiling $SOURCE ..."
     env['ARCOMSTR'] = "Archiving $TARGET ..."
-    env['RANLIBCOMSTR'] = ""
+    env['RANLIBCOMSTR'] = "Indexing $TARGET ..."
     env['LINKCOMSTR'] = "Linking $TARGET ..."
+    env['SHLINKCOMSTR'] = "Linking $TARGET ..."
+    env['LDMODULECOMSTR'] = "Linking $TARGET ..."
+    env['SWIGCOMSTR'] = "Generating $TARGET ..."
 
 
 def createConvenienceLibBuilder(env):
@@ -185,9 +191,8 @@ def num_jobs():
 def generate(env):
     """Common environment generation code"""
 
-    # FIXME: this is already too late
-    #if env.get('quiet', False):
-    #    quietCommandLines(env)
+    if env.get('quiet', True):
+        quietCommandLines(env)
 
     # Toolchain
     platform = env['platform']
@@ -357,11 +362,24 @@ def generate(env):
               '/GL-', # disable whole program optimization
             ]
         else:
+            if env['machine'] == 'x86_64':
+                cflags += [
+                    # Same as /O2, but without global optimizations or auto-inlining
+                    # http://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx
+                    '/Ob1', # enable inline expansion, disable auto-inlining
+                    '/Oi', # enable intrinsic functions
+                    '/Ot', # favors fast code
+                    '/Oy', # omit frame pointer
+                    '/Gs', # enable stack probes
+                    '/GF', # eliminate duplicate strings
+                    '/Gy', # enable function-level linking
+                ]
+            else:
+                cflags += [
+                    '/O2', # optimize for speed
+                ]
             cflags += [
-              '/Ox', # maximum optimizations
-              '/Oi', # enable intrinsic functions
-              '/Ot', # favor code speed
-              #'/fp:fast', # fast floating point 
+                #'/fp:fast', # fast floating point 
             ]
         if env['profile']:
             cflags += [
index 9fedeef..9f95671 100644 (file)
@@ -60,8 +60,6 @@ struct aaline_fragment_shader
    struct pipe_shader_state state;
    void *driver_fs;
    void *aaline_fs;
-   void *aapoint_fs; /* not yet */
-   void *sprite_fs; /* not yet */
    uint sampler_unit;
    int generic_attrib;  /**< texcoord/generic used for texture */
 };
@@ -373,10 +371,15 @@ generate_aaline_fs(struct aaline_stage *aaline)
    aaline->fs->aaline_fs
       = aaline->driver_create_fs_state(aaline->pipe, &aaline_fs);
    if (aaline->fs->aaline_fs == NULL)
-      return FALSE;
+      goto fail;
 
    aaline->fs->generic_attrib = transform.maxGeneric + 1;
+   FREE((void *)aaline_fs.tokens);
    return TRUE;
+
+fail:
+   FREE((void *)aaline_fs.tokens);
+   return FALSE;
 }
 
 
@@ -816,6 +819,10 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs)
    struct aaline_fragment_shader *aafs = (struct aaline_fragment_shader *) fs;
    /* pass-through */
    aaline->driver_delete_fs_state(aaline->pipe, aafs->driver_fs);
+
+   if (aafs->aaline_fs)
+      aaline->driver_delete_fs_state(aaline->pipe, aafs->aaline_fs);
+
    FREE(aafs);
 }
 
index 66839f7..ae1712f 100644 (file)
@@ -523,11 +523,15 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
    aapoint->fs->aapoint_fs
       = aapoint->driver_create_fs_state(aapoint->pipe, &aapoint_fs);
    if (aapoint->fs->aapoint_fs == NULL)
-      return FALSE;
+      goto fail;
 
    aapoint->fs->generic_attrib = transform.maxGeneric + 1;
-
+   FREE((void *)aapoint_fs.tokens);
    return TRUE;
+
+fail:
+   FREE((void *)aapoint_fs.tokens);
+   return FALSE;
 }
 
 
@@ -825,8 +829,13 @@ aapoint_delete_fs_state(struct pipe_context *pipe, void *fs)
 {
    struct aapoint_stage *aapoint = aapoint_stage_from_pipe(pipe);
    struct aapoint_fragment_shader *aafs = (struct aapoint_fragment_shader *) fs;
+
    /* pass-through */
    aapoint->driver_delete_fs_state(aapoint->pipe, aafs->driver_fs);
+
+   if (aafs->aapoint_fs)
+      aapoint->driver_delete_fs_state(aapoint->pipe, aafs->aapoint_fs);
+
    FREE(aafs);
 }
 
index 9287fc1..30a6d29 100644 (file)
@@ -358,6 +358,7 @@ generate_pstip_fs(struct pstip_stage *pstip)
 
    pstip->fs->pstip_fs = pstip->driver_create_fs_state(pstip->pipe, &pstip_fs);
 
+   FREE((void *)pstip_fs.tokens);
    return TRUE;
 }
 
@@ -649,6 +650,10 @@ pstip_delete_fs_state(struct pipe_context *pipe, void *fs)
    struct pstip_fragment_shader *aafs = (struct pstip_fragment_shader *) fs;
    /* pass-through */
    pstip->driver_delete_fs_state(pstip->pipe, aafs->driver_fs);
+
+   if (aafs->pstip_fs)
+      pstip->driver_delete_fs_state(pstip->pipe, aafs->pstip_fs);
+
    FREE(aafs);
 }
 
index 0b4b2a6..da22baa 100644 (file)
@@ -34,7 +34,7 @@
 extern "C" {
 #endif
 
-#define MAX_LABELS 1024
+#define MAX_LABELS (4 * 1024)  /**< basically, max instructions */
 
 #define NUM_CHANNELS 4  /* R,G,B,A */
 #define QUAD_SIZE    4  /* 4 pixel/quad */
index f0a5a33..9747a55 100644 (file)
@@ -1126,7 +1126,22 @@ pipe_get_tile_z(struct pipe_transfer *pt,
          for (i = 0; i < h; i++) {
             for (j = 0; j < w; j++) {
                /* convert 24-bit Z to 32-bit Z */
-               pDest[j] = (ptrc[j] << 8) | (ptrc[j] & 0xff);
+               pDest[j] = (ptrc[j] << 8) | ((ptrc[j] >> 16) & 0xff);
+            }
+            pDest += dstStride;
+            ptrc += pt->stride/4;
+         }
+      }
+      break;
+   case PIPE_FORMAT_Z24S8_UNORM:
+   case PIPE_FORMAT_Z24X8_UNORM:
+      {
+         const uint *ptrc
+            = (const uint *)(map + y * pt->stride + x*4);
+         for (i = 0; i < h; i++) {
+            for (j = 0; j < w; j++) {
+               /* convert 24-bit Z to 32-bit Z */
+               pDest[j] = (ptrc[j] & 0xffffff00) | ((ptrc[j] >> 24) & 0xff);
             }
             pDest += dstStride;
             ptrc += pt->stride/4;
index 768cef3..de37d13 100644 (file)
 #include "stw_tls.h"
 
 
+struct stw_framebuffer *
+stw_framebuffer_from_hwnd_locked(
+   HWND hwnd )
+{
+   struct stw_framebuffer *fb;
+
+   for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
+      if (fb->hWnd == hwnd)
+         break;
+
+   return fb;
+}
+
+
+static INLINE void
+stw_framebuffer_destroy_locked(
+   struct stw_framebuffer *fb )
+{
+   struct stw_framebuffer **link;
+
+   link = &stw_dev->fb_head;
+   while (*link != fb)
+      link = &(*link)->next;
+   assert(*link);
+   *link = fb->next;
+   fb->next = NULL;
+
+   st_unreference_framebuffer(fb->stfb);
+   
+   pipe_mutex_destroy( fb->mutex );
+   
+   FREE( fb );
+}
+
+
 /**
  * @sa http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx
  * @sa http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx
@@ -69,9 +104,7 @@ stw_call_window_proc(
       struct stw_framebuffer *fb;
 
       pipe_mutex_lock( stw_dev->mutex );
-      for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
-         if (fb->hWnd == pParams->hwnd)
-            break;
+      fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
       pipe_mutex_unlock( stw_dev->mutex );
       
       if(fb) {
@@ -90,6 +123,18 @@ stw_call_window_proc(
       }
    }
 
+   if (pParams->message == WM_DESTROY) {
+      struct stw_framebuffer *fb;
+
+      pipe_mutex_lock( stw_dev->mutex );
+      
+      fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
+      if(fb)
+         stw_framebuffer_destroy_locked(fb);
+      
+      pipe_mutex_unlock( stw_dev->mutex );
+   }
+
    return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
 }
 
@@ -212,27 +257,6 @@ stw_framebuffer_resize(
 }                      
 
 
-static INLINE void
-stw_framebuffer_destroy_locked(
-   struct stw_framebuffer *fb )
-{
-   struct stw_framebuffer **link;
-
-   link = &stw_dev->fb_head;
-   while (*link != fb)
-      link = &(*link)->next;
-   assert(*link);
-   *link = fb->next;
-   fb->next = NULL;
-
-   st_unreference_framebuffer(fb->stfb);
-   
-   pipe_mutex_destroy( fb->mutex );
-   
-   FREE( fb );
-}
-
-
 void
 stw_framebuffer_cleanup( void )
 {
index ad47e22..bf53bd3 100644 (file)
@@ -1011,6 +1011,16 @@ _mesa_free_context_data( GLcontext *ctx )
 
    _mesa_delete_array_object(ctx, ctx->Array.DefaultArrayObj);
 
+#if FEATURE_ARB_pixel_buffer_object
+   _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, NULL);
+   _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, NULL);
+#endif
+
+#if FEATURE_ARB_vertex_buffer_object
+   _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL);
+   _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, NULL);
+#endif
+
    /* free dispatch tables */
    _mesa_free(ctx->Exec);
    _mesa_free(ctx->Save);
index f570647..62c3ead 100644 (file)
@@ -61,6 +61,7 @@
 #define FEATURE_ARB_occlusion_query  _HAVE_FULL_GL
 #define FEATURE_ARB_fragment_program  _HAVE_FULL_GL
 #define FEATURE_ARB_framebuffer_object  _HAVE_FULL_GL
+#define FEATURE_ARB_pixel_buffer_object  _HAVE_FULL_GL
 #define FEATURE_ARB_vertex_buffer_object  _HAVE_FULL_GL
 #define FEATURE_ARB_vertex_program  _HAVE_FULL_GL
 #define FEATURE_ARB_vertex_shader _HAVE_FULL_GL
index b182106..14b78d1 100644 (file)
@@ -673,7 +673,7 @@ st_TexImage(GLcontext * ctx,
                                    PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
       if (compress_with_blit(ctx, target, level, 0, 0, 0, width, height, depth,
                              format, type, pixels, unpack, texImage)) {
-         return;
+         goto done;
       }
    }
 
@@ -750,6 +750,7 @@ st_TexImage(GLcontext * ctx,
 
    _mesa_unmap_teximage_pbo(ctx, unpack);
 
+done:
    if (stImage->pt && texImage->Data) {
       st_texture_image_unmap(ctx->st, stImage);
       texImage->Data = NULL;
@@ -1061,7 +1062,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
                              xoffset, yoffset, zoffset,
                              width, height, depth,
                              format, type, pixels, packing, texImage)) {
-         return;
+         goto done;
       }
    }
 
@@ -1110,16 +1111,17 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
       }
    }
 
-   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      ctx->Driver.GenerateMipmap(ctx, target, texObj);
-   }
-
    _mesa_unmap_teximage_pbo(ctx, packing);
 
+done:
    if (stImage->pt) {
       st_texture_image_unmap(ctx->st, stImage);
       texImage->Data = NULL;
    }
+
+   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+      ctx->Driver.GenerateMipmap(ctx, target, texObj);
+   }
 }
 
 
@@ -1315,6 +1317,9 @@ st_copy_texsubimage(GLcontext *ctx,
    GLboolean use_fallback = GL_TRUE;
    GLboolean matching_base_formats;
 
+   /* any rendering in progress must flushed before we grab the fb image */
+   st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+
    /* make sure finalize_textures has been called? 
     */
    if (0) st_validate_state(ctx->st);
index 6ec633c..3492610 100644 (file)
@@ -49,7 +49,7 @@
 #include "cso_cache/cso_context.h"
 
 
-#define ST_MAX_SHADER_TOKENS 4096
+#define ST_MAX_SHADER_TOKENS (8 * 1024)
 
 
 #define TGSI_DEBUG 0