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 <sagar.ghuge@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25478>
This commit is contained in:
Sagar Ghuge 2023-09-28 22:52:48 -07:00 committed by Marge Bot
parent 4bc58c9f11
commit 9d7166dfc0

View file

@ -39,19 +39,20 @@
struct surface_format_info { struct surface_format_info {
bool exists; bool exists;
uint8_t sampling; /* These fields must fit the largest verx10 value. */
uint8_t filtering; uint16_t sampling;
uint8_t shadow_compare; uint16_t filtering;
uint8_t chroma_key; uint16_t shadow_compare;
uint8_t render_target; uint16_t chroma_key;
uint8_t alpha_blend; uint16_t render_target;
uint8_t input_vb; uint16_t alpha_blend;
uint8_t streamed_output_vb; uint16_t input_vb;
uint8_t color_processing; uint16_t streamed_output_vb;
uint8_t typed_write; uint16_t color_processing;
uint8_t typed_read; uint16_t typed_write;
uint8_t typed_atomics; uint16_t typed_read;
uint8_t ccs_e; uint16_t typed_atomics;
uint16_t ccs_e;
}; };
/* This macro allows us to write the table almost as it appears in the PRM, /* 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}, [ISL_FORMAT_##sf] = { true, sampl, filt, shad, ck, rt, ab, vb, so, color, tw, tr, ta, ccs_e},
#define Y 0 #define Y 0
#define x 255 #define x 0xFFFF
/** /**
* This is the table of support for surface (texture, renderbuffer, and vertex * This is the table of support for surface (texture, renderbuffer, and vertex
* buffer, but not depthbuffer) formats across the various hardware generations. * 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)) if (!format_info_exists(format))
return false; 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; return devinfo->verx10 >= format_info[format].render_target;
} }