diff options
author | Jason Ekstrand <[email protected]> | 2017-07-16 16:35:22 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-07-17 13:48:38 -0700 |
commit | ec4364d57ec2990e9cc81bb5a932bc115d3e6c44 (patch) | |
tree | 3501a9febf867f2a431c9163925a4ea3c8cdc477 | |
parent | f44171ef6230d9e0adf76c563c83103f9af7b124 (diff) |
i965: Rework the modifier info map
This commit splits the mapping in half. The modifier_infos table now
only contains the modifier and the since_gen field. The tiling bits
have been moved into a table in tiling_to_modifier as that's the only
place it was ever used. The modifier_is_supported function now takes a
devinfo and does the since_gen check.
Reviewed-by: Daniel Stone <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_screen.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index f137e3ecf97..0c1a88d36f3 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -296,26 +296,25 @@ static struct intel_image_format intel_image_formats[] = { }; static const struct { - uint32_t tiling; uint64_t modifier; unsigned since_gen; -} tiling_modifier_map[] = { - { .tiling = I915_TILING_NONE, .modifier = DRM_FORMAT_MOD_LINEAR, - .since_gen = 1 }, - { .tiling = I915_TILING_X, .modifier = I915_FORMAT_MOD_X_TILED, - .since_gen = 1 }, - { .tiling = I915_TILING_Y, .modifier = I915_FORMAT_MOD_Y_TILED, - .since_gen = 6 }, +} supported_modifiers[] = { + { .modifier = DRM_FORMAT_MOD_LINEAR , .since_gen = 1 }, + { .modifier = I915_FORMAT_MOD_X_TILED , .since_gen = 1 }, + { .modifier = I915_FORMAT_MOD_Y_TILED , .since_gen = 6 }, }; static bool -modifier_is_supported(uint64_t modifier) +modifier_is_supported(const struct gen_device_info *devinfo, + uint64_t modifier) { int i; - for (i = 0; i < ARRAY_SIZE(tiling_modifier_map); i++) { - if (tiling_modifier_map[i].modifier == modifier) - return true; + for (i = 0; i < ARRAY_SIZE(supported_modifiers); i++) { + if (supported_modifiers[i].modifier != modifier) + continue; + + return supported_modifiers[i].since_gen <= devinfo->gen; } return false; @@ -324,14 +323,15 @@ modifier_is_supported(uint64_t modifier) static uint64_t tiling_to_modifier(uint32_t tiling) { - int i; + static const uint64_t map[] = { + [I915_TILING_NONE] = DRM_FORMAT_MOD_LINEAR, + [I915_TILING_X] = I915_FORMAT_MOD_X_TILED, + [I915_TILING_Y] = I915_FORMAT_MOD_Y_TILED, + }; - for (i = 0; i < ARRAY_SIZE(tiling_modifier_map); i++) { - if (tiling_modifier_map[i].tiling == tiling) - return tiling_modifier_map[i].modifier; - } + assert(tiling < ARRAY_SIZE(map)); - unreachable("tiling_to_modifier received unknown tiling mode"); + return map[tiling]; } static void @@ -860,8 +860,9 @@ intel_create_image_from_fds_common(__DRIscreen *dri_screen, if (f == NULL) return NULL; - if (modifier != DRM_FORMAT_MOD_INVALID && !modifier_is_supported(modifier)) - return NULL; + if (modifier != DRM_FORMAT_MOD_INVALID && + !modifier_is_supported(&screen->devinfo, modifier)) + return NULL; if (f->nplanes == 1) image = intel_allocate_image(screen, f->planes[0].dri_format, @@ -1074,15 +1075,16 @@ intel_query_dma_buf_modifiers(__DRIscreen *_screen, int fourcc, int max, if (f == NULL) return false; - for (i = 0; i < ARRAY_SIZE(tiling_modifier_map); i++) { - if (screen->devinfo.gen < tiling_modifier_map[i].since_gen) + for (i = 0; i < ARRAY_SIZE(supported_modifiers); i++) { + uint64_t modifier = supported_modifiers[i].modifier; + if (!modifier_is_supported(&screen->devinfo, modifier)) continue; num_mods++; if (max == 0) continue; - modifiers[num_mods - 1] = tiling_modifier_map[i].modifier; + modifiers[num_mods - 1] = modifier; if (num_mods >= max) break; } |