15bd8deadSopenharmony_ciXXX - Almost complete; needs GLX protocol.
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ciName
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ci    SGIX_instruments
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ciName Strings
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ci    GL_SGIX_instruments
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ciVersion
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ci    $Date: 1997/09/18 01:12:38 $ $Revision: 1.6 $
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ciNumber
165bd8deadSopenharmony_ci
175bd8deadSopenharmony_ci    55
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ciDependencies
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ci    None
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ciOverview
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ci    This extension allows the gathering and return of performance
265bd8deadSopenharmony_ci    measurements from within the graphics pipeline by adding
275bd8deadSopenharmony_ci    instrumentation.
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ci    There are two reasons to do this.  The first is as a part of some
305bd8deadSopenharmony_ci    type of fixed-frame-rate load management scheme.  If we know that
315bd8deadSopenharmony_ci    the pipeline is stalled or struggling to process the amount of
325bd8deadSopenharmony_ci    data we have given it so far, we can reduce the level of detail of
335bd8deadSopenharmony_ci    the remaining objects in the current frame or the next frame, or
345bd8deadSopenharmony_ci    adjust the framebuffer resolution for the next frame if we have a
355bd8deadSopenharmony_ci    video-zoom capability available.  We can call this type of
365bd8deadSopenharmony_ci    instrumentation Load Monitoring.
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ci    The second is for performance tuning and debugging of an
395bd8deadSopenharmony_ci    application. It might tell us how many triangles were culled or
405bd8deadSopenharmony_ci    clipped before being rasterized.  We can call this simply Tuning.
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ci    Load Monitoring requires that the instrumentation and the access
435bd8deadSopenharmony_ci    of the measurements be efficient, otherwise the instrumentation
445bd8deadSopenharmony_ci    itself will reduce performance more than any load-management
455bd8deadSopenharmony_ci    scheme could hope to offset.  Tuning does not have the same
465bd8deadSopenharmony_ci    requirements.
475bd8deadSopenharmony_ci
485bd8deadSopenharmony_ci    The proposed extension adds a call to setup a measurements return
495bd8deadSopenharmony_ci    buffer, similar to FeedbackBuffer but with an asynchrounous
505bd8deadSopenharmony_ci    behavior to prevent filling the pipeline with NOP's while waiting
515bd8deadSopenharmony_ci    for the data to be returned.
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ci    Note that although the extension has been specified without any
545bd8deadSopenharmony_ci    particular instruments, defining either a device dependent or
555bd8deadSopenharmony_ci    device independent instrument should be as simple as introducing
565bd8deadSopenharmony_ci    an extension consisting primarily of a new enumerant to identify
575bd8deadSopenharmony_ci    the instrument.
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ciNew Procedures and Functions
605bd8deadSopenharmony_ci
615bd8deadSopenharmony_ci    void InstrumentsBufferSGIX(sizei size, int *buf)
625bd8deadSopenharmony_ci
635bd8deadSopenharmony_ci    void StartInstrumentsSGIX(void)
645bd8deadSopenharmony_ci
655bd8deadSopenharmony_ci    void StopInstrumentsSGIX(int marker)
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    void ReadInstrumentsSGIX(int marker)
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ci    int PollInstrumentsSGIX(int *markerp)
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ci    int GetInstrumentsSGIX(void)
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ci    An example of using the calls to test the extension:
745bd8deadSopenharmony_ci{
755bd8deadSopenharmony_ci#ifdef GL_SGIX_instruments
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci   static GLint buffer[64];
785bd8deadSopenharmony_ci   void *bufp;
795bd8deadSopenharmony_ci   int id, count0, count1, r;
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ci   /* define the buffer to hold the measurments */
825bd8deadSopenharmony_ci   glInstrumentsBufferSGIX(sizeof(buffer)/sizeof(GLint), (GLint *) buffer);
835bd8deadSopenharmony_ci
845bd8deadSopenharmony_ci   /* enable the instruments from which one wishes to take measurements */
855bd8deadSopenharmony_ci   glEnable(<an enum for instrument in use>);
865bd8deadSopenharmony_ci
875bd8deadSopenharmony_ci   glStartInstrumentsSGIX();
885bd8deadSopenharmony_ci   /* insert GL commands here */
895bd8deadSopenharmony_ci   glReadInstrumentsSGIX(14);
905bd8deadSopenharmony_ci   /* insert GL commands here */
915bd8deadSopenharmony_ci   glStopInstrumentsSGIX(15);
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci   /* the number of msrmnts since the buffer was specified can be queried */
945bd8deadSopenharmony_ci   glGetIntegerv(GL_INSTRUMENT_MEASUREMENTS_SGIX,&r); /* r should be 2 */
955bd8deadSopenharmony_ci
965bd8deadSopenharmony_ci   glGetPointervEXT(GL_INSTRUMENT_BUFFER_SGIX,&bufp);
975bd8deadSopenharmony_ci   /* bufp should be equal to buffer */
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_ci   /*
1005bd8deadSopenharmony_ci    * we can do a GetInstrumentsSGIX before or after the calls to
1015bd8deadSopenharmony_ci    * PollInstrumentsSGIX but to be sure of exactly what
1025bd8deadSopenharmony_ci    * measurements are in the buffer, we can use PollInstrumentsSGIX.
1035bd8deadSopenharmony_ci    */
1045bd8deadSopenharmony_ci   count0 = glGetInstrumentsSGIX();
1055bd8deadSopenharmony_ci   /* count0 will be a count of from 0 to 2 multiples of the size
1065bd8deadSopenharmony_ci    * in words of the instrument measurement we have enabled.
1075bd8deadSopenharmony_ci    * If buffer was overflowed, count0 will be 1.
1085bd8deadSopenharmony_ci    */
1095bd8deadSopenharmony_ci
1105bd8deadSopenharmony_ci   while (!(r = glPollInstrumentsSGIX(&id))) ;
1115bd8deadSopenharmony_ci   /* if r is -1, we have overflowed, if it is 1, id will
1125bd8deadSopenharmony_ci    * have the value of the marker passed in with the first
1135bd8deadSopenharmony_ci    * measurement request (should be 14)
1145bd8deadSopenharmony_ci    */
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ci   while (!(r = glPollInstrumentsSGIX(&id))) ;
1175bd8deadSopenharmony_ci   /* see the note on the first poll; id should be 15 */
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci   count1 = glGetInstrumentsSGIX();
1205bd8deadSopenharmony_ci   /* the sum of count0 and count1 should be 2 times
1215bd8deadSopenharmony_ci    * the size in words of an instrument measurement
1225bd8deadSopenharmony_ci    * that we have enabled.
1235bd8deadSopenharmony_ci    */
1245bd8deadSopenharmony_ci
1255bd8deadSopenharmony_ci#endif
1265bd8deadSopenharmony_ci}
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ci
1295bd8deadSopenharmony_ciNew Tokens
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetIntegerv, GetFloatv, and
1325bd8deadSopenharmony_ci    GetDoublev:
1335bd8deadSopenharmony_ci
1345bd8deadSopenharmony_ci    INSTRUMENT_MEASUREMENTS_SGIX
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetPointervEXT:
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    INSTRUMENT_BUFFER_POINTER_SGIX
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ciAdditions to Chapter 2 of the 1.0 Specification (OpenGL Operation)
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ci    None
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ciAdditions to Chapter 3 of the 1.0 Specification (Rasterization)
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ci    None
1475bd8deadSopenharmony_ci
1485bd8deadSopenharmony_ciAdditions to Chapter 4 of the 1.0 Specification (Per-Fragment
1495bd8deadSopenharmony_ciOperations and the Frame Buffer)
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci    None
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ciAdditions to Chapter 5 of the 1.0 Specification (Special Functions)
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ci    The following commands are not included in display lists:
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ci        InstrumentsBufferSGIX
1585bd8deadSopenharmony_ci        PollInstrumentsSGIX
1595bd8deadSopenharmony_ci        GetInstrumentsSGIX
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ci    Add a section 5.X entitled  Instruments:
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci    Instruments provide a method to measure performance of the GL
1645bd8deadSopenharmony_ci    pipeline and identify possible bottlenecks. This information may
1655bd8deadSopenharmony_ci    be useful in feedback-based load management schemes which attempt
1665bd8deadSopenharmony_ci    to maintain a constant frame-rate.  A set of functions is provided
1675bd8deadSopenharmony_ci    which allows an asynchronous implementation such that the graphics
1685bd8deadSopenharmony_ci    pipeline need not be stalled while measurements are returned to
1695bd8deadSopenharmony_ci    the client.
1705bd8deadSopenharmony_ci
1715bd8deadSopenharmony_ci    A buffer in which to collect instrument measurements is defined
1725bd8deadSopenharmony_ci    with InstrumentsBufferSGIX, where <size> defines the size of the
1735bd8deadSopenharmony_ci    buffer.  If <buf> has been previously defined with a prior call,
1745bd8deadSopenharmony_ci    the buffer is reset, that is, measurements taken after the call to
1755bd8deadSopenharmony_ci    InstrumentsBufferSGIX will be written to the start of the buffer.
1765bd8deadSopenharmony_ci    Otherwise the buffer will be processed in a way that allows
1775bd8deadSopenharmony_ci    asynchronous writing to the buffer from the graphics pipeline. If
1785bd8deadSopenharmony_ci    <buf> is zero, then any resources allocated to prepare the buffer
1795bd8deadSopenharmony_ci    for writing from the graphics pipeline from a previous call will
1805bd8deadSopenharmony_ci    be freed. If <buf> is non-zero, but is different from a previous
1815bd8deadSopenharmony_ci    call, the old buffer is considered to be replaced by the new
1825bd8deadSopenharmony_ci    buffer and any allocated resources involved in preparing the old
1835bd8deadSopenharmony_ci    buffer for writing are freed.
1845bd8deadSopenharmony_ci
1855bd8deadSopenharmony_ci    If <size> is negative an INVALID_VALUE is generated.
1865bd8deadSopenharmony_ci
1875bd8deadSopenharmony_ci    An INVALID_OPERATION is generated if InstrumentsBufferSGIX is
1885bd8deadSopenharmony_ci    called between Begin/End.
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ci    If there are multiple instruments enabled, the measurement for
1915bd8deadSopenharmony_ci    each enabled instrument can appear in the buffer in any order for
1925bd8deadSopenharmony_ci    a given measurement.
1935bd8deadSopenharmony_ci
1945bd8deadSopenharmony_ci    The buffer address can be queried with glGetPointervEXT using
1955bd8deadSopenharmony_ci    <pname> GL_INSTRUMENT_BUFFER_POINTER.
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ci    To start the enabled instrument(s) before taking a measurement
1985bd8deadSopenharmony_ci    execute StartInstrumentsSGIX. To stop the enabled instruments and
1995bd8deadSopenharmony_ci    take a measurement use StopInstrumentsSGIX. The parameter <marker>
2005bd8deadSopenharmony_ci    is passed through the pipe and written back to the buffer to ease
2015bd8deadSopenharmony_ci    the task of interpreting the buffer.
2025bd8deadSopenharmony_ci
2035bd8deadSopenharmony_ci    To take an instrument measurement use ReadInstrumentsSGIX.  The
2045bd8deadSopenharmony_ci    parameter <marker> is processed as with StopInstrumentsSGIX.
2055bd8deadSopenharmony_ci
2065bd8deadSopenharmony_ci    An INVALID_OPERATION is generated if StartInstrumentsSGIX is
2075bd8deadSopenharmony_ci    executed twice without an intervening execution of
2085bd8deadSopenharmony_ci    StopInstrumentsSGIX or InstrumentsBufferSGIX. Symetrically, an
2095bd8deadSopenharmony_ci    INVALID_OPERATION is generated if StopInstrumentsSGIX is executed
2105bd8deadSopenharmony_ci    twice without an intervening execution of StartInstrumentsSGIX.
2115bd8deadSopenharmony_ci    ReadInstrumentsSGIX will generate an INVALID_OPERATION if executed
2125bd8deadSopenharmony_ci    after an execution of StopInstruments without an intervening
2135bd8deadSopenharmony_ci    execution of StopInstrumentsSGIX or InstrumentsBufferSGIX.
2145bd8deadSopenharmony_ci
2155bd8deadSopenharmony_ci    Executing any of StartInstrumentsSGIX, StopInstrumentsSGIX,
2165bd8deadSopenharmony_ci    ReadInstruments without a successful call to InstrumentsBufferSGIX
2175bd8deadSopenharmony_ci    to define a buffer will generate an INVALID_OPERATION.  Executing
2185bd8deadSopenharmony_ci    any of StartInstrumentsSGIX, StopInstrumentsSGIX, ReadInstruments
2195bd8deadSopenharmony_ci    between Begin/End will generate an INVALID_OPERATION
2205bd8deadSopenharmony_ci
2215bd8deadSopenharmony_ci    If no instruments are enabled, executions of StartInstrumentsSGIX,
2225bd8deadSopenharmony_ci    StopInstrumentsSGIX, ReadInstruments will not write measurements
2235bd8deadSopenharmony_ci    to the buffer.
2245bd8deadSopenharmony_ci
2255bd8deadSopenharmony_ci    The number of measurements taken since the buffer was reset can be
2265bd8deadSopenharmony_ci    queried with glGet using <pname> GL_INSTRUMENT_MEASUREMENTS.
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci    To determine whether a measurement of the enabled instruments has
2295bd8deadSopenharmony_ci    been written to the buffer call PollInstrumentsSGIX.  If a new
2305bd8deadSopenharmony_ci    measurement has appeared in the buffer since the last call to
2315bd8deadSopenharmony_ci    PollInstrumentsSGIX, 1 will be returned, otherwise zero is
2325bd8deadSopenharmony_ci    returned.  If 1 is returned, the value of marker associated with
2335bd8deadSopenharmony_ci    the measurement and passed to StopInstrumentsSGIX or
2345bd8deadSopenharmony_ci    ReadInstrumentsSGIX is written into the integer referred to by
2355bd8deadSopenharmony_ci    <markerp>. The measurements will appear in the buffer in the order
2365bd8deadSopenharmony_ci    in which they were requested. If the buffer is overflowed,
2375bd8deadSopenharmony_ci    PollInstrumentsSGIX may return -1 as soon as the overflow is
2385bd8deadSopenharmony_ci    detected, even if the measurement being polled for did not cause
2395bd8deadSopenharmony_ci    the overflow. An implementation may choose to delay reporting the
2405bd8deadSopenharmony_ci    overflow until the measurement that caused the overflow is the one
2415bd8deadSopenharmony_ci    being polled.
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ci    To get a total count of the number of new valid words written to
2445bd8deadSopenharmony_ci    the buffer call GetInstrumentsSGIX. The value returned is the
2455bd8deadSopenharmony_ci    number of ints that have been written to the buffer since the last
2465bd8deadSopenharmony_ci    call to GetInstrumentsSGIX. GetInstrumentsSGIX can be used
2475bd8deadSopenharmony_ci    independently of PollInstrumentsSGIX. If the buffer has been
2485bd8deadSopenharmony_ci    overflowed since the last call to GetInstrumentsSGIX, -1 is
2495bd8deadSopenharmony_ci    returned for the count.
2505bd8deadSopenharmony_ci
2515bd8deadSopenharmony_ciAdditions to Chapter 6 of the 1.0 Specification (State and State Requests)
2525bd8deadSopenharmony_ci
2535bd8deadSopenharmony_ci    The GL_INSTRUMENT_BUFFER_POINTER_SGIX enum should be added to the
2545bd8deadSopenharmony_ci    list of enum's recognized by GetPointerv.
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ciAdditions to the GLX Specification
2575bd8deadSopenharmony_ci
2585bd8deadSopenharmony_ci    None
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ciGLX Protocol
2615bd8deadSopenharmony_ci
2625bd8deadSopenharmony_ci    XXX - not yet complete
2635bd8deadSopenharmony_ci
2645bd8deadSopenharmony_ciErrors
2655bd8deadSopenharmony_ci
2665bd8deadSopenharmony_ci    An INVALID_OPERATION is generated if any of the instruments
2675bd8deadSopenharmony_ci    functions or procedures are called within Begin/End.
2685bd8deadSopenharmony_ci
2695bd8deadSopenharmony_ci    When calling glInstrumentsBufferSGIX, an INVALID_VALUE is
2705bd8deadSopenharmony_ci    generated if <size> is negative.
2715bd8deadSopenharmony_ci
2725bd8deadSopenharmony_ci    An INVALID_OPERATION is generated if two StartInstrumentsSGIX are
2735bd8deadSopenharmony_ci    called without an intervening call to StopInstrumentsSGIX or
2745bd8deadSopenharmony_ci    InstrumentsBufferSGIX. Symetrically, an INVALID_OPERATION is
2755bd8deadSopenharmony_ci    generated if StopInstrumentsSGIX is called twice without an
2765bd8deadSopenharmony_ci    intervening StartInstrumentsSGIX.  ReadInstrumentsSGIX will
2775bd8deadSopenharmony_ci    generate an INVALID_OPERATION if called after a call to
2785bd8deadSopenharmony_ci    StopInstruments without an intervening call to StopInstrumentsSGIX
2795bd8deadSopenharmony_ci    or InstrumentsBufferSGIX.
2805bd8deadSopenharmony_ci
2815bd8deadSopenharmony_ci    Calling any of StartInstrumentsSGIX, StopInstrumentsSGIX,
2825bd8deadSopenharmony_ci    ReadInstruments without a successful call to InstrumentsBufferSGIX
2835bd8deadSopenharmony_ci    to define a buffer will generate an INVALID_OPERATION.
2845bd8deadSopenharmony_ci
2855bd8deadSopenharmony_ciNew State
2865bd8deadSopenharmony_ci
2875bd8deadSopenharmony_ci    Initial                             Initial
2885bd8deadSopenharmony_ci    Get Value                           Get Command     Type    Value   Attrib
2895bd8deadSopenharmony_ci    ---------                           -----------     ----    -----   ------
2905bd8deadSopenharmony_ci    INSTRUMENT_MEASUREMENTS_SGIX        GetInteger      Z       0         -
2915bd8deadSopenharmony_ci    INSTRUMENT_BUFFER_POINTER_SGIX      GetPointervEXT  Y       0         -
2925bd8deadSopenharmony_ci
2935bd8deadSopenharmony_ciNew Implementation Dependent State
2945bd8deadSopenharmony_ci
2955bd8deadSopenharmony_ci    None
2965bd8deadSopenharmony_ci
297