From 34ce1a850236b94186f73c24a7ddb0f18075eb94 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 7 Nov 2013 17:28:33 -0700 Subject: [PATCH] svga: improve loops over color buffers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Only loop over the actual number of color buffers supported, not PIPE_MAX_COLOR_BUFS. Reviewed-by: José Fonseca --- src/gallium/drivers/svga/svga_context.c | 3 ++- src/gallium/drivers/svga/svga_pipe_misc.c | 6 ++++-- src/gallium/drivers/svga/svga_screen.c | 10 ++++++---- src/gallium/drivers/svga/svga_screen.h | 1 + src/gallium/drivers/svga/svga_state_framebuffer.c | 7 +++++-- src/gallium/drivers/svga/svga_surface.c | 3 ++- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c index 83afe79..21fe73a 100644 --- a/src/gallium/drivers/svga/svga_context.c +++ b/src/gallium/drivers/svga/svga_context.c @@ -246,6 +246,7 @@ void svga_hwtnl_flush_buffer( struct svga_context *svga, */ void svga_surfaces_flush(struct svga_context *svga) { + struct svga_screen *svgascreen = svga_screen(svga->pipe.screen); unsigned i; /* Emit buffered drawing commands. @@ -254,7 +255,7 @@ void svga_surfaces_flush(struct svga_context *svga) /* Emit back-copy from render target view to texture. */ - for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { + for (i = 0; i < svgascreen->max_color_buffers; i++) { if (svga->curr.framebuffer.cbufs[i]) svga_propagate_surface(svga, svga->curr.framebuffer.cbufs[i]); } diff --git a/src/gallium/drivers/svga/svga_pipe_misc.c b/src/gallium/drivers/svga/svga_pipe_misc.c index f1c007b..2c88e2a 100644 --- a/src/gallium/drivers/svga/svga_pipe_misc.c +++ b/src/gallium/drivers/svga/svga_pipe_misc.c @@ -28,6 +28,7 @@ #include "util/u_inlines.h" #include "svga_context.h" +#include "svga_screen.h" #include "svga_surface.h" @@ -52,11 +53,12 @@ static void svga_set_polygon_stipple( struct pipe_context *pipe, void svga_cleanup_framebuffer(struct svga_context *svga) { + struct svga_screen *svgascreen = svga_screen(svga->pipe.screen); struct pipe_framebuffer_state *curr = &svga->curr.framebuffer; struct pipe_framebuffer_state *hw = &svga->state.hw_clear.framebuffer; - int i; + unsigned i; - for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { + for (i = 0; i < svgascreen->max_color_buffers; i++) { pipe_surface_reference(&curr->cbufs[i], NULL); pipe_surface_reference(&hw->cbufs[i], NULL); } diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index cc6214d..3c013ea 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -154,10 +154,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_TGSI_TEXCOORD: return 0; case PIPE_CAP_MAX_RENDER_TARGETS: - /* The SVGA3D device always supports 4 targets at this time, regardless - * of what querying SVGA3D_DEVCAP_MAX_RENDER_TARGETS might return. - */ - return 4; + return svgascreen->max_color_buffers; case PIPE_CAP_OCCLUSION_QUERY: return 1; case PIPE_CAP_QUERY_TIME_ELAPSED: @@ -661,6 +658,11 @@ svga_screen_create(struct svga_winsys_screen *sws) svgascreen->maxPointSize = MIN2(result.f, 80.0f); } + /* The SVGA3D device always supports 4 targets at this time, regardless + * of what querying SVGA3D_DEVCAP_MAX_RENDER_TARGETS might return. + */ + svgascreen->max_color_buffers = 4; + pipe_mutex_init(svgascreen->tex_mutex); pipe_mutex_init(svgascreen->swc_mutex); diff --git a/src/gallium/drivers/svga/svga_screen.h b/src/gallium/drivers/svga/svga_screen.h index 0606147..517a3fa 100644 --- a/src/gallium/drivers/svga/svga_screen.h +++ b/src/gallium/drivers/svga/svga_screen.h @@ -48,6 +48,7 @@ struct svga_screen SVGA3dHardwareVersion hw_version; float maxPointSize; + unsigned max_color_buffers; struct { boolean force_level_surface_view; diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c index 4254404..6976d37 100644 --- a/src/gallium/drivers/svga/svga_state_framebuffer.c +++ b/src/gallium/drivers/svga/svga_state_framebuffer.c @@ -31,6 +31,7 @@ #include "svga_state.h" #include "svga_cmd.h" #include "svga_debug.h" +#include "svga_screen.h" /* @@ -54,6 +55,7 @@ static enum pipe_error emit_framebuffer( struct svga_context *svga, unsigned dirty ) { + struct svga_screen *svgascreen = svga_screen(svga->pipe.screen); const struct pipe_framebuffer_state *curr = &svga->curr.framebuffer; struct pipe_framebuffer_state *hw = &svga->state.hw_clear.framebuffer; boolean reemit = svga->rebind.rendertargets; @@ -65,7 +67,7 @@ emit_framebuffer( struct svga_context *svga, * dirty, to ensure that the resources are paged in. */ - for(i = 0; i < PIPE_MAX_COLOR_BUFS; ++i) { + for (i = 0; i < svgascreen->max_color_buffers; i++) { if (curr->cbufs[i] != hw->cbufs[i] || (reemit && hw->cbufs[i])) { if (svga->curr.nr_fbs++ > MAX_RT_PER_BATCH) @@ -118,13 +120,14 @@ emit_framebuffer( struct svga_context *svga, enum pipe_error svga_reemit_framebuffer_bindings(struct svga_context *svga) { + struct svga_screen *svgascreen = svga_screen(svga->pipe.screen); struct pipe_framebuffer_state *hw = &svga->state.hw_clear.framebuffer; unsigned i; enum pipe_error ret; assert(svga->rebind.rendertargets); - for (i = 0; i < MIN2(PIPE_MAX_COLOR_BUFS, 8); ++i) { + for (i = 0; i < svgascreen->max_color_buffers; i++) { if (hw->cbufs[i]) { ret = SVGA3D_SetRenderTarget(svga->swc, SVGA3D_RT_COLOR0 + i, hw->cbufs[i]); if (ret != PIPE_OK) { diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c index 3cbe4cb..5fafadf 100644 --- a/src/gallium/drivers/svga/svga_surface.c +++ b/src/gallium/drivers/svga/svga_surface.c @@ -323,9 +323,10 @@ svga_mark_surface_dirty(struct pipe_surface *surf) void svga_mark_surfaces_dirty(struct svga_context *svga) { + struct svga_screen *svgascreen = svga_screen(svga->pipe.screen); unsigned i; - for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { + for (i = 0; i < svgascreen->max_color_buffers; i++) { if (svga->curr.framebuffer.cbufs[i]) svga_mark_surface_dirty(svga->curr.framebuffer.cbufs[i]); } -- 2.7.4