1. 31 May, 2021 1 commit
  2. 30 May, 2021 23 commits
  3. 27 May, 2021 1 commit
  4. 20 May, 2021 1 commit
    • Erik Kurzinger's avatar
      xwayland/eglstream: flush stream after eglSwapBuffers · 7515c23a
      Erik Kurzinger authored and Olivier Fourdan's avatar Olivier Fourdan committed
      When eglSwapBuffers inserts a new frame into a window's stream, there may be a
      delay before the state of the consumer end of the stream is updated to reflect
      this. If the subsequent wl_surface_attach, wl_surface_damage, wl_surface_commit
      calls are received by the compositor before then, it will (typically) re-use
      the previous frame acquired from the stream instead of the latest one.
      
      This can leave the window displaying out-of-date contents, which might never be
      updated thereafter.
      
      To fix this, after calling eglSwapBuffers, xwl_glamor_eglstream_post_damage
      should call eglStreamFlushNV. This call will block until it can be guaranteed
      that the state of the consumer end of the stream has been updated to reflect
      that a new frame is available.
      
      Closes: xorg/xserver#1171
      
      
      
      Signed-off-by: Erik Kurzinger's avatarErik Kurzinger <ekurzinger@nvidia.com>
      7515c23a
  5. 18 May, 2021 1 commit
  6. 17 May, 2021 1 commit
  7. 11 May, 2021 12 commits
    • Olivier Fourdan's avatar
      xwayland/eglstream: Set ALU to GXCopy for blitting · 012350e3
      Olivier Fourdan authored
      
      
      The EGLstream backend's post damage function uses a shader and
      glDrawArrays() to copy the data from the glamor's pixmap texture prior
      to do the eglSwapBuffers().
      
      However, glDrawArrays() can be affected by the GL state, and therefore
      not reliably produce the expected copy, causing the content of the
      buffer to be corrupted.
      
      Make sure to set the ALU to GXCopy prior to call glDrawArrays() to get
      the expected result.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Suggested-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      012350e3
    • Olivier Fourdan's avatar
      xwayland/eglstream: Do not always increment pixmap refcnt on commit · d85bfa6a
      Olivier Fourdan authored
      
      
      Currently, the EGLstream backend would increment the pixmap refcount for
      each commit, and decrease that refcount on the wl_buffer release
      callback.
      
      But that's relying on the compositor sending us a release callback for
      each commit, otherwise the pixmap refcount will keep increasing and the
      pixmap will be leaked.
      
      So instead, increment the refcount on the pixmap only when we have not
      received a release notification for the wl_buffer, to avoid increasing
      the pixmap refcount more than once without a corresponding release
      event.
      
      This way, if the pixmap is still in use when released on the X11 side,
      the EGL stream will be kept until the compositor releases it.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Suggested-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      d85bfa6a
    • Olivier Fourdan's avatar
      xwayland/eglstream: Check eglSwapBuffers() · b583395c
      Olivier Fourdan authored
      
      
      EGLstream's post_damage() would unconditionally return success
      regardless of the actual status of the eglSwapBuffers().
      
      Yet, if eglSwapBuffers() fails, we should not post the corresponding
      damage as they wouldn't match the actual content of the buffer.
      
      Use the eglSwapBuffers() return value as the return value for
      post_damage() and do not take a refrence on the pixmap if it fails.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      b583395c
    • Olivier Fourdan's avatar
      xwayland/eglstream: Fix calloc/malloc · a4579997
      Olivier Fourdan authored
      
      
      Use calloc() instead of malloc() like the rest of the code.
      
      Also fix the arguments of calloc() calls to match the definition which
      is calloc(size_t nmemb, size_t size).
      
      This is a cleanup patch, no functional change.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      a4579997
    • Olivier Fourdan's avatar
      xwayland/eglstream: Do not commit without surface · 098e0f52
      Olivier Fourdan authored
      
      
      The EGL surface for the xwl_pixmap is created once the stream is ready
      and valid.
      
      If the pixmap's EGL surface fails, for whatever reason, the xwl_pixmap
      will be unusable and will end up as an invalid wl_buffer.
      
      Make sure we do not allow commits in that case and recreate the
      xwl_pixmap/stream.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      xorg/xserver#1156
      098e0f52
    • Olivier Fourdan's avatar
      xwayland/eglstream: Drop the list of pending streams · bee2ebb2
      Olivier Fourdan authored
      
      
      Now that the pending stream is associated with the xwl_pixmap for
      EGLStream and the xwl_pixmap itself is associated to the pixmap, we have
      a reliable way to get to those data from any pending stream.
      
      As a result, the list of pending streams that we keep in the EGLStream
      global structure becomes useless.
      
      So we can drop the pending stream's xwl_pixmap and also the list of
      pending streams altogether, and save us a walk though that list for each
      callback.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Suggested-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      bee2ebb2
    • Olivier Fourdan's avatar
      xwayland/eglstream: Keep a reference to the pixmap · e19bf86c
      Olivier Fourdan authored
      Commit affc4745 - "xwayland: Drop the separate refcount for the
      xwl_pixmap" removed the separate reference counter for the xwl_pixmap
      which holds the EGLStream.
      
      While that works fine for the common case, if the window's pixmap is
      changed before the stream is ready, the older pixmap will be destroyed
      and the xwl_pixmap along with it, even if the compositor is still using
      the stream.
      
      The code that was removed with commit affc4745
      
       was taking care of that
      by increasing the separate reference counter for the xwl_pixmap, but it
      no longer the case.
      
      As a result, we may end up with the EGL stream in the wrong state when
      trying to use it, which will cascade down into all sort of issues.
      
      To avoid the problem, increase the reference count on the pixmap when it
      is marked as invalid in EGLStream's SetWindowPixmap().
      
      This way, the xwl_pixmap and the EGLStream are kept until released by
      the compositor, even when the pixmap changes before stream is ready.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      Fixes: affc4745 xwayland: Drop the separate refcount for the xwl_pixmap
      xorg/xserver#1156
      e19bf86c
    • Olivier Fourdan's avatar
      xwayland/eglstream: Dissociate pending stream from window · cb61ecc7
      Olivier Fourdan authored
      Previously, we would have pending streams associated with top level X11
      windows, keeping temporary accounting for the pending streams before
      they get fully initialized for the xwl_pixmap which would be associated
      with X11 pixmaps.
      
      If the window content changes before the stream is ready, the
      corresponding pending stream would be marked as invalid and the pending
      stream would be eventually removed once the stream becomes ready.
      
      Since commit affc4745
      
       - "xwayland: Drop the separate refcount for the
      xwl_pixmap", we no longer keep a separate reference counter for the
      xwl_pixmap, but rather tie it to the X11 pixmap lifespan. Yet, the
      pending stream would still be associated with the X11 toplevel window.
      
      Dissociate the pending streams from the X11 toplevel window, to keep it
      tied only to the xwl_pixmap so that we can have:
      
       - pixmap <-> xwl_pixmap
       - xwl_pixmap <-> pending stream
      
      Of course, the pending streams remain temporary and get removed as soon
      as the ready callback is triggered, but the pending streams are not
      linked to the X11 window anymore which can change their content, and
      therefore their X11 pixmap at any time.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      xorg/xserver#1156
      cb61ecc7
    • Olivier Fourdan's avatar
      xwayland/eglstream: Add more error checking · cc596bcf
      Olivier Fourdan authored
      
      
      eglCreateStreamKHR() can fail and return EGL_NO_STREAM_KHR, in which
      case there is no point in trying to create a buffer from it.
      
      Similarly, eglCreateStreamProducerSurfaceKHR() also fail and return
      EGL_NO_SURFACE, which in turn will be used in eglMakeCurrent() as
      draw/read surface, and therefore would mean no draw/read buffer.
      
      In those cases, log the error, and bail out early. That won't solve the
      issue but will help with investigating the root cause of issues with
      EGLStream backend.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      xorg/xserver#1156
      cc596bcf
    • Olivier Fourdan's avatar
      xwayland/eglstream: Small refactoring · 823f3254
      Olivier Fourdan authored
      
      
      Some functions are called "callback" whereas they are not longer
      callback functions or "unref" while they no longer deal with a reference
      counter anymore, which is quite confusing. Rename those functions to be
      more explicit.
      
      Also, the pending streams can be destroyed in different places, move the
      common code to separate function to avoid duplicating code and help with
      readability of the code.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Acked-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      823f3254
    • Olivier Fourdan's avatar
      xwayland/eglstream: Check framebuffer status · 85244d2a
      Olivier Fourdan authored
      
      
      The EGLStream backend would sometime generate GL errors trying to draw
      to the framebuffer, which gives an invalid buffer, which in turn would
      generate a Wayland error from the compositor which is fatal to the
      client.
      
      Check the framebuffer status and bail out early if it's not complete,
      to avoid getting into trouble later.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      xorg/xserver#1156
      85244d2a
    • Olivier Fourdan's avatar
      xwayland/glamor: Add return status to post_damage · 252cbad3
      Olivier Fourdan authored
      
      
      If the glamor backend failed to post damage, the caller should do the
      same to avoid a failure to attach the buffer to the Wayland surface.
      
      Change the API of Xwayland's glamor backend post_damage() to return a
      status so that xwl_window_post_damage() can tell whether the callee
      failed.
      
      Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      xorg/xserver#1156
      252cbad3