intel: Be more conservative in disabling tiling to save memory.
[mesa.git] / src / mesa / drivers / dri / intel / intel_pixel_bitmap.c
index 1727d4c1a916cd39997b1b506891705b842c5fb4..954dfc50b141b325443cd76944189699f3d2c3f0 100644 (file)
@@ -37,6 +37,7 @@
 #include "main/state.h"
 #include "main/texobj.h"
 #include "main/context.h"
+#include "main/fbobject.h"
 #include "swrast/swrast.h"
 #include "drivers/common/meta.h"
 
@@ -74,9 +75,9 @@ static const GLubyte *map_pbo( struct gl_context *ctx,
       return NULL;
    }
 
-   buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
-                                          GL_READ_ONLY_ARB,
-                                          unpack->BufferObj);
+   buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
+                                               GL_MAP_READ_BIT,
+                                               unpack->BufferObj);
    if (!buf) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)");
       return NULL;
@@ -85,7 +86,7 @@ static const GLubyte *map_pbo( struct gl_context *ctx,
    return ADD_POINTERS(buf, bitmap);
 }
 
-static GLboolean test_bit( const GLubyte *src, GLuint bit )
+static bool test_bit( const GLubyte *src, GLuint bit )
 {
    return (src[bit/8] & (1<<(bit % 8))) ? 1 : 0;
 }
@@ -105,7 +106,7 @@ static GLuint get_bitmap_rect(GLsizei width, GLsizei height,
                              GLuint w, GLuint h,
                              GLubyte *dest,
                              GLuint row_align,
-                             GLboolean invert)
+                             bool invert)
 {
    GLuint src_offset = (x + unpack->SkipPixels) & 0x7;
    GLuint mask = unpack->LsbFirst ? 0 : 7;
@@ -158,7 +159,7 @@ static GLuint get_bitmap_rect(GLsizei width, GLsizei height,
 static INLINE int
 y_flip(struct gl_framebuffer *fb, int y, int height)
 {
-   if (fb->Name != 0)
+   if (_mesa_is_user_fbo(fb))
       return y;
    else
       return fb->Height - y - height;
@@ -167,7 +168,7 @@ y_flip(struct gl_framebuffer *fb, int y, int height)
 /*
  * Render a bitmap.
  */
-static GLboolean
+static bool
 do_blit_bitmap( struct gl_context *ctx, 
                GLint dstx, GLint dsty,
                GLsizei width, GLsizei height,
@@ -195,19 +196,19 @@ do_blit_bitmap( struct gl_context *ctx,
        * It seems the blit Z coord is always 1.0 (the far plane) so fragments
        * will likely be obscured by other, closer geometry.
        */
-      return GL_FALSE;
+      return false;
    }
 
    intel_prepare_render(intel);
    dst = intel_drawbuf_region(intel);
 
    if (!dst)
-       return GL_FALSE;
+       return false;
 
    if (_mesa_is_bufferobj(unpack->BufferObj)) {
       bitmap = map_pbo(ctx, width, height, unpack, bitmap);
       if (bitmap == NULL)
-        return GL_TRUE;        /* even though this is an error, we're done */
+        return true;   /* even though this is an error, we're done */
    }
 
    COPY_4V(tmpColor, ctx->Current.RasterColor);
@@ -227,7 +228,7 @@ do_blit_bitmap( struct gl_context *ctx,
       color = PACK_COLOR_8888(ubcolor[3], ubcolor[0], ubcolor[1], ubcolor[2]);
 
    if (!intel_check_blit_fragment_ops(ctx, tmpColor[3] == 1.0F))
-      return GL_FALSE;
+      return false;
 
    /* Clip to buffer bounds and scissor. */
    if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin,
@@ -265,7 +266,7 @@ do_blit_bitmap( struct gl_context *ctx,
                             w, h,
                             (GLubyte *)stipple,
                             8,
-                            fb->Name == 0 ? GL_TRUE : GL_FALSE) == 0)
+                            _mesa_is_winsys_fbo(fb)) == 0)
            continue;
 
         if (!intelEmitImmediateColorExpandBlit(intel,
@@ -274,14 +275,14 @@ do_blit_bitmap( struct gl_context *ctx,
                                                sz,
                                                color,
                                                dst->pitch,
-                                               dst->buffer,
+                                               dst->bo,
                                                0,
                                                dst->tiling,
                                                dstx + px,
                                                dsty + py,
                                                w, h,
                                                logic_op)) {
-           return GL_FALSE;
+           return false;
         }
       }
    }
@@ -297,7 +298,7 @@ out:
 
    intel_check_front_buffer_rendering(intel);
 
-   return GL_TRUE;
+   return true;
 }
 
 
@@ -328,8 +329,6 @@ intelBitmap(struct gl_context * ctx,
            const struct gl_pixelstore_attrib *unpack,
            const GLubyte * pixels)
 {
-   struct intel_context *intel = intel_context(ctx);
-
    if (!_mesa_check_conditional_render(ctx))
       return;
 
@@ -337,9 +336,5 @@ intelBitmap(struct gl_context * ctx,
                           unpack, pixels))
       return;
 
-   /* FIXME */
-   if (intel->gen == 6)
-       return _swrast_Bitmap(ctx, x, y, width, height, unpack, pixels);
-
    _mesa_meta_Bitmap(ctx, x, y, width, height, unpack, pixels);
 }