intel: Update renderbuffers unconditionally in intelSetTexBuffer2()
[mesa.git] / src / mesa / drivers / dri / intel / intel_pixel_draw.c
index f94c6e4bc4708bd7de8b9efebdb1b0b98cb52e2d..bd1dd13fb7d058f6961e7397a9a748290a25f1e7 100644 (file)
@@ -29,8 +29,6 @@
 #include "main/enums.h"
 #include "main/image.h"
 #include "main/mtypes.h"
-#include "main/macros.h"
-#include "main/bufferobj.h"
 #include "main/teximage.h"
 #include "main/texenv.h"
 #include "main/texobj.h"
 #include "main/enable.h"
 #include "main/buffers.h"
 #include "main/fbobject.h"
-#include "main/renderbuffer.h"
 #include "main/depth.h"
 #include "main/hash.h"
 #include "main/blend.h"
-#include "main/viewport.h"
-#include "glapi/dispatch.h"
 #include "swrast/swrast.h"
 #include "drivers/common/meta.h"
 
-#include "intel_screen.h"
 #include "intel_context.h"
-#include "intel_batchbuffer.h"
-#include "intel_blit.h"
-#include "intel_buffers.h"
-#include "intel_regions.h"
 #include "intel_pixel.h"
-#include "intel_buffer_objects.h"
 #include "intel_fbo.h"
 
 
-/** XXX compare perf of this vs. _mesa_meta_draw_pixels(STENCIL) */
+/** XXX compare perf of this vs. _mesa_meta_DrawPixels(STENCIL) */
 static GLboolean
 intel_stencil_drawpixels(GLcontext * ctx,
                         GLint x, GLint y,
@@ -76,7 +65,6 @@ intel_stencil_drawpixels(GLcontext * ctx,
    GLfloat vertices[4][2];
    struct intel_renderbuffer *irb;
    struct intel_renderbuffer *depth_irb;
-   struct gl_renderbuffer *rb;
    struct gl_pixelstore_attrib old_unpack;
    GLstencil *stencil_pixels;
    int row, y1, y2;
@@ -159,7 +147,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
 
    /* Unpack the supplied stencil values into a ubyte buffer. */
    assert(sizeof(GLstencil) == sizeof(GLubyte));
-   stencil_pixels = _mesa_malloc(width * height * sizeof(GLstencil));
+   stencil_pixels = malloc(width * height * sizeof(GLstencil));
    for (row = 0; row < height; row++) {
       GLvoid *source = _mesa_image_address2d(unpack, pixels,
                                             width, height,
@@ -176,8 +164,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
     * buffer.
     */
    depth_irb = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
-   irb = intel_create_renderbuffer(GL_RGBA8);
-   rb = &irb->Base;
+   irb = intel_create_renderbuffer(MESA_FORMAT_ARGB8888);
    irb->Base.Width = depth_irb->Base.Width;
    irb->Base.Height = depth_irb->Base.Height;
    intel_renderbuffer_set_region(irb, depth_irb->region);
@@ -214,7 +201,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
    _mesa_TexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY, width, height, 0,
                    GL_RED, GL_UNSIGNED_BYTE, stencil_pixels);
    ctx->Unpack = old_unpack;
-   _mesa_free(stencil_pixels);
+   free(stencil_pixels);
 
    meta_set_passthrough_transform(&intel->meta);
 
@@ -268,10 +255,25 @@ intelDrawPixels(GLcontext * ctx,
                 const struct gl_pixelstore_attrib *unpack,
                 const GLvoid * pixels)
 {
+#if 0
+   /* XXX this function doesn't seem to work reliably even when all
+    * the pre-requisite conditions are met.
+    * Note that this function is never hit with conform.
+    * Fall back to swrast because even the _mesa_meta_DrawPixels() approach
+    * isn't working because of an apparent stencil bug.
+    */
    if (intel_stencil_drawpixels(ctx, x, y, width, height, format, type,
                                unpack, pixels))
       return;
+#else
+   (void) intel_stencil_drawpixels; /* silence warning */
+   if (format == GL_STENCIL_INDEX) {
+      _swrast_DrawPixels(ctx, x, y, width, height, format, type,
+                         unpack, pixels);
+      return;
+   }
+#endif
 
-   _mesa_meta_draw_pixels(ctx, x, y, width, height, format, type,
-                          unpack, pixels);
+   _mesa_meta_DrawPixels(ctx, x, y, width, height, format, type,
+                         unpack, pixels);
 }