Mesa (nvfx-next): nvfx: new 2D: add u_blitter support
Luca Barbieri
lb at kemper.freedesktop.org
Tue Apr 13 15:17:31 UTC 2010
Module: Mesa
Branch: nvfx-next
Commit: 3d0d607679c817a5960b7d9dd839b9a57b0b9980
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d0d607679c817a5960b7d9dd839b9a57b0b9980
Author: Luca Barbieri <luca at luca-barbieri.com>
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 | 36 +++++++++++++++++++++++++------
2 files changed, 31 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..f2d042d 100644
--- a/src/gallium/drivers/nvfx/nvfx_surface.c
+++ b/src/gallium/drivers/nvfx/nvfx_surface.c
@@ -118,6 +118,31 @@ 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_rasterizer(blitter, nvfx->rasterizer);
+ util_blitter_save_fragment_shader(blitter, nvfx->fragprog);
+ util_blitter_save_vertex_shader(blitter, nvfx->vertprog);
+ util_blitter_save_framebuffer(blitter, &nvfx->framebuffer);
+
+ 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 +186,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 +216,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
More information about the mesa-commit
mailing list