summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-09-13 00:36:06 +0200
committerMarek Olšák <[email protected]>2012-09-30 18:57:56 +0200
commitced065a0797d9504950b7763cd90244ca478a723 (patch)
treed3fc20a3c1e2dd2dcd791655f4f01fa66dfc29f4 /src
parentdb85443922e93191b9056799ed649ab6f7d8f758 (diff)
nv30: implement blit
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/nv30/nv30_context.c9
-rw-r--r--src/gallium/drivers/nv30/nv30_context.h5
-rw-r--r--src/gallium/drivers/nv30/nv30_miptree.c58
-rw-r--r--src/gallium/drivers/nv30/nv30_query.c3
-rw-r--r--src/gallium/drivers/nv30/nv30_resource.c1
-rw-r--r--src/gallium/drivers/nv30/nv30_resource.h4
6 files changed, 80 insertions, 0 deletions
diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
index 42e844f141e..31519de7a24 100644
--- a/src/gallium/drivers/nv30/nv30_context.c
+++ b/src/gallium/drivers/nv30/nv30_context.c
@@ -84,6 +84,9 @@ nv30_context_destroy(struct pipe_context *pipe)
{
struct nv30_context *nv30 = nv30_context(pipe);
+ if (nv30->blitter)
+ util_blitter_destroy(nv30->blitter);
+
if (nv30->draw)
draw_destroy(nv30->draw);
@@ -171,5 +174,11 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv)
nv40_verttex_init(pipe);
nv30_draw_init(pipe);
+ nv30->blitter = util_blitter_create(pipe);
+ if (!nv30->blitter) {
+ nv30_context_destroy(pipe);
+ return NULL;
+ }
+
return pipe;
}
diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
index 0a6f97f7fb1..c90dd3c1061 100644
--- a/src/gallium/drivers/nv30/nv30_context.h
+++ b/src/gallium/drivers/nv30/nv30_context.h
@@ -2,6 +2,7 @@
#define __NV30_CONTEXT_H__
#include "pipe/p_format.h"
+#include "util/u_blitter.h"
#include "nv30_screen.h"
#include "nv30_state.h"
@@ -42,6 +43,7 @@
struct nv30_context {
struct nouveau_context base;
struct nv30_screen *screen;
+ struct blitter_context *blitter;
struct nouveau_bufctx *bufctx;
@@ -124,6 +126,9 @@ struct nv30_context {
enum {
HW,
} render_mode;
+
+ struct pipe_query *render_cond_query;
+ unsigned render_cond_mode;
};
static INLINE struct nv30_context *
diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c
index 7e677291f6a..79034ac7dae 100644
--- a/src/gallium/drivers/nv30/nv30_miptree.c
+++ b/src/gallium/drivers/nv30/nv30_miptree.c
@@ -159,6 +159,64 @@ nv30_resource_resolve(struct pipe_context *pipe,
nv30_transfer_rect(nv30, BILINEAR, &src, &dst);
}
+void
+nv30_blit(struct pipe_context *pipe,
+ const struct pipe_blit_info *blit_info)
+{
+ struct nv30_context *nv30 = nv30_context(pipe);
+ struct pipe_blit_info info = *blit_info;
+
+ if (info.src.resource->nr_samples > 1 &&
+ info.dst.resource->nr_samples <= 1 &&
+ !util_format_is_depth_or_stencil(info.src.resource->format) &&
+ !util_format_is_pure_integer(info.src.resource->format)) {
+ debug_printf("nv30: color resolve unimplemented\n");
+ return;
+ }
+
+ if (util_try_blit_via_copy_region(pipe, &info)) {
+ return; /* done */
+ }
+
+ if (info.mask & PIPE_MASK_S) {
+ debug_printf("nv30: cannot blit stencil, skipping\n");
+ info.mask &= ~PIPE_MASK_S;
+ }
+
+ if (!util_blitter_is_blit_supported(nv30->blitter, &info)) {
+ debug_printf("nv30: blit unsupported %s -> %s\n",
+ util_format_short_name(info.src.resource->format),
+ util_format_short_name(info.dst.resource->format));
+ return;
+ }
+
+ /* XXX turn off occlusion queries */
+
+ util_blitter_save_vertex_buffers(nv30->blitter,
+ nv30->num_vtxbufs,
+ nv30->vtxbuf);
+ util_blitter_save_vertex_elements(nv30->blitter, nv30->vertex);
+ util_blitter_save_vertex_shader(nv30->blitter, nv30->vertprog.program);
+ util_blitter_save_rasterizer(nv30->blitter, nv30->rast);
+ util_blitter_save_viewport(nv30->blitter, &nv30->viewport);
+ util_blitter_save_scissor(nv30->blitter, &nv30->scissor);
+ util_blitter_save_fragment_shader(nv30->blitter, nv30->fragprog.program);
+ util_blitter_save_blend(nv30->blitter, nv30->blend);
+ util_blitter_save_depth_stencil_alpha(nv30->blitter,
+ nv30->zsa);
+ util_blitter_save_stencil_ref(nv30->blitter, &nv30->stencil_ref);
+ util_blitter_save_sample_mask(nv30->blitter, nv30->sample_mask);
+ util_blitter_save_framebuffer(nv30->blitter, &nv30->framebuffer);
+ util_blitter_save_fragment_sampler_states(nv30->blitter,
+ nv30->fragprog.num_samplers,
+ (void**)nv30->fragprog.samplers);
+ util_blitter_save_fragment_sampler_views(nv30->blitter,
+ nv30->fragprog.num_textures, nv30->fragprog.textures);
+ util_blitter_save_render_condition(nv30->blitter, nv30->render_cond_query,
+ nv30->render_cond_mode);
+ util_blitter_blit(nv30->blitter, &info);
+}
+
static struct pipe_transfer *
nv30_miptree_transfer_new(struct pipe_context *pipe, struct pipe_resource *pt,
unsigned level, unsigned usage,
diff --git a/src/gallium/drivers/nv30/nv30_query.c b/src/gallium/drivers/nv30/nv30_query.c
index 001aba1e26c..9262e44ecdc 100644
--- a/src/gallium/drivers/nv30/nv30_query.c
+++ b/src/gallium/drivers/nv30/nv30_query.c
@@ -238,6 +238,9 @@ nv40_query_render_condition(struct pipe_context *pipe,
struct nv30_query *q = nv30_query(pq);
struct nouveau_pushbuf *push = nv30->base.pushbuf;
+ nv30->render_cond_query = pq;
+ nv30->render_cond_mode = mode;
+
if (!pq) {
BEGIN_NV04(push, SUBC_3D(0x1e98), 1);
PUSH_DATA (push, 0x01000000);
diff --git a/src/gallium/drivers/nv30/nv30_resource.c b/src/gallium/drivers/nv30/nv30_resource.c
index 3d8e7d74b31..80dc61efcb0 100644
--- a/src/gallium/drivers/nv30/nv30_resource.c
+++ b/src/gallium/drivers/nv30/nv30_resource.c
@@ -76,4 +76,5 @@ nv30_resource_init(struct pipe_context *pipe)
pipe->surface_destroy = nv30_miptree_surface_del;
pipe->resource_copy_region = nv30_resource_copy_region;
pipe->resource_resolve = nv30_resource_resolve;
+ pipe->blit = nv30_blit;
}
diff --git a/src/gallium/drivers/nv30/nv30_resource.h b/src/gallium/drivers/nv30/nv30_resource.h
index 6f5d1a86590..fdf62c7cf15 100644
--- a/src/gallium/drivers/nv30/nv30_resource.h
+++ b/src/gallium/drivers/nv30/nv30_resource.h
@@ -68,4 +68,8 @@ nv30_resource_copy_region(struct pipe_context *pipe,
void
nv30_resource_resolve(struct pipe_context *, const struct pipe_resolve_info *);
+void
+nv30_blit(struct pipe_context *pipe,
+ const struct pipe_blit_info *blit_info);
+
#endif