21.06.2014 Views

OpenGL 4.2 (Compatibility Profile) - April 27, 2012

OpenGL 4.2 (Compatibility Profile) - April 27, 2012

OpenGL 4.2 (Compatibility Profile) - April 27, 2012

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.14. VERTEX SHADERS 157<br />

invocation assumes that the other invocation has been launched and can complete<br />

its writes. The only case where such a guarantee is made is when the inputs of<br />

one shader invocation are generated from the outputs of a shader invocation in a<br />

previous stage.<br />

Stores issued to different memory locations within a single shader invocation<br />

may not be visible to other invocations in the order they were performed. The<br />

built-in function memoryBarrier() may be used to provide stronger ordering of<br />

reads and writes performed by a single invocation. Calling memoryBarrier()<br />

guarantees that any memory transactions issued by the shader invocation prior to<br />

the call complete prior to the memory transactions issued after the call. Memory<br />

barriers may be needed for algorithms that require multiple invocations to access<br />

the same memory and require the operations need to be performed in a partiallydefined<br />

relative order. For example, if one shader invocation does a series of writes,<br />

followed by a memoryBarrier() call, followed by another write, then another<br />

invocation that sees the results of the final write will also see the previous writes.<br />

Without the memory barrier, the final write may be visible before the previous<br />

writes.<br />

The built-in atomic memory transaction functions may be used to read and<br />

write a given memory address atomically. While built-in atomic functions issued<br />

by multiple shader invocations are executed in undefined order relative to each<br />

other, these functions perform both a read and a write of a memory address and<br />

guarantee that no other memory transaction will write to the underlying memory<br />

between the read and write. Atomics allow shaders to use shared global addresses<br />

for mutual exclusion or as counters, among other uses.<br />

Shader Memory Access Synchronization<br />

Data written to textures or buffer objects by a shader invocation may eventually<br />

be read by other shader invocations, sourced by other fixed pipeline stages, or read<br />

back by the application. When applications write to buffer objects or textures using<br />

API commands such as TexSubImage* or BufferSubData, the GL implementation<br />

knows when and where writes occur and can perform implicit synchronization<br />

to ensure that operations requested before the update see the original data and<br />

that subsequent operations see the modified data. Without logic to track the target<br />

address of each shader instruction performing a store, automatic synchronization<br />

of stores performed by a shader invocation would require the GL implementation<br />

to make worst-case assumptions at significant performance cost. To permit<br />

cases where textures or buffers may be read or written in different pipeline stages<br />

without the overhead of automatic synchronization, buffer object and texture stores<br />

performed by shaders are not automatically synchronized with other GL operations<br />

<strong>OpenGL</strong> <strong>4.2</strong> (<strong>Compatibility</strong> <strong>Profile</strong>) - <strong>April</strong> <strong>27</strong>, <strong>2012</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!