Module: Mesa
Branch: 10.2
Commit: b20c82f74c44941368c681fb118338a29c2b1ea5
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b20c82f74c44941368c681fb118338a29c2b1ea5

Author: Rob Clark <robcl...@freedesktop.org>
Date:   Mon Jun  9 13:34:07 2014 -0400

freedreno: fix for null textures

Some apps seem to give us a null sampler/view for texture slots which
come before the last used texture slot.  In particular 0ad triggers
this.

Signed-off-by: Rob Clark <robcl...@freedesktop.org>
(cherry picked from commit 6aeeb706d218be030b39e431e53ec07edb974564)

---

 src/gallium/drivers/freedreno/a3xx/fd3_emit.c     |   12 ++++++++----
 src/gallium/drivers/freedreno/freedreno_texture.c |    4 ++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c 
b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index c78d5e8..4c6b5c1 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -195,8 +195,10 @@ emit_textures(struct fd_ringbuffer *ring,
                OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
                                CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
                for (i = 0; i < tex->num_textures; i++) {
-                       struct fd3_pipe_sampler_view *view =
-                                       fd3_pipe_sampler_view(tex->textures[i]);
+                       static const struct fd3_pipe_sampler_view dummy_view = 
{};
+                       const struct fd3_pipe_sampler_view *view = 
tex->textures[i] ?
+                                       fd3_pipe_sampler_view(tex->textures[i]) 
:
+                                       &dummy_view;
                        OUT_RING(ring, view->texconst0);
                        OUT_RING(ring, view->texconst1);
                        OUT_RING(ring, view->texconst2 |
@@ -213,8 +215,10 @@ emit_textures(struct fd_ringbuffer *ring,
                OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
                                CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
                for (i = 0; i < tex->num_textures; i++) {
-                       struct fd3_pipe_sampler_view *view =
-                                       fd3_pipe_sampler_view(tex->textures[i]);
+                       static const struct fd3_pipe_sampler_view dummy_view = 
{};
+                       const struct fd3_pipe_sampler_view *view = 
tex->textures[i] ?
+                                       fd3_pipe_sampler_view(tex->textures[i]) 
:
+                                       &dummy_view;
                        struct fd_resource *rsc = view->tex_resource;
 
                        for (j = 0; j < view->mipaddrs; j++) {
diff --git a/src/gallium/drivers/freedreno/freedreno_texture.c 
b/src/gallium/drivers/freedreno/freedreno_texture.c
index 8fb9419..212e506 100644
--- a/src/gallium/drivers/freedreno/freedreno_texture.c
+++ b/src/gallium/drivers/freedreno/freedreno_texture.c
@@ -57,7 +57,7 @@ static void bind_sampler_states(struct fd_texture_stateobj 
*prog,
 
        for (i = 0; i < nr; i++) {
                if (hwcso[i])
-                       new_nr++;
+                       new_nr = i + 1;
                prog->samplers[i] = hwcso[i];
                prog->dirty_samplers |= (1 << i);
        }
@@ -78,7 +78,7 @@ static void set_sampler_views(struct fd_texture_stateobj 
*prog,
 
        for (i = 0; i < nr; i++) {
                if (views[i])
-                       new_nr++;
+                       new_nr = i + 1;
                pipe_sampler_view_reference(&prog->textures[i], views[i]);
                prog->dirty_samplers |= (1 << i);
        }

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to