nouveau: implement is_{texture,buffer}_referenced properly
authorBen Skeggs <bskeggs@redhat.com>
Sun, 18 Oct 2009 23:28:59 +0000 (09:28 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Sun, 18 Oct 2009 23:49:02 +0000 (09:49 +1000)
15 files changed:
src/gallium/drivers/nouveau/Makefile
src/gallium/drivers/nouveau/nouveau_context.c [new file with mode: 0644]
src/gallium/drivers/nouveau/nouveau_context.h [new file with mode: 0644]
src/gallium/drivers/nv04/nv04_context.c
src/gallium/drivers/nv04/nv04_context.h
src/gallium/drivers/nv10/nv10_context.c
src/gallium/drivers/nv10/nv10_context.h
src/gallium/drivers/nv20/nv20_context.c
src/gallium/drivers/nv20/nv20_context.h
src/gallium/drivers/nv30/nv30_context.c
src/gallium/drivers/nv30/nv30_context.h
src/gallium/drivers/nv40/nv40_context.c
src/gallium/drivers/nv40/nv40_context.h
src/gallium/drivers/nv50/nv50_context.c
src/gallium/drivers/nv50/nv50_context.h

index dbe8a6e..0cb6604 100644 (file)
@@ -3,6 +3,7 @@ include $(TOP)/configs/current
 
 LIBNAME = nouveau
 
-C_SOURCES = nouveau_screen.c
+C_SOURCES = nouveau_screen.c \
+           nouveau_context.c
 
 include ../../Makefile.template
diff --git a/src/gallium/drivers/nouveau/nouveau_context.c b/src/gallium/drivers/nouveau/nouveau_context.c
new file mode 100644 (file)
index 0000000..2344386
--- /dev/null
@@ -0,0 +1,41 @@
+#include <pipe/p_defines.h>
+#include <pipe/p_context.h>
+
+#include "nouveau/nouveau_screen.h"
+#include "nouveau/nouveau_context.h"
+
+#include "nouveau/nouveau_bo.h"
+
+static unsigned int
+nouveau_reference_flags(struct nouveau_bo *bo)
+{
+       uint32_t bo_flags;
+       int flags = 0;
+
+       bo_flags = nouveau_bo_pending(bo);
+       if (bo_flags & NOUVEAU_BO_RD)
+               flags |= PIPE_REFERENCED_FOR_READ;
+       if (bo_flags & NOUVEAU_BO_WR)
+               flags |= PIPE_REFERENCED_FOR_WRITE;
+
+       return flags;
+}
+
+unsigned int
+nouveau_is_texture_referenced(struct pipe_context *pipe,
+                             struct pipe_texture *pt,
+                             unsigned face, unsigned level)
+{
+       struct nouveau_miptree *mt = nouveau_miptree(pt);
+
+       return nouveau_reference_flags(mt->bo);
+}
+
+unsigned int
+nouveau_is_buffer_referenced(struct pipe_context *pipe, struct pipe_buffer *pb)
+{
+       struct nouveau_bo *bo = nouveau_bo(pb);
+
+       return nouveau_reference_flags(bo);
+}
+
diff --git a/src/gallium/drivers/nouveau/nouveau_context.h b/src/gallium/drivers/nouveau/nouveau_context.h
new file mode 100644 (file)
index 0000000..6a28d40
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef __NOUVEAU_CONTEXT_H__
+#define __NOUVEAU_CONTEXT_H__
+
+unsigned int
+nouveau_is_texture_referenced(struct pipe_context *, struct pipe_texture *,
+                             unsigned face, unsigned level);
+
+unsigned int
+nouveau_is_buffer_referenced(struct pipe_context *, struct pipe_buffer *);
+
+#endif
index 17166c9..10d984a 100644 (file)
@@ -64,30 +64,6 @@ nv04_init_hwctx(struct nv04_context *nv04)
        return TRUE;
 }
 
-static unsigned int
-nv04_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv04_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-
 struct pipe_context *
 nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -113,8 +89,8 @@ nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv04->pipe.clear = nv04_clear;
        nv04->pipe.flush = nv04_flush;
 
-       nv04->pipe.is_texture_referenced = nv04_is_texture_referenced;
-       nv04->pipe.is_buffer_referenced = nv04_is_buffer_referenced;
+       nv04->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv04->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
 
        nv04_init_surface_functions(nv04);
        nv04_init_state_functions(nv04);
index 2842b2c..55326c7 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
+#include "nouveau/nouveau_context.h"
 
 #define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
        struct nv04_screen *ctx = nv04->screen
index a127b13..933176f 100644 (file)
@@ -257,29 +257,6 @@ nv10_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
 {
 }
 
-static unsigned int
-nv10_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv10_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
 struct pipe_context *
 nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -305,8 +282,8 @@ nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv10->pipe.clear = nv10_clear;
        nv10->pipe.flush = nv10_flush;
 
-       nv10->pipe.is_texture_referenced = nv10_is_texture_referenced;
-       nv10->pipe.is_buffer_referenced = nv10_is_buffer_referenced;
+       nv10->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv10->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
 
        nv10_init_surface_functions(nv10);
        nv10_init_state_functions(nv10);
index f1e003c..36a6aa7 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
+#include "nouveau/nouveau_context.h"
 
 #define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
        struct nv10_screen *ctx = nv10->screen
index b32d0d8..9a48739 100644 (file)
@@ -380,30 +380,6 @@ nv20_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
 {
 }
 
-
-static unsigned int
-nv20_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv20_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
 struct pipe_context *
 nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -429,8 +405,8 @@ nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv20->pipe.clear = nv20_clear;
        nv20->pipe.flush = nv20_flush;
 
-       nv20->pipe.is_texture_referenced = nv20_is_texture_referenced;
-       nv20->pipe.is_buffer_referenced = nv20_is_buffer_referenced;
+       nv20->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv20->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
 
        nv20_init_surface_functions(nv20);
        nv20_init_state_functions(nv20);
index fc932f1..a4eaa95 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
+#include "nouveau/nouveau_context.h"
 
 #define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
        struct nv20_screen *ctx = nv20->screen
index a3e65b9..d8300fd 100644 (file)
@@ -31,37 +31,6 @@ nv30_destroy(struct pipe_context *pipe)
        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)
 {
@@ -86,8 +55,8 @@ nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
        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;
 
        nv30_init_query_functions(nv30);
        nv30_init_surface_functions(nv30);
index 4229c0a..8d49366 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
+#include "nouveau/nouveau_context.h"
 
 #define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
        struct nv30_screen *ctx = nv30->screen
index 4e23671..7f00827 100644 (file)
@@ -31,37 +31,6 @@ nv40_destroy(struct pipe_context *pipe)
        FREE(nv40);
 }
 
-static unsigned int
-nv40_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Return the correct result. We can't always 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
-nv40_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Return the correct result. We can't always 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 *
 nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -86,8 +55,8 @@ nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
        nv40->pipe.clear = nv40_clear;
        nv40->pipe.flush = nv40_flush;
 
-       nv40->pipe.is_texture_referenced = nv40_is_texture_referenced;
-       nv40->pipe.is_buffer_referenced = nv40_is_buffer_referenced;
+       nv40->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv40->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
 
        nv40_init_query_functions(nv40);
        nv40_init_surface_functions(nv40);
index 97bc832..a3d5941 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
+#include "nouveau/nouveau_context.h"
 
 #define NOUVEAU_PUSH_CONTEXT(ctx)                                              \
        struct nv40_screen *ctx = nv40->screen
index fca078b..7ef27bb 100644 (file)
@@ -60,29 +60,6 @@ nv50_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
 {
 }
 
-static unsigned int
-nv50_is_texture_referenced( struct pipe_context *pipe,
-                           struct pipe_texture *texture,
-                           unsigned face, unsigned level)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-nv50_is_buffer_referenced( struct pipe_context *pipe,
-                          struct pipe_buffer *buf)
-{
-   /**
-    * FIXME: Optimize.
-    */
-
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
 struct pipe_context *
 nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
 {
@@ -108,8 +85,8 @@ nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
 
        nv50->pipe.flush = nv50_flush;
 
-       nv50->pipe.is_texture_referenced = nv50_is_texture_referenced;
-       nv50->pipe.is_buffer_referenced = nv50_is_buffer_referenced;
+       nv50->pipe.is_texture_referenced = nouveau_is_texture_referenced;
+       nv50->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
 
        screen->base.channel->user_private = nv50;
        screen->base.channel->flush_notify = nv50_state_flush_notify;
index 4608854..fd2dab8 100644 (file)
@@ -14,6 +14,7 @@
 #include "nouveau/nouveau_winsys.h"
 #include "nouveau/nouveau_gldefs.h"
 #include "nouveau/nouveau_stateobj.h"
+#include "nouveau/nouveau_context.h"
 
 #include "nv50_screen.h"
 #include "nv50_program.h"