summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk@arm.linux.org.uk>2015-10-29 11:47:22 +0000
committerRussell King <rmk@arm.linux.org.uk>2015-11-08 20:09:13 +0000
commit53e46087af4e20b557a0a268d7123f3d6f72f23f (patch)
treee1014e1ab486acefd41ecca43087683a5ba70331
parent6081fcfd3af768169a62cbd22ad766051c809fdb (diff)
etnaviv: align DRI2 buffers to 16 pixel width/height
The Vivante 3D resolve engine requires 16 pixel alignment for both the width and height. Arrange for the DRI2 allocated buffers to meet this requirement. Signed-off-by: Russell King <rmk@arm.linux.org.uk>
-rw-r--r--etnaviv/etnaviv.c7
-rw-r--r--etnaviv/etnaviv_accel.h1
-rw-r--r--etnaviv/etnaviv_dri2.c3
-rw-r--r--etnaviv/etnaviv_utils.h13
4 files changed, 23 insertions, 1 deletions
diff --git a/etnaviv/etnaviv.c b/etnaviv/etnaviv.c
index b4306e9..b94b635 100644
--- a/etnaviv/etnaviv.c
+++ b/etnaviv/etnaviv.c
@@ -663,6 +663,13 @@ static Bool etnaviv_alloc_etna_bo(ScreenPtr pScreen, struct etnaviv *etnaviv,
pitch = etnaviv_tile_pitch(w, bpp);
size = pitch * etnaviv_tile_height(h);
fmt.tile = 1;
+ } else if (usage_hint & CREATE_PIXMAP_USAGE_3D) {
+ /*
+ * The Vivante 3D resolve engine requires the
+ * width and height to be appropriately aligned.
+ */
+ pitch = etnaviv_3d_pitch(w, bpp);
+ size = etnaviv_3d_size(pitch, h);
} else {
pitch = etnaviv_pitch(w, bpp);
size = pitch * h;
diff --git a/etnaviv/etnaviv_accel.h b/etnaviv/etnaviv_accel.h
index d2cf1a6..9ee3dc9 100644
--- a/etnaviv/etnaviv_accel.h
+++ b/etnaviv/etnaviv_accel.h
@@ -49,6 +49,7 @@ struct etnaviv_dri2_info;
enum {
CREATE_PIXMAP_USAGE_TILE = 0x80000000,
CREATE_PIXMAP_USAGE_GPU = 0x40000000, /* Must be vpix backed */
+ CREATE_PIXMAP_USAGE_3D = 0x20000000, /* 3D has restrictions */
};
/* Workarounds for hardware bugs */
diff --git a/etnaviv/etnaviv_dri2.c b/etnaviv/etnaviv_dri2.c
index 82538b1..5f52e50 100644
--- a/etnaviv/etnaviv_dri2.c
+++ b/etnaviv/etnaviv_dri2.c
@@ -64,7 +64,8 @@ static DRI2Buffer2Ptr etnaviv_dri2_CreateBuffer(DrawablePtr drawable,
if (pixmap == NULL) {
pixmap = common_dri2_create_pixmap(drawable, attachment, format,
- CREATE_PIXMAP_USAGE_GPU);
+ CREATE_PIXMAP_USAGE_GPU |
+ CREATE_PIXMAP_USAGE_3D);
if (!pixmap)
goto err;
}
diff --git a/etnaviv/etnaviv_utils.h b/etnaviv/etnaviv_utils.h
index 2b54c54..36ca4fe 100644
--- a/etnaviv/etnaviv_utils.h
+++ b/etnaviv/etnaviv_utils.h
@@ -64,6 +64,19 @@ static inline size_t etnaviv_tile_height(unsigned height)
return ALIGN(height, ETNAVIV_TILE_HEIGHT) / ETNAVIV_TILE_HEIGHT;
}
+#define ETNAVIV_3D_WIDTH_ALIGN 16
+#define ETNAVIV_3D_HEIGHT_ALIGN 8
+
+static inline unsigned int etnaviv_3d_pitch(unsigned width, unsigned bpp)
+{
+ return etnaviv_pitch(ALIGN(width, ETNAVIV_3D_WIDTH_ALIGN), bpp);
+}
+
+static inline size_t etnaviv_3d_size(unsigned int pitch, unsigned int height)
+{
+ return pitch * ALIGN(height, ETNAVIV_3D_HEIGHT_ALIGN);
+}
+
static inline uint32_t scale16(uint32_t val, int bits)
{
val <<= (16 - bits);