Module: Mesa Branch: i965g-restart Commit: 4e335a213acd535af81dd0c4b448003eb81db0cf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e335a213acd535af81dd0c4b448003eb81db0cf
Author: Keith Whitwell <kei...@vmware.com> Date: Wed Nov 4 19:32:44 2009 +0000 i965g: add missing is_*_referenced callbacks --- src/gallium/drivers/i965/brw_pipe_flush.c | 24 +++++++++++++++ src/gallium/drivers/i965/brw_screen.h | 12 +++++++ src/gallium/drivers/i965/brw_screen_buffers.c | 12 +++++++ src/gallium/drivers/i965/brw_screen_texture.c | 39 +++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 0 deletions(-) diff --git a/src/gallium/drivers/i965/brw_pipe_flush.c b/src/gallium/drivers/i965/brw_pipe_flush.c index 9b52b56..6ae3c57 100644 --- a/src/gallium/drivers/i965/brw_pipe_flush.c +++ b/src/gallium/drivers/i965/brw_pipe_flush.c @@ -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; } diff --git a/src/gallium/drivers/i965/brw_screen.h b/src/gallium/drivers/i965/brw_screen.h index dda516e..820c6a6 100644 --- a/src/gallium/drivers/i965/brw_screen.h +++ b/src/gallium/drivers/i965/brw_screen.h @@ -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 */ diff --git a/src/gallium/drivers/i965/brw_screen_buffers.c b/src/gallium/drivers/i965/brw_screen_buffers.c index 0bf885c..c0f19d6 100644 --- a/src/gallium/drivers/i965/brw_screen_buffers.c +++ b/src/gallium/drivers/i965/brw_screen_buffers.c @@ -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) { diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c index fe3e57d..c318b07 100644 --- a/src/gallium/drivers/i965/brw_screen_texture.c +++ b/src/gallium/drivers/i965/brw_screen_texture.c @@ -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; _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit