i965g: add missing is_*_referenced callbacks
authorKeith Whitwell <keithw@vmware.com>
Wed, 4 Nov 2009 19:32:44 +0000 (19:32 +0000)
committerKeith Whitwell <keithw@vmware.com>
Wed, 4 Nov 2009 19:32:44 +0000 (19:32 +0000)
src/gallium/drivers/i965/brw_pipe_flush.c
src/gallium/drivers/i965/brw_screen.h
src/gallium/drivers/i965/brw_screen_buffers.c
src/gallium/drivers/i965/brw_screen_texture.c

index 9b52b56eae7de9d425a529c3b42c1b61581e1460..6ae3c5776577067b9de9b2ff07768ffd05ff33d8 100644 (file)
@@ -2,6 +2,7 @@
 #include "util/u_upload_mgr.h"
 
 #include "brw_context.h"
+#include "brw_screen.h"
 #include "brw_batchbuffer.h"
 
 
@@ -44,10 +45,33 @@ brw_flush( struct pipe_context *pipe,
    *fence = NULL;
 }
 
+static unsigned brw_is_buffer_referenced(struct pipe_context *pipe,
+                                  struct pipe_buffer *buffer)
+{
+   struct brw_context *brw = brw_context(pipe);
+
+   return brw_is_buffer_referenced_by_bo( brw->brw_screen,
+                                          buffer,
+                                          brw->batch->buf );
+}
+
+static unsigned brw_is_texture_referenced(struct pipe_context *pipe,
+                                   struct pipe_texture *texture,
+                                   unsigned face,
+                                   unsigned level)
+{
+   struct brw_context *brw = brw_context(pipe);
+
+   return brw_is_texture_referenced_by_bo( brw->brw_screen,
+                                           texture, face, level,
+                                           brw->batch->buf );
+}
 
 void brw_pipe_flush_init( struct brw_context *brw )
 {
    brw->base.flush = brw_flush;
+   brw->base.is_buffer_referenced = brw_is_buffer_referenced;
+   brw->base.is_texture_referenced = brw_is_texture_referenced;
 }
 
 
index dda516ee68ccd3c6a2e691c0ca8a6e9e9f127bc9..820c6a6679fef8868b2599217beaaf1d8bd16a43 100644 (file)
@@ -183,4 +183,16 @@ void brw_screen_tex_surface_init( struct brw_screen *brw_screen );
 void brw_screen_buffer_init(struct brw_screen *brw_screen);
 
 
+boolean brw_is_texture_referenced_by_bo( struct brw_screen *brw_screen,
+                                         struct pipe_texture *texture,
+                                         unsigned face, 
+                                         unsigned level,
+                                         struct brw_winsys_buffer *bo );
+
+boolean brw_is_buffer_referenced_by_bo( struct brw_screen *brw_screen,
+                                        struct pipe_buffer *buffer,
+                                        struct brw_winsys_buffer *bo );
+
+
+
 #endif /* BRW_SCREEN_H */
index 0bf885ce8c60cecc4af69c48e1114ddc2a4b715d..c0f19d64aad7d03ec6d681e92a03ddc230ada329 100644 (file)
@@ -131,6 +131,18 @@ brw_user_buffer_create(struct pipe_screen *screen,
    return &buf->base; 
 }
 
+
+boolean brw_is_buffer_referenced_by_bo( struct brw_screen *brw_screen,
+                                     struct pipe_buffer *buffer,
+                                     struct brw_winsys_buffer *bo )
+{
+   struct brw_buffer *buf = brw_buffer(buffer);
+   if (buf->bo == NULL)
+      return FALSE;
+
+   return brw_screen->sws->bo_references( bo, buf->bo );
+}
+
    
 void brw_screen_buffer_init(struct brw_screen *brw_screen)
 {
index fe3e57da908112549496fcf0782b7635c2df4dc3..c318b07f97a693d08832b4252170914636da8095 100644 (file)
@@ -325,6 +325,45 @@ static boolean brw_is_format_supported( struct pipe_screen *screen,
 }
 
 
+boolean brw_is_texture_referenced_by_bo( struct brw_screen *brw_screen,
+                                      struct pipe_texture *texture,
+                                      unsigned face, 
+                                      unsigned level,
+                                      struct brw_winsys_buffer *bo )
+{
+   struct brw_texture *tex = brw_texture(texture);
+   struct brw_surface *surf;
+   int i;
+
+   /* XXX: this is subject to false positives if the underlying
+    * texture BO is referenced, we can't tell whether the sub-region
+    * we care about participates in that.
+    */
+   if (brw_screen->sws->bo_references( bo, tex->bo ))
+      return TRUE;
+
+   /* Find any view on this texture for this face/level and see if it
+    * is referenced:
+    */
+   for (i = 0; i < 2; i++) {
+      foreach (surf, &tex->views[i]) {
+         if (surf->bo == tex->bo)
+            continue;
+
+         if (surf->id.bits.face != face ||
+             surf->id.bits.level != level)
+            continue;
+         
+         if (brw_screen->sws->bo_references( bo, surf->bo))
+            return TRUE;
+      }
+   }
+
+   return FALSE;
+}
+
+
+
 void brw_screen_tex_init( struct brw_screen *brw_screen )
 {
    brw_screen->base.is_format_supported = brw_is_format_supported;