[PATCH 04/16] glamor: add support for allocating linear buffers (v2)
Dave Airlie
airlied at gmail.com
Thu Jun 25 16:51:07 PDT 2015
We need this for doing USB offload scenarios using glamor
and modesetting driver.
unfortunately only gbm in mesa 10.6 has support for the
linear API.
v1.1: fix bad define
v2: update the configure.ac test as per amdgpu. (Michel)
set linear bos to external to avoid cache. (Eric)
Reviewed-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
configure.ac | 4 ++++
glamor/glamor.h | 3 ++-
glamor/glamor_egl.c | 5 ++++-
glamor/glamor_egl_stubs.c | 2 +-
glamor/glamor_fbo.c | 13 ++++++++-----
hw/xwayland/xwayland-glamor.c | 2 +-
include/dix-config.h.in | 3 +++
7 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index f760730..592e133 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2105,6 +2105,10 @@ if test "x$GLAMOR" = xyes; then
if test "x$GBM" = xyes; then
AC_DEFINE(GLAMOR_HAS_GBM, 1,
[Build glamor with GBM-based EGL support])
+ AC_CHECK_DECL(GBM_BO_USE_LINEAR,
+ [AC_DEFINE(GLAMOR_HAS_GBM_LINEAR, 1, [Have GBM_BO_USE_LINEAR])], [],
+ [#include <stdlib.h>
+ #include <gbm.h>])
fi
fi
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 0d57fff..657354d 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -142,7 +142,8 @@ extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen);
extern _X_EXPORT unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr
screen,
int w,
- int h);
+ int h,
+ Bool linear);
extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
unsigned int, Bool,
CARD16 *, CARD32 *);
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index dc54561..4c0db6a 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -187,7 +187,7 @@ glamor_egl_get_gbm_device(ScreenPtr screen)
}
unsigned int
-glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
+glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h, Bool linear)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
struct glamor_egl_screen_private *glamor_egl;
@@ -200,6 +200,9 @@ glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
glamor_egl = glamor_egl_get_screen_private(scrn);
bo = gbm_bo_create(glamor_egl->gbm, w, h, GBM_FORMAT_ARGB8888,
+#ifdef GLAMOR_HAS_GBM_LINEAR
+ (linear ? GBM_BO_USE_LINEAR : 0) |
+#endif
GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
if (!bo)
return 0;
diff --git a/glamor/glamor_egl_stubs.c b/glamor/glamor_egl_stubs.c
index a93f62d..c11e6d5 100644
--- a/glamor/glamor_egl_stubs.c
+++ b/glamor/glamor_egl_stubs.c
@@ -50,7 +50,7 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
}
unsigned int
-glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
+glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h, Bool linear)
{
return 0;
}
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index ea0e801..6017f5e 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -228,6 +228,9 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
fbo->external = FALSE;
fbo->format = format;
+ if (flag == CREATE_PIXMAP_USAGE_SHARED)
+ fbo->external = TRUE;
+
if (flag != GLAMOR_CREATE_FBO_NO_FBO) {
if (glamor_pixmap_ensure_fb(glamor_priv, fbo) != 0) {
glamor_purge_fbo(glamor_priv, fbo);
@@ -313,7 +316,7 @@ glamor_destroy_fbo(glamor_screen_private *glamor_priv,
static int
_glamor_create_tex(glamor_screen_private *glamor_priv,
- int w, int h, GLenum format)
+ int w, int h, GLenum format, Bool linear)
{
unsigned int tex = 0;
@@ -323,7 +326,7 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
* an ARGB8888 based texture for us. */
if (glamor_priv->dri3_enabled && format == GL_RGBA) {
tex = glamor_egl_create_argb8888_based_texture(glamor_priv->screen,
- w, h);
+ w, h, linear);
}
if (!tex) {
glamor_make_current(glamor_priv);
@@ -344,14 +347,14 @@ glamor_create_fbo(glamor_screen_private *glamor_priv,
glamor_pixmap_fbo *fbo;
GLint tex = 0;
- if (flag == GLAMOR_CREATE_FBO_NO_FBO)
+ if (flag == GLAMOR_CREATE_FBO_NO_FBO || flag == CREATE_PIXMAP_USAGE_SHARED)
goto new_fbo;
fbo = glamor_pixmap_fbo_cache_get(glamor_priv, w, h, format);
if (fbo)
return fbo;
new_fbo:
- tex = _glamor_create_tex(glamor_priv, w, h, format);
+ tex = _glamor_create_tex(glamor_priv, w, h, format, flag == CREATE_PIXMAP_USAGE_SHARED);
fbo = glamor_create_fbo_from_tex(glamor_priv, w, h, format, tex, flag);
return fbo;
@@ -531,7 +534,7 @@ glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
if (!pixmap_priv->fbo->tex)
pixmap_priv->fbo->tex =
_glamor_create_tex(glamor_priv, pixmap->drawable.width,
- pixmap->drawable.height, format);
+ pixmap->drawable.height, format, FALSE);
if (flag != GLAMOR_CREATE_FBO_NO_FBO && pixmap_priv->fbo->fb == 0)
if (glamor_pixmap_ensure_fb(glamor_priv, pixmap_priv->fbo) != 0)
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 6b6e597..ece7dbe 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -415,7 +415,7 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
}
unsigned int
-glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
+glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h, Bool linear)
{
return 0;
}
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 76f45f5..c2ba434 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -503,6 +503,9 @@
/* Build glamor's GBM-based EGL support */
#undef GLAMOR_HAS_GBM
+/* Build glamor/gbm has linear support */
+#undef GLAMOR_HAS_GBM_LINEAR
+
/* byte order */
#undef X_BYTE_ORDER
--
2.4.3
More information about the xorg-devel
mailing list