summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Widawsky <ben@bwidawsk.net>2017-01-13 12:01:37 -0800
committerBen Widawsky <ben@bwidawsk.net>2017-03-09 16:09:58 -0800
commit360d3bdb76b7e3ec7762a78b2f80b0184d3fe72d (patch)
tree9141897c818c7ed2d2c620a69a34521a5e55311b
parent7d2948bd38b35ca07ad1df3f11db6049179f5f68 (diff)
i965: 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. References: https://patchwork.kernel.org/patch/9419157/ Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
-rw-r--r--src/mesa/drivers/dri/i965/intel_image.h1
-rw-r--r--src/mesa/drivers/dri/i965/intel_screen.c34
2 files changed, 28 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_image.h b/src/mesa/drivers/dri/i965/intel_image.h
index fd63919b2d..3a35487dc4 100644
--- a/src/mesa/drivers/dri/i965/intel_image.h
+++ b/src/mesa/drivers/dri/i965/intel_image.h
@@ -71,6 +71,7 @@ struct __DRIimageRec {
GLenum internal_format;
uint32_t dri_format;
GLuint format;
+ uint64_t modifier; /** fb modifier (fourcc) */
uint32_t offset;
/*
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index c23872e399..0ed5d22231 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 =
@@ -520,7 +524,16 @@ select_best_modifier(struct gen_device_info *devinfo,
const uint64_t *modifiers,
const unsigned count)
{
- return DRM_FORMAT_MOD_INVALID;
+ uint64_t modifier = DRM_FORMAT_MOD_INVALID;
+
+ for (int i = 0; i < count; i++) {
+ switch (modifiers[i]) {
+ case DRM_FORMAT_MOD_LINEAR:
+ return modifiers[i];
+ }
+ }
+
+ return modifier;
}
static __DRIimage *
@@ -533,7 +546,10 @@ __intel_create_image(__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;
@@ -544,12 +560,15 @@ __intel_create_image(__DRIscreen *dri_screen,
assert(!(use && count));
uint64_t modifier = select_best_modifier(&screen->devinfo, modifiers, count);
- assert(modifier == DRM_FORMAT_MOD_INVALID);
+ switch (modifier) {
+ case DRM_FORMAT_MOD_LINEAR:
+ tiling = I915_TILING_NONE;
+ break;
+ case DRM_FORMAT_MOD_INVALID:
+ 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 +593,7 @@ __intel_create_image(__DRIscreen *dri_screen,
image->width = width;
image->height = height;
image->pitch = pitch;
+ image->modifier = modifier;
return image;
}