Mesa (master): nvc0: shrink CSOs a little

Christoph Bumiller chrisbmr at kemper.freedesktop.org
Sun Apr 10 05:07:43 PDT 2011


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

Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date:   Fri Apr  8 15:32:18 2011 +0200

nvc0: shrink CSOs a little

---

 src/gallium/drivers/nv50/nv50_state.c          |    6 ++--
 src/gallium/drivers/nvc0/nvc0_state.c          |   35 +++++++++++-------------
 src/gallium/drivers/nvc0/nvc0_state_validate.c |    7 ++---
 src/gallium/drivers/nvc0/nvc0_stateobj.h       |    6 ++--
 4 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c
index 030cdcb..ef5a184 100644
--- a/src/gallium/drivers/nv50/nv50_state.c
+++ b/src/gallium/drivers/nv50/nv50_state.c
@@ -155,7 +155,7 @@ nv50_blend_state_create(struct pipe_context *pipe,
          SB_DATA(so, cmask);
    }
 
-   assert(so->size < (sizeof(so->state) / sizeof(so->state[0])));
+   assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
    return so;
 }
 
@@ -262,7 +262,7 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
       SB_DATA    (so, fui(cso->offset_units * 2.0f));
    }
 
-   assert(so->size < (sizeof(so->state) / sizeof(so->state[0])));
+   assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
    return (void *)so;
 }
 
@@ -341,7 +341,7 @@ nv50_zsa_state_create(struct pipe_context *pipe,
       SB_DATA    (so, 0);
    }
 
-   assert(so->size < (sizeof(so->state) / sizeof(so->state[0])));
+   assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
    return (void *)so;
 }
 
diff --git a/src/gallium/drivers/nvc0/nvc0_state.c b/src/gallium/drivers/nvc0/nvc0_state.c
index db3b78f..85a4d99 100644
--- a/src/gallium/drivers/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nvc0/nvc0_state.c
@@ -93,9 +93,18 @@ nvc0_blend_state_create(struct pipe_context *pipe,
 
     SB_IMMED_3D(so, BLEND_INDEPENDENT, cso->independent_blend_enable);
 
+    if (!cso->logicop_enable)
+       SB_IMMED_3D(so, LOGIC_OP_ENABLE, 0);
+
+    if (cso->logicop_enable) {
+       SB_BEGIN_3D(so, LOGIC_OP_ENABLE, 2);
+       SB_DATA    (so, 1);
+       SB_DATA    (so, nvgl_logicop_func(cso->logicop_func));
+
+       SB_IMMED_3D(so, BLEND_ENABLES, 0);
+    } else
     if (!cso->independent_blend_enable) {
-        SB_BEGIN_3D(so, BLEND_ENABLES, 1);
-        SB_DATA    (so, cso->rt[0].blend_enable ? 0xff : 0);
+        SB_IMMED_3D(so, BLEND_ENABLES, cso->rt[0].blend_enable ? 0xff : 0);
 
         if (cso->rt[0].blend_enable) {
             SB_BEGIN_3D(so, BLEND_EQUATION_RGB, 5);
@@ -126,23 +135,14 @@ nvc0_blend_state_create(struct pipe_context *pipe,
             SB_DATA    (so, nvc0_blend_fac(cso->rt[i].alpha_src_factor));
             SB_DATA    (so, nvc0_blend_fac(cso->rt[i].alpha_dst_factor));
         }
-        SB_BEGIN_3D(so, BLEND_ENABLES, 1);
-        SB_DATA    (so, en);
+        SB_IMMED_3D(so, BLEND_ENABLES, en);
 
         SB_BEGIN_3D(so, COLOR_MASK(0), 8);
         for (i = 0; i < 8; ++i)
             SB_DATA(so, nvc0_colormask(cso->rt[i].colormask));
     }
 
-    if (cso->logicop_enable) {
-       SB_BEGIN_3D(so, LOGIC_OP_ENABLE, 2);
-       SB_DATA    (so, 1);
-       SB_DATA    (so, nvgl_logicop_func(cso->logicop_func));
-    } else {
-       SB_IMMED_3D(so, LOGIC_OP_ENABLE, 0);
-    }
-
-    assert(so->size < (sizeof(so->state) / sizeof(so->state[0])));
+    assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
     return so;
 }
 
@@ -195,15 +195,12 @@ nvc0_rasterizer_state_create(struct pipe_context *pipe,
        SB_BEGIN_3D(so, LINE_WIDTH_ALIASED, 1);
     SB_DATA    (so, fui(cso->line_width));
 
-    SB_BEGIN_3D(so, LINE_STIPPLE_ENABLE, 1);
+    SB_IMMED_3D(so, LINE_STIPPLE_ENABLE, cso->line_stipple_enable);
     if (cso->line_stipple_enable) {
-        SB_DATA    (so, 1);
         SB_BEGIN_3D(so, LINE_STIPPLE_PATTERN, 1);
         SB_DATA    (so, (cso->line_stipple_pattern << 8) |
                          cso->line_stipple_factor);
                     
-    } else {
-        SB_DATA    (so, 0);
     }
 
     SB_IMMED_3D(so, VP_POINT_SIZE_EN, cso->point_size_per_vertex);
@@ -257,7 +254,7 @@ nvc0_rasterizer_state_create(struct pipe_context *pipe,
         SB_DATA    (so, fui(cso->offset_units * 2.0f));
     }
 
-    assert(so->size < (sizeof(so->state) / sizeof(so->state[0])));
+    assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
     return (void *)so;
 }
 
@@ -328,7 +325,7 @@ nvc0_zsa_state_create(struct pipe_context *pipe,
       SB_DATA    (so, nvgl_comparison_op(cso->alpha.func));
    }
 
-   assert(so->size < (sizeof(so->state) / sizeof(so->state[0])));
+   assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
    return (void *)so;
 }
 
diff --git a/src/gallium/drivers/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nvc0/nvc0_state_validate.c
index bb81480..23a5526 100644
--- a/src/gallium/drivers/nvc0/nvc0_state_validate.c
+++ b/src/gallium/drivers/nvc0/nvc0_state_validate.c
@@ -156,11 +156,10 @@ static void
 nvc0_validate_stencil_ref(struct nvc0_context *nvc0)
 {
     struct nouveau_channel *chan = nvc0->screen->base.channel;
+    const ubyte *ref = &nvc0->stencil_ref.ref_value[0];
 
-    BEGIN_RING(chan, RING_3D(STENCIL_FRONT_FUNC_REF), 1);
-    OUT_RING  (chan, nvc0->stencil_ref.ref_value[0]);
-    BEGIN_RING(chan, RING_3D(STENCIL_BACK_FUNC_REF), 1);
-    OUT_RING  (chan, nvc0->stencil_ref.ref_value[1]);
+    IMMED_RING(chan, RING_3D(STENCIL_FRONT_FUNC_REF), ref[0]);
+    IMMED_RING(chan, RING_3D(STENCIL_BACK_FUNC_REF), ref[1]);
 }
 
 static void
diff --git a/src/gallium/drivers/nvc0/nvc0_stateobj.h b/src/gallium/drivers/nvc0/nvc0_stateobj.h
index cc6b04d..b300ec9 100644
--- a/src/gallium/drivers/nvc0/nvc0_stateobj.h
+++ b/src/gallium/drivers/nvc0/nvc0_stateobj.h
@@ -19,19 +19,19 @@
 struct nvc0_blend_stateobj {
    struct pipe_blend_state pipe;
    int size;
-   uint32_t state[72];
+   uint32_t state[69];
 };
 
 struct nvc0_rasterizer_stateobj {
    struct pipe_rasterizer_state pipe;
    int size;
-   uint32_t state[39];
+   uint32_t state[38];
 };
 
 struct nvc0_zsa_stateobj {
    struct pipe_depth_stencil_alpha_state pipe;
    int size;
-   uint32_t state[29];
+   uint32_t state[26];
 };
 
 struct nvc0_vertex_element {



More information about the mesa-commit mailing list