aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2013-11-07 17:28:33 -0700
committerBrian Paul <[email protected]>2013-11-11 08:12:18 -0700
commit34ce1a850236b94186f73c24a7ddb0f18075eb94 (patch)
treeb5e450678aba1ab8d5ca47dc07ee5eda9b53f38e
parent2182d2db28e9ae5c276dcbad1309cf3484a4476e (diff)
svga: improve loops over color buffers
Only loop over the actual number of color buffers supported, not PIPE_MAX_COLOR_BUFS. Reviewed-by: José Fonseca <[email protected]>
-rw-r--r--src/gallium/drivers/svga/svga_context.c3
-rw-r--r--src/gallium/drivers/svga/svga_pipe_misc.c6
-rw-r--r--src/gallium/drivers/svga/svga_screen.c10
-rw-r--r--src/gallium/drivers/svga/svga_screen.h1
-rw-r--r--src/gallium/drivers/svga/svga_state_framebuffer.c7
-rw-r--r--src/gallium/drivers/svga/svga_surface.c3
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 83afe796f4b..21fe73ad152 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 f1c007b5594..2c88e2a90de 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 cc6214dfbc5..3c013eaec49 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 0606147dd20..517a3fa844a 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 42544047bdc..6976d37e294 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 3cbe4cb80d4..5fafadf6175 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]);
}