Loading PREUPLOAD.cfg +1 −0 Original line number Diff line number Diff line Loading @@ -41,3 +41,4 @@ dumpstate_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD dumpsys_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "^cmds/dumpsys/" # bugreports matches both cmds/bugreport and cmds/bugreportz bugreports_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "^cmds/bugreport" binder_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "^libs/binder/" libs/binder/tests/binderRpcTest.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -464,7 +464,9 @@ TEST_P(BinderRpc, ThreadPoolOverSaturated) { constexpr size_t kNumThreads = 10; constexpr size_t kNumCalls = kNumThreads + 3; auto proc = createRpcTestSocketServerProcess({.numThreads = kNumThreads}); testThreadPoolOverSaturated(proc.rootIface, kNumCalls, 250 /*ms*/); // b/272429574 - below 500ms, the test fails testThreadPoolOverSaturated(proc.rootIface, kNumCalls, 500 /*ms*/); } TEST_P(BinderRpc, ThreadPoolLimitOutgoing) { Loading @@ -477,7 +479,9 @@ TEST_P(BinderRpc, ThreadPoolLimitOutgoing) { constexpr size_t kNumCalls = kNumOutgoingConnections + 3; auto proc = createRpcTestSocketServerProcess( {.numThreads = kNumThreads, .numOutgoingConnections = kNumOutgoingConnections}); testThreadPoolOverSaturated(proc.rootIface, kNumCalls, 250 /*ms*/); // b/272429574 - below 500ms, the test fails testThreadPoolOverSaturated(proc.rootIface, kNumCalls, 500 /*ms*/); } TEST_P(BinderRpc, ThreadingStressTest) { Loading libs/gui/tests/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,9 @@ cc_test { compile_multilib: "both", header_libs: ["libsurfaceflinger_headers"], data: [ ":libgui_test", ], } cc_test { Loading libs/renderengine/skia/SkiaRenderEngine.cpp +23 −29 Original line number Diff line number Diff line Loading @@ -395,10 +395,14 @@ void SkiaRenderEngine::mapExternalTextureBuffer(const sp<GraphicBuffer>& buffer, mRenderEngineType != RenderEngineType::SKIA_VK_THREADED) { return; } // We currently don't attempt to map a buffer if the buffer contains protected content // because GPU resources for protected buffers is much more limited. // We don't attempt to map a buffer if the buffer contains protected content. In GL this is // important because GPU resources for protected buffers are much more limited. (In Vk we // simply match the existing behavior for protected buffers.) In Vk, we never cache any // buffers while in a protected context, since Vk cannot share across contexts, and protected // is less common. const bool isProtectedBuffer = buffer->getUsage() & GRALLOC_USAGE_PROTECTED; if (isProtectedBuffer) { if (isProtectedBuffer || (mRenderEngineType == RenderEngineType::SKIA_VK_THREADED && isProtected())) { return; } ATRACE_CALL(); Loading Loading @@ -461,6 +465,20 @@ void SkiaRenderEngine::unmapExternalTextureBuffer(sp<GraphicBuffer>&& buffer) { } } std::shared_ptr<AutoBackendTexture::LocalRef> SkiaRenderEngine::getOrCreateBackendTexture( const sp<GraphicBuffer>& buffer, bool isOutputBuffer) { // Do not lookup the buffer in the cache for protected contexts with the SkiaVk back-end if (mRenderEngineType == RenderEngineType::SKIA_GL_THREADED || (mRenderEngineType == RenderEngineType::SKIA_VK_THREADED && !isProtected())) { if (const auto& it = mTextureCache.find(buffer->getId()); it != mTextureCache.end()) { return it->second; } } return std::make_shared<AutoBackendTexture::LocalRef>(getActiveGrContext(), buffer->toAHardwareBuffer(), isOutputBuffer, mTextureCleanupMgr); } bool SkiaRenderEngine::canSkipPostRenderCleanup() const { std::lock_guard<std::mutex> lock(mRenderingMutex); return mTextureCleanupMgr.isEmpty(); Loading Loading @@ -651,21 +669,11 @@ void SkiaRenderEngine::drawLayersInternal( validateOutputBufferUsage(buffer->getBuffer()); auto grContext = getActiveGrContext(); auto& cache = mTextureCache; // any AutoBackendTexture deletions will now be deferred until cleanupPostRender is called DeferTextureCleanup dtc(mTextureCleanupMgr); std::shared_ptr<AutoBackendTexture::LocalRef> surfaceTextureRef; if (const auto& it = cache.find(buffer->getBuffer()->getId()); it != cache.end()) { surfaceTextureRef = it->second; } else { surfaceTextureRef = std::make_shared<AutoBackendTexture::LocalRef>(grContext, buffer->getBuffer() ->toAHardwareBuffer(), true, mTextureCleanupMgr); } auto surfaceTextureRef = getOrCreateBackendTexture(buffer->getBuffer(), true); // wait on the buffer to be ready to use prior to using it waitFence(grContext, bufferFence); Loading Loading @@ -904,21 +912,7 @@ void SkiaRenderEngine::drawLayersInternal( ATRACE_NAME("DrawImage"); validateInputBufferUsage(layer.source.buffer.buffer->getBuffer()); const auto& item = layer.source.buffer; std::shared_ptr<AutoBackendTexture::LocalRef> imageTextureRef = nullptr; if (const auto& iter = cache.find(item.buffer->getBuffer()->getId()); iter != cache.end()) { imageTextureRef = iter->second; } else { // If we didn't find the image in the cache, then create a local ref but don't cache // it. If we're using skia, we're guaranteed to run on a dedicated GPU thread so if // we didn't find anything in the cache then we intentionally did not cache this // buffer's resources. imageTextureRef = std::make_shared< AutoBackendTexture::LocalRef>(grContext, item.buffer->getBuffer()->toAHardwareBuffer(), false, mTextureCleanupMgr); } auto imageTextureRef = getOrCreateBackendTexture(item.buffer->getBuffer(), false); // if the layer's buffer has a fence, then we must must respect the fence prior to using // the buffer. Loading libs/renderengine/skia/SkiaRenderEngine.h +5 −1 Original line number Diff line number Diff line Loading @@ -133,6 +133,8 @@ private: void unmapExternalTextureBuffer(sp<GraphicBuffer>&& buffer) override final; bool canSkipPostRenderCleanup() const override final; std::shared_ptr<AutoBackendTexture::LocalRef> getOrCreateBackendTexture( const sp<GraphicBuffer>& buffer, bool isOutputBuffer) REQUIRES(mRenderingMutex); void initCanvas(SkCanvas* canvas, const DisplaySettings& display); void drawShadow(SkCanvas* canvas, const SkRRect& casterRRect, const ShadowSettings& shadowSettings); Loading Loading @@ -167,7 +169,9 @@ private: // Number of external holders of ExternalTexture references, per GraphicBuffer ID. std::unordered_map<GraphicBufferId, int32_t> mGraphicBufferExternalRefs GUARDED_BY(mRenderingMutex); // Cache of GL textures that we'll store per GraphicBuffer ID, shared between GPU contexts. // For GL, this cache is shared between protected and unprotected contexts. For Vulkan, it is // only used for the unprotected context, because Vulkan does not allow sharing between // contexts, and protected is less common. std::unordered_map<GraphicBufferId, std::shared_ptr<AutoBackendTexture::LocalRef>> mTextureCache GUARDED_BY(mRenderingMutex); std::unordered_map<shaders::LinearEffect, sk_sp<SkRuntimeEffect>, shaders::LinearEffectHasher> Loading Loading
PREUPLOAD.cfg +1 −0 Original line number Diff line number Diff line Loading @@ -41,3 +41,4 @@ dumpstate_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD dumpsys_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "^cmds/dumpsys/" # bugreports matches both cmds/bugreport and cmds/bugreportz bugreports_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "^cmds/bugreport" binder_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "^libs/binder/"
libs/binder/tests/binderRpcTest.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -464,7 +464,9 @@ TEST_P(BinderRpc, ThreadPoolOverSaturated) { constexpr size_t kNumThreads = 10; constexpr size_t kNumCalls = kNumThreads + 3; auto proc = createRpcTestSocketServerProcess({.numThreads = kNumThreads}); testThreadPoolOverSaturated(proc.rootIface, kNumCalls, 250 /*ms*/); // b/272429574 - below 500ms, the test fails testThreadPoolOverSaturated(proc.rootIface, kNumCalls, 500 /*ms*/); } TEST_P(BinderRpc, ThreadPoolLimitOutgoing) { Loading @@ -477,7 +479,9 @@ TEST_P(BinderRpc, ThreadPoolLimitOutgoing) { constexpr size_t kNumCalls = kNumOutgoingConnections + 3; auto proc = createRpcTestSocketServerProcess( {.numThreads = kNumThreads, .numOutgoingConnections = kNumOutgoingConnections}); testThreadPoolOverSaturated(proc.rootIface, kNumCalls, 250 /*ms*/); // b/272429574 - below 500ms, the test fails testThreadPoolOverSaturated(proc.rootIface, kNumCalls, 500 /*ms*/); } TEST_P(BinderRpc, ThreadingStressTest) { Loading
libs/gui/tests/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,9 @@ cc_test { compile_multilib: "both", header_libs: ["libsurfaceflinger_headers"], data: [ ":libgui_test", ], } cc_test { Loading
libs/renderengine/skia/SkiaRenderEngine.cpp +23 −29 Original line number Diff line number Diff line Loading @@ -395,10 +395,14 @@ void SkiaRenderEngine::mapExternalTextureBuffer(const sp<GraphicBuffer>& buffer, mRenderEngineType != RenderEngineType::SKIA_VK_THREADED) { return; } // We currently don't attempt to map a buffer if the buffer contains protected content // because GPU resources for protected buffers is much more limited. // We don't attempt to map a buffer if the buffer contains protected content. In GL this is // important because GPU resources for protected buffers are much more limited. (In Vk we // simply match the existing behavior for protected buffers.) In Vk, we never cache any // buffers while in a protected context, since Vk cannot share across contexts, and protected // is less common. const bool isProtectedBuffer = buffer->getUsage() & GRALLOC_USAGE_PROTECTED; if (isProtectedBuffer) { if (isProtectedBuffer || (mRenderEngineType == RenderEngineType::SKIA_VK_THREADED && isProtected())) { return; } ATRACE_CALL(); Loading Loading @@ -461,6 +465,20 @@ void SkiaRenderEngine::unmapExternalTextureBuffer(sp<GraphicBuffer>&& buffer) { } } std::shared_ptr<AutoBackendTexture::LocalRef> SkiaRenderEngine::getOrCreateBackendTexture( const sp<GraphicBuffer>& buffer, bool isOutputBuffer) { // Do not lookup the buffer in the cache for protected contexts with the SkiaVk back-end if (mRenderEngineType == RenderEngineType::SKIA_GL_THREADED || (mRenderEngineType == RenderEngineType::SKIA_VK_THREADED && !isProtected())) { if (const auto& it = mTextureCache.find(buffer->getId()); it != mTextureCache.end()) { return it->second; } } return std::make_shared<AutoBackendTexture::LocalRef>(getActiveGrContext(), buffer->toAHardwareBuffer(), isOutputBuffer, mTextureCleanupMgr); } bool SkiaRenderEngine::canSkipPostRenderCleanup() const { std::lock_guard<std::mutex> lock(mRenderingMutex); return mTextureCleanupMgr.isEmpty(); Loading Loading @@ -651,21 +669,11 @@ void SkiaRenderEngine::drawLayersInternal( validateOutputBufferUsage(buffer->getBuffer()); auto grContext = getActiveGrContext(); auto& cache = mTextureCache; // any AutoBackendTexture deletions will now be deferred until cleanupPostRender is called DeferTextureCleanup dtc(mTextureCleanupMgr); std::shared_ptr<AutoBackendTexture::LocalRef> surfaceTextureRef; if (const auto& it = cache.find(buffer->getBuffer()->getId()); it != cache.end()) { surfaceTextureRef = it->second; } else { surfaceTextureRef = std::make_shared<AutoBackendTexture::LocalRef>(grContext, buffer->getBuffer() ->toAHardwareBuffer(), true, mTextureCleanupMgr); } auto surfaceTextureRef = getOrCreateBackendTexture(buffer->getBuffer(), true); // wait on the buffer to be ready to use prior to using it waitFence(grContext, bufferFence); Loading Loading @@ -904,21 +912,7 @@ void SkiaRenderEngine::drawLayersInternal( ATRACE_NAME("DrawImage"); validateInputBufferUsage(layer.source.buffer.buffer->getBuffer()); const auto& item = layer.source.buffer; std::shared_ptr<AutoBackendTexture::LocalRef> imageTextureRef = nullptr; if (const auto& iter = cache.find(item.buffer->getBuffer()->getId()); iter != cache.end()) { imageTextureRef = iter->second; } else { // If we didn't find the image in the cache, then create a local ref but don't cache // it. If we're using skia, we're guaranteed to run on a dedicated GPU thread so if // we didn't find anything in the cache then we intentionally did not cache this // buffer's resources. imageTextureRef = std::make_shared< AutoBackendTexture::LocalRef>(grContext, item.buffer->getBuffer()->toAHardwareBuffer(), false, mTextureCleanupMgr); } auto imageTextureRef = getOrCreateBackendTexture(item.buffer->getBuffer(), false); // if the layer's buffer has a fence, then we must must respect the fence prior to using // the buffer. Loading
libs/renderengine/skia/SkiaRenderEngine.h +5 −1 Original line number Diff line number Diff line Loading @@ -133,6 +133,8 @@ private: void unmapExternalTextureBuffer(sp<GraphicBuffer>&& buffer) override final; bool canSkipPostRenderCleanup() const override final; std::shared_ptr<AutoBackendTexture::LocalRef> getOrCreateBackendTexture( const sp<GraphicBuffer>& buffer, bool isOutputBuffer) REQUIRES(mRenderingMutex); void initCanvas(SkCanvas* canvas, const DisplaySettings& display); void drawShadow(SkCanvas* canvas, const SkRRect& casterRRect, const ShadowSettings& shadowSettings); Loading Loading @@ -167,7 +169,9 @@ private: // Number of external holders of ExternalTexture references, per GraphicBuffer ID. std::unordered_map<GraphicBufferId, int32_t> mGraphicBufferExternalRefs GUARDED_BY(mRenderingMutex); // Cache of GL textures that we'll store per GraphicBuffer ID, shared between GPU contexts. // For GL, this cache is shared between protected and unprotected contexts. For Vulkan, it is // only used for the unprotected context, because Vulkan does not allow sharing between // contexts, and protected is less common. std::unordered_map<GraphicBufferId, std::shared_ptr<AutoBackendTexture::LocalRef>> mTextureCache GUARDED_BY(mRenderingMutex); std::unordered_map<shaders::LinearEffect, sk_sp<SkRuntimeEffect>, shaders::LinearEffectHasher> Loading