diff options
author | Chia-I Wu <[email protected]> | 2015-06-22 14:27:19 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2015-06-22 15:18:57 +0800 |
commit | 878714142999ca6a6aa03d962e01da94d44c8574 (patch) | |
tree | 61ecabebd98bb6805ffa9b1cf64aad70c30faef3 /src | |
parent | 58f95b332d0cbad226f5bb2e96cd0cad8864fe79 (diff) |
ilo: emit 3DPRIMITIVE from gen6_3dprimitive_info
It allows us to remove ilo_ib_state::draw_start_offset and
ILO_PRIM_RECTANGLES. gen6_3d_translate_pipe_prim() is also replaced by
ilo_translate_draw_mode().
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_builder_3d.h | 54 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_builder_3d_top.h | 29 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_core.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_blitter.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_blitter_rectlist.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render_gen.h | 9 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render_gen6.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render_gen7.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render_gen8.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state.c | 58 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state.h | 4 |
11 files changed, 91 insertions, 87 deletions
diff --git a/src/gallium/drivers/ilo/core/ilo_builder_3d.h b/src/gallium/drivers/ilo/core/ilo_builder_3d.h index 8d8a79599bd..fb8b53cbe23 100644 --- a/src/gallium/drivers/ilo/core/ilo_builder_3d.h +++ b/src/gallium/drivers/ilo/core/ilo_builder_3d.h @@ -35,41 +35,45 @@ #include "ilo_builder_3d_top.h" #include "ilo_builder_3d_bottom.h" +struct gen6_3dprimitive_info { + enum gen_3dprim_type topology; + bool indexed; + + uint32_t vertex_count; + uint32_t vertex_start; + uint32_t instance_count; + uint32_t instance_start; + int32_t vertex_base; +}; + static inline void gen6_3DPRIMITIVE(struct ilo_builder *builder, - const struct pipe_draw_info *info, - int64_t start_offset) + const struct gen6_3dprimitive_info *info) { const uint8_t cmd_len = 6; - const int prim = gen6_3d_translate_pipe_prim(info->mode); - const int vb_access = (info->indexed) ? - GEN6_3DPRIM_DW0_ACCESS_RANDOM : GEN6_3DPRIM_DW0_ACCESS_SEQUENTIAL; uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | - vb_access | - prim << GEN6_3DPRIM_DW0_TYPE__SHIFT | - (cmd_len - 2); - dw[1] = info->count; - dw[2] = info->start + start_offset; + dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2) | + info->topology << GEN6_3DPRIM_DW0_TYPE__SHIFT; + if (info->indexed) + dw[0] |= GEN6_3DPRIM_DW0_ACCESS_RANDOM; + + dw[1] = info->vertex_count; + dw[2] = info->vertex_start; dw[3] = info->instance_count; - dw[4] = info->start_instance; - dw[5] = info->index_bias; + dw[4] = info->instance_start; + dw[5] = info->vertex_base; } static inline void gen7_3DPRIMITIVE(struct ilo_builder *builder, - const struct pipe_draw_info *info, - int64_t start_offset) + const struct gen6_3dprimitive_info *info) { const uint8_t cmd_len = 7; - const int prim = gen6_3d_translate_pipe_prim(info->mode); - const int vb_access = (info->indexed) ? - GEN7_3DPRIM_DW1_ACCESS_RANDOM : GEN7_3DPRIM_DW1_ACCESS_SEQUENTIAL; uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 7, 8); @@ -77,12 +81,16 @@ gen7_3DPRIMITIVE(struct ilo_builder *builder, ilo_builder_batch_pointer(builder, cmd_len, &dw); dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2); - dw[1] = vb_access | prim; - dw[2] = info->count; - dw[3] = info->start + start_offset; + + dw[1] = info->topology << GEN7_3DPRIM_DW1_TYPE__SHIFT; + if (info->indexed) + dw[1] |= GEN7_3DPRIM_DW1_ACCESS_RANDOM; + + dw[2] = info->vertex_count; + dw[3] = info->vertex_start; dw[4] = info->instance_count; - dw[5] = info->start_instance; - dw[6] = info->index_bias; + dw[5] = info->instance_start; + dw[6] = info->vertex_base; } #endif /* ILO_BUILDER_3D_H */ diff --git a/src/gallium/drivers/ilo/core/ilo_builder_3d_top.h b/src/gallium/drivers/ilo/core/ilo_builder_3d_top.h index 42d171fc0d2..8d30095e6f6 100644 --- a/src/gallium/drivers/ilo/core/ilo_builder_3d_top.h +++ b/src/gallium/drivers/ilo/core/ilo_builder_3d_top.h @@ -217,35 +217,6 @@ gen6_3DSTATE_VF_STATISTICS(struct ilo_builder *builder, ilo_builder_batch_write(builder, cmd_len, &dw0); } -/** - * Translate a pipe primitive type to the matching hardware primitive type. - */ -static inline int -gen6_3d_translate_pipe_prim(unsigned prim) -{ - static const int prim_mapping[ILO_PRIM_MAX] = { - [PIPE_PRIM_POINTS] = GEN6_3DPRIM_POINTLIST, - [PIPE_PRIM_LINES] = GEN6_3DPRIM_LINELIST, - [PIPE_PRIM_LINE_LOOP] = GEN6_3DPRIM_LINELOOP, - [PIPE_PRIM_LINE_STRIP] = GEN6_3DPRIM_LINESTRIP, - [PIPE_PRIM_TRIANGLES] = GEN6_3DPRIM_TRILIST, - [PIPE_PRIM_TRIANGLE_STRIP] = GEN6_3DPRIM_TRISTRIP, - [PIPE_PRIM_TRIANGLE_FAN] = GEN6_3DPRIM_TRIFAN, - [PIPE_PRIM_QUADS] = GEN6_3DPRIM_QUADLIST, - [PIPE_PRIM_QUAD_STRIP] = GEN6_3DPRIM_QUADSTRIP, - [PIPE_PRIM_POLYGON] = GEN6_3DPRIM_POLYGON, - [PIPE_PRIM_LINES_ADJACENCY] = GEN6_3DPRIM_LINELIST_ADJ, - [PIPE_PRIM_LINE_STRIP_ADJACENCY] = GEN6_3DPRIM_LINESTRIP_ADJ, - [PIPE_PRIM_TRIANGLES_ADJACENCY] = GEN6_3DPRIM_TRILIST_ADJ, - [PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = GEN6_3DPRIM_TRISTRIP_ADJ, - [ILO_PRIM_RECTANGLES] = GEN6_3DPRIM_RECTLIST, - }; - - assert(prim_mapping[prim]); - - return prim_mapping[prim]; -} - static inline void gen8_3DSTATE_VF_TOPOLOGY(struct ilo_builder *builder, enum gen_3dprim_type topology) diff --git a/src/gallium/drivers/ilo/core/ilo_core.h b/src/gallium/drivers/ilo/core/ilo_core.h index 3587d3930f3..0a7f7d9d3fe 100644 --- a/src/gallium/drivers/ilo/core/ilo_core.h +++ b/src/gallium/drivers/ilo/core/ilo_core.h @@ -40,7 +40,4 @@ #include "util/u_memory.h" #include "util/u_pointer.h" -#define ILO_PRIM_RECTANGLES PIPE_PRIM_MAX -#define ILO_PRIM_MAX (PIPE_PRIM_MAX + 1) - #endif /* ILO_CORE_H */ diff --git a/src/gallium/drivers/ilo/ilo_blitter.h b/src/gallium/drivers/ilo/ilo_blitter.h index 6af6046e1a9..4eba8481c28 100644 --- a/src/gallium/drivers/ilo/ilo_blitter.h +++ b/src/gallium/drivers/ilo/ilo_blitter.h @@ -58,7 +58,7 @@ struct ilo_blitter { bool initialized; float vertices[3][2]; - struct pipe_draw_info draw; + struct gen6_3dprimitive_info draw_info; uint32_t vf_data[4]; struct ilo_state_vf vf; diff --git a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c index afdb0377824..13c8f500680 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c +++ b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c @@ -45,9 +45,9 @@ ilo_blitter_set_invariants(struct ilo_blitter *blitter) return true; /* a rectangle has 3 vertices in a RECTLIST */ - util_draw_init_info(&blitter->draw); - blitter->draw.mode = ILO_PRIM_RECTANGLES; - blitter->draw.count = 3; + blitter->draw_info.topology = GEN6_3DPRIM_RECTLIST; + blitter->draw_info.vertex_count = 3; + blitter->draw_info.instance_count = 1; memset(&elem, 0, sizeof(elem)); /* only vertex X and Y */ diff --git a/src/gallium/drivers/ilo/ilo_render_gen.h b/src/gallium/drivers/ilo/ilo_render_gen.h index aae4ef2f373..6b133750043 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen.h +++ b/src/gallium/drivers/ilo/ilo_render_gen.h @@ -389,11 +389,8 @@ ilo_render_pipe_control(struct ilo_render *r, uint32_t dw1) */ static inline void ilo_render_3dprimitive(struct ilo_render *r, - const struct pipe_draw_info *info, - const struct ilo_ib_state *ib) + const struct gen6_3dprimitive_info *info) { - const int64_t start_offset = (info->indexed) ? ib->draw_start_offset : 0; - ILO_DEV_ASSERT(r->dev, 6, 8); if (r->state.deferred_pipe_control_dw1) @@ -401,9 +398,9 @@ ilo_render_3dprimitive(struct ilo_render *r, /* 3DPRIMITIVE */ if (ilo_dev_gen(r->dev) >= ILO_GEN(7)) - gen7_3DPRIMITIVE(r->builder, info, start_offset); + gen7_3DPRIMITIVE(r->builder, info); else - gen6_3DPRIMITIVE(r->builder, info, start_offset); + gen6_3DPRIMITIVE(r->builder, info); r->state.current_pipe_control_dw1 = 0; assert(!r->state.deferred_pipe_control_dw1); diff --git a/src/gallium/drivers/ilo/ilo_render_gen6.c b/src/gallium/drivers/ilo/ilo_render_gen6.c index b2bc2dcface..c1f759f3043 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen6.c +++ b/src/gallium/drivers/ilo/ilo_render_gen6.c @@ -806,7 +806,7 @@ ilo_render_emit_draw_commands_gen6(struct ilo_render *render, gen6_draw_sf_rect(render, vec, session); gen6_draw_vf(render, vec, session); - ilo_render_3dprimitive(render, vec->draw, &vec->ib); + ilo_render_3dprimitive(render, &vec->draw_info); } static void @@ -926,7 +926,7 @@ ilo_render_emit_rectlist_commands_gen6(struct ilo_render *r, gen6_3DSTATE_DRAWING_RECTANGLE(r->builder, 0, 0, blitter->fb.width, blitter->fb.height); - ilo_render_3dprimitive(r, &blitter->draw, NULL); + ilo_render_3dprimitive(r, &blitter->draw_info); } int diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.c b/src/gallium/drivers/ilo/ilo_render_gen7.c index 4c54edeeb96..6623a8bcb43 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen7.c +++ b/src/gallium/drivers/ilo/ilo_render_gen7.c @@ -649,7 +649,7 @@ ilo_render_emit_draw_commands_gen7(struct ilo_render *render, gen6_draw_sf_rect(render, vec, session); gen6_draw_vf(render, vec, session); - ilo_render_3dprimitive(render, vec->draw, &vec->ib); + ilo_render_3dprimitive(render, &vec->draw_info); } static void @@ -804,7 +804,7 @@ ilo_render_emit_rectlist_commands_gen7(struct ilo_render *r, if (ilo_dev_gen(r->dev) == ILO_GEN(7)) gen7_wa_post_ps_and_later(r); - ilo_render_3dprimitive(r, &blitter->draw, NULL); + ilo_render_3dprimitive(r, &blitter->draw_info); } int diff --git a/src/gallium/drivers/ilo/ilo_render_gen8.c b/src/gallium/drivers/ilo/ilo_render_gen8.c index f86871f852f..65494b4058a 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen8.c +++ b/src/gallium/drivers/ilo/ilo_render_gen8.c @@ -220,8 +220,7 @@ gen8_draw_vf(struct ilo_render *r, if (session->vf_delta.dirty & ILO_STATE_VF_3DSTATE_VERTEX_ELEMENTS) gen6_3DSTATE_VERTEX_ELEMENTS(r->builder, &vec->ve->vf); - gen8_3DSTATE_VF_TOPOLOGY(r->builder, - gen6_3d_translate_pipe_prim(vec->draw->mode)); + gen8_3DSTATE_VF_TOPOLOGY(r->builder, vec->draw_info.topology); if (session->vf_delta.dirty & ILO_STATE_VF_3DSTATE_VF_INSTANCING) { const uint8_t attr_count = ilo_state_vf_get_attr_count(&vec->ve->vf); @@ -270,7 +269,7 @@ ilo_render_emit_draw_commands_gen8(struct ilo_render *render, gen6_draw_sf_rect(render, vec, session); gen8_draw_vf(render, vec, session); - ilo_render_3dprimitive(render, vec->draw, &vec->ib); + ilo_render_3dprimitive(render, &vec->draw_info); } int diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c index 4252dbe5613..63534f33fa7 100644 --- a/src/gallium/drivers/ilo/ilo_state.c +++ b/src/gallium/drivers/ilo/ilo_state.c @@ -25,7 +25,6 @@ * Chia-I Wu <[email protected]> */ -#include "core/ilo_builder_3d.h" /* for gen6_3d_translate_pipe_prim() */ #include "util/u_dual_blend.h" #include "util/u_dynarray.h" #include "util/u_framebuffer.h" @@ -39,6 +38,34 @@ #include "ilo_shader.h" #include "ilo_state.h" +/** + * Translate a pipe primitive type to the matching hardware primitive type. + */ +static enum gen_3dprim_type +ilo_translate_draw_mode(unsigned mode) +{ + static const enum gen_3dprim_type prim_mapping[PIPE_PRIM_MAX] = { + [PIPE_PRIM_POINTS] = GEN6_3DPRIM_POINTLIST, + [PIPE_PRIM_LINES] = GEN6_3DPRIM_LINELIST, + [PIPE_PRIM_LINE_LOOP] = GEN6_3DPRIM_LINELOOP, + [PIPE_PRIM_LINE_STRIP] = GEN6_3DPRIM_LINESTRIP, + [PIPE_PRIM_TRIANGLES] = GEN6_3DPRIM_TRILIST, + [PIPE_PRIM_TRIANGLE_STRIP] = GEN6_3DPRIM_TRISTRIP, + [PIPE_PRIM_TRIANGLE_FAN] = GEN6_3DPRIM_TRIFAN, + [PIPE_PRIM_QUADS] = GEN6_3DPRIM_QUADLIST, + [PIPE_PRIM_QUAD_STRIP] = GEN6_3DPRIM_QUADSTRIP, + [PIPE_PRIM_POLYGON] = GEN6_3DPRIM_POLYGON, + [PIPE_PRIM_LINES_ADJACENCY] = GEN6_3DPRIM_LINELIST_ADJ, + [PIPE_PRIM_LINE_STRIP_ADJACENCY] = GEN6_3DPRIM_LINESTRIP_ADJ, + [PIPE_PRIM_TRIANGLES_ADJACENCY] = GEN6_3DPRIM_TRILIST_ADJ, + [PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = GEN6_3DPRIM_TRISTRIP_ADJ, + }; + + assert(prim_mapping[mode]); + + return prim_mapping[mode]; +} + static enum gen_index_format ilo_translate_index_size(unsigned index_size) { @@ -386,6 +413,7 @@ finalize_index_buffer(struct ilo_context *ilo) vec->ib.state.offset % vec->ib.state.index_size)); struct pipe_resource *current_hw_res = NULL; struct ilo_state_index_buffer_info info; + int64_t vertex_start_bias = 0; if (!(vec->dirty & ILO_DIRTY_IB) && !need_upload) return; @@ -410,25 +438,23 @@ finalize_index_buffer(struct ilo_context *ilo) /* the HW offset should be aligned */ assert(hw_offset % vec->ib.state.index_size == 0); - vec->ib.draw_start_offset = hw_offset / vec->ib.state.index_size; + vertex_start_bias = hw_offset / vec->ib.state.index_size; /* * INDEX[vec->draw->start] in the original buffer is INDEX[0] in the HW * resource */ - vec->ib.draw_start_offset -= vec->draw->start; + vertex_start_bias -= vec->draw->start; } else { pipe_resource_reference(&vec->ib.hw_resource, vec->ib.state.buffer); /* note that index size may be zero when the draw is not indexed */ - if (vec->draw->indexed) { - vec->ib.draw_start_offset = - vec->ib.state.offset / vec->ib.state.index_size; - } else { - vec->ib.draw_start_offset = 0; - } + if (vec->draw->indexed) + vertex_start_bias = vec->ib.state.offset / vec->ib.state.index_size; } + vec->draw_info.vertex_start += vertex_start_bias; + /* treat the IB as clean if the HW states do not change */ if (vec->ib.hw_resource == current_hw_res && vec->ib.hw_index_size == vec->ib.state.index_size) @@ -456,8 +482,6 @@ finalize_vertex_elements(struct ilo_context *ilo) const struct ilo_dev *dev = ilo->dev; struct ilo_state_vector *vec = &ilo->state_vector; struct ilo_ve_state *ve = vec->ve; - const enum gen_3dprim_type topology = - gen6_3d_translate_pipe_prim(vec->draw->mode); const bool last_element_edge_flag = (vec->vs && ilo_shader_get_kernel_param(vec->vs, ILO_KERNEL_VS_INPUT_EDGEFLAG)); const bool prepend_vertexid = (vec->vs && @@ -469,14 +493,14 @@ finalize_vertex_elements(struct ilo_context *ilo) ilo_translate_index_size(vec->ib.state.index_size) : GEN6_INDEX_DWORD; /* check for non-orthogonal states */ - if (ve->vf_params.cv_topology != topology || + if (ve->vf_params.cv_topology != vec->draw_info.topology || ve->vf_params.prepend_vertexid != prepend_vertexid || ve->vf_params.prepend_instanceid != prepend_instanceid || ve->vf_params.last_element_edge_flag != last_element_edge_flag || ve->vf_params.cv_index_format != index_format || ve->vf_params.cut_index_enable != vec->draw->primitive_restart || ve->vf_params.cut_index != vec->draw->restart_index) { - ve->vf_params.cv_topology = topology; + ve->vf_params.cv_topology = vec->draw_info.topology; ve->vf_params.prepend_vertexid = prepend_vertexid; ve->vf_params.prepend_instanceid = prepend_instanceid; ve->vf_params.last_element_edge_flag = last_element_edge_flag; @@ -769,6 +793,14 @@ ilo_finalize_3d_states(struct ilo_context *ilo, { ilo->state_vector.draw = draw; + ilo->state_vector.draw_info.topology = ilo_translate_draw_mode(draw->mode); + ilo->state_vector.draw_info.indexed = draw->indexed; + ilo->state_vector.draw_info.vertex_count = draw->count; + ilo->state_vector.draw_info.vertex_start = draw->start; + ilo->state_vector.draw_info.instance_count = draw->instance_count; + ilo->state_vector.draw_info.instance_start = draw->start_instance; + ilo->state_vector.draw_info.vertex_base = draw->index_bias; + finalize_blend(ilo); finalize_shader_states(&ilo->state_vector); finalize_constant_buffers(ilo); diff --git a/src/gallium/drivers/ilo/ilo_state.h b/src/gallium/drivers/ilo/ilo_state.h index 537e5db120b..3e6fd8a2554 100644 --- a/src/gallium/drivers/ilo/ilo_state.h +++ b/src/gallium/drivers/ilo/ilo_state.h @@ -28,6 +28,7 @@ #ifndef ILO_STATE_H #define ILO_STATE_H +#include "core/ilo_builder_3d.h" /* for gen6_3dprimitive_info */ #include "core/ilo_state_cc.h" #include "core/ilo_state_compute.h" #include "core/ilo_state_raster.h" @@ -169,8 +170,6 @@ struct ilo_ib_state { struct pipe_resource *hw_resource; unsigned hw_index_size; struct ilo_state_index_buffer ib; - /* an offset to be added to pipe_draw_info::start */ - int64_t draw_start_offset; }; struct ilo_cbuf_cso { @@ -339,6 +338,7 @@ struct ilo_global_binding { struct ilo_state_vector { const struct pipe_draw_info *draw; + struct gen6_3dprimitive_info draw_info; uint32_t dirty; |