From 9d7166dfc00d19d91ea7d5b55042f3e1ecea64db Mon Sep 17 00:00:00 2001 From: Sagar Ghuge Date: Thu, 28 Sep 2023 22:52:48 -0700 Subject: [PATCH] isl: Use 16-bit instead of 8-bits for surface format info fields Comparing uint8_t max value 255 with devinfo->verx10 will work fine for now but for future platforms, comparison will fail. To avoid this let's switch the field data type from 8-bits to 16-bits. v1: (Jordan) - Use 16 bits instead of 32 and add assertion. Signed-off-by: Sagar Ghuge Reviewed-by: Jordan Justen Part-of: --- src/intel/isl/isl_format.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/intel/isl/isl_format.c b/src/intel/isl/isl_format.c index 9a58a4e..1e9bd99 100644 --- a/src/intel/isl/isl_format.c +++ b/src/intel/isl/isl_format.c @@ -39,19 +39,20 @@ struct surface_format_info { bool exists; - uint8_t sampling; - uint8_t filtering; - uint8_t shadow_compare; - uint8_t chroma_key; - uint8_t render_target; - uint8_t alpha_blend; - uint8_t input_vb; - uint8_t streamed_output_vb; - uint8_t color_processing; - uint8_t typed_write; - uint8_t typed_read; - uint8_t typed_atomics; - uint8_t ccs_e; + /* These fields must fit the largest verx10 value. */ + uint16_t sampling; + uint16_t filtering; + uint16_t shadow_compare; + uint16_t chroma_key; + uint16_t render_target; + uint16_t alpha_blend; + uint16_t input_vb; + uint16_t streamed_output_vb; + uint16_t color_processing; + uint16_t typed_write; + uint16_t typed_read; + uint16_t typed_atomics; + uint16_t ccs_e; }; /* This macro allows us to write the table almost as it appears in the PRM, @@ -61,7 +62,7 @@ struct surface_format_info { [ISL_FORMAT_##sf] = { true, sampl, filt, shad, ck, rt, ab, vb, so, color, tw, tr, ta, ccs_e}, #define Y 0 -#define x 255 +#define x 0xFFFF /** * This is the table of support for surface (texture, renderbuffer, and vertex * buffer, but not depthbuffer) formats across the various hardware generations. @@ -705,6 +706,9 @@ isl_format_supports_rendering(const struct intel_device_info *devinfo, if (!format_info_exists(format)) return false; + /* If this fails, then we need to update struct surface_format_info */ + assert(devinfo->verx10 < + (1ul << (8 * sizeof(format_info[format].render_target)))); return devinfo->verx10 >= format_info[format].render_target; } -- 2.7.4