[Pull Request] Glamor: A 2D rendering acceleration implementation based on OpenGL

zhigang gong zhigang.gong at gmail.com
Tue Sep 27 06:50:06 PDT 2011


Hi Keith,

Here is the pull request to merge glamor. Basically, it has three parts.
The first part is the 2D rendering acceleration implementation in
glamor directory. It supports both OpenGL/GLESv2. The second part is
in hw/kdrive/xephyr. This part integrate glamor into Xephyr. And by
specify a "-glamor" when invoke the Xephyr then you can use glamor
to accelerate the rendering operations. The third part is in
hw/xfree86/glamor. This part implements a standalone ddx driver based
on glamor, egl and kms. With this glamor driver, you can start up
a Xserver over Mesa/EGL directly, without any native window system.

Here are some instructions for how to build and use glamor:

1. Xephyr over glamor.

Firstly configure Xephyr as below:
#./autogen.sh --prefix=/opt/xserver-glamor --disable-glx
--enable-kdrive --enable-xephyr --enable-glamor
Then build and install the Xephyr. Then start a xserver which has glx support.
Then invoke the Xephyr within the X env:
#Xephyr -glamor

2. Standalone glamor ddx over EGL + KMS.
Firstly we need to build mesa, the prefer version is git master. Build
MESA as below (disable gallium, enable egl drm platform and must enable gbm.)
#./autogen.sh --prefix=/opt/xserver-glamor --with-egl-platforms=drm
--with-gallium-drivers= --enable-shared-glapi --enable-gles2
Then build and install the mesa library.

Secondly configure Xorg as below:
#./autogen.sh --prefix=/opt/xserver-glamor --disable-glx
--enable-glamor --enable-glamor-ddx
Then build and install this Xorg. And invoke it as below:
#startx -- /opt/xserver-glamor/bin/Xorg
You can check the /opt/xserver-glamor/var/log/Xorg.0.log to find the
following words:
Standalone glamor: OpenGL accelerated X.org driver
which indicates the glamor ddx driver is running.

Restrictions:
1. Not fully support glx.
Glamor ang glx both need to create and maintain gl contexts. I haven't
find a way to make them co-exist concurrently peacefully. One workaround
is to rename those function names in glx/glapi.c and that will break
the indirect glx rendering. But the direct rendering works fine with this
workaround. This pull request doesn't has that workaround, so to
enabling glamor, you must disable glx when build the xserver.

2. Not fully support DRI2.
Gbm and mesa drm image extension don't support allocate dri2 buffers,
especially for those Y-tiled buffers. So we can't support dri2 by
using standalone glamor ddx driver. One workaround is to integrate
glamor to current 2D driver, let the 2D rendering go to glamor and
the other functions still use the original 2D drivers. We can borrow
original 2D driver's buffer management to allocate dri2 buffers,
and then bind those buffers to EGL KHR images, and then we can easily
use glamor to rendering on those buffers directly. Discussed with
Kristian on this restriction, and the conclusion is that we may
hack the MESA buffer allocation to export those dri2 buffer allocation
APIs to glamor. I will publish my modified xf86-video-driver-glamor
latter on my personal repository which utilize glamor and support
DRI2 and direct glx rendering.

3. Only support Intel platform currently.
As glamor depends on KMS + MESA/EGL + GBM, currently only
intel gfx device get supported.

At last Just as Eric said, glamor's development has gone on for a long time
without cleaning up and getting code merged, we have to submit this very
long patch list here . I know this is inconvenient for the community to review,
but I really have little choice. Anyway, please help to check it. Any comments
are welcome.

Thanks.

The following changes since commit 7fb4bef0394a5d09680985d34bce8252b61493cb:

  Merge remote-tracking branch 'mattst88/for-keith' (2011-09-21 14:34:27 -0700)

are available in the git repository at:

  git://people.freedesktop.org/~gongzg/xserver-glamor glamor

Eric Anholt (100):
      Add build infrastructure for glamor.
      More ephyr/glamor glue.
      Add exa/glamor to _DEPENDENCIES so the bin gets rebuilt with the libs.
      glamor: Use -lgl for Xephyr if GLX is unset.
      glamor: Start trying to hook up the rendering bits
      glamor: Use a nicer struct initializer for gcops.
      glamor: glFlush from the blockhandler so rendering happens.
      glamor: first real attempt at rendering.
      ephyr: merge the host glamor bits into hostx.
      add fill files, merge with first real attempt at rendering.
      ephyr: Make sure a glamor-using window is created with a glx visual.
      ephyr: Use GLEW.
      glamor: Fix up block/wakeup handler.
      glamor: remove gratuitous flush.
      glamor: Fix up DrawPixels arguments to bear some relation to reality.
      glamor: Move to using shader objects.
      glamor: Add getspans implementation.
      glamor: Maybe fix up the format/type for setspans.
      glamor: Create FBOs for pixmaps.
      glamor: Fill out glamor_get_color_4f_from_pixel() a bit.
      glamor: Add untested support for tile filling.
      glamor: Free resources when destroying pixmaps.
      glamor: Add stub Composite support.
      glamor: Fill in 1 and 24-bit getspans.
      glamor: Add more solid_fail_regions for software fallbacks.
      glamor: Add trapezoids code.
      glamor: Add 8bpp to get/setspans.
      glamor: Add untested putimage support.
      glamor: Add ALU support to solid, tile, and putimage.
      glamor: Hook up miGetImage to fix some invalid accesses.
      glamor: Move setspans to a separate file.
      glamor: Fix memory leak in getspans.
      glamor: Fix bad fallthrough in getspans (accessing invalid memory).
      glamor: Give setspans the same format support as getspans.
      glamor: add alu support to setspans.
      glamor: Move planemask to a function in case I decide to fill it in.
      glamor: Fix some screen_xy offsets to be the right way around.
      glamor: Add clipping to setspans.
      glamor: Start adding render acceleration support.
      glamor: make the polylines complaint a little more useful.
      glamor: Add untested PutImage XYBitmap support.
      glamor: Add untested PutImage 1bpp XYPixmap support.
      glamor: Accelerate PolyFillRect using glamor_fill instead of spans.
      glamor: Add untested copyarea implementation
      glamor: Add support for solid source pictures.
      glamor: Fix pixmap private getter in copyarea.
      glamor: Add prepare/finishaccess code based on UXA.
      glamor: Fix the type for copyarea.
      glamor: Move glamor_poly_lines to a separate file.
      glamor: Add fallbacks for glamor_copy_area().
      glamor: Add fallbacks for Render.
      glamor: Use GL_MESA_pack_invert to avoid complexity in prepare_access.
      glamor: Add glamor_prepare_access_gc() from UXA.
      glamor: Add fallback support to glamor_set_spans().
      glamor: Add fallback support to glamor_put_image().
      glamor: Fix up the access flags for glamor_prepare_access().
      glamor: Fix the row length of 1bpp prepare_access.
      ephyr: Hook the glamor into damage and draw into the backbuffer.
      glamor: Add fallback support for glamor_get_spans().
      glamor: Add check for EXT_bgra which we rely on.
      glamor: All the fallbacks in the world.
      glamor: Replace the glDrawPixels in glamor_finish_access with GLSL.
      glamor: Use the pixmap stride in fallbacks instead of trying to guess it.
      glamor: Fix prepare_access on 1bpp data.
      glamor: Enable fill acceleration and flip opposite for pixmaps too.
      glamor: Add CopyWindow implementation so it doesn't crash.
      glamor: Add acceleration for copyarea not from the screen.
      glamor: Pull in UXA code for dumping some composites down to copy_n_to_n.
      glamor: Provide more information about the operands to fallback
composites.
      glamor: Split the copy path out into its own function.
      glamor: Align stride of fallback pixmap data to 32 bits.
      glamor: Set active texture in finishaccess drawing.
      glamor: Restore planemask to all-on when finishing a fill.
      glamor: Fix up and enable accelerated composite.
      glamor: Add the glyph cache from UXA (de-camelCased).
      glamor: Rework the Render shader setup to be easily modified,
like cairo-gl.
      glamor: Don't try to CopyArea from a Solid source picture.
      glamor: Set active texture on glamor_copy_n_to_n setup.
      glamor: Add support for accel of x8r8g8b8 source pictures.
      glamor: Implement glCopyPixels based src == dest CopyArea acceleration
      glamor: Fix screen_x/screen_y handling for compositing.
      glamor: Fix off-by-one in CopyPixels CopyArea path.
      glamor: Fix and enable tile fill acceleration (aka the root weave).
      glamor: Fix up the wide/non-solid lines fallback.
      glamor: Enable glamor_fill_spans().
      glamor: Fix and enable glamor_get_spans().
      glamor: Fix render source transforms.
      glamor: Fix and enable ZPixmap PutImage acceleration.
      glamor: Add support for a1 composite sources.
      glamor: Fix up the fallback message for no texture present on compositing.
      glamor: Add a little mechanism for only printing fallbacks when
they happen.
      glamor: Rework shader setup to make extending the IN types easier.
      glamor: Add support for component alpha rendering.
      glamor: Convert the shaders path to handling glamor_composite_rect_t.
      glamor: Use glamor_composite_with_shader once per group of glyphs.
      glamor: Use a VBO to accumulate multiple glyph quads at once.
      glamor: Replace the immediate mode in glamor_fill() with glDrawArrays().
      glamor: Fix the segfault at screen fini.
      glamor: Reduce the noise from wide lines "fallback".
      glamor: Add support for using EXT_framebuffer_blit to do CopyArea.

Kristian Høgsberg (1):
      glamor ddx driver using EGL on KMS

Zhenyu Wang (3):
      glamor: Use function pointer to get extenstion calls
      glamor: Require libdrm CFLAGS for building
      glamor: Fix direct call for glEGLImageTargetTexture2DOES

Zhigang Gong (125):
      glamor: Fixed some compiling and linking errors.
      glamor: Fixed one conflict data type(XID) bug.
      glamor: Call glamor_composite_rects only when enable RENDER.
      glamor: Merged with latest xserver.
      glamor: Fixed one linking error.
      glamor: Fixed one segfault bug when close screen.
      glamor:  Resolved merge conflictions with Kristian's glamor-ddx patch.
      glamor: Add glamor-ddx driver to the build tree.
      glamor: Add new feature which is to flip output on y axis.
      glamor-ddx: Migrate the code to latest mesa library.
      glamor-ddx: Fix a compiling error. Need revisit.
      glamor-ddx: Move the cursor EGL image to crtc strcture.
      glamor: Silent compilation warnings due to some deprecated APIs.
      glamor-ddx: Fixed one bug when a client reset the connection.
      glamor: Switch to software fb for too large pixmap.
      glamor: glamor_set_alu should enable GL_COLOR_LOGIC_OP.
      glamor: Add fallback code path for glamor_fill.
      glamor-ddx: Remove debug message when moving cursor.
      glamor: Use buffer object as much as possible.
      glamor: Don't write back read only pixmap to fbo.
      glamor: improve glamor_finish_access.
      glamor: Don't use glamor_pixmap_type currently.
      glamor: Optimize glamor_finish_access.
      glamor: Don't print those fallback messages by default.
      glamor: Optimize composite when soure/mask is xrgb.
      glamor: Use software fb for 1bpp pixmap.
      glamor: Add render triangles support.
      glamor: Silence compilation warnings.
      glamor: For non-supported fill style fallback to fbFill.
      glamor: Fallback to fbPolylines for diagonal poly_line.
      glamor: Simplify fill acceleration for spans/polyfillrect by
only clipping once.
      glamor : Add dynamic texture uploading feature.
      glamor: Concentrate and reduce some coords processing code.
      glamor: Don't always fallback everything when change window attr.
      glamor: Initialize pixmap private's container to correct value.
      glamor: Fixed one bug when enable dynamic pixmap uploading.
      glamor: Move the blend set up after the pixmap uploading.
      glamor: Don't need to read dest if op is SRC or CLEAR.
      glamor: Prepare/finish access once if src equal to dst.
      glamor: Change to use system memory for write only access.
      glamor: Reduce one extra copy in glamor_trapezoids.
      glamor: Don't map the vbo to system memory.
      glamor: Add one option to force create a cpu memory pixmap.
      glamor: Reduce source pixmap's size.
      glamor: Fix the coords calculation in glamor_fill.
      glamor: Convert picture to proper size and format.
      glamor: Remove one extra area copy in glamor_glyph.
      glamor: Fix one typo bug in glamor_tile.
      glamor: silence compilation warnings.
      glamor: convert if too large source or mask .
      glamor-ddx: Reinit crtc if we need to reopen the card.
      glamor-ddx: Add missed drmmode_crtc_destroy function.
      Revert "glamor: Don't need to read dest if op is SRC or CLEAR."
      glamor: Optimize fallback case for the polylines.
      glamor: Fix multiple crtc setup.
      glamor: Fixed two unintialized warnings.
      glamor: We don't need to check format in compositing.
      glamor: Don't need to pad the tile image if pixmap is ni texture.
      glamor: comment out the message when creating a system memory pixmap.
      glamor: Should return when done gl drawing.
      glamor: Fixed a bug when computing the bounds of boxes.
      glamor: Implement delayed solid filling.
      glamor: Avoid 2D bitblit if possible.
      glamor: Use small internal texture format if possible.
      glamor: Fix one bug for Xephyr.
      glamor: Change to use official APIs rather than ARB version function.
      glamor-es2: Add gles2 option.
      glamor-ddx: Use glamor ddx driver only if enable GLAMOR_DDX.
      glamor: Add glamor related macros to xorg config header file.
      glamor-es2: Fix some non-es2 functions.
      glamor-es: Use glVertexAttribPointer to replace glVertexPointer.
      glamor_gles2: Use gl_flavor to determine which version of GL.
      glamor: Check GLAMOR_GLES2 in configure process.
      glamor-ddx: Define macro GLAMOR_DDX in command line.
      glamor-gles2: Add initial support for GLES2.
      glamor: Define macro GLAMOR_GLES2 if enable glamor_gles2
      glamor: Concentrate FBO's creation to one function.
      glamor-ddx: Silence one warning.
      glamor: Disable ALPHA8 fbo.
      glamor:  Unify the variable name which used to indicate no alpha.
      glamor: Only fallbac glamor_setspan when we are using gles2.
      glamor: Remove useless glVertexPointer related code.
      glamor: Remove glu3 which is unnecessary.
      glamor-ddx: Hardware cursor's format should be GL_RGBA.
      glamor:  GLES2 doesn't support GL_CLAMP_TO_BORDER.
      glamor: GLES2 doesn't support glEnable/Disable Texture 2D.
      glamor: Add color conversion support by using new shader.
      glamor: Convert pixmap to supported format before getspans.
      glamor: Fix the copy of overlaped region in one pixmap.
      glamor: Add device independent glamor to the installation package.
      glamor-ddx: Add code to check required egl extensions.
      glamor:  egl version 7.11 should be ok for us.
      glamor: Don't need to check status when set the target.
      glamor-dix: Make a glamor dix module.
      glamor: Change to use the original drawable in glamor_fill.
      glamor: Fallback to software fb when repeat is needed.
      glamor-gles2: Add explicit precision qualifiers for gles2.
      glamor-egl: Move EGL surfaceless related code to dix module.
      glamor: Remove the version check for EGL/gles.
      glamor-egl: Fix direct call for glEGLImageTargetTexture2DOES.
      glamor: Change glamor_egl_init API.
      glamor: Move glamor_glyphs_init to create screen resources stage.
      glamor: Improve glyphs cache mechanism.
      glamor: Route UnrealizeGlyph to glamor_glyph_unrealize.
      glamor: Let GLAMOR_DDX implicit GLAMOR.
      glamor: Don't direct call to any gl functions.
      glamor: Re-arrange some macros/definitions in header files.
      glamor-egl: Added new function to create image for a pixmap.
      glamor-ddx: Change naming of glamor ddx module.
      glamor-ddx: Use gbm to allocate front buffer and cursor image.
      glamor-ddx: Fix the broken switching between VTs.
      glamor-egl: Add gbm device support.
      glamor-ddx: Reuse glamor_dix module to handle egl platform.
      glamor-ddx: Don't need to call preInit in screen_init.
      glamor-ddx: Destroy all the pixmap cursors when close current screen.
      glamor: Correct the version check for GLES2.
      ephyr-glamor: Set texture 0 to screen pixmap.
      ephyr-glamor:  Implment gl disptach function for host glx.
      glamor: Refine the screen pixmap initialization for Xephyr.
      glamor-ddx: Don't double free the cursor memory.
      glamor: Check libgbm if enable glamor ddx.
      glamor-ddx: Rename glamor.c to glamor_ddx.c.
      glamor: Don't call to glamor functions if it's dumb.
      glamor: Abort if fail to initialize glamor for xephyr.
      xephyr-glamor: Abort if use glamor over GLES2.

 Makefile.am                        |    6 +
 configure.ac                       |   45 +-
 glamor/Makefile.am                 |   47 ++
 glamor/glamor.c                    |  401 +++++++++
 glamor/glamor.h                    |   63 ++
 glamor/glamor_copyarea.c           |  401 +++++++++
 glamor/glamor_copywindow.c         |   60 ++
 glamor/glamor_core.c               |  495 ++++++++++++
 glamor/glamor_debug.h              |   82 ++
 glamor/glamor_egl.c                |  384 +++++++++
 glamor/glamor_fill.c               |  205 +++++
 glamor/glamor_fillspans.c          |   89 ++
 glamor/glamor_getspans.c           |  110 +++
 glamor/glamor_gl_dispatch.c        |   73 ++
 glamor/glamor_gl_dispatch.h        |  101 +++
 glamor/glamor_glext.h              |   32 +
 glamor/glamor_glyphs.c             |  860 ++++++++++++++++++++
 glamor/glamor_picture.c            |   93 +++
 glamor/glamor_pixmap.c             |  752 +++++++++++++++++
 glamor/glamor_polyfillrect.c       |  110 +++
 glamor/glamor_polylines.c          |  179 ++++
 glamor/glamor_priv.h               |  569 +++++++++++++
 glamor/glamor_putimage.c           |  417 ++++++++++
 glamor/glamor_render.c             | 1446 +++++++++++++++++++++++++++++++++
 glamor/glamor_setspans.c           |  110 +++
 glamor/glamor_tile.c               |  194 +++++
 glamor/glamor_triangles.c          |   61 ++
 glamor/glamor_utils.h              |  542 +++++++++++++
 glamor/glamor_window.c             |   74 ++
 hw/kdrive/ephyr/Makefile.am        |   16 +-
 hw/kdrive/ephyr/ephyr.c            |   18 +-
 hw/kdrive/ephyr/ephyr.h            |    7 +
 hw/kdrive/ephyr/ephyr_glamor.c     |   70 ++
 hw/kdrive/ephyr/ephyrinit.c        |   16 +
 hw/kdrive/ephyr/hostx.c            |  103 +++-
 hw/kdrive/ephyr/hostx.h            |    3 +
 hw/xfree86/Makefile.am             |    8 +-
 hw/xfree86/common/Makefile.am      |    8 +-
 hw/xfree86/common/xf86pciBus.c     |    6 +-
 hw/xfree86/dixmods/Makefile.am     |   15 +-
 hw/xfree86/dixmods/glamor_module.c |   47 ++
 hw/xfree86/glamor/Makefile.am      |   28 +
 hw/xfree86/glamor/glamor_crtc.c    | 1565 ++++++++++++++++++++++++++++++++++++
 hw/xfree86/glamor/glamor_ddx.c     |  531 ++++++++++++
 hw/xfree86/glamor/glamor_ddx.h     |   42 +
 include/kdrive-config.h.in         |    5 +
 include/xorg-config.h.in           |    9 +
 47 files changed, 10484 insertions(+), 14 deletions(-)



More information about the xorg mailing list