Re: [PATCH xf86-video-dummy] Add glamor acceleration which enables native OpenGL support

2017-03-08 Thread Emil Velikov
On 8 March 2017 at 01:04, Yu, Qiang  wrote:
>
>> You want to AC_MSG_ERROR if the the option is set to "yes" and it's
>> not available. Currently one silently ignores it, which is not good.
> Right, so I need to make it "auto" by default?
>
If you change the current default to "auto" that will fit the code
better. At the same time you'll still get the feature silently
disabled even if you _explicitly_ enable it.
Something like the following should do it.

check_all_dependencies(, have_glamor=yes, have_glamor=no) //
pseudo code/function - set variable to 'yes', if deps are met, and
'no' otherwise

case "$enable_glamor,$have_glamor" in
   yes,yes | auto,yes)
   ;;
   yes,no)
   AC_MSG_ERROR([GLAMOR requested, but $dependencies not found.])
   ;;
   no,*)
   ;;
   *)
   AC_MSG_NOTICE([GLAMOR disabled because $dependencies not found.])
   enable_glamor=no
   ;;
esac

-Emil
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xf86-video-dummy] Add glamor acceleration which enables native OpenGL support

2017-03-07 Thread Adam Jackson
On Wed, 2017-03-08 at 01:03 +, Yu, Qiang wrote:
> > Now this is cool. Any chance I can get you to do the same for Xvfb?
> 
> Thanks. I can give a try latter next month, seems glamor and egl need to 
> support
> more depth for this.

No they don't. I mean, it'd be awesome if glamor worked well at depth
16 too, but depth 24 only is entirely sufficient.

- ajax
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xf86-video-dummy] Add glamor acceleration which enables native OpenGL support

2017-03-07 Thread Yu, Qiang

> You want to AC_MSG_ERROR if the the option is set to "yes" and it's
> not available. Currently one silently ignores it, which is not good.
Right, so I need to make it "auto" by default?

Regards,
Qiang
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xf86-video-dummy] Add glamor acceleration which enables native OpenGL support

2017-03-07 Thread Yu, Qiang

> Now this is cool. Any chance I can get you to do the same for Xvfb?
Thanks. I can give a try latter next month, seems glamor and egl need to support
more depth for this.

Regards,
Qiang
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xf86-video-dummy] Add glamor acceleration which enables native OpenGL support

2017-03-07 Thread Emil Velikov
On 7 March 2017 at 03:53, Qiang Yu  wrote:
> Enable glamor acceleration in xorg.conf by:
> Section "Device"
>   ...
>   Driver "dummy"
>   Option "Render" "/dev/dri/renderD128"
>   ...
> EndSection
>
> GPU is chosen by the Render option which specifies the render
> node of the GPU DRM device.
>
> We could use the dumb buffer instead of gbm buffer as the
> screen front buffer. But dumb buffer requires open
> /dev/dri/cardx which has the limitation of only one instance
> of OpenGL enabled xserver can start.
>
> With gbm buffer, we can use /dev/dri/renderDx which has no
> limitation on the number of OpenGL enabled xserver and even
> won't conflict with a "real" xserver using radeon/amdgpu DDX.
>
> Due to using renderDx, only DRI3 OpenGL is supported.
>
> DGA is disabled when glamor is enabled, we can enable it with
> new gbm_bo_map/unmap API, but consider a more effiction way
> is just using DRI3BufferFromPixmap for the root window pixmap.
>
> Signed-off-by: Qiang Yu 
> ---
>  configure.ac   |  26 ++
>  src/Makefile.am|   7 ++-
>  src/dummy.h|   9 
>  src/dummy_dga.c|   3 ++
>  src/dummy_driver.c | 143 
> -
>  5 files changed, 176 insertions(+), 12 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 4eb7fae..7239b63 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -68,6 +68,32 @@ AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
>  # Obtain compiler/linker options for the driver dependencies
>  PKG_CHECK_MODULES(XORG, [xorg-server >= 1.4.99.901] xproto fontsproto 
> $REQUIRED_MODULES)
>
> +# Check glamor support
> +AC_ARG_ENABLE(glamor,
> + AS_HELP_STRING([--disable-glamor],
> +[Disable glamor, a new GL-based acceleration 
> [default=enabled]]),
> + [GLAMOR="$enableval"],
> + [GLAMOR=yes])
> +
> +SAVE_CPPFLAGS="$CPPFLAGS"
> +CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
> +if test "x$GLAMOR" != "xno"; then
> +   AC_CHECK_HEADERS([glamor.h], , [GLAMOR=no], [#include 
> "xorg-server.h"])
> +fi
> +CPPFLAGS="$SAVE_CPPFLAGS"
> +
> +if test "x$GLAMOR" != "xno"; then
> +   PKG_CHECK_MODULES(GBM, [gbm], , [GLAMOR=no])
> +fi
> +
> +AC_MSG_CHECKING([whether to include GLAMOR support])
> +AC_MSG_RESULT([$GLAMOR])
> +
> +if test "x$GLAMOR" != "xno"; then
> +AC_DEFINE(USE_GLAMOR, 1, [Enable glamor acceleration])
> +fi
> +AM_CONDITIONAL(GLAMOR, test x$GLAMOR != xno)
> +
The idea is cool, but the above looks wrong/broken.

You want to AC_MSG_ERROR if the the option is set to "yes" and it's
not available. Currently one silently ignores it, which is not good.

-Emil
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xf86-video-dummy] Add glamor acceleration which enables native OpenGL support

2017-03-07 Thread Adam Jackson
On Tue, 2017-03-07 at 11:53 +0800, Qiang Yu wrote:
> Enable glamor acceleration in xorg.conf by:
> Section "Device"
>   ...
>   Driver "dummy"
>   Option "Render" "/dev/dri/renderD128"
>   ...
> EndSection
> 
> GPU is chosen by the Render option which specifies the render
> node of the GPU DRM device.

Now this is cool. Any chance I can get you to do the same for Xvfb?

- ajax
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xf86-video-dummy] Add glamor acceleration which enables native OpenGL support

2017-03-06 Thread Qiang Yu
Enable glamor acceleration in xorg.conf by:
Section "Device"
  ...
  Driver "dummy"
  Option "Render" "/dev/dri/renderD128"
  ...
EndSection

GPU is chosen by the Render option which specifies the render
node of the GPU DRM device.

We could use the dumb buffer instead of gbm buffer as the
screen front buffer. But dumb buffer requires open
/dev/dri/cardx which has the limitation of only one instance
of OpenGL enabled xserver can start.

With gbm buffer, we can use /dev/dri/renderDx which has no
limitation on the number of OpenGL enabled xserver and even
won't conflict with a "real" xserver using radeon/amdgpu DDX.

Due to using renderDx, only DRI3 OpenGL is supported.

DGA is disabled when glamor is enabled, we can enable it with
new gbm_bo_map/unmap API, but consider a more effiction way
is just using DRI3BufferFromPixmap for the root window pixmap.

Signed-off-by: Qiang Yu 
---
 configure.ac   |  26 ++
 src/Makefile.am|   7 ++-
 src/dummy.h|   9 
 src/dummy_dga.c|   3 ++
 src/dummy_driver.c | 143 -
 5 files changed, 176 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4eb7fae..7239b63 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,6 +68,32 @@ AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
 # Obtain compiler/linker options for the driver dependencies
 PKG_CHECK_MODULES(XORG, [xorg-server >= 1.4.99.901] xproto fontsproto 
$REQUIRED_MODULES)
 
+# Check glamor support
+AC_ARG_ENABLE(glamor,
+ AS_HELP_STRING([--disable-glamor],
+[Disable glamor, a new GL-based acceleration 
[default=enabled]]),
+ [GLAMOR="$enableval"],
+ [GLAMOR=yes])
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
+if test "x$GLAMOR" != "xno"; then
+   AC_CHECK_HEADERS([glamor.h], , [GLAMOR=no], [#include "xorg-server.h"])
+fi
+CPPFLAGS="$SAVE_CPPFLAGS"
+
+if test "x$GLAMOR" != "xno"; then
+   PKG_CHECK_MODULES(GBM, [gbm], , [GLAMOR=no])
+fi
+
+AC_MSG_CHECKING([whether to include GLAMOR support])
+AC_MSG_RESULT([$GLAMOR])
+
+if test "x$GLAMOR" != "xno"; then
+AC_DEFINE(USE_GLAMOR, 1, [Enable glamor acceleration])
+fi
+AM_CONDITIONAL(GLAMOR, test x$GLAMOR != xno)
+
 # Checks for libraries.
 
 
diff --git a/src/Makefile.am b/src/Makefile.am
index da1dd9a..9faa9c4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,7 +25,7 @@
 # _ladir passes a dummy rpath to libtool so the thing will actually link
 # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
 
-AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS)
+AM_CFLAGS = $(XORG_CFLAGS)
 
 dummy_drv_la_LTLIBRARIES = dummy_drv.la
 dummy_drv_la_LDFLAGS = -module -avoid-version
@@ -38,6 +38,11 @@ dummy_drv_la_SOURCES = \
  dummy_driver.c \
  dummy.h
 
+if GLAMOR
+AM_CFLAGS += $(GBM_CFLAGS)
+dummy_drv_la_LIBADD += $(GBM_LIBS)
+endif
+
 if DGA
 dummy_drv_la_SOURCES +=\
  dummy_dga.c
diff --git a/src/dummy.h b/src/dummy.h
index c3fdd6e..1eecdec 100644
--- a/src/dummy.h
+++ b/src/dummy.h
@@ -42,6 +42,9 @@ typedef struct _color
 int blue;
 } dummy_colors;
 
+struct gbm_device;
+struct gbm_bo;
+
 typedef struct dummyRec 
 {
 DGAModePtr DGAModes;
@@ -72,6 +75,12 @@ typedef struct dummyRec
 pointer* FBBase;
 Bool(*CreateWindow)() ; /* wrapped CreateWindow */
 Bool prop;
+
+/* DRI support */
+int fd;
+CreateScreenResourcesProcPtr createScreenResources;
+struct gbm_device *gbm;
+struct gbm_bo *front_bo;
 } DUMMYRec, *DUMMYPtr;
 
 /* The privates of the DUMMY driver */
diff --git a/src/dummy_dga.c b/src/dummy_dga.c
index d16d09f..8335874 100644
--- a/src/dummy_dga.c
+++ b/src/dummy_dga.c
@@ -165,6 +165,9 @@ DUMMY_OpenFramebuffer(
 ){
 DUMMYPtr pDUMMY = DUMMYPTR(pScrn);
 
+if (pDUMMY->FBBase == NULL)
+   return FALSE;
+
 *name = NULL;  /* no special device */
 *mem = (unsigned char*)pDUMMY->FBBase;
 *size = pScrn->videoRam * 1024;
diff --git a/src/dummy_driver.c b/src/dummy_driver.c
index 2656602..174695c 100644
--- a/src/dummy_driver.c
+++ b/src/dummy_driver.c
@@ -49,6 +49,15 @@
 #include 
 #endif
 
+#ifdef USE_GLAMOR
+#define GLAMOR_FOR_XORG
+#include 
+#include 
+#endif
+
+#include 
+#include 
+
 /* Mandatory functions */
 static const OptionInfoRec *   DUMMYAvailableOptions(int chipid, int busid);
 static void DUMMYIdentify(int flags);
@@ -115,11 +124,13 @@ static SymTabRec DUMMYChipsets[] = {
 };
 
 typedef enum {
-OPTION_SW_CURSOR
+OPTION_SW_CURSOR,
+OPTION_RENDER,
 } DUMMYOpts;
 
 static const OptionInfoRec DUMMYOptions[] = {
 { OPTION_SW_CURSOR,"SWcursor", OPTV_BOOLEAN,   {0}, FALSE },
+{ OPTION_RENDER,   "Render",   OPTV_STRING,{0}, FALSE },
 { -1,  NULL,   OPTV_NONE,  {0}, FALSE }
 };
 
@@ -189,15 +200,21 @@ DUMMYGetRec(ScrnInfoPtr pScrn)
 
 if