View is primary sorting mechanism in bgfx. View represent bucket of draw and compute calls. Compute
and draw calls inside bucket are sorted in the way that all compute calls are executed before draw
calls. Compute calls are always in order of submission, while draw calls are sorted by internal
state if view is not in sequential mode. In the most of cases when z-buffer is used this change in
order is not noticable to desired output. In cases where order has to be preserved (for example in
rendering GUIs), view can be set to be in sequential order. Sequential order is less efficient,
because it doesn’t allow state change optimization, and should be avoided when possible.

By default views ids are sorted in ascending order. For dynamic renderers where order might not be
known until the last moment, view ids can be remaped to arbitrary order by calling
bgfx::setViewOrder.

If texture is 2D this argument should be 0. If destination texture is cube this argument represents destination texture cube face. For 3D texture this argument represents destination texture Z position.

_src -

Source texture handle.

_srcMip -

Source texture mip level.

_srcX -

Source texture X position.

_srcY -

Source texture Y position.

_srcZ -

If texture is 2D this argument should be 0. If source texture is cube this argument represents source texture cube face. For 3D texture this argument represents source texture Z position.

_width -

Width of region.

_height -

Height of region.

_depth -

If texture is 3D this argument represents depth of region, otherwise it’s unused.

If texture is 2D this argument should be 0. If destination texture is cube this argument represents destination texture cube face. For 3D texture this argument represents destination texture Z position.

_src -

Source texture handle.

_srcMip -

Source texture mip level.

_srcX -

Source texture X position.

_srcY -

Source texture Y position.

_srcZ -

If texture is 2D this argument should be 0. If source texture is cube this argument represents source texture cube face. For 3D texture this argument represents source texture Z position.

_width -

Width of region.

_height -

Height of region.

_depth -

If texture is 3D this argument represents depth of region, otherwise it’s unused.

Make reference to data to pass to bgfx. Unlike bgfx::alloc, this call doesn’t allocate memory for data. It just copies the _data pointer. You can pass ReleaseFn function pointer to release this memory after it’s consumed, otherwise you must make sure _data is available for at least 2 bgfx::frame calls. ReleaseFn function must be able to be called from any thread.

Uniform names are unique. It’s valid to call bgfx::createUniform multiple times with the same uniform name. The library will always return the same handle, but the handle reference count will be incremented. This means that the same number of bgfx::destroyUniform must be called to properly destroy the uniform.

Predefined uniforms (declared in bgfx_shader.sh):

u_viewRectvec4(x,y,width,height) - view rectangle for current view, in pixels.

BGFX_BUFFER_COMPUTE_READ - Buffer will be read from by compute shader.

BGFX_BUFFER_COMPUTE_WRITE - Buffer will be written into by compute shader. When buffer is created with BGFX_BUFFER_COMPUTE_WRITE flag it cannot be updated from CPU.

BGFX_BUFFER_COMPUTE_READ_WRITE - Buffer will be used for read/write by compute shader.

BGFX_BUFFER_ALLOW_RESIZE - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers.

BGFX_BUFFER_INDEX32 - Buffer is using 32-bit indices. This flag has effect only on index buffers.

When using fixed point AttribType (f.e. Uint8) value will be normalized for vertex shader usage. When normalized is set to true, AttribType::Uint8 value in range 0-255 will be in range 0.0-1.0 in vertex shader.

BGFX_BUFFER_COMPUTE_READ - Buffer will be read from by compute shader.

BGFX_BUFFER_COMPUTE_WRITE - Buffer will be written into by compute shader. When buffer is created with BGFX_BUFFER_COMPUTE_WRITE flag it cannot be updated from CPU.

BGFX_BUFFER_COMPUTE_READ_WRITE - Buffer will be used for read/write by compute shader.

BGFX_BUFFER_ALLOW_RESIZE - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers.

BGFX_BUFFER_INDEX32 - Buffer is using 32-bit indices. This flag has effect only on index buffers.

BGFX_BUFFER_COMPUTE_READ - Buffer will be read from by compute shader.

BGFX_BUFFER_COMPUTE_WRITE - Buffer will be written into by compute shader. When buffer is created with BGFX_BUFFER_COMPUTE_WRITE flag it cannot be updated from CPU.

BGFX_BUFFER_COMPUTE_READ_WRITE - Buffer will be used for read/write by compute shader.

BGFX_BUFFER_ALLOW_RESIZE - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers.

BGFX_BUFFER_INDEX32 - Buffer is using 32-bit indices. This flag has effect only on index buffers.

BGFX_BUFFER_COMPUTE_READ - Buffer will be read from by compute shader.

BGFX_BUFFER_COMPUTE_WRITE - Buffer will be written into by compute shader. When buffer is created with BGFX_BUFFER_COMPUTE_WRITE flag it cannot be updated from CPU.

BGFX_BUFFER_COMPUTE_READ_WRITE - Buffer will be used for read/write by compute shader.

BGFX_BUFFER_ALLOW_RESIZE - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers.

BGFX_BUFFER_INDEX32 - Buffer is using 32-bit indices. This flag has effect only on index buffers.

BGFX_BUFFER_COMPUTE_READ - Buffer will be read from by compute shader.

BGFX_BUFFER_COMPUTE_WRITE - Buffer will be written into by compute shader. When buffer is created with BGFX_BUFFER_COMPUTE_WRITE flag it cannot be updated from CPU.

BGFX_BUFFER_COMPUTE_READ_WRITE - Buffer will be used for read/write by compute shader.

BGFX_BUFFER_ALLOW_RESIZE - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers.

BGFX_BUFFER_INDEX32 - Buffer is using 32-bit indices. This flag has effect only on index buffers.

BGFX_BUFFER_COMPUTE_READ - Buffer will be read from by compute shader.

BGFX_BUFFER_COMPUTE_WRITE - Buffer will be written into by compute shader. When buffer is created with BGFX_BUFFER_COMPUTE_WRITE flag it cannot be updated from CPU.

BGFX_BUFFER_COMPUTE_READ_WRITE - Buffer will be used for read/write by compute shader.

BGFX_BUFFER_ALLOW_RESIZE - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers.

BGFX_BUFFER_INDEX32 - Buffer is using 32-bit indices. This flag has effect only on index buffers.

BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC] - Point or anisotropic sampling.

_mem -

Texture data. If _mem is non-NULL, created texture will be immutable. If _mem is NULL content of the texture is uninitialized. When _numLayers is more than 1, expected memory layout is texture and all mips together for each array element.

BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC] - Point or anisotropic sampling.

_mem -

Texture data. If _mem is non-NULL, created texture will be immutable. If _mem is NULL content of the texture is uninitialized. When _numLayers is more than 1, expected memory layout is texture and all mips together for each array element.

Pointer to texture memory. If returned pointer is NULL direct access is not available for this texture. If pointer is UINTPTR_MAX sentinel value it means texture is pending creation. Pointer returned can be cached and it will be valid until texture is destroyed.

Attention

Availability depends on: BGFX_CAPS_TEXTURE_DIRECT_ACCESS. This feature is available on GPUs that have unified memory architecture (UMA) support.