summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2013-06-26 11:52:55 +0800
committerChia-I Wu <[email protected]>2013-06-26 16:42:46 +0800
commit5fb5d4f0a6208e720998bbdbfe83df1035957f4a (patch)
treea1017994126a86dbc119124f370cc439f3beacce
parent3eb6754e94c623c4c2393f23aeaafa933bee154e (diff)
ilo: make pipe_draw_info a context state
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.
-rw-r--r--src/gallium/drivers/ilo/ilo_3d.c25
-rw-r--r--src/gallium/drivers/ilo/ilo_3d_pipeline.c9
-rw-r--r--src/gallium/drivers/ilo/ilo_3d_pipeline.h5
-rw-r--r--src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c13
-rw-r--r--src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.h3
-rw-r--r--src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c5
-rw-r--r--src/gallium/drivers/ilo/ilo_context.h2
-rw-r--r--src/gallium/drivers/ilo/ilo_state.c7
-rw-r--r--src/gallium/drivers/ilo/ilo_state.h3
9 files changed, 33 insertions, 39 deletions
diff --git a/src/gallium/drivers/ilo/ilo_3d.c b/src/gallium/drivers/ilo/ilo_3d.c
index 9ce6b75f978..69808d90751 100644
--- a/src/gallium/drivers/ilo/ilo_3d.c
+++ b/src/gallium/drivers/ilo/ilo_3d.c
@@ -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 */
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline.c b/src/gallium/drivers/ilo/ilo_3d_pipeline.c
index 5b4dae9ae3c..9d146d27c2d 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline.c
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline.c
@@ -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;
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline.h b/src/gallium/drivers/ilo/ilo_3d_pipeline.h
index 7aa17b8682c..7a867aaea27 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline.h
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline.h
@@ -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
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
index 1a20599f5a1..00da47f3bb2 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
@@ -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;
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.h b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.h
index 6ba1f2a87b9..11e3cb0b55f 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.h
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.h
@@ -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
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
index a0d321cafe5..e8a825d5271 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
@@ -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;
diff --git a/src/gallium/drivers/ilo/ilo_context.h b/src/gallium/drivers/ilo/ilo_context.h
index ed9bba39ab5..a5c1ce0755a 100644
--- a/src/gallium/drivers/ilo/ilo_context.h
+++ b/src/gallium/drivers/ilo/ilo_context.h
@@ -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;
diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c
index 71783dfaca8..0e4e937879f 100644
--- a/src/gallium/drivers/ilo/ilo_state.c
+++ b/src/gallium/drivers/ilo/ilo_state.c
@@ -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;
diff --git a/src/gallium/drivers/ilo/ilo_state.h b/src/gallium/drivers/ilo/ilo_state.h
index 8a0d5e7f14d..69ef9025c4f 100644
--- a/src/gallium/drivers/ilo/ilo_state.h
+++ b/src/gallium/drivers/ilo/ilo_state.h
@@ -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,