1. 18 Dec, 2013 17 commits
    • Zhigang Gong's avatar
      5c1f15fa
    • Zhigang Gong's avatar
      glamor_copyarea: Return earlier if have zero nbox. · 1f83411c
      Zhigang Gong authored
      Almost all callers will check whether the regions is empty
      before call to this internal API, but it seems the
      glamor_composite_with_copy may call into here with a zero
      nbox. A little weird, as the miComputeCompositeRegion return
      a Non-NULL, but the region is empty.
      
      Also remove a unecessary glflush.
      
      So let's check it here.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      1f83411c
    • Zhigang Gong's avatar
      glamor_copyarea: Don't access a DRM only pixmap. · 8a85071e
      Zhigang Gong authored
      As EGL image/gbm only support ARGB8888 image, we don't support
      other format. We may change the way to use gbm directly latter.
      But now, we have to face this limitation, and thus if a client
      create a 16bpp drawable, and call get texture from pixmap then
      a copy to here may occur and thus we have to force retur a TRUE
      without do nothing.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      8a85071e
    • Zhigang Gong's avatar
      pending_op: Remove the pending operations handling. · 9bcddff9
      Zhigang Gong authored
      We have disabled this feature for a long time, and previous
      testing shows that this(pending fill) will not bring observed
      performance gain. Now remove it.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      9bcddff9
    • 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>
      3e9c35bd
    • 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
      GLES2.
      
      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
      glamor_get_tex_format_type_from_pictformat.
      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
          below:
              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>
      3add3750
    • Zhigang Gong's avatar
      glamor_copyarea: Don't use GL_CLAMP_TO_BORDER when GLES2 enabled. · 8012b030
      Zhigang Gong authored
      We may need to modify all the shader to handle GL_CLAMP_TO_BORDER
      when using GLES2. XXX, for now, we just ignore them.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      8012b030
    • 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);
       ...
       glamor_put_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>
      556adfa6
    • 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"
      EndSection
      
      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>
      430bc16c
    • Chris Wilson's avatar
      Use CLAMP_TO_BORDER in copy_n_to_n so we can sample outside of the source · 97efbd25
      Chris Wilson authored
      In order to reduce a composite operation to a source, we need to provide
      Render semantics for the pixel values of samples outside of the source
      pixmap, i.e. they need to be rgba(0, 0, 0, 0). This is provided by using
      the CLAMP_TO_BORDER repeat mode, but only if the texture has an alpha
      channel.
      Signed-off-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      97efbd25
    • 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>
      2ff41008
    • 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>
      a65e1c73
    • 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>
      8c7fcefb
    • Zhigang Gong's avatar
      Call glamor_create_pixmap directly in glamor rendering path. · 36d424fe
      Zhigang Gong authored
      When glamor is rendering pixmaps, and needs to create some
      temporary pixmap, it's better to use glamor version create
      pixmap directly. As if goes to external DDX's create pixmap,
      it may create a external DRM buffer which is not necessary.
      All the case within glamor scope is to create a texture only
      pixmap or a in memory pixmap.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      36d424fe
    • 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>
      92fd8387
    • 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>
      b5630663
    • Zhigang Gong's avatar
      Initial version. · b861aad8
      Zhigang Gong authored
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      b861aad8
  2. 26 Sep, 2011 23 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>
      0dff23d6
    • Zhigang Gong's avatar
      glamor: Fix the copy of overlaped region in one pixmap. · 1658454d
      Zhigang Gong authored
      Originaly, we use fbo blit to handle overlaped region copy.
      But GLES2 doesn't support that, just simply copy the needed
      region to another texture can fix this problem.
      Signed-off-by: Zhigang Gong's avatarZhigang Gong <zhigang.gong@gmail.com>
      1658454d
    • 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>
      a228effb
    • Zhigang Gong's avatar
      glamor: Remove GLEW dependency. · 172e8cfc
      Zhigang Gong authored
      Glamor doesn't need to use GLEW. We can parse the extension by
      ourself. This patch also fix the fbo size checking from a hard
      coded style to a dynamic checking style.
      Signed-off-by: Zhigang Gong's avatarZhigang Gong <zhigang.gong@gmail.com>
      172e8cfc
    • 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>
      ee33c947
    • Zhigang Gong's avatar
      glamor-es2: Fix some non-es2 functions. · 94d884a1
      Zhigang Gong authored
      ES2.0 doesn't support QUADS and also doesn't support
      some EXT APIs. Fix some of them in this commit.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      94d884a1
    • Zhigang Gong's avatar
    • Zhigang Gong's avatar
      glamor: Fix one bug for Xephyr. · 0ef1698b
      Zhigang Gong authored
      Xephyr doesn't has a bounded valid texture. It seems that we can't
      load texture 0 directly sometimes. Especially in the copyarea, function
      if that is the case, we prefer to use fbo blit to read the screen pixmap
      rather than load the bound texture.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      0ef1698b
    • Zhigang Gong's avatar
      glamor: Avoid 2D bitblit if possible. · 1f3f3baf
      Zhigang Gong authored
      It turns out that the use of fbo blit is one of the root cause
      which lead to slow drawing, especially slow filling rects.
      
      We guess there should be a performance bug in the mesa driver
      or even in the kernel drm driver. Currently, the only thing
      glamor can do is to avoid calling those functions.
      
      We check whether the copy source and destination has overlapped
      region, if it has, we have to call fbo blit function. If it has
      not, we can load the source texture directly and draw it to the
      target texture. We totally don't need the glCopyPixels here, so
      remove it.
      
      By apply this patch, the rendering time of firefox-planet-gnome
      decrease to 10.4 seconds. At the same platform, uxa driver get 13
      seconds. This is the first time we get better performance than
      uxa driver.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      1f3f3baf
    • 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>
      5c4d53c5
    • Zhigang Gong's avatar
      477a54bc
    • Zhigang Gong's avatar
      glamor: Reduce source pixmap's size. · 1dca5d7b
      Zhigang Gong authored
      If the dest pixmap is in texture memory, but source pixmap is not.
      Then we need to upload the source pixmap to texture memory. Previous
      version will upload the whole source pixmap. This commit preprocess
      the source pixmap, and reduce it to a smaller tempory pixmap only
      contains the required region.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      1dca5d7b
    • Zhigang Gong's avatar
    • Zhigang Gong's avatar
      glamor: Fixed one bug when enable dynamic pixmap uploading. · bf782283
      Zhigang Gong authored
      When try to upload a pixmap without yInverted set, we must
      set up a fbo for it to do the y flip. Previous implementation
      only consider the ax bit. After fix this problem, we can
      enable the dynamic uploading feature in copyarea function when
      the yInverted is not set (from Xephyr).
      Signed-off-by: Zhigang Gong's avatarZhigang Gong <zhigang.gong@gmail.com>
      bf782283
    • 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>
      ca1908e1
    • 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>
      355334fc
    • 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.
      eb3487a4
    • Eric Anholt's avatar
    • Eric Anholt's avatar
      glamor: Add a little mechanism for only printing fallbacks when they happen. · 8cefa287
      Eric Anholt authored
      Sometimes we want to try a couple of different methods for
      accelerating.  If one of them says "no" and the other says "yes",
      don't spam the log about the "no."
      8cefa287
    • Eric Anholt's avatar
      glamor: Fix off-by-one in CopyPixels CopyArea path. · 86a20652
      Eric Anholt authored
      Fixes window dragging in uncomposited metacity.
      86a20652
    • 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.
      be82a062
    • Eric Anholt's avatar
    • Eric Anholt's avatar
      glamor: Set active texture on glamor_copy_n_to_n setup. · e6bf5057
      Eric Anholt authored
      Fixes failure in rendercheck -t blend -o src
      e6bf5057