anv: fix potential integer overflow

Description by Coverity:
"Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression 1 << b with type int
(32 bits, signed) is evaluated using 32-bit arithmetic, and then used in
a context that expects an expression of type VkAccessFlags2KHR (64 bits,
unsigned)"

CID: 1492745
CID: 1492748

Fixes: b996fa8efa ("anv: implement VK_KHR_synchronization2")
Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13284>
This commit is contained in:
Marcin Ślusarz 2021-10-11 10:58:11 +02:00 committed by Marge Bot
parent c89616c98d
commit 3b9b6db031

View file

@ -2499,7 +2499,7 @@ anv_pipe_flush_bits_for_access_flags(struct anv_device *device,
enum anv_pipe_bits pipe_bits = 0;
u_foreach_bit64(b, flags) {
switch ((VkAccessFlags2KHR)(1 << b)) {
switch ((VkAccessFlags2KHR)BITFIELD64_BIT(b)) {
case VK_ACCESS_2_SHADER_WRITE_BIT_KHR:
case VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT_KHR:
/* We're transitioning a buffer that was previously used as write
@ -2576,7 +2576,7 @@ anv_pipe_invalidate_bits_for_access_flags(struct anv_device *device,
enum anv_pipe_bits pipe_bits = 0;
u_foreach_bit64(b, flags) {
switch ((VkAccessFlags2KHR)(1 << b)) {
switch ((VkAccessFlags2KHR)BITFIELD64_BIT(b)) {
case VK_ACCESS_2_INDIRECT_COMMAND_READ_BIT_KHR:
/* Indirect draw commands take a buffer as input that we're going to
* read from the command streamer to load some of the HW registers