Mesa (master): r600g: fix up segfault with variation between views and count.

Dave Airlie airlied at kemper.freedesktop.org
Wed Jul 28 05:27:19 UTC 2010


Module: Mesa
Branch: master
Commit: 2ab24a6faedb0f9b93055cbf3d52be1120353ee1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ab24a6faedb0f9b93055cbf3d52be1120353ee1

Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Jul 28 15:26:14 2010 +1000

r600g: fix up segfault with variation between views and count.

For some reason gallium hands us something with lots of empty views, and
we are expected to deal with it, just do what r300g does for this bit.

---

 src/gallium/drivers/r600/r600_state.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 367a1f9..2fdcdea 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -481,18 +481,26 @@ static void r600_set_fragment_sampler_views(struct pipe_context *ctx,
 	struct r600_texture_resource *rtexture;
 	struct r600_context *rctx = r600_context(ctx);
 	struct pipe_sampler_view *tmp;
-	unsigned i;
+	unsigned i, real_num_views = 0;
 
 	if (views == NULL)
 		return;
 
+	for (i = 0; i < count; i++) {
+		if (views[i])
+			real_num_views++;
+	}
+
 	for (i = 0; i < rctx->nps_view; i++) {
 		tmp = &rctx->ps_view[i]->view;
 		pipe_sampler_view_reference(&tmp, NULL);
 		rctx->ps_view[i] = NULL;
 	}
-	rctx->nps_view = count;
+	rctx->nps_view = real_num_views;
 	for (i = 0; i < count; i++) {
+
+		if (!views[i])
+			continue;
 		rtexture = LIST_ENTRY(struct r600_texture_resource, views[i], view);
 		rctx->ps_view[i] = rtexture;
 		tmp = NULL;
@@ -508,18 +516,24 @@ static void r600_set_vertex_sampler_views(struct pipe_context *ctx,
 	struct r600_texture_resource *rtexture;
 	struct r600_context *rctx = r600_context(ctx);
 	struct pipe_sampler_view *tmp;
-	unsigned i;
+	unsigned i, real_num_views = 0;
 
 	if (views == NULL)
 		return;
 
+	for (i = 0; i < count; i++) {
+		if (views[i])
+			real_num_views++;
+	}
 	for (i = 0; i < rctx->nvs_view; i++) {
 		tmp = &rctx->vs_view[i]->view;
 		pipe_sampler_view_reference(&tmp, NULL);
 		rctx->vs_view[i] = NULL;
 	}
-	rctx->nps_view = count;
+	rctx->nvs_view = real_num_views;
 	for (i = 0; i < count; i++) {
+		if (!views[i])
+			continue;
 		rtexture = LIST_ENTRY(struct r600_texture_resource, views[i], view);
 		rctx->vs_view[i] = rtexture;
 		tmp = NULL;




More information about the mesa-commit mailing list