Commit Graph

828 Commits

Author SHA1 Message Date
Hugues Evrard
c1eee2851b Merge "Use VK_ANDROID_frame_boundary in HWUI" into sc-dev 2021-03-15 15:28:05 +00:00
Siarhei Vishniakou
adf5024a5d Send metrics notification just before frame advances
Currently, it is possible to notify frame metrics observers that
registered to receive present time about the same frame twice.

This is wasteful, but also requires the metrics listener to guard
against duplicates. See https://b.corp.google.com/issues/169866723#comment23

To avoid this issue, only notify about metrics with present time just
before the frame is advanced to the next position. This ensures that we
are always notifying about the last frame that's about to go away.

Bug: 169866723
Test: added a crash to LatencyTracker for the case where we are notified
about non-existent record. The record disappears once it's complete. So
the first call was completing the record, and the second call was
causing a crash. Now, the crash is gone with this patch.

Change-Id: Ia247b4a0010b8ecb016ac66e44e211ec4f40bf8f
2021-03-11 21:59:15 +00:00
Hugues Evrard
b9510a0a8b Use VK_ANDROID_frame_boundary in HWUI
This extension paves the way to profiling HWUI apps with AGI.

Bug: 181645761
Test: manual

Change-Id: I03ee66832a9013016dc91904962ce54809b198e6
2021-03-09 18:22:32 +00:00
Siarhei Vishniakou
6387cdfb91 Merge "Pass actual present time to ViewRootImpl" into sc-dev 2021-03-08 19:44:12 +00:00
Siarhei Vishniakou
f0cf18d3ed Pass actual present time to ViewRootImpl
To measure end-to-end touch latency, we need to report the actual
present time to ViewRootImpl. ViewRootImpl, in turn, will report this
information to InputDispatcher. Finally, InputDispatcher will combine
all known information for a specific input event, and will report this
data to westworld.

In another patch, we will add a new call, 'reportLatencyInfo', to
InputPublisher. This call will allow the app to send this latency data
to InputDispatcher.

Bug: 169866723
Test: printed the input event present times inside ViewRootImpl
Change-Id: Ibd3a2cfeb1a340eb15cd2165071df1f8589634af
2021-03-05 21:42:32 +00:00
TreeHugger Robot
4379d99c29 Merge "Trace vsync id" into sc-dev 2021-03-05 21:37:02 +00:00
Ady Abraham
150816ce28 Trace vsync id
Add vsync id to the main trace functions.

Test: capture a systrace
Bug: 170914689
Change-Id: If17394d1bd75bf8139e82c88783e89c00a30a167
2021-03-01 17:41:28 -08:00
Greg Daniel
be2803a817 Remove flushAndSubit from SkiaPipeline renderFrame.
Previously we would submit a command buffer for the
frames draws and then immediately submit a second
command buffer that had no commands and just an attached
semaphore. This merges those two submit calls into Skia
into one call.

Test: manual running of system of benches
Bug: 175913056

Change-Id: If0d054960de8b459814cbfa9289756f8ee9d4a93
(cherry picked from commit f16ba60194)
2021-03-01 13:56:45 +00:00
Siarhei Vishniakou
554afe2691 Merge "Add presentTime to FrameInfo" into sc-dev 2021-02-24 20:38:17 +00:00
Jorim Jaggi
33adb57a7b Don't double lock when resetting jank tests
Fixes: 180875541
Test: adb shell dumpsys com.android.systemui reset
Change-Id: Ie656730bbbbb249e6798617cf236b93332e79eb6
2021-02-22 14:27:53 +01:00
Siarhei Vishniakou
4bcbffd584 Add presentTime to FrameInfo
Present time is available to apps, but is not currently stored inside
FrameInfo. In this CL, we add a location for storing the present time inside
FrameInfo.

Currently, the metrics reporter is triggered after the buffer is sent to
SurfaceFlinger. That means, metrics for anything that happens after gpu
draw completes are currently not available.

In a future CL, we will populate the 'presentTime' field.

In a future CL, we will register a metrics observer inside ViewRootImpl
in order to send this data to InputDispatcher. This will enable
end-to-end touch latency metrics collection.

Bug: 169866723
Test: printed present time inside FrameTimeline.cpp (surfaceflinger
side) and compared to the values printed inside a metrics observer
registered in ViewRootImpl (not done in this CL)
Test: atest ViewFrameInfoTest

Change-Id: I7d0f8c5d7b5a2572abdc4e107123e8938a36f582
2021-02-18 22:07:09 +00:00
Jorim Jaggi
71db8892ac Add GPU completion to FrameMetrics (1/3)
- Add SurfaceStatsCallback to TransactionCompletedListener
- Register a callback in RenderProxy to be called when we have
surface stats from SF via the BLAST callback.
- Instead of finishing a frame for frame metrics reporting
immediately, wait until BLAST callback fires, note GPU completion
time and finish frame.
- Expose GPU_COMPLETION in FrameMetrics
- Modify TOTAL_DURATION to also include GPU_COMPLETION

Test: FrameMetricsListenerTest
Fixes: 171046219
Change-Id: I16fa1d80cfc4e7a5527c18fec7e885409f17ee4d
2021-02-17 14:55:22 +01:00
Huihong Luo
5fdf7b8d26 Add SurfaceControl to hwui
add a method, setSurfaceControl, for java layer to pass surface control to the render thread

Bug: 173671170
Test: call setSurfaceControl method in ViewRootImpl.java
Change-Id: I886a79c377938f19cf38b9058f2bec64e1439000
2021-02-16 17:38:12 +01:00
Ady Abraham
aa92c8daf3 Merge "Remove render ahead from hwui" into sc-dev 2021-02-09 22:28:40 +00:00
Greg Daniel
41ef566268 Change CacheManager to not flush and submit at end of trimMemory.
The flush and submit at the start of trim memory now syncs the
cpu so that all work is done on the gpu and the max possible
amount of resources can be freed

This fixes CacheManager unit test since the submit at the end
trim memory was causing new resources to be available to be
purged.

Test: locally ran unit tests
Bug: 178978639
Change-Id: I8b57b042dd146fc6c1083540715295e93fd113d3
(cherry picked from commit 846644a46e)
2021-02-09 13:04:50 +00:00
Ady Abraham
7bb70faa04 Remove render ahead from hwui
As HWUI uses vsync id to send buffers to SF, SF applies the right
amount of render ahead by latching the buffers at the configured time.

Test: launch an app and observe systrace
Bug: 178148035
Change-Id: Ifd3e1a2971aad0a085cb35d33e950194046aa634
2021-02-08 18:13:45 +00:00
John Reck
1aee20138c Merge "Fix render_ahead properties" into sc-dev 2021-02-04 18:29:11 +00:00
John Reck
f516e3a36e Fix render_ahead properties
0 and -1 both meant default when 0 should mean
0 and -1 should mean default

Test: manual
Fixes: 179290765
Change-Id: Ia9aa5e3d83757282bfff776e083d6b3d7d29e9c0
2021-02-03 15:30:05 -08:00
Siarhei Vishniakou
d11f38f6c5 Send input event id to SurfaceFlinger
The application receives input events and produces graphic buffers in
response. We are interested in measuring the total time that the input
event takes to process, from the moment it's received on the device, to
the moment that the image is displayed on the screen.

To do this, we need to understand which input event produced a specific
buffer. In this CL, we are sending the input event id from FrameInfo to
SurfaceFlinger. This event id will later be used to identify a specific
frame, and provide the frame timing information to inputflinger.

Inputflinger will be able to use this information to reconstruct the
complete event timeline, and record metrics on the duration of each
input / graphics processing stage. This will allow us to optimize
end-to-end touch latency.

In the current CL, we are using 'NewestInputEvent' as the inputEventId.
That's not quite correct. Today, this field contains the timestamp of
the input event. Therefore, we will simply pass the truncated
timestamp instead of proper input event id. We will fix this in a
separate CL by providing input event id to FrameInfo.

Design doc: https://docs.google.com/document/d/1G3bLaZYSmbe6AKcL-6ZChvrw_B_LXEz29Z6Ed9QoYXY/edit#
Bug: 169866723
Test: printed input event id at the site of SurfaceFrame creation in
FrameTimeline.cpp

Change-Id: Ia90337bb2f000e9c93a4db04d9dd6ea9ea153520
2021-01-29 18:41:08 +00:00
Alec Mouri
aa3e498bbc Turn on vk unit tests
* Degrade error when changing the rendering backend from Properties to
no longer be fatal.
* Support using a single graphics queue for the Vulkan backend. Cloud
devices only support a single queue and some Vulkan implementations such
as Swiftshader expose only one queue for simplying their implementation,
so we'll need to support one.

Bug: 175618060
Bug: 162628999
Test: hwui_unit_tests
Test: experiment on Pixel 4 enforcing a single queue (settings app,
maps, sysui)

Change-Id: I495fcabc3c89bd62bbb833998eab4944c6660f6f
2021-01-13 14:35:58 -08:00
Alec Mouri
7e7c3d72bc Check if mGrContext exists when requiring a vk context.
Vulkan context is shared with HardwareBitmapUploader and the
RenderThread, meaning if the upload thread runs prior to the render
thread then some configuration is skipped such as recording the max
texture size and cache setup, which affects benchmark tools. So we need
to check whether the GrContext exists in addition to checking if the
shared VkManager has been properly intialized.

Bug: 175913056
Test: hwuimacro works for benchmarks that upload HW bitmaps prior to
benchmark execution. For example: tvapp_norcEglImage

Change-Id: I149c294b39f1e88226fc5d8d72c30bc4fb3d8404
2021-01-06 17:46:22 -08:00
Vishnu Nair
70a8f0ea98 HWUI: Finish frame callbacks before framecomplete callbacks
If returning early from a draw, there is a chance that the frame
complete callbacks can execute before the frame callbacks. To fix
this, explicitly wait on frame callbacks to complete.

Test: Enable blast and test split screen resize
Change-Id: Id0eabd4dacdccbf1ce774efaad51abae7c57d5ea
2020-10-15 11:50:30 -07:00
Ady Abraham
439b20b2c7 Merge "pass frame deadline to Choreographer" 2020-10-13 23:03:55 +00:00
Ady Abraham
dfb13985af pass frame deadline to Choreographer
Pass the frame deadline calculated by SF to Choreographer so
hwui would be able to improve its stats by knowing if a frame is
likely to be late.

Bug: 169858174
Test: manual
Change-Id: Ib9fd93638b54f08d8dc72fa6b023e2dd7c276dc7
2020-10-09 11:17:32 -07:00
Adlai Holler
d2345212d8 Migrate some last instances of GrContext to GrDirectContext
This is a rename with no functional changes.

Change-Id: I4b0b7ee1926b688029e257b35c469113c0404a5b
2020-10-07 22:20:44 +00:00
TreeHugger Robot
b5cb0b58b7 Merge "Fix override setBufferCount" 2020-09-21 23:03:38 +00:00
John Reck
fbe14bbbd3 Fix override setBufferCount
The logic in setBufferCount was still assuming it needed
to inject the extra buffers, however that injection was
already happening in the min_undequeued query. So it was
increasing buffercount by 2x the extraCount, or concretely
5 buffers when it should have been 4 on >75hz devices

Bug: 168928692
Test: Boot coral, verify 4 buffers instead of 5
Change-Id: I0908228a6791d90544fbf4cb21170931bd31a9db
2020-09-21 14:37:41 -07:00
Adlai Holler
ab762153fb Migrate from SkCanvas::getGrContext to SkCanvas::recordingContext
This is part of API cleanup as we make DDL usage more mainstream
in Skia. Since Android doesn't use DDLs, the cast from recordingContext
to directContext will always succeed and there's no functional change.

Change-Id: Ie585cf6c97d01fecf082f146d5692999371fd39d
2020-09-18 14:42:41 +00:00
Ady Abraham
41b5d5a764 Merge "Shared timeline plumbing" 2020-09-17 21:16:25 +00:00
Steven Thomas
6fabb5aa17 Shared timeline plumbing
Add plumbing to get shared timeline data from Surface Flinger to HWUI
and back.

Bug: 162890382
Bug: 162888881
Bug: 162890407

Test: manual using ALOG messages in SF
Change-Id: I85c5eb56d2fa933889518854e7b79b1e65e29af3
2020-09-16 22:58:39 -07:00
Adlai Holler
0375fee9b1 Use SkSurface::recordingContext instead of deprecated getContext
The difference between recording & direct contexts does not matter
to Android right now because they don't use DDLs, so there's no
functional change here.

Change-Id: Iedcdf5c3ce0ccd3c7e1724d8fb45b7882d8c2129
2020-09-15 12:31:22 -04:00
Yiwei Zhang
276d5fc7b1 HWUI: remove the redundant present queue
This change also fixed that the graphics queue should be the one to wait
on upon surface destruction.

Bug: 162628999
Bug: 167693610
Test: no new regressions in CtsUiRenderingTestCases with Vulkan backend
Change-Id: I919748b85b2194bb4f13e1af6950d6493a17921d
2020-09-03 12:07:28 -07:00
Leon Scroggins III
09ea8e370a Remove VulkanManager::mCommandPool
Test: make

This is unused. Splitting out from
I0289938333e2c3dafcc2ce18e72dca3acf4d5b79.

Change-Id: I33eaaa2db86c5d8e3c98c63ba0f6f938e8456cc3
2020-08-20 15:58:27 -04:00
John Reck
e1b982f381 Merge "Fix crash regression when calling setSurface(null)" 2020-08-18 21:50:00 +00:00
John Reck
e95c62d74a Fix crash regression when calling setSurface(null)
Test: HardwareRendererTests#testSetNullSurface
Fixes: 165335939
Change-Id: I8f93a0b6a115088af634e21e91b95b4f6a521f12
2020-08-18 13:21:39 -07:00
Derek Sollenberger
4237d5487b Merge "Share Vulkan resources between RenderThread and HardwareBitmapUploader" 2020-08-18 14:13:02 +00:00
Derek Sollenberger
802fefa881 Share Vulkan resources between RenderThread and HardwareBitmapUploader
The VkInstance and VkDevice are constructs that can be shared between
threads and avoid the extra driver allocations associated with them.

This CL also fixes a bug where Vulkan uploads were occuring on the
thread that invoked the upload and not occuring on the upload thread.

Bug: b/162628999
Test: atest CtsUiRenderingTestCases
Change-Id: I0289938333e2c3dafcc2ce18e72dca3acf4d5b79
2020-08-17 13:22:34 -04:00
Yiwei Zhang
7f43013042 Refactor since EGL_ANDROID_native_fence_sync is exposed via eglQueryString
Bug: 157518032
Test: build, compile, boot
Change-Id: I9dee6d54e290bdd1def44dff1f869581f9583c3e
2020-08-12 15:09:31 -07:00
TreeHugger Robot
eb6d60e5f5 Merge "Revert "libhwui: avoid creating GPU context in Zygote"" 2020-07-31 22:22:22 +00:00
Yiwei Zhang
bf37175044 Revert "libhwui: avoid creating GPU context in Zygote"
The original CL is not needed as HardwareRenderer.preload is not in Zygote but at app launch time.

Bug: 162242036
Change-Id: I41e46e22cb9730b350feb9f6acb2021264a18a97
Test: atest CtsUiRenderingTestCases all pass on GL backend
Test: atest CtsUiRenderingTestCases no regression on VK backend
2020-07-31 21:03:29 +00:00
John Reck
b36bfddb1e Wire-up colorMode="hdr"
Fow now it uses a fixed white point of 150nits
TBD if this is disabled or adjusted

Test: Demo app
Change-Id: Iac13597b3d7633fdef3feaf7ec1da0c27c87904c
2020-07-30 08:54:03 -07:00
TreeHugger Robot
0d958de9d3 Merge "libhwui: avoid creating GPU context in Zygote" 2020-07-28 20:50:31 +00:00
Yiwei Zhang
12259e59c4 libhwui: avoid creating GPU context in Zygote
Creating GPU context besides loading the GPU driver would potentially
affect graphics driver updatability. Currently, we always preload
graphics drivers in Zygote to speed up app startup time. Upon using
updatable driver, we'll unload the current driver and load the uploaded
one. Although the symbol table is fully protected by the linkerconfig we
setup in Android 10, we still have to make sure the driver has a clean
state upon unloading and reloading.

At this moment, Vulkan driver unloading has not been supported yet. So
if we are going to turn on skia Vulkan backend by default, we should
avoid preloading the Vulkan driver until the unloading feature is
supported for Vulkan.

Bug: 162242036
Bug: 135536511
Test: atest CtsUiRenderingTestCases all pass on GL backend
Test: atest CtsUiRenderingTestCases no regression on VK backend
Change-Id: I9084586315a7593be2cfe17710620aacce568d36
2020-07-28 09:52:14 -07:00
Adlai Holler
f8c434eb7a Migrate from GrContext to GrDirectContext
This is part of an effort to distinguish between different types of
contexts in GPU Skia. When using a DeferredDisplayList (DDL)
recorder, the context you get is not a direct context and cannot
be used for operations like uploading or reading textures.

Since Android does not use DDLs, it is not directly affected by this
change but other APIs, such as SkImage::MakeFromTexture are
being migrated to require a GrDirectContext to increase sanity.

Change-Id: I9afbdf3c026a9f9cb6ad2aad904915e189e584d6
2020-07-28 09:18:33 -04:00
Alec Mouri
9c9df934cb Merge "Correctly expose EGL_ANDROID_native_fence_sync to hwui" 2020-07-06 21:20:14 +00:00
Alec Mouri
49d87e5c07 Correctly expose EGL_ANDROID_native_fence_sync to hwui
When we moved off of gui/SyncFeatures for retrieving this extension, we
accidentally didn't include the eglQueryStringImplementationANDROID path
for retrieving extensions. Fortunately this extension is only used for
TextureView synchronization, but we should still use the extension when
available.

Bug: 159921224
Test: Manually inject log statements to verify the extension is
correctly visible.

Change-Id: Idaa872778afc13e86bdea918da8631b4747fe9c1
2020-06-29 16:58:02 -07:00
John Reck
aa4c982294 Remove legacy callDrawGlFunction2 from HWUI
Bug: 151439970
Test: CtsUiRenderingTestCases passes

Change-Id: I1c29df17bb6e8b078467edf73cb3547db6948cdd
2020-06-26 13:49:05 -07:00
Greg Daniel
01b0f4701d Remove old GrFlushFlag for cpu sync which isn't used anymore.
Test: manual
Change-Id: Ib362f228c18b6c452e66debe6f6f076451670cd7
2020-06-24 14:58:28 -04:00
John Reck
b51641316c Merge "Revert "Drop max texture cache size from 12x to 5x"" into rvc-dev am: 556fe0b9e5 am: 6bf4b6b216 am: aeae81a937 am: 3844f2a385
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11838959

Change-Id: I7f9db598d3051993c1fc58b35ffd2d84527842ad
2020-06-16 20:49:02 +00:00
Leon Scroggins
30d3678734 Revert "Drop max texture cache size from 12x to 5x"
Bug: 155002050
Test: Manual - scroll Pchome app

This reverts commit 05ac516412.

Reason for revert: When running Pchome, this change resulted in poor
performance while scrolling. Every frame appears to be uploading
several textures, potentially the same textures over and over again.

Change-Id: I0fc7216e16f783051d1bd87af764c1a6f361c138
2020-06-11 17:24:47 +00:00