extensions: Add EGL_ANGLE_sync_control_rate (KhronosGroup#116) (#118)

diff --git a/api/EGL/eglext.h b/api/EGL/eglext.h
index c8df7f1..8c81099 100644
--- a/api/EGL/eglext.h
+++ b/api/EGL/eglext.h
@@ -574,6 +574,14 @@
 #define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
 #endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */
 
+#ifndef EGL_ANGLE_sync_control_rate
+#define EGL_ANGLE_sync_control_rate 1
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETMSCRATEANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *numerator, EGLint *denominator);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglGetMscRateANGLE(EGLDisplay dpy, EGLSurface surface, EGLint *numerator, EGLint *denominator);
+#endif
+#endif /* EGL_ANGLE_sync_control_rate */
+
 #ifndef EGL_ANGLE_window_fixed_size
 #define EGL_ANGLE_window_fixed_size 1
 #define EGL_FIXED_SIZE_ANGLE              0x3201
diff --git a/api/egl.xml b/api/egl.xml
index 4d27853..554f1ba 100644
--- a/api/egl.xml
+++ b/api/egl.xml
@@ -1366,6 +1366,13 @@
             <proto><ptype>EGLint</ptype> <name>eglGetError</name></proto>
         </command>
         <command>
+            <proto><ptype>EGLBoolean</ptype> <name>eglGetMscRateANGLE</name></proto>
+            <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+            <param><ptype>EGLSurface</ptype> <name>surface</name></param>
+            <param><ptype>EGLint</ptype> *<name>numerator</name></param>
+            <param><ptype>EGLint</ptype> *<name>denominator</name></param>
+        </command>
+        <command>
             <proto><ptype>EGLClientBuffer</ptype> <name>eglGetNativeClientBufferANDROID</name></proto>
             <param>const struct <ptype>AHardwareBuffer</ptype> *<name>buffer</name></param>
         </command>
@@ -2340,6 +2347,11 @@
                 <enum name="EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE"/>
             </require>
         </extension>
+        <extension name="EGL_ANGLE_sync_control_rate" supported="egl">
+            <require>
+                <command name="eglGetMscRateANGLE"/>
+            </require>
+        </extension>
         <extension name="EGL_ANGLE_window_fixed_size" supported="egl">
             <require>
                 <enum name="EGL_FIXED_SIZE_ANGLE"/>
diff --git a/extensions/ANGLE/EGL_ANGLE_sync_control_rate.txt b/extensions/ANGLE/EGL_ANGLE_sync_control_rate.txt
new file mode 100644
index 0000000..4259145
--- /dev/null
+++ b/extensions/ANGLE/EGL_ANGLE_sync_control_rate.txt
@@ -0,0 +1,99 @@
+Name
+
+   ANGLE_sync_control_rate
+
+Name Strings
+
+   EGL_ANGLE_sync_control_rate
+
+Contact
+
+   Jonah Ryan-Davis, Google (jonahr 'at' google.com)
+
+Status
+
+   Draft.
+
+Version
+
+   Version 1, 2020-03-24
+
+   Based on GLX_OML_sync_control Revision 6.0
+   Related to EGL_CHROMIUM_sync_control Revision 2.0
+
+Number
+
+   142
+
+Dependencies
+
+   The extension is written against the EGL 1.2 Specification, although it
+   should work on other versions of these specifications.
+
+Overview
+
+   This extension provides counters which let applications know about the
+   timing of the last vertical retrace. By looking at the system clock, as
+   well as the refresh rate of the monitor, this should enable applications
+   to predict the position of future retraces so as to schedule an optimal
+   workload.
+
+   This extension incorporates the use of a counter that provides the
+   necessary synchronization. The graphics Media Stream Counter (or
+   graphics MSC) is a counter that is unique to the graphics subsystem
+   and increments for each vertical retrace that occurs. 
+
+   By querying the MSC rate for a given surface, the application can
+   accurately predict the timing for the next vertical retraces and schedule
+   rendering accordingly.
+
+Issues
+
+   None.
+
+IP Status
+
+   No known issues.
+
+New Procedures and Functions
+
+   Bool eglGetMscRateANGLE(EGLDisplay* dpy,
+                           EGLSurface surface,
+                           int32_t* numerator,
+                           int32_t* denominator)
+
+New Tokens
+
+   None
+
+Additions to the EGL 1.3 Specification
+
+   The graphics MSC value is incremented once for each screen refresh.
+   For a non-interlaced display, this means that the graphics MSC value
+   is incremented for each frame. For an interlaced display, it means
+   that it will be incremented for each field. For a multi-monitor
+   system, the monitor used to determine MSC is the one where the surface
+   is located. If the surface spans multiple monitors, the monitor used
+   to determine MSC is the one with the biggest coverage in pixels.
+
+   eglGetMscRateANGLE returns the rate at which the MSC will be incremented
+   for the display associated with <dpy> and <surface>. The rate is expressed
+   in Hertz as <numerator> / <denominator>. If the MSC rate in Hertz is an
+   integer, then <denominator> will be 1 and <numerator> will be
+   the MSC rate.
+
+Errors
+
+   The function eglGetMscRateANGLE returns FALSE on failure.
+   If <dpy> is not a valid EGLDisplay, EGL_BAD_DISPLAY is generated.
+   If <surface> is not a valid EGLSurface, EGL_BAD_SURFACE is generated.
+   If there is no current EGLContext, EGL_BAD_CONTEXT is generated.
+
+New Implementation Dependent State
+
+   None
+
+Revision History
+
+    Version 1, 2020-03-24 (Jonah Ryan-Davis)
+       - Initial draft, based on GLX_OML_sync_control revision 6.0.
diff --git a/index.php b/index.php
index adb4136..a8ab96e 100644
--- a/index.php
+++ b/index.php
@@ -349,6 +349,8 @@
 </li>
 <li value=141> <a href="extensions/EXT/EGL_EXT_platform_xcb.txt">EGL_EXT_platform_xcb</a>
 </li>
+<li value=142> <a href="extensions/ANGLE/EGL_ANGLE_sync_control_rate.txt">EGL_ANGLE_sync_control_rate</a>
+</li>
 </ol>
 
 <h6> Providing Feedback on the Registry </h6>
diff --git a/registry.tcl b/registry.tcl
index c6d6d0f..67b4b89 100644
--- a/registry.tcl
+++ b/registry.tcl
@@ -732,4 +732,9 @@
     flags       public
     filename    extensions/EXT/EGL_EXT_platform_xcb.txt
 }
-# Next free extension number: 142
+extension EGL_ANGLE_sync_control_rate {
+    number      142
+    flags       public
+    filename    extensions/ANGLE/EGL_ANGLE_sync_control_rate.txt
+}
+# Next free extension number: 143