From: Antonio Caggiano Date: Mon, 26 Apr 2021 16:49:14 +0000 (+0200) Subject: panfrost: Fix invalid conversions X-Git-Tag: upstream/21.2.3~3952 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a67ea63718466053e48fbeeb204c00435c14a736;p=platform%2Fupstream%2Fmesa.git panfrost: Fix invalid conversions When compiling with a C++ compiler, invalid conversions are treated as errors unless the fpermissive flag is provided. These changes fix all invalid conversions encountered while including libpanfrost in a C++ project. Signed-off-by: Antonio Caggiano Reviewed-by: Boris Brezillon Acked-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/lib/gen_pack.py b/src/panfrost/lib/gen_pack.py index 46b76fc..fbb08a4 100644 --- a/src/panfrost/lib/gen_pack.py +++ b/src/panfrost/lib/gen_pack.py @@ -105,7 +105,7 @@ __gen_unpack_uint(const uint8_t *restrict cl, uint32_t start, uint32_t end) const int width = end - start + 1; const uint64_t mask = (width == 64 ? ~0 : (1ull << width) - 1 ); - for (int byte = start / 8; byte <= end / 8; byte++) { + for (uint32_t byte = start / 8; byte <= end / 8; byte++) { val |= ((uint64_t) cl[byte]) << ((byte - start / 8) * 8); } @@ -171,19 +171,19 @@ __gen_unpack_padded(const uint8_t *restrict cl, uint32_t start, uint32_t end) #define mali_pixel_format_print_v6(fp, format) \\ fprintf(fp, "%*sFormat (v6): %s%s%s %s%s%s%s\\n", indent, "", \\ - mali_format_as_str((format >> 12) & 0xFF), \\ + mali_format_as_str((enum mali_format)((format >> 12) & 0xFF)), \\ (format & (1 << 20)) ? " sRGB" : "", \\ (format & (1 << 21)) ? " big-endian" : "", \\ - mali_channel_as_str(((format >> 0) & 0x7)), \\ - mali_channel_as_str(((format >> 3) & 0x7)), \\ - mali_channel_as_str(((format >> 6) & 0x7)), \\ - mali_channel_as_str(((format >> 9) & 0x7))); + mali_channel_as_str((enum mali_channel)((format >> 0) & 0x7)), \\ + mali_channel_as_str((enum mali_channel)((format >> 3) & 0x7)), \\ + mali_channel_as_str((enum mali_channel)((format >> 6) & 0x7)), \\ + mali_channel_as_str((enum mali_channel)((format >> 9) & 0x7))); #define mali_pixel_format_print_v7(fp, format) \\ fprintf(fp, "%*sFormat (v7): %s%s %s%s\\n", indent, "", \\ - mali_format_as_str((format >> 12) & 0xFF), \\ + mali_format_as_str((enum mali_format)((format >> 12) & 0xFF)), \\ (format & (1 << 20)) ? " sRGB" : "", \\ - mali_rgb_component_order_as_str((format & ((1 << 12) - 1))), \\ + mali_rgb_component_order_as_str((enum mali_rgb_component_order)(format & ((1 << 12) - 1))), \\ (format & (1 << 21)) ? " XXX BAD BIT" : ""); @@ -584,8 +584,10 @@ class Group(object): args.append(str(fieldref.start)) args.append(str(fieldref.end)) - if field.type in set(["uint", "uint/float", "address", "Pixel Format"]) | self.parser.enums: + if field.type in set(["uint", "uint/float", "address", "Pixel Format"]): convert = "__gen_unpack_uint" + elif field.type in self.parser.enums: + convert = "(enum %s)__gen_unpack_uint" % enum_name(field.type) elif field.type == "int": convert = "__gen_unpack_sint" elif field.type == "padded": diff --git a/src/panfrost/lib/pan_device.h b/src/panfrost/lib/pan_device.h index 976d34e..27f40ee 100644 --- a/src/panfrost/lib/pan_device.h +++ b/src/panfrost/lib/pan_device.h @@ -250,7 +250,7 @@ panfrost_query_sample_position( static inline struct panfrost_bo * pan_lookup_bo(struct panfrost_device *dev, uint32_t gem_handle) { - return util_sparse_array_get(&dev->bo_map, gem_handle); + return (struct panfrost_bo *)util_sparse_array_get(&dev->bo_map, gem_handle); } static inline bool