[Mesa-dev] [PATCH 3/3] svga: improve loops over color buffers
Brian Paul
brianp at vmware.com
Thu Nov 7 16:33:13 PST 2013
Only loop over the actual number of color buffers supported, not
PIPE_MAX_COLOR_BUFS.
---
src/gallium/drivers/svga/svga_context.c | 3 ++-
src/gallium/drivers/svga/svga_pipe_misc.c | 5 +++--
src/gallium/drivers/svga/svga_screen.c | 10 ++++++----
src/gallium/drivers/svga/svga_screen.h | 1 +
src/gallium/drivers/svga/svga_state_framebuffer.c | 6 ++++--
src/gallium/drivers/svga/svga_surface.c | 3 ++-
6 files changed, 18 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..0fd92428c 100644
--- a/src/gallium/drivers/svga/svga_pipe_misc.c
+++ b/src/gallium/drivers/svga/svga_pipe_misc.c
@@ -52,11 +52,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..fb041a3 100644
--- a/src/gallium/drivers/svga/svga_state_framebuffer.c
+++ b/src/gallium/drivers/svga/svga_state_framebuffer.c
@@ -54,6 +54,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 +66,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 +119,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]);
}
--
1.7.10.4
More information about the mesa-dev
mailing list