diff options
author | Ben Widawsky <ben@bwidawsk.net> | 2017-01-13 12:01:37 -0800 |
---|---|---|
committer | Ben Widawsky <ben@bwidawsk.net> | 2017-03-21 14:48:12 -0700 |
commit | d78a36ea6241b375f071302f78b1144b5c28e6c4 (patch) | |
tree | e8af7ab706878a5109a1ae1b5b9beb9944def3da /src | |
parent | 79f619ca7082fec38576491fa0010c476d1ded65 (diff) |
i965/dri: Handle the linear fb modifier
At image creation create a path for dealing with the linear modifier.
This works exactly like the old usage flags where __DRI_IMAGE_USE_LINEAR
was specified.
During development of this patch series, it was decided that a lack of
modifier was an insufficient way to express the required modifiers. As a
result, 0 was repurposed to mean a modifier for a LINEAR layout.
NOTE: This patch was added for v3 of the patch series.
v2: Rework the algorithm for modifier selection to go from a bitmask
based selection to this priority value.
v3: Make DRM_FORMAT_MOD_INVALID allowed at selection as a way of
identifying no modifiers found (because 0 is LINEAR) (Jason)
v4: Remove the logic to prune unknown modifiers (like those from other
vendors) and simply handle is in select_best_modifier (Jason)
Requested-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_screen.c | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 26ab5a8e19..a430964f02 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -45,6 +45,10 @@ #define DRM_FORMAT_MOD_INVALID ((1ULL<<56) - 1) #endif +#ifndef DRM_FORMAT_MOD_LINEAR +#define DRM_FORMAT_MOD_LINEAR 0 +#endif + static const __DRIconfigOptionsExtension brw_config_options = { .base = { __DRI_CONFIG_OPTIONS, 1 }, .xml = @@ -511,13 +515,36 @@ intel_destroy_image(__DRIimage *image) free(image); } +enum modifier_priority { + MODIFIER_PRIORITY_INVALID = 0, + MODIFIER_PRIORITY_LINEAR, +}; + +const uint64_t priority_to_modifier[] = { + [MODIFIER_PRIORITY_INVALID] = DRM_FORMAT_MOD_INVALID, + [MODIFIER_PRIORITY_LINEAR] = DRM_FORMAT_MOD_LINEAR, +}; + static uint64_t select_best_modifier(struct gen_device_info *devinfo, const uint64_t *modifiers, const unsigned count) { - /* Modifiers are not supported by this DRI driver */ - return DRM_FORMAT_MOD_INVALID; + + enum modifier_priority prio = MODIFIER_PRIORITY_INVALID; + + for (int i = 0; i < count; i++) { + switch (modifiers[i]) { + case DRM_FORMAT_MOD_LINEAR: + prio = MAX2(prio, MODIFIER_PRIORITY_LINEAR); + break; + case DRM_FORMAT_MOD_INVALID: + default: + break; + } + } + + return priority_to_modifier[prio]; } static __DRIimage * @@ -530,7 +557,10 @@ intel_create_image_common(__DRIscreen *dri_screen, { __DRIimage *image; struct intel_screen *screen = dri_screen->driverPrivate; - uint32_t tiling; + /* Historically, X-tiled was the default, and so lack of modifier means + * X-tiled. + */ + uint32_t tiling = I915_TILING_X; int cpp; unsigned long pitch; @@ -541,15 +571,17 @@ intel_create_image_common(__DRIscreen *dri_screen, assert(!(use && count)); uint64_t modifier = select_best_modifier(&screen->devinfo, modifiers, count); - assert(modifier == DRM_FORMAT_MOD_INVALID); - - if (modifier == DRM_FORMAT_MOD_INVALID && modifiers) - return NULL; + switch (modifier) { + case DRM_FORMAT_MOD_LINEAR: + tiling = I915_TILING_NONE; + break; + case DRM_FORMAT_MOD_INVALID: + if (modifiers) + return NULL; + default: + break; + } - /* Historically, X-tiled was the default, and so lack of modifier means - * X-tiled. - */ - tiling = I915_TILING_X; if (use & __DRI_IMAGE_USE_CURSOR) { if (width != 64 || height != 64) return NULL; @@ -574,6 +606,7 @@ intel_create_image_common(__DRIscreen *dri_screen, image->width = width; image->height = height; image->pitch = pitch; + image->modifier = modifier; return image; } |