mesa: fix total_invocations computation

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 <marek.olsak@amd.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35877>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2025-06-27 10:52:58 +02:00 committed by Marge Bot
parent fddd5bc2e5
commit f7890c0df9

View file

@ -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.