gallium: Permit surface_copy and surface_fill to be NULL.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 18 Oct 2009 04:32:56 +0000 (21:32 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 18 Oct 2009 04:32:56 +0000 (21:32 -0700)
Uf. Lots of files touched. Would people with working vega, xorg, dri1, etc.
please make sure you are not broken, and fix yourself up if you are.

There were only two or three places where the code did not have painful
fallbacks, so I would advise st maintainers to find less painful workarounds,
or consider overhauling util_surface_copy and util_surface_fill.

Per ymanton, darktama, and Dr_Jakob's suggestions, clear has been left as-is.

I will not add PIPE_CAP_BLITTER unless it is deemed necessary.

14 files changed:
src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_clear.h
src/gallium/drivers/r300/r300_context.c
src/gallium/include/pipe/p_context.h
src/gallium/state_trackers/dri/dri_drawable.c
src/gallium/state_trackers/egl/egl_surface.c
src/gallium/state_trackers/vega/renderer.c
src/gallium/state_trackers/vega/vg_tracker.c
src/gallium/state_trackers/xorg/xorg_exa.c
src/gallium/state_trackers/xorg/xorg_renderer.c
src/mesa/state_tracker/st_atom_framebuffer.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_texture.c

index fb00c3abe8bfebd6462f1bd6af86909219031d8e..5038642599531044a819d1f993b7066b442998b8 100644 (file)
@@ -46,6 +46,7 @@
 #include "util/u_memory.h"
 #include "util/u_simple_shaders.h"
 #include "util/u_surface.h"
+#include "util/u_rect.h"
 
 #include "cso_cache/cso_context.h"
 
@@ -301,7 +302,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
     * no overlapping.
     * Filter mode should not matter since there's no stretching.
     */
-   if (dst->format == src->format &&
+   if (pipe->surface_copy &&
+       dst->format == src->format &&
        srcX0 < srcX1 &&
        dstX0 < dstX1 &&
        srcY0 < srcY1 &&
@@ -365,10 +367,17 @@ util_blit_pixels_writemask(struct blit_state *ctx,
                                         PIPE_BUFFER_USAGE_GPU_WRITE);
 
       /* load temp texture */
-      pipe->surface_copy(pipe,
-                         texSurf, 0, 0,   /* dest */
-                         src, srcLeft, srcTop, /* src */
-                         srcW, srcH);     /* size */
+      if (pipe->surface_copy) {
+         pipe->surface_copy(pipe,
+                            texSurf, 0, 0,   /* dest */
+                            src, srcLeft, srcTop, /* src */
+                            srcW, srcH);     /* size */
+      } else {
+         util_surface_copy(pipe, FALSE,
+                           texSurf, 0, 0,   /* dest */
+                           src, srcLeft, srcTop, /* src */
+                           srcW, srcH);     /* size */
+      }
 
       /* free the surface, update the texture if necessary.
        */
index 7c16b32cf9f280464d680fc05c73c7000323b539..1e65a035aed103fee2b886dfe732b2909c6b4ed1 100644 (file)
@@ -32,6 +32,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
 #include "util/u_pack_color.h"
+#include "util/u_rect.h"
 
 
 /**
@@ -48,13 +49,22 @@ util_clear(struct pipe_context *pipe,
       unsigned color;
 
       util_pack_color(rgba, ps->format, &color);
-      pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color);
+      if (pipe->surface_fill) {
+         pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color);
+      } else {
+         util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color);
+      }
    }
 
    if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
       struct pipe_surface *ps = framebuffer->zsbuf;
 
-      pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
-                         util_pack_z_stencil(ps->format, depth, stencil));
+      if (pipe->surface_fill) {
+         pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
+                            util_pack_z_stencil(ps->format, depth, stencil));
+      } else {
+         util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
+                           util_pack_z_stencil(ps->format, depth, stencil));
+      }
    }
 }
index 05186852008bfa84952a941c06b3e6d1505eb079..7b370b3e955fb985991eca86f3d3911b10930075 100644 (file)
@@ -206,7 +206,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
 
     r300_init_query_functions(r300);
 
-    r300_init_surface_functions(r300);
+    /* r300_init_surface_functions(r300); */
 
     r300_init_state_functions(r300);
 
index 39620a7198027dfefe846401b5b761fda5cc97be..5569001e601b12bdbd4c3fdb7e582ef64895a2fc 100644 (file)
@@ -189,6 +189,9 @@ struct pipe_context {
 
    /**
     * Surface functions
+    *
+    * The pipe driver is allowed to set these functions to NULL, and in that
+    * case, they will not be available.
     */
    /*@{*/
 
index c67cc8dacb61f60fb4d932153fe521555c999132..5625ff53cfd77096bdf7e293f1cbe7d7fe03d04c 100644 (file)
@@ -45,6 +45,7 @@
 #include "state_tracker/st_cb_fbo.h"
 
 #include "util/u_memory.h"
+#include "util/u_rect.h"
 
 static struct pipe_surface *
 dri_surface_from_handle(struct drm_api *api,
@@ -541,12 +542,21 @@ dri1_swap_copy(struct dri_context *ctx,
    cur = dPriv->pClipRects;
 
    for (i = 0; i < dPriv->numClipRects; ++i) {
-      if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox))
-        pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
-                           src,
-                           (int)clip.x1 - dPriv->x,
-                           (int)clip.y1 - dPriv->y,
-                           clip.x2 - clip.x1, clip.y2 - clip.y1);
+      if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) {
+         if (pipe->surface_copy) {
+            pipe->surface_copy(pipe, dst, clip.x1, clip.y1,
+                               src,
+                               (int)clip.x1 - dPriv->x,
+                               (int)clip.y1 - dPriv->y,
+                               clip.x2 - clip.x1, clip.y2 - clip.y1);
+         } else {
+            util_surface_copy(pipe, FALSE, dst, clip.x1, clip.y1,
+                              src,
+                              (int)clip.x1 - dPriv->x,
+                              (int)clip.y1 - dPriv->y,
+                              clip.x2 - clip.x1, clip.y2 - clip.y1);
+         }
+      }
    }
 }
 
index 7911a8834e01576c888d34332d4c7d888043f86b..71c013756d30af60c5d26cbbbed6e93d19e9b791 100644 (file)
@@ -12,6 +12,8 @@
 
 #include "state_tracker/drm_api.h"
 
+#include "util/u_rect.h"
+
 /*
  * Util functions
  */
@@ -360,12 +362,21 @@ drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
                st_notify_swapbuffers(surf->stfb);
 
                if (ctx && surf->screen) {
-                       ctx->pipe->surface_copy(ctx->pipe,
-                               surf->screen->surface,
-                               0, 0,
-                               back_surf,
-                               0, 0,
-                               surf->w, surf->h);
+            if (ctx->pipe->surface_copy) {
+                ctx->pipe->surface_copy(ctx->pipe,
+                    surf->screen->surface,
+                    0, 0,
+                    back_surf,
+                    0, 0,
+                    surf->w, surf->h);
+            } else {
+                util_surface_copy(ctx->pipe, FALSE,
+                    surf->screen->surface,
+                    0, 0,
+                    back_surf,
+                    0, 0,
+                    surf->w, surf->h);
+            }
                        ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL);
 
 #ifdef DRM_MODE_FEATURE_DIRTYFB
index f7c5f2f0cdf3f715516f6ba60d6189b2b905b67c..396c88aa3d25430aadd1927017c483b7f42152cf 100644 (file)
@@ -37,6 +37,7 @@
 #include "util/u_draw_quad.h"
 #include "util/u_simple_shaders.h"
 #include "util/u_memory.h"
+#include "util/u_rect.h"
 
 #include "cso_cache/cso_context.h"
 
@@ -457,10 +458,17 @@ void renderer_copy_surface(struct renderer *ctx,
                                      PIPE_BUFFER_USAGE_GPU_WRITE);
 
    /* load temp texture */
-   pipe->surface_copy(pipe,
-                      texSurf, 0, 0,   /* dest */
-                      src, srcLeft, srcTop, /* src */
-                      srcW, srcH);     /* size */
+   if (pipe->surface_copy) {
+      pipe->surface_copy(pipe,
+                         texSurf, 0, 0,   /* dest */
+                         src, srcLeft, srcTop, /* src */
+                         srcW, srcH);     /* size */
+   } else {
+      util_surface_copy(pipe, FALSE,
+                        texSurf, 0, 0,   /* dest */
+                        src, srcLeft, srcTop, /* src */
+                        srcW, srcH);     /* size */
+   }
 
    /* free the surface, update the texture if necessary.*/
    screen->tex_surface_destroy(texSurf);
index 56cc60aebe1889eabd775869b44291a92932565a..c4da01e52ccbb07c721b36acd1417557406a89f5 100644 (file)
@@ -235,13 +235,23 @@ static void setup_new_alpha_mask(struct vg_context *ctx,
          old_texture,
          0, 0, 0,
          PIPE_BUFFER_USAGE_GPU_READ);
-      pipe->surface_copy(pipe,
-                         surface,
-                         0, 0,
-                         old_surface,
-                         0, 0,
-                         MIN2(old_surface->width, width),
-                         MIN2(old_surface->height, height));
+      if (pipe->surface_copy) {
+         pipe->surface_copy(pipe,
+                            surface,
+                            0, 0,
+                            old_surface,
+                            0, 0,
+                            MIN2(old_surface->width, width),
+                            MIN2(old_surface->height, height));
+      } else {
+         util_surface_copy(pipe, FALSE,
+                           surface,
+                           0, 0,
+                           old_surface,
+                           0, 0,
+                           MIN2(old_surface->width, width),
+                           MIN2(old_surface->height, height));
+      }
       if (surface)
          pipe_surface_reference(&surface, NULL);
       if (old_surface)
index af76d6690f5e49a978436b95c340d10be5b3a81b..4988af48641c96a3dbbabe66ac6ed2a2cb297365 100644 (file)
@@ -693,9 +693,15 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
            dst_surf = exa->scrn->get_tex_surface(
                exa->scrn, texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
            src_surf = xorg_gpu_surface(exa->pipe->screen, priv);
-           exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
-                                   0, 0, min(width, texture->width[0]),
-                                   min(height, texture->height[0]));
+        if (exa->pipe->surface_copy) {
+            exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
+                        0, 0, min(width, texture->width[0]),
+                        min(height, texture->height[0]));
+        } else {
+            util_surface_copy(exa->pipe, FALSE, dst_surf, 0, 0, src_surf,
+                        0, 0, min(width, texture->width[0]),
+                        min(height, texture->height[0]));
+        }
            exa->scrn->tex_surface_destroy(dst_surf);
            exa->scrn->tex_surface_destroy(src_surf);
        }
index 81b209cb59649d2d575fa4ff3c46571231c30cce..ca69e1e0e92f129f7ddb21fd90142500e6a554e3 100644 (file)
@@ -7,6 +7,7 @@
 #include "util/u_draw_quad.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_rect.h"
 
 #include "pipe/p_inlines.h"
 
@@ -586,11 +587,19 @@ create_sampler_texture(struct xorg_renderer *r,
          screen, src, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
       struct pipe_surface *ps_tex = screen->get_tex_surface(
          screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE );
-      pipe->surface_copy(pipe,
-                        ps_tex, /* dest */
-                        0, 0, /* destx/y */
-                        ps_read,
-                        0, 0, src->width[0], src->height[0]);
+      if (pipe->surface_copy) {
+         pipe->surface_copy(pipe,
+                ps_tex, /* dest */
+                0, 0, /* destx/y */
+                ps_read,
+                0, 0, src->width[0], src->height[0]);
+      } else {
+          util_surface_copy(pipe, FALSE,
+                ps_tex, /* dest */
+                0, 0, /* destx/y */
+                ps_read,
+                0, 0, src->width[0], src->height[0]);
+      }
       pipe_surface_reference(&ps_read, NULL);
       pipe_surface_reference(&ps_tex, NULL);
    }
index 5209a6a0c9c668703dc87ebe52e9612a10efd452..e18c0f6e0a19b42c083600d7f2d1e1b1ac71a255 100644 (file)
@@ -39,6 +39,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
 #include "cso_cache/cso_context.h"
+#include "util/u_rect.h"
 
 
 
@@ -162,10 +163,17 @@ update_framebuffer_state( struct st_context *st )
          (void) st_get_framebuffer_surface(stfb, ST_SURFACE_FRONT_LEFT, &surf_front);
          (void) st_get_framebuffer_surface(stfb, ST_SURFACE_BACK_LEFT, &surf_back);
 
-         st->pipe->surface_copy(st->pipe,
-                                surf_front, 0, 0,  /* dest */
-                                surf_back, 0, 0,   /* src */
-                                fb->Width, fb->Height);
+         if (st->pipe->surface_copy) {
+            st->pipe->surface_copy(st->pipe,
+                                   surf_front, 0, 0,  /* dest */
+                                   surf_back, 0, 0,   /* src */
+                                   fb->Width, fb->Height);
+         } else {
+            util_surface_copy(st->pipe, FALSE,
+                              surf_front, 0, 0,
+                              surf_back, 0, 0,
+                              fb->Width, fb->Height);
+         }
       }
       /* we're assuming we'll really draw to the front buffer */
       st->frontbuffer_status = FRONT_STATUS_DIRTY;
index 5c3413f9056d7fd64edd280aeb911633bdff18a6..be445771175c6d8f5299c8eda4676281b028600e 100644 (file)
@@ -62,6 +62,7 @@
 #include "util/u_tile.h"
 #include "util/u_draw_quad.h"
 #include "util/u_math.h"
+#include "util/u_rect.h"
 #include "shader/prog_instruction.h"
 #include "cso_cache/cso_context.h"
 
@@ -1075,11 +1076,19 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
                                        PIPE_BUFFER_USAGE_GPU_READ);
       struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, 
                                       PIPE_BUFFER_USAGE_GPU_WRITE );
-      pipe->surface_copy(pipe,
-                        psTex, /* dest */
-                        0, 0, /* destx/y */
-                        psRead,
-                        srcx, srcy, width, height);
+      if (pipe->surface_copy) {
+         pipe->surface_copy(pipe,
+                            psTex, /* dest */
+                            0, 0, /* destx/y */
+                            psRead,
+                            srcx, srcy, width, height);
+      } else {
+         util_surface_copy(pipe, FALSE,
+                           psTex,
+                           0, 0,
+                           psRead,
+                           srcx, srcy, width, height);
+      }
       pipe_surface_reference(&psRead, NULL); 
       pipe_surface_reference(&psTex, NULL);
    }
index 864f5d3ca3f2617092d3489da2d4c1ff3ef4f671..73aa65955bad98d7212ee393f294dc4901a3c863 100644 (file)
@@ -49,6 +49,7 @@
 #include "st_public.h"
 #include "st_texture.h"
 
+#include "util/u_rect.h"
 
 
 /**
@@ -538,10 +539,17 @@ copy_back_to_front(struct st_context *st,
    (void) st_get_framebuffer_surface(stfb, backIndex, &surf_back);
 
    if (surf_front && surf_back) {
-      st->pipe->surface_copy(st->pipe,
-                             surf_front, 0, 0,  /* dest */
-                             surf_back, 0, 0,   /* src */
-                             fb->Width, fb->Height);
+      if (st->pipe->surface_copy) {
+         st->pipe->surface_copy(st->pipe,
+                                surf_front, 0, 0,  /* dest */
+                                surf_back, 0, 0,   /* src */
+                                fb->Width, fb->Height);
+      } else {
+         util_surface_copy(st->pipe, FALSE,
+                           surf_front, 0, 0,
+                           surf_back, 0, 0,
+                           fb->Width, fb->Height);
+      }
    }
 }
 
index b9437871063695afb264e6278ec13a2be72eeb2c..a1953342b41c3e9609a9bd0b410a21f74163fd79 100644 (file)
@@ -1546,7 +1546,8 @@ st_copy_texsubimage(GLcontext *ctx,
 
    if (ctx->_ImageTransferState == 0x0) {
 
-      if (matching_base_formats && 
+      if (pipe->surface_copy &&
+          matching_base_formats &&
           src_format == dest_format &&
           !do_flip) 
       {