1. 18 Dec, 2013 9 commits
    • Chris Wilson's avatar
      Fixup glx support · 556adfa6
      Chris Wilson authored
      Renaming glamor_priv->dispatch and wrapping the access to
      the dispatch table with a function that also ensured the
      context was bound.
       dispatch = glamor_get_dispatch(glamor_priv);
      So that we catch all places where we attempt to call into GL withouta
      context. As an optimisation we can then do glamor_get_context();
      glamor_put_context() around the rendering entry points to reduce the
      frequency of having to restore the old context. (Along with allowing
      the context to be recursively acquired and making the old context part of
      the glamor_egl state.)
      Reviewed-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      GLX: Enable glx support. · 430bc16c
      Zhigang Gong authored
      If we are using MESA as our GL library, then both xserver's
      GLX and glamor are link to the same library. As xserver's
      GLX has its own _glapi_get/set_context/dispatch etc, and it
      is a simplified version derived from mesa thus is not
      sufficient for mesa/egl's dri loader which is used by glamor.
      Then if glx module is loaded before glamoregl module, the
      initialization of mesa/egl/opengl will not be correct, and
      will fail at a very early stage, most likely fail to map
      the element buffer.
      Two methodis to fix this problem, first is to modify the xserver's
      glx's glapi.c to fit mesa's requirement. The second is to put
      a glamor.conf as below, to the system's xorg.conf path.
      Section "Module"
              Load  "glamoregl"
      Then glamor will be loaded firstly, and the mesa's libglapi.so
      will be used. As current xserver's dispatch table is the same
      as mesa's, then the glx's dri loader can work without problem.
      We took the second method as it don't need any change to xorg.:)
      Although this is not a graceful implementation as it depends
      on the xserver's dispatch table and the mesa's dispatch table
      is the same and the context set and get is using the same method.
      Anyway it works.
      As by default, xserver will enable GLX_USE_TLS. But mesa will not
      enable it, you may need to enable that when build mesa.
      Three pre-requirements to make this glamor version work:
      0. Make sure xserver has commit 66e603, if not please pull the latest
         master branch.
      1. Rebuild mesa by enable GLX_USE_TLS.
      2. Put the glamor.conf to your system's xorg.conf path and make sure
         it loaded prior to glx module.
      Preliminary testing shows indirect glxgears works fine.
      If user want to use GLES2 for glamor by using MESA, GLX will not
      work correctly.
      If you are not using normal MESA, for example PVR's private GLES
      implementation, then it should be ok to use GLES2 glamor and the
      GLX should work as expected. In this commit, I use gbm to check
      whether we are using MESA or non-mesa. Maybe not the best way.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      Refine CloseScreen and FreeScreen processes. · bf7d79dc
      Zhigang Gong authored
      This commit move the calling to glamor_close_screen from
      glamor_egl_free_screen to glamor_egl_close_screen, as this
      is the right place to do this.
      We should detach screen fbo and destroy the corresponding
      KHR image at glamor_egl_close_screen stage. As latter
      DDX driver will call DestroyPixmap to destroy screen pixmap,
      if the fbo and image are still there but glamor screen private
      data pointer has been freed, then it causes segfault.
      This commit also introduces a new flag GLAMOR_USE_EGL_SCREEN.
      if DDX driver is using EGL layer then should set this bit
      when call to glamor_init and then both glamor_close_screen
      and glamor_egl_close_screen will be registered correctly,
      DDX layer will not need to call these two functions manually.
      This way is also the preferred method within Xorg domain.
      As interfaces changed, bump the version to 0.3.0.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      Tested-by: default avatarPeng Li <peng.li@intel.com>
    • Zhigang Gong's avatar
      glamor-fbo: Tweek the cache bucket calculation. · 36ac9b71
      Zhigang Gong authored
      And also reduce the expire count to 100 which should be
      good enough on x11perf and cairo-trace testing.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor_create_fbo: Concentrate the fbo size/depth checking. · a1de528c
      Zhigang Gong authored
      Concentrate checking the size/depth when creating fbo. Simply
      the pixmap creation and the uploading fbo/texture preparing.
      Also slightly change the uploading fbo's preparation. If don't
      need fbo, then a fbo only has valid texture should be enough
      to return.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor-pixmap-upload: Create a uploading fbo with a texture only. · 1bfe5957
      Zhigang Gong authored
      Just an initial implementation and disabled by default.
      When uploading a pixmap to a texture, we don't really want
      to attach the texture to any fbo. So add one fbo type
      which doesn't has a gl FBO attached to it.
      This commit can increase the cairo-trace's performance by
      10-20%. Now the firefox-planet-gnome is 8.3s. SNA is still
      the best, only take 3.5s.
      Thanks for Chris to point out the A1 pixmap uploading bug.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor-fbo-pool: Enable to reuse different size fbo/texture. · 9c6fd931
      Zhigang Gong authored
      Fixup three special cases, one is in tile and the other is in
      composite. Both cases are due to repeat texture issue. Maybe
      we can refine the shader to recalculate texture coords to
      support partial texture's repeating.
      The third is when upload a memory pixmap to texture, as now
      the texture may not have the exact size as the pixmap, we
      should not use the full rect coords.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor-fbo-pool: Implement fbo cache mechanism. · c7e79d6a
      Zhigang Gong authored
      We classify the cache according to the texture's format/width/height.
      As openGL doesn't allow us to change a texture's format/width/height
      after the internal texture object is already allocated, we can't
      just calculate the size and then according ths size to put the
      fbo to an bucket which is just like SNA does. We can only put
      the fbo to the corresponding format/width/height bucket.
      This commit only support the exact size match. The following patch
      will remove this restriction, just need to handle the repeat/tile
      case when the size is not exactly match.
      Should use fls instead of ffs when decide the width/height bucket,
      thanks for Chris to point this out.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor_fbo: Introduce glamor fbo to manage all the fb/tex. · 2ff41008
      Zhigang Gong authored
      This is the first patch to implement a fbo/tex pool mechanism which
      is like the sna's BO cache list. We firstly need to decopule the
      fbo/tex from each pixmap. The new glamor_pixmap_fbo data
      structure is for that purpose. It's somehow independent to each
      pixmap and can be reused latter by other pixmaps once it's detached
      from the current pixmap.
      And this commit also slightly change the way to create a
      memory pixmap. We will not create a pixmap private data structure
      by default, instead we will crete that structure when a memory
      pixmap is attaching a fbo to it.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>