<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
              "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
<refentry id="glFenceSync">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>2010</year>
                <holder>Khronos Group</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glFenceSync</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glFenceSync</refname>
        <refpurpose>create a new sync object and insert it into the GL command stream</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>GLsync <function>glFenceSync</function></funcdef>
                <paramdef>GLenum <parameter>condition</parameter></paramdef>
                <paramdef>GLbitfield <parameter>flags</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <!-- eqn: ignoring delim $$ -->
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>condition</parameter></term>
            <listitem>
                <para>
                    Specifies the condition that must be met to set the sync object's state to signaled. <parameter>condition</parameter>
                    must be <constant>GL_SYNC_GPU_COMMANDS_COMPLETE</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>flags</parameter></term>
            <listitem>
                <para>
                    Specifies a bitwise combination of flags controlling the behavior of the sync object. No flags are presently defined
                    for this operation and <parameter>flags</parameter> must be zero.<footnote><para>
                        <parameter>flags</parameter> is a placeholder for anticipated future extensions of fence sync object capabilities.
                        </para>
                    </footnote>
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            <function>glFenceSync</function> creates a new fence sync object, inserts a fence command into the GL command stream and
            associates it with that sync object, and returns a non-zero name corresponding to the sync object.
        </para>
        <para>
            When the specified <parameter>condition</parameter> of the sync object is satisfied by the fence command, the sync object
            is signaled by the GL, causing any <citerefentry><refentrytitle>glWaitSync</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glClientWaitSync</refentrytitle></citerefentry> commands blocking in <parameter>sync</parameter>
            to <emphasis>unblock</emphasis>. No other state is affected by <function>glFenceSync</function> or by the execution
            of the associated fence command.
        </para>
        <para>
            <parameter>condition</parameter> must be <constant>GL_SYNC_GPU_COMMANDS_COMPLETE</constant>. This condition is satisfied by 
            completion of the fence command corresponding to the sync object and all preceding commands in the same command stream.
            The sync object will not be signaled until all effects from these commands on GL client and server state and the
            framebuffer are fully realized. Note that completion of the fence command occurs once the state of the corresponding sync
            object has been changed, but commands waiting on that sync object may not be unblocked until after the fence command completes.
        </para>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
        <function>glFenceSync</function> is only supported if the GL version is 3.2 or greater, or if
            the <code>ARB_sync</code> extension is supported.
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>GL_INVALID_ENUM</constant> is generated if <parameter>condition</parameter> is not
            <constant>GL_SYNC_GPU_COMMANDS_COMPLETE</constant>.
        </para>
        <para>
            <constant>GL_INVALID_VALUE</constant> is generated if <parameter>flags</parameter> is not zero.
        </para>
        <para>
            Additionally, if <function>glFenceSync</function> fails, it will return zero.
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glDeleteSync</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glGetSync</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glWaitSync</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glClientWaitSync</refentrytitle></citerefentry>
        </para>
    </refsect1>
    <refsect1 id="Copyright"><title>Copyright</title>
        <para>
            Copyright <trademark class="copyright"></trademark> 2010 Khronos Group. 
            This material may be distributed subject to the terms and conditions set forth in 
            the Open Publication License, v 1.0, 8 June 1999.
            <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>.
        </para>
    </refsect1>
</refentry>
