Shader Storage Buffer Object: Difference between revisions
Line 18: | Line 18: | ||
# SSBOs are typically much larger. The smallest required UBO size is 16KB; the smallest required SSBO size is 16'''MB''', and typical sizes will be on the order of the size of GPU memory. | # SSBOs are typically much larger. The smallest required UBO size is 16KB; the smallest required SSBO size is 16'''MB''', and typical sizes will be on the order of the size of GPU memory. | ||
# SSBOs are writable, even atomically; UBOs are {{code|uniform}}s. SSBOs | # SSBOs are writable, even atomically; UBOs are {{code|uniform}}s. SSBOs reads and writes use [[Memory_Model#Incoherent_memory_access|incoherent memory accesses]], so they need the appropriate barriers, just as [[Image Load Store]] operations. | ||
# SSBOs can have unbounded storage, up to the buffer range bound; UBOs must have a specific, fixed storage size. This means that you can have an array of arbitrary length in an SSBO. The actual size of the array, based on the range of the buffer bound, can be queried at runtime in the shader using the {{code|length}} function on the unbounded array variable. | # SSBOs can have unbounded storage, up to the buffer range bound; UBOs must have a specific, fixed storage size. This means that you can have an array of arbitrary length in an SSBO. The actual size of the array, based on the range of the buffer bound, can be queried at runtime in the shader using the {{code|length}} function on the unbounded array variable. | ||
Revision as of 03:04, 4 January 2013
|
||||||||||||
OpenGL Objects
|
A Shader Storage Buffer Object is a Buffer Object that is used to store and retrieve data from GLSL.
This article is a stub. You can help the OpenGL Wiki by expanding it. |
Overview
SSBOs are a lot like Uniform Buffer Objects. Shader storage blocks are defined almost identically to uniform blocks. SSBOs are bound to SSBO binding points, just as UBOs are bound to UBO binding points. And so forth.
The major differences between them are:
- SSBOs are typically much larger. The smallest required UBO size is 16KB; the smallest required SSBO size is 16MB, and typical sizes will be on the order of the size of GPU memory.
- SSBOs are writable, even atomically; UBOs are uniforms. SSBOs reads and writes use incoherent memory accesses, so they need the appropriate barriers, just as Image Load Store operations.
- SSBOs can have unbounded storage, up to the buffer range bound; UBOs must have a specific, fixed storage size. This means that you can have an array of arbitrary length in an SSBO. The actual size of the array, based on the range of the buffer bound, can be queried at runtime in the shader using the length function on the unbounded array variable.
Functionally speaking, SSBOs can be thought of as a much nicer interface to Buffer Textures when accessed via Image Load Store.
Atomic operations
There are special atomic functions that can be applied to buffer variables (and to compute shader shared variables). They only take uint or int types, but these can be members of aggregates (structs/arrays) or vector elements (ie: you can atomically access uvec3.x).
All of the atomic functions return the original value. The term "nint" can be int or uint.
Adds data to mem.
The mem's value is no lower than data.
The mem's value is no greater than data.
mem becomes the bitwise-and between mem and data.
mem becomes the bitwise-or between mem and data.
mem becomes the bitwise-xor between mem and data.
Sets mem's value to data.
If the current value of mem is equal to compare, then mem is set to data. Otherwise it is left unchanged.