15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci OML_sync_control 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci WGL_OML_sync_control 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Randi Rost, 3Dlabs (rost 'at' 3dlabs.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciStatus 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Complete. Approved by the Khronos SIG on July 19, 2001. 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ciVersion 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ci Last Modified Date: 07/23/2001 Revision: 17.0 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ciNumber 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ci 242 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ciDependencies 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ci The extension is written against the OpenGL 1.2.1 Specification 285bd8deadSopenharmony_ci although it should work on any previous OpenGL specification. 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ci WGL_ARB_extensions_string is required. 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ciOverview 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ci This extension provides the control necessary to ensure 355bd8deadSopenharmony_ci synchronization between events on the graphics card (such as 365bd8deadSopenharmony_ci vertical retrace) and other parts of the system. It provides support 375bd8deadSopenharmony_ci for applications with real-time rendering requirements by providing 385bd8deadSopenharmony_ci precise synchronization between graphics and streaming video or 395bd8deadSopenharmony_ci audio. 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ci This extension incorporates the use of three counters that provide 425bd8deadSopenharmony_ci the necessary synchronization. The Unadjusted System Time (or UST) 435bd8deadSopenharmony_ci is a 64-bit monotonically increasing counter that is available 445bd8deadSopenharmony_ci throughout the system. UST is not a resource that is controlled 455bd8deadSopenharmony_ci by OpenGL, so it is not defined further as part of this extension. 465bd8deadSopenharmony_ci The graphics Media Stream Counter (or graphics MSC) is a counter 475bd8deadSopenharmony_ci that is unique to the graphics subsystem and increments for each 485bd8deadSopenharmony_ci vertical retrace that occurs. The Swap Buffer Counter (SBC) is a 495bd8deadSopenharmony_ci per-window value that is incremented each time a swap buffer 505bd8deadSopenharmony_ci action is performed on the window. 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci The use of these three counters allows the application to 535bd8deadSopenharmony_ci synchronize graphics rendering to vertical retraces and/or swap 545bd8deadSopenharmony_ci buffer actions, and to synchronize other activities in the system 555bd8deadSopenharmony_ci (such as streaming video or audio) to vertical retraces and/or 565bd8deadSopenharmony_ci swap buffer actions. 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ci Functions are provided to allow an application to detect when an 595bd8deadSopenharmony_ci MSC or SBC has reached a certain value. This function will block 605bd8deadSopenharmony_ci until the specified value has been reached. Applications that want 615bd8deadSopenharmony_ci to continue other processing while waiting are expected to call 625bd8deadSopenharmony_ci these blocking functions from a thread that is separate from the 635bd8deadSopenharmony_ci main processing thread(s) of the application. 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ci This extension carefully defines the observable order in which 665bd8deadSopenharmony_ci things occur in order to allow implementations to perform 675bd8deadSopenharmony_ci optimizations and avoid artifacts such as tearing, while at the 685bd8deadSopenharmony_ci same time providing a framework for consistent behavior from the 695bd8deadSopenharmony_ci point of view of an application. 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ciIssues 725bd8deadSopenharmony_ci 735bd8deadSopenharmony_ci None. 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ciIP Status 765bd8deadSopenharmony_ci 775bd8deadSopenharmony_ci No known issues. 785bd8deadSopenharmony_ci 795bd8deadSopenharmony_ciNew Procedures and Functions 805bd8deadSopenharmony_ci 815bd8deadSopenharmony_ci BOOL wglGetSyncValuesOML(HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc) 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ci BOOL wglGetMscRateOML(HDC hdc, INT32 *numerator, INT32 *denominator) 845bd8deadSopenharmony_ci 855bd8deadSopenharmony_ci INT64 wglSwapBuffersMscOML(HDC hdc, INT64 target_msc, INT64 divisor, 865bd8deadSopenharmony_ci INT64 remainder) 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci INT64 wglSwapLayerBuffersMscOML(HDC hdc, INT fuPlanes, INT64 target_msc, 895bd8deadSopenharmony_ci INT64 divisor, INT64 remainder) 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci BOOL wglWaitForMscOML(HDC hdc, INT64 target_msc, INT64 divisor, 925bd8deadSopenharmony_ci INT64 remainder, INT64 *ust, INT64 *msc, 935bd8deadSopenharmony_ci INT64 *sbc) 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci BOOL wglWaitForSbcOML(HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, 965bd8deadSopenharmony_ci INT64 *sbc) 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ciNew Tokens 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci None 1015bd8deadSopenharmony_ci 1025bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation) 1035bd8deadSopenharmony_ci 1045bd8deadSopenharmony_ci None 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 1.2.1 Specification (Rasterization) 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci None 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 1.2.1 Specification (Per-Fragment 1115bd8deadSopenharmony_ciOperations and the Framebuffer) 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci None 1145bd8deadSopenharmony_ci 1155bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions) 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ci None 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 1.2.1 Specification (State and 1205bd8deadSopenharmony_ciState Requests) 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci None 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ciAdditions to the WGL Specification 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ci wglGetSyncValuesOML returns the current UST/MSC/SBC triple. A UST 1275bd8deadSopenharmony_ci timestamp is obtained each time the graphics MSC is incremented. 1285bd8deadSopenharmony_ci If this value does not reflect the value of the UST at the time the 1295bd8deadSopenharmony_ci first scan line of the display begins passing through the video 1305bd8deadSopenharmony_ci output port, it will be adjusted by the graphics driver to do so 1315bd8deadSopenharmony_ci prior to being returned by any of the functions defined by this 1325bd8deadSopenharmony_ci extension. 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci This UST timestamp, together with the current graphics MSC and the 1355bd8deadSopenharmony_ci current SBC, comprise the current UST/MSC/SBC triple. The UST, 1365bd8deadSopenharmony_ci graphics MSC, and SBC values are not part of the render context 1375bd8deadSopenharmony_ci state. These values cannot be pushed or popped. The graphics MSC 1385bd8deadSopenharmony_ci value is initialized to 0 when the graphics device is initialized. 1395bd8deadSopenharmony_ci The SBC is per-window state and is initialized to 0 when the window 1405bd8deadSopenharmony_ci is initialized. 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci The SBC value is incremented by the graphics driver at the completion 1435bd8deadSopenharmony_ci of each buffer swap (e.g., the pixel copy has been completed or the 1445bd8deadSopenharmony_ci hardware register that swaps memory banks has been written). For pixel 1455bd8deadSopenharmony_ci formats that do not contain a back buffer, the SBC will always be 1465bd8deadSopenharmony_ci returned as 0. 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci The graphics MSC value is incremented once for each screen refresh. 1495bd8deadSopenharmony_ci For a non-interlaced display, this means that the graphics MSC value 1505bd8deadSopenharmony_ci is incremented for each frame. For an interlaced display, it means 1515bd8deadSopenharmony_ci that it will be incremented for each field. For a multi-monitor 1525bd8deadSopenharmony_ci system, the monitor used to determine MSC is the one Windows 1535bd8deadSopenharmony_ci associates with <hdc> (i.e., the primary monitor). 1545bd8deadSopenharmony_ci 1555bd8deadSopenharmony_ci wglGetMscRateOML returns the rate at which the MSC will be incremented 1565bd8deadSopenharmony_ci for the display associated with <hdc>. The rate is expressed in Hertz 1575bd8deadSopenharmony_ci as <numerator> / <denominator>. If the MSC rate in Hertz is an 1585bd8deadSopenharmony_ci integer, then <denominator> will be 1 and <numerator> will be 1595bd8deadSopenharmony_ci the MSC rate. 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci wglSwapBuffersMscOML has the same functionality as SwapBuffers, 1625bd8deadSopenharmony_ci except for the following. The swap indicated by a call to 1635bd8deadSopenharmony_ci wglSwapBuffersMscOML does not perform an implicit glFlush. The 1645bd8deadSopenharmony_ci indicated swap will not occur until all prior rendering commands 1655bd8deadSopenharmony_ci affecting the buffer have been completed. Once prior rendering 1665bd8deadSopenharmony_ci commands have been completed, if the current MSC is less than 1675bd8deadSopenharmony_ci <target_msc>, the buffer swap will occur when the MSC value becomes 1685bd8deadSopenharmony_ci equal to <target_msc>. Once prior rendering commands have completed, 1695bd8deadSopenharmony_ci if the current MSC is greater than or equal to <target_msc>, the 1705bd8deadSopenharmony_ci buffer swap will occur the next time the MSC value is incremented 1715bd8deadSopenharmony_ci to a value such that MSC % <divisor> = <remainder>. If <divisor> = 0, 1725bd8deadSopenharmony_ci the swap will occur when MSC becomes greater than or equal to 1735bd8deadSopenharmony_ci <target_msc>. 1745bd8deadSopenharmony_ci 1755bd8deadSopenharmony_ci Once wglSwapBuffersMscOML has been called, subsequent OpenGL commands 1765bd8deadSopenharmony_ci can be issued immediately. If the thread's current context is made 1775bd8deadSopenharmony_ci current to another drawable, or if the thread makes another context 1785bd8deadSopenharmony_ci current on another drawable, rendering can proceed immediately. 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ci If there are multiple outstanding swaps for the same window, at most 1815bd8deadSopenharmony_ci one such swap can be satisfied per increment of MSC. The order of 1825bd8deadSopenharmony_ci satisfying outstanding swaps of a window must be the order they were 1835bd8deadSopenharmony_ci issued. Each window that has an outstanding swap satisfied by the same 1845bd8deadSopenharmony_ci current MSC should have one swap done. 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ci If a thread issues a wglSwapBuffersMscOML call on a window, then 1875bd8deadSopenharmony_ci issues OpenGL commands while still current to this window (which now 1885bd8deadSopenharmony_ci has a pending wglSwapBuffersMscOML call), the commands will be executed 1895bd8deadSopenharmony_ci in the order they were received, subject to implementation resource 1905bd8deadSopenharmony_ci constraints. Furthermore, subsequent commands that would affect 1915bd8deadSopenharmony_ci the back buffer will only affect the new back buffer (that is, the 1925bd8deadSopenharmony_ci back buffer after the swap completes). Such commands do not affect 1935bd8deadSopenharmony_ci the current front buffer. 1945bd8deadSopenharmony_ci 1955bd8deadSopenharmony_ci If the graphics driver utilizes an extra thread to perform the wait, 1965bd8deadSopenharmony_ci it is expected that this thread will have a high priority so that 1975bd8deadSopenharmony_ci the swap will occur at the earliest possible moment once all the 1985bd8deadSopenharmony_ci conditions for swapping have been satisfied. 1995bd8deadSopenharmony_ci 2005bd8deadSopenharmony_ci wglSwapLayerBuffersMscOML works identically to wglSwapBuffersMscOML, 2015bd8deadSopenharmony_ci except that the specified layers of a window are swapped when the 2025bd8deadSopenharmony_ci buffer swap occurs, as defined in wglSwapLayerBuffers. The <planes> 2035bd8deadSopenharmony_ci parameter has the same definition as it has in the 2045bd8deadSopenharmony_ci wglSwapLayerBuffers function, and it indicates whether to swap 2055bd8deadSopenharmony_ci buffers for the overlay, underlay, or main planes of the window. 2065bd8deadSopenharmony_ci 2075bd8deadSopenharmony_ci Both wglSwapBuffersMscOML and wglSwapLayerBuffersMscOML return the 2085bd8deadSopenharmony_ci value that will correspond to the value of the SBC when the buffer 2095bd8deadSopenharmony_ci swap actually occurs (in other words, the return value will be the 2105bd8deadSopenharmony_ci current value of the SBC + the number of pending buffer swaps + 1). 2115bd8deadSopenharmony_ci Both functions will return a value of -1 if the function failed 2125bd8deadSopenharmony_ci because of errors detected in the input parameters. Both functions 2135bd8deadSopenharmony_ci are no-ops if the current pixel format for <hdc> does not include 2145bd8deadSopenharmony_ci a back buffer. 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci wglWaitForMscOML can be used to cause the calling thread to wait 2175bd8deadSopenharmony_ci until a specific graphics MSC value has been reached. If the current 2185bd8deadSopenharmony_ci MSC is less than the <target_msc> parameter for wglWaitForMscOML, 2195bd8deadSopenharmony_ci wglWaitForMscOML will block until the MSC value becomes equal to 2205bd8deadSopenharmony_ci <target_msc> and then will return the current values for UST, MSC, 2215bd8deadSopenharmony_ci and SBC. Otherwise, the function will block until the MSC value is 2225bd8deadSopenharmony_ci incremented to a value such that MSC % <divisor> = <remainder> and 2235bd8deadSopenharmony_ci then will return the current values for UST, MSC, and SBC. If 2245bd8deadSopenharmony_ci <divisor> = 0, then the wait will return as soon as MSC >= <target_msc>. 2255bd8deadSopenharmony_ci 2265bd8deadSopenharmony_ci wglWaitForSbcOML can be used to cause the calling thread to wait 2275bd8deadSopenharmony_ci until a specific SBC value has been reached. This function will block 2285bd8deadSopenharmony_ci until the SBC value for <hdc> becomes equal to <target_sbc> and then 2295bd8deadSopenharmony_ci will return the current values for UST, MSC, and SBC. If the SBC 2305bd8deadSopenharmony_ci value is already greater than or equal to <target_sbc>, the function 2315bd8deadSopenharmony_ci will return immediately with the current values for UST, MSC, and 2325bd8deadSopenharmony_ci SBC. If <target_sbc> = 0, the function will block until all previous 2335bd8deadSopenharmony_ci swaps requested with wglSwapBuffersMscOML or wglSwapLayerBuffersMscOML 2345bd8deadSopenharmony_ci for that window have completed. It will then return the current values 2355bd8deadSopenharmony_ci for UST, MSC, and SBC. 2365bd8deadSopenharmony_ci 2375bd8deadSopenharmony_ci When wglSwapBuffersMscOML or wglSwapLayerBuffersMscOML has been 2385bd8deadSopenharmony_ci called to cause a swap at a particular MSC, an application process 2395bd8deadSopenharmony_ci would observe the following order of execution for that MSC: 2405bd8deadSopenharmony_ci 2415bd8deadSopenharmony_ci 1. The window for which a wglSwapBuffersMscOML call has been 2425bd8deadSopenharmony_ci issued has been completely scanned out to the display for 2435bd8deadSopenharmony_ci the previous MSC 2445bd8deadSopenharmony_ci 2. The swap buffer action for that window begins 2455bd8deadSopenharmony_ci 3. All the swap buffer actions for all the windows for the 2465bd8deadSopenharmony_ci application process are completed 2475bd8deadSopenharmony_ci 4. SBC and MSC values are atomically incremented 2485bd8deadSopenharmony_ci 5. Any calls to wglWaitForMscOML or wglWaitForSbcOML that 2495bd8deadSopenharmony_ci are satisfied by the new values for SBC and graphics 2505bd8deadSopenharmony_ci MSC are released 2515bd8deadSopenharmony_ci 2525bd8deadSopenharmony_ci The functions wglGetSyncValuesOML, wglGetMscRateOML, wglWaitForMscOML, 2535bd8deadSopenharmony_ci and wglWaitForSbcOML will each return TRUE if the function completed 2545bd8deadSopenharmony_ci successfully, FALSE otherwise. 2555bd8deadSopenharmony_ci 2565bd8deadSopenharmony_ciDependencies on WGL_ARB_extensions_string 2575bd8deadSopenharmony_ci 2585bd8deadSopenharmony_ci Because there is no way to extend wgl, these calls are defined in 2595bd8deadSopenharmony_ci the ICD and can be called by obtaining the address with 2605bd8deadSopenharmony_ci wglGetProcAddress. Because this is not a GL extension, it is not 2615bd8deadSopenharmony_ci included in the GL_EXTENSIONS string. If this extension is supported 2625bd8deadSopenharmony_ci by the implementation, its name will be returned in the extension 2635bd8deadSopenharmony_ci string returned by wglGetExtensionString. 2645bd8deadSopenharmony_ci 2655bd8deadSopenharmony_ciErrors 2665bd8deadSopenharmony_ci 2675bd8deadSopenharmony_ci To get extended error information, call GetLastError. Each of the 2685bd8deadSopenharmony_ci functions defined by this extension may generate the following error: 2695bd8deadSopenharmony_ci 2705bd8deadSopenharmony_ci ERROR_DC_NOT_FOUND The <hDC> parameter was not valid. 2715bd8deadSopenharmony_ci 2725bd8deadSopenharmony_ci The following error will be generated for the functions 2735bd8deadSopenharmony_ci wglSwapBuffersMscOML, wglSwapLayerBuffersMscOML, and 2745bd8deadSopenharmony_ci wglWaitForMscOML, if <divisor> is less than zero, or if <remainder> 2755bd8deadSopenharmony_ci is less than zero, or if <remainder> is greater than or equal to 2765bd8deadSopenharmony_ci a non-zero <divisor>, or if <target_msc> is less than zero; and 2775bd8deadSopenharmony_ci for the function wglWaitForSbcOML if <target_sbc> is less than zero: 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci ERROR_INVALID_DATA A parameter is incorrect. 2805bd8deadSopenharmony_ci 2815bd8deadSopenharmony_ciNew State 2825bd8deadSopenharmony_ci 2835bd8deadSopenharmony_ci Get Value Get Command Type Initial Value 2845bd8deadSopenharmony_ci --------- ----------- ---- ------------- 2855bd8deadSopenharmony_ci [UST] wglGetSyncValuesOML Z unspecified 2865bd8deadSopenharmony_ci [MSC] wglGetSyncValuesOML Z 0 2875bd8deadSopenharmony_ci [SBC] wglGetSyncValuesOML Z 0 2885bd8deadSopenharmony_ci 2895bd8deadSopenharmony_ciNew Implementation Dependent State 2905bd8deadSopenharmony_ci 2915bd8deadSopenharmony_ci None 2925bd8deadSopenharmony_ci 2935bd8deadSopenharmony_ci 2945bd8deadSopenharmony_ci 2955bd8deadSopenharmony_ci 2965bd8deadSopenharmony_ci 2975bd8deadSopenharmony_ci 2985bd8deadSopenharmony_ci 2995bd8deadSopenharmony_ci 300