1. 06 Jun, 2019 1 commit
  2. 05 Jun, 2019 9 commits
    • Manuel Stoeckl's avatar
      Apply dmabuf modifiers to replicated dmabuf file descriptors · 362679d2
      Manuel Stoeckl authored
      The code is complicated by the fact that the libgbm backends
      sometimes don't support buffer combinations which compositors do,
      and don't have an api to create buffer objects from the minimum
      information required by the kernel.
      
      This patch has only been tested with i915 drivers and x-tiled
      surfaces.
      362679d2
    • Manuel Stoeckl's avatar
      Clarify reference counting logic for struct shadow_fd · 1eaec59c
      Manuel Stoeckl authored
      This commit divides the reference count for struct shadow_fd objects
      into two main categories: the reference counts required to keep
      the file descriptors associated with the shadow_fd alive until they
      can be written to the Wayland application/compositor, and the reference
      counts from protocol objects.
      
      In the process, fix a memory leak and an early destruction bug for dmabuf
      objects.
      1eaec59c
    • Manuel Stoeckl's avatar
      Use a login shell with waypipe ssh · 295cdf74
      Manuel Stoeckl authored
      295cdf74
    • Manuel Stoeckl's avatar
      Fix refcount calculation for dmabufs · 854844cc
      Manuel Stoeckl authored
      An earlier decision of decreasing refcounts exactly once per unique
      fd transferred to the wayland program was reversed here; tracking
      unique fd transfers properly requires keeping track of all fds which
      have been transferred so far. Instead, the reference counts for dmabuf
      shadow structures are increased proportionately to the number of times
      the dmabuf will be transferred.
      854844cc
    • Manuel Stoeckl's avatar
      Fix overflow when sending many fds to a Wayland program · 298d63ce
      Manuel Stoeckl authored
      The linux-dmabuf protocol, when its messages are reordered, sometimes
      produces transfers with a much larger number of file descriptors than
      the messages produced by libwayland have. Because libwayland has an
      effective 28-fd limit per message, this commit changes iovec_write to
      send as most 28 file descriptors at a time.
      
      It is necessary to write at least one byte per set of 28 file
      descriptors; fortunately, running out of bytes to write is practically
      impossible as it would require Wayland protocol messages that send 224
      fds each.
      298d63ce
    • Manuel Stoeckl's avatar
      Fix duplicate detection for dmabufs · 423df579
      Manuel Stoeckl authored
      It turns out that the handles associated with a gbm_bo are only unique
      for the lifetime of the buffer object; to compare a set of dmabuf fds,
      one must construct buffer objects for them all, extract handles, and then
      delete the temporary buffer objects.
      423df579
    • Manuel Stoeckl's avatar
      1e0ecd69
    • Manuel Stoeckl's avatar
      Fix writes to channel with empty transfer blocks · 2e21922c
      Manuel Stoeckl authored
      Before this fix, whenever a pipe object was closed, it would produce a
      0-length transfer, and waypipe would run in an infinite loop trying to
      write 0 bytes through the channel over to the other waypipe instance.
      2e21922c
    • Manuel Stoeckl's avatar
      Deduplicate dmabufs for multiplanar images · 8e35ac64
      Manuel Stoeckl authored
      A common construct when creating multiplanar dmabufs for the linux-dmabuf
      protocol is to allocate all planes as part of the same dmabuf, and then
      to provide the same file descriptor to the protocol for each individual
      plane. As this file descriptors is dup2'd on being sent from an application
      to waypipe, determining which file descriptors share an underlying
      dmabuf requires extracting their associated buffer handles with libgbm.
      
      Additional error checks for close() operations, and to verify the validity
      of file descriptors before sendmsg'ing to another program, have also been
      added.
      8e35ac64
  3. 04 Jun, 2019 1 commit
    • Manuel Stoeckl's avatar
      Delay linux-dmabuf paramater requests until format is known · 27ae64b6
      Manuel Stoeckl authored
      The linux_dmabuf_unstable_v1 protocol sets up a buffer with a series
      of add requests that provide dmabuf fds, followed by a create request
      which provides the format, modifiers, width, and height for the surface.
      
      This latter information makes it significantly easier to properly process
      provided dmabuf fds. To make such information available, the dmabuf param
      add requests are delayed until either a create or a create_immed request
      is provided, and then all the parameter requests are sent at once.
      27ae64b6
  4. 03 Jun, 2019 4 commits
    • Manuel Stoeckl's avatar
      Use vectored io to reduce data copies when writing to channel · 2fc6e7d5
      Manuel Stoeckl authored
      Specifically, the function pack_pipe_message, instead of allocating
      a large buffer and copying transfer blocks into the buffer, now sets
      up metadata for the function writev, which can writev a series of
      data buffers without unnecessary copies.
      
      This is especially useful for file or dmabuf update diffs, which are
      often >100KB; it reduces the net processing time for them by 20%, in
      some cases.
      2fc6e7d5
    • Manuel Stoeckl's avatar
      Switch dmabuf backend to libgbm · 5c1f6ff2
      Manuel Stoeckl authored
      The previous intel-specific, libdrm-based backend for dmabuf
      operations was a temporary measure. This commit replaces
      it with a backend based on libgbm, a generic buffer management
      library supported by most graphics drivers.
      
      DMABUFs are still assumed to correspond to standard single-plane
      linear packed image. This limitation can be corrected, but was
      necessary for this commit because buffers are currently imported
      and created before protocol messages are read.
      5c1f6ff2
    • Manuel Stoeckl's avatar
      Optimize file buffer diff construction routine · 9c496331
      Manuel Stoeckl authored
      waypipe used to contruct a diff between a modified and a reference
      buffer, and then update the reference buffer using the diff. This
      change merges both operations into a single method, using a single
      pass.
      9c496331
    • Manuel Stoeckl's avatar
      Add partial support for wl_drm and linux-dmabuf protocols · 67aa508f
      Manuel Stoeckl authored
      This commit adds support for DMABUF file descriptor types and for the
      wayland-drm and linux-dmabuf-v1 protocols, on machines with an i915
      driver only. (Other drivers are not yet supported, due to difficulties
      with the generic libgbm buffer management library.)
      
      To support the wl_drm protocol, the device advertisement event was modified
      to indicate only a default DRM render node (/dev/dri/renderD128). This
      avoids the authentication steps which would otherwise be necessary when
      the main DRM device paths are provided, and still should work for most
      OpenGL programs.
      
      This change also involved significant main loop refactoring to remain
      readable during an extensions to the protocol parsing code; specifically,
      to allow message handlers to increase the length of protocol messages.
      
      A command line flag, -no-gpu, has been added to block the wl_drm and
      zwp_linux_dmabuf_v1 global advertisements; when running on a system
      without an i915 drm node, these two pro...
      67aa508f
  5. 31 May, 2019 1 commit
  6. 30 May, 2019 4 commits
    • Manuel Stoeckl's avatar
      Account for pixel byte length in damage estimates · 693060ec
      Manuel Stoeckl authored
      Damage estimation for wl_surface.commit previously calculated the
      interval containing damage pixels as though each pixel used one
      byte of space. This commit corrects that assumption, and adds a fallback
      path for unusual (i.e, multiplanar) pixel buffer formats.
      693060ec
    • Manuel Stoeckl's avatar
      Convert timestamps for presentation-time to real time · 16f24620
      Manuel Stoeckl authored
      The presentation-time protocol provides frame feedback information,
      including timings produced by the compositor with respect to a
      "presentation clock" (such as CLOCK_MONOTONIC_RAW.) Such clocks
      typically have significantly different baselines on different
      systems -- in the case of CLOCK_MONOTONIC_RAW, typically the time
      since boot.
      
      This commit translates the (local) protocol timestamps to an
      approximation of CLOCK_REALTIME and back. Assuming the computers
      at each end of the waypipe connection use NTP and have well-calibrated
      clocks, CLOCK_REALTIME should agree within <5ms on local networks, or
      <1ms if there is a local NTP server. This ensures that the wayland
      protocol client sees timestamps consistent with its own presentation
      clock offset.
      
      Clock skew is not handled; the clock offsets are computed from a single
      measurement and may be affected by scheduler preemption; no sanity
      checks are performed.
      
      This change was tested with `weston-presentation-time`. The Wayland core
      protocol timestamps its frame callbacks with an clock of implementation-
      -specific baseline. These frame callback timestamps (affecting log fields
      f2p and f2c) can be ignored.
      16f24620
    • Manuel Stoeckl's avatar
      298ba10b
    • Manuel Stoeckl's avatar
      1d12ebd2
  7. 29 May, 2019 3 commits
  8. 28 May, 2019 4 commits
    • Manuel Stoeckl's avatar
      Use wl_surface.damage requests to reduce diff costs · d61d431c
      Manuel Stoeckl authored
      waypipe now records all wl_surface.damage requests made to a given surface,
      and at surface commit time, determines which range of bytes in the attached
      wl_buffer's memory pool file may have changed. This range can be much
      smaller than the size of the file, so that change detection on the range
      can be significantly cheaper than full-file change detection.
      
      This commit also sets up subtyping for struct wp_object, to reduce the memory
      usage needed for typical objects.
      d61d431c
    • Manuel Stoeckl's avatar
      Include common private protocol files · 2508d388
      Manuel Stoeckl authored
      Currently, waypipe requires these to correctly identify which wayland
      messages consume a passed file descriptor.
      2508d388
    • Manuel Stoeckl's avatar
      Defer truncated message parts correctly · 15ac2e38
      Manuel Stoeckl authored
      This commit ensures that when a series of messages read from
      either the compositor or application is truncated halfway through
      a message, that the truncated message is completed and correctly
      parsed on the next iteration of the message transport state machine.
      15ac2e38
    • Manuel Stoeckl's avatar
      Rewrite main proxy loop to use nonblocking sockets · 4d42fae3
      Manuel Stoeckl authored
      Previously, the main proxy loops in `run_server_child` and
      `run_client_child` alternated between making transfers from their shared
      channel to their individual wayland compositor/application channels.
      
      By using socket connections in nonblocking mode, the proxy now can
      simultaneously maintain transfers in both directions. This ensures that
      large transfers (such as a full-screen image) do not prevent e.g. key
      release events from being transferred.
      
      Additionally, as the two proxy loops were very similar, they have been
       combined into the `main_interface_loop` routine.
      
      The code still does not correctly handle the case where a read from
      the wayland compositor/application fills the entire read buffer and
      truncates a sent message, but it is now easier to adjust for that case.
      4d42fae3
  9. 27 May, 2019 5 commits
    • Manuel Stoeckl's avatar
      Add deletion framework for file descriptors · 1c834fdf
      Manuel Stoeckl authored
      When shadow_fd structs _that are owned by known protocol objects_
      have their reference count drop to zero, they are deleted.
      
      Newly created shadow_fd's begin with a reference count of 1,
      which is reduced when the translated fd to sent to the
      display/application/other waypipe socket end. This ensures
      that the object is not deleted early, even if the compositor
      e.g. wl_display.delete_id's the fd owning object before receiving
      it.
      1c834fdf
    • Manuel Stoeckl's avatar
      Remove incorrect warning messages · fc9fecef
      Manuel Stoeckl authored
      For wl_shm_pool.resize, wl_shm.create_pool, and wl_surface.commit .
      fc9fecef
    • Manuel Stoeckl's avatar
      d9e70242
    • Manuel Stoeckl's avatar
      Improve build portability · 065233ab
      Manuel Stoeckl authored
      * Make scdoc optional; documentation is not strictly necessary
      * Explicitly test for fmacro-prefix-map support
      * Test for the minimum possible versions of wayland dependencies
      * Reduce required meson version
      065233ab
    • Manuel Stoeckl's avatar
      Implement simple buffer ownership system · f73e15a0
      Manuel Stoeckl authored
      Every wp_object has a nullable reference to the shadow structure
      for a file descriptor. As the existence of wayland protocol
      objects is not guaranteed in the face of compositor/application
      misbehavior, when e.g. a wl_buffer is created from a wl_shm_pool,
      the wl_buffer registers a reference to the file descriptor that
      the wl_shm_pool had. Methods that imply a file descriptor change
      (wl_keyboard.keymap, wl_surface.commit) mark the object's referenced
      file descriptor as dirty, so that changes can be transferred.
      
      This commit does not yet implement any deletion logic.
      f73e15a0
  10. 26 May, 2019 1 commit
  11. 25 May, 2019 1 commit
  12. 23 May, 2019 1 commit
  13. 21 May, 2019 1 commit
  14. 20 May, 2019 3 commits
  15. 18 May, 2019 1 commit