Skip to content

Commit 6ba22ee

Browse files
vontureCommit Bot
authored andcommitted
GL: Implement EGL_ANDROID_get_frame_timestamps.
BUG=angleproject:2936 Change-Id: I758d797d185b2de330cce3401bfeef76c7df590e Reviewed-on: https://chromium-review.googlesource.com/c/1302836 Commit-Queue: Geoff Lang <[email protected]> Reviewed-by: Yuly Novikov <[email protected]>
1 parent 99d0463 commit 6ba22ee

22 files changed

Lines changed: 904 additions & 19 deletions

scripts/run_code_generation_hashes.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@
8484
"Vulkan mandatory format support table:src/libANGLE/renderer/vulkan/vk_mandatory_format_support_data.json":
8585
"fa2bd54c1bb0ab2cf1d386061a4bc5c5",
8686
"Vulkan mandatory format support table:third_party/vulkan-headers/src/registry/vk.xml":
87-
"36d0ec2733888108d2acb56134df6b22",
87+
"cd73387d7cdaa5d403eab411194342b3",
8888
"packed enum:src/common/gen_packed_gl_enums.py":
8989
"a9b1c38b4e4d8a1038e743be323f1a51",
9090
"packed enum:src/common/packed_egl_enums.json":
91-
"0389a8a565ccee99163bd0cf3ca146d3",
91+
"5f591d220ee53b6e54a27d1523a3ab79",
9292
"packed enum:src/common/packed_gl_enums.json":
9393
"7338a2a11c679aeb8efe2b415dbd4810",
9494
"proc table:src/libGLESv2/gen_proc_table.py":
9595
"027bfd5a8a8dffe91f492bf199029cde",
9696
"proc table:src/libGLESv2/proc_table_data.json":
97-
"9bc7a48223f99e16f11b14ccaeedb09d",
97+
"78d7d15862b563adf3fe957672ca1845",
9898
"uniform type:src/common/gen_uniform_type_table.py":
9999
"59cb4ffd0f584c4bd37f2f4ff59a2b93"
100100
}

src/common/PackedEGLEnums_autogen.cpp

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,38 @@
1515
namespace egl
1616
{
1717

18+
template <>
19+
CompositorTiming FromEGLenum<CompositorTiming>(EGLenum from)
20+
{
21+
switch (from)
22+
{
23+
case EGL_COMPOSITE_DEADLINE_ANDROID:
24+
return CompositorTiming::CompositeDeadline;
25+
case EGL_COMPOSITE_INTERVAL_ANDROID:
26+
return CompositorTiming::CompositInterval;
27+
case EGL_COMPOSITE_TO_PRESENT_LATENCY_ANDROID:
28+
return CompositorTiming::CompositToPresentLatency;
29+
default:
30+
return CompositorTiming::InvalidEnum;
31+
}
32+
}
33+
34+
EGLenum ToEGLenum(CompositorTiming from)
35+
{
36+
switch (from)
37+
{
38+
case CompositorTiming::CompositeDeadline:
39+
return EGL_COMPOSITE_DEADLINE_ANDROID;
40+
case CompositorTiming::CompositInterval:
41+
return EGL_COMPOSITE_INTERVAL_ANDROID;
42+
case CompositorTiming::CompositToPresentLatency:
43+
return EGL_COMPOSITE_TO_PRESENT_LATENCY_ANDROID;
44+
default:
45+
UNREACHABLE();
46+
return 0;
47+
}
48+
}
49+
1850
template <>
1951
MessageType FromEGLenum<MessageType>(EGLenum from)
2052
{
@@ -131,4 +163,60 @@ EGLenum ToEGLenum(TextureFormat from)
131163
}
132164
}
133165

166+
template <>
167+
Timestamp FromEGLenum<Timestamp>(EGLenum from)
168+
{
169+
switch (from)
170+
{
171+
case EGL_REQUESTED_PRESENT_TIME_ANDROID:
172+
return Timestamp::RequestedPresentTime;
173+
case EGL_RENDERING_COMPLETE_TIME_ANDROID:
174+
return Timestamp::RenderingCompleteTime;
175+
case EGL_COMPOSITION_LATCH_TIME_ANDROID:
176+
return Timestamp::CompositionLatchTime;
177+
case EGL_FIRST_COMPOSITION_START_TIME_ANDROID:
178+
return Timestamp::FirstCompositionStartTime;
179+
case EGL_LAST_COMPOSITION_START_TIME_ANDROID:
180+
return Timestamp::LastCompositionStartTime;
181+
case EGL_FIRST_COMPOSITION_GPU_FINISHED_TIME_ANDROID:
182+
return Timestamp::FirstCompositionGPUFinishedTime;
183+
case EGL_DISPLAY_PRESENT_TIME_ANDROID:
184+
return Timestamp::DisplayPresentTime;
185+
case EGL_DEQUEUE_READY_TIME_ANDROID:
186+
return Timestamp::DequeueReadyTime;
187+
case EGL_READS_DONE_TIME_ANDROID:
188+
return Timestamp::ReadsDoneTime;
189+
default:
190+
return Timestamp::InvalidEnum;
191+
}
192+
}
193+
194+
EGLenum ToEGLenum(Timestamp from)
195+
{
196+
switch (from)
197+
{
198+
case Timestamp::RequestedPresentTime:
199+
return EGL_REQUESTED_PRESENT_TIME_ANDROID;
200+
case Timestamp::RenderingCompleteTime:
201+
return EGL_RENDERING_COMPLETE_TIME_ANDROID;
202+
case Timestamp::CompositionLatchTime:
203+
return EGL_COMPOSITION_LATCH_TIME_ANDROID;
204+
case Timestamp::FirstCompositionStartTime:
205+
return EGL_FIRST_COMPOSITION_START_TIME_ANDROID;
206+
case Timestamp::LastCompositionStartTime:
207+
return EGL_LAST_COMPOSITION_START_TIME_ANDROID;
208+
case Timestamp::FirstCompositionGPUFinishedTime:
209+
return EGL_FIRST_COMPOSITION_GPU_FINISHED_TIME_ANDROID;
210+
case Timestamp::DisplayPresentTime:
211+
return EGL_DISPLAY_PRESENT_TIME_ANDROID;
212+
case Timestamp::DequeueReadyTime:
213+
return EGL_DEQUEUE_READY_TIME_ANDROID;
214+
case Timestamp::ReadsDoneTime:
215+
return EGL_READS_DONE_TIME_ANDROID;
216+
default:
217+
UNREACHABLE();
218+
return 0;
219+
}
220+
}
221+
134222
} // namespace egl

src/common/PackedEGLEnums_autogen.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ namespace egl
2424
template <typename Enum>
2525
Enum FromEGLenum(EGLenum from);
2626

27+
enum class CompositorTiming : uint8_t
28+
{
29+
CompositeDeadline = 0,
30+
CompositInterval = 1,
31+
CompositToPresentLatency = 2,
32+
33+
InvalidEnum = 3,
34+
EnumCount = 3,
35+
};
36+
37+
template <>
38+
CompositorTiming FromEGLenum<CompositorTiming>(EGLenum from);
39+
EGLenum ToEGLenum(CompositorTiming from);
40+
2741
enum class MessageType : uint8_t
2842
{
2943
Critical = 0,
@@ -71,6 +85,26 @@ template <>
7185
TextureFormat FromEGLenum<TextureFormat>(EGLenum from);
7286
EGLenum ToEGLenum(TextureFormat from);
7387

88+
enum class Timestamp : uint8_t
89+
{
90+
RequestedPresentTime = 0,
91+
RenderingCompleteTime = 1,
92+
CompositionLatchTime = 2,
93+
FirstCompositionStartTime = 3,
94+
LastCompositionStartTime = 4,
95+
FirstCompositionGPUFinishedTime = 5,
96+
DisplayPresentTime = 6,
97+
DequeueReadyTime = 7,
98+
ReadsDoneTime = 8,
99+
100+
InvalidEnum = 9,
101+
EnumCount = 9,
102+
};
103+
104+
template <>
105+
Timestamp FromEGLenum<Timestamp>(EGLenum from);
106+
EGLenum ToEGLenum(Timestamp from);
107+
74108
} // namespace egl
75109

76110
#endif // COMMON_PACKEDEGLENUMS_AUTOGEN_H_

src/common/packed_egl_enums.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,23 @@
2121
"Error": "EGL_DEBUG_MSG_ERROR_KHR",
2222
"Warn": "EGL_DEBUG_MSG_WARN_KHR",
2323
"Info": "EGL_DEBUG_MSG_INFO_KHR"
24+
},
25+
"CompositorTiming":
26+
{
27+
"CompositeDeadline": "EGL_COMPOSITE_DEADLINE_ANDROID",
28+
"CompositInterval": "EGL_COMPOSITE_INTERVAL_ANDROID",
29+
"CompositToPresentLatency": "EGL_COMPOSITE_TO_PRESENT_LATENCY_ANDROID"
30+
},
31+
"Timestamp":
32+
{
33+
"RequestedPresentTime": "EGL_REQUESTED_PRESENT_TIME_ANDROID",
34+
"RenderingCompleteTime": "EGL_RENDERING_COMPLETE_TIME_ANDROID",
35+
"CompositionLatchTime": "EGL_COMPOSITION_LATCH_TIME_ANDROID",
36+
"FirstCompositionStartTime": "EGL_FIRST_COMPOSITION_START_TIME_ANDROID",
37+
"LastCompositionStartTime": "EGL_LAST_COMPOSITION_START_TIME_ANDROID",
38+
"FirstCompositionGPUFinishedTime": "EGL_FIRST_COMPOSITION_GPU_FINISHED_TIME_ANDROID",
39+
"DisplayPresentTime": "EGL_DISPLAY_PRESENT_TIME_ANDROID",
40+
"DequeueReadyTime": "EGL_DEQUEUE_READY_TIME_ANDROID",
41+
"ReadsDoneTime": "EGL_READS_DONE_TIME_ANDROID"
2442
}
2543
}

src/libANGLE/Caps.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,8 @@ DisplayExtensions::DisplayExtensions()
13621362
createContextExtensionsEnabled(false),
13631363
presentationTime(false),
13641364
blobCache(false),
1365-
imageNativeBuffer(false)
1365+
imageNativeBuffer(false),
1366+
getFrameTimestamps(false)
13661367
{
13671368
}
13681369

@@ -1413,6 +1414,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const
14131414
InsertExtensionString("EGL_ANDROID_presentation_time", presentationTime, &extensionStrings);
14141415
InsertExtensionString("EGL_ANDROID_blob_cache", blobCache, &extensionStrings);
14151416
InsertExtensionString("EGL_ANDROID_image_native_buffer", imageNativeBuffer, &extensionStrings);
1417+
InsertExtensionString("EGL_ANDROID_get_frame_timestamps", getFrameTimestamps, &extensionStrings);
14161418
// TODO(jmadill): Enable this when complete.
14171419
//InsertExtensionString("KHR_create_context_no_error", createContextNoError, &extensionStrings);
14181420
// clang-format on

src/libANGLE/Caps.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,9 @@ struct DisplayExtensions
813813

814814
// EGL_ANDROID_image_native_buffer
815815
bool imageNativeBuffer;
816+
817+
// EGL_ANDROID_get_frame_timestamps
818+
bool getFrameTimestamps;
816819
};
817820

818821
struct DeviceExtensions

src/libANGLE/Surface.cpp

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace egl
2626
{
2727

2828
SurfaceState::SurfaceState(const egl::Config *configIn, const AttributeMap &attributesIn)
29-
: label(nullptr), config(configIn), attributes(attributesIn)
29+
: label(nullptr), config(configIn), attributes(attributesIn), timestampsEnabled(false)
3030
{
3131
}
3232

@@ -169,6 +169,12 @@ Error Surface::initialize(const Display *display)
169169
}
170170
}
171171

172+
if (mType == EGL_WINDOW_BIT && display->getExtensions().getFrameTimestamps)
173+
{
174+
mState.supportedCompositorTimings = mImplementation->getSupportedCompositorTimings();
175+
mState.supportedTimestamps = mImplementation->getSupportedTimestamps();
176+
}
177+
172178
return NoError();
173179
}
174180

@@ -481,6 +487,47 @@ void Surface::setInitState(const gl::ImageIndex & /*imageIndex*/, gl::InitState
481487
mInitState = initState;
482488
}
483489

490+
void Surface::setTimestampsEnabled(bool enabled)
491+
{
492+
mImplementation->setTimestampsEnabled(enabled);
493+
mState.timestampsEnabled = enabled;
494+
}
495+
496+
bool Surface::isTimestampsEnabled() const
497+
{
498+
return mState.timestampsEnabled;
499+
}
500+
501+
const SupportedCompositorTiming &Surface::getSupportedCompositorTimings() const
502+
{
503+
return mState.supportedCompositorTimings;
504+
}
505+
506+
Error Surface::getCompositorTiming(EGLint numTimestamps,
507+
const EGLint *names,
508+
EGLnsecsANDROID *values) const
509+
{
510+
return mImplementation->getCompositorTiming(numTimestamps, names, values);
511+
}
512+
513+
Error Surface::getNextFrameId(EGLuint64KHR *frameId) const
514+
{
515+
return mImplementation->getNextFrameId(frameId);
516+
}
517+
518+
const SupportedTimestamps &Surface::getSupportedTimestamps() const
519+
{
520+
return mState.supportedTimestamps;
521+
}
522+
523+
Error Surface::getFrameTimestamps(EGLuint64KHR frameId,
524+
EGLint numTimestamps,
525+
const EGLint *timestamps,
526+
EGLnsecsANDROID *values) const
527+
{
528+
return mImplementation->getFrameTimestamps(frameId, numTimestamps, timestamps, values);
529+
}
530+
484531
WindowSurface::WindowSurface(rx::EGLImplFactory *implFactory,
485532
const egl::Config *config,
486533
EGLNativeWindowType window,

src/libANGLE/Surface.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,20 @@ namespace egl
4040
class Display;
4141
struct Config;
4242

43+
using SupportedCompositorTiming = angle::PackedEnumBitSet<CompositorTiming>;
44+
using SupportedTimestamps = angle::PackedEnumBitSet<Timestamp>;
45+
4346
struct SurfaceState final : private angle::NonCopyable
4447
{
4548
SurfaceState(const egl::Config *configIn, const AttributeMap &attributesIn);
4649

4750
EGLLabelKHR label;
4851
const egl::Config *config;
4952
AttributeMap attributes;
53+
54+
bool timestampsEnabled;
55+
SupportedCompositorTiming supportedCompositorTimings;
56+
SupportedTimestamps supportedTimestamps;
5057
};
5158

5259
class Surface : public LabeledObject, public gl::FramebufferAttachmentObject
@@ -140,6 +147,22 @@ class Surface : public LabeledObject, public gl::FramebufferAttachmentObject
140147

141148
const gl::Format &getBindTexImageFormat() const { return mColorFormat; }
142149

150+
// EGL_ANDROID_get_frame_timestamps entry points
151+
void setTimestampsEnabled(bool enabled);
152+
bool isTimestampsEnabled() const;
153+
154+
const SupportedCompositorTiming &getSupportedCompositorTimings() const;
155+
Error getCompositorTiming(EGLint numTimestamps,
156+
const EGLint *names,
157+
EGLnsecsANDROID *values) const;
158+
159+
Error getNextFrameId(EGLuint64KHR *frameId) const;
160+
const SupportedTimestamps &getSupportedTimestamps() const;
161+
Error getFrameTimestamps(EGLuint64KHR frameId,
162+
EGLint numTimestamps,
163+
const EGLint *timestamps,
164+
EGLnsecsANDROID *values) const;
165+
143166
protected:
144167
Surface(EGLint surfaceType,
145168
const egl::Config *config,

src/libANGLE/queryutils.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,6 +2988,9 @@ void QuerySurfaceAttrib(const Surface *surface, EGLint attribute, EGLint *value)
29882988
case EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE:
29892989
*value = surface->isRobustResourceInitEnabled();
29902990
break;
2991+
case EGL_TIMESTAMPS_ANDROID:
2992+
*value = surface->isTimestampsEnabled();
2993+
break;
29912994
default:
29922995
UNREACHABLE();
29932996
break;
@@ -3013,6 +3016,9 @@ void SetSurfaceAttrib(Surface *surface, EGLint attribute, EGLint value)
30133016
case EGL_HEIGHT:
30143017
surface->setFixedHeight(value);
30153018
break;
3019+
case EGL_TIMESTAMPS_ANDROID:
3020+
surface->setTimestampsEnabled(value != EGL_FALSE);
3021+
break;
30163022
default:
30173023
UNREACHABLE();
30183024
break;

0 commit comments

Comments
 (0)