Module: Mesa
Branch: nvfx-next-6
Commit: 6f0467324d5990859b494ac38533d927dfa7c6c3
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f0467324d5990859b494ac38533d927dfa7c6c3

Author: Luca Barbieri <[email protected]>
Date:   Wed Mar 17 21:59:14 2010 +0100

nvfx: new 2D: add u_blitter support

Add support for surface_copy and surface_flip using the 3D engine,
reusing the u_blitter module created for r300.

This is used for unswizzling and copies between swizzled surfaces.

---

 src/gallium/drivers/nvfx/nvfx_context.h |    2 +
 src/gallium/drivers/nvfx/nvfx_surface.c |   41 +++++++++++++++++++++++++-----
 2 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/nvfx/nvfx_context.h 
b/src/gallium/drivers/nvfx/nvfx_context.h
index 3acdd7a..d379e6a 100644
--- a/src/gallium/drivers/nvfx/nvfx_context.h
+++ b/src/gallium/drivers/nvfx/nvfx_context.h
@@ -14,6 +14,7 @@
 #include "util/u_double_list.h"
 
 #include "draw/draw_vertex.h"
+#include "util/u_blitter.h"
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
@@ -91,6 +92,7 @@ struct nvfx_context {
        unsigned is_nv4x; /* either 0 or ~0 */
 
        struct draw_context *draw;
+       struct blitter_context* blitter;
        struct list_head render_cache;
 
        /* HW state derived from pipe states */
diff --git a/src/gallium/drivers/nvfx/nvfx_surface.c 
b/src/gallium/drivers/nvfx/nvfx_surface.c
index 62f308d..44df192 100644
--- a/src/gallium/drivers/nvfx/nvfx_surface.c
+++ b/src/gallium/drivers/nvfx/nvfx_surface.c
@@ -118,6 +118,36 @@ nv04_scaled_image_format(enum pipe_format format)
        }
 }
 
+static struct blitter_context*
+nvfx_get_blitter(struct pipe_context* pipe, int copy)
+{
+       struct nvfx_context* nvfx = nvfx_context(pipe);
+
+       struct blitter_context* blitter = nvfx->blitter;
+       if(!blitter)
+               nvfx->blitter = blitter = util_blitter_create(pipe);
+
+       util_blitter_save_blend(blitter, nvfx->blend);
+       util_blitter_save_depth_stencil_alpha(blitter, nvfx->zsa);
+       util_blitter_save_stencil_ref(blitter, &nvfx->stencil_ref);
+       util_blitter_save_rasterizer(blitter, nvfx->rasterizer);
+       util_blitter_save_fragment_shader(blitter, nvfx->fragprog);
+       util_blitter_save_vertex_shader(blitter, nvfx->vertprog);
+       util_blitter_save_viewport(blitter, &nvfx->viewport);
+       util_blitter_save_framebuffer(blitter, &nvfx->framebuffer);
+       util_blitter_save_clip(blitter, &nvfx->clip);
+       util_blitter_save_vertex_elements(blitter, nvfx->vtxelt);
+       util_blitter_save_vertex_buffers(blitter, nvfx->vtxbuf_nr, 
nvfx->vtxbuf);
+       
+       if(copy)
+       {
+               util_blitter_save_fragment_sampler_states(blitter, 
nvfx->nr_samplers, (void**)nvfx->tex_sampler);
+               util_blitter_save_fragment_sampler_views(blitter, 
nvfx->nr_textures, nvfx->fragment_sampler_views);
+       }
+
+       return blitter;
+}
+
 static void
 nvfx_surface_copy(struct pipe_context* pipe, struct pipe_surface *dsts,
                  unsigned dx, unsigned dy, struct pipe_surface *srcs, unsigned 
sx, unsigned sy,
@@ -161,12 +191,11 @@ nvfx_surface_copy(struct pipe_context* pipe, struct 
pipe_surface *dsts,
                        dst_to_gpu, src_on_gpu);
        if(!ret)
        {}
-       else if(ret > 0 && 0 /* TODO: change this once we have blitter support 
*/
-                       && dsts->texture->bind & PIPE_BIND_RENDER_TARGET
+       else if(ret > 0 && dsts->texture->bind & PIPE_BIND_RENDER_TARGET
                        && srcs->texture->bind & PIPE_BIND_SAMPLER_VIEW
                        )
        {
-               struct blitter_context* blitter = 0;
+               struct blitter_context* blitter = nvfx_get_blitter(pipe, 1);
                util_blitter_copy(blitter, dsts, dx, dy, srcs, sx, sy, w, h, 
TRUE);
        }
        else
@@ -192,11 +221,9 @@ nvfx_surface_fill(struct pipe_context* pipe, struct 
pipe_surface *dsts,
        int ret = nv04_region_fill_2d(ctx, &dst, w, h, value);
        if(!ret)
                return;
-       else if(ret > 0 && 0 /* TODO: change this once we have blitter support 
*/
-                       && dsts->texture->bind & PIPE_BIND_RENDER_TARGET
-                       )
+       else if(ret > 0 && dsts->texture->bind & PIPE_BIND_RENDER_TARGET)
        {
-               struct blitter_context* blitter = 0;
+               struct blitter_context* blitter = nvfx_get_blitter(pipe, 0);
                util_blitter_fill(blitter, dsts, dx, dy, w, h, value);
        }
        else

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to