1. 16 Apr, 2020 4 commits
    • Jonas Ådahl's avatar
      onscreen/native: Add API to check whether buffer is scanout compatible · b9fe9c73
      Jonas Ådahl authored
      While this is fairly incomplete, as to check things fully we need to use
      TEST_ONLY in atomic to try out a complete assignment on the device, but
      this works well enough for legacy non-modifier cases.
      
      !798
      b9fe9c73
    • Jonas Ådahl's avatar
      renderer/native: Add API to get primary GPU · 3dd8861f
      Jonas Ådahl authored
      Will be used when acquiring scanouts from Wayland buffers.
      
      !798
      3dd8861f
    • Jonas Ådahl's avatar
      cogl/onscreen: Add API to scanout a buffer directly · 3da8c1bf
      Jonas Ådahl authored
      Instead of always swapping buffers and flipping the back buffer, make it
      possible to scan out a provided buffer directly without swapping any EGL
      buffers.
      
      A buffer is passed as an object implementing the empty CoglScanout
      interface. It is only possible to do this in the native backend; and the
      interface is implemented by MetaDrmBufferGbm. When directly scanned out,
      instead of calling gbm_surface_lock_front_buffer() to get the gbm_bo and
      fbid, get it directly from the MetaDrmBufferGbm, and use that to create
      the page flip KMS update.
      
      !798
      3da8c1bf
    • Jonas Ådahl's avatar
      drm-buffer/gbm: Support both surface and standalone buffers · 282aada1
      Jonas Ådahl authored
      Surface buffers are created with meta_drm_buffer_new_acquire(), taking a
      gbm_surface acquiring the gbm itself, and meta_drm_buffer_new_take()
      that takes over ownership of a passed gbm_bo.
      
      !798
      282aada1
  2. 15 Apr, 2020 1 commit
    • Jonas Ådahl's avatar
      renderer-native: Use CRTC layout in stage view · bc350f37
      Jonas Ådahl authored
      The port to per CRTC views was incomplete; we still used the logical
      monitor layout as the stage view layout, while still using one view per
      CRTC.
      
      This worked fine for most cases, e.g. regular monitors, tiled or
      non-tiled, transformed or non-transformed. Where it broke, however, was
      when a monitor consists of multiple CRTCs. We already have the layout a
      CRTC corresponds to on the stage kept with the CRTC metadata, so use
      this directly.
      
      Closes: #1170
      
      !1199`
      bc350f37
  3. 26 Mar, 2020 1 commit
    • Jonas Ådahl's avatar
      cogl: Install cogl-trace.h and include from cogl.h · 238e41d4
      Jonas Ådahl authored
      This is so that cogl-trace.h can start using things from cogl-macros.h,
      and so that it doesn't leak cogl-config.h into the world, while exposing
      it to e.g. gnome-shell so that it can make use of it as well. There is
      no practical reason why we shouldn't just include cogl-trace.h via
      cogl.h as we do with everything else.
      
      !1059
      238e41d4
  4. 18 Mar, 2020 1 commit
  5. 28 Feb, 2020 2 commits
  6. 25 Feb, 2020 4 commits
    • Jonas Ådahl's avatar
      renderer-native: Draw stage separately per CRTC · 1c98f01a
      Jonas Ådahl authored
      Prior to this commit the stage was drawn separately for each logical
      monitor. This allowed to draw different parts of the stage with
      different transformations, e.g. with a different viewport to implement
      HiDPI support.
      
      Go even further and have one view per CRTC. This causes the stage to
      e.g. draw two mirrored monitors twice, instead of using the same
      framebuffer on both. This enables us to do two things: one is to support
      tiled monitors and monitor mirroring using the EGLStreams backend; the
      other is that it'll enable us to tie rendering directly to the CRTC it
      will render for. It is also a requirement for rendering being affected
      by CRTC state, such as gamma.
      
      It'll be possible to still inhibit re-drawing of the same content
      twice, but it should be implemented differently, so that it will still
      be possible to implement features requiring the CRTC split.
      
      !1042
      1c98f01a
    • Jonas Ådahl's avatar
      renderer-native: Fix a couple of style misses · e3f30371
      Jonas Ådahl authored
      Removed stray newline, and fixed an incorrect indentation.
      
      !1042
      e3f30371
    • Jonas Ådahl's avatar
      crtc: Move configured state to separate struct · fe42d56d
      Jonas Ådahl authored
      To make it more reliable to distinguish between values that are read
      from the backend implementation (which is likely to be irrelevant for
      anything but the backend implementation), split out those values (e.g.
      layout).
      
      This changes the meaning of what was MetaCrtc::rect, to a
      MetaCrtcConfig::layout which is the layout the CRTC has in the global
      coordinate space.
      
      !1042
      fe42d56d
    • Jonas Ådahl's avatar
      logical-monitor: Pass monitor in the for each CRTC helper callback · 7f6cafa8
      Jonas Ådahl authored
      Will be used in later commits.
      
      !1042
      7f6cafa8
  7. 20 Feb, 2020 2 commits
  8. 11 Feb, 2020 1 commit
  9. 16 Jan, 2020 8 commits
    • Pekka Paalanen's avatar
      renderer/native: Import primary buffer to 2nd GPU · b6c824dd
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      Where possible, try to export the buffer rendered by the primary GPU as a
      dmabuf and import it to the secondary GPU and turn it into a DRM FB for
      scanout. If this works, we get a zero-copy path to secondary GPU outputs.
      
      This is especially useful on virtual drivers like EVDI (used for DisplayLink
      devices) which are not picky at all about what kind of FBs they can handle.
      
      The zero-copy path is prioritised after the secondary GPU copy path, which
      should avoid regressions for existing working systems. Attempting zero-copy
      would have the risk of being less performant than doing the copy on the
      secondary GPU. This does not affect the DisplayLink use case, because there is
      no GPU in a DisplayLink device.
      
      The zero-copy path is prioritised before the primary GPU and CPU copy paths. It
      will be tried on the first frame of an output and the copy path is executed
      too. If zero-copy fails, the result from the copy path will take over on that
      frame. Furthermore, zero-copy will not be attemped again on that output. If
      zero-copy succeeds, the copy path is de-initialized.
      
      Zero-copy is assumed to be always preferable over the primary GPU and CPU copy
      paths. Whether this is universally true remains to be seen.
      
      This patch has one unhandled failure mode: if zero-copy path first succeeds and
      then fails later, there is no fallback and the output is left frozen or black.
      
      !810
      b6c824dd
    • Pekka Paalanen's avatar
      backend/native: Share drmModeAddFB code · 03ac7b18
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      With all the three paths this is quite a handful of code, and it was mostly
      duplicated in two places. A follow-up patch would need to introduce a third
      copy of it. Therefore move the code into a helper function.
      
      There are two behavioral changes:
      
      - The format error now prints the string code as well, because it is easy to
        read.
      
      - The g_debug() in init_dumb_fb() is removed. Did not seem useful.
      
      !810
      03ac7b18
    • Pekka Paalanen's avatar
      renderer/native: Extract secondary_gpu_release_dumb · f409dddb
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      There will be another place where I need to release the dumb buffers but not
      destroy the whole secondary_gpu_state, so extract this bit of code into a
      helper.
      
      The checks of fb_id are dropped as redundant with the check already in in
      release_dumb_fb ().
      
      !810
      f409dddb
    • Pekka Paalanen's avatar
      renderer/native: Reset all fields of MetaDumbBuffer · fe76e6a2
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      release_dumb_fb () checks 'map' to see if anything needs freeing. Other places
      are checking fb_id instead. The checks maybe redundant, but let's reset all
      fields here while at it, so that all the checks work as expected.
      
      !810
      fe76e6a2
    • Pekka Paalanen's avatar
      renderer/native: Absorb free_next_secondary_bo · 40408150
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      The function is trivial and only used once, so fold it into the caller.
      
      Makes the code more readable by removing a little bit of boilerplate.
      
      !810
      40408150
    • Pekka Paalanen's avatar
      renderer/native: Copy mode irrelevant for bo freeing · fea6abb4
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      Simplify the bo freeing functions by not checking what the copy mode is. This
      matches what swap_secondary_drm_fb () already does. g_clear_object () is safe
      to call even if the value is already NULL.
      
      The copy mode does not change mid-operation. If it did, this change would
      ensure we still clean up everything. So this is more future-proof too.
      
      !810
      fea6abb4
    • Pekka Paalanen's avatar
      renderer/native: META_DRM_BUFFER is not NULL-safe · 94992fff
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      I could not find this in GObject documentation, but I hear the cast macro is
      not safe to call with NULL.
      
      !810
      94992fff
    • Pekka Paalanen's avatar
      renderer/native: state consistency in copy_shared_framebuffer_gpu · d7c9042c
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      To mirror what happens in meta_onscreen_native_swap_buffers_with_damage(), warn
      here too if next_fb is not NULL. This makes it clear to the reader of what the
      expectations are inside this function.
      
      Ensuring next_fb is NULL as the first thing in the function will make all error
      paths equal: no longer some failures reset next_fb while others don't. Removing
      such special cases should reduce surprises.
      
      !810
      d7c9042c
  10. 22 Nov, 2019 1 commit
  11. 04 Nov, 2019 1 commit
    • Olivier Fourdan's avatar
      renderer-native: Separate offscreen and shadowfb · 60800d23
      Olivier Fourdan authored
      Create the intermediate shadow framebuffer for use exclusively when a
      shadowfb is required.
      
      Keep the previous offscreen framebuffer is as an intermediate
      framebuffer for transformations only.
      
      This way, we can apply transformations between in-memory framebuffers
      prior to blit the result to screen, and achieve acceptable performance
      even with software rendering on discrete GPU.
      
      !877
      60800d23
  12. 30 Sep, 2019 1 commit
    • Jonas Ådahl's avatar
      Revert "renderer-native: Actually use shadow fb when using software rendering" · 7049b2f2
      Jonas Ådahl authored
      It was not the lack of forcing the shadow fb that caused slowness, but
      rather due to the method the shadow fb content was copied onto the
      scanout fb. With 'clutter: Use cogl_blit_framebuffer() for shadow FB'
      we'll use a path that shouldn't be slow when copying onto the scanout
      fb.
      
      Also 437f6b3d accidentally enabled
      shadow fb when using hw accelerated contexts, due to the cap being set
      to 1 in majority of drivers. While the kernel documentation for the
      related field says "hint to userspace to prefer shadow-fb rendering",
      the name of the hint when exposed to userspace is
      DRM_CAP_DUMB_PREFER_SHADOW, thus should only be taken into consideration
      for dumb buffers, not rendering in general.
      
      This reverts commit 437f6b3d.
      
      !818
      7049b2f2
  13. 27 Sep, 2019 1 commit
    • Jonas Ådahl's avatar
      renderer-native: Actually use shadow fb when using software rendering · 437f6b3d
      Jonas Ådahl authored
      The commit 'renderer/native: Use shadow fb on software GL if preferred'
      attempted to force using a shadow fb when using llvmpipe in order to
      speed up blending, but instead only did so when llvmpipe AND the drm
      device explicityl asked for it.
      
      Now instead always force it for llvmpipe and other software rendering
      backends, and otherwise just query the drm device (i.e.
      DRM_CAP_DUMB_PREFER_SHADOW).
      
      !807
      437f6b3d
  14. 12 Sep, 2019 1 commit
  15. 31 Aug, 2019 1 commit
  16. 18 Jul, 2019 2 commits
  17. 10 Jul, 2019 4 commits
    • Pekka Paalanen's avatar
      renderer/native: Debug for primary copy mode · a95644db
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      COPY_MODE_PRIMARY has two paths, automatically chosen. For debugging purposes,
      e.g. why is my DisplayLink screen slowing down the whole desktop, it will be
      useful to know which copy path is taken. Debug prints are added to both when
      the primary GPU copy succeeds the first time and when it fails the first time.
      
      This is not the full truth, because theoretically the success/failure could
      change every frame, but we don't want to spam the logs (even in debug mode)
      every frame. In practise, it should be rare for the success or failure to ever
      change. Hence, saying what happened on the first time is enough. This does
      indicate if it ever changes even once, too, so we know if that unexpected thing
      happens.
      
      The debug prints are per secondary GPU since there could be several.
      
      !615
      a95644db
    • Pekka Paalanen's avatar
      renderer/native: Add tracing for 2nd GPU copies · 720f3632
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      These traces allow seeing how long the copy operations stall in libmutter, and
      which copy operations actually get used.
      
      !615
      720f3632
    • Pekka Paalanen's avatar
      renderer/native: Use primary GPU to copy · 3794df60
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      When the preferred path META_SHARED_FRAMEBUFFER_COPY_MODE_SECONDARY_GPU cannot
      be used, as is the case for e.g. DisplayLink devices which do not actually have
      a GPU, try to use the primary GPU for the copying before falling back to
      read-pixels which is a CPU copy.
      
      When the primary GPU copy works, it should be a significant performance win
      over the CPU copy by avoiding stalling libmutter for the duration.
      
      This also renames META_SHARED_FRAMEBUFFER_COPY_MODE_* because the new names are
      more accurate. While the secondary GPU copy is always a GPU copy, the primary
      copy might be either a CPU or a GPU copy.
      
      !615
      3794df60
    • Pekka Paalanen's avatar
      renderer/native: Add meta_dumb_buffer_ensure_dmabuf_fd · 2c893bef
      Pekka Paalanen authored and Jonas Ådahl's avatar Jonas Ådahl committed
      Follow-up work will use this in an attempt to use the primary GPU to
      copy into secondary GPU dumb buffers.
      
      !615
      2c893bef
  18. 27 Jun, 2019 3 commits
  19. 20 Jun, 2019 1 commit
    • Jonas Ådahl's avatar
      backend/native: Add and use transactional KMS API · 75dff3e7
      Jonas Ådahl authored and Georges Basile Stavracas Neto's avatar Georges Basile Stavracas Neto committed
      This commit introduces, and makes use of, a transactional API used for
      setting up KMS state, later to be applied, potentially atomically. From
      an API point of view, so is always the case, but in the current
      implementation, it still uses legacy drmMode* API to apply the state
      non-atomically.
      
      The API consists of various buliding blocks:
      
       * MetaKmsUpdate - a set of configuration changes, the higher level
      handle for handing over configuration to the impl backend. It's used to
      set mode, assign framebuffers to planes, queue page flips and set
      connector properties.
       * MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
      Currently used to map a framebuffer to the primary plane of a CRTC. In
      the legacy KMS implementation, the plane assignment is used to derive
      the framebuffer used for mode setting and page flipping.
      
      This also means various high level changes:
      
      State, excluding configuring the cursor plane and creating/destroying
      DRM framebuffer handles, are applied in the end of a clutter frame, in
      one go. From an API point of view, this is done atomically, but as
      mentioned, only the non-atomic implementation exists so far.
      
      From MetaRendererNative's point of view, a page flip now initially
      always succeeds; the handling of EBUSY errors are done asynchronously in
      the MetaKmsImpl backend (still by retrying at refresh rate, but
      postponing flip callbacks instead of manipulating the frame clock).
      Handling of falling back to mode setting instead of page flipping is
      notified after the fact by a more precise page flip feedback API.
      
      EGLStream based page flipping relies on the impl backend not being
      atomic, as the page flipping is done in the EGLStream backend (e.g.
      nvidia driver). It uses a 'custom' page flip queueing method, keeping
      the EGLStream logic inside meta-renderer-native.c.
      
      Page flip handling is moved to meta-kms-impl-device.c from
      meta-gpu-kms.c. It goes via an extra idle callback before reaching
      meta-renderer-native.c to make sure callbacks are invoked outside of the
      impl context.
      
      While dummy power save page flipping is kept in meta-renderer-native.c, the
      EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
      frame clock, actual page flip callbacks are postponed until all EBUSY retries
      have either succeeded or failed due to some other error than EBUSY. This
      effectively inhibits new frames to be drawn, meaning we won't stall waiting on
      the file descriptor for pending page flips.
      
      #548
      !525
      75dff3e7