From: Lionel Landwerlin Date: Mon, 10 Aug 2020 20:58:55 +0000 (+0300) Subject: anv: fix up dynamic clip emission X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ffc8f2ba4c2cc38c5612ef20235b90b648c4feff;p=mesa.git anv: fix up dynamic clip emission There were 2 issues : * We were not emitting the clip state when the pipeline changed * On Gen7 we did not program the front facing & cull mode dynamic values in the clip state Signed-off-by: Lionel Landwerlin Fixes: c34d8ac26e0a21 ("anv: handle dynamic viewport count") Closes https://gitlab.freedesktop.org/mesa/mesa/-/issues/3379 Reviewed-by: Tapani Pälli Part-of: --- diff --git a/src/intel/vulkan/anv_genX.h b/src/intel/vulkan/anv_genX.h index aede549f487..65af516d3e9 100644 --- a/src/intel/vulkan/anv_genX.h +++ b/src/intel/vulkan/anv_genX.h @@ -72,8 +72,6 @@ void genX(flush_pipeline_select_gpgpu)(struct anv_cmd_buffer *cmd_buffer); void genX(cmd_buffer_config_l3)(struct anv_cmd_buffer *cmd_buffer, const struct gen_l3_config *cfg); -void genX(cmd_buffer_emit_clip)(struct anv_cmd_buffer *cmd_buffer); - void genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer); void genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer); diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index c3bf66df3d3..7afaeca366b 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -3263,26 +3263,44 @@ cmd_buffer_flush_push_constants(struct anv_cmd_buffer *cmd_buffer, cmd_buffer->state.push_constants_dirty &= ~flushed; } -void -genX(cmd_buffer_emit_clip)(struct anv_cmd_buffer *cmd_buffer) +static void +cmd_buffer_emit_clip(struct anv_cmd_buffer *cmd_buffer) { - struct anv_graphics_pipeline *pipeline = cmd_buffer->state.gfx.pipeline; + const uint32_t clip_states = +#if GEN_GEN <= 7 + ANV_CMD_DIRTY_DYNAMIC_FRONT_FACE | + ANV_CMD_DIRTY_DYNAMIC_CULL_MODE | +#endif + ANV_CMD_DIRTY_DYNAMIC_VIEWPORT | + ANV_CMD_DIRTY_PIPELINE; - if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE | - ANV_CMD_DIRTY_DYNAMIC_VIEWPORT)) { - uint32_t dwords[GENX(3DSTATE_CLIP_length)]; - int32_t count = - cmd_buffer->state.gfx.dynamic.viewport.count > 0 ? - cmd_buffer->state.gfx.dynamic.viewport.count - 1 : 0; + if ((cmd_buffer->state.gfx.dirty & clip_states) == 0) + return; - struct GENX(3DSTATE_CLIP) clip = { - GENX(3DSTATE_CLIP_header), - .MaximumVPIndex = count, - }; - GENX(3DSTATE_CLIP_pack)(NULL, dwords, &clip); - anv_batch_emit_merge(&cmd_buffer->batch, dwords, - pipeline->gen7.clip); +#if GEN_GEN <= 7 + const struct anv_dynamic_state *d = &cmd_buffer->state.gfx.dynamic; +#endif + struct GENX(3DSTATE_CLIP) clip = { + GENX(3DSTATE_CLIP_header), +#if GEN_GEN <= 7 + .FrontWinding = genX(vk_to_gen_front_face)[d->front_face], + .CullMode = genX(vk_to_gen_cullmode)[d->cull_mode], +#endif + }; + uint32_t dwords[GENX(3DSTATE_CLIP_length)]; + + struct anv_graphics_pipeline *pipeline = cmd_buffer->state.gfx.pipeline; + const struct brw_vue_prog_data *last = + anv_pipeline_get_last_vue_prog_data(pipeline); + if (last->vue_map.slots_valid & VARYING_BIT_VIEWPORT) { + clip.MaximumVPIndex = + cmd_buffer->state.gfx.dynamic.viewport.count > 0 ? + cmd_buffer->state.gfx.dynamic.viewport.count - 1 : 0; } + + GENX(3DSTATE_CLIP_pack)(NULL, dwords, &clip); + anv_batch_emit_merge(&cmd_buffer->batch, dwords, + pipeline->gen7.clip); } void @@ -3469,10 +3487,10 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer) if (dirty) cmd_buffer_emit_descriptor_pointers(cmd_buffer, dirty); - if (cmd_buffer->state.gfx.dirty & ANV_CMD_DIRTY_DYNAMIC_VIEWPORT) { - genX(cmd_buffer_emit_clip)(cmd_buffer); + cmd_buffer_emit_clip(cmd_buffer); + + if (cmd_buffer->state.gfx.dirty & ANV_CMD_DIRTY_DYNAMIC_VIEWPORT) gen8_cmd_buffer_emit_viewport(cmd_buffer); - } if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_DYNAMIC_VIEWPORT | ANV_CMD_DIRTY_PIPELINE)) {