svga: adapt to stencil ref changes
[mesa.git] / src / gallium / drivers / nv30 / nv30_context.c
index a3e65b96f7b54c89deb13bd5e159e9a3b5cd53cc..8bfd7b2c9095bf9c8dfcee533c164007da9ecdb3 100644 (file)
@@ -1,6 +1,6 @@
 #include "draw/draw_context.h"
 #include "pipe/p_defines.h"
-#include "pipe/internal/p_winsys_screen.h"
+#include "util/u_simple_screen.h"
 
 #include "nv30_context.h"
 #include "nv30_screen.h"
@@ -10,60 +10,40 @@ nv30_flush(struct pipe_context *pipe, unsigned flags,
           struct pipe_fence_handle **fence)
 {
        struct nv30_context *nv30 = nv30_context(pipe);
+       struct nv30_screen *screen = nv30->screen;
+       struct nouveau_channel *chan = screen->base.channel;
+       struct nouveau_grobj *rankine = screen->rankine;
 
        if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
-               BEGIN_RING(rankine, 0x1fd8, 1);
-               OUT_RING  (2);
-               BEGIN_RING(rankine, 0x1fd8, 1);
-               OUT_RING  (1);
+               BEGIN_RING(chan, rankine, 0x1fd8, 1);
+               OUT_RING  (chan, 2);
+               BEGIN_RING(chan, rankine, 0x1fd8, 1);
+               OUT_RING  (chan, 1);
        }
 
-       FIRE_RING(fence);
+       FIRE_RING(chan);
+       if (fence)
+               *fence = NULL;
 }
 
 static void
 nv30_destroy(struct pipe_context *pipe)
 {
        struct nv30_context *nv30 = nv30_context(pipe);
+       unsigned i;
+
+       for (i = 0; i < NV30_STATE_MAX; i++) {
+               if (nv30->state.hw[i])
+                       so_ref(NULL, &nv30->state.hw[i]);
+       }
 
        if (nv30->draw)
                draw_destroy(nv30->draw);
        FREE(nv30);
 }
 
-static unsigned int
-nv30_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Return the corrent result. We can't alays return referenced
-    *        since it causes a double flush within the vbo module.
-    */
-#if 0
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-#else
-   return 0;
-#endif
-}
-
-static unsigned int
-nv30_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Return the corrent result. We can't alays return referenced
-    *        since it causes a double flush within the vbo module.
-    */
-#if 0
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-#else
-   return 0;
-#endif
-}
-
 struct pipe_context *
-nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
+nv30_create(struct pipe_screen *pscreen, void *priv)
 {
        struct nv30_screen *screen = nv30_screen(pscreen);
        struct pipe_winsys *ws = pscreen->winsys;
@@ -74,20 +54,23 @@ nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
        if (!nv30)
                return NULL;
        nv30->screen = screen;
-       nv30->pctx_id = pctx_id;
 
        nv30->nvws = nvws;
 
        nv30->pipe.winsys = ws;
        nv30->pipe.screen = pscreen;
+       nv30->pipe.priv = priv;
        nv30->pipe.destroy = nv30_destroy;
        nv30->pipe.draw_arrays = nv30_draw_arrays;
        nv30->pipe.draw_elements = nv30_draw_elements;
        nv30->pipe.clear = nv30_clear;
        nv30->pipe.flush = nv30_flush;
 
-       nv30->pipe.is_texture_referenced = nv30_is_texture_referenced;
-       nv30->pipe.is_buffer_referenced = nv30_is_buffer_referenced;
+       nv30->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv30->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
+
+       screen->base.channel->user_private = nv30;
+       screen->base.channel->flush_notify = nv30_state_flush_notify;
 
        nv30_init_query_functions(nv30);
        nv30_init_surface_functions(nv30);