From 639b1366d020eb2bc08679ac736435aebf6e44f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 25 Aug 2020 22:35:29 -0400 Subject: [PATCH] radeonsi: resolve a tricky C++ failure with goto jumping over initializations C++ doesn't allow jumping over variable initializations, so we have to use a macro. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_state_draw.c | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index 0e4e2c4d835..4ceb2794109 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -1882,6 +1882,11 @@ static ALWAYS_INLINE bool pd_msg(const char *s) return false; } +#define DRAW_CLEANUP do { \ + if (index_size && indexbuf != info->index.resource) \ + pipe_resource_reference(&indexbuf, NULL); \ + } while (0) + static void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info, const struct pipe_draw_indirect_info *indirect, @@ -2159,9 +2164,11 @@ static void si_draw_vbo(struct pipe_context *ctx, break; case SI_PRIM_DISCARD_DRAW_SPLIT: sctx->compute_num_verts_rejected -= total_direct_count; - goto return_cleanup; + FALLTHROUGH; case SI_PRIM_DISCARD_MULTI_DRAW_SPLIT: - goto return_cleanup; + /* The multi draw was split into multiple ones and executed. Return. */ + DRAW_CLEANUP; + return; } } @@ -2234,8 +2241,10 @@ static void si_draw_vbo(struct pipe_context *ctx, } if (unlikely(sctx->do_update_shaders)) { - if (unlikely(!si_update_shaders(sctx))) - goto return_cleanup; + if (unlikely(!si_update_shaders(sctx))) { + DRAW_CLEANUP; + return; + } /* Insert a VGT_FLUSH when enabling fast launch changes to prevent hangs. * See issues #2418, #2426, #2434 @@ -2282,8 +2291,10 @@ static void si_draw_vbo(struct pipe_context *ctx, if (unlikely(!si_upload_graphics_shader_descriptors(sctx) || (sctx->vertex_buffers_dirty && sctx->num_vertex_elements && - !si_upload_vertex_buffer_descriptors(sctx)))) - goto return_cleanup; + !si_upload_vertex_buffer_descriptors(sctx)))) { + DRAW_CLEANUP; + return; + } /* Vega10/Raven scissor bug workaround. When any context register is * written (i.e. the GPU rolls the context), PA_SC_VPORT_SCISSOR @@ -2399,9 +2410,7 @@ static void si_draw_vbo(struct pipe_context *ctx, sctx->num_spill_draw_calls++; } -return_cleanup: - if (index_size && indexbuf != info->index.resource) - pipe_resource_reference(&indexbuf, NULL); + DRAW_CLEANUP; } static void si_draw_rectangle(struct blitter_context *blitter, void *vertex_elements_cso,