summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2013-05-29 14:25:34 +0800
committerChia-I Wu <[email protected]>2013-06-07 11:13:14 +0800
commit6b14b392d04d8f1b43d565f65cdbd738b9f950a7 (patch)
treecbb8d861f73a43f95d8fb7b9d848b9f872d4d47d /src
parentf0af29223957a94e24ae45921da080bc99037d69 (diff)
ilo: switch to ilo states for VF stage
Define and use struct ilo_vb_state; struct ilo_ve_state; struct ilo_ib_state; in ilo_context.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/ilo/ilo_3d.c16
-rw-r--r--src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c15
-rw-r--r--src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c4
-rw-r--r--src/gallium/drivers/ilo/ilo_blit.c5
-rw-r--r--src/gallium/drivers/ilo/ilo_context.h16
-rw-r--r--src/gallium/drivers/ilo/ilo_gpe.h14
-rw-r--r--src/gallium/drivers/ilo/ilo_state.c38
7 files changed, 55 insertions, 53 deletions
diff --git a/src/gallium/drivers/ilo/ilo_3d.c b/src/gallium/drivers/ilo/ilo_3d.c
index ba3fa96d513..e6ed4c9c50f 100644
--- a/src/gallium/drivers/ilo/ilo_3d.c
+++ b/src/gallium/drivers/ilo/ilo_3d.c
@@ -535,7 +535,7 @@ ilo_check_restart_index(struct ilo_context *ilo,
return true;
/* Note: indices must be unsigned byte, unsigned short or unsigned int */
- switch (ilo->index_buffer.index_size) {
+ switch (ilo->ib.state.index_size) {
case 1:
return ((info->restart_index & 0xff) == 0xff);
break;
@@ -607,15 +607,11 @@ ilo_draw_vbo_with_sw_restart(struct pipe_context *pipe,
struct pipe_transfer *transfer = NULL;
const void *map = NULL;
- map = pipe_buffer_map(pipe,
- ilo->index_buffer.buffer,
- PIPE_TRANSFER_READ,
- &transfer);
-
- sub_prim_count = ilo_find_sub_primitives(map + ilo->index_buffer.offset,
- ilo->index_buffer.index_size,
- info,
- restart_info);
+ map = pipe_buffer_map(pipe, ilo->ib.state.buffer,
+ PIPE_TRANSFER_READ, &transfer);
+
+ sub_prim_count = ilo_find_sub_primitives(map + ilo->ib.state.offset,
+ ilo->ib.state.index_size, info, restart_info);
pipe_buffer_unmap(pipe, transfer);
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
index 6eef701295f..e0aff6d221c 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
@@ -290,8 +290,8 @@ gen6_pipeline_common_urb(struct ilo_3d_pipeline *p,
* VS-generated output data, output URB availability isn't a
* factor."
*/
- if (vs_entry_size < ilo->vertex_elements->num_elements)
- vs_entry_size = ilo->vertex_elements->num_elements;
+ if (vs_entry_size < ilo->ve->count)
+ vs_entry_size = ilo->ve->count;
gs_entry_size = (gs) ? gs->out.count :
(vs && vs->stream_output) ? vs_entry_size : 0;
@@ -398,19 +398,18 @@ gen6_pipeline_vf(struct ilo_3d_pipeline *p,
/* 3DSTATE_INDEX_BUFFER */
if (DIRTY(INDEX_BUFFER)) {
p->gen6_3DSTATE_INDEX_BUFFER(p->dev,
- &ilo->index_buffer, session->info->primitive_restart, p->cp);
+ &ilo->ib.state, session->info->primitive_restart, p->cp);
}
/* 3DSTATE_VERTEX_BUFFERS */
if (DIRTY(VERTEX_BUFFERS)) {
p->gen6_3DSTATE_VERTEX_BUFFERS(p->dev,
- ilo->vertex_buffers.buffers, NULL,
- (1 << ilo->vertex_buffers.num_buffers) - 1, p->cp);
+ ilo->vb.states, NULL, ilo->vb.enabled_mask, p->cp);
}
/* 3DSTATE_VERTEX_ELEMENTS */
if (DIRTY(VERTEX_ELEMENTS) || DIRTY(VS)) {
- const struct ilo_vertex_element *ive = ilo->vertex_elements;
+ const struct ilo_ve_state *ve = ilo->ve;
bool last_velement_edgeflag = false;
bool prepend_generate_ids = false;
@@ -419,7 +418,7 @@ gen6_pipeline_vf(struct ilo_3d_pipeline *p,
if (info->edgeflag_in >= 0) {
/* we rely on the state tracker here */
- assert(info->edgeflag_in == ive->num_elements - 1);
+ assert(info->edgeflag_in == ve->count - 1);
last_velement_edgeflag = true;
}
@@ -427,7 +426,7 @@ gen6_pipeline_vf(struct ilo_3d_pipeline *p,
}
p->gen6_3DSTATE_VERTEX_ELEMENTS(p->dev,
- ive->elements, ive->num_elements,
+ ve->states, ve->count,
last_velement_edgeflag, prepend_generate_ids, p->cp);
}
}
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
index a2e7ea2304c..e53eb6432a4 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
@@ -202,8 +202,8 @@ gen7_pipeline_common_urb(struct ilo_3d_pipeline *p,
* Allocation Size must be sized to the maximum of the vertex input
* and output structures."
*/
- if (vs_entry_size < ilo->vertex_elements->num_elements)
- vs_entry_size = ilo->vertex_elements->num_elements;
+ if (vs_entry_size < ilo->ve->count)
+ vs_entry_size = ilo->ve->count;
vs_entry_size *= sizeof(float) * 4;
vs_total_size = ilo->dev->urb_size - offset;
diff --git a/src/gallium/drivers/ilo/ilo_blit.c b/src/gallium/drivers/ilo/ilo_blit.c
index 4ef9b30c73e..e38d51f2256 100644
--- a/src/gallium/drivers/ilo/ilo_blit.c
+++ b/src/gallium/drivers/ilo/ilo_blit.c
@@ -542,9 +542,8 @@ static void
ilo_blitter_begin(struct ilo_context *ilo, enum ilo_blitter_op op)
{
/* as documented in util/u_blitter.h */
- util_blitter_save_vertex_buffer_slot(ilo->blitter,
- ilo->vertex_buffers.buffers);
- util_blitter_save_vertex_elements(ilo->blitter, ilo->vertex_elements);
+ util_blitter_save_vertex_buffer_slot(ilo->blitter, ilo->vb.states);
+ util_blitter_save_vertex_elements(ilo->blitter, (void *) ilo->ve);
util_blitter_save_vertex_shader(ilo->blitter, ilo->vs);
util_blitter_save_geometry_shader(ilo->blitter, ilo->gs);
util_blitter_save_so_targets(ilo->blitter,
diff --git a/src/gallium/drivers/ilo/ilo_context.h b/src/gallium/drivers/ilo/ilo_context.h
index 7d691399b68..07905b70176 100644
--- a/src/gallium/drivers/ilo/ilo_context.h
+++ b/src/gallium/drivers/ilo/ilo_context.h
@@ -41,11 +41,6 @@ struct ilo_cp;
struct ilo_screen;
struct ilo_shader_state;
-struct ilo_vertex_element {
- struct pipe_vertex_element elements[PIPE_MAX_ATTRIBS];
- unsigned num_elements;
-};
-
struct ilo_context {
struct pipe_context base;
@@ -61,13 +56,16 @@ struct ilo_context {
uint32_t dirty;
+ struct ilo_vb_state vb;
+ const struct ilo_ve_state *ve;
+ struct ilo_ib_state ib;
+
struct pipe_blend_state *blend;
struct pipe_rasterizer_state *rasterizer;
struct pipe_depth_stencil_alpha_state *depth_stencil_alpha;
struct ilo_shader_state *fs;
struct ilo_shader_state *vs;
struct ilo_shader_state *gs;
- struct ilo_vertex_element *vertex_elements;
struct pipe_blend_color blend_color;
struct pipe_stencil_ref stencil_ref;
@@ -77,12 +75,6 @@ struct ilo_context {
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct pipe_viewport_state viewport;
- struct pipe_index_buffer index_buffer;
-
- struct {
- struct pipe_vertex_buffer buffers[PIPE_MAX_ATTRIBS];
- unsigned num_buffers;
- } vertex_buffers;
struct {
struct pipe_sampler_state *samplers[ILO_MAX_SAMPLERS];
diff --git a/src/gallium/drivers/ilo/ilo_gpe.h b/src/gallium/drivers/ilo/ilo_gpe.h
index 5fd2309237f..7c103aa3842 100644
--- a/src/gallium/drivers/ilo/ilo_gpe.h
+++ b/src/gallium/drivers/ilo/ilo_gpe.h
@@ -52,4 +52,18 @@
#define ILO_WM_CONST_SURFACE(i) (ILO_MAX_DRAW_BUFFERS + i)
#define ILO_WM_TEXTURE_SURFACE(i) (ILO_MAX_DRAW_BUFFERS + ILO_MAX_CONST_BUFFERS + i)
+struct ilo_vb_state {
+ struct pipe_vertex_buffer states[PIPE_MAX_ATTRIBS];
+ uint32_t enabled_mask;
+};
+
+struct ilo_ib_state {
+ struct pipe_index_buffer state;
+};
+
+struct ilo_ve_state {
+ struct pipe_vertex_element states[PIPE_MAX_ATTRIBS];
+ unsigned count;
+};
+
#endif /* ILO_GPE_H */
diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c
index 33da429bf37..75b87d872a5 100644
--- a/src/gallium/drivers/ilo/ilo_state.c
+++ b/src/gallium/drivers/ilo/ilo_state.c
@@ -436,15 +436,15 @@ ilo_create_vertex_elements_state(struct pipe_context *pipe,
unsigned num_elements,
const struct pipe_vertex_element *elements)
{
- struct ilo_vertex_element *velem;
+ struct ilo_ve_state *ve;
- velem = MALLOC_STRUCT(ilo_vertex_element);
- assert(velem);
+ ve = MALLOC_STRUCT(ilo_ve_state);
+ assert(ve);
- memcpy(velem->elements, elements, sizeof(*elements) * num_elements);
- velem->num_elements = num_elements;
+ memcpy(ve->states, elements, sizeof(*elements) * num_elements);
+ ve->count = num_elements;
- return velem;
+ return ve;
}
static void
@@ -452,7 +452,7 @@ ilo_bind_vertex_elements_state(struct pipe_context *pipe, void *state)
{
struct ilo_context *ilo = ilo_context(pipe);
- ilo->vertex_elements = state;
+ ilo->ve = state;
ilo->dirty |= ILO_DIRTY_VERTEX_ELEMENTS;
}
@@ -460,7 +460,9 @@ ilo_bind_vertex_elements_state(struct pipe_context *pipe, void *state)
static void
ilo_delete_vertex_elements_state(struct pipe_context *pipe, void *state)
{
- FREE(state);
+ struct ilo_ve_state *ve = state;
+
+ FREE(ve);
}
static void
@@ -722,8 +724,8 @@ ilo_set_vertex_buffers(struct pipe_context *pipe,
{
struct ilo_context *ilo = ilo_context(pipe);
- util_set_vertex_buffers_count(ilo->vertex_buffers.buffers,
- &ilo->vertex_buffers.num_buffers, buffers, start_slot, num_buffers);
+ util_set_vertex_buffers_mask(ilo->vb.states,
+ &ilo->vb.enabled_mask, buffers, start_slot, num_buffers);
ilo->dirty |= ILO_DIRTY_VERTEX_BUFFERS;
}
@@ -735,16 +737,16 @@ ilo_set_index_buffer(struct pipe_context *pipe,
struct ilo_context *ilo = ilo_context(pipe);
if (state) {
- ilo->index_buffer.index_size = state->index_size;
- ilo->index_buffer.offset = state->offset;
- pipe_resource_reference(&ilo->index_buffer.buffer, state->buffer);
- ilo->index_buffer.user_buffer = state->user_buffer;
+ ilo->ib.state.index_size = state->index_size;
+ ilo->ib.state.offset = state->offset;
+ pipe_resource_reference(&ilo->ib.state.buffer, state->buffer);
+ ilo->ib.state.user_buffer = state->user_buffer;
}
else {
- ilo->index_buffer.index_size = 0;
- ilo->index_buffer.offset = 0;
- pipe_resource_reference(&ilo->index_buffer.buffer, NULL);
- ilo->index_buffer.user_buffer = NULL;
+ ilo->ib.state.index_size = 0;
+ ilo->ib.state.offset = 0;
+ pipe_resource_reference(&ilo->ib.state.buffer, NULL);
+ ilo->ib.state.user_buffer = NULL;
}
ilo->dirty |= ILO_DIRTY_INDEX_BUFFER;