diff options
author | Chia-I Wu <[email protected]> | 2014-09-25 12:02:33 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2014-09-26 21:15:55 +0800 |
commit | 8f284343e08bffa798c99763e4a3c234da6ab4d3 (patch) | |
tree | 05a0a5ad428dbb77008981bb910567a29737f0fa /src/gallium | |
parent | a05ce904aabcc3733df1338472348c636fce2341 (diff) |
ilo: make ilo_render_emit_draw() direct
Remove emit_draw() and ILO_RENDER_DRAW indirections. With all emit functions
being direct now, ilo_render_estimate_size() and more can also be removed.
Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/ilo/Makefile.sources | 1 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_draw.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render.c | 98 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render.h | 37 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render_gen.h | 66 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render_gen6.c | 141 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render_gen7.c | 85 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render_gen7.h | 38 |
8 files changed, 174 insertions, 295 deletions
diff --git a/src/gallium/drivers/ilo/Makefile.sources b/src/gallium/drivers/ilo/Makefile.sources index 2bb81baf90d..52f4ff25987 100644 --- a/src/gallium/drivers/ilo/Makefile.sources +++ b/src/gallium/drivers/ilo/Makefile.sources @@ -40,7 +40,6 @@ C_SOURCES := \ ilo_render_dynamic.c \ ilo_render_gen6.c \ ilo_render_gen7.c \ - ilo_render_gen7.h \ ilo_render_surface.c \ ilo_screen.c \ ilo_screen.h \ diff --git a/src/gallium/drivers/ilo/ilo_draw.c b/src/gallium/drivers/ilo/ilo_draw.c index 8e01f6d3d6f..1c9c4226650 100644 --- a/src/gallium/drivers/ilo/ilo_draw.c +++ b/src/gallium/drivers/ilo/ilo_draw.c @@ -320,8 +320,7 @@ draw_vbo(struct ilo_context *ilo, const struct ilo_state_vector *vec) ilo_draw_set_owner(ilo); /* make sure there is enough room first */ - max_len = ilo_render_estimate_size(ilo->render, - ILO_RENDER_DRAW, vec); + max_len = ilo_render_get_draw_len(ilo->render, vec); if (need_flush) max_len += ilo_render_get_flush_len(ilo->render); diff --git a/src/gallium/drivers/ilo/ilo_render.c b/src/gallium/drivers/ilo/ilo_render.c index 4f78cf59ead..2b8412a348f 100644 --- a/src/gallium/drivers/ilo/ilo_render.c +++ b/src/gallium/drivers/ilo/ilo_render.c @@ -26,6 +26,7 @@ */ #include "genhw/genhw.h" +#include "util/u_prim.h" #include "intel_winsys.h" #include "ilo_builder.h" @@ -33,7 +34,6 @@ #include "ilo_builder_render.h" #include "ilo_query.h" #include "ilo_render_gen.h" -#include "ilo_render_gen7.h" #include "ilo_render.h" /* in U0.4 */ @@ -77,21 +77,6 @@ ilo_render_create(struct ilo_builder *builder) render->dev = builder->dev; render->builder = builder; - switch (ilo_dev_gen(render->dev)) { - case ILO_GEN(6): - ilo_render_init_gen6(render); - break; - case ILO_GEN(7): - case ILO_GEN(7.5): - ilo_render_init_gen7(render); - break; - default: - assert(!"unsupported GEN"); - FREE(render); - return NULL; - break; - } - render->workaround_bo = intel_winsys_alloc_buffer(builder->winsys, "PIPE_CONTROL workaround", 4096, false); if (!render->workaround_bo) { @@ -388,3 +373,84 @@ ilo_render_emit_rectlist(struct ilo_render *render, ilo_render_emit_rectlist_dynamic_states(render, blitter); ilo_render_emit_rectlist_commands(render, blitter); } + +int +ilo_render_get_draw_len(const struct ilo_render *render, + const struct ilo_state_vector *vec) +{ + ILO_DEV_ASSERT(render->dev, 6, 7.5); + + return ilo_render_get_draw_dynamic_states_len(render, vec) + + ilo_render_get_draw_surface_states_len(render, vec) + + ilo_render_get_draw_commands_len(render, vec); +} + +static void +gen6_draw_prepare(struct ilo_render *render, + const struct ilo_state_vector *vec, + struct gen6_draw_session *session) +{ + memset(session, 0, sizeof(*session)); + session->pipe_dirty = vec->dirty; + session->reduced_prim = u_reduced_prim(vec->draw->mode); + + if (render->hw_ctx_changed) { + /* these should be enough to make everything uploaded */ + render->batch_bo_changed = true; + render->state_bo_changed = true; + render->instruction_bo_changed = true; + + session->prim_changed = true; + session->primitive_restart_changed = true; + } else { + session->prim_changed = + (render->state.reduced_prim != session->reduced_prim); + session->primitive_restart_changed = + (render->state.primitive_restart != vec->draw->primitive_restart); + } +} + +static void +gen6_draw_end(struct ilo_render *render, + const struct ilo_state_vector *vec, + struct gen6_draw_session *session) +{ + render->hw_ctx_changed = false; + + render->batch_bo_changed = false; + render->state_bo_changed = false; + render->instruction_bo_changed = false; + + render->state.reduced_prim = session->reduced_prim; + render->state.primitive_restart = vec->draw->primitive_restart; +} + +void +ilo_render_emit_draw(struct ilo_render *render, + const struct ilo_state_vector *vec) +{ + struct gen6_draw_session session; + + ILO_DEV_ASSERT(render->dev, 6, 7.5); + + gen6_draw_prepare(render, vec, &session); + + /* force all states to be uploaded if the state bo changed */ + if (render->state_bo_changed) + session.pipe_dirty = ILO_DIRTY_ALL; + else + session.pipe_dirty = vec->dirty; + + ilo_render_emit_draw_dynamic_states(render, vec, &session); + ilo_render_emit_draw_surface_states(render, vec, &session); + + /* force all commands to be uploaded if the HW context changed */ + if (render->hw_ctx_changed) + session.pipe_dirty = ILO_DIRTY_ALL; + else + session.pipe_dirty = vec->dirty; + + ilo_render_emit_draw_commands(render, vec, &session); + + gen6_draw_end(render, vec, &session); +} diff --git a/src/gallium/drivers/ilo/ilo_render.h b/src/gallium/drivers/ilo/ilo_render.h index dd4c3c0f95a..60e3769e0dc 100644 --- a/src/gallium/drivers/ilo/ilo_render.h +++ b/src/gallium/drivers/ilo/ilo_render.h @@ -37,10 +37,6 @@ struct ilo_cp; struct ilo_query; struct ilo_state_vector; -enum ilo_render_action { - ILO_RENDER_DRAW, -}; - /** * Render Engine. */ @@ -54,13 +50,6 @@ struct ilo_render { uint32_t packed_sample_position_4x; uint32_t packed_sample_position_8x[2]; - int (*estimate_size)(struct ilo_render *render, - enum ilo_render_action action, - const void *arg); - - void (*emit_draw)(struct ilo_render *render, - const struct ilo_state_vector *vec); - bool hw_ctx_changed; /* @@ -143,24 +132,6 @@ ilo_render_destroy(struct ilo_render *render); /** * Estimate the size of an action. */ -static inline int -ilo_render_estimate_size(struct ilo_render *render, - enum ilo_render_action action, - const void *arg) -{ - return render->estimate_size(render, action, arg); -} - -/** - * Emit context states and 3DPRIMITIVE. - */ -static inline void -ilo_render_emit_draw(struct ilo_render *render, - const struct ilo_state_vector *vec) -{ - render->emit_draw(render, vec); -} - void ilo_render_get_sample_position(const struct ilo_render *render, unsigned sample_count, @@ -195,4 +166,12 @@ void ilo_render_emit_rectlist(struct ilo_render *render, const struct ilo_blitter *blitter); +int +ilo_render_get_draw_len(const struct ilo_render *render, + const struct ilo_state_vector *vec); + +void +ilo_render_emit_draw(struct ilo_render *render, + const struct ilo_state_vector *vec); + #endif /* ILO_RENDER_H */ diff --git a/src/gallium/drivers/ilo/ilo_render_gen.h b/src/gallium/drivers/ilo/ilo_render_gen.h index 80e51cab31d..ffddaa87f67 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen.h +++ b/src/gallium/drivers/ilo/ilo_render_gen.h @@ -45,10 +45,6 @@ struct gen6_draw_session { bool prim_changed; bool primitive_restart_changed; - void (*emit_draw_commands)(struct ilo_render *render, - const struct ilo_state_vector *ilo, - struct gen6_draw_session *session); - /* dynamic states */ bool viewport_changed; bool scissor_changed; @@ -74,6 +70,50 @@ struct gen6_draw_session { }; int +ilo_render_get_draw_commands_len_gen6(const struct ilo_render *render, + const struct ilo_state_vector *vec); + +int +ilo_render_get_draw_commands_len_gen7(const struct ilo_render *render, + const struct ilo_state_vector *vec); + +static inline int +ilo_render_get_draw_commands_len(const struct ilo_render *render, + const struct ilo_state_vector *vec) +{ + if (ilo_dev_gen(render->dev) >= ILO_GEN(7)) + return ilo_render_get_draw_commands_len_gen7(render, vec); + else + return ilo_render_get_draw_commands_len_gen6(render, vec); +} + +void +ilo_render_emit_draw_commands_gen6(struct ilo_render *render, + const struct ilo_state_vector *vec, + struct gen6_draw_session *session); + +void +ilo_render_emit_draw_commands_gen7(struct ilo_render *render, + const struct ilo_state_vector *vec, + struct gen6_draw_session *session); + +static inline void +ilo_render_emit_draw_commands(struct ilo_render *render, + const struct ilo_state_vector *vec, + struct gen6_draw_session *session) +{ + const unsigned batch_used = ilo_builder_batch_used(render->builder); + + if (ilo_dev_gen(render->dev) >= ILO_GEN(7)) + ilo_render_emit_draw_commands_gen7(render, vec, session); + else + ilo_render_emit_draw_commands_gen6(render, vec, session); + + assert(ilo_builder_batch_used(render->builder) <= batch_used + + ilo_render_get_draw_commands_len(render, vec)); +} + +int ilo_render_get_rectlist_commands_len_gen6(const struct ilo_render *render, const struct ilo_blitter *blitter); @@ -137,21 +177,6 @@ void gen6_wa_pre_pipe_control(struct ilo_render *r, uint32_t dw1); void -gen6_draw_prepare(struct ilo_render *r, - const struct ilo_state_vector *ilo, - struct gen6_draw_session *session); - -void -gen6_draw_emit(struct ilo_render *r, - const struct ilo_state_vector *ilo, - struct gen6_draw_session *session); - -void -gen6_draw_end(struct ilo_render *r, - const struct ilo_state_vector *ilo, - struct gen6_draw_session *session); - -void gen6_draw_common_select(struct ilo_render *r, const struct ilo_state_vector *ilo, struct gen6_draw_session *session); @@ -196,7 +221,4 @@ gen6_draw_wm_raster(struct ilo_render *r, const struct ilo_state_vector *ilo, struct gen6_draw_session *session); -void -ilo_render_init_gen6(struct ilo_render *render); - #endif /* ILO_RENDER_GEN_H */ diff --git a/src/gallium/drivers/ilo/ilo_render_gen6.c b/src/gallium/drivers/ilo/ilo_render_gen6.c index 2173746c83b..f2b876cf046 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen6.c +++ b/src/gallium/drivers/ilo/ilo_render_gen6.c @@ -834,11 +834,13 @@ gen6_draw_wm_raster(struct ilo_render *r, #undef DIRTY -static void -gen6_draw_commands(struct ilo_render *render, - const struct ilo_state_vector *vec, - struct gen6_draw_session *session) +void +ilo_render_emit_draw_commands_gen6(struct ilo_render *render, + const struct ilo_state_vector *vec, + struct gen6_draw_session *session) { + ILO_DEV_ASSERT(render->dev, 6, 6); + /* * We try to keep the order of the commands match, as closely as possible, * that of the classic i965 driver. It allows us to compare the command @@ -866,83 +868,6 @@ gen6_draw_commands(struct ilo_render *render, gen6_draw_vf_draw(render, vec, session); } -void -gen6_draw_prepare(struct ilo_render *render, - const struct ilo_state_vector *vec, - struct gen6_draw_session *session) -{ - memset(session, 0, sizeof(*session)); - session->pipe_dirty = vec->dirty; - session->reduced_prim = u_reduced_prim(vec->draw->mode); - - if (render->hw_ctx_changed) { - /* these should be enough to make everything uploaded */ - render->batch_bo_changed = true; - render->state_bo_changed = true; - render->instruction_bo_changed = true; - - session->prim_changed = true; - session->primitive_restart_changed = true; - } else { - session->prim_changed = - (render->state.reduced_prim != session->reduced_prim); - session->primitive_restart_changed = - (render->state.primitive_restart != vec->draw->primitive_restart); - } -} - -void -gen6_draw_emit(struct ilo_render *render, - const struct ilo_state_vector *vec, - struct gen6_draw_session *session) -{ - /* force all states to be uploaded if the state bo changed */ - if (render->state_bo_changed) - session->pipe_dirty = ILO_DIRTY_ALL; - else - session->pipe_dirty = vec->dirty; - - ilo_render_emit_draw_dynamic_states(render, vec, session); - ilo_render_emit_draw_surface_states(render, vec, session); - - /* force all commands to be uploaded if the HW context changed */ - if (render->hw_ctx_changed) - session->pipe_dirty = ILO_DIRTY_ALL; - else - session->pipe_dirty = vec->dirty; - - session->emit_draw_commands(render, vec, session); -} - -void -gen6_draw_end(struct ilo_render *render, - const struct ilo_state_vector *vec, - struct gen6_draw_session *session) -{ - render->hw_ctx_changed = false; - - render->batch_bo_changed = false; - render->state_bo_changed = false; - render->instruction_bo_changed = false; - - render->state.reduced_prim = session->reduced_prim; - render->state.primitive_restart = vec->draw->primitive_restart; -} - -static void -ilo_render_emit_draw_gen6(struct ilo_render *render, - const struct ilo_state_vector *vec) -{ - struct gen6_draw_session session; - - gen6_draw_prepare(render, vec, &session); - - session.emit_draw_commands = gen6_draw_commands; - - gen6_draw_emit(render, vec, &session); - gen6_draw_end(render, vec, &session); -} - static void gen6_rectlist_vs_to_sf(struct ilo_render *r, const struct ilo_blitter *blitter) @@ -1085,17 +1010,20 @@ ilo_render_emit_rectlist_commands_gen6(struct ilo_render *r, gen6_3DPRIMITIVE(r->builder, &blitter->draw, NULL); } -static int -gen6_render_max_command_size(const struct ilo_render *render) +int +ilo_render_get_draw_commands_len_gen6(const struct ilo_render *render, + const struct ilo_state_vector *vec) { - static int size; + static int len; + + ILO_DEV_ASSERT(render->dev, 6, 6); - if (!size) { - size += GEN6_3DSTATE_CONSTANT_ANY__SIZE * 3; - size += GEN6_3DSTATE_GS_SVB_INDEX__SIZE * 4; - size += GEN6_PIPE_CONTROL__SIZE * 5; + if (!len) { + len += GEN6_3DSTATE_CONSTANT_ANY__SIZE * 3; + len += GEN6_3DSTATE_GS_SVB_INDEX__SIZE * 4; + len += GEN6_PIPE_CONTROL__SIZE * 5; - size += + len += GEN6_STATE_BASE_ADDRESS__SIZE + GEN6_STATE_SIP__SIZE + GEN6_3DSTATE_VF_STATISTICS__SIZE + @@ -1128,38 +1056,5 @@ gen6_render_max_command_size(const struct ilo_render *render) GEN6_3DPRIMITIVE__SIZE; } - return size; -} - -static int -ilo_render_estimate_size_gen6(struct ilo_render *render, - enum ilo_render_action action, - const void *arg) -{ - int size; - - switch (action) { - case ILO_RENDER_DRAW: - { - const struct ilo_state_vector *vec = arg; - - size = gen6_render_max_command_size(render) + - ilo_render_get_draw_dynamic_states_len(render, vec) + - ilo_render_get_draw_surface_states_len(render, vec); - } - break; - default: - assert(!"unknown render action"); - size = 0; - break; - } - - return size; -} - -void -ilo_render_init_gen6(struct ilo_render *render) -{ - render->estimate_size = ilo_render_estimate_size_gen6; - render->emit_draw = ilo_render_emit_draw_gen6; + return len; } diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.c b/src/gallium/drivers/ilo/ilo_render_gen7.c index 3ec24c823c3..888d67810af 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen7.c +++ b/src/gallium/drivers/ilo/ilo_render_gen7.c @@ -35,7 +35,6 @@ #include "ilo_state.h" #include "ilo_render.h" #include "ilo_render_gen.h" -#include "ilo_render_gen7.h" /** * A wrapper for gen6_PIPE_CONTROL(). @@ -652,11 +651,13 @@ gen7_draw_vf_draw(struct ilo_render *r, r->state.deferred_pipe_control_dw1 = 0; } -static void -gen7_draw_commands(struct ilo_render *render, - const struct ilo_state_vector *vec, - struct gen6_draw_session *session) +void +ilo_render_emit_draw_commands_gen7(struct ilo_render *render, + const struct ilo_state_vector *vec, + struct gen6_draw_session *session) { + ILO_DEV_ASSERT(render->dev, 7, 7.5); + /* * We try to keep the order of the commands match, as closely as possible, * that of the classic i965 driver. It allows us to compare the command @@ -687,20 +688,6 @@ gen7_draw_commands(struct ilo_render *render, } static void -ilo_render_emit_draw_gen7(struct ilo_render *render, - const struct ilo_state_vector *vec) -{ - struct gen6_draw_session session; - - gen6_draw_prepare(render, vec, &session); - - session.emit_draw_commands = gen7_draw_commands; - - gen6_draw_emit(render, vec, &session); - gen6_draw_end(render, vec, &session); -} - -static void gen7_rectlist_pcb_alloc(struct ilo_render *r, const struct ilo_blitter *blitter) { @@ -887,20 +874,23 @@ ilo_render_emit_rectlist_commands_gen7(struct ilo_render *r, gen7_3DPRIMITIVE(r->builder, &blitter->draw, NULL); } -static int -gen7_render_max_command_size(const struct ilo_render *render) +int +ilo_render_get_draw_commands_len_gen7(const struct ilo_render *render, + const struct ilo_state_vector *vec) { - static int size; + static int len; - if (!size) { - size += GEN7_3DSTATE_URB_ANY__SIZE * 4; - size += GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_ANY__SIZE * 5; - size += GEN6_3DSTATE_CONSTANT_ANY__SIZE * 5; - size += GEN7_3DSTATE_POINTERS_ANY__SIZE * (5 + 5 + 4); - size += GEN7_3DSTATE_SO_BUFFER__SIZE * 4; - size += GEN6_PIPE_CONTROL__SIZE * 5; + ILO_DEV_ASSERT(render->dev, 7, 7.5); - size += + if (!len) { + len += GEN7_3DSTATE_URB_ANY__SIZE * 4; + len += GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_ANY__SIZE * 5; + len += GEN6_3DSTATE_CONSTANT_ANY__SIZE * 5; + len += GEN7_3DSTATE_POINTERS_ANY__SIZE * (5 + 5 + 4); + len += GEN7_3DSTATE_SO_BUFFER__SIZE * 4; + len += GEN6_PIPE_CONTROL__SIZE * 5; + + len += GEN6_STATE_BASE_ADDRESS__SIZE + GEN6_STATE_SIP__SIZE + GEN6_3DSTATE_VF_STATISTICS__SIZE + @@ -935,38 +925,5 @@ gen7_render_max_command_size(const struct ilo_render *render) GEN6_3DPRIMITIVE__SIZE; } - return size; -} - -static int -ilo_render_estimate_size_gen7(struct ilo_render *render, - enum ilo_render_action action, - const void *arg) -{ - int size; - - switch (action) { - case ILO_RENDER_DRAW: - { - const struct ilo_state_vector *vec = arg; - - size = gen7_render_max_command_size(render) + - ilo_render_get_draw_dynamic_states_len(render, vec) + - ilo_render_get_draw_surface_states_len(render, vec); - } - break; - default: - assert(!"unknown render action"); - size = 0; - break; - } - - return size; -} - -void -ilo_render_init_gen7(struct ilo_render *render) -{ - render->estimate_size = ilo_render_estimate_size_gen7; - render->emit_draw = ilo_render_emit_draw_gen7; + return len; } diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.h b/src/gallium/drivers/ilo/ilo_render_gen7.h deleted file mode 100644 index 5721ce2991c..00000000000 --- a/src/gallium/drivers/ilo/ilo_render_gen7.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2013 LunarG, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu <[email protected]> - */ - -#ifndef ILO_RENDER_GEN7_H -#define ILO_RENDER_GEN7_H - -#include "ilo_common.h" - -struct ilo_render; - -void -ilo_render_init_gen7(struct ilo_render *render); - -#endif /* ILO_RENDER_GEN7_H */ |