ilo: make pipe_draw_info a context state
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 9ce6b75f9782386ac2ea0821bba4f52119926b16..69808d90751741af72dec417b3275056d2c4c8ed 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 5b4dae9ae3c72af088dc91ce4e6aad5bb0a37ac6..9d146d27c2d9ebe2a42f4e24b8a9411b14fef49b 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 7aa17b8682c4aecbdf57906070ad962d87215ddc..7a867aaea2738c94f6fbc4395415cedb27be176c 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 1a20599f5a1e86636ddd5368bb2df46e515d6740..00da47f3bb2c7dcfbe333cecea392ac6c569cc2c 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 6ba1f2a87b9dd4c250ae37092e509edf7a5d3a6c..11e3cb0b55fcb3ea1695a19537a5ef9f8355f0a4 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 a0d321cafe57ac5c55ed1a608ea4ee24e53ddb96..e8a825d5271c5bfe210ed5b58e91c2df2951937f 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 ed9bba39ab5402c54c22013ee02ac663800d5461..a5c1ce0755afa70ae1d1943515da8a710a6369b5 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 71783dfaca8d7332aa275d60ce084a7d10f55cdc..0e4e937879ffd3ab67f5d479b2bb04f2f45f5133 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 8a0d5e7f14d3b4c90cc038bcf168f276eb5f31d7..69ef9025c4fdc9edd851448f9fab9013ba87a577 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,