nouveau: adapt to interface changes
authorRoland Scheidegger <sroland@vmware.com>
Mon, 17 May 2010 19:28:14 +0000 (21:28 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Mon, 17 May 2010 19:28:14 +0000 (21:28 +0200)
this probably needs further cleanup (just getting a surface for the resource
seems quite nonoptimal and potentially cause unnecessary copies I think)

src/gallium/drivers/nouveau/nouveau_screen.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nv50/nv50_surface.c
src/gallium/drivers/nvfx/nv04_surface_2d.c
src/gallium/drivers/nvfx/nvfx_miptree.c
src/gallium/drivers/nvfx/nvfx_screen.c
src/gallium/drivers/nvfx/nvfx_surface.c
src/gallium/drivers/nvfx/nvfx_transfer.c

index 233a91a..89d5ffa 100644 (file)
@@ -51,8 +51,6 @@ nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
 
        if (bind & (PIPE_BIND_RENDER_TARGET |
                        PIPE_BIND_DEPTH_STENCIL |
-                       PIPE_BIND_BLIT_SOURCE |
-                       PIPE_BIND_BLIT_DESTINATION |
                        PIPE_BIND_SCANOUT |
                        PIPE_BIND_DISPLAY_TARGET |
                        PIPE_BIND_SAMPLER_VIEW))
index 2dd1042..a8cb1e2 100644 (file)
@@ -32,8 +32,12 @@ static boolean
 nv50_screen_is_format_supported(struct pipe_screen *pscreen,
                                enum pipe_format format,
                                enum pipe_texture_target target,
+                               unsigned sample_count,
                                unsigned tex_usage, unsigned geom_flags)
 {
+       if (sample_count > 1)
+               return FALSE;
+
        if (tex_usage & PIPE_BIND_RENDER_TARGET) {
                switch (format) {
                case PIPE_FORMAT_B8G8R8X8_UNORM:
index d905d95..40b8d25 100644 (file)
@@ -195,27 +195,40 @@ nv50_surface_do_copy(struct nv50_screen *screen, struct pipe_surface *dst,
 
 static void
 nv50_surface_copy(struct pipe_context *pipe,
-                 struct pipe_surface *dest, unsigned destx, unsigned desty,
-                 struct pipe_surface *src, unsigned srcx, unsigned srcy,
+                 struct pipe_resource *dest, struct pipe_subresource subdst,
+                 unsigned destx, unsigned desty, unsigned destz,
+                 struct pipe_resource *src, struct pipe_subresource subsrc,
+                 unsigned srcx, unsigned srcy, unsigned srcz,
                  unsigned width, unsigned height)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
        struct nv50_screen *screen = nv50->screen;
+       struct pipe_surface *ps_dst, *ps_src;
 
        assert((src->format == dest->format) ||
               (nv50_2d_format_faithful(src->format) &&
                nv50_2d_format_faithful(dest->format)));
 
-       nv50_surface_do_copy(screen, dest, destx, desty, src, srcx,
-                                    srcy, width, height);
+       ps_src = nv50_miptree_surface_new(pipe->screen, dest, subsrc.face,
+                                         subsrc.level, srcz, 0 /* bind flags */);
+       ps_dst = nv50_miptree_surface_new(pipe->screen, dest, subdst.face,
+                                         subdst.level, destz, 0 /* bindflags */);
+
+       nv50_surface_do_copy(screen, ps_dst, destx, desty, ps_src, srcx,
+                            srcy, width, height);
+
+       nv50_miptree_surface_del(ps_src);
+       nv50_miptree_surface_del(ps_dst);
 }
 
 static void
-nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
-                 unsigned destx, unsigned desty, unsigned width,
-                 unsigned height, unsigned value)
+nv50_surface_fill(struct pipe_context *pipe, struct pipe_resource *dest,
+                 struct pipe_subresource subdst,
+                 unsigned destx, unsigned desty, unsigned destz,
+                 unsigned width, unsigned height, unsigned value)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
+       struct pipe_surface *ps;
        struct nv50_screen *screen = nv50->screen;
        struct nouveau_channel *chan = screen->eng2d->channel;
        struct nouveau_grobj *eng2d = screen->eng2d;
@@ -225,9 +238,12 @@ nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
        if (format < 0)
                return;
 
+       ps = nv50_miptree_surface_new(pipe->screen, dest, subdst.face,
+                                     subdst.level, destz, 0 /* bind flags */);
+       
        WAIT_RING (chan, 32);
 
-       ret = nv50_surface_set(screen, dest, 1);
+       ret = nv50_surface_set(screen, ps, 1);
        if (ret)
                return;
 
@@ -240,13 +256,15 @@ nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
        OUT_RING  (chan, desty);
        OUT_RING  (chan, width);
        OUT_RING  (chan, height);
+
+       nv50_miptree_surface_del(ps);
 }
 
 void
 nv50_init_surface_functions(struct nv50_context *nv50)
 {
-       nv50->pipe.surface_copy = nv50_surface_copy;
-       nv50->pipe.surface_fill = nv50_surface_fill;
+       nv50->pipe.resource_copy_region = nv50_surface_copy;
+       nv50->pipe.resource_fill_region = nv50_surface_fill;
 }
 
 
index 4ed5742..7acbb50 100644 (file)
@@ -502,12 +502,9 @@ nv04_surface_wrap_for_render(struct pipe_screen *pscreen,
        struct nv04_surface* temp_ns;
        int temp_flags;
 
-       temp_flags = (ns->base.usage |
-                     PIPE_BIND_BLIT_SOURCE |
-                     PIPE_BIND_BLIT_DESTINATION);
+       temp_flags = ns->base.usage;
 
-       ns->base.usage = (PIPE_BIND_BLIT_SOURCE |
-                        PIPE_BIND_BLIT_DESTINATION);
+       ns->base.usage = 0;
 
        memset(&templ, 0, sizeof(templ));
        templ.format = ns->base.texture->format;
@@ -526,7 +523,7 @@ nv04_surface_wrap_for_render(struct pipe_screen *pscreen,
        temp_ns = (struct nv04_surface*)pscreen->get_tex_surface(pscreen, temp_tex, 0, 0, 0, temp_flags);
        temp_ns->backing = ns;
 
-       if(ns->base.usage & PIPE_BIND_BLIT_SOURCE)
+       if(1) /* hmm */
                eng2d->copy(eng2d, &temp_ns->backing->base,
                            0, 0, &ns->base,
                            0, 0, ns->base.width, ns->base.height);
index aeb88e9..b5639bb 100644 (file)
@@ -300,7 +300,7 @@ nvfx_miptree_surface_del(struct pipe_surface *ps)
        if(ns->backing)
        {
                struct nvfx_screen* screen = (struct nvfx_screen*)ps->texture->screen;
-               if(ns->backing->base.usage & PIPE_BIND_BLIT_DESTINATION)
+               if(1 /*ns->backing->base.usage & PIPE_BIND_BLIT_DESTINATION*/)
                        screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
                nvfx_miptree_surface_del(&ns->backing->base);
        }
index 9f03ab1..1786af7 100644 (file)
@@ -115,11 +115,15 @@ static boolean
 nvfx_screen_surface_format_supported(struct pipe_screen *pscreen,
                                     enum pipe_format format,
                                     enum pipe_texture_target target,
+                                    unsigned sample_count,
                                     unsigned tex_usage, unsigned geom_flags)
 {
        struct nvfx_screen *screen = nvfx_screen(pscreen);
        struct pipe_surface *front = ((struct nouveau_winsys *) pscreen->winsys)->front;
 
+        if (sample_count > 1)
+               return FALSE;
+
        if (tex_usage & PIPE_BIND_RENDER_TARGET) {
                switch (format) {
                case PIPE_FORMAT_B8G8R8A8_UNORM:
index 2e11565..fc3a670 100644 (file)
  **************************************************************************/
 
 #include "nvfx_context.h"
+#include "nvfx_resource.h"
 #include "pipe/p_defines.h"
 #include "util/u_inlines.h"
 
 static void
 nvfx_surface_copy(struct pipe_context *pipe,
-                 struct pipe_surface *dest, unsigned destx, unsigned desty,
-                 struct pipe_surface *src, unsigned srcx, unsigned srcy,
+                 struct pipe_resource *dest, struct pipe_subresource subdst,
+                 unsigned destx, unsigned desty, unsigned destz,
+                 struct pipe_resource *src, struct pipe_subresource subsrc,
+                 unsigned srcx, unsigned srcy, unsigned srcz,
                  unsigned width, unsigned height)
 {
        struct nvfx_context *nvfx = nvfx_context(pipe);
        struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
+       struct pipe_surface *ps_dst, *ps_src;
 
-       eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
+       ps_src = nvfx_miptree_surface_new(pipe->screen, dest, subsrc.face,
+                                         subsrc.level, srcz, 0 /* bind flags */);
+       ps_dst = nvfx_miptree_surface_new(pipe->screen, dest, subdst.face,
+                                         subdst.level, destz, 0 /* bindflags */);
+
+       eng2d->copy(eng2d, ps_dst, destx, desty, ps_src, srcx, srcy, width, height);
+
+       nvfx_miptree_surface_del(ps_src);
+       nvfx_miptree_surface_del(ps_dst);
 }
 
 static void
-nvfx_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
-                 unsigned destx, unsigned desty, unsigned width,
-                 unsigned height, unsigned value)
+nvfx_surface_fill(struct pipe_context *pipe, struct pipe_resource *dest,
+                 struct pipe_subresource subdst,
+                 unsigned destx, unsigned desty, unsigned destz,
+                 unsigned width, unsigned height, unsigned value)
 {
        struct nvfx_context *nvfx = nvfx_context(pipe);
+       struct pipe_surface *ps;
        struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
 
-       eng2d->fill(eng2d, dest, destx, desty, width, height, value);
+       ps = nvfx_miptree_surface_new(pipe->screen, dest, subdst.face,
+                                     subdst.level, destz, 0 /* bind flags */);
+       
+       eng2d->fill(eng2d, ps, destx, desty, width, height, value);
+
+       nvfx_miptree_surface_del(ps);
 }
 
 void
 nvfx_init_surface_functions(struct nvfx_context *nvfx)
 {
-       nvfx->pipe.surface_copy = nvfx_surface_copy;
-       nvfx->pipe.surface_fill = nvfx_surface_fill;
+       nvfx->pipe.resource_copy_region = nvfx_surface_copy;
+       nvfx->pipe.resource_fill_region = nvfx_surface_fill;
 }
index b2ef27c..9ff0a93 100644 (file)
@@ -40,11 +40,13 @@ static unsigned nvfx_transfer_bind_flags( unsigned transfer_usage )
 {
        unsigned bind = 0;
 
+#if 0
        if (transfer_usage & PIPE_TRANSFER_WRITE)
                bind |= PIPE_BIND_BLIT_SOURCE;
 
        if (transfer_usage & PIPE_TRANSFER_READ)
                bind |= PIPE_BIND_BLIT_DESTINATION;
+#endif
 
        return bind;
 }
@@ -128,7 +130,7 @@ nvfx_miptree_transfer_new(struct pipe_context *pipe,
 
                src = pscreen->get_tex_surface(pscreen, pt,
                                               sr.face, sr.level, box->z,
-                                              PIPE_BIND_BLIT_SOURCE);
+                                              0 /*PIPE_BIND_BLIT_SOURCE*/);
 
                /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
                /* TODO: Check if SIFM can un-swizzle */
@@ -160,7 +162,7 @@ nvfx_miptree_transfer_del(struct pipe_context *pipe,
                                               ptx->sr.face,
                                               ptx->sr.level,
                                               ptx->box.z,
-                                              PIPE_BIND_BLIT_DESTINATION);
+                                              0 /*PIPE_BIND_BLIT_DESTINATION*/);
 
                /* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
                nvscreen->eng2d->copy(nvscreen->eng2d,