From 46be8896a5a6a368a7b6b57b24ed94d11dc7417c Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Thu, 14 Jan 2021 13:28:46 +0100 Subject: [PATCH] vrend: use a helper variable for the buffer pointer This makes the code a bit easier to read and may help the complier to avoid needless dereferencing of pointers. Signed-off-by: Gert Wollny Reviewed-by: Chia-I Wu --- src/vrend_renderer.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 632c3c6..f55e7f8 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -2747,6 +2747,9 @@ void vrend_set_uniform_buffer(struct vrend_context *ctx, if (!has_feature(feat_ubo)) return; + struct pipe_constant_buffer *cbs = &ctx->sub->cbs[shader][index]; + const uint32_t mask = 1u << index; + if (res_handle) { res = vrend_renderer_ctx_res_lookup(ctx, res_handle); @@ -2754,18 +2757,17 @@ void vrend_set_uniform_buffer(struct vrend_context *ctx, vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle); return; } - ctx->sub->cbs[shader][index].buffer = (struct pipe_resource *)res; - ctx->sub->cbs[shader][index].buffer_offset = offset; - ctx->sub->cbs[shader][index].buffer_size = length; - - ctx->sub->const_bufs_used_mask[shader] |= (1u << index); + cbs->buffer = (struct pipe_resource *)res; + cbs->buffer_offset = offset; + cbs->buffer_size = length; + ctx->sub->const_bufs_used_mask[shader] |= mask; } else { - ctx->sub->cbs[shader][index].buffer = NULL; - ctx->sub->cbs[shader][index].buffer_offset = 0; - ctx->sub->cbs[shader][index].buffer_size = 0; - ctx->sub->const_bufs_used_mask[shader] &= ~(1u << index); + cbs->buffer = NULL; + cbs->buffer_offset = 0; + cbs->buffer_size = 0; + ctx->sub->const_bufs_used_mask[shader] &= ~mask; } - ctx->sub->const_bufs_dirty[shader] |= (1u << index); + ctx->sub->const_bufs_dirty[shader] |= mask; } void vrend_set_index_buffer(struct vrend_context *ctx,