From f7890c0df92f62fbf716dd84059910c9bc59b4a9 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 27 Jun 2025 10:52:58 +0200 Subject: [PATCH] mesa: fix total_invocations computation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The multiplication of 32 bits integers will be truncated before being widened to the destination variable' size. Reported by static analysis. Reviewed-by: Marek Olšák Reviewed-by: Ian Romanick Part-of: --- src/mesa/main/compute.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/compute.c b/src/mesa/main/compute.c index 299ba097f65..9ad499040b7 100644 --- a/src/mesa/main/compute.c +++ b/src/mesa/main/compute.c @@ -167,7 +167,7 @@ validate_DispatchComputeGroupSizeARB(struct gl_context *ctx, * for compute shaders with variable group size * (MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB)." */ - uint64_t total_invocations = info->block[0] * info->block[1]; + uint64_t total_invocations = info->block[0] * (uint64_t) info->block[1]; if (total_invocations <= UINT32_MAX) { /* Only bother multiplying the third value if total still fits in * 32-bit, since MaxComputeVariableGroupInvocations is also 32-bit.