summaryrefslogtreecommitdiff
path: root/libs/renderengine/tests/RenderEngineThreadedTest.cpp
AgeCommit message (Collapse)Author
2021-07-01Enable RenderEngine context switching to be async.Derek Sollenberger
Also in the case of a threaded RenderEngine we can avoid the thread hop entirely by quickly returning if the GPU is already in the correct state. Bug: 192099706 Test: atest librenderengine_test Change-Id: I316096ffd89960a1d3742edacdeb442626e9ee3e
2021-06-15Defer deleting ExternalTextures that go out of scope during DrawLayersDerek Sollenberger
Some buffers (e.g. protected content) are not pre-mapped into a texture. Their textures are created in drawLayers and go out of scope at the end of drawLayers drawLayers when those temporary textures are sent to the GPU. This CL ensures that in those cases we defer unbinding and deleting the temporary texture until the cleanupPostRender method is called. Also to avoid unecessary thread hops into cleanupPostRender this CL also adds a thread-safe check to see if cleanup is necessary. Finally, we also make the threaded variant asynchronous to further improve the availability of SurfaceFlinger. Bug: 190628682 Bug: 191132989 Test: atest librenderengine_test and perfetto traces Change-Id: Ic2f4384cd1957c928a0ef656a98eb0041e29622c
2021-04-16Revert "Revert "Add ExternalTexture class into RenderEngine inte..."Alec Mouri
Revert submission 14199598-revert-14086921-renderengine-external-tex-QJNBWQMQEU Reason for revert: Prepare for relanding Reverted Changes: I01e65a7f4:Revert "Update WaylandRenderSurface to accomodate ... I7d58118c1:Revert "Update Readback VTS to align with RenderEn... I1501890f4:Revert "Add ExternalTexture class into RenderEngin... Added the following fixes: 1. CachedSet renders to intermediate texture variable rather than mTexture directly, since mTexture is not guaranteed to be nonnull. 2. Add null check when setting new buffer in BLAST. Bug: 185524947 Bug: 180767535 Test: builds, boots Test: librenderengine_test Change-Id: I52ea82e24336b496d996bbe3e445db0affe1abb8
2021-04-15Revert "Add ExternalTexture class into RenderEngine interface"Alec Mouri
Revert submission 14086921-renderengine-external-tex Reason for revert: Potential culprit for b/185361988 Reverted Changes: I7796764e2:Update WaylandRenderSurface to accomodate interfac... I13904eec4:Update Readback VTS to align with RenderEngine int... I222c71e6e:Add ExternalTexture class into RenderEngine interf... Change-Id: I1501890f4861a3df7ce273f1fe2ccdb275e2632c
2021-04-13Add ExternalTexture class into RenderEngine interfaceAlec Mouri
ExternalTexture is an RAII structure that wraps raw GraphicBuffers that are passed into RenderEngine. ExternalTexture's role is to help with managing GPU resources of GraphicBuffers by mapping buffers into textures, EGLImages, or AutoBackendTextures depending on the RenderEngine backend. Under the hood, mapExternalTextureBuffer and unmapExternalTextureBuffer (renamed from cacheExternalTextureBuffer and unbindExternalTextureBuffer respectively) are used to help tie resource management to the ExternalTexture lifetime. The main motivation for this is that currently managing buffer lifecycle has historically been errorprone and caused memory leaks, so this improves code health. As part of this: * mapExternalTextureBuffer and unmapExternalTextureBuffer are now protected methods, and are never called outside of RenderEngine with the exception of creating and destroying ExternalTextures. * Because GLESRenderEngine's output buffers are cached differently from Skia RenderEngine, if there are output-only buffers then disable the mapExternalTextureBuffer calls whenever GLESRenderEngine is used. * Custom RAII classes in the Planner and in BufferLayerConsumer are now removed since they're subsumed by ExternalTexture * RenderSurface now controls its own management of ExternalTextures in a small queue * cleanFramebufferCache is now unimplemented for Skia, because ExternalTextures are now deleted whenever a RenderSurface is deleted. Bug: 180767535 Test: libsurfaceflinger_unittest Test: libcompositionengine_test Test: librenderengine_test Test: Simulate virtual displays Test: Screen reotation Test: Movie playback on Google TV Test: Force GPU composition Test: screenshot Change-Id: I222c71e6e1c67485cdeac49e2cb829289af9efec
2021-04-13Improve performance for certain queries/functions in REThreaded.Derek Sollenberger
Some queries into RE were already thread safe, but now they are documented as such and avoid jumping to another thread. Additionally all void method in REThreaded are executed in an async strategy. Test: librenderengine_test Bug: 184243497 Change-Id: Id04bcccf2c90acc3e6cb6f7716f9629639b757b7
2021-02-26Dispatch texture destruction off of render thread for screenshotsAlec Mouri
This is only enabled when the skia threaded variant renderengine is enabled. This essentially defers texture deletion until after drawLayers() is invoked, which shaves off time from the main SF thread. Bug: 179959621 Bug: 180767535 Test: perfetto trace Change-Id: I333091d8792fdd0dc01076c73af2956da9ee73df
2021-02-18Enable RenderEngine blur testing on more devices.Derek Sollenberger
Test: atest renderengine_test Bug: 176903027 Change-Id: I85e3a561548506bd9cab1a6c8f7e15c47fbff960
2021-01-20Caching images and textures for threaded Skia REAna Krulec
Skia also performs texture generation and deletion when we create an image. This needs to happen on the same thread. Running Skia on it's own thread, will allow async caching of images, and hopefully increasing the start up/transition of application. Screenshot of the parallel caching: https://screenshot.googleplex.com/BUnne3urcoavykk Test results for DisplayOrientationMicrobench test for SFSTATS_GLOBAL_RENDER_ENGINE_DURATION_AVG metric: skiathreaded 1st run: 5.750296 ms skia threaded 2nd run: 5.530306 ms gles: 4.974821 ms skia: 6.374791 ms Test: Set renderengine backend to 'skiathreaded'. - run libsurfaceflinger_test, SurfaceFlinger_test - open apps - switch between apps Bug: 175312877 Change-Id: I6521f9ddfadff8c839bdd7071c2bd6cfadebb663
2020-09-14Remove unused codeAlec Mouri
* Remove BufferLayer::bindTextureImage * Remove RenderEngine::bindExternalTextureBuffer. In particular, this function was legacy back from 2012 around when SurfaceTexture was forked into SurfaceFlinger. By now there's been some architectural changes, including Treble enforcement of a process boundary between SF and HWC, meaning that the "implicit synchronization" no longer really makes sense to enforce. Bug: 168553972 Test: builds Test: Cuttlefish boots, can interact without visual artifacts. Change-Id: I259160ccc6cc02fe3ac0d9b5edc4c1c72d3d582f
2020-09-03Remove some private methods from RenderEngineJohn Reck
Moved some methods that are only used as an implementation detail of GLESRenderEngine out of RE's main header Test: builds Change-Id: Ib157082df23615b8c95a8aede9cd0ded093c8948
2020-08-13Toggle for RenderEngine to cleanup texture memory.Alec Mouri
Currently RenderEngine does not rebind texture memory after it is done drawing, so buffers may not be freed until the corresponding texture is deleted. For SurfaceFlinger this is more acceptable since layers tend to reuse buffers and they own their own texture name, so it's more natural to implicitly tie memory lifecycle to layer lifecycle since the buffers won't need to be free until the layer is deleted anyways. But for mediaserver it's not acceptable, since thumbnail generation is rare and texture generation is expensive, so if we don't clean up texture resources properly then mediaserver hangs on to a video frame until the next time a thumbnail is generated, which is very bad for HDR frames since it's a multi-megabyte overhead. This patch will solve this for mediaserver by adding a toggle to cleanupPostRender. It's likely that SurfaceFlinger can benefit from this as well since rebinding memory is fast, but more investigation would be needed to see if that is the case, and this patch is less risky to be applied to other branches. Bug: 162202251 Test: librenderengine_test Test: Launch custom apk with thumbnail generation Test: adb shell dumpsys meminfo mediaserver Change-Id: Iec7f65c4911b5cbf2189fa33929bbcfa97bb4c14
2020-05-12RenderEngineThreaded takes a function as an argument to createAna Krulec
In order to simplify testing and implementation of threaded RE, RenderEngineThreaded::create can takes a std::function argument to call to create the RE instance. RenderEngineThreaded::threadMain then call the function. - RenderEngine::create() uses it to create the production instance. - The test uses it to create the mock instance. Test: Unit tests Change-Id: Ic1af134979d4449c34d9ad86d07673367eb16896
2020-05-12Creating a threaded version of the Render Engine.Ana Krulec
This class contains a thread. Each time a function of this class is called, we create a lambda function that is put on a queue. The main thread then executes the functions in order. In V1, all elements are passed by reference, and the main thread blocks on the execution of this thread. In the future iterations, the lambda makes copies of elements that should exist regardless of what happens to the thread that calls into this thread. go/speculative-render-engine for more info. Test: Activate blur. Collect systrace. Test: Open Chrome. Collect systrace. Test: atest RenderEngineThreadedTest Bug: 155929501 Change-Id: I246c6c1abb77a4c96c0867e722757326f8069b16