[PATCH 4/4] modesetting: Add support for rendering using glamor.

Thomas Hellstrom thellstrom at vmware.com
Mon Nov 17 13:24:40 PST 2014


Ping?

If there's no intention to fix this before 1.17, this commit should
probably be reverted.

Thanks,
Thomas


On 11/12/2014 09:38 AM, Thomas Hellstrom wrote:
> Hi!
>
> On 10/08/2014 10:58 AM, Eric Anholt wrote:
>> By default modesetting now tries to enable X acceleration using
>> glamor, but falls back to normal shadowfb if GL fails to initialize.
>>
>> Signed-off-by: Eric Anholt <eric at anholt.net>
>> ---
>>  hw/xfree86/drivers/modesetting/Makefile.am     |   1 +
>>  hw/xfree86/drivers/modesetting/driver.c        | 101 ++++++++++++++++++++++---
>>  hw/xfree86/drivers/modesetting/driver.h        |   1 +
>>  hw/xfree86/drivers/modesetting/modesetting.man |   3 +
>>  4 files changed, 95 insertions(+), 11 deletions(-)
>>
>> diff --git a/hw/xfree86/drivers/modesetting/Makefile.am b/hw/xfree86/drivers/modesetting/Makefile.am
>> index ca3279e..e6834e2 100644
>> --- a/hw/xfree86/drivers/modesetting/Makefile.am
>> +++ b/hw/xfree86/drivers/modesetting/Makefile.am
>> @@ -28,6 +28,7 @@ AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) $(LIBDRM_CFLAGS) $(UDEV_CFLAGS) $(CWARN
>>  
>>  AM_CPPFLAGS = \
>>  	$(XORG_INCS) \
>> +	-I$(top_srcdir)/glamor \
>>  	-I$(srcdir)/../../ddc \
>>  	-I$(srcdir)/../../i2c \
>>  	-I$(srcdir)/../../modes \
>> diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
>> index c713746..c62147a 100644
>> --- a/hw/xfree86/drivers/modesetting/driver.c
>> +++ b/hw/xfree86/drivers/modesetting/driver.c
>> @@ -61,6 +61,11 @@
>>  
>>  #include "driver.h"
>>  
>> +#ifdef GLAMOR
>> +#define GLAMOR_FOR_XORG 1
>> +#include "glamor.h"
>> +#endif
>> +
>>  static void AdjustFrame(ScrnInfoPtr pScrn, int x, int y);
>>  static Bool CloseScreen(ScreenPtr pScreen);
>>  static Bool EnterVT(ScrnInfoPtr pScrn);
>> @@ -122,12 +127,14 @@ typedef enum {
>>      OPTION_SW_CURSOR,
>>      OPTION_DEVICE_PATH,
>>      OPTION_SHADOW_FB,
>> +    OPTION_ACCEL_METHOD,
>>  } modesettingOpts;
>>  
>>  static const OptionInfoRec Options[] = {
>>      {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE},
>>      {OPTION_DEVICE_PATH, "kmsdev", OPTV_STRING, {0}, FALSE},
>>      {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE},
>> +    {OPTION_ACCEL_METHOD, "AccelMethod", OPTV_STRING, {0}, FALSE},
>>      {-1, NULL, OPTV_NONE, {0}, FALSE}
>>  };
>>  
>> @@ -577,6 +584,43 @@ FreeRec(ScrnInfoPtr pScrn)
>>  
>>  }
>>  
>> +static void
>> +try_enable_glamor(ScrnInfoPtr pScrn)
>> +{
>> +    modesettingPtr ms = modesettingPTR(pScrn);
>> +    const char *accel_method_str = xf86GetOptValString(ms->Options,
>> +                                                       OPTION_ACCEL_METHOD);
>> +    Bool do_glamor = (!accel_method_str ||
>> +                      strcmp(accel_method_str, "glamor") == 0);
>> +
>> +    ms->glamor = FALSE;
>> +
>> +#ifdef GLAMOR
>> +    if (!do_glamor) {
>> +        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "glamor disabled\n");
>> +        return;
>> +    }
>> +
>> +    if (xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME)) {
>> +        if (glamor_egl_init(pScrn, ms->fd)) {
>> +            xf86DrvMsg(pScrn->scrnIndex, X_INFO, "glamor initialized\n");
>> +            ms->glamor = TRUE;
>> +        } else {
>> +            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
>> +                       "glamor initialization failed\n");
>> +        }
>> +    } else {
>> +        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
>> +                   "Failed to load glamor module.\n");
>> +    }
>> +#else
>> +    if (do_glamor) {
>> +        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
>> +                   "No glamor support in the X Server\n");
>> +    }
>> +#endif
>> +}
>> +
>>  #ifndef DRM_CAP_CURSOR_WIDTH
>>  #define DRM_CAP_CURSOR_WIDTH 0x8
>>  #endif
>> @@ -594,7 +638,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
>>      EntPtr msEnt = NULL;
>>      char *BusID = NULL;
>>      const char *devicename;
>> -    Bool prefer_shadow = TRUE;
>>      uint64_t value = 0;
>>      int ret;
>>      int bppflags;
>> @@ -732,11 +775,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
>>          ms->drmmode.sw_cursor = TRUE;
>>      }
>>  
>> -    ret = drmGetCap(ms->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
>> -    if (!ret) {
>> -        prefer_shadow = ! !value;
>> -    }
>> -
>>      ms->cursor_width = 64;
>>      ms->cursor_height = 64;
>>      ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_WIDTH, &value);
>> @@ -748,12 +786,26 @@ PreInit(ScrnInfoPtr pScrn, int flags)
>>          ms->cursor_height = value;
>>      }
>>  
>> -    ms->drmmode.shadow_enable =
>> -        xf86ReturnOptValBool(ms->Options, OPTION_SHADOW_FB, prefer_shadow);
>> +    try_enable_glamor(pScrn);
>> +
>> +    if (!ms->glamor) {
>> +        Bool prefer_shadow = TRUE;
>> +
>> +        ret = drmGetCap(ms->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
>> +        if (!ret) {
>> +            prefer_shadow = !!value;
>> +        }
>> +
>> +        ms->drmmode.shadow_enable = xf86ReturnOptValBool(ms->Options,
>> +                                                         OPTION_SHADOW_FB,
>> +                                                         prefer_shadow);
>> +
>> +        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
>> +                   "ShadowFB: preferred %s, enabled %s\n",
>> +                   prefer_shadow ? "YES" : "NO",
>> +                   ms->drmmode.shadow_enable ? "YES" : "NO");
>> +    }
>>  
>> -    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ShadowFB: preferred %s, enabled %s\n",
>> -               prefer_shadow ? "YES" : "NO",
>> -               ms->drmmode.shadow_enable ? "YES" : "NO");
>>      if (drmmode_pre_init(pScrn, &ms->drmmode, pScrn->bitsPerPixel / 8) == FALSE) {
>>          xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n");
>>          goto fail;
>> @@ -832,6 +884,20 @@ CreateScreenResources(ScreenPtr pScreen)
>>      if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
>>          return FALSE;
>>  
>> +#ifdef GLAMOR
>> +    if (ms->glamor) {
>> +        if (!glamor_egl_create_textured_screen_ext(pScreen,
>> +                                                   ms->drmmode.front_bo->handle,
> Here ms->drmmode.front_bo->handle is a handle to a dumb buffer, and thus
> it's illegal to import it into EGL for rendering.
>
> Since this has already been merged, I've created a bug on the issue
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid-3D86191&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=vpukPkBtpoNQp2IUKuFviOmPNYWVKmen3Jeeu55zmEA&m=2KuapJ3DY2efBBO_NM9t93g19LkpN_gUADs_sDLnqis&s=clxRD-JqtTgBaPqWU-gzOtaKiSeuboa_Xg3kC9RQPnU&e= 
>
> Thanks,
> Thomas
>
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.x.org_archives_xorg-2Ddevel&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=vpukPkBtpoNQp2IUKuFviOmPNYWVKmen3Jeeu55zmEA&m=2KuapJ3DY2efBBO_NM9t93g19LkpN_gUADs_sDLnqis&s=XWrxVcw2nHntPBm5sYTEMyD2n0AuJH63vnQ0XQ2V-pI&e= 
> Info: https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.x.org_mailman_listinfo_xorg-2Ddevel&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=vpukPkBtpoNQp2IUKuFviOmPNYWVKmen3Jeeu55zmEA&m=2KuapJ3DY2efBBO_NM9t93g19LkpN_gUADs_sDLnqis&s=HgrfX9JV9Zg6ocwG_pnbIJlyfl4tpkZ_66YFM0NwUEc&e= 



More information about the xorg-devel mailing list