Mesa (master): radeonsi: resolve a tricky C++ failure with goto jumping over initializations
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Dec 9 21:57:53 UTC 2020
Module: Mesa
Branch: master
Commit: 639b1366d020eb2bc08679ac736435aebf6e44f4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=639b1366d020eb2bc08679ac736435aebf6e44f4
Author: Marek Olšák <marek.olsak at amd.com>
Date: Tue Aug 25 22:35:29 2020 -0400
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 <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7807>
---
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,
More information about the mesa-commit
mailing list