summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/include/bgfx/bgfx.h
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/include/bgfx/bgfx.h')
-rw-r--r--3rdparty/bgfx/include/bgfx/bgfx.h303
1 files changed, 111 insertions, 192 deletions
diff --git a/3rdparty/bgfx/include/bgfx/bgfx.h b/3rdparty/bgfx/include/bgfx/bgfx.h
index 9398837eb8d..02881cac71d 100644
--- a/3rdparty/bgfx/include/bgfx/bgfx.h
+++ b/3rdparty/bgfx/include/bgfx/bgfx.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/
@@ -10,7 +10,7 @@
#include <stdint.h> // uint32_t
#include <stdlib.h> // NULL
-#include <bgfx/bgfxdefines.h>
+#include <bgfx/defines.h>
///
#define BGFX_HANDLE(_name) \
@@ -562,7 +562,7 @@ namespace bgfx
Limits limits;
- /// Supported texture formats.
+ /// Supported texture format capabilities flags:
/// - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - Texture format is not supported.
/// - `BGFX_CAPS_FORMAT_TEXTURE_2D` - Texture format is supported.
/// - `BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB` - Texture as sRGB format is supported.
@@ -581,6 +581,8 @@ namespace bgfx
/// - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA` - Texture format can be used as MSAA
/// frame buffer.
/// - `BGFX_CAPS_FORMAT_TEXTURE_MSAA` - Texture can be sampled as MSAA.
+ /// - `BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN` - Texture format supports auto-generated
+ /// mips.
uint16_t formats[TextureFormat::Count];
};
@@ -641,6 +643,17 @@ namespace bgfx
bool cubeMap; //!< Texture is cubemap.
};
+ /// Uniform info.
+ ///
+ /// @attention C99 equivalent is `bgfx_uniform_info_t`.
+ ///
+ struct UniformInfo
+ {
+ char name[256]; //!< Uniform name.
+ UniformType::Enum type; //!< Uniform type.
+ uint16_t num; //!< Number of elements in array.
+ };
+
/// Frame buffer texture attachemnt info.
///
/// @attention C99 equivalent is `bgfx_attachment_t`.
@@ -658,7 +671,7 @@ namespace bgfx
///
struct Transform
{
- float* data; //!< Pointer to first matrix.
+ float* data; //!< Pointer to first 4x4 matrix.
uint16_t num; //!< Number of matrices.
};
@@ -679,7 +692,7 @@ namespace bgfx
float fov[4]; //!< Field of view (up, down, left, right).
float viewOffset[3]; //!< Eye view matrix translation adjustment.
float projection[16]; //!< Eye projection matrix
- float pixelsPerTanAngle[2]; //!<
+ float pixelsPerTanAngle[2]; //!< Number of pixels that fit in tan(angle) = 1.
};
Eye eye[2];
@@ -696,17 +709,26 @@ namespace bgfx
///
struct Stats
{
- uint64_t cpuTimeBegin; //!< CPU frame begin time.
- uint64_t cpuTimeEnd; //!< CPU frame end time.
- uint64_t cpuTimerFreq; //!< CPU timer frequency.
-
- uint64_t gpuTimeBegin; //!< GPU frame begin time.
- uint64_t gpuTimeEnd; //!< GPU frame end time.
- uint64_t gpuTimerFreq; //!< GPU timer frequency.
-
- int64_t waitRender; //!< Time spent waiting for render backend thread to finish issuing
- //! draw commands to underlying graphics API.
- int64_t waitSubmit; //!< Time spent waiting for submit thread to advance to next frame.
+ uint64_t cpuTimeBegin; //!< CPU frame begin time.
+ uint64_t cpuTimeEnd; //!< CPU frame end time.
+ uint64_t cpuTimerFreq; //!< CPU timer frequency.
+
+ uint64_t gpuTimeBegin; //!< GPU frame begin time.
+ uint64_t gpuTimeEnd; //!< GPU frame end time.
+ uint64_t gpuTimerFreq; //!< GPU timer frequency.
+
+ int64_t waitRender; //!< Time spent waiting for render backend thread to finish issuing
+ //! draw commands to underlying graphics API.
+ int64_t waitSubmit; //!< Time spent waiting for submit thread to advance to next frame.
+
+ uint32_t numDraw; //!< Number of draw calls submitted.
+ uint32_t numCompute; //!< Number of compute calls submitted.
+ uint32_t maxGpuLatency; //!< GPU driver latency.
+
+ uint16_t width; //!< Backbuffer width in pixels.
+ uint16_t height; //!< Backbuffer height in pixels.
+ uint16_t textWidth; //!< Debug text width in characters.
+ uint16_t textHeight; //!< Debug text height in characters.
};
/// Vertex declaration.
@@ -1098,7 +1120,7 @@ namespace bgfx
/// can pass `ReleaseFn` function pointer to release this memory after it's
/// consumed, or you must make sure data is available for at least 2
/// `bgfx::frame` calls. `ReleaseFn` function must be able to be called
- /// called from any thread.
+ /// from any thread.
///
/// @attention C99 equivalent are `bgfx_make_ref`, `bgfx_make_ref_release`.
///
@@ -1369,46 +1391,31 @@ namespace bgfx
///
void destroyDynamicVertexBuffer(DynamicVertexBufferHandle _handle);
- /// Returns true if internal transient index buffer has enough space.
+ /// Returns number of available indices.
///
- /// @param[in] _num Number of indices.
+ /// @param[in] _num Number of required indices.
///
- /// @attention C99 equivalent is `bgfx_check_avail_transient_index_buffer`.
+ /// @attention C99 equivalent is `bgfx_get_avail_transient_index_buffer`.
///
- bool checkAvailTransientIndexBuffer(uint32_t _num);
+ uint32_t getAvailTransientIndexBuffer(uint32_t _num);
- /// Returns true if internal transient vertex buffer has enough space.
+ /// Returns number of available vertices.
///
- /// @param[in] _num Number of vertices.
+ /// @param[in] _num Number of required vertices.
/// @param[in] _decl Vertex declaration.
///
/// @attention C99 equivalent is `bgfx_check_avail_transient_vertex_buffer`.
///
- bool checkAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl);
+ uint32_t getAvailTransientVertexBuffer(uint32_t _num, const VertexDecl& _decl);
- /// Returns true if internal instance data buffer has enough space.
+ /// Returns number of available instance buffer slots.
///
- /// @param[in] _num Number of instances.
+ /// @param[in] _num Number of required instances.
/// @param[in] _stride Stride per instance.
///
/// @attention C99 equivalent is `bgfx_check_avail_instance_data_buffer`.
///
- bool checkAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride);
-
- /// Returns true if both internal transient index and vertex buffer have
- /// enough space.
- ///
- /// @param[in] _numVertices Number of vertices.
- /// @param[in] _decl Vertex declaration.
- /// @param[in] _numIndices Number of indices.
- ///
- /// @attention C99 equivalent is `bgfx_check_avail_transient_buffers`.
- ///
- bool checkAvailTransientBuffers(
- uint32_t _numVertices
- , const VertexDecl& _decl
- , uint32_t _numIndices
- );
+ uint32_t getAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride);
/// Allocate transient index buffer.
///
@@ -1551,12 +1558,31 @@ namespace bgfx
///
void destroyProgram(ProgramHandle _handle);
+ /// Validate texture parameters.
+ ///
+ /// @param[in] _depth Depth dimension of volume texture.
+ /// @param[in] _cubeMap Indicates that texture contains cubemap.
+ /// @param[in] _numLayers Number of layers in texture array.
+ /// @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ /// @param[in] _flags Texture flags. See `BGFX_TEXTURE_*`.
+ /// @returns True if texture can be successfully created.
+ ///
+ /// @attention C99 equivalent is `bgfx_is_texture_valid`.
+ ///
+ bool isTextureValid(
+ uint16_t _depth
+ , bool _cubeMap
+ , uint16_t _numLayers
+ , TextureFormat::Enum _format
+ , uint32_t _flags
+ );
+
/// Calculate amount of memory required for texture.
///
/// @param[out] _info Resulting texture info structure.
/// @param[in] _width Width.
/// @param[in] _height Height.
- /// @param[in] _depth Depth.
+ /// @param[in] _depth Depth dimension of volume texture.
/// @param[in] _cubeMap Indicates that texture contains cubemap.
/// @param[in] _hasMips Indicates that texture contains full mip-map chain.
/// @param[in] _numLayers Number of layers in texture array.
@@ -1827,20 +1853,6 @@ namespace bgfx
///
uint32_t readTexture(TextureHandle _handle, void* _data, uint8_t _mip = 0);
- /// Read back texture content.
- ///
- /// @param[in] _handle Frame buffer handle.
- /// @param[in] _attachment Frame buffer attachment index.
- /// @param[in] _data Destination buffer.
- ///
- /// @returns Frame number when the result will be available. See: `bgfx::frame`.
- ///
- /// @attention Texture must be created with `BGFX_TEXTURE_READ_BACK` flag.
- /// @attention Availability depends on: `BGFX_CAPS_TEXTURE_READ_BACK`.
- /// @attention C99 equivalent is `bgfx_read_frame_buffer`.
- ///
- uint32_t readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data);
-
/// Destroy texture.
///
/// @param[in] _handle Texture handle.
@@ -1950,6 +1962,16 @@ namespace bgfx
, TextureFormat::Enum _depthFormat = TextureFormat::UnknownDepth
);
+ /// Obtain texture handle of frame buffer attachment.
+ ///
+ /// @param[in] _handle Frame buffer handle.
+ /// @param[in] _attachment Frame buffer attachment index.
+ ///
+ /// @returns Returns invalid texture handle if attachment index is not
+ /// correct, or frame buffer is created with native window handle.
+ ///
+ TextureHandle getTexture(FrameBufferHandle _handle, uint8_t _attachment = 0);
+
/// Destroy frame buffer.
///
/// @attention C99 equivalent is `bgfx_destroy_frame_buffer`.
@@ -1965,27 +1987,42 @@ namespace bgfx
/// @returns Handle to uniform object.
///
/// @remarks
- /// Predefined uniforms (declared in `bgfx_shader.sh`):
- /// - `u_viewRect vec4(x, y, width, height)` - view rectangle for current
- /// view.
- /// - `u_viewTexel vec4(1.0/width, 1.0/height, undef, undef)` - inverse
- /// width and height
- /// - `u_view mat4` - view matrix
- /// - `u_invView mat4` - inverted view matrix
- /// - `u_proj mat4` - projection matrix
- /// - `u_invProj mat4` - inverted projection matrix
- /// - `u_viewProj mat4` - concatenated view projection matrix
- /// - `u_invViewProj mat4` - concatenated inverted view projection matrix
- /// - `u_model mat4[BGFX_CONFIG_MAX_BONES]` - array of model matrices.
- /// - `u_modelView mat4` - concatenated model view matrix, only first
- /// model matrix from array is used.
- /// - `u_modelViewProj mat4` - concatenated model view projection matrix.
- /// - `u_alphaRef float` - alpha reference value for alpha test.
+ /// 1. 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.
+ ///
+ /// 2. Predefined uniforms (declared in `bgfx_shader.sh`):
+ /// - `u_viewRect vec4(x, y, width, height)` - view rectangle for current
+ /// view.
+ /// - `u_viewTexel vec4(1.0/width, 1.0/height, undef, undef)` - inverse
+ /// width and height
+ /// - `u_view mat4` - view matrix
+ /// - `u_invView mat4` - inverted view matrix
+ /// - `u_proj mat4` - projection matrix
+ /// - `u_invProj mat4` - inverted projection matrix
+ /// - `u_viewProj mat4` - concatenated view projection matrix
+ /// - `u_invViewProj mat4` - concatenated inverted view projection matrix
+ /// - `u_model mat4[BGFX_CONFIG_MAX_BONES]` - array of model matrices.
+ /// - `u_modelView mat4` - concatenated model view matrix, only first
+ /// model matrix from array is used.
+ /// - `u_modelViewProj mat4` - concatenated model view projection matrix.
+ /// - `u_alphaRef float` - alpha reference value for alpha test.
///
/// @attention C99 equivalent is `bgfx_create_uniform`.
///
UniformHandle createUniform(const char* _name, UniformType::Enum _type, uint16_t _num = 1);
+ /// Retrieve uniform info.
+ ///
+ /// @param[in] _handle Handle to uniform object.
+ /// @param[out] _info Uniform info.
+ ///
+ /// @attention C99 equivalent is `bgfx_get_uniform_info`.
+ ///
+ void getUniformInfo(UniformHandle _handle, UniformInfo& _info);
+
/// Destroy shader uniform parameter.
///
/// @param[in] _handle Handle to uniform object.
@@ -2208,7 +2245,7 @@ namespace bgfx
///
/// @attention C99 equivalent is `bgfx_set_view_remap`.
///
- void setViewRemap(uint8_t _id = 0, uint8_t _num = UINT8_MAX, const void* _remap = NULL);
+ void setViewOrder(uint8_t _id = 0, uint8_t _num = UINT8_MAX, const void* _remap = NULL);
/// Reset all view settings to default.
///
@@ -2505,29 +2542,6 @@ namespace bgfx
, uint32_t _flags = UINT32_MAX
);
- /// Set texture stage for draw primitive.
- ///
- /// @param[in] _stage Texture unit.
- /// @param[in] _sampler Program sampler.
- /// @param[in] _handle Frame buffer handle.
- /// @param[in] _attachment Frame buffer attachment index.
- /// @param[in] _flags Texture sampling mode. Default value UINT32_MAX uses
- /// texture sampling settings from the texture.
- /// - `BGFX_TEXTURE_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
- /// mode.
- /// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
- /// sampling.
- ///
- /// @attention C99 equivalent is `bgfx_set_texture_from_frame_buffer`.
- ///
- void setTexture(
- uint8_t _stage
- , UniformHandle _sampler
- , FrameBufferHandle _handle
- , uint8_t _attachment = 0
- , uint32_t _flags = UINT32_MAX
- );
-
/// Submit an empty primitive for rendering. Uniforms and draw state
/// will be applied but no geometry will be submitted.
///
@@ -2671,26 +2685,6 @@ namespace bgfx
, TextureFormat::Enum _format = TextureFormat::Count
);
- /// Set compute image from frame buffer texture.
- ///
- /// @param[in] _stage Texture unit.
- /// @param[in] _sampler Program sampler.
- /// @param[in] _handle Frame buffer handle.
- /// @param[in] _attachment Frame buffer attachment index.
- /// @param[in] _access Texture access. See `Access::Enum`.
- /// @param[in] _format Texture format. See: `TextureFormat::Enum`.
- ///
- /// @attention C99 equivalent is `bgfx_set_image_from_frame_buffer`.
- ///
- void setImage(
- uint8_t _stage
- , UniformHandle _sampler
- , FrameBufferHandle _handle
- , uint8_t _attachment
- , Access::Enum _access
- , TextureFormat::Enum _format = TextureFormat::Count
- );
-
/// Dispatch compute.
///
/// @param[in] _id View id.
@@ -2771,36 +2765,6 @@ namespace bgfx
, uint16_t _height = UINT16_MAX
);
- /// Blit texture 2D region between 2D frame buffer and 2D texture.
- ///
- /// @param[in] _id View id.
- /// @param[in] _dst Destination texture handle.
- /// @param[in] _dstX Destination texture X position.
- /// @param[in] _dstY Destination texture Y position.
- /// @param[in] _src Source frame buffer handle.
- /// @param[in] _attachment Source frame buffer attachment index.
- /// @param[in] _srcX Source texture X position.
- /// @param[in] _srcY Source texture Y position.
- /// @param[in] _width Width of region.
- /// @param[in] _height Height of region.
- ///
- /// @attention Destination texture must be create with `BGFX_TEXTURE_BLIT_DST` flag.
- /// @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`.
- /// @attention C99 equivalent is `bgfx_blit`.
- ///
- void blit(
- uint8_t _id
- , TextureHandle _dst
- , uint16_t _dstX
- , uint16_t _dstY
- , FrameBufferHandle _src
- , uint8_t _attachment = 0
- , uint16_t _srcX = 0
- , uint16_t _srcY = 0
- , uint16_t _width = UINT16_MAX
- , uint16_t _height = UINT16_MAX
- );
-
/// Blit texture region between two textures.
///
/// @param[in] _id View id.
@@ -2844,51 +2808,6 @@ namespace bgfx
, uint16_t _depth = UINT16_MAX
);
- /// Blit texture region between frame buffer and texture.
- ///
- /// @param[in] _id View id.
- /// @param[in] _dst Destination texture handle.
- /// @param[in] _dstMip Destination texture mip level.
- /// @param[in] _dstX Destination texture X position.
- /// @param[in] _dstY Destination texture Y position.
- /// @param[in] _dstZ If texture is 2D this argument should be 0. If destination texture is cube
- /// this argument represent destination texture cube face. For 3D texture this argument
- /// represent destination texture Z position.
- /// @param[in] _src Source frame buffer handle.
- /// @param[in] _attachment Source frame buffer attachment index.
- /// @param[in] _srcMip Source texture mip level.
- /// @param[in] _srcX Source texture X position.
- /// @param[in] _srcY Source texture Y position.
- /// @param[in] _srcZ If texture is 2D this argument should be 0. If source texture is cube
- /// this argument represent source texture cube face. For 3D texture this argument
- /// represent source texture Z position.
- /// @param[in] _width Width of region.
- /// @param[in] _height Height of region.
- /// @param[in] _depth If texture is 3D this argument represent depth of region, otherwise is
- /// unused.
- ///
- /// @attention Destination texture must be create with `BGFX_TEXTURE_BLIT_DST` flag.
- /// @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`.
- /// @attention C99 equivalent is `bgfx_blit`.
- ///
- void blit(
- uint8_t _id
- , TextureHandle _dst
- , uint8_t _dstMip
- , uint16_t _dstX
- , uint16_t _dstY
- , uint16_t _dstZ
- , FrameBufferHandle _src
- , uint8_t _attachment = 0
- , uint8_t _srcMip = 0
- , uint16_t _srcX = 0
- , uint16_t _srcY = 0
- , uint16_t _srcZ = 0
- , uint16_t _width = UINT16_MAX
- , uint16_t _height = UINT16_MAX
- , uint16_t _depth = UINT16_MAX
- );
-
/// Request screen shot.
///
/// @param[in] _filePath Will be passed to `bgfx::CallbackI::screenShot` callback.