mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 02:48:06 +02:00
intel/isl: Add bounds-checking assertions for the format_info table
We follow the same convention as isl_format_get_layout in having two assertions to ensure that only valid formats are passed in. We also check against the array size of the table because some valid formats such as CCS formats will may be past the end of the table. This fixes some potential out-of-bounds array access even in valid cases. Cc: mesa-stable@lists.freedesktop.org Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> (cherry picked from commit 45c05a7cee32990feda89685f1080b7251fa1a59)
This commit is contained in:
parent
0046ee83d7
commit
c2e44a3540
1 changed files with 16 additions and 8 deletions
|
|
@ -365,11 +365,19 @@ format_gen(const struct gen_device_info *devinfo)
|
|||
return devinfo->gen * 10 + (devinfo->is_g4x || devinfo->is_haswell) * 5;
|
||||
}
|
||||
|
||||
static bool
|
||||
format_info_exists(enum isl_format format)
|
||||
{
|
||||
assert(format != ISL_FORMAT_UNSUPPORTED);
|
||||
assert(format < ISL_NUM_FORMATS);
|
||||
return format < ARRAY_SIZE(format_info) && format_info[format].exists;
|
||||
}
|
||||
|
||||
bool
|
||||
isl_format_supports_rendering(const struct gen_device_info *devinfo,
|
||||
enum isl_format format)
|
||||
{
|
||||
if (!format_info[format].exists)
|
||||
if (!format_info_exists(format))
|
||||
return false;
|
||||
|
||||
return format_gen(devinfo) >= format_info[format].render_target;
|
||||
|
|
@ -379,7 +387,7 @@ bool
|
|||
isl_format_supports_alpha_blending(const struct gen_device_info *devinfo,
|
||||
enum isl_format format)
|
||||
{
|
||||
if (!format_info[format].exists)
|
||||
if (!format_info_exists(format))
|
||||
return false;
|
||||
|
||||
return format_gen(devinfo) >= format_info[format].alpha_blend;
|
||||
|
|
@ -389,7 +397,7 @@ bool
|
|||
isl_format_supports_sampling(const struct gen_device_info *devinfo,
|
||||
enum isl_format format)
|
||||
{
|
||||
if (!format_info[format].exists)
|
||||
if (!format_info_exists(format))
|
||||
return false;
|
||||
|
||||
if (devinfo->is_baytrail) {
|
||||
|
|
@ -422,7 +430,7 @@ bool
|
|||
isl_format_supports_filtering(const struct gen_device_info *devinfo,
|
||||
enum isl_format format)
|
||||
{
|
||||
if (!format_info[format].exists)
|
||||
if (!format_info_exists(format))
|
||||
return false;
|
||||
|
||||
if (devinfo->is_baytrail) {
|
||||
|
|
@ -455,7 +463,7 @@ bool
|
|||
isl_format_supports_vertex_fetch(const struct gen_device_info *devinfo,
|
||||
enum isl_format format)
|
||||
{
|
||||
if (!format_info[format].exists)
|
||||
if (!format_info_exists(format))
|
||||
return false;
|
||||
|
||||
/* For vertex fetch, Bay Trail supports the same set of formats as Haswell
|
||||
|
|
@ -474,7 +482,7 @@ bool
|
|||
isl_format_supports_typed_writes(const struct gen_device_info *devinfo,
|
||||
enum isl_format format)
|
||||
{
|
||||
if (!format_info[format].exists)
|
||||
if (!format_info_exists(format))
|
||||
return false;
|
||||
|
||||
return format_gen(devinfo) >= format_info[format].typed_write;
|
||||
|
|
@ -495,7 +503,7 @@ bool
|
|||
isl_format_supports_typed_reads(const struct gen_device_info *devinfo,
|
||||
enum isl_format format)
|
||||
{
|
||||
if (!format_info[format].exists)
|
||||
if (!format_info_exists(format))
|
||||
return false;
|
||||
|
||||
return format_gen(devinfo) >= format_info[format].typed_read;
|
||||
|
|
@ -533,7 +541,7 @@ bool
|
|||
isl_format_supports_ccs_e(const struct gen_device_info *devinfo,
|
||||
enum isl_format format)
|
||||
{
|
||||
if (!format_info[format].exists)
|
||||
if (!format_info_exists(format))
|
||||
return false;
|
||||
|
||||
/* For simplicity, only report that a format supports CCS_E if blorp can
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue