<!DOCTYPE refentry [ <!ENTITY % mathent SYSTEM "math.ent"> %mathent; ]>

<!-- Converted by db4-upgrade version 1.1 -->

<refentry xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="barrier">
    <info>
        <copyright>
            <year>2011-2014</year>
            <holder>Khronos Group</holder>
        </copyright>
    </info>
    <refmeta>
        <refentrytitle>barrier</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>barrier</refname>
        <refpurpose>synchronize execution of multiple shader invocations</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>Declaration</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>void <function>barrier</function></funcdef>
                <paramdef>void</paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <refsect1 xml:id="description"><title>Description</title>
        <para>
            <emphasis>Available only in the Tessellation Control and Compute Shaders</emphasis>, <function>barrier</function> provides
            a partially defined order of execution between shader invocations. For any given static instance of <function>barrier</function>,
            in a tessellation control shader, all invocations for a single input patch must enter it before any will be allowed
            to continue beyond it. For any given static instance of <function>barrier</function> in a compute shader, all invocations
            within a single work group must enter it before any are allowed to continue beyond it.
            This ensures that values written by one invocation prior to a given static instance
            of <function>barrier</function> can be safely read by other invocations after their call to the same static
            instance of <function>barrier</function>. Because invocations may execute in undefined order between these
            <function>barrier</function> calls, the values of a per-vertex or per-patch output variable, or any shared variable will be undefined
            in a number of cases.
        </para>
        <para>
            <function>barrier</function> may only be placed inside the function <code>main()</code> of the tessellation
            control shader, but may be placed anywhere in a compute shader. Calls to <function>barrier</function> may not
            be placed within any control flow. Barriers are also disallowed after a return
            statement in the function <code>main()</code>.
        </para>
    </refsect1>
    <refsect1 xml:id="versions"><title>Version Support</title>
        <informaltable>
            <tgroup cols="13" align="left">
                <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="funchead.xml" xpointer="xpointer(/*/*)"/>
                <tbody>
                    <row>
                        <entry>barrier</entry>
                        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="version.xml" xpointer="xpointer(/*/*[@role='40']/*)"/>
                    </row>
                </tbody>
            </tgroup>
        </informaltable>
    </refsect1>
    <refsect1 xml:id="Copyright"><title>Copyright</title>
        <para>
            Copyright <trademark class="copyright"/> 2011-2014 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.
            <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://opencontent.org/openpub/">http://opencontent.org/openpub/</link>.
        </para>
    </refsect1>
</refentry>
