Direct State Access

From OpenGL Wiki
Revision as of 19:06, 10 April 2015 by Alfonse (talk | contribs) (Start on article about DSA.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Direct State Access
Core in version 4.6
Core since version 4.5
Core ARB extension ARB_direct_state_access
EXT extension EXT_direct_state_access

Direct State Access (DSA) is a means of modifying OpenGL Objects without having to bind them to the context. This allows one to modify object state within a local context without affecting global state shared by all parts of an application. It also makes the API a bit more object-oriented, as functions that modify the state of objects can be clearly identified.

Changes from EXT

The core DSA functionality, and the Core Extension equivalent, have some differences compared to the original EXT_direct_state_access extension. One of the most obvious is the fact that the EXT version supported a great deal of Compatibility state; the core version only supports core OpenGL functionality.

This also extends to not providing support for some things that are technically core OpenGL, but have preferred ways of doing them. For example, the core DSA functions only allow the use of separate vertex format definitions, and storage allocated for Textures must be immutable, However, Buffer Object storage can still be mutable.

A more subtle change has to do with the dichotomy between object names and object data. In the pre-DSA days, glGen* functions generate object names only; they don't generate the state stored in those objects. That is generated by the various glBind* functions. This was useful, but created a problem when it came time to want to modify an object's state without binding it.

Core DSA and EXT_DSA take different approaches to resolving this problem. In EXT_DSA, all of the DSA-style functions could take an object name that had no state data associated with it (ie: had not yet been bound). These functions were therefore required to be able to generate the state behind those names, then perform whatever processing the function normally did.

Core DSA does not do this. If you pass a new object to any of the core DSA functions, they will fail with GL_INVALID_OPERATION. Instead, the object's state must be initialized. This can be done via glBind* functions (which goes against the point of the functionality), but the preferred method is to use the glCreate* set of functions. These create object names and fill them with their initial state. Those object types which have a target that defines the type of that object (Textures and Query Objects) have this type specified by their glCreate* function.

The core DSA functionality provides glCreate* support even for object types that technically do not need it. These being Sampler Objects and Program Pipeline Objects, both of which already use DSA-style operations (though they both use the EXT wording, where every DSA function that takes one will give it state).

This change also affected many of the API functions. For example, the DSA functions for modifying Textures all took both a texture and the texture's target in the EXT version. The core functions do not, as the texture type is defined when the object's state is created (either via glBindTexture or via glCreateTextures).

The core functionality also supports a few OpenGL features released since EXT_DSA was published. It provides full Multibind support for vertex array object buffer binding, and unlike EXT_DSA, it offers support for Query Objects.

Nomenclature