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

Author: Ben Skeggs <[email protected]>
Date:   Tue Oct  6 13:55:48 2009 +1000

nv50: fix segfault when there's gaps in enabled texture units

Tested with progs/demos/multiarb.

---

 src/gallium/drivers/nv50/nv50_state_validate.c |   11 +++++++----
 src/gallium/drivers/nv50/nv50_tex.c            |    3 +++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c 
b/src/gallium/drivers/nv50/nv50_state_validate.c
index 867b1ea..fd27620 100644
--- a/src/gallium/drivers/nv50/nv50_state_validate.c
+++ b/src/gallium/drivers/nv50/nv50_state_validate.c
@@ -356,13 +356,16 @@ viewport_uptodate:
        if (nv50->dirty & NV50_NEW_SAMPLER) {
                int i;
 
-               so = so_new(nv50->sampler_nr * 8 + 3, 0);
+               so = so_new(nv50->sampler_nr * 9 + 2, 0);
                so_method(so, tesla, NV50TCL_CB_ADDR, 1);
                so_data  (so, NV50_CB_TSC);
-               so_method(so, tesla, NV50TCL_CB_DATA(0) | 0x40000000,
-                       nv50->sampler_nr * 8);
-               for (i = 0; i < nv50->sampler_nr; i++)
+               for (i = 0; i < nv50->sampler_nr; i++) {
+                       if (!nv50->sampler[i])
+                               continue;
+
+                       so_method(so, tesla, NV50TCL_CB_DATA(0) | (2<<29), 8);
                        so_datap (so, nv50->sampler[i]->tsc, 8);
+               }
                so_ref(so, &nv50->state.tsc_upload);
                so_ref(NULL, &so);
        }
diff --git a/src/gallium/drivers/nv50/nv50_tex.c 
b/src/gallium/drivers/nv50/nv50_tex.c
index 21825a0..72d3315 100644
--- a/src/gallium/drivers/nv50/nv50_tex.c
+++ b/src/gallium/drivers/nv50/nv50_tex.c
@@ -157,6 +157,9 @@ nv50_tex_validate(struct nv50_context *nv50)
        for (unit = 0; unit < nv50->miptree_nr; unit++) {
                struct nv50_miptree *mt = nv50->miptree[unit];
 
+               if (!mt)
+                       continue;
+
                so_method(so, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
                if (nv50_tex_construct(nv50, so, mt, unit)) {
                        NOUVEAU_ERR("failed tex validate\n");

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to