radv: Prevent out of bound shift on 32-bit builds.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 10 Jun 2019 14:17:46 +0000 (16:17 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 10 Jun 2019 22:18:51 +0000 (22:18 +0000)
uintptr_t is 32-bits then and shifting it by 32 bits results in undefined
behavior IIRC.

Fixes: b3c8de1c55c "radv: save all descriptor pointers into the trace BO"
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/vulkan/radv_cmd_buffer.c

index 58ba1039bb0ac6d5a9776c0fd0a161e4425737c5..3faaf94eb992629f421a963a12bd8b21fa2f0d96 100644 (file)
@@ -584,8 +584,8 @@ radv_save_descriptors(struct radv_cmd_buffer *cmd_buffer,
 
        for_each_bit(i, descriptors_state->valid) {
                struct radv_descriptor_set *set = descriptors_state->sets[i];
-               data[i * 2] = (uintptr_t)set;
-               data[i * 2 + 1] = (uintptr_t)set >> 32;
+               data[i * 2] = (uint64_t)(uintptr_t)set;
+               data[i * 2 + 1] = (uint64_t)(uintptr_t)set >> 32;
        }
 
        radv_emit_write_data_packet(cmd_buffer, va, MAX_SETS * 2, data);