ilo: make pipe_draw_info a context state 50/7150/1
authorChia-I Wu <olvaffe@gmail.com>
Wed, 26 Jun 2013 03:52:55 +0000 (11:52 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Wed, 26 Jun 2013 08:42:46 +0000 (16:42 +0800)
Rename ilo_finalize_states() to ilo_finalize_3d_states(), and bind
pipe_draw_info to the context when it is called.  This saves us from having to
pass pipe_draw_info around in several places.

src/gallium/drivers/ilo/ilo_3d.c
src/gallium/drivers/ilo/ilo_3d_pipeline.c
src/gallium/drivers/ilo/ilo_3d_pipeline.h
src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.h
src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
src/gallium/drivers/ilo/ilo_context.h
src/gallium/drivers/ilo/ilo_state.c
src/gallium/drivers/ilo/ilo_state.h

index 9ce6b75..69808d9 100644 (file)
@@ -372,7 +372,6 @@ ilo_3d_destroy(struct ilo_3d *hw3d)
 
 static bool
 draw_vbo(struct ilo_3d *hw3d, const struct ilo_context *ilo,
-         const struct pipe_draw_info *info,
          int *prim_generated, int *prim_emitted)
 {
    bool need_flush = false;
@@ -410,7 +409,7 @@ draw_vbo(struct ilo_3d *hw3d, const struct ilo_context *ilo,
    if (need_flush)
       ilo_3d_pipeline_emit_flush(hw3d->pipeline);
 
-   return ilo_3d_pipeline_emit_draw(hw3d->pipeline, ilo, info,
+   return ilo_3d_pipeline_emit_draw(hw3d->pipeline, ilo,
          prim_generated, prim_emitted);
 }
 
@@ -527,8 +526,7 @@ ilo_find_sub_primitives(const void *elements, unsigned element_size,
 }
 
 static inline bool
-ilo_check_restart_index(struct ilo_context *ilo,
-                        const struct pipe_draw_info *info)
+ilo_check_restart_index(const struct ilo_context *ilo, unsigned restart_index)
 {
    /*
     * Haswell (GEN(7.5)) supports an arbitrary cut index, check everything
@@ -540,23 +538,22 @@ ilo_check_restart_index(struct ilo_context *ilo,
    /* Note: indices must be unsigned byte, unsigned short or unsigned int */
    switch (ilo->ib.state.index_size) {
    case 1:
-      return ((info->restart_index & 0xff) == 0xff);
+      return ((restart_index & 0xff) == 0xff);
       break;
    case 2:
-      return ((info->restart_index & 0xffff) == 0xffff);
+      return ((restart_index & 0xffff) == 0xffff);
       break;
    case 4:
-      return (info->restart_index == 0xffffffff);
+      return (restart_index == 0xffffffff);
       break;
    }
    return false;
 }
 
 static inline bool
-ilo_check_restart_prim_type(struct ilo_context *ilo,
-                            const struct pipe_draw_info *info)
+ilo_check_restart_prim_type(const struct ilo_context *ilo, unsigned prim)
 {
-   switch (info->mode) {
+   switch (prim) {
    case PIPE_PRIM_POINTS:
    case PIPE_PRIM_LINES:
    case PIPE_PRIM_LINE_STRIP:
@@ -705,20 +702,20 @@ ilo_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
        * Want to draw an indexed primitive using primitive restart
        * Check that HW can handle the request and fall to SW if not.
        */
-      if (!ilo_check_restart_index(ilo, info) ||
-          !ilo_check_restart_prim_type(ilo, info)) {
+      if (!ilo_check_restart_index(ilo, info->restart_index) ||
+          !ilo_check_restart_prim_type(ilo, info->mode)) {
          ilo_draw_vbo_with_sw_restart(pipe, info);
          return;
       }
    }
 
-   ilo_finalize_states(ilo);
+   ilo_finalize_3d_states(ilo, info);
 
    if (!upload_shaders(hw3d, ilo->shader_cache))
       return;
 
    /* If draw_vbo ever fails, return immediately. */
-   if (!draw_vbo(hw3d, ilo, info, &prim_generated, &prim_emitted))
+   if (!draw_vbo(hw3d, ilo, &prim_generated, &prim_emitted))
       return;
 
    /* clear dirty status */
index 5b4dae9..9d146d2 100644 (file)
@@ -149,7 +149,6 @@ handle_invalid_batch_bo(struct ilo_3d_pipeline *p, bool unset)
 bool
 ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p,
                           const struct ilo_context *ilo,
-                          const struct pipe_draw_info *info,
                           int *prim_generated, int *prim_emitted)
 {
    bool success;
@@ -181,7 +180,7 @@ ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p,
 
       /* draw! */
       ilo_cp_assert_no_implicit_flush(p->cp, true);
-      p->emit_draw(p, ilo, info);
+      p->emit_draw(p, ilo);
       ilo_cp_assert_no_implicit_flush(p->cp, false);
 
       err = intel_winsys_check_aperture_space(ilo->winsys, &p->cp->bo, 1);
@@ -204,10 +203,12 @@ ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p,
    }
 
    if (success) {
-      const int num_verts = u_vertices_per_prim(u_reduced_prim(info->mode));
+      const int num_verts =
+         u_vertices_per_prim(u_reduced_prim(ilo->draw->mode));
       const int max_emit =
          (p->state.so_max_vertices - p->state.so_num_vertices) / num_verts;
-      const int generated = u_reduced_prims_for_vertices(info->mode, info->count);
+      const int generated =
+         u_reduced_prims_for_vertices(ilo->draw->mode, ilo->draw->count);
       const int emitted = MIN2(generated, max_emit);
 
       p->state.so_num_vertices += emitted * num_verts;
index 7aa17b8..7a867aa 100644 (file)
@@ -33,7 +33,6 @@
 #include "ilo_gpe_gen6.h"
 #include "ilo_gpe_gen7.h"
 
-struct pipe_draw_info;
 struct intel_bo;
 struct ilo_cp;
 struct ilo_context;
@@ -74,8 +73,7 @@ struct ilo_3d_pipeline {
                         const void *arg);
 
    void (*emit_draw)(struct ilo_3d_pipeline *pipeline,
-                     const struct ilo_context *ilo,
-                     const struct pipe_draw_info *info);
+                     const struct ilo_context *ilo);
 
    void (*emit_flush)(struct ilo_3d_pipeline *pipeline);
 
@@ -257,7 +255,6 @@ ilo_3d_pipeline_estimate_size(struct ilo_3d_pipeline *pipeline,
 bool
 ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p,
                           const struct ilo_context *ilo,
-                          const struct pipe_draw_info *info,
                           int *prim_generated, int *prim_emitted);
 
 void
index 1a20599..00da47f 100644 (file)
@@ -401,7 +401,7 @@ gen6_pipeline_vf(struct ilo_3d_pipeline *p,
    /* 3DSTATE_INDEX_BUFFER */
    if (DIRTY(INDEX_BUFFER) || session->batch_bo_changed) {
       p->gen6_3DSTATE_INDEX_BUFFER(p->dev,
-            &ilo->ib.state, session->info->primitive_restart, p->cp);
+            &ilo->ib.state, ilo->draw->primitive_restart, p->cp);
    }
 
    /* 3DSTATE_VERTEX_BUFFERS */
@@ -455,7 +455,7 @@ gen6_pipeline_vf_draw(struct ilo_3d_pipeline *p,
                       struct gen6_pipeline_session *session)
 {
    /* 3DPRIMITIVE */
-   p->gen6_3DPRIMITIVE(p->dev, session->info, false, p->cp);
+   p->gen6_3DPRIMITIVE(p->dev, ilo->draw, false, p->cp);
    p->state.has_gen6_wa_pipe_control = false;
 }
 
@@ -1288,13 +1288,11 @@ gen6_pipeline_states(struct ilo_3d_pipeline *p,
 void
 gen6_pipeline_prepare(const struct ilo_3d_pipeline *p,
                       const struct ilo_context *ilo,
-                      const struct pipe_draw_info *info,
                       struct gen6_pipeline_session *session)
 {
    memset(session, 0, sizeof(*session));
-   session->info = info;
    session->pipe_dirty = ilo->dirty;
-   session->reduced_prim = u_reduced_prim(info->mode);
+   session->reduced_prim = u_reduced_prim(ilo->draw->mode);
 
    /* available space before the session */
    session->init_cp_space = ilo_cp_space(p->cp);
@@ -1369,12 +1367,11 @@ gen6_pipeline_end(struct ilo_3d_pipeline *p,
 
 static void
 ilo_3d_pipeline_emit_draw_gen6(struct ilo_3d_pipeline *p,
-                               const struct ilo_context *ilo,
-                               const struct pipe_draw_info *info)
+                               const struct ilo_context *ilo)
 {
    struct gen6_pipeline_session session;
 
-   gen6_pipeline_prepare(p, ilo, info, &session);
+   gen6_pipeline_prepare(p, ilo, &session);
 
    session.emit_draw_states = gen6_pipeline_states;
    session.emit_draw_commands = gen6_pipeline_commands;
index 6ba1f2a..11e3cb0 100644 (file)
@@ -34,8 +34,6 @@ struct ilo_3d_pipeline;
 struct ilo_context;
 
 struct gen6_pipeline_session {
-   const struct pipe_draw_info *info;
-
    uint32_t pipe_dirty;
 
    int reduced_prim;
@@ -77,7 +75,6 @@ struct gen6_pipeline_session {
 void
 gen6_pipeline_prepare(const struct ilo_3d_pipeline *p,
                       const struct ilo_context *ilo,
-                      const struct pipe_draw_info *info,
                       struct gen6_pipeline_session *session);
 
 void
index a0d321c..e8a825d 100644 (file)
@@ -605,12 +605,11 @@ gen7_pipeline_commands(struct ilo_3d_pipeline *p,
 
 static void
 ilo_3d_pipeline_emit_draw_gen7(struct ilo_3d_pipeline *p,
-                               const struct ilo_context *ilo,
-                               const struct pipe_draw_info *info)
+                               const struct ilo_context *ilo)
 {
    struct gen6_pipeline_session session;
 
-   gen6_pipeline_prepare(p, ilo, info, &session);
+   gen6_pipeline_prepare(p, ilo, &session);
 
    session.emit_draw_states = gen6_pipeline_states;
    session.emit_draw_commands = gen7_pipeline_commands;
index ed9bba3..a5c1ce0 100644 (file)
@@ -34,6 +34,7 @@
 #include "ilo_gpe.h"
 #include "ilo_common.h"
 
+struct pipe_draw_info;
 struct u_upload_mgr;
 struct intel_winsys;
 struct intel_bo;
@@ -60,6 +61,7 @@ struct ilo_context {
 
    struct u_upload_mgr *uploader;
 
+   const struct pipe_draw_info *draw;
    uint32_t dirty;
 
    struct ilo_vb_state vb;
index 71783df..0e4e937 100644 (file)
@@ -131,8 +131,11 @@ finalize_constant_buffers(struct ilo_context *ilo)
  * incomplete/invalid until finalized.
  */
 void
-ilo_finalize_states(struct ilo_context *ilo)
+ilo_finalize_3d_states(struct ilo_context *ilo,
+                       const struct pipe_draw_info *draw)
 {
+   ilo->draw = draw;
+
    finalize_shader_states(ilo);
    finalize_constant_buffers(ilo);
 
@@ -577,7 +580,7 @@ ilo_set_constant_buffer(struct pipe_context *pipe,
       cbuf->user_buffer_size = 0;
    }
 
-   /* the correct value will be set in ilo_finalize_states() */
+   /* the correct value will be set in ilo_finalize_3d_states() */
    ilo->cbuf[shader].count = 0;
 
    ilo->dirty |= ILO_DIRTY_CONSTANT_BUFFER;
index 8a0d5e7..69ef902 100644 (file)
@@ -126,7 +126,8 @@ void
 ilo_cleanup_states(struct ilo_context *ilo);
 
 void
-ilo_finalize_states(struct ilo_context *ilo);
+ilo_finalize_3d_states(struct ilo_context *ilo,
+                       const struct pipe_draw_info *draw);
 
 void
 ilo_mark_states_with_resource_dirty(struct ilo_context *ilo,