[Mesa-dev] [PATCH 03/15] gallium/postprocessing: convert blits to pipe->blit

Marek Olšák maraeo at gmail.com
Fri Jul 19 08:18:13 PDT 2013


PP saves current states to cso_context and then util_blit_pixels does
the same. cso_context doesn't like that and the original state is not
correctly restored.

Cc: mesa-stable at lists.freedesktop.org
---
 src/gallium/auxiliary/postprocess/postprocess.h |  8 +++++
 src/gallium/auxiliary/postprocess/pp_init.c     | 13 -------
 src/gallium/auxiliary/postprocess/pp_mlaa.c     |  8 ++---
 src/gallium/auxiliary/postprocess/pp_program.h  |  2 --
 src/gallium/auxiliary/postprocess/pp_run.c      | 48 ++++++++++++++++++++++---
 5 files changed, 54 insertions(+), 25 deletions(-)

diff --git a/src/gallium/auxiliary/postprocess/postprocess.h b/src/gallium/auxiliary/postprocess/postprocess.h
index 52c6c75..04b6c75 100644
--- a/src/gallium/auxiliary/postprocess/postprocess.h
+++ b/src/gallium/auxiliary/postprocess/postprocess.h
@@ -77,6 +77,14 @@ void pp_debug(const char *, ...);
 struct program *pp_init_prog(struct pp_queue_t *, struct pipe_context *pipe,
                              struct cso_context *);
 void pp_init_fbos(struct pp_queue_t *, unsigned int, unsigned int);
+void pp_blit(struct pipe_context *pipe,
+             struct pipe_resource *src_tex,
+             int srcX0, int srcY0,
+             int srcX1, int srcY1,
+             int srcZ0,
+             struct pipe_surface *dst,
+             int dstX0, int dstY0,
+             int dstX1, int dstY1);
 
 /* The filters */
 
diff --git a/src/gallium/auxiliary/postprocess/pp_init.c b/src/gallium/auxiliary/postprocess/pp_init.c
index 1130248..201a357 100644
--- a/src/gallium/auxiliary/postprocess/pp_init.c
+++ b/src/gallium/auxiliary/postprocess/pp_init.c
@@ -31,7 +31,6 @@
 
 #include "pipe/p_screen.h"
 #include "util/u_inlines.h"
-#include "util/u_blit.h"
 #include "util/u_math.h"
 #include "util/u_debug.h"
 #include "util/u_memory.h"
@@ -111,13 +110,6 @@ pp_init(struct pipe_context *pipe, const unsigned int *enabled,
       }
    }
 
-   ppq->p->blitctx = util_create_blit(ppq->p->pipe, cso);
-
-   if (ppq->p->blitctx == NULL) {
-      pp_debug("Unable to create a blit context.\n");
-      goto error;
-   }
-
    ppq->n_filters = curpos;
    ppq->n_tmp = (curpos > 2 ? 2 : 1);
    ppq->n_inner_tmp = tmp_req;
@@ -180,11 +172,6 @@ pp_free(struct pp_queue_t *ppq)
    pp_free_fbos(ppq);
 
    if (ppq && ppq->p) {
-      /* Only destroy created contexts. */
-      if (ppq->p->blitctx) {
-         util_destroy_blit(ppq->p->blitctx);
-      }
-
       if (ppq->p->pipe && ppq->filters && ppq->shaders) {
          for (i = 0; i < ppq->n_filters; i++) {
             unsigned int filter = ppq->filters[i];
diff --git a/src/gallium/auxiliary/postprocess/pp_mlaa.c b/src/gallium/auxiliary/postprocess/pp_mlaa.c
index 503749b..b299c66 100644
--- a/src/gallium/auxiliary/postprocess/pp_mlaa.c
+++ b/src/gallium/auxiliary/postprocess/pp_mlaa.c
@@ -43,7 +43,6 @@
 #include "postprocess/postprocess.h"
 #include "postprocess/pp_mlaa.h"
 #include "postprocess/pp_filters.h"
-#include "util/u_blit.h"
 #include "util/u_box.h"
 #include "util/u_sampler.h"
 #include "util/u_inlines.h"
@@ -191,10 +190,9 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
    pp_filter_set_fb(p);
 
    /* Blit the input to the output */
-   util_blit_pixels(p->blitctx, in, 0, 0, 0,
-                    w, h, 0, p->framebuffer.cbufs[0],
-                    0, 0, w, h, 0, PIPE_TEX_MIPFILTER_NEAREST,
-                    TGSI_WRITEMASK_XYZW, 0);
+   pp_blit(p->pipe, in, 0, 0,
+           w, h, 0, p->framebuffer.cbufs[0],
+           0, 0, w, h);
 
    u_sampler_view_default_template(&v_tmp, in, in->format);
    arr[0] = p->pipe->create_sampler_view(p->pipe, in, &v_tmp);
diff --git a/src/gallium/auxiliary/postprocess/pp_program.h b/src/gallium/auxiliary/postprocess/pp_program.h
index 2d1804d..b7774dc 100644
--- a/src/gallium/auxiliary/postprocess/pp_program.h
+++ b/src/gallium/auxiliary/postprocess/pp_program.h
@@ -56,8 +56,6 @@ struct program
    struct pipe_resource *vbuf;
    struct pipe_surface surf;
    struct pipe_sampler_view *view;
-
-   struct blit_state *blitctx;
 };
 
 
diff --git a/src/gallium/auxiliary/postprocess/pp_run.c b/src/gallium/auxiliary/postprocess/pp_run.c
index 7c0f85c..81b538c 100644
--- a/src/gallium/auxiliary/postprocess/pp_run.c
+++ b/src/gallium/auxiliary/postprocess/pp_run.c
@@ -28,12 +28,50 @@
 #include "postprocess.h"
 
 #include "postprocess/pp_filters.h"
-#include "util/u_blit.h"
 #include "util/u_inlines.h"
 #include "util/u_sampler.h"
 
 #include "tgsi/tgsi_parse.h"
 
+void
+pp_blit(struct pipe_context *pipe,
+        struct pipe_resource *src_tex,
+        int srcX0, int srcY0,
+        int srcX1, int srcY1,
+        int srcZ0,
+        struct pipe_surface *dst,
+        int dstX0, int dstY0,
+        int dstX1, int dstY1)
+{
+   struct pipe_blit_info blit;
+
+   memset(&blit, 0, sizeof(blit));
+
+   blit.src.resource = src_tex;
+   blit.src.level = 0;
+   blit.src.format = src_tex->format;
+   blit.src.box.x = srcX0;
+   blit.src.box.y = srcY0;
+   blit.src.box.z = srcZ0;
+   blit.src.box.width = srcX1 - srcX0;
+   blit.src.box.height = srcY1 - srcY0;
+   blit.src.box.depth = 1;
+
+   blit.dst.resource = dst->texture;
+   blit.dst.level = dst->u.tex.level;
+   blit.dst.format = dst->format;
+   blit.dst.box.x = dstX0;
+   blit.dst.box.y = dstY0;
+   blit.dst.box.z = 0;
+   blit.dst.box.width = dstX1 - dstX0;
+   blit.dst.box.height = dstY1 - dstY0;
+   blit.dst.box.depth = 1;
+
+   blit.mask = PIPE_MASK_RGBA;
+
+   pipe->blit(pipe, &blit);
+}
+
 /**
 *	Main run function of the PP queue. Called on swapbuffers/flush.
 *
@@ -66,10 +104,10 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
       unsigned int w = ppq->p->framebuffer.width;
       unsigned int h = ppq->p->framebuffer.height;
 
-      util_blit_pixels(ppq->p->blitctx, in, 0, 0, 0,
-                       w, h, 0, ppq->tmps[0],
-                       0, 0, w, h, 0, PIPE_TEX_MIPFILTER_NEAREST,
-                       TGSI_WRITEMASK_XYZW, 0);
+
+      pp_blit(ppq->p->pipe, in, 0, 0,
+              w, h, 0, ppq->tmps[0],
+              0, 0, w, h);
 
       in = ppq->tmp[0];
    }
-- 
1.8.1.2



More information about the mesa-dev mailing list