ilo: remove ilo_cbuf_state::count
authorChia-I Wu <olvaffe@gmail.com>
Fri, 28 Jun 2013 05:59:18 +0000 (13:59 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Fri, 28 Jun 2013 07:01:00 +0000 (15:01 +0800)
We can derive it from enabled_mask.

src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
src/gallium/drivers/ilo/ilo_gpe.h
src/gallium/drivers/ilo/ilo_state.c

index 7afe6af3b3b1afce3d673ae5d34a58fea78eccf9..cd67f85e68926b3ff6038b88e822aac72166abdd 100644 (file)
@@ -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) {
index 19c101c38c6eec3098390a41f6e52eefd9c99b47..fc16f80a54a7dfd564de9e2b2b083cea4f354c0a 100644 (file)
@@ -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) {
index 1f5f47cacaa0b3c1f8f00d9f70b017cffe3cb248..67674768e356f69e5f29d48165609b29a882723b 100644 (file)
@@ -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 {
index 87b4e2992a485accead056691b34f067f002a7e8..c6790045c364bc057a75159e52ad099c85c64ab7 100644 (file)
@@ -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);
    }
 }