Skip to content
Snippets Groups Projects
  1. Dec 28, 2023
    • Leon Scroggins III's avatar
      SF: Update present timing per display · 370b8b52
      Leon Scroggins III authored
      Calculate presentation timing info (i.e. expected- and earliest-
      PresentTime) separately for each display, since they are generally not
      in sync. This allows SF to present each display at the proper time,
      using tools that are already in use for the pacesetter display.
      
      CompositionRefreshArgs:
      - Replace earliest- and expected- PresentTime with a map of
        FrameTargets which hold the times.
      
      Output:
      - Retrieve appropriate times from the relevant FrameTarget.
      - Note: Since HAL virtual displays do not have a FrameTarget, they now
        are provided with the default expected (0) and earliest (nullopt)
        -PresentTimes. This is fine, since these times are irrelevant for
        a virtual display. Previously, they simply used the pacesetter's
        times.
      - Trace the expected present time.
      
      Scheduler:
      - Compute the expectedPresentTime aka expectedVsyncTime for follower
        displays via the next VSYNC after the pacesetter's
        expectedPresentTime. TODO (b/256196556): The "followers" should
        follow the frontrunner, not the pacesetter.
      
      SurfaceFlinger:
      - Populate CompositionRefreshArgs' map of FrameTargets.
      
      For now, continue using the same scheduledFrameTime for all follower
      displays. This is only used as a deadline for determining whether to
      render a CachedSet. Adjusting it per follower would make us more likely
      to render more CachedSets per frame, and we need a more holistic
      approach for caching anyway.
      
      Bug: 255601557
      Bug: 256196556
      Bug: 259132483
      Test: perfetto traces
      Change-Id: I2c27dc709afd1f33bddbf9c2ca1cd61dd335f66c
      370b8b52
  2. Dec 15, 2023
    • Huihong Luo's avatar
      Update HDCP for external displays · 9ebb7a72
      Huihong Luo authored
      So the secure flag of Display object in Display Manager (DM) can
      be set correctly. HWC calls the onSync method as a workaround,
      to notify SurfaceFlinger (SF) about hdcp changes, SF in turn sends
      an event to DM, DM will then fetch and update display info.
      
      Bug: 280818362
      Test: manual
      Change-Id: I29ce0337865b51c0fc7bf7c2d7fdd4cd6d66ef46
      9ebb7a72
  3. Dec 06, 2023
    • Alec Mouri's avatar
      Support fp16 in sf · f97df4d8
      Alec Mouri authored
      * Make sure we don't dim SDR in renderengine, and instead map HDR to the
        correct relative luminance above 1.0
      * Plumb the HDR/SDR ratio into HWC
      
      Bug: 236745178
      Test: builds
      Change-Id: I325972a01280d287189d38dd6c5bf7f2d4b776bb
      f97df4d8
  4. Dec 05, 2023
    • Chavi Weingarten's avatar
      Add isProtected flag to Output · 18fa7c60
      Chavi Weingarten authored
      Allow outputs to decide if they want to render protected content, not
      just if they support it. The current code checks if the Output is secure
      when deciding whether to render protected content. By adding a new flag,
      it will allow displays to decide if they want to render secure,
      protected, or both.
      
      This code doesn't have a way to create displays with only protected and
      will still rely on the isSecure flag to ensure backwards compatibility.
      
      Test: presubmit
      Fixes: 285553970
      Fixes: 300492271
      Change-Id: If5e65388825d37f4ddaea5190259a136cfa89264
      18fa7c60
  5. Nov 29, 2023
  6. Nov 21, 2023
    • Leon Scroggins III's avatar
      Offload present to a separate thread · 2f60d735
      Leon Scroggins III authored
      Make Output::present() return an ftl::Future. When offloading its
      HWC call, present will return a future that can be waited upon.
      
      In CompositionEngine::present, store a vector of futures and wait
      upon the results before returning. This allow's HWC's present to run in
      parallel with other work; in particular, present on other displays.
      Waiting here ensures that post-composition work does not start until
      present has completed. Future work may defer this even later.
      
      Reuse HwcAsyncWorker to run present on a separate thread. Add a new
      variable for determining whether to run validate in parallel, since the
      presence of the HwcAsyncWorker could just mean that we are offloading
      present.
      
      Read the new DisplayCapability to determine whether a display can be
      offloaded to a worker thread. Only run displays in parallel if they all
      have the DisplayCapability. Non HWC-enabled displays without the
      capability do not prevent other displays from being offloaded. They also
      run last, since they can run in parallel with HWC-enabled displays.
      (The ordering is now set by SurfaceFlinger, which places physical
      displays at the start of the list of outputs.)
      
      When telling a display to offload its present call, make it only last
      for a single frame. This simplifies the code while ensuring we do not
      leave it enabled unnecessarily.
      
      Leave a single present call on the main thread. This saves a thread-hop,
      while still allowing it to run in parallel with other HWC work.
      
      Only attempt to offload present if the appropriate trunk stable flag (or
      debug sysprop, "debug.sf.multithreaded_present") is set.
      
      Bug: 241285491
      Bug: 259132483
      Test: manual: perfetto trace
      Test: libcompositionengine_test
      Change-Id: Ib9d074671e32c95875ef7e0791dd95d6e595e47a
      2f60d735
  7. Nov 16, 2023
  8. Nov 09, 2023
  9. Nov 07, 2023
    • Leon Scroggins III's avatar
      SF: Rename `postFramebuffer` for clarity · c1623d11
      Leon Scroggins III authored
      The "post" in "postFramebuffer" can be read as a preposition or a verb,
      making the name less easy to understand. Furthermore, "framebuffer" is
      typically used in the context of GPU composition, but this function
      involves DPU composition.
      
      Rename to "presentFrameAndReleaseLayers" to better describe what it
      does. While we're at it, shorten "presentAndGetFrameFences" to simply
      "presentFrame".
      
      Splitting out from original motivating discussion in
      Ib9d074671e32c95875ef7e0791dd95d6e595e47a.
      
      Bug: 241285491
      Bug: 259132483
      Test: No new behavior; no new tests
      Change-Id: I41df1d0b98c34eaffe44c5c29006356964c555a6
      c1623d11
  10. Oct 06, 2023
    • Vishnu Nair's avatar
      Clean up duplicate shadow lengths in layer snapshot · d9e4f46c
      Vishnu Nair authored
      The shadow length is currently tracked in both the LayerFE
      CompositionState and the shadow settings, which are used by the
      RenderEngine. We can consolidate these fields and track shadow
      settings in the LayerFE CompositionState. This makes sense because
      we want the LayerFE CompositionState to contain all relevant
      information that it can pass to the RenderEngine without calling
      back into the frontend.
      
      Bug: 302551905
      Test: presubmit
      
      Change-Id: I583c43993cf73784c6fec9ec2d40f2c76d21adeb
      d9e4f46c
  11. Aug 17, 2023
  12. Aug 02, 2023
    • Huihong Luo's avatar
      Generate texture pool asynchronously · 56866118
      Huihong Luo authored
      This improves performance by moving allocateHelper to a different
      thread, which is launched early so that the allocation is ready when
      it is needed. In addition, each display will only need at most one
      additional texture per frame, so replace the idea of a minimum pool
      with making sure there is either at least one texture in the pool
      or a future which will generate one.
      
      Bug: 256184546
      Test: atest libcompositionengine_test
      Change-Id: Icb92a85c07b9f2911d1365aa9bbc8d0750a8c116
      Merged-In: Icb92a85c07b9f2911d1365aa9bbc8d0750a8c116
      56866118
  13. Jul 25, 2023
    • Alec Mouri's avatar
      Remove the concept of target dataspace · 88790f34
      Alec Mouri authored
      This is only needed for configuring colorspace agnostic dataspaces, but
      no device does that. For colorspace agnostic layers, it's sufficient to
      just use the colormode dataspace, with the possible exception of HDR
      where we can preserve some bespoke logic, so we can just get rid of
      target dataspaces and any associated plumbing.
      
      Bug: 292162273
      Test: builds
      Test: libsurfaceflinger_unittest
      Test: libcompositionengine_test
      Change-Id: I319bb354e80e3ad1eaaacd896b897e6696f96588
      88790f34
  14. Jul 24, 2023
    • Huihong Luo's avatar
      Generate texture pool asynchronously · bfcc6102
      Huihong Luo authored
      This improves performance by moving allocateHelper to a different
      thread, which is launched early so that the allocation is ready when
      it is needed. In addition, each display will only need at most one
      additional texture per frame, so replace the idea of a minimum pool
      with making sure there is either at least one texture in the pool
      or a future which will generate one.
      
      Bug: 256184546
      Test: atest libcompositionengine_test
      Change-Id: Icb92a85c07b9f2911d1365aa9bbc8d0750a8c116
      bfcc6102
  15. Jun 21, 2023
    • jimmyshiu's avatar
      Send load up hint for cache rendering · 4e211773
      jimmyshiu authored
      cache buffer rendering supposes to utilize the cpu gap after current
      frame finised and before the next frame. But it could take long and
      delay the next frame start time and cause jank eventually.
      Sending CPU LOAD UP hint to prevent stealing time from the next frame.
      
      Bug: 285991802
      Test: PtsUiBench QHD
      Change-Id: Id619a8166ae253fef815a25a35fc4b82066144a9
      4e211773
  16. Apr 19, 2023
    • Vishnu Nair's avatar
      [sf] Release the currently presented buffer when setBuffer is called · 7ee4f464
      Vishnu Nair authored
      with null
      
      Fixes a regression introduced in T which ignores a setBuffer call
      with a null buffer. The expected behavior should be to release the
      currently presented buffer from surfaceflinger. The subsequent frame
      will not present this layer so the region behind the layer will be
      composited instead.
      
      Bug: 241271897
      Test: presubmit
      Change-Id: Ie06025c59c58cc75a267b783729996a3cbceef45
      7ee4f464
  17. Mar 28, 2023
    • Ady Abraham's avatar
      SF: avoid skipping waiting for the earliest time to present · f1db8031
      Ady Abraham authored
      When the next expected presentation time is not allocated for
      the previous frame, SF needs to wait before submitting it to HWC
      to prevent early presentation.
      
      Bug: 273419557
      Test: tested by partner
      Test: atest ASurfaceControlTest
      Change-Id: Ia83755bbc71968369fd9176944b9a85135d8a04a
      f1db8031
  18. Mar 24, 2023
  19. Feb 24, 2023
    • Vishnu Nair's avatar
      SF: Frontend fixes for issues surfaced by SurfaceFlinger_test · d47bceea
      Vishnu Nair authored
      - separate color and bgcolor in layer state so we don't set a color
       on a layer without a buffer
       - avoid using legacy layer state when latching a buffer
       - fix callback issue where invisible or offscreen layers were not invoking
       the callbacks
       - pass in layer snapshot for trusted presentation state
       - fix a screenshot issue where the root layer was skipped
       - pass in framerate changes to layer history
      
      Test: presubmit
      Test: atest SurfaceFlinger_test with new fe
      Bug: 238781169
      
      Change-Id: Id9ff8a036dc283e21a05985c1c01ebd070b1df24
      d47bceea
  20. Feb 17, 2023
    • Alec Mouri's avatar
      Add CachingHint into SurfaceFlinger · f4af03ed
      Alec Mouri authored
      Some system layers may need to be excluded from surfaceflinger caching
      for a variety of reasons, including power or image quality
      considerations. This provides a mechanism for those system layers to
      never be cached on the GPU.
      
      Bug: 259311918
      Test: libcompositionengine_test
      Test: run test app and inspect planner state
      Change-Id: I35418ad5a41cb2546e3b27b0af290bf3c31a0180
      f4af03ed
  21. Feb 10, 2023
    • Chavi Weingarten's avatar
      Some fixes to TrustedPresentationListener · 545da0e1
      Chavi Weingarten authored
      1. Ignore display overlays since we don't want screen decorations
         included in the occlusion
      
      2. Handle occluded region as separate Rects to ensure that disconnected
         Rects in a Region are not considered occluding in the disconnected
         area.
      
      Test: LayerTrustedPresentationListenerTest
      Bug: 256993331
      Change-Id: Ib0a4b850e2aafb42e206b8728fcc9b6013171f3f
      545da0e1
  22. Jan 31, 2023
    • Patrick Williams's avatar
      SF: clean up texture filtering logic · 278a88f6
      Patrick Williams authored
      * Removes redundant logic for determining whether or not SurfaceFlinger should request texture filtering.
      * Fixes an issue where ScreenCaptureOutput was using incorrect values for its layer stack projection space.
      
      Bug: 238348307
      Test: atest TextureFilteringTest
      
      Change-Id: I4ece87321ee73d10b86a2c01d53717d337c11926
      278a88f6
  23. Jan 25, 2023
  24. Dec 21, 2022
    • Brian Lindahl's avatar
      Uncache the active buffer slot last · 3e1e1e69
      Brian Lindahl authored
      This allows the memory for the active buffer to be freed as soon as
      possible by purging it from HWC cache as soon as the next buffer is sent
      to the layer.
      
      Bug: 258196272
      Test: atest OutputLayerUncacheBufferTest
      Change-Id: I96c24390de5757ac99b369119e9ba031afb0b042
      3e1e1e69
  25. Dec 17, 2022
    • Brian Lindahl's avatar
      Maintain the active buffer when clearing buffer slots · b158a5c5
      Brian Lindahl authored
      When an app discards graphic buffers, for example when a MediaCodec
      disconnects from a surface, those buffers will be uncached and removed
      from HWC buffer slots. The active buffer, however, should still remain
      active until the next buffer is queued up.
      
      Bug: 262037933
      Bug: 258196272
      Test: atest OutputLayerUncacheBufferTest
      Test: atest VtsHalGraphicsComposer3_TargetTest
      Test: atest VtsHalGraphicsComposerV2_2TargetTest
      Change-Id: I7c4eefb17e8bad694d698f9ad6d1d289f4af8d2c
      b158a5c5
  26. Dec 15, 2022
    • Brian Lindahl's avatar
      Clear HWC layer buffer slots by assiging a placeholder buffer · 90553da7
      Brian Lindahl authored
      When buffers are discarded by SurfaceFlinger clients, the memory should
      be free'd immediately. This includes clearing references to them from
      within the implementation of Composer HAL, specifically in cache slots
      associated with the layer.
      
      Since there is no HAL API to clear the slot directly, prior to writing
      any other buffer to the layer, we set the layer's buffer multiple times
      to a placeholder buffer, using each of the slot numbers that need to be
      cleared. This replaces the reference to the client-discarded buffer
      inside Composer HAL with a reference to the placeholder buffer, causing
      the reference count to drop, allowing the buffer memory to be freed.
      
      Bug: 258196272
      Test: atest OutputLayerUncacheBufferTest
      Change-Id: Id85482e8859490566f0eedbd8d8729c47a7349fb
      90553da7
  27. Dec 09, 2022
    • Brian Lindahl's avatar
      Push HWC cache slot generation down into CompositionEngine · 439afadf
      Brian Lindahl authored
      Stop caching buffers inside SurfaceFlinger and remove the tight coupling
      between SurfaceFlinger's ClientCache and the Hardware Composer cache.
      This allows a better seperation of responsibility, where buffer cache
      management is not split between HwcSlotGenerator and HwcBufferCache, but
      is instead solely handled by HwcBufferCache.
      
      Note that FramebufferSurface and VirtualDisplaySurface no longer use
      HwcBufferCache, but instead use their own cache slot management that
      is solely based on BufferQueue slot numbers.
      
      Also do minor refactoring in FramebufferSurface to simplify code.
      
      Bug: 258196272
      Test: started and stopped multiple YouTube videos on adt4 and verified
      no change in graphic buffer usage
      Test: atest HwcBufferCacheTest
      Test: atest OutputPrepareTest
      
      Change-Id: Ica7955ab4bc70e3c70207390e36dff73a2fc4949
      439afadf
  28. Nov 17, 2022
  29. Nov 11, 2022
    • Leon Scroggins III's avatar
      Add display name and id to traces · 5a655b8d
      Leon Scroggins III authored
      On a multi-display device, it is helpful to know which display
      particular methods are called for. Add information to traces specifying
      the name and id of the display. The device still needs to specify
      different names for displays (see b/254851304), but the traces will now
      show the id, which is helpful until the device is updated, at which
      point the names will be immediately helpful.
      
      Output:
      - Store a string that combines the readable name and the DisplayId. This
        saves allocation costs for the various places where we add this info
        to the trace.
      - Print the name and id in present and postFramebuffer. Although
        postFramebuffer is called by present, future CLs will move it to a
        separate thread, and this allows tracking which call applies to which
        display.
      DisplaySettings:
      - Add a field with the display name and id. This allows SkiaRenderEngine
        to print them as well.
      SkiaRenderEngine:
      - Print the name and id in drawLayersInternal
      - Replace the outdated text for the function name referring to the class
        as "SkiaGL" with a simple call to __func__.
      Display:
      - Print the name and id in chooseClientCompositionStrategy, which may
        also run in another thread.
      
      Bug: 241285473
      Test: manual; look at traces
      Change-Id: I3081c4e4a7b5874139af6b5dd74a6a8ab0ad8cf7
      5a655b8d
  30. Nov 09, 2022
  31. Nov 03, 2022
    • Patrick Williams's avatar
      CE: Make TimeStats nullable · 74c0bf65
      Patrick Williams authored
      This CL allows CE instances without TimeStats. This will be used by the
      short lived CE instances created in the upcoming renderScreenImpl
      refactor.
      
      Bug: 238643986
      Test: presubmits
      Change-Id: I7f996f3ce660b335f6228069aa04bba617806b68
      74c0bf65
  32. Oct 31, 2022
    • Patrick Williams's avatar
      SF: Change RenderEngine ownership · 0a525a45
      Patrick Williams authored
      This change allows multiple instances of CompositionEngine to use
      the same RenderEngine instance which enables creating new instances of
      CompositionEngine to run off the main thread. This will be used in the
      refactor of SurfaceFlinger::renderScreenImpl to generate LayerSettings
      via CompositionEngine.
      
      Bug: 238643986
      Test: presubmits
      
      Change-Id: I0c8dc30e091578d0d77afb434a52038db6e82288
      0a525a45
  33. Oct 13, 2022
    • Vishnu Nair's avatar
      SF: Split FE and CE · e14c6b35
      Vishnu Nair authored
      Make LayerFE a standalone class with no links back to Layer. Pass
      LayerSnapshot from Layer into LayerFE before CompositionEngine::present
      and back after.
      
      Bug: 238781169
      Test: go/wm-smoke
      Test: presubmit
      
      Change-Id: I5395fb717a931f88e2bf26395acd21e8b308961e
      e14c6b35
  34. Oct 04, 2022
    • Chavi Weingarten's avatar
      Don't queue buffer if nothing new to draw in Display · a722b816
      Chavi Weingarten authored
      The current logic only checks if dirty is not empty, but doesn't account
      for no content changing. Instead use the same logic that's in
      beginFrame to compute mustRecompute and use that when determining if the
      display should queue a buffer.
      
      This fixes an issue where a Displays first few frames could be black
      until the content is loaded.
      
      Bug: 239888440
      Test: First frame from screenrecord is no longer black
      Change-Id: Ibb568302bf2d50db167a1f9ca76a0f37e2c65bf5
      (cherry picked from commit 09fa1d66)
      a722b816
  35. Sep 29, 2022
    • Vishnu Nair's avatar
      CE: Snapshot layer metadata · 0a4fb001
      Vishnu Nair authored
      Adds LayerMetadata to LayerSnapshots. LayerMetadata is only populated
      when CE enables the new feature flag and the feature flag will only be
      enabled in ARC++'s CE.
      
      This change is necessary to split LayerFE from the Layer class as
      ARC++'s LayerFE subclass accesses LayerMetadata.
      
      Bug: 238781169
      Test: go/wm-smoke
      Test: presubmit
      
      Change-Id: Iae405707897eedf5af9025fe628c1cd60b596e10
      0a4fb001
  36. Sep 13, 2022
    • Vishnu Nair's avatar
      CE: Update layer composition state outside of CE · ba354103
      Vishnu Nair authored
      First step in breaking CE dependencies with frontend.
      FE should provide a snapshot of the state for CE to
      consume. This cl updates the composition state
      based on whether visible regions are dirty before
      calling into composition engine.
      
      Test: presubmit
      Test: go/wm-smoke
      Bug: 238781169
      Change-Id: I6efd71cf66d9e1cae163c98ad4ce3097e09848af
      ba354103
  37. Sep 09, 2022
    • joenchen's avatar
      CE: flush the staged brightness to HWC before power off · e72ba5e2
      joenchen authored
      After SurfaceFlinger receives the brightness commands, the commands are
      sent to HWC until the next frame presents. However, no following frames
      are present after the power mode is set to off, and HWC cannot receive
      the last brightness commands.
      
      This change forces SurfaceFlinger to flush the staged brightness to HWC
      prior to execution of power off.
      
      Bug: 239908529
      Test: suspend and resume repeatedly
      Change-Id: Ia8fb04399e757de16e06e6516d86bdfcfabd5a2e
      e72ba5e2
  38. Aug 25, 2022
    • Chavi Weingarten's avatar
      Don't queue buffer if nothing new to draw in Display · 09fa1d66
      Chavi Weingarten authored
      The current logic only checks if dirty is not empty, but doesn't account
      for no content changing. Instead use the same logic that's in
      beginFrame to compute mustRecompute and use that when determining if the
      display should queue a buffer.
      
      This fixes an issue where a Displays first few frames could be black
      until the content is loaded.
      
      Bug: 239888440
      Test: First frame from screenrecord is no longer black
      Change-Id: Ibb568302bf2d50db167a1f9ca76a0f37e2c65bf5
      09fa1d66
Loading