Merge branch 'mesa_7_5_branch'
authorBrian Paul <brianp@vmware.com>
Wed, 5 Aug 2009 20:13:48 +0000 (14:13 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 5 Aug 2009 20:13:48 +0000 (14:13 -0600)
Conflicts:

src/mesa/main/state.c

1  2 
progs/xdemos/glxswapcontrol.c
src/mesa/drivers/dri/intel/intel_batchbuffer.c
src/mesa/main/image.c
src/mesa/state_tracker/st_extensions.c

@@@ -303,13 -303,13 +303,13 @@@ draw(void
        glDisable(GL_LIGHTING);
        glShadeModel(GL_SMOOTH);
  
 -      glEnable( GL_VERTEX_ARRAY );
 -      glEnable( GL_COLOR_ARRAY );
 +      glEnableClientState( GL_VERTEX_ARRAY );
 +      glEnableClientState( GL_COLOR_ARRAY );
        glVertexPointer( 3, GL_FLOAT, 0, vert );
        glColorPointer( 3, GL_FLOAT, 0, col );
        glDrawArrays( GL_POLYGON, 0, 4 );
 -      glDisable( GL_COLOR_ARRAY );
 -      glDisable( GL_VERTEX_ARRAY );
 +      glDisableClientState( GL_COLOR_ARRAY );
 +      glDisableClientState( GL_VERTEX_ARRAY );
  
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
@@@ -587,6 -587,9 +587,9 @@@ event_loop(Display *dpy, Window win
        angle += 2.0;
  
        draw();
+       glXSwapBuffers(dpy, win);
        if ( get_frame_usage != NULL ) {
         GLfloat   temp;
         
         frame_usage += temp;
        }
  
-       glXSwapBuffers(dpy, win);
        /* calc framerate */
        {
           static int t0 = -1;
@@@ -195,12 -195,13 +195,17 @@@ _intel_batchbuffer_flush(struct intel_b
  {
     struct intel_context *intel = batch->intel;
     GLuint used = batch->ptr - batch->map;
 -   GLboolean was_locked = intel->locked;
 +
 +   if (intel->first_post_swapbuffers_batch == NULL) {
 +      intel->first_post_swapbuffers_batch = intel->batch->buf;
 +      drm_intel_bo_reference(intel->first_post_swapbuffers_batch);
 +   }
  
+    if (intel->first_post_swapbuffers_batch == NULL) {
+       intel->first_post_swapbuffers_batch = intel->batch->buf;
+       drm_intel_bo_reference(intel->first_post_swapbuffers_batch);
+    }
     if (used == 0) {
        batch->cliprect_mode = IGNORE_CLIPRECTS;
        return;
     /* TODO: Just pass the relocation list and dma buffer up to the
      * kernel.
      */
 -   if (!was_locked)
 -      LOCK_HARDWARE(intel);
 -
 +   LOCK_HARDWARE(intel);
     do_flush_locked(batch, used, GL_FALSE);
 -
 -   if (!was_locked)
 -      UNLOCK_HARDWARE(intel);
 +   UNLOCK_HARDWARE(intel);
  
     if (INTEL_DEBUG & DEBUG_SYNC) {
        fprintf(stderr, "waiting for idle\n");
diff --combined src/mesa/main/image.c
@@@ -182,8 -182,6 +182,8 @@@ _mesa_sizeof_type( GLenum type 
         return sizeof(GLint);
        case GL_FLOAT:
         return sizeof(GLfloat);
 +      case GL_DOUBLE:
 +       return sizeof(GLdouble);
        case GL_HALF_FLOAT_ARB:
         return sizeof(GLhalfARB);
        default:
@@@ -5335,3 -5333,181 +5335,181 @@@ _mesa_clip_to_region(GLint xmin, GLint 
  
     return GL_TRUE;
  }
+ /**
+  * Clip dst coords against Xmax (or Ymax).
+  */
+ static INLINE void
+ clip_right_or_top(GLint *srcX0, GLint *srcX1,
+                   GLint *dstX0, GLint *dstX1,
+                   GLint maxValue)
+ {
+    GLfloat t, bias;
+    if (*dstX1 > maxValue) {
+       /* X1 outside right edge */
+       ASSERT(*dstX0 < maxValue); /* X0 should be inside right edge */
+       t = (GLfloat) (maxValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0);
+       /* chop off [t, 1] part */
+       ASSERT(t >= 0.0 && t <= 1.0);
+       *dstX1 = maxValue;
+       bias = (*srcX0 < *srcX1) ? 0.5 : -0.5;
+       *srcX1 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias);
+    }
+    else if (*dstX0 > maxValue) {
+       /* X0 outside right edge */
+       ASSERT(*dstX1 < maxValue); /* X1 should be inside right edge */
+       t = (GLfloat) (maxValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1);
+       /* chop off [t, 1] part */
+       ASSERT(t >= 0.0 && t <= 1.0);
+       *dstX0 = maxValue;
+       bias = (*srcX0 < *srcX1) ? -0.5 : 0.5;
+       *srcX0 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias);
+    }
+ }
+ /**
+  * Clip dst coords against Xmin (or Ymin).
+  */
+ static INLINE void
+ clip_left_or_bottom(GLint *srcX0, GLint *srcX1,
+                     GLint *dstX0, GLint *dstX1,
+                     GLint minValue)
+ {
+    GLfloat t, bias;
+    if (*dstX0 < minValue) {
+       /* X0 outside left edge */
+       ASSERT(*dstX1 > minValue); /* X1 should be inside left edge */
+       t = (GLfloat) (minValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0);
+       /* chop off [0, t] part */
+       ASSERT(t >= 0.0 && t <= 1.0);
+       *dstX0 = minValue;
+       bias = (*srcX0 < *srcX1) ? 0.5 : -0.5; /* flipped??? */
+       *srcX0 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias);
+    }
+    else if (*dstX1 < minValue) {
+       /* X1 outside left edge */
+       ASSERT(*dstX0 > minValue); /* X0 should be inside left edge */
+       t = (GLfloat) (minValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1);
+       /* chop off [0, t] part */
+       ASSERT(t >= 0.0 && t <= 1.0);
+       *dstX1 = minValue;
+       bias = (*srcX0 < *srcX1) ? 0.5 : -0.5;
+       *srcX1 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias);
+    }
+ }
+ /**
+  * Do clipping of blit src/dest rectangles.
+  * The dest rect is clipped against both the buffer bounds and scissor bounds.
+  * The src rect is just clipped against the buffer bounds.
+  *
+  * When either the src or dest rect is clipped, the other is also clipped
+  * proportionately!
+  *
+  * Note that X0 need not be less than X1 (same for Y) for either the source
+  * and dest rects.  That makes the clipping a little trickier.
+  *
+  * \return GL_TRUE if anything is left to draw, GL_FALSE if totally clipped
+  */
+ GLboolean
+ _mesa_clip_blit(GLcontext *ctx,
+                 GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1,
+                 GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1)
+ {
+    const GLint srcXmin = 0;
+    const GLint srcXmax = ctx->ReadBuffer->Width;
+    const GLint srcYmin = 0;
+    const GLint srcYmax = ctx->ReadBuffer->Height;
+    /* these include scissor bounds */
+    const GLint dstXmin = ctx->DrawBuffer->_Xmin;
+    const GLint dstXmax = ctx->DrawBuffer->_Xmax;
+    const GLint dstYmin = ctx->DrawBuffer->_Ymin;
+    const GLint dstYmax = ctx->DrawBuffer->_Ymax;
+    /*
+    printf("PreClipX:  src: %d .. %d  dst: %d .. %d\n",
+           *srcX0, *srcX1, *dstX0, *dstX1);
+    printf("PreClipY:  src: %d .. %d  dst: %d .. %d\n",
+           *srcY0, *srcY1, *dstY0, *dstY1);
+    */
+    /* trivial rejection tests */
+    if (*dstX0 == *dstX1)
+       return GL_FALSE; /* no width */
+    if (*dstX0 <= dstXmin && *dstX1 <= dstXmin)
+       return GL_FALSE; /* totally out (left) of bounds */
+    if (*dstX0 >= dstXmax && *dstX1 >= dstXmax)
+       return GL_FALSE; /* totally out (right) of bounds */
+    if (*dstY0 == *dstY1)
+       return GL_FALSE;
+    if (*dstY0 <= dstYmin && *dstY1 <= dstYmin)
+       return GL_FALSE;
+    if (*dstY0 >= dstYmax && *dstY1 >= dstYmax)
+       return GL_FALSE;
+    if (*srcX0 == *srcX1)
+       return GL_FALSE;
+    if (*srcX0 <= srcXmin && *srcX1 <= srcXmin)
+       return GL_FALSE;
+    if (*srcX0 >= srcXmax && *srcX1 >= srcXmax)
+       return GL_FALSE;
+    if (*srcY0 == *srcY1)
+       return GL_FALSE;
+    if (*srcY0 <= srcYmin && *srcY1 <= srcYmin)
+       return GL_FALSE;
+    if (*srcY0 >= srcYmax && *srcY1 >= srcYmax)
+       return GL_FALSE;
+    /*
+     * dest clip
+     */
+    clip_right_or_top(srcX0, srcX1, dstX0, dstX1, dstXmax);
+    clip_right_or_top(srcY0, srcY1, dstY0, dstY1, dstYmax);
+    clip_left_or_bottom(srcX0, srcX1, dstX0, dstX1, dstXmin);
+    clip_left_or_bottom(srcY0, srcY1, dstY0, dstY1, dstYmin);
+    /*
+     * src clip (just swap src/dst values from above)
+     */
+    clip_right_or_top(dstX0, dstX1, srcX0, srcX1, srcXmax);
+    clip_right_or_top(dstY0, dstY1, srcY0, srcY1, srcYmax);
+    clip_left_or_bottom(dstX0, dstX1, srcX0, srcX1, srcXmin);
+    clip_left_or_bottom(dstY0, dstY1, srcY0, srcY1, srcYmin);
+    /*
+    printf("PostClipX: src: %d .. %d  dst: %d .. %d\n",
+           *srcX0, *srcX1, *dstX0, *dstX1);
+    printf("PostClipY: src: %d .. %d  dst: %d .. %d\n",
+           *srcY0, *srcY1, *dstY0, *dstY1);
+    */
+    ASSERT(*dstX0 >= dstXmin);
+    ASSERT(*dstX0 <= dstXmax);
+    ASSERT(*dstX1 >= dstXmin);
+    ASSERT(*dstX1 <= dstXmax);
+    ASSERT(*dstY0 >= dstYmin);
+    ASSERT(*dstY0 <= dstYmax);
+    ASSERT(*dstY1 >= dstYmin);
+    ASSERT(*dstY1 <= dstYmax);
+    ASSERT(*srcX0 >= srcXmin);
+    ASSERT(*srcX0 <= srcXmax);
+    ASSERT(*srcX1 >= srcXmin);
+    ASSERT(*srcX1 <= srcXmax);
+    ASSERT(*srcY0 >= srcYmin);
+    ASSERT(*srcY0 <= srcYmax);
+    ASSERT(*srcY1 >= srcYmin);
+    ASSERT(*srcY1 <= srcYmax);
+    return GL_TRUE;
+ }
@@@ -143,21 -143,19 +143,21 @@@ void st_init_extensions(struct st_conte
     /*
      * Extensions that are supported by all Gallium drivers:
      */
 -   ctx->Extensions.ARB_multisample = GL_TRUE;
 +   ctx->Extensions.ARB_copy_buffer = GL_TRUE;
     ctx->Extensions.ARB_fragment_program = GL_TRUE;
 +   ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
 +   ctx->Extensions.ARB_multisample = GL_TRUE;
     ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */
     ctx->Extensions.ARB_texture_compression = GL_TRUE;
     ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
     ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
     ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
     ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
 -   ctx->Extensions.ARB_vertex_program = GL_TRUE;
 +   ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
     ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;
 +   ctx->Extensions.ARB_vertex_program = GL_TRUE;
  
     ctx->Extensions.EXT_blend_color = GL_TRUE;
 -   ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
     ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
     ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
     ctx->Extensions.EXT_blend_minmax = GL_TRUE;
     ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
     ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
     ctx->Extensions.EXT_point_parameters = GL_TRUE;
 +   ctx->Extensions.EXT_provoking_vertex = GL_TRUE;
     ctx->Extensions.EXT_secondary_color = GL_TRUE;
     ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
     ctx->Extensions.EXT_texture_env_add = GL_TRUE;
     ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
     ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
     ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
 +   ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
 +
 +   ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
  
     ctx->Extensions.NV_blend_square = GL_TRUE;
     ctx->Extensions.NV_texgen_reflection = GL_TRUE;
 +   ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
  
     ctx->Extensions.SGI_color_matrix = GL_TRUE;
     ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
        ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
     }
  
 +   if (screen->get_param(screen, PIPE_CAP_BLEND_EQUATION_SEPARATE)) {
 +      ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
 +   }
 +
     if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_CLAMP) > 0) {
        ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
     }
  
     if (screen->get_param(screen, PIPE_CAP_POINT_SPRITE)) {
        ctx->Extensions.ARB_point_sprite = GL_TRUE;
-       ctx->Extensions.NV_point_sprite = GL_TRUE;
+       /* GL_NV_point_sprite is not supported by gallium because we don't
+        * support the GL_POINT_SPRITE_R_MODE_NV option.
+        */
     }
  
     if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) {
                                     PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
        ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
     }
 +
 +   /* GL_ARB_framebuffer_object */
 +   if (ctx->Extensions.EXT_packed_depth_stencil) {
 +      /* we support always support GL_EXT_framebuffer_blit */
 +      ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
 +   }
  }