1. 26 Sep, 2011 40 commits
    • Zhigang Gong's avatar
    • Zhigang Gong's avatar
      glamor: Move the blend set up after the pixmap uploading. · b8e692d9
      Zhigang Gong authored
      This is a bug, as if we do blend set up before do the pixmap
      dynamic uploading. We will have a incorrect blend env when
      doing the uploading.
      Signed-off-by: Zhigang Gong's avatarZhigang Gong <zhigang.gong@gmail.com>
      b8e692d9
    • 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: Initialize pixmap private's container to correct value. · 489e6c4e
      Zhigang Gong authored
      When calling from ephyr, we forgot to initialize it to the correct
      value. Will cause segfault when run Xephyr.
      Signed-off-by: Zhigang Gong's avatarZhigang Gong <zhigang.gong@gmail.com>
      489e6c4e
    • Zhigang Gong's avatar
      glamor: Don't always fallback everything when change window attr. · ca36ada0
      Zhigang Gong authored
      Change the glamor_change_window_attributes's handling. We don't need
      to fallback every thing to cpu at the beginning. Only when there
      is a real need to change the pixmap's format, we need to do something.
      Otherwise, we need do nothing here.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      ca36ada0
    • 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: Simplify fill acceleration for spans/polyfillrect by only clipping once. · ba6dd8aa
      Zhigang Gong authored
          This commit was borrowed from uxa driver contributed by Eric.
          commit number is e0066e77e026b0dd0daa0c3765473c7d63aa6753. commit log paste as
          below:
          We were clipping each span against the bounds of the clip, throwing
          out the span early if it was all clipped, and then walked the clip box
          clipping against each of the cliprects.  We would expect spans to
          typically be clipped against one box, and not thrown out, so we were
          not saving any work there.  For multiple cliprects, we were adding
          work.  Only for many spans clipped entirely out of a complicated clip
          region would it have saved work, and it clearly didn't save bugs as
          evidenced by the many fix attempts here.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      ba6dd8aa
    • Zhigang Gong's avatar
      glamor: Fallback to fbPolylines for diagonal poly_line. · a0a52be7
      Zhigang Gong authored
      It's better to give a correct output when we haven't
      implement all the code path.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      a0a52be7
    • Zhigang Gong's avatar
      glamor: For non-supported fill style fallback to fbFill. · d7f8b888
      Zhigang Gong authored
      The previous implementation will just skip the rendering
      which is not good.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      d7f8b888
    • Zhigang Gong's avatar
      b60e6cb6
    • Zhigang Gong's avatar
      glamor: Add render triangles support. · 229240e5
      Zhigang Gong authored
      By default, fallback to frame buffer currently. This commit
      makes us pass the rendercheck's triangles testing.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      229240e5
    • Zhigang Gong's avatar
      glamor: Use software fb for 1bpp pixmap. · ac0589c9
      Zhigang Gong authored
      For 1bpp pixmap, software fb get better performance than
      GL surface. The main reason is that fbo doesn't support
      1bpp texture as internal format, so we have to translate
      a 1bpp bitmap to a 8bit alpha format each time which is
      very inefficient. And the previous implementation is
      not supported by the latest OpenGL 4.0, the GL_BITMAP
      was deprecated.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      ac0589c9
    • 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>
      3c44e3e0
    • Zhigang Gong's avatar
    • Zhigang Gong's avatar
      glamor: Optimize glamor_finish_access. · 925fc972
      Zhigang Gong authored
      use pbo if possible when we load texture to a temporary tex.
      And for the previous direct texture load function, it's not
      correct and get removed in this commit.
      Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
      925fc972
    • Zhigang Gong's avatar
      glamor: Don't use glamor_pixmap_type currently. · b8ce483f
      Zhigang Gong authored
      Added comments to glamor_pixmap_create. To be refined in the future.
      We need to identify whether a pixmap is a CPU memory pixmap or a
      GPU pixmap. Current implementation is not correct. There are three
      cases:
      
      1. Too large pixmap, we direct it to CPU memory pixmap.
      2. w ==0 ||  h == 0 pixmap, this case has two possibilities:
         2.1 It will become a screen pixmap latter, then it should be
             GPU type.
         2.2 It's a scratch pixmap or created from a share memory, then
             it should belong to CPU memory.
      
      XXX, need to be refined latter.
      b8ce483f
    • Zhigang Gong's avatar
      glamor: improve glamor_finish_access. · 28835be1
      Zhigang Gong authored
      When the platform's coordinate system is the same as X11's . We
      can load the texture to the fbo directly without one extra texture
      transformation.
      28835be1
    • Zhigang Gong's avatar
      glamor: Don't write back read only pixmap to fbo. · 1edf0cc6
      Zhigang Gong authored
      For those pixmap which has valid fbo and opened as GLAMOR_ACCESS_RO
      mode, we don't need to upload the texture back when calling the
      glamor_finish_access(). This will get about 10% performance gain.
      1edf0cc6
    • Zhigang Gong's avatar
      glamor: Use buffer object as much as possible. · 1495ba9e
      Zhigang Gong authored
      Change the row length of 1bit color depth pixmap to the actual stride.
      The previous implementation use the width as its stride which is not
      good. As it will waste 8 times of space and also bring some non-unify
      code path. With this commit, we can merge those 1bit or other color
      depth to almost one code path. And we will use pixel buffer object
      as much as possible due to performance issue. By default, some mesa
      hardware driver will fallback to software rasterization when use
      glReadPixels on a non-buffer-object frame buffer. This change will
      get about 4x times performance improvemention when we use y-inverted
      glamor or the driver support hardware y-flipped blitting.
      1495ba9e
    • Zhigang Gong's avatar
      529c38a4
    • Zhigang Gong's avatar
      cd43b1ea
    • Zhigang Gong's avatar
      glamor: glamor_set_alu should enable GL_COLOR_LOGIC_OP. · 8593f22f
      Zhigang Gong authored
      GL_COLOR_OP seems not supported in current MESA.
      8593f22f
    • Zhigang Gong's avatar
      glamor: Switch to software fb for too large pixmap. · f871d174
      Zhigang Gong authored
      If pixmap's size exceeds the limitation of the MESA library, the
      rendering will fail. So we switch to software fb if it is the case.
      Add one new element for pixmap private structure to indicate whehter
      we are a software fb type or a opengl type.
      f871d174
    • Zhigang Gong's avatar
      glamor-ddx: Fixed one bug when a client reset the connection. · 74ca45e7
      Zhigang Gong authored
      This commit fixed two bugs when one client reset the connection.
      The first is that we should reopen the graphic device when the previous
      node was closed during the screen closing. The second one is we should
      call glamor_close_screen (not the ddx version) prior to call
      eglTerminate(). As eglTerminate will release the share library. And
      the glamor_close_screen may still need to call openGL APIs and thus
      will hit segfault. And renamed the ddx functions to avoid naming
      conflications with the glamor functions.
      74ca45e7
    • Zhigang Gong's avatar
      glamor: Silent compilation warnings due to some deprecated APIs. · c97d4533
      Zhigang Gong authored
      those xcalloc/xfree/xalloc/XNFprintf/... are deprecated. Replace
      then with the new one. And fix some other minor problems.
      c97d4533
    • Zhigang Gong's avatar
      glamor-ddx: Move the cursor EGL image to crtc strcture. · e3295d41
      Zhigang Gong authored
      Cursor is a per crtc resource. And this commit also fix the cursor
      initialization regard to the latest mesa EGL code. Now hardware
      cursor works fine.
      e3295d41
    • Zhigang Gong's avatar
      glamor-ddx: Fix a compiling error. Need revisit. · 43280372
      Zhigang Gong authored
      GC is redefined in the X11/Xlib.h and include/gcstruct.h which is
      a xorg header file. Just use a macro to simply avoid the conflict.
      Need revisit latter to find a correct way to fix this problem.
      43280372
    • Zhigang Gong's avatar
      glamor-ddx: Migrate the code to latest mesa library. · 18a52e23
      Zhigang Gong authored
      Use eglCreateDRMImageMESA to create surfaceless image. And then
      export the drm buffer back which can be used to create the frame
      buffer.
      18a52e23
    • 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
    • Zhigang Gong's avatar
      glamor: Add glamor-ddx driver to the build tree. · 6dae8dc7
      Zhigang Gong authored
      Correct the linking parameters and add dependency to the libglamor.a.
      6dae8dc7
    • Zhigang Gong's avatar
    • Kristian Høgsberg's avatar
      glamor ddx driver using EGL on KMS · 49bf0e30
      Kristian Høgsberg authored
      49bf0e30
    • Zhigang Gong's avatar
      glamor: Fixed one segfault bug when close screen. · 47b65312
      Zhigang Gong authored
      move the original glamor_fini to glamor_close_screen. And wrap the CloseScreen
      with glamor_close_screen, Then we can do some thing before call the underlying
      CloseScreen().
      The root cause is that glamor_fini will be called after the ->CloseScreen().
      This may trigger a segmentation fault at
      glamor_unrealize_glyph_caches() at calling into FreePicture().
      47b65312
    • Zhigang Gong's avatar
      glamor: Fixed one linking error. · 0d9e8db8
      Zhigang Gong authored
      As current glamor implementation depends on the glx library in the
      mesa package which is conflict with the version in xorg. We have to
      --disable-glx when build Xephyr. But this leads to the linking error
      here. We comment out the calling to ephyrHijackGLXExtension() now.
      Need revisit latter.
      0d9e8db8
    • Zhigang Gong's avatar
      glamor: Merged with latest xserver. · b3577a1c
      Zhigang Gong authored
      Merged with latest xserver, the major change is due to the API change of
      the management of devPrivates.
      b3577a1c
    • Zhigang Gong's avatar
    • Zhigang Gong's avatar
      glamor: Fixed one conflict data type(XID) bug. · f9843c7a
      Zhigang Gong authored
      We should include the dix-config.h for all the glamor files. Otherwise
      the XID type maybe inconsisitent in different files in 64bit machine.
      The root cause is this macro "#define _XSERVER64 1" should be included
      in all files refer to the data type "XID" which is originally defined
      in X.h. If _XSERVER64 is defined as 1, then XID is defined as CARD32
      which is a 32bit integer. If _XSERVER64 is not defined as 1 then XID
      is "unsigned long". In a 32bit machine, "unsigned long" should be
      identical to CARD32. But in a 64bit machine, they are different.
      f9843c7a
    • Zhigang Gong's avatar
      glamor: Fixed some compiling and linking errors. · e194740c
      Zhigang Gong authored
      Change the inline functions to static type, otherwise when linking it
      complains multiple definitions of those functions.
      e194740c
    • Eric Anholt's avatar