[Mesa-dev] [PATCH 2/3] gallium: add fallback for copying buffers to all drivers

Marek Olšák maraeo at gmail.com
Thu Apr 21 04:11:20 PDT 2011


Just to keep drivers working.
---
 src/gallium/drivers/i915/i915_surface.c   |   15 +++++++++++++++
 src/gallium/drivers/llvmpipe/lp_surface.c |    7 +++++++
 src/gallium/drivers/nv50/nv50_surface.c   |    8 ++++++++
 src/gallium/drivers/nvc0/nvc0_surface.c   |    8 ++++++++
 src/gallium/drivers/nvfx/nvfx_surface.c   |    8 ++++++++
 src/gallium/drivers/r300/r300_blit.c      |    8 ++++++++
 src/gallium/drivers/r600/r600_blit.c      |    7 +++++++
 src/gallium/drivers/svga/svga_pipe_blit.c |    9 +++++++++
 8 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c
index d02c420..ac6e945 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -37,6 +37,7 @@
 #include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_pack_color.h"
+#include "util/u_surface.h"
 
 /*
  * surface functions using the render engine
@@ -51,6 +52,13 @@ i915_surface_copy_render(struct pipe_context *pipe,
 {
    struct i915_context *i915 = i915_context(pipe);
 
+   /* Fallback for buffers. */
+   if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
+      util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
+                                src, src_level, src_box);
+      return;
+   }
+
    util_blitter_save_blend(i915->blitter, (void *)i915->blend);
    util_blitter_save_depth_stencil_alpha(i915->blitter, (void *)i915->depth_stencil);
    util_blitter_save_stencil_ref(i915->blitter, &i915->stencil_ref);
@@ -158,6 +166,13 @@ i915_surface_copy_blitter(struct pipe_context *pipe,
    struct pipe_resource *spt = &src_tex->b.b;
    unsigned dst_offset, src_offset;  /* in bytes */
 
+   /* Fallback for buffers. */
+   if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
+      util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
+                                src, src_level, src_box);
+      return;
+   }
+
    /* XXX cannot copy 3d regions at this time */
    assert(src_box->depth == 1);
    if (dst->target != PIPE_TEXTURE_CUBE &&
diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c
index f49638a..1b5e9d0 100644
--- a/src/gallium/drivers/llvmpipe/lp_surface.c
+++ b/src/gallium/drivers/llvmpipe/lp_surface.c
@@ -67,6 +67,13 @@ lp_resource_copy(struct pipe_context *pipe,
    unsigned height = src_box->height;
    assert(src_box->depth == 1);
 
+   /* Fallback for buffers. */
+   if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
+      util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
+                                src, src_level, src_box);
+      return;
+   }
+
    llvmpipe_flush_resource(pipe,
                            dst, dst_level, dstz,
                            FALSE, /* read_only */
diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c
index dc9e288..3d7e880 100644
--- a/src/gallium/drivers/nv50/nv50_surface.c
+++ b/src/gallium/drivers/nv50/nv50_surface.c
@@ -27,6 +27,7 @@
 #include "util/u_inlines.h"
 #include "util/u_pack_color.h"
 #include "util/u_format.h"
+#include "util/u_surface.h"
 
 #include "nv50_context.h"
 #include "nv50_resource.h"
@@ -198,6 +199,13 @@ nv50_resource_copy_region(struct pipe_context *pipe,
    int ret;
    unsigned dst_layer = dstz, src_layer = src_box->z;
 
+   /* Fallback for buffers. */
+   if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
+      util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
+                                src, src_level, src_box);
+      return;
+   }
+
    assert((src->format == dst->format) ||
           (nv50_2d_format_faithful(src->format) &&
            nv50_2d_format_faithful(dst->format)));
diff --git a/src/gallium/drivers/nvc0/nvc0_surface.c b/src/gallium/drivers/nvc0/nvc0_surface.c
index fc5f45e..6be3702 100644
--- a/src/gallium/drivers/nvc0/nvc0_surface.c
+++ b/src/gallium/drivers/nvc0/nvc0_surface.c
@@ -27,6 +27,7 @@
 #include "util/u_inlines.h"
 #include "util/u_pack_color.h"
 #include "util/u_format.h"
+#include "util/u_surface.h"
 
 #include "nvc0_context.h"
 #include "nvc0_resource.h"
@@ -234,6 +235,13 @@ nvc0_resource_copy_region(struct pipe_context *pipe,
    int ret;
    unsigned dst_layer = dstz, src_layer = src_box->z;
 
+   /* Fallback for buffers. */
+   if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
+      util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
+                                src, src_level, src_box);
+      return;
+   }
+
    nv04_resource(dst)->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING;
 
    if (src->format == dst->format) {
diff --git a/src/gallium/drivers/nvfx/nvfx_surface.c b/src/gallium/drivers/nvfx/nvfx_surface.c
index be31853..ced2649 100644
--- a/src/gallium/drivers/nvfx/nvfx_surface.c
+++ b/src/gallium/drivers/nvfx/nvfx_surface.c
@@ -33,6 +33,7 @@
 #include "util/u_memory.h"
 #include "util/u_pack_color.h"
 #include "util/u_blitter.h"
+#include "util/u_surface.h"
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_screen.h"
@@ -252,6 +253,13 @@ nvfx_resource_copy_region(struct pipe_context *pipe,
 	if(!w || !h)
 		return;
 
+        /* Fallback for buffers. */
+        if (dstr->target == PIPE_BUFFER && srcr->target == PIPE_BUFFER) {
+                util_resource_copy_region(pipe, dstr, dst_level, dstx, dsty, dstz,
+                                          srcr, src_level, src_box);
+                return;
+        }
+
 	if(copy_threshold < 0)
 		copy_threshold = debug_get_num_option("NOUVEAU_COPY_THRESHOLD", 4);
 
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c
index 62d90af..1217488 100644
--- a/src/gallium/drivers/r300/r300_blit.c
+++ b/src/gallium/drivers/r300/r300_blit.c
@@ -26,6 +26,7 @@
 
 #include "util/u_format.h"
 #include "util/u_pack_color.h"
+#include "util/u_surface.h"
 
 enum r300_blitter_op /* bitmask */
 {
@@ -415,6 +416,13 @@ static void r300_resource_copy_region(struct pipe_context *pipe,
             util_format_description(dst->format);
     struct pipe_box box;
 
+    /* Fallback for buffers. */
+    if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
+        util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
+                                  src, src_level, src_box);
+        return;
+    }
+
     if (r300->zmask_in_use && !r300->hyperz_locked) {
         if (fb->zsbuf->texture == src ||
             fb->zsbuf->texture == dst) {
diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index 04408a5..151f48a 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -277,6 +277,13 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
 	struct texture_orig_info orig_info[2];
 	boolean restore_orig[2];
 
+	/* Fallback for buffers. */
+	if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
+		util_resource_copy_region(ctx, dst, dst_level, dstx, dsty, dstz,
+                                          src, src_level, src_box);
+		return;
+	}
+
 	if (rsrc->depth && !rsrc->is_flushing_texture)
 		r600_texture_depth_flush(ctx, src, FALSE);
 
diff --git a/src/gallium/drivers/svga/svga_pipe_blit.c b/src/gallium/drivers/svga/svga_pipe_blit.c
index c87afb6..c4f122f 100644
--- a/src/gallium/drivers/svga/svga_pipe_blit.c
+++ b/src/gallium/drivers/svga/svga_pipe_blit.c
@@ -29,6 +29,8 @@
 #include "svga_cmd.h"
 #include "svga_surface.h"
 
+#include "util/u_surface.h"
+
 #define FILE_DEBUG_FLAG DEBUG_BLIT
 
 
@@ -54,6 +56,13 @@ static void svga_surface_copy(struct pipe_context *pipe,
     */
    svga_surfaces_flush( svga );
 
+   /* Fallback for buffers. */
+   if (dst_tex->target == PIPE_BUFFER && src_tex->target == PIPE_BUFFER) {
+      util_resource_copy_region(pipe, dst_tex, dst_level, dstx, dsty, dstz,
+                                src_tex, src_level, src_box);
+      return;
+   }
+
 #if 0
    srcsurf = screen->get_tex_surface(screen, src_tex,
                                      src_level, src_box->z, src_box->z,
-- 
1.7.4.1



More information about the mesa-dev mailing list