1. 18 Dec, 2013 20 commits
    • Zhigang Gong's avatar
    • Zhigang Gong's avatar
      glamor_putimage: Optimize for direct uploading and fallback path. · 05da9910
      Zhigang Gong authored
      This commit optimize two cases:
      1. When the clip contains the whole area, we can directly upload
      the texel data to the pixmap, and don't need to do one extra
      clipped copy.
      2. At fallback path, we don't read back the whole pixmap, just
      need a sub region.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      code clean up. · e15bc120
      Zhigang Gong authored
      Remove unused variables.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor_put_sub_pixmap: Change to use glamor_upload_sub_pixmap. · e38eb675
      Zhigang Gong authored
      As the pixmap may be attached to a picture, we need to use
      glamor_upload_sub_pixmap to process it. glamor_copy_n_to_n
      will not consider the picture case.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor_putimage: Reuse copy area to do the clipped copy. · 70b71718
      Zhigang Gong authored
      If no clip set, we load the bits to the pixmap directly.
      Otherwise, load the bits to a temporary pixmap and call
      glamor_copy_area to do the clipped copy.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      Don't need to set GL_PACK_ROW_LENGTH/GL_UNPACK_ROW_LENGTH. · 420af44a
      Zhigang Gong authored
      We already adjust the stride of the pixmap, and keep the alignment
      as 4 should be ok to let the GL/GLES match the stride.
      Previous version has a unbalanced PACK ROW length seting, and is
      buggy, now fixed it.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor_pixmap_upload_texture: Support to upload a sub region of data. · b0e91f0f
      Zhigang Gong authored
      Just as the downloading side, we can upload an sub region data to
      a pixmap's specified region. The data could be in memory or in a
      pbo buffer.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor_set_alu: Fallback for non GXcopy ops with GLES2. · 3e9c35bd
      Zhigang Gong authored
      As GLES2 doesn't support LogiOps, we have to fallback
      here. GLES2 programing guide's statement is as below:
      "In addition, LogicOp is removed as it is very
      infrequently used by applications and the OpenGL ES
      working group did not get requests from independent
      software vendors (ISVs) to support this feature in
      OpenGL ES 2.0."
      So, I think, fallback here may not a big deal ;).
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor_putimage: Reuse the function in pixmap.c to do the uploading. · 1a238e89
      Zhigang Gong authored
      We reuse glamor_upload_bits_to_pixmap_texture to do the
      data uploading to texture in putimage. Besides to avoid
      duplicate code, this also fixed the potential problem
      when the data format need extra reversion which is not
      supported by the finish shader, as
      glamor_upload_bits_to_pixmap_texture will handle all
      Tested-by: He Junyan's avatarJunyan He <junyan.he@linux.intel.com>
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      gles2: Fixed color conversion for the formats except 1555 and 2101010. · 3add3750
      Zhigang Gong authored
      This patch fixed two major problems when we do the color convesion with
      1. lack of necessary formats in FBO pool.
      GLES2 has three different possible texture formats, GL_RGBA,
      GL_BGRA and GL_ALPHA. Previous implementation only has one bucket
      for all the three formats which may reuse a incorrect texture format
      when do the cache lookup. After this fix, we can enable fbo safely
      when running with GLES2.
      2. Refine the format matching method in
      If both revertion and swap_rb are needed, for example use GL_RGBA
      to represent PICT_b8g8r8a8. Then the downloading and uploading should
      be handled differently.
          The picture's format is PICT_b8g8r8a8,
          Then the expecting color layout is as below (little endian):
          0   1       2       3   : address
          a   r       g       b
          Now the in GLES2 the supported color format is GL_RGBA, type is
          GL_UNSIGNED_TYPE, then we need to shuffle the fragment
          color as :
              frag_color = sample(texture).argb;
          before we use glReadPixel to get it back.
          For the uploading process, the shuffle is a revert shuffle.
          We still use GL_RGBA, GL_UNSIGNED_BYTE to upload the color
          to a texture, then let's see
          0   1       2       3   : address
          a   r       g       b   : correct colors
          R   G       B       A   : GL_RGBA with GL_UNSIGNED_BYTE
          Now we need to shuffle again, the mapping rule is
          r = G, g = B, b = A, a = R. Then the uploading shuffle is as
              frag_color = sample(texture).gbar;
      After this commit, gles2 version can pass render check with all
      the formats except those 1555/2101010.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • 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
      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
      Set filter to GL_NEAREST by default. · a74596be
      Zhigang Gong authored
      This is the fastest filter and let's use it by default.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      Reduce the double check of pixmap's private pointer. · a65e1c73
      Zhigang Gong authored
      As we now add the checking to the Macro, we don't need to check
      the pointer outside the Macro.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      Fixed a bug at putImage. · 70b63415
      Zhigang Gong authored
      fbPutImage wants the input drawable is the target drawable rather
      than the backing pixmap. This bug cause some XTS failures, now
      fix it.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor-for-ddx: Exports all rendering/drawing functions. · 8c7fcefb
      Zhigang Gong authored
      This commit exports all the rest rendering/drawing functions
      to the DDX drivers. And introduce some new pixmap type. For
      a pixmap which has a separated texture, we never fallback
      it to the DDX layer.
      This commit also adds the following new functions:
      glamor_composite_rects, glamor_get_image_nf which are needed
      by UXA framework. Just a simple wrapper function of miXXX.
      Will consider to optimize them next few weeks.
      This commit also Fixed a glyphs rendering bug pointed by Chris.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      Remove the access mode from private pixmap structure. · 92fd8387
      Zhigang Gong authored
      Change the finish_access to pass in the access mode, and remove
      the access mode from the pixmap structure. This element should
      not be a pixmap's property.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      exports more rendering functions to DDX driver. · b5630663
      Zhigang Gong authored
      Exports all necessary rendering functions to DDx drivers, including
      CopyArea, Glyphs, Composite, Triangles, ....
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      Initial version. · b861aad8
      Zhigang Gong authored
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
  2. 26 Sep, 2011 20 commits
    • Zhigang Gong's avatar
      glamor: Don't direct call to any gl functions. · 0dff23d6
      Zhigang Gong authored
      Create a new structure glamor_gl_dispatch to hold all the
      gl function's pointer and initialize them at run time ,
      rather than use them directly. To do this is to avoid
      symbol conflicts.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor: Add color conversion support by using new shader. · 67da52ec
      Zhigang Gong authored
      There are two places we need to do color conversion.
      1. When upload a image data to a texture.
      2. When download a texture to a memory buffer.
      As the color format may not be supported in GLES2. We may
      need to do the following two operations to convert dat.
      a. revert argb to bgra / abgr to rgba.
      b. swap argb to abgr / bgra to rgba.
      Signed-off-by: Zhigang Gong's avatarZhigang Gong <zhigang.gong@gmail.com>
    • Zhigang Gong's avatar
      glamor: Remove useless glVertexPointer related code. · a228effb
      Zhigang Gong authored
      As glVertexPointer is not supported by GLES2, I totally
      replaced it by VertexAttribArray. This commit remove those
      old code.
      Signed-off-by: Zhigang Gong's avatarZhigang Gong <zhigang.gong@gmail.com>
    • Zhigang Gong's avatar
      glamor: Unify the variable name which used to indicate no alpha. · 667d6553
      Zhigang Gong authored
      The original code use different name and the name is vague.
      Now change it to no_alpha.
      Signed-off-by: Zhigang Gong's avatarZhigang Gong <zhigang.gong@gmail.com>
    • Zhigang Gong's avatar
      glamor-es2: Add --enable-glamor-gles2 to build system. · 7aecfa24
      Zhigang Gong authored
      Now, to build a gles2 version of glamor server, we could
      use ./autogen.sh --enable-glamor-ddx --enable-glamor-gles2
      Signed-off-by: Zhigang Gong's avatarZhigang Gong <zhigang.gong@gmail.com>
    • Zhigang Gong's avatar
      glamor-es: Use glVertexAttribPointer to replace glVertexPointer. · ee33c947
      Zhigang Gong authored
      As GLES2 doesn't support glVertexPointer.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
    • Zhigang Gong's avatar
      glamor: Implement delayed solid filling. · 5c4d53c5
      Zhigang Gong authored
      When we need to solid fill an entire pixmap with a specific color,
      we do not need to draw it immediately. We can defer it to the
      following occasions:
      1. The pixmap will be used as source, then we can just use a shader
         to instead of one copyarea.
      2. The pixmap will be used as target, then we can do the filling
         just before drawing new pixel onto it. The filling and drawing
         will have the same target texture, we can save one time of
         fbo context switching.
      Actually, for the 2nd case, we have opportunity to further optimize
      it. We can just fill the untouched region.
      By applying this patch, the cairo-trace for the firefox-planet-gnome's
      rendering time decrease to 14seconds from 16 seconds.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor: Concentrate and reduce some coords processing code. · ca1908e1
      Zhigang Gong authored
      Concentrate the verties and texture coords processing code to a new
      file glamor_utils.h. Change most of the code to macro. Will have some
      performance benefit on slow machine. And reduce most of the duplicate
      code when calculate the normalized coords.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor : Add dynamic texture uploading feature. · 355334fc
      Zhigang Gong authored
      Major refactoring.
      1. Rewrite the pixmap texture uploading and downloading functions.
         Add some new functions for both the prepare/finish access and
         the new performance feature dynamic texture uploading, which
         could download and upload the current image to/from a private
         texture/fbo. In the uploading or downloading phase, we need to
         handle two things:
         The first is the yInverted option, If it set, then we don't need
         to flip y. If not set, if it is from a dynamic texture uploading
         then we don't need to flip either if the current drawing process
         will flip it latter. If it is from finish_access, then we must
         flip the y axis.
         The second thing is the alpha channel hanlding, if the pixmap's
         format is something like x8a8r8g8, x1r5g5b5 which means it doesn't
         has alpha channel, but it do has those extra bits. Then we need to
         wire those bits to 1.
      2. Add almost all the required picture format support.
         This is not as trivial as it looks like. The previous implementation
         only support GL_a8,GL_a8r8g8b8,GL_x8r8g8b8. All the other format,
         we have to fallback to cpu. The reason why we can't simply add those
         other color format is because the exists of picture. one drawable
         pixmap may has one or even more container pictures. The drawable pixmap's
         depth can't map to a specified color format, for example depth 16 can
         mapped to r5g6b5, x1r5g5b5, a1r5g5b5, or even b5g6r5. So we can't get
         get the color format just from the depth value. But the pixmap do not
         has a pict_format element. We have to make a new one in the pixmap
         private data structure. Reroute the CreatePicture to glamor_create_picture
         and then store the picture's format to the pixmap's private structure.
         This is not an ideal solution, as there may be more than one pictures
         refer to the same pixmap. Then we will have trouble. There is an example
         in glamor_composite_with_shader. The source and mask often share the
         same pixmap, but use different picture format. Our current solution is to
         combine those two different picture formats to one which will not lose any
         data. Then change the source's format to this new format and then upload
         the pixmap to texture once. It works. If we fail to find a matched new
         format then we fallback.
         There still is a potential problem, if two pictures refer to the same
         pixmap, and one of them destroy the picture, but the other still remained
         to be used latter. We don't handle that situation currently. To be fixed.
      3. Dynamic texture uploading.
         This is a performance feature. Although we don't like the client to hold
         a pixmap data to shared memory and we can't accelerate it. And even worse,
         we may need to fallback all the required pixmaps to cpu memory and then
         process them on CPU. This feature is to mitigate this penalty. When the
         target pixmap has a valid gl fbo attached to it. But the other pixmaps are
         not. Then it will be more efficient to upload the other pixmaps to GPU and
         then do the blitting or rendering on GPU than fallback all the pixmaps to CPU.
         To enable this feature, I experienced a significant performance improvement
         in the Game "Mines" :).
      4. Debug facility.
         Modify the debug output mechanism. Now add a new macro:
         glamor_debug_output(_level_, _format_,...) to conditional output some messages
         according to the environment variable GLAMOR_DEBUG. We have the following
         levels currently.
          exports GLAMOR_DEBUG to 3 will enable all the above messages.
      5. Changes in pixmap private data structure.
         Add some for the full color format supports and relate it to the pictures which
         already described. Also Add the following new elements:
         gl_fbo - to indicates whether this pixmap is on gpu only.
         gl_tex - to indicates whether the tex is valid and is containing the pixmap's
                  image originally.
         As we bring the dynamic pixmap uploading feature, so a cpu memory pixmap may
         also has a valid fbo or tex attached to it. So we will have to use the above
         new element to check it true type.
      After this commit, we can pass the rendercheck testing for all the picture formats.
      And is much much fater than fallback to cpu when doing rendercheck testing.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor: Optimize composite when soure/mask is xrgb. · 3c44e3e0
      Zhigang Gong authored
      Added a new shader aswizlle_prog to wired the alpha to 1 when
      the image color depth is 24 (xrgb). Then we don't need to fallback
      the xrgb source/mask to software composite in render phase. Also
      don't wire the alpha bit to 1 in the render phase. This can get
      about 2x performance gain with the cairo performance trace's
      firefox-planet case.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
    • Zhigang Gong's avatar
      glamor: Add new feature which is to flip output on y axis. · eb3487a4
      Zhigang Gong authored
      Due to the coordinate system on EGL is different from FBO
      object. To support EGL surface well, we add this new feature.
      When calling glamor_init from EGL ddx driver, it should use
      the new flag GLAMOR_INVERTED_Y_AXIS.
    • Eric Anholt's avatar
    • Eric Anholt's avatar
    • Eric Anholt's avatar
      glamor: Fix screen_x/screen_y handling for compositing. · be82a062
      Eric Anholt authored
      It's not an offset from pixmap coords to composited pixmap coords,
      it's an offset from screen-relative window drawable coords to
      composited pixmap coords.
    • Eric Anholt's avatar
      glamor: All the fallbacks in the world. · d8d3fa10
      Eric Anholt authored
      Bringup is really not flying when I can't see anything.  So dump back
      to all software so I can turn on a bit at a time.
    • Eric Anholt's avatar
    • Eric Anholt's avatar
    • Eric Anholt's avatar
    • Eric Anholt's avatar