nv30, nv40: unify nv[34]0_query.c
authorLuca Barbieri <luca@luca-barbieri.com>
Sat, 20 Feb 2010 18:39:24 +0000 (19:39 +0100)
committerYounes Manton <younes.m@gmail.com>
Mon, 15 Mar 2010 04:03:02 +0000 (00:03 -0400)
The files are identical except formatting.

14 files changed:
src/gallium/drivers/nv30/Makefile
src/gallium/drivers/nv30/nv30_context.c
src/gallium/drivers/nv30/nv30_context.h
src/gallium/drivers/nv30/nv30_query.c [deleted file]
src/gallium/drivers/nv30/nv30_surface.c [deleted file]
src/gallium/drivers/nv40/Makefile
src/gallium/drivers/nv40/nv40_context.c
src/gallium/drivers/nv40/nv40_context.h
src/gallium/drivers/nv40/nv40_query.c [deleted file]
src/gallium/drivers/nv40/nv40_surface.c [deleted file]
src/gallium/drivers/nvfx/Makefile
src/gallium/drivers/nvfx/nvfx_context.h
src/gallium/drivers/nvfx/nvfx_query.c [new file with mode: 0644]
src/gallium/drivers/nvfx/nvfx_surface.c [new file with mode: 0644]

index d8de297f128714dd74b8fdbb8639c783f1ea1f70..4f9798de0c66660ca8545e016d1edcb87f3006e6 100644 (file)
@@ -8,12 +8,10 @@ C_SOURCES = \
        nv30_draw.c \
        nv30_fragprog.c \
        nv30_fragtex.c \
-       nv30_query.c \
        nv30_screen.c \
        nv30_state.c \
        nv30_state_fb.c \
        nv30_state_viewport.c \
-       nv30_surface.c \
        nv30_vbo.c \
        nv30_vertprog.c
 
index 6fe8cb3e324e70356380ef54b1a3e633240a33a2..f13458d50a38b80208467a745f64255657db7eb2 100644 (file)
@@ -73,8 +73,8 @@ nv30_create(struct pipe_screen *pscreen, void *priv)
 
        nvfx->is_nv4x = screen->is_nv4x;
 
-       nv30_init_query_functions(nvfx);
-       nv30_init_surface_functions(nvfx);
+       nvfx_init_query_functions(nvfx);
+       nvfx_init_surface_functions(nvfx);
        nv30_init_state_functions(nvfx);
        nvfx_init_transfer_functions(nvfx);
 
index 46b36ee2e506bcc83d59dc9b06bf16d8d92edd9a..a0a1c335ec16ddbf8ce6f5b1c58738f8e2b13939 100644 (file)
@@ -4,8 +4,6 @@
 #include "nvfx_context.h"
 
 extern void nv30_init_state_functions(struct nvfx_context *nvfx);
-extern void nv30_init_surface_functions(struct nvfx_context *nvfx);
-extern void nv30_init_query_functions(struct nvfx_context *nvfx);
 
 /* nv30_draw.c */
 extern struct draw_stage *nv30_draw_render_stage(struct nvfx_context *nvfx);
diff --git a/src/gallium/drivers/nv30/nv30_query.c b/src/gallium/drivers/nv30/nv30_query.c
deleted file mode 100644 (file)
index 53b11a8..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-#include "pipe/p_context.h"
-
-#include "nv30_context.h"
-
-struct nv30_query {
-       struct nouveau_resource *object;
-       unsigned type;
-       boolean ready;
-       uint64_t result;
-};
-
-static INLINE struct nv30_query *
-nv30_query(struct pipe_query *pipe)
-{
-       return (struct nv30_query *)pipe;
-}
-
-static struct pipe_query *
-nv30_query_create(struct pipe_context *pipe, unsigned query_type)
-{
-       struct nv30_query *q;
-
-       q = CALLOC(1, sizeof(struct nv30_query));
-       q->type = query_type;
-
-       return (struct pipe_query *)q;
-}
-
-static void
-nv30_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
-{
-       struct nv30_query *q = nv30_query(pq);
-
-       if (q->object)
-               nouveau_resource_free(&q->object);
-       FREE(q);
-}
-
-static void
-nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
-{
-       struct nvfx_context *nvfx = nvfx_context(pipe);
-       struct nv30_query *q = nv30_query(pq);
-       struct nvfx_screen *screen = nvfx->screen;
-       struct nouveau_channel *chan = screen->base.channel;
-       struct nouveau_grobj *eng3d = screen->eng3d;
-
-       assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
-
-       /* Happens when end_query() is called, then another begin_query()
-        * without querying the result in-between.  For now we'll wait for
-        * the existing query to notify completion, but it could be better.
-        */
-       if (q->object) {
-               uint64_t tmp;
-               pipe->get_query_result(pipe, pq, 1, &tmp);
-       }
-
-       if (nouveau_resource_alloc(nvfx->screen->query_heap, 1, NULL, &q->object))
-               assert(0);
-       nouveau_notifier_reset(nvfx->screen->query, q->object->start);
-
-       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1);
-       OUT_RING  (chan, 1);
-       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_UNK17CC, 1);
-       OUT_RING  (chan, 1);
-
-       q->ready = FALSE;
-}
-
-static void
-nv30_query_end(struct pipe_context *pipe, struct pipe_query *pq)
-{
-       struct nvfx_context *nvfx = nvfx_context(pipe);
-       struct nvfx_screen *screen = nvfx->screen;
-       struct nouveau_channel *chan = screen->base.channel;
-       struct nouveau_grobj *eng3d = screen->eng3d;
-       struct nv30_query *q = nv30_query(pq);
-
-       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_GET, 1);
-       OUT_RING  (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
-                  ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
-       FIRE_RING(chan);
-}
-
-static boolean
-nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq,
-                 boolean wait, uint64_t *result)
-{
-       struct nvfx_context *nvfx = nvfx_context(pipe);
-       struct nv30_query *q = nv30_query(pq);
-
-       assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER);
-
-       if (!q->ready) {
-               unsigned status;
-
-               status = nouveau_notifier_status(nvfx->screen->query,
-                                                q->object->start);
-               if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
-                       if (wait == FALSE)
-                               return FALSE;
-
-                       nouveau_notifier_wait_status(nvfx->screen->query,
-                                       q->object->start,
-                                       NV_NOTIFY_STATE_STATUS_COMPLETED, 0);
-               }
-
-               q->result = nouveau_notifier_return_val(nvfx->screen->query,
-                                                       q->object->start);
-               q->ready = TRUE;
-               nouveau_resource_free(&q->object);
-       }
-
-       *result = q->result;
-       return TRUE;
-}
-
-void
-nv30_init_query_functions(struct nvfx_context *nvfx)
-{
-       nvfx->pipe.create_query = nv30_query_create;
-       nvfx->pipe.destroy_query = nv30_query_destroy;
-       nvfx->pipe.begin_query = nv30_query_begin;
-       nvfx->pipe.end_query = nv30_query_end;
-       nvfx->pipe.get_query_result = nv30_query_result;
-}
diff --git a/src/gallium/drivers/nv30/nv30_surface.c b/src/gallium/drivers/nv30/nv30_surface.c
deleted file mode 100644 (file)
index 613a9fa..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-
-/**************************************************************************
- * 
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-#include "nv30_context.h"
-#include "pipe/p_defines.h"
-#include "util/u_inlines.h"
-#include "util/u_tile.h"
-
-static void
-nv30_surface_copy(struct pipe_context *pipe,
-                 struct pipe_surface *dest, unsigned destx, unsigned desty,
-                 struct pipe_surface *src, unsigned srcx, unsigned srcy,
-                 unsigned width, unsigned height)
-{
-       struct nvfx_context *nvfx = nvfx_context(pipe);
-       struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
-
-       eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
-}
-
-static void
-nv30_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
-                 unsigned destx, unsigned desty, unsigned width,
-                 unsigned height, unsigned value)
-{
-       struct nvfx_context *nvfx = nvfx_context(pipe);
-       struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
-
-       eng2d->fill(eng2d, dest, destx, desty, width, height, value);
-}
-
-void
-nv30_init_surface_functions(struct nvfx_context *nvfx)
-{
-       nvfx->pipe.surface_copy = nv30_surface_copy;
-       nvfx->pipe.surface_fill = nv30_surface_fill;
-}
index bf68338e3f32d50be17fdbcf729b8e33348912e0..0b3607be89779ce828ebc7e748af3d4d621931b9 100644 (file)
@@ -8,12 +8,10 @@ C_SOURCES = \
        nv40_draw.c \
        nv40_fragprog.c \
        nv40_fragtex.c \
-       nv40_query.c \
        nv40_screen.c \
        nv40_state.c \
        nv40_state_fb.c \
        nv40_state_viewport.c \
-       nv40_surface.c \
        nv40_vbo.c \
        nv40_vertprog.c
 
index 12f57377cde938961386e9b111abb463d64d3f71..441b038b052b66aa7c2dcada3bd7b793c978b8d8 100644 (file)
@@ -73,8 +73,8 @@ nv40_create(struct pipe_screen *pscreen, void *priv)
 
        nvfx->is_nv4x = screen->is_nv4x;
 
-       nv40_init_query_functions(nvfx);
-       nv40_init_surface_functions(nvfx);
+       nvfx_init_query_functions(nvfx);
+       nvfx_init_surface_functions(nvfx);
        nv40_init_state_functions(nvfx);
        nvfx_init_transfer_functions(nvfx);
 
index fe44452f81101dea5237c916ab24e34eae09cbf5..4353d78cd23fa67547dc29dbe36f54a629f311da 100644 (file)
@@ -4,8 +4,6 @@
 #include "nvfx_context.h"
 
 extern void nv40_init_state_functions(struct nvfx_context *nvfx);
-extern void nv40_init_surface_functions(struct nvfx_context *nvfx);
-extern void nv40_init_query_functions(struct nvfx_context *nvfx);
 
 /* nv40_draw.c */
 extern struct draw_stage *nv40_draw_render_stage(struct nvfx_context *nvfx);
diff --git a/src/gallium/drivers/nv40/nv40_query.c b/src/gallium/drivers/nv40/nv40_query.c
deleted file mode 100644 (file)
index 48cfc4d..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-#include "pipe/p_context.h"
-
-#include "nv40_context.h"
-
-struct nv40_query {
-       struct nouveau_resource *object;
-       unsigned type;
-       boolean ready;
-       uint64_t result;
-};
-
-static INLINE struct nv40_query *
-nv40_query(struct pipe_query *pipe)
-{
-       return (struct nv40_query *)pipe;
-}
-
-static struct pipe_query *
-nv40_query_create(struct pipe_context *pipe, unsigned query_type)
-{
-       struct nv40_query *q;
-
-       q = CALLOC(1, sizeof(struct nv40_query));
-       q->type = query_type;
-
-       return (struct pipe_query *)q;
-}
-
-static void
-nv40_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
-{
-       struct nv40_query *q = nv40_query(pq);
-
-       if (q->object)
-               nouveau_resource_free(&q->object);
-       FREE(q);
-}
-
-static void
-nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
-{
-       struct nvfx_context *nvfx = nvfx_context(pipe);
-       struct nv40_query *q = nv40_query(pq);
-       struct nvfx_screen *screen = nvfx->screen;
-       struct nouveau_channel *chan = screen->base.channel;
-       struct nouveau_grobj *eng3d = screen->eng3d;
-
-       assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
-
-       /* Happens when end_query() is called, then another begin_query()
-        * without querying the result in-between.  For now we'll wait for
-        * the existing query to notify completion, but it could be better.
-        */
-       if (q->object) {
-               uint64_t tmp;
-               pipe->get_query_result(pipe, pq, 1, &tmp);
-       }
-
-       if (nouveau_resource_alloc(nvfx->screen->query_heap, 1, NULL, &q->object))
-               assert(0);
-       nouveau_notifier_reset(nvfx->screen->query, q->object->start);
-
-       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1);
-       OUT_RING  (chan, 1);
-       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_UNK17CC, 1);
-       OUT_RING  (chan, 1);
-
-       q->ready = FALSE;
-}
-
-static void
-nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq)
-{
-       struct nvfx_context *nvfx = nvfx_context(pipe);
-       struct nv40_query *q = nv40_query(pq);
-       struct nvfx_screen *screen = nvfx->screen;
-       struct nouveau_channel *chan = screen->base.channel;
-       struct nouveau_grobj *eng3d = screen->eng3d;
-
-       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_GET, 1);
-       OUT_RING  (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
-                  ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
-       FIRE_RING(chan);
-}
-
-static boolean
-nv40_query_result(struct pipe_context *pipe, struct pipe_query *pq,
-                 boolean wait, uint64_t *result)
-{
-       struct nvfx_context *nvfx = nvfx_context(pipe);
-       struct nv40_query *q = nv40_query(pq);
-
-       assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER);
-
-       if (!q->ready) {
-               unsigned status;
-
-               status = nouveau_notifier_status(nvfx->screen->query,
-                                                q->object->start);
-               if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
-                       if (wait == FALSE)
-                               return FALSE;
-                       nouveau_notifier_wait_status(nvfx->screen->query,
-                                             q->object->start,
-                                             NV_NOTIFY_STATE_STATUS_COMPLETED,
-                                             0);
-               }
-
-               q->result = nouveau_notifier_return_val(nvfx->screen->query,
-                                                       q->object->start);
-               q->ready = TRUE;
-               nouveau_resource_free(&q->object);
-       }
-
-       *result = q->result;
-       return TRUE;
-}
-
-void
-nv40_init_query_functions(struct nvfx_context *nvfx)
-{
-       nvfx->pipe.create_query = nv40_query_create;
-       nvfx->pipe.destroy_query = nv40_query_destroy;
-       nvfx->pipe.begin_query = nv40_query_begin;
-       nvfx->pipe.end_query = nv40_query_end;
-       nvfx->pipe.get_query_result = nv40_query_result;
-}
diff --git a/src/gallium/drivers/nv40/nv40_surface.c b/src/gallium/drivers/nv40/nv40_surface.c
deleted file mode 100644 (file)
index 328c23b..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-
-/**************************************************************************
- * 
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-#include "pipe/p_defines.h"
-#include "util/u_inlines.h"
-
-#include "util/u_tile.h"
-
-#include "nv40_context.h"
-
-static void
-nv40_surface_copy(struct pipe_context *pipe,
-                 struct pipe_surface *dest, unsigned destx, unsigned desty,
-                 struct pipe_surface *src, unsigned srcx, unsigned srcy,
-                 unsigned width, unsigned height)
-{
-       struct nvfx_context *nvfx = nvfx_context(pipe);
-       struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
-
-       eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
-}
-
-static void
-nv40_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
-                 unsigned destx, unsigned desty, unsigned width,
-                 unsigned height, unsigned value)
-{
-       struct nvfx_context *nvfx = nvfx_context(pipe);
-       struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
-
-       eng2d->fill(eng2d, dest, destx, desty, width, height, value);
-}
-
-void
-nv40_init_surface_functions(struct nvfx_context *nvfx)
-{
-       nvfx->pipe.surface_copy = nv40_surface_copy;
-       nvfx->pipe.surface_fill = nv40_surface_fill;
-}
index 5073168604fe9030369b75e7208f8129126b9435..f51ab1856b65d41ce8cd3ef0c1fe7f06d0b8aa3a 100644 (file)
@@ -7,11 +7,13 @@ C_SOURCES = \
        nvfx_clear.c \
        nvfx_state_emit.c \
        nvfx_miptree.c \
+       nvfx_query.c \
        nvfx_state_blend.c \
        nvfx_state_rasterizer.c \
        nvfx_state_scissor.c \
         nvfx_state_stipple.c \
        nvfx_state_zsa.c \
+       nvfx_surface.c \
        nvfx_transfer.c
 
 include ../../Makefile.template
index 8f5013a9d6b578b1dae4ff1a08d82c077a13ed7d..5f61d4450d172cb35fe38f7736d5a1d83e348c5c 100644 (file)
@@ -189,6 +189,9 @@ extern struct nvfx_state_entry nvfx_state_sr;
 extern struct nvfx_state_entry nvfx_state_stipple;
 extern struct nvfx_state_entry nvfx_state_zsa;
 
+extern void nvfx_init_query_functions(struct nvfx_context *nvfx);
+extern void nvfx_init_surface_functions(struct nvfx_context *nvfx);
+
 /* nvfx_clear.c */
 extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
                       const float *rgba, double depth, unsigned stencil);
diff --git a/src/gallium/drivers/nvfx/nvfx_query.c b/src/gallium/drivers/nvfx/nvfx_query.c
new file mode 100644 (file)
index 0000000..acbaf75
--- /dev/null
@@ -0,0 +1,127 @@
+#include "pipe/p_context.h"
+
+#include "nvfx_context.h"
+
+struct nvfx_query {
+       struct nouveau_resource *object;
+       unsigned type;
+       boolean ready;
+       uint64_t result;
+};
+
+static INLINE struct nvfx_query *
+nvfx_query(struct pipe_query *pipe)
+{
+       return (struct nvfx_query *)pipe;
+}
+
+static struct pipe_query *
+nvfx_query_create(struct pipe_context *pipe, unsigned query_type)
+{
+       struct nvfx_query *q;
+
+       q = CALLOC(1, sizeof(struct nvfx_query));
+       q->type = query_type;
+
+       return (struct pipe_query *)q;
+}
+
+static void
+nvfx_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
+{
+       struct nvfx_query *q = nvfx_query(pq);
+
+       if (q->object)
+               nouveau_resource_free(&q->object);
+       FREE(q);
+}
+
+static void
+nvfx_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
+{
+       struct nvfx_context *nvfx = nvfx_context(pipe);
+       struct nvfx_query *q = nvfx_query(pq);
+       struct nvfx_screen *screen = nvfx->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *eng3d = screen->eng3d;
+
+       assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
+
+       /* Happens when end_query() is called, then another begin_query()
+        * without querying the result in-between.  For now we'll wait for
+        * the existing query to notify completion, but it could be better.
+        */
+       if (q->object) {
+               uint64_t tmp;
+               pipe->get_query_result(pipe, pq, 1, &tmp);
+       }
+
+       if (nouveau_resource_alloc(nvfx->screen->query_heap, 1, NULL, &q->object))
+               assert(0);
+       nouveau_notifier_reset(nvfx->screen->query, q->object->start);
+
+       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1);
+       OUT_RING  (chan, 1);
+       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_UNK17CC, 1);
+       OUT_RING  (chan, 1);
+
+       q->ready = FALSE;
+}
+
+static void
+nvfx_query_end(struct pipe_context *pipe, struct pipe_query *pq)
+{
+       struct nvfx_context *nvfx = nvfx_context(pipe);
+       struct nvfx_screen *screen = nvfx->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *eng3d = screen->eng3d;
+       struct nvfx_query *q = nvfx_query(pq);
+
+       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_GET, 1);
+       OUT_RING  (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
+                  ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
+       FIRE_RING(chan);
+}
+
+static boolean
+nvfx_query_result(struct pipe_context *pipe, struct pipe_query *pq,
+                 boolean wait, uint64_t *result)
+{
+       struct nvfx_context *nvfx = nvfx_context(pipe);
+       struct nvfx_query *q = nvfx_query(pq);
+
+       assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER);
+
+       if (!q->ready) {
+               unsigned status;
+
+               status = nouveau_notifier_status(nvfx->screen->query,
+                                                q->object->start);
+               if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
+                       if (wait == FALSE)
+                               return FALSE;
+
+                       nouveau_notifier_wait_status(nvfx->screen->query,
+                                       q->object->start,
+                                       NV_NOTIFY_STATE_STATUS_COMPLETED, 0);
+               }
+
+               q->result = nouveau_notifier_return_val(nvfx->screen->query,
+                                                       q->object->start);
+               q->ready = TRUE;
+               nouveau_resource_free(&q->object);
+       }
+
+       *result = q->result;
+       return TRUE;
+}
+
+void
+nvfx_init_query_functions(struct nvfx_context *nvfx)
+{
+       nvfx->pipe.create_query = nvfx_query_create;
+       nvfx->pipe.destroy_query = nvfx_query_destroy;
+       nvfx->pipe.begin_query = nvfx_query_begin;
+       nvfx->pipe.end_query = nvfx_query_end;
+       nvfx->pipe.get_query_result = nvfx_query_result;
+}
diff --git a/src/gallium/drivers/nvfx/nvfx_surface.c b/src/gallium/drivers/nvfx/nvfx_surface.c
new file mode 100644 (file)
index 0000000..8a05ad0
--- /dev/null
@@ -0,0 +1,62 @@
+
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "nvfx_context.h"
+#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
+#include "util/u_tile.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,
+                 unsigned width, unsigned height)
+{
+       struct nvfx_context *nvfx = nvfx_context(pipe);
+       struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
+
+       eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
+}
+
+static void
+nvfx_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
+                 unsigned destx, unsigned desty, unsigned width,
+                 unsigned height, unsigned value)
+{
+       struct nvfx_context *nvfx = nvfx_context(pipe);
+       struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
+
+       eng2d->fill(eng2d, dest, destx, desty, width, height, value);
+}
+
+void
+nvfx_init_surface_functions(struct nvfx_context *nvfx)
+{
+       nvfx->pipe.surface_copy = nvfx_surface_copy;
+       nvfx->pipe.surface_fill = nvfx_surface_fill;
+}