nv30: implement blit
authorMarek Olšák <maraeo@gmail.com>
Wed, 12 Sep 2012 22:36:06 +0000 (00:36 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sun, 30 Sep 2012 16:57:56 +0000 (18:57 +0200)
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/nv30/nv30_context.c
src/gallium/drivers/nv30/nv30_context.h
src/gallium/drivers/nv30/nv30_miptree.c
src/gallium/drivers/nv30/nv30_query.c
src/gallium/drivers/nv30/nv30_resource.c
src/gallium/drivers/nv30/nv30_resource.h

index 42e844f141e9004fc83a442ae323bb3f6794f570..31519de7a2438bcf19222e28988ab445f2101a03 100644 (file)
@@ -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;
 }
index 0a6f97f7fb10e4d33410002a6868a4d5c82a95f9..c90dd3c1061704a93ad60072b931a69eca6658f8 100644 (file)
@@ -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 *
index 7e677291f6ade419b6b8b6871562ae0aa7e0b9c8..79034ac7daef3cc975dd94b2894d3bd752a76260 100644 (file)
@@ -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,
index 001aba1e26c142d82f7c97049ecf155c8c1f6a21..9262e44ecdc425717a8803b3ae72cd56e52b02bc 100644 (file)
@@ -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);
index 3d8e7d74b314debac6011b2532f25847dd9b1c42..80dc61efcb05ddecaae207fbb4a5bb19430f83a2 100644 (file)
@@ -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;
 }
index 6f5d1a86590a7a7c6cf1a03f522ac34421565e41..fdf62c7cf15f991dc3566c3ef33d5ac900953946 100644 (file)
@@ -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