diff options
| author | 2023-08-17 23:57:49 +0000 | |
|---|---|---|
| committer | 2023-08-17 23:57:49 +0000 | |
| commit | 24c62b635bf69758431ccdd92e16dac893df8364 (patch) | |
| tree | f90740ea06d6624accf0a9de7a525e29da44a86a | |
| parent | f485f766c59b67de988f012b2a660488ac827c16 (diff) | |
| parent | 2a3d29dc8f33363bac4196a6ef72d53d58ee4fbe (diff) | |
Merge "Add dump of hdr event history" into main
| -rw-r--r-- | services/surfaceflinger/HdrLayerInfoReporter.cpp | 19 | ||||
| -rw-r--r-- | services/surfaceflinger/HdrLayerInfoReporter.h | 15 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 11 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 1 | ||||
| -rw-r--r-- | services/surfaceflinger/Tracing/LayerTracing.cpp | 5 | ||||
| -rw-r--r-- | services/surfaceflinger/Tracing/LayerTracing.h | 4 | ||||
| -rw-r--r-- | services/surfaceflinger/Tracing/TransactionRingBuffer.h (renamed from services/surfaceflinger/Tracing/RingBuffer.h) | 2 | ||||
| -rw-r--r-- | services/surfaceflinger/Tracing/TransactionTracing.h | 4 | ||||
| -rw-r--r-- | services/surfaceflinger/Utils/RingBuffer.h | 68 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/unittests/TransactionTracingTest.cpp | 1 |
10 files changed, 122 insertions, 8 deletions
diff --git a/services/surfaceflinger/HdrLayerInfoReporter.cpp b/services/surfaceflinger/HdrLayerInfoReporter.cpp index 9eefbe463d..278833244c 100644 --- a/services/surfaceflinger/HdrLayerInfoReporter.cpp +++ b/services/surfaceflinger/HdrLayerInfoReporter.cpp @@ -18,14 +18,22 @@ #define LOG_TAG "HdrLayerInfoReporter" #define ATRACE_TAG ATRACE_TAG_GRAPHICS +#include <android-base/stringprintf.h> +#include <inttypes.h> #include <utils/Trace.h> #include "HdrLayerInfoReporter.h" namespace android { +using base::StringAppendF; + void HdrLayerInfoReporter::dispatchHdrLayerInfo(const HdrLayerInfo& info) { ATRACE_CALL(); + if (mHdrInfoHistory.size() == 0 || mHdrInfoHistory.back().info != info) { + mHdrInfoHistory.next() = EventHistoryEntry{info}; + } + std::vector<sp<gui::IHdrLayerInfoListener>> toInvoke; { std::scoped_lock lock(mMutex); @@ -62,4 +70,15 @@ void HdrLayerInfoReporter::removeListener(const sp<gui::IHdrLayerInfoListener>& mListeners.erase(wp<IBinder>(IInterface::asBinder(listener))); } +void HdrLayerInfoReporter::dump(std::string& result) const { + for (size_t i = 0; i < mHdrInfoHistory.size(); i++) { + const auto& event = mHdrInfoHistory[i]; + const auto& info = event.info; + StringAppendF(&result, + "%" PRId64 ": numHdrLayers(%d), size(%dx%d), flags(%X), desiredRatio(%.2f)\n", + event.timestamp, info.numberOfHdrLayers, info.maxW, info.maxH, info.flags, + info.maxDesiredHdrSdrRatio); + } +} + } // namespace android
\ No newline at end of file diff --git a/services/surfaceflinger/HdrLayerInfoReporter.h b/services/surfaceflinger/HdrLayerInfoReporter.h index bf7c7753d2..614f33fbce 100644 --- a/services/surfaceflinger/HdrLayerInfoReporter.h +++ b/services/surfaceflinger/HdrLayerInfoReporter.h @@ -19,9 +19,11 @@ #include <android-base/thread_annotations.h> #include <android/gui/IHdrLayerInfoListener.h> #include <binder/IBinder.h> +#include <utils/Timers.h> #include <unordered_map> +#include "Utils/RingBuffer.h" #include "WpHash.h" namespace android { @@ -79,6 +81,8 @@ public: return !mListeners.empty(); } + void dump(std::string& result) const; + private: mutable std::mutex mMutex; @@ -88,6 +92,17 @@ private: }; std::unordered_map<wp<IBinder>, TrackedListener, WpHash> mListeners GUARDED_BY(mMutex); + + struct EventHistoryEntry { + nsecs_t timestamp = -1; + HdrLayerInfo info; + + EventHistoryEntry() {} + + EventHistoryEntry(const HdrLayerInfo& info) : info(info) { timestamp = systemTime(); } + }; + + utils::RingBuffer<EventHistoryEntry, 32> mHdrInfoHistory; }; } // namespace android
\ No newline at end of file diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 4784fe940b..f8f0d79dd3 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -5750,6 +5750,7 @@ status_t SurfaceFlinger::doDump(int fd, const DumpArgs& args, bool asProto) { {"--edid"s, argsDumper(&SurfaceFlinger::dumpRawDisplayIdentificationData)}, {"--events"s, dumper(&SurfaceFlinger::dumpEvents)}, {"--frametimeline"s, argsDumper(&SurfaceFlinger::dumpFrameTimeline)}, + {"--hdrinfo"s, dumper(&SurfaceFlinger::dumpHdrInfo)}, {"--hwclayers"s, dumper(&SurfaceFlinger::dumpHwcLayersMinidumpLockedLegacy)}, {"--latency"s, argsDumper(&SurfaceFlinger::dumpStatsLocked)}, {"--latency-clear"s, argsDumper(&SurfaceFlinger::clearStatsLocked)}, @@ -6058,6 +6059,14 @@ void SurfaceFlinger::dumpWideColorInfo(std::string& result) const { result.append("\n"); } +void SurfaceFlinger::dumpHdrInfo(std::string& result) const { + for (const auto& [displayId, listener] : mHdrLayerInfoListeners) { + StringAppendF(&result, "HDR events for display %" PRIu64 "\n", displayId.value); + listener->dump(result); + result.append("\n"); + } +} + LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t traceFlags) const { std::unordered_set<uint64_t> stackIdsToSkip; @@ -6222,6 +6231,8 @@ void SurfaceFlinger::dumpAllLocked(const DumpArgs& args, const std::string& comp result.append("\nWide-Color information:\n"); dumpWideColorInfo(result); + dumpHdrInfo(result); + colorizer.bold(result); result.append("Sync configuration: "); colorizer.reset(result); diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 81c3f2f9d2..4d17fa7d2a 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -1086,6 +1086,7 @@ private: void dumpDisplayIdentificationData(std::string& result) const REQUIRES(mStateLock); void dumpRawDisplayIdentificationData(const DumpArgs&, std::string& result) const; void dumpWideColorInfo(std::string& result) const REQUIRES(mStateLock); + void dumpHdrInfo(std::string& result) const REQUIRES(mStateLock); LayersProto dumpDrawingStateProto(uint32_t traceFlags) const; void dumpOffscreenLayersProto(LayersProto& layersProto, diff --git a/services/surfaceflinger/Tracing/LayerTracing.cpp b/services/surfaceflinger/Tracing/LayerTracing.cpp index ecdeabe528..b92d50b423 100644 --- a/services/surfaceflinger/Tracing/LayerTracing.cpp +++ b/services/surfaceflinger/Tracing/LayerTracing.cpp @@ -27,12 +27,13 @@ #include <utils/Trace.h> #include "LayerTracing.h" -#include "RingBuffer.h" +#include "TransactionRingBuffer.h" namespace android { LayerTracing::LayerTracing() - : mBuffer(std::make_unique<RingBuffer<LayersTraceFileProto, LayersTraceProto>>()) {} + : mBuffer(std::make_unique<TransactionRingBuffer<LayersTraceFileProto, LayersTraceProto>>()) { +} LayerTracing::~LayerTracing() = default; diff --git a/services/surfaceflinger/Tracing/LayerTracing.h b/services/surfaceflinger/Tracing/LayerTracing.h index 40b0fbee18..7c0d23d5b6 100644 --- a/services/surfaceflinger/Tracing/LayerTracing.h +++ b/services/surfaceflinger/Tracing/LayerTracing.h @@ -30,7 +30,7 @@ using namespace android::surfaceflinger; namespace android { template <typename FileProto, typename EntryProto> -class RingBuffer; +class TransactionRingBuffer; class SurfaceFlinger; @@ -71,7 +71,7 @@ private: uint32_t mFlags = TRACE_INPUT; mutable std::mutex mTraceLock; bool mEnabled GUARDED_BY(mTraceLock) = false; - std::unique_ptr<RingBuffer<LayersTraceFileProto, LayersTraceProto>> mBuffer + std::unique_ptr<TransactionRingBuffer<LayersTraceFileProto, LayersTraceProto>> mBuffer GUARDED_BY(mTraceLock); size_t mBufferSizeInBytes GUARDED_BY(mTraceLock) = 20 * 1024 * 1024; }; diff --git a/services/surfaceflinger/Tracing/RingBuffer.h b/services/surfaceflinger/Tracing/TransactionRingBuffer.h index b41c65b10e..e6f85ca4a5 100644 --- a/services/surfaceflinger/Tracing/RingBuffer.h +++ b/services/surfaceflinger/Tracing/TransactionRingBuffer.h @@ -32,7 +32,7 @@ namespace android { class SurfaceFlinger; template <typename FileProto, typename EntryProto> -class RingBuffer { +class TransactionRingBuffer { public: size_t size() const { return mSizeInBytes; } size_t used() const { return mUsedInBytes; } diff --git a/services/surfaceflinger/Tracing/TransactionTracing.h b/services/surfaceflinger/Tracing/TransactionTracing.h index a59dc6e7dc..31bca5fc66 100644 --- a/services/surfaceflinger/Tracing/TransactionTracing.h +++ b/services/surfaceflinger/Tracing/TransactionTracing.h @@ -30,8 +30,8 @@ #include "FrontEnd/LayerCreationArgs.h" #include "FrontEnd/Update.h" #include "LocklessStack.h" -#include "RingBuffer.h" #include "TransactionProtoParser.h" +#include "TransactionRingBuffer.h" using namespace android::surfaceflinger; @@ -81,7 +81,7 @@ private: static constexpr auto FILE_PATH = "/data/misc/wmtrace/transactions_trace.winscope"; mutable std::mutex mTraceLock; - RingBuffer<proto::TransactionTraceFile, proto::TransactionTraceEntry> mBuffer + TransactionRingBuffer<proto::TransactionTraceFile, proto::TransactionTraceEntry> mBuffer GUARDED_BY(mTraceLock); size_t mBufferSizeInBytes GUARDED_BY(mTraceLock) = CONTINUOUS_TRACING_BUFFER_SIZE; std::unordered_map<uint64_t, proto::TransactionState> mQueuedTransactions diff --git a/services/surfaceflinger/Utils/RingBuffer.h b/services/surfaceflinger/Utils/RingBuffer.h new file mode 100644 index 0000000000..198e7b2cf1 --- /dev/null +++ b/services/surfaceflinger/Utils/RingBuffer.h @@ -0,0 +1,68 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include <stddef.h> +#include <array> + +namespace android::utils { + +template <class T, size_t SIZE> +class RingBuffer { + RingBuffer(const RingBuffer&) = delete; + void operator=(const RingBuffer&) = delete; + +public: + RingBuffer() = default; + ~RingBuffer() = default; + + constexpr size_t capacity() const { return SIZE; } + + size_t size() const { return mCount; } + + T& next() { + mHead = static_cast<size_t>(mHead + 1) % SIZE; + if (mCount < SIZE) { + mCount++; + } + return mBuffer[static_cast<size_t>(mHead)]; + } + + T& front() { return (*this)[0]; } + + T& back() { return (*this)[size() - 1]; } + + T& operator[](size_t index) { + return mBuffer[(static_cast<size_t>(mHead + 1) + index) % mCount]; + } + + const T& operator[](size_t index) const { + return mBuffer[(static_cast<size_t>(mHead + 1) + index) % mCount]; + } + + void clear() { + mCount = 0; + mHead = -1; + } + +private: + std::array<T, SIZE> mBuffer; + int mHead = -1; + size_t mCount = 0; +}; + +} // namespace android::utils diff --git a/services/surfaceflinger/tests/unittests/TransactionTracingTest.cpp b/services/surfaceflinger/tests/unittests/TransactionTracingTest.cpp index 809966f9d6..71a2d2b9a6 100644 --- a/services/surfaceflinger/tests/unittests/TransactionTracingTest.cpp +++ b/services/surfaceflinger/tests/unittests/TransactionTracingTest.cpp @@ -25,7 +25,6 @@ #include "FrontEnd/LayerCreationArgs.h" #include "FrontEnd/Update.h" #include "Tracing/LayerTracing.h" -#include "Tracing/RingBuffer.h" #include "Tracing/TransactionTracing.h" using namespace android::surfaceflinger; |