From 2c9b6a2164281f29217e75c3ab3a018dcd22ae11 Mon Sep 17 00:00:00 2001
From: Chia-I Wu <olvaffe@gmail.com>
Date: Fri, 28 Jun 2013 13:59:18 +0800
Subject: ilo: remove ilo_cbuf_state::count

We can derive it from enabled_mask.
---
 src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c | 24 +++++++++++-------------
 src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c |  2 +-
 src/gallium/drivers/ilo/ilo_gpe.h              |  1 -
 src/gallium/drivers/ilo/ilo_state.c            |  2 --
 4 files changed, 12 insertions(+), 17 deletions(-)

(limited to 'src/gallium/drivers/ilo')

diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
index 7afe6af3b3b..cd67f85e689 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
@@ -1003,10 +1003,9 @@ gen6_pipeline_state_surfaces_const(struct ilo_3d_pipeline *p,
                                    int shader_type,
                                    struct gen6_pipeline_session *session)
 {
-   const struct ilo_cbuf_cso *buffers = ilo->cbuf[shader_type].cso;
-   const int num_buffers = ilo->cbuf[shader_type].count;
+   const struct ilo_cbuf_state *cbuf = &ilo->cbuf[shader_type];
    uint32_t *surface_state;
-   int offset, i;
+   int offset, count, i;
    bool skip = false;
 
    /* SURFACE_STATEs for constant buffers */
@@ -1041,22 +1040,21 @@ gen6_pipeline_state_surfaces_const(struct ilo_3d_pipeline *p,
    if (skip)
       return;
 
-   for (i = 0; i < num_buffers; i++) {
-      if (buffers[i].resource) {
-         const struct ilo_view_surface *surf = &buffers[i].surface;
-
-         surface_state[i] =
-            p->gen6_SURFACE_STATE(p->dev, surf, false, p->cp);
+   count = util_last_bit(cbuf->enabled_mask);
+   for (i = 0; i < count; i++) {
+      if (cbuf->cso[i].resource) {
+         surface_state[i] = p->gen6_SURFACE_STATE(p->dev,
+               &cbuf->cso[i].surface, false, p->cp);
       }
       else {
          surface_state[i] = 0;
       }
    }
 
-   memset(&surface_state[i], 0, (ILO_MAX_CONST_BUFFERS - i) * 4);
+   memset(&surface_state[count], 0, (ILO_MAX_CONST_BUFFERS - count) * 4);
 
-   if (i && session->num_surfaces[shader_type] < offset + i)
-      session->num_surfaces[shader_type] = offset + i;
+   if (count && session->num_surfaces[shader_type] < offset + count)
+      session->num_surfaces[shader_type] = offset + count;
 }
 
 static void
@@ -1542,7 +1540,7 @@ gen6_pipeline_estimate_states(const struct ilo_3d_pipeline *p,
 
    for (shader_type = 0; shader_type < PIPE_SHADER_TYPES; shader_type++) {
       count += ilo->view[shader_type].count;
-      count += ilo->cbuf[shader_type].count;
+      count += util_bitcount(ilo->cbuf[shader_type].enabled_mask);
    }
 
    if (count) {
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
index 19c101c38c6..fc16f80a54a 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
@@ -712,7 +712,7 @@ gen7_pipeline_estimate_states(const struct ilo_3d_pipeline *p,
    count = ilo->fb.state.nr_cbufs;
    for (shader_type = 0; shader_type < PIPE_SHADER_TYPES; shader_type++) {
       count += ilo->view[shader_type].count;
-      count += ilo->cbuf[shader_type].count;
+      count += util_bitcount(ilo->cbuf[shader_type].enabled_mask);
    }
 
    if (count) {
diff --git a/src/gallium/drivers/ilo/ilo_gpe.h b/src/gallium/drivers/ilo/ilo_gpe.h
index 1f5f47cacaa..67674768e35 100644
--- a/src/gallium/drivers/ilo/ilo_gpe.h
+++ b/src/gallium/drivers/ilo/ilo_gpe.h
@@ -222,7 +222,6 @@ struct ilo_cbuf_cso {
 struct ilo_cbuf_state {
    struct ilo_cbuf_cso cso[ILO_MAX_CONST_BUFFERS];
    uint32_t enabled_mask;
-   unsigned count;
 };
 
 struct ilo_resource_state {
diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c
index 87b4e2992a4..c6790045c36 100644
--- a/src/gallium/drivers/ilo/ilo_state.c
+++ b/src/gallium/drivers/ilo/ilo_state.c
@@ -122,8 +122,6 @@ finalize_constant_buffers(struct ilo_context *ilo)
             cbuf->user_buffer_size = 0;
          }
       }
-
-      ilo->cbuf[sh].count = util_last_bit(ilo->cbuf[sh].enabled_mask);
    }
 }
 
-- 
cgit v1.2.3