Commit Graph

82 Commits

Author SHA1 Message Date
Greg Daniel
d667077899 Make sure to close vulkan fd's in error cases
In one set of the fixed cases we actually were never closing the
fd. In the other set we would crash with a fatal error. Now both
have been updated to handle the failures and correctly close the
fd to make sure it all works.

However, I don't think this is the route case of the leaking fds
from the bug since I don't believe we are seeing any of the
corresponding error messages in the logs.

Test: Manual running on phone and watching logs.
Bug: 187240173
Change-Id: I18babe91b0ec83ca63199f06d3d02ec10e8aea85
2021-06-09 12:11:49 -04:00
rnlee
ce9762b57f Use TraceUtils.h from gui shared library.
Test: It makes
Bug: 183120308
Change-Id: I331262dd2da59817031f0c708f4c102041dcb5e0
2021-05-22 00:12:43 +00:00
Greg Daniel
1d9de71ed9 Add a mutex to VulkanManager::initialize.
The initialize call can be made from both an GrallocUploadThread
and the RenderThread. So we need a mutex to make sure both
threads don't try to initialize in parallel.

Bug: 187218890
Test: manual running of device, guessing this could fix bug.
Change-Id: I203afd91fad5eacc131c839dff1a1065864b76f8
2021-05-14 10:42:34 -04: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
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
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
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
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
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
Greg Daniel
c7ad4080ba Update skia flush call APIs.
Test: manual
Change-Id: I72fa57b04f1b4ea594063ddb4ce6af9507b1fcdb
2020-05-14 15:38:26 -04:00
Jagadeesh Pakaravoor
b624af3dca Revert^2 "hwui: remove FatVector"
Revert submission 10449863-revert-fatvector

Reason for revert: b/149254345

Original change (of introducing FatVector) was reverted as a stop-gap solution to fix the aforementioned bug.

The bug was caused by an ABI lock between Surface's definition (that changed with Region) and lib-imsvt prebuilt.

Enabling this change now as we have re-compiled the prebuilt with the change enabled. Doing that via a revert of the revert.

Reverted Changes:
I8ac66acb8:Revert "hwui: remove FatVector"
Ib60dbf3ef:Revert "libui: rewrite Region with FatVector"

Original changes:
I09dc2fddd:hwui: remove FatVector
I265c6c831:libui: rewrite Region with FatVector

bug: 149254345

Change-Id: I9fb5e8908434abb9a763992e922445a2dc37e865
2020-05-01 15:57:15 +00:00
Tim Murray
894f132ba0 Revert "hwui: remove FatVector"
Revert "libui: rewrite Region with FatVector"

Revert submission 10248126-fatvector-region

Reason for revert: b/149254345
Reverted Changes:
I09dc2fddd:hwui: remove FatVector
I265c6c831:libui: rewrite Region with FatVector

also fix wrong license in FatVector.h

Test: boots
Bug: 149254345

Change-Id: I8ac66acb8b635324051edd41c5d4092c223157ff
2020-03-05 12:15:40 -08:00
Tim Murray
0865f2e7b2 hwui: remove FatVector
FatVector now lives in fw/native/libs/ui.

Test: builds, boots, works
Bug: 149096186
Change-Id: I09dc2fddd2a238ef47d7853b64b0bfbf74d3f71f
2020-02-07 17:57:44 +00:00
Stan Iliev
aaa9e834d4 Decouple SurfaceTexture from HWUI
Remove all Skia and HWUI types from SurfaceTexture
implementation.
Move SurfaceTexture to libgui (ag/9578265).
Define private C++ API for SurfaceTexture, which is consumed
by DeferredLayerUpdater.
Move AutoBackendTextureRelease/Skia code from SurfaceTexture
to HWUI.

Test: pass CtsUiRenderingTestCases and CtsViewTestCases
Bug: 136263580
Change-Id: I3f971bb490f64a3ac0b2a66a89ba935bf7f08213
2019-11-08 15:37:17 +00:00
Yiwei Zhang
0b9f0b81bc HWUI-VK: remove duplicate GET_DEV_PROC
Test: build, flash and boot
Change-Id: Ia3b62c5d31952f85664f1926584fc9438d48dec3
2019-08-15 11:33:59 -07:00
Alec Mouri
6db59a66bd [HWUI] clean up libgui include directives
As a first pass removing some stale includes.

Bug: 138819035
Change-Id: I7aef319aa8f1b13b6482ef61fda151560e570558
Test: builds
2019-08-02 18:02:50 -07:00
Yiwei Zhang
bd363c94ff HWUI-VK: Decouple hwui Vulkan backend from Vulkan WSI APIs
1. Android support all transforms as exposed by client composition.
2. Properly exposing min/max image size is tracked in http://b/134182502.
3. Current image size and max buffer count are cached in Surface already.
4. Remove surface support check since hwui does not have YUV + CPU consumer.
5. Since HWUI must require those image usage flags, just use them directly,
   and those are always supported by Vulkan driver and enforced by cts.

Bug: 136110987
Test: CtsUiRenderingTestCases and CtsGraphicsTestCases
Change-Id: I89bd9afb69a46e3deca09890ce6348c6b61edddf
2019-06-26 17:10:28 -07:00
Greg Daniel
9f3966356b Merge "Make sure we don't delete VkSemaphores before exporting in VulkanManager" 2019-05-18 12:30:48 +00:00
Greg Daniel
fd4293962c Make sure we don't delete VkSemaphores before exporting in VulkanManager
Test: Manual building and testing on device to confirm error messages
are gone.

Bug: b/132358913
Change-Id: I0e22df5eb3bc61a7dd84d87db9a4f67756ecd5ae
2019-05-15 14:19:16 -04:00
Greg Daniel
13a31b2648 Merge "Remove workaround in VulkanSurface for missing vendor flag." into qt-dev 2019-05-14 21:32:29 +00:00
Greg Daniel
cdfc90231c Remove workaround in VulkanSurface for missing vendor flag.
Test: manual building and testing
Bug: b/128923272
Change-Id: I6be67fddbbf06d4eb7efe316f7e6fd12157e2852
2019-05-14 09:25:41 -04:00
Greg Daniel
d92a9b158e Fix deletion of VkSemaphores in VulkanManager.
We were deleting the VkSemaphore objects too quickly when
importing/exporting the semaphores. Even though the semaphore payload
gets reset on these operations the VkSemaphore still needs to be
finished its use in Vulkan before being deleted.

Test: manual build and testing of vulkan apps and vulakn ImageConsumer
Bug: b/130643604
Change-Id: I7f03087e477d812c0174ede3a10f12dc1df72ee1
2019-04-23 14:36:37 -04:00
John Reck
0fa0cbcade Support render-ahead in vulkan
Bug: 127822449
Test: verified render_ahead working with skiavk
Change-Id: Iae1b227a763f6def035057f38cca4b0ab65c7e82
2019-04-12 13:33:25 -07:00
Greg Daniel
2173f1890c Add workaround for qualcomm vulkan AHDARDWAREBUFFER_USAGE_VENDER_0
Test: manual building and testing on device. Bugs related to lack of
flag go away.
Bug: 128923272
Change-Id: I2457988c097d73020162947c346a8716d373185e
2019-04-02 13:21:28 +00:00
TreeHugger Robot
b51fda1bc3 Merge "Invalidate Skia shader cache if Vulkan driver has changed" 2019-04-01 16:49:26 +00:00
Stan Iliev
bf99c4450b Invalidate Skia shader cache if Vulkan driver has changed
Test: Ran apps several time and observed shader cache validation
Change-Id: I7c2620b9a0eefcb7acedc86647ecf44805518b2f
2019-03-29 11:18:21 -04:00
Stan Iliev
bc5f06bdaa Fix crash after dequeueNativeBuffer fails
Anytime dequeueNativeBuffer fails, it sets mDequeuedIndex to -1.
This is causing a crash latter, when getCurrentSkSurface tries
to index mNativeBuffers[mDequeuedIndex].
This CL removes mDequeuedIndex and improves Vulkan swapchain
error handling.

Test: Ran Camera app
Bug: 129024275
Change-Id: Ieeb685c3a1b33f23ce2334d286199a44ace53165
2019-03-26 15:14:34 -04:00
Stan Iliev
197843d031 Block GPU on dequeue fence only if it has not signalled already
When Vulkan pipeline dequeues next frame at the beginning of
DrawFrame, the dequeue fence has been signalled in most cases.
This CL avoids additional work and saves about 0.3ms per frame.
There is no need to create VkSemaphore and commit an empty command
buffer to the queue if the fence has already signalled.

Bug: 128998567
Test: Ran systrace on SelfieCity and observed better performance
Change-Id: I3532b785fae90308d922a29f1698f5dbcbd79079
2019-03-21 12:25:08 -04:00
Stan Iliev
3e99fa7a27 Block GPU on release fence from dequeueBuffer earlier
If dequeueBuffer fence has not fired yet, then submit to the queue
and block GPU on VkSemaphore immediatelly.
It is not clear why this CL makes a difference, because semaphore
was already waited on.

Fixes: 128805387
Fixes: 128806388
Fixes: 128807485
Fixes: 128879779
Fixes: 128417453
Bug: 128998567
Test: Ran SelfieCity, Camera360, Settings app
Change-Id: I880ba6fa65509ba4c6faca0dc933551efcee423b
2019-03-21 12:21:08 -04:00
John Reck
09e2fbe605 Merge "Remove old TaskManager system" 2019-03-18 20:31:22 +00:00
John Reck
322b8ab774 Remove old TaskManager system
Replace it with a newer, fancier, WorkQueue-inspired
one that's just a global common thread pool.

Test: hwuiunit passes
Change-Id: Ib5d03104a08bbac9a4ec67a1bfc0db2b35d6700f
2019-03-18 09:34:11 -07:00
TreeHugger Robot
f296a878bf Merge "Copy extension names to an owning container to prevent use-after-free" 2019-03-12 03:58:01 +00:00
Roman Kiryanov
74ace839e0 Copy extension names to an owning container to prevent use-after-free
Bug: 127660235
Test: make -j
Change-Id: I3748b7b4b51f99acf59748675223cef02c22bee2
Signed-off-by: Roman Kiryanov <rkir@google.com>
2019-03-11 16:07:20 -07:00
Derek Sollenberger
a19b71a54a Directly manage buffer presentation in Vulkan using AHardwareBuffers.
Instead of relying on Vulkan swapchains this CL enables HWUI to directly
manage the native window.  This allows us to preallocate buffers using
our own strategy as well as having no longer having to jump through an
unecessary translation layer that resulted in code that was hard to
reason about and also introduced inefficiencies.

Bug: 123541940
Bug: 119687951
Test: CtsUiRenderingTestCases and CtsGraphicsTestCases
Change-Id: I7e5930748795e7ca4a998ab2c608c3c9b6363037
2019-03-08 09:25:35 -05:00
Stan Iliev
7e733366fc Add ability to change context priority of RT Vulkan queues
Test: Pixel 3 does not support VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME
Bug: 126595186
Change-Id: I4b2e9c6d5f92665fd2274d0aabf4b012a7a29f46
2019-02-28 13:16:36 -05:00
Stan Iliev
898123b6a3 Start RenderThread earlier to preload Vulkan/EGL drivers
This CL should fix application startup regression for Vulkan
detected by "Hermetic Startup: EmptyActivity" test.
EGL drivers are loaded in a temp thread to leave more time
in RenderThread for other work. Loading EGL drivers
on the RenderThread may cause a perf regression.

Test: Ran cold-dropcache-test test.
Bug: 122659224
Bug: 123361175
Change-Id: I8ca818e98fac196a41d079be15594caca5cb1bab
2019-02-20 02:10:52 +00:00
Stan Iliev
981afe773a Decouple VulkanManager from RenderThread
This CL allows for more than one VulkanManager to exist.
VulkanManager ctor are public allowing for classes other
than RenderThread to instantiate it.
Secondary VulkanManager can be used to render on a thread
other than RT.

Test: Ran HWUI unit tests and several apps
Change-Id: Ibfd76c86ff67e01617a500902bba7431b928f5c0
2019-02-13 15:55:45 -05:00
Stan Iliev
90276c8621 Fix crash when VulkanSurface is no longer valid
SkiaVulkanPipeline::mVkSurface can become obsolete if
RenderThread destroys Vulkan context. This CL enables
RenderThread to notify active Vulkan pipelines that their
surface is invalid.
Improve error handling, when trying to draw a frame with null
VulkanSurface.

Bug: 123640274
Bug: 123541940
Test: Ran several apps
Change-Id: If7fba00713d097192c96179df36e90b54f4f8090
2019-02-04 11:51:20 -05:00
Greg Daniel
eaf310e1ce Update Vulkan skia creation to use apiVersion instead of instanceVersion
This updates to use Skia's new api which takes the vulkan apiVersion
instead of the instance version. This is technically more correct since
the application apiVersion is really the only client modifiable version
value in vulkan.

This change also updates the webview structs to use the apiVersion as
well.

Test: manual build and testing.
Change-Id: I6ce7c20949eb7242f7bbe69955b54c0785696891
2019-01-29 15:03:10 -05:00
Brian Osman
e0cf597556 Remove use of SkColorSpace::Gamut enum
Get the gamut matrix from the color space, compare against sRGB/P3.

Test: Refactoring CL.
Change-Id: I9f5bcae8c1f637919ee9da892266ea882f16208c
2019-01-24 16:05:05 +00:00
Greg Daniel
c407678982 Add support for preTransform in Vulkan swapchain.
Test: manual building and running of apps.
Bug: 110985606
Bug: 122662274
Change-Id: Id53aa1ce028b448b1f12558eec78a60e09512166
2019-01-18 18:56:44 +00:00
Bo Liu
7b8c1eb302 VkFunctorDrawable implementation
Bug: 115613038
Test: Turning on vulkan with appropriate webview apk does not crash and
sort of works.
Change-Id: If1504da7a35e4bd74a994ab2c2a351e6bc415a18
2019-01-15 15:25:04 -08:00
Peiyong Lin
3bff135503 [HWUI] Remove hardcoding around wide color gamut.
Previously we hardcode wide color gamut in HWUI as scRGB color space with FP16
pixel format. However, the hardware composer doesn't support this combination.
This patch plumbs wide color gamut composition preference from composer API to
HWUI such that HWUI can now pick the combination of color space and pixel
format for the surface.

BUG: 111436479
Test: Build, flash and boot, verify with a demo app.
Change-Id: I7a8b4d8deca72ef40069dba9d23a3f5e90dbfe5a
2018-12-15 09:35:25 -08:00
Stan Iliev
bc46258527 Fix temporary stretching when Surface is resized with Vulkan
Set NATIVE_WINDOW_SCALING_MODE_FREEZE scaling mode on the surface
after Vulkan swapchain is created. This is the scaling mode used
by GL as well. Window resize flow depends on preserving this
behavior, because SurfaceComposerClient::Transaction::setSize
calls are not postponed until a new buffer is enqueued.

Test: StatusBar is resized correctly without any glitch.
Bug: 118501234
Change-Id: Icfb6805bc362a742e14b993a0b825e5447d6eeb4
2018-12-10 21:54:58 +00:00
TreeHugger Robot
163e42ca59 Merge "Prefer using 3 buffers in vulkan swapchain." 2018-12-05 02:44:32 +00:00
Greg Daniel
4d5bf2a0f5 Prefer using 3 buffers in vulkan swapchain.
Test: manual build and running.
Bug: 119687951

Change-Id: I799955d8e035d01acb991417e95e424848fe711f
2018-12-04 19:50:38 +00:00
Stan Iliev
987a80c0ca Set color space on Vulkan render target surface
Test: Pass UiRendering tests with Vulkan pipeline
Bug: 116117654
Bug: 111436479
Change-Id: Id58a8a93c6f311402273b1a9e3606c9732f55aec
2018-12-04 11:23:21 -05:00
Greg Daniel
050361732a In VulkanManager enable ycbcr feature on VkDevice.
Test: manual build and test

Change-Id: I820670ee7566e1dd5c86cfa473725b91e4eb6154
2018-11-29 16:42:52 -05:00