diff options
author | 2025-02-25 16:08:19 -0800 | |
---|---|---|
committer | 2025-03-13 15:41:05 -0700 | |
commit | df868baf2abefbb45341530d20a948ffd6b2c304 (patch) | |
tree | e1e4b886b5a03e0dee5f6780ee3a0431af9637db /libs/ui/GraphicBuffer.cpp | |
parent | c28b463221a7516fa8e9aa30dfd33f290f635e99 (diff) |
Introduce a dependency monitor for fences
This allows for userspace logging for a buffer and read/write dependencies on the buffer.
Hook up SF to the dependency monitor.
Right now this _does_ emit logs in SF when the primary display is powered down, which is likely indicative of SF being sloppy about release fences in situations where tearing won't be noticeable, but I did verify that manually making screenshotting forget to merge GPU work into a layer's release fence, which has been one way SF's torn the screen, triggers logcat, which is ultimately what we want.
Bug: 360932099
Flag: com.android.graphics.surfaceflinger.flags.monitor_buffer_fences
Test: manually remove screenshot fence handling and check logs
Change-Id: Ica391dfa8a4f2924bb72664b9d9399e4ad9e1747
Diffstat (limited to 'libs/ui/GraphicBuffer.cpp')
-rw-r--r-- | libs/ui/GraphicBuffer.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index 18c9a6bc48..f7c94005f1 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -27,6 +27,8 @@ #include <ui/GraphicBufferMapper.h> #include <utils/Trace.h> +#include <string> + namespace android { // =========================================================================== @@ -104,6 +106,7 @@ GraphicBuffer::GraphicBuffer() usage = 0; layerCount = 0; handle = nullptr; + mDependencyMonitor.setToken(std::to_string(mId)); } // deprecated @@ -155,6 +158,8 @@ GraphicBuffer::GraphicBuffer(const GraphicBufferAllocator::AllocationRequest& re layerCount = request.layerCount; usage = request.usage; usage_deprecated = int(usage); + std::string name = request.requestorName; + mDependencyMonitor.setToken(name.append(":").append(std::to_string(mId))); } } @@ -252,6 +257,7 @@ status_t GraphicBuffer::initWithSize(uint32_t inWidth, uint32_t inHeight, usage = inUsage; usage_deprecated = int(usage); stride = static_cast<int>(outStride); + mDependencyMonitor.setToken(requestorName.append(":").append(std::to_string(mId))); } return err; } @@ -609,6 +615,14 @@ status_t GraphicBuffer::unflatten(void const*& buffer, size_t& size, int const*& mBufferMapper.getTransportSize(handle, &mTransportNumFds, &mTransportNumInts); } + std::string name; + status_t err = mBufferMapper.getName(handle, &name); + if (err != NO_ERROR) { + name = "<Unknown>"; + } + + mDependencyMonitor.setToken(name.append(":").append(std::to_string(mId))); + buffer = static_cast<void const*>(static_cast<uint8_t const*>(buffer) + sizeNeeded); size -= sizeNeeded; fds += numFds; |