Merge branch 'mesa_7_6_branch'
[mesa.git] / src / gallium / drivers / nv50 / nv50_state_validate.c
index a879df2e6e29af1665c51b7fc9fcaf4033eef4ff..fd276203710f570f3cfc40dd3cea681ad5e671ff 100644 (file)
@@ -33,7 +33,7 @@ nv50_state_validate_fb(struct nv50_context *nv50)
 
        for (i = 0; i < fb->nr_cbufs; i++) {
                struct pipe_texture *pt = fb->cbufs[i]->texture;
-               struct nouveau_bo *bo = nv50_miptree(pt)->bo;
+               struct nouveau_bo *bo = nv50_miptree(pt)->base.bo;
 
                if (!gw) {
                        w = fb->cbufs[i]->width;
@@ -57,6 +57,9 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                case PIPE_FORMAT_A8R8G8B8_UNORM:
                        so_data(so, NV50TCL_RT_FORMAT_A8R8G8B8_UNORM);
                        break;
+               case PIPE_FORMAT_X8R8G8B8_UNORM:
+                       so_data(so, NV50TCL_RT_FORMAT_X8R8G8B8_UNORM);
+                       break;
                case PIPE_FORMAT_R5G6B5_UNORM:
                        so_data(so, NV50TCL_RT_FORMAT_R5G6B5_UNORM);
                        break;
@@ -66,7 +69,8 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                        so_data(so, NV50TCL_RT_FORMAT_X8R8G8B8_UNORM);
                        break;
                }
-               so_data(so, bo->tile_mode << 4);
+               so_data(so, nv50_miptree(pt)->
+                               level[fb->cbufs[i]->level].tile_mode << 4);
                so_data(so, 0x00000000);
 
                so_method(so, tesla, 0x1224, 1);
@@ -75,7 +79,7 @@ nv50_state_validate_fb(struct nv50_context *nv50)
 
        if (fb->zsbuf) {
                struct pipe_texture *pt = fb->zsbuf->texture;
-               struct nouveau_bo *bo = nv50_miptree(pt)->bo;
+               struct nouveau_bo *bo = nv50_miptree(pt)->base.bo;
 
                if (!gw) {
                        w = fb->zsbuf->width;
@@ -110,7 +114,8 @@ nv50_state_validate_fb(struct nv50_context *nv50)
                        so_data(so, NV50TCL_ZETA_FORMAT_S8Z24_UNORM);
                        break;
                }
-               so_data(so, bo->tile_mode << 4);
+               so_data(so, nv50_miptree(pt)->
+                               level[fb->zsbuf->level].tile_mode << 4);
                so_data(so, 0x00000000);
 
                so_method(so, tesla, 0x1538, 1);
@@ -187,6 +192,8 @@ nv50_state_emit(struct nv50_context *nv50)
                so_emit(chan, nv50->state.vertprog);
        if (nv50->state.dirty & NV50_NEW_FRAGPROG)
                so_emit(chan, nv50->state.fragprog);
+       if (nv50->state.dirty & (NV50_NEW_FRAGPROG | NV50_NEW_VERTPROG))
+               so_emit(chan, nv50->state.programs);
        if (nv50->state.dirty & NV50_NEW_RASTERIZER)
                so_emit(chan, nv50->state.rast);
        if (nv50->state.dirty & NV50_NEW_BLEND_COLOUR)
@@ -204,8 +211,16 @@ nv50_state_emit(struct nv50_context *nv50)
        if (nv50->state.dirty & NV50_NEW_ARRAYS) {
                so_emit(chan, nv50->state.vtxfmt);
                so_emit(chan, nv50->state.vtxbuf);
+               if (nv50->state.vtxattr)
+                       so_emit(chan, nv50->state.vtxattr);
        }
        nv50->state.dirty = 0;
+}
+
+void
+nv50_state_flush_notify(struct nouveau_channel *chan)
+{
+       struct nv50_context *nv50 = chan->user_private;
 
        so_emit_reloc_markers(chan, nv50->state.fb);
        so_emit_reloc_markers(chan, nv50->state.vertprog);
@@ -236,6 +251,9 @@ nv50_state_validate(struct nv50_context *nv50)
        if (nv50->dirty & (NV50_NEW_FRAGPROG | NV50_NEW_FRAGPROG_CB))
                nv50_fragprog_validate(nv50);
 
+       if (nv50->dirty & (NV50_NEW_FRAGPROG | NV50_NEW_VERTPROG))
+               nv50_linkage_validate(nv50);
+
        if (nv50->dirty & NV50_NEW_RASTERIZER)
                so_ref(nv50->rasterizer->so, &nv50->state.rast);
 
@@ -297,7 +315,7 @@ scissor_uptodate:
                        goto viewport_uptodate;
                nv50->state.viewport_bypass = bypass;
 
-               so = so_new(12, 0);
+               so = so_new(14, 0);
                if (!bypass) {
                        so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE(0), 3);
                        so_data  (so, fui(nv50->viewport.translate[0]));
@@ -310,12 +328,21 @@ scissor_uptodate:
 
                        so_method(so, tesla, NV50TCL_VIEWPORT_TRANSFORM_EN, 1);
                        so_data  (so, 1);
+                       /* 0x0000 = remove whole primitive only (xyz)
+                        * 0x1018 = remove whole primitive only (xy), clamp z
+                        * 0x1080 = clip primitive (xyz)
+                        * 0x1098 = clip primitive (xy), clamp z
+                        */
+                       so_method(so, tesla, NV50TCL_VIEW_VOLUME_CLIP_CTRL, 1);
+                       so_data  (so, 0x1080);
                        /* no idea what 0f90 does */
                        so_method(so, tesla, 0x0f90, 1);
                        so_data  (so, 0);
                } else {
                        so_method(so, tesla, NV50TCL_VIEWPORT_TRANSFORM_EN, 1);
                        so_data  (so, 0);
+                       so_method(so, tesla, NV50TCL_VIEW_VOLUME_CLIP_CTRL, 1);
+                       so_data  (so, 0x0000);
                        so_method(so, tesla, 0x0f90, 1);
                        so_data  (so, 1);
                }
@@ -329,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);
        }