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 dbe8a6e7bf5816620f667f97c1f478cf3fd70a01..0cb66041d50ac12d21cd9161e32523e874d8a1f8 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 17166c9f51de49f07281928fa3ae33ac09d07871..10d984ace9b6a556d3be85a1cd19932e3a6b7123 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 2842b2c90db54f7ce62fc7499733bed9ec9e2ca6..55326c787a801512060ea43a3a7bbc69bb5a78c9 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 a127b134ecd5043369915ae96b9d90e707b70156..933176fc32adf2c3c245346b372d66eb149b35c6 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 f1e003c95373f752bf78a3d9f8b413eb66c9118a..36a6aa7a74e230213e3d07d9fe3a8da1fb3eab58 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 b32d0d83ba0642fd111352c74be272447c866277..9a48739661ba90efbbd0513f5ebc6ad3a14b5c7a 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 fc932f1f90e13c69c782f15e2b47fb2dadeae045..a4eaa9566089e4fb3ac15e66366ae53aa2a92c74 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 a3e65b96f7b54c89deb13bd5e159e9a3b5cd53cc..d8300fd69f647a95ed00ce0581deed5012707a3b 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 4229c0a0e1478bc33842e4416e0283fdf751dd73..8d49366dfcb813dd91e54812593e52caeb760466 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 4e236712027accfc92f896f380153dea6881a93b..7f008274a4e301d5621234853afbfb036e51bb3e 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 97bc83292d4dd0edf3217bbf4af7a8e38701d3b6..a3d594167aad1c668c93ff74a85996220397a658 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 fca078b174a4f1d3178bee90e9869a21214ffcb3..7ef27bb671c2b1980202c379b63e462519a5a520 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 4608854d7111734de2136facf4b6f4c1cf3acdf1..fd2dab856defe1543d55167c5aef3b2b3c54e767 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"