Sfoglia il codice sorgente

Update IDL code generator

Cloud Wu 6 anni fa
parent
commit
309edd2adf
11 ha cambiato i file con 6646 aggiunte e 2271 eliminazioni
  1. 3170 452
      include/bgfx/c99/bgfx.h
  2. 0 734
      include/bgfx/c99/bgfx.idl.h
  3. 1 1
      include/bgfx/defines.h
  4. 258 66
      scripts/bgfx-idl.lua
  5. 2077 737
      scripts/bgfx.idl
  6. 574 77
      scripts/codegen.lua
  7. 21 0
      scripts/doxygen.lua
  8. 192 57
      scripts/idl.lua
  9. 127 0
      scripts/temp.bgfx.h
  10. 59 0
      scripts/temp.bgfx.idl.inl
  11. 167 147
      src/bgfx.idl.inl

+ 3170 - 452
include/bgfx/c99/bgfx.h

@@ -5,6 +5,12 @@
  * vim: set tabstop=4 expandtab:
  */
 
+/*
+ *
+ * AUTO GENERATED! DO NOT EDIT! ( source : temp.bgfx.h )
+ *
+ */
+
 #ifndef BGFX_C99_H_HEADER_GUARD
 #define BGFX_C99_H_HEADER_GUARD
 
@@ -51,628 +57,3340 @@
 
 #include "../defines.h"
 
-typedef enum bgfx_renderer_type
+/**
+ * Fatal error enum.
+ *
+ */
+typedef enum bgfx_fatal
 {
-    BGFX_RENDERER_TYPE_NOOP,
-    BGFX_RENDERER_TYPE_DIRECT3D9,
-    BGFX_RENDERER_TYPE_DIRECT3D11,
-    BGFX_RENDERER_TYPE_DIRECT3D12,
-    BGFX_RENDERER_TYPE_GNM,
-    BGFX_RENDERER_TYPE_METAL,
-    BGFX_RENDERER_TYPE_OPENGLES,
-    BGFX_RENDERER_TYPE_OPENGL,
-    BGFX_RENDERER_TYPE_VULKAN,
+	BGFX_FATAL_DEBUG_CHECK,                   /** ( 0)                                */
+	BGFX_FATAL_INVALID_SHADER,                /** ( 1)                                */
+	BGFX_FATAL_UNABLE_TO_INITIALIZE,          /** ( 2)                                */
+	BGFX_FATAL_UNABLE_TO_CREATE_TEXTURE,      /** ( 3)                                */
+	BGFX_FATAL_DEVICE_LOST,                   /** ( 4)                                */
 
-    BGFX_RENDERER_TYPE_COUNT
+	BGFX_FATAL_COUNT
+
+} bgfx_fatal_t;
+
+/**
+ * Renderer backend type enum.
+ *
+ */
+typedef enum bgfx_renderer_type
+{
+	BGFX_RENDERER_TYPE_NOOP,                  /** ( 0) No rendering.                  */
+	BGFX_RENDERER_TYPE_DIRECT3D9,             /** ( 1) Direct3D 9.0                   */
+	BGFX_RENDERER_TYPE_DIRECT3D11,            /** ( 2) Direct3D 11.0                  */
+	BGFX_RENDERER_TYPE_DIRECT3D12,            /** ( 3) Direct3D 12.0                  */
+	BGFX_RENDERER_TYPE_GNM,                   /** ( 4) GNM                            */
+	BGFX_RENDERER_TYPE_METAL,                 /** ( 5) Metal                          */
+	BGFX_RENDERER_TYPE_OPENGLES,              /** ( 6) OpenGL ES 2.0+                 */
+	BGFX_RENDERER_TYPE_OPENGL,                /** ( 7) OpenGL 2.1+                    */
+	BGFX_RENDERER_TYPE_VULKAN,                /** ( 8) Vulkan                         */
+
+	BGFX_RENDERER_TYPE_COUNT
 
 } bgfx_renderer_type_t;
 
+/**
+ * Access mode enum.
+ *
+ */
 typedef enum bgfx_access
 {
-    BGFX_ACCESS_READ,
-    BGFX_ACCESS_WRITE,
-    BGFX_ACCESS_READWRITE,
+	BGFX_ACCESS_READ,                         /** ( 0) Read.                          */
+	BGFX_ACCESS_WRITE,                        /** ( 1) Write.                         */
+	BGFX_ACCESS_READWRITE,                    /** ( 2) Read and write.                */
 
-    BGFX_ACCESS_COUNT
+	BGFX_ACCESS_COUNT
 
 } bgfx_access_t;
 
+/**
+ * Vertex attribute enum.
+ *
+ */
 typedef enum bgfx_attrib
 {
-    BGFX_ATTRIB_POSITION,
-    BGFX_ATTRIB_NORMAL,
-    BGFX_ATTRIB_TANGENT,
-    BGFX_ATTRIB_BITANGENT,
-    BGFX_ATTRIB_COLOR0,
-    BGFX_ATTRIB_COLOR1,
-    BGFX_ATTRIB_COLOR2,
-    BGFX_ATTRIB_COLOR3,
-    BGFX_ATTRIB_INDICES,
-    BGFX_ATTRIB_WEIGHT,
-    BGFX_ATTRIB_TEXCOORD0,
-    BGFX_ATTRIB_TEXCOORD1,
-    BGFX_ATTRIB_TEXCOORD2,
-    BGFX_ATTRIB_TEXCOORD3,
-    BGFX_ATTRIB_TEXCOORD4,
-    BGFX_ATTRIB_TEXCOORD5,
-    BGFX_ATTRIB_TEXCOORD6,
-    BGFX_ATTRIB_TEXCOORD7,
-
-    BGFX_ATTRIB_COUNT
+	BGFX_ATTRIB_POSITION,                     /** ( 0) a_position                     */
+	BGFX_ATTRIB_NORMAL,                       /** ( 1) a_normal                       */
+	BGFX_ATTRIB_TANGENT,                      /** ( 2) a_tangent                      */
+	BGFX_ATTRIB_BITANGENT,                    /** ( 3) a_bitangent                    */
+	BGFX_ATTRIB_COLOR0,                       /** ( 4) a_color0                       */
+	BGFX_ATTRIB_COLOR1,                       /** ( 5) a_color1                       */
+	BGFX_ATTRIB_COLOR2,                       /** ( 6) a_color2                       */
+	BGFX_ATTRIB_COLOR3,                       /** ( 7) a_color3                       */
+	BGFX_ATTRIB_INDICES,                      /** ( 8) a_indices                      */
+	BGFX_ATTRIB_WEIGHT,                       /** ( 9) a_weight                       */
+	BGFX_ATTRIB_TEXCOORD0,                    /** (10) a_texcoord0                    */
+	BGFX_ATTRIB_TEXCOORD1,                    /** (11) a_texcoord1                    */
+	BGFX_ATTRIB_TEXCOORD2,                    /** (12) a_texcoord2                    */
+	BGFX_ATTRIB_TEXCOORD3,                    /** (13) a_texcoord3                    */
+	BGFX_ATTRIB_TEXCOORD4,                    /** (14) a_texcoord4                    */
+	BGFX_ATTRIB_TEXCOORD5,                    /** (15) a_texcoord5                    */
+	BGFX_ATTRIB_TEXCOORD6,                    /** (16) a_texcoord6                    */
+	BGFX_ATTRIB_TEXCOORD7,                    /** (17) a_texcoord7                    */
+
+	BGFX_ATTRIB_COUNT
 
 } bgfx_attrib_t;
 
+/**
+ * Vertex attribute type enum.
+ *
+ */
 typedef enum bgfx_attrib_type
 {
-    BGFX_ATTRIB_TYPE_UINT8,
-    BGFX_ATTRIB_TYPE_UINT10,
-    BGFX_ATTRIB_TYPE_INT16,
-    BGFX_ATTRIB_TYPE_HALF,
-    BGFX_ATTRIB_TYPE_FLOAT,
+	BGFX_ATTRIB_TYPE_UINT8,                   /** ( 0) Uint8                          */
+	BGFX_ATTRIB_TYPE_UINT10,                  /** ( 1) Uint10, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_UINT10`. */
+	BGFX_ATTRIB_TYPE_INT16,                   /** ( 2) Int16                          */
+	BGFX_ATTRIB_TYPE_HALF,                    /** ( 3) Half, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_HALF`. */
+	BGFX_ATTRIB_TYPE_FLOAT,                   /** ( 4) Float                          */
 
-    BGFX_ATTRIB_TYPE_COUNT
+	BGFX_ATTRIB_TYPE_COUNT
 
 } bgfx_attrib_type_t;
 
+/**
+ * Texture format enum.
+ * Notation:
+ *       RGBA16S
+ *       ^   ^ ^
+ *       |   | +-- [ ]Unorm
+ *       |   |     [F]loat
+ *       |   |     [S]norm
+ *       |   |     [I]nt
+ *       |   |     [U]int
+ *       |   +---- Number of bits per component
+ *       +-------- Components
+ * @attention Availability depends on Caps (see: formats).
+ *
+ */
 typedef enum bgfx_texture_format
 {
-    BGFX_TEXTURE_FORMAT_BC1,
-    BGFX_TEXTURE_FORMAT_BC2,
-    BGFX_TEXTURE_FORMAT_BC3,
-    BGFX_TEXTURE_FORMAT_BC4,
-    BGFX_TEXTURE_FORMAT_BC5,
-    BGFX_TEXTURE_FORMAT_BC6H,
-    BGFX_TEXTURE_FORMAT_BC7,
-    BGFX_TEXTURE_FORMAT_ETC1,
-    BGFX_TEXTURE_FORMAT_ETC2,
-    BGFX_TEXTURE_FORMAT_ETC2A,
-    BGFX_TEXTURE_FORMAT_ETC2A1,
-    BGFX_TEXTURE_FORMAT_PTC12,
-    BGFX_TEXTURE_FORMAT_PTC14,
-    BGFX_TEXTURE_FORMAT_PTC12A,
-    BGFX_TEXTURE_FORMAT_PTC14A,
-    BGFX_TEXTURE_FORMAT_PTC22,
-    BGFX_TEXTURE_FORMAT_PTC24,
-    BGFX_TEXTURE_FORMAT_ATC,
-    BGFX_TEXTURE_FORMAT_ATCE,
-    BGFX_TEXTURE_FORMAT_ATCI,
-    BGFX_TEXTURE_FORMAT_ASTC4x4,
-    BGFX_TEXTURE_FORMAT_ASTC5x5,
-    BGFX_TEXTURE_FORMAT_ASTC6x6,
-    BGFX_TEXTURE_FORMAT_ASTC8x5,
-    BGFX_TEXTURE_FORMAT_ASTC8x6,
-    BGFX_TEXTURE_FORMAT_ASTC10x5,
-
-    BGFX_TEXTURE_FORMAT_UNKNOWN,
-
-    BGFX_TEXTURE_FORMAT_R1,
-    BGFX_TEXTURE_FORMAT_A8,
-    BGFX_TEXTURE_FORMAT_R8,
-    BGFX_TEXTURE_FORMAT_R8I,
-    BGFX_TEXTURE_FORMAT_R8U,
-    BGFX_TEXTURE_FORMAT_R8S,
-    BGFX_TEXTURE_FORMAT_R16,
-    BGFX_TEXTURE_FORMAT_R16I,
-    BGFX_TEXTURE_FORMAT_R16U,
-    BGFX_TEXTURE_FORMAT_R16F,
-    BGFX_TEXTURE_FORMAT_R16S,
-    BGFX_TEXTURE_FORMAT_R32I,
-    BGFX_TEXTURE_FORMAT_R32U,
-    BGFX_TEXTURE_FORMAT_R32F,
-    BGFX_TEXTURE_FORMAT_RG8,
-    BGFX_TEXTURE_FORMAT_RG8I,
-    BGFX_TEXTURE_FORMAT_RG8U,
-    BGFX_TEXTURE_FORMAT_RG8S,
-    BGFX_TEXTURE_FORMAT_RG16,
-    BGFX_TEXTURE_FORMAT_RG16I,
-    BGFX_TEXTURE_FORMAT_RG16U,
-    BGFX_TEXTURE_FORMAT_RG16F,
-    BGFX_TEXTURE_FORMAT_RG16S,
-    BGFX_TEXTURE_FORMAT_RG32I,
-    BGFX_TEXTURE_FORMAT_RG32U,
-    BGFX_TEXTURE_FORMAT_RG32F,
-    BGFX_TEXTURE_FORMAT_RGB8,
-    BGFX_TEXTURE_FORMAT_RGB8I,
-    BGFX_TEXTURE_FORMAT_RGB8U,
-    BGFX_TEXTURE_FORMAT_RGB8S,
-    BGFX_TEXTURE_FORMAT_RGB9E5F,
-    BGFX_TEXTURE_FORMAT_BGRA8,
-    BGFX_TEXTURE_FORMAT_RGBA8,
-    BGFX_TEXTURE_FORMAT_RGBA8I,
-    BGFX_TEXTURE_FORMAT_RGBA8U,
-    BGFX_TEXTURE_FORMAT_RGBA8S,
-    BGFX_TEXTURE_FORMAT_RGBA16,
-    BGFX_TEXTURE_FORMAT_RGBA16I,
-    BGFX_TEXTURE_FORMAT_RGBA16U,
-    BGFX_TEXTURE_FORMAT_RGBA16F,
-    BGFX_TEXTURE_FORMAT_RGBA16S,
-    BGFX_TEXTURE_FORMAT_RGBA32I,
-    BGFX_TEXTURE_FORMAT_RGBA32U,
-    BGFX_TEXTURE_FORMAT_RGBA32F,
-    BGFX_TEXTURE_FORMAT_R5G6B5,
-    BGFX_TEXTURE_FORMAT_RGBA4,
-    BGFX_TEXTURE_FORMAT_RGB5A1,
-    BGFX_TEXTURE_FORMAT_RGB10A2,
-    BGFX_TEXTURE_FORMAT_RG11B10F,
-
-    BGFX_TEXTURE_FORMAT_UNKNOWN_DEPTH,
-
-    BGFX_TEXTURE_FORMAT_D16,
-    BGFX_TEXTURE_FORMAT_D24,
-    BGFX_TEXTURE_FORMAT_D24S8,
-    BGFX_TEXTURE_FORMAT_D32,
-    BGFX_TEXTURE_FORMAT_D16F,
-    BGFX_TEXTURE_FORMAT_D24F,
-    BGFX_TEXTURE_FORMAT_D32F,
-    BGFX_TEXTURE_FORMAT_D0S8,
-
-    BGFX_TEXTURE_FORMAT_COUNT
+	BGFX_TEXTURE_FORMAT_BC1,                  /** ( 0) DXT1                           */
+	BGFX_TEXTURE_FORMAT_BC2,                  /** ( 1) DXT3                           */
+	BGFX_TEXTURE_FORMAT_BC3,                  /** ( 2) DXT5                           */
+	BGFX_TEXTURE_FORMAT_BC4,                  /** ( 3) LATC1/ATI1                     */
+	BGFX_TEXTURE_FORMAT_BC5,                  /** ( 4) LATC2/ATI2                     */
+	BGFX_TEXTURE_FORMAT_BC6H,                 /** ( 5) BC6H                           */
+	BGFX_TEXTURE_FORMAT_BC7,                  /** ( 6) BC7                            */
+	BGFX_TEXTURE_FORMAT_ETC1,                 /** ( 7) ETC1 RGB8                      */
+	BGFX_TEXTURE_FORMAT_ETC2,                 /** ( 8) ETC2 RGB8                      */
+	BGFX_TEXTURE_FORMAT_ETC2A,                /** ( 9) ETC2 RGBA8                     */
+	BGFX_TEXTURE_FORMAT_ETC2A1,               /** (10) ETC2 RGB8A1                    */
+	BGFX_TEXTURE_FORMAT_PTC12,                /** (11) PVRTC1 RGB 2BPP                */
+	BGFX_TEXTURE_FORMAT_PTC14,                /** (12) PVRTC1 RGB 4BPP                */
+	BGFX_TEXTURE_FORMAT_PTC12A,               /** (13) PVRTC1 RGBA 2BPP               */
+	BGFX_TEXTURE_FORMAT_PTC14A,               /** (14) PVRTC1 RGBA 4BPP               */
+	BGFX_TEXTURE_FORMAT_PTC22,                /** (15) PVRTC2 RGBA 2BPP               */
+	BGFX_TEXTURE_FORMAT_PTC24,                /** (16) PVRTC2 RGBA 4BPP               */
+	BGFX_TEXTURE_FORMAT_ATC,                  /** (17) ATC RGB 4BPP                   */
+	BGFX_TEXTURE_FORMAT_ATCE,                 /** (18) ATCE RGBA 8 BPP explicit alpha */
+	BGFX_TEXTURE_FORMAT_ATCI,                 /** (19) ATCI RGBA 8 BPP interpolated alpha */
+	BGFX_TEXTURE_FORMAT_ASTC4X4,              /** (20) ASTC 4x4 8.0 BPP               */
+	BGFX_TEXTURE_FORMAT_ASTC5X5,              /** (21) ASTC 5x5 5.12 BPP              */
+	BGFX_TEXTURE_FORMAT_ASTC6X6,              /** (22) ASTC 6x6 3.56 BPP              */
+	BGFX_TEXTURE_FORMAT_ASTC8X5,              /** (23) ASTC 8x5 3.20 BPP              */
+	BGFX_TEXTURE_FORMAT_ASTC8X6,              /** (24) ASTC 8x6 2.67 BPP              */
+	BGFX_TEXTURE_FORMAT_ASTC10X5,             /** (25) ASTC 10x5 2.56 BPP             */
+	BGFX_TEXTURE_FORMAT_UNKNOWN,              /** (26) Compressed formats above.      */
+	BGFX_TEXTURE_FORMAT_R1,                   /** (27)                                */
+	BGFX_TEXTURE_FORMAT_A8,                   /** (28)                                */
+	BGFX_TEXTURE_FORMAT_R8,                   /** (29)                                */
+	BGFX_TEXTURE_FORMAT_R8I,                  /** (30)                                */
+	BGFX_TEXTURE_FORMAT_R8U,                  /** (31)                                */
+	BGFX_TEXTURE_FORMAT_R8S,                  /** (32)                                */
+	BGFX_TEXTURE_FORMAT_R16,                  /** (33)                                */
+	BGFX_TEXTURE_FORMAT_R16I,                 /** (34)                                */
+	BGFX_TEXTURE_FORMAT_R16U,                 /** (35)                                */
+	BGFX_TEXTURE_FORMAT_R16F,                 /** (36)                                */
+	BGFX_TEXTURE_FORMAT_R16S,                 /** (37)                                */
+	BGFX_TEXTURE_FORMAT_R32I,                 /** (38)                                */
+	BGFX_TEXTURE_FORMAT_R32U,                 /** (39)                                */
+	BGFX_TEXTURE_FORMAT_R32F,                 /** (40)                                */
+	BGFX_TEXTURE_FORMAT_RG8,                  /** (41)                                */
+	BGFX_TEXTURE_FORMAT_RG8I,                 /** (42)                                */
+	BGFX_TEXTURE_FORMAT_RG8U,                 /** (43)                                */
+	BGFX_TEXTURE_FORMAT_RG8S,                 /** (44)                                */
+	BGFX_TEXTURE_FORMAT_RG16,                 /** (45)                                */
+	BGFX_TEXTURE_FORMAT_RG16I,                /** (46)                                */
+	BGFX_TEXTURE_FORMAT_RG16U,                /** (47)                                */
+	BGFX_TEXTURE_FORMAT_RG16F,                /** (48)                                */
+	BGFX_TEXTURE_FORMAT_RG16S,                /** (49)                                */
+	BGFX_TEXTURE_FORMAT_RG32I,                /** (50)                                */
+	BGFX_TEXTURE_FORMAT_RG32U,                /** (51)                                */
+	BGFX_TEXTURE_FORMAT_RG32F,                /** (52)                                */
+	BGFX_TEXTURE_FORMAT_RGB8,                 /** (53)                                */
+	BGFX_TEXTURE_FORMAT_RGB8I,                /** (54)                                */
+	BGFX_TEXTURE_FORMAT_RGB8U,                /** (55)                                */
+	BGFX_TEXTURE_FORMAT_RGB8S,                /** (56)                                */
+	BGFX_TEXTURE_FORMAT_RGB9E5F,              /** (57)                                */
+	BGFX_TEXTURE_FORMAT_BGRA8,                /** (58)                                */
+	BGFX_TEXTURE_FORMAT_RGBA8,                /** (59)                                */
+	BGFX_TEXTURE_FORMAT_RGBA8I,               /** (60)                                */
+	BGFX_TEXTURE_FORMAT_RGBA8U,               /** (61)                                */
+	BGFX_TEXTURE_FORMAT_RGBA8S,               /** (62)                                */
+	BGFX_TEXTURE_FORMAT_RGBA16,               /** (63)                                */
+	BGFX_TEXTURE_FORMAT_RGBA16I,              /** (64)                                */
+	BGFX_TEXTURE_FORMAT_RGBA16U,              /** (65)                                */
+	BGFX_TEXTURE_FORMAT_RGBA16F,              /** (66)                                */
+	BGFX_TEXTURE_FORMAT_RGBA16S,              /** (67)                                */
+	BGFX_TEXTURE_FORMAT_RGBA32I,              /** (68)                                */
+	BGFX_TEXTURE_FORMAT_RGBA32U,              /** (69)                                */
+	BGFX_TEXTURE_FORMAT_RGBA32F,              /** (70)                                */
+	BGFX_TEXTURE_FORMAT_R5G6B5,               /** (71)                                */
+	BGFX_TEXTURE_FORMAT_RGBA4,                /** (72)                                */
+	BGFX_TEXTURE_FORMAT_RGB5A1,               /** (73)                                */
+	BGFX_TEXTURE_FORMAT_RGB10A2,              /** (74)                                */
+	BGFX_TEXTURE_FORMAT_RG11B10F,             /** (75)                                */
+	BGFX_TEXTURE_FORMAT_UNKNOWNDEPTH,         /** (76) Depth formats below.           */
+	BGFX_TEXTURE_FORMAT_D16,                  /** (77)                                */
+	BGFX_TEXTURE_FORMAT_D24,                  /** (78)                                */
+	BGFX_TEXTURE_FORMAT_D24S8,                /** (79)                                */
+	BGFX_TEXTURE_FORMAT_D32,                  /** (80)                                */
+	BGFX_TEXTURE_FORMAT_D16F,                 /** (81)                                */
+	BGFX_TEXTURE_FORMAT_D24F,                 /** (82)                                */
+	BGFX_TEXTURE_FORMAT_D32F,                 /** (83)                                */
+	BGFX_TEXTURE_FORMAT_D0S8,                 /** (84)                                */
+
+	BGFX_TEXTURE_FORMAT_COUNT
 
 } bgfx_texture_format_t;
 
+/**
+ * Uniform type enum.
+ *
+ */
 typedef enum bgfx_uniform_type
 {
-    BGFX_UNIFORM_TYPE_SAMPLER,
-    BGFX_UNIFORM_TYPE_END,
-
-    BGFX_UNIFORM_TYPE_VEC4,
-    BGFX_UNIFORM_TYPE_MAT3,
-    BGFX_UNIFORM_TYPE_MAT4,
+	BGFX_UNIFORM_TYPE_SAMPLER,                /** ( 0) Sampler.                       */
+	BGFX_UNIFORM_TYPE_END,                    /** ( 1) Reserved, do not use.          */
+	BGFX_UNIFORM_TYPE_VEC4,                   /** ( 2) 4 floats vector.               */
+	BGFX_UNIFORM_TYPE_MAT3,                   /** ( 3) 3x3 matrix.                    */
+	BGFX_UNIFORM_TYPE_MAT4,                   /** ( 4) 4x4 matrix.                    */
 
-    BGFX_UNIFORM_TYPE_COUNT
+	BGFX_UNIFORM_TYPE_COUNT
 
 } bgfx_uniform_type_t;
 
+/**
+ * Backbuffer ratio enum.
+ *
+ */
 typedef enum bgfx_backbuffer_ratio
 {
-    BGFX_BACKBUFFER_RATIO_EQUAL,
-    BGFX_BACKBUFFER_RATIO_HALF,
-    BGFX_BACKBUFFER_RATIO_QUARTER,
-    BGFX_BACKBUFFER_RATIO_EIGHTH,
-    BGFX_BACKBUFFER_RATIO_SIXTEENTH,
-    BGFX_BACKBUFFER_RATIO_DOUBLE,
+	BGFX_BACKBUFFER_RATIO_EQUAL,              /** ( 0) Equal to backbuffer.           */
+	BGFX_BACKBUFFER_RATIO_HALF,               /** ( 1) One half size of backbuffer.   */
+	BGFX_BACKBUFFER_RATIO_QUARTER,            /** ( 2) One quarter size of backbuffer. */
+	BGFX_BACKBUFFER_RATIO_EIGHTH,             /** ( 3) One eighth size of backbuffer. */
+	BGFX_BACKBUFFER_RATIO_SIXTEENTH,          /** ( 4) One sixteenth size of backbuffer. */
+	BGFX_BACKBUFFER_RATIO_DOUBLE,             /** ( 5) Double size of backbuffer.     */
 
-    BGFX_BACKBUFFER_RATIO_COUNT
+	BGFX_BACKBUFFER_RATIO_COUNT
 
 } bgfx_backbuffer_ratio_t;
 
+/**
+ * Occlusion query result.
+ *
+ */
 typedef enum bgfx_occlusion_query_result
 {
-    BGFX_OCCLUSION_QUERY_RESULT_INVISIBLE,
-    BGFX_OCCLUSION_QUERY_RESULT_VISIBLE,
-    BGFX_OCCLUSION_QUERY_RESULT_NORESULT,
+	BGFX_OCCLUSION_QUERY_RESULT_INVISIBLE,    /** ( 0) Query failed test.             */
+	BGFX_OCCLUSION_QUERY_RESULT_VISIBLE,      /** ( 1) Query passed test.             */
+	BGFX_OCCLUSION_QUERY_RESULT_NORESULT,     /** ( 2) Query result is not available yet. */
 
-    BGFX_OCCLUSION_QUERY_RESULT_COUNT
+	BGFX_OCCLUSION_QUERY_RESULT_COUNT
 
 } bgfx_occlusion_query_result_t;
 
+/**
+ * Primitive topology.
+ *
+ */
 typedef enum bgfx_topology
 {
-    BGFX_TOPOLOGY_TRI_LIST,
-    BGFX_TOPOLOGY_TRI_STRIP,
-    BGFX_TOPOLOGY_LINE_LIST,
-    BGFX_TOPOLOGY_LINE_STRIP,
-    BGFX_TOPOLOGY_POINT_LIST,
+	BGFX_TOPOLOGY_TRI_LIST,                   /** ( 0) Triangle list.                 */
+	BGFX_TOPOLOGY_TRI_STRIP,                  /** ( 1) Triangle strip.                */
+	BGFX_TOPOLOGY_LINE_LIST,                  /** ( 2) Line list.                     */
+	BGFX_TOPOLOGY_LINE_STRIP,                 /** ( 3) Line strip.                    */
+	BGFX_TOPOLOGY_POINT_LIST,                 /** ( 4) Point list.                    */
 
-    BGFX_TOPOLOGY_COUNT
+	BGFX_TOPOLOGY_COUNT
 
 } bgfx_topology_t;
 
+/**
+ * Topology conversion function.
+ *
+ */
 typedef enum bgfx_topology_convert
 {
-    BGFX_TOPOLOGY_CONVERT_TRI_LIST_FLIP_WINDING,
-    BGFX_TOPOLOGY_CONVERT_TRI_STRIP_FLIP_WINDING,
-    BGFX_TOPOLOGY_CONVERT_TRI_LIST_TO_LINE_LIST,
-    BGFX_TOPOLOGY_CONVERT_TRI_STRIP_TO_TRI_LIST,
-    BGFX_TOPOLOGY_CONVERT_LINE_STRIP_TO_LINE_LIST,
+	BGFX_TOPOLOGY_CONVERT_TRI_LIST_FLIP_WINDING, /** ( 0) Flip winding order of triangle list. */
+	BGFX_TOPOLOGY_CONVERT_TRI_STRIP_FLIP_WINDING, /** ( 1) Flip winding order of trinagle strip. */
+	BGFX_TOPOLOGY_CONVERT_TRI_LIST_TO_LINE_LIST, /** ( 2) Convert triangle list to line list. */
+	BGFX_TOPOLOGY_CONVERT_TRI_STRIP_TO_TRI_LIST, /** ( 3) Convert triangle strip to triangle list. */
+	BGFX_TOPOLOGY_CONVERT_LINE_STRIP_TO_LINE_LIST, /** ( 4) Convert line strip to line list. */
 
-    BGFX_TOPOLOGY_CONVERT_COUNT
+	BGFX_TOPOLOGY_CONVERT_COUNT
 
 } bgfx_topology_convert_t;
 
+/**
+ * Topology sort order.
+ *
+ */
 typedef enum bgfx_topology_sort
 {
-    BGFX_TOPOLOGY_SORT_DIRECTION_FRONT_TO_BACK_MIN,
-    BGFX_TOPOLOGY_SORT_DIRECTION_FRONT_TO_BACK_AVG,
-    BGFX_TOPOLOGY_SORT_DIRECTION_FRONT_TO_BACK_MAX,
-    BGFX_TOPOLOGY_SORT_DIRECTION_BACK_TO_FRONT_MIN,
-    BGFX_TOPOLOGY_SORT_DIRECTION_BACK_TO_FRONT_AVG,
-    BGFX_TOPOLOGY_SORT_DIRECTION_BACK_TO_FRONT_MAX,
-    BGFX_TOPOLOGY_SORT_DISTANCE_FRONT_TO_BACK_MIN,
-    BGFX_TOPOLOGY_SORT_DISTANCE_FRONT_TO_BACK_AVG,
-    BGFX_TOPOLOGY_SORT_DISTANCE_FRONT_TO_BACK_MAX,
-    BGFX_TOPOLOGY_SORT_DISTANCE_BACK_TO_FRONT_MIN,
-    BGFX_TOPOLOGY_SORT_DISTANCE_BACK_TO_FRONT_AVG,
-    BGFX_TOPOLOGY_SORT_DISTANCE_BACK_TO_FRONT_MAX,
-
-    BGFX_TOPOLOGY_SORT_COUNT
+	BGFX_TOPOLOGY_SORT_DIRECTION_FRONT_TO_BACK_MIN, /** ( 0)                                */
+	BGFX_TOPOLOGY_SORT_DIRECTION_FRONT_TO_BACK_AVG, /** ( 1)                                */
+	BGFX_TOPOLOGY_SORT_DIRECTION_FRONT_TO_BACK_MAX, /** ( 2)                                */
+	BGFX_TOPOLOGY_SORT_DIRECTION_BACK_TO_FRONT_MIN, /** ( 3)                                */
+	BGFX_TOPOLOGY_SORT_DIRECTION_BACK_TO_FRONT_AVG, /** ( 4)                                */
+	BGFX_TOPOLOGY_SORT_DIRECTION_BACK_TO_FRONT_MAX, /** ( 5)                                */
+	BGFX_TOPOLOGY_SORT_DISTANCE_FRONT_TO_BACK_MIN, /** ( 6)                                */
+	BGFX_TOPOLOGY_SORT_DISTANCE_FRONT_TO_BACK_AVG, /** ( 7)                                */
+	BGFX_TOPOLOGY_SORT_DISTANCE_FRONT_TO_BACK_MAX, /** ( 8)                                */
+	BGFX_TOPOLOGY_SORT_DISTANCE_BACK_TO_FRONT_MIN, /** ( 9)                                */
+	BGFX_TOPOLOGY_SORT_DISTANCE_BACK_TO_FRONT_AVG, /** (10)                                */
+	BGFX_TOPOLOGY_SORT_DISTANCE_BACK_TO_FRONT_MAX, /** (11)                                */
+
+	BGFX_TOPOLOGY_SORT_COUNT
 
 } bgfx_topology_sort_t;
 
+/**
+ * View mode sets draw call sort order.
+ *
+ */
 typedef enum bgfx_view_mode
 {
-    BGFX_VIEW_MODE_DEFAULT,
-    BGFX_VIEW_MODE_SEQUENTIAL,
-    BGFX_VIEW_MODE_DEPTH_ASCENDING,
-    BGFX_VIEW_MODE_DEPTH_DESCENDING,
+	BGFX_VIEW_MODE_DEFAULT,                   /** ( 0) Default sort order.            */
+	BGFX_VIEW_MODE_SEQUENTIAL,                /** ( 1) Sort in the same order in which submit calls were called. */
+	BGFX_VIEW_MODE_DEPTH_ASCENDING,           /** ( 2) Sort draw call depth in ascending order. */
+	BGFX_VIEW_MODE_DEPTH_DESCENDING,          /** ( 3) Sort draw call depth in descending order. */
 
-    BGFX_VIEW_MODE_CCOUNT
+	BGFX_VIEW_MODE_COUNT
 
 } bgfx_view_mode_t;
 
-#define BGFX_HANDLE_T(_name) \
-    typedef struct _name##_s { uint16_t idx; } _name##_t
+/**
+ * Render frame enum.
+ *
+ */
+typedef enum bgfx_render_frame
+{
+	BGFX_RENDER_FRAME_NO_CONTEXT,             /** ( 0) Renderer context is not created yet. */
+	BGFX_RENDER_FRAME_RENDER,                 /** ( 1) Renderer context is created and rendering. */
+	BGFX_RENDER_FRAME_TIMEOUT,                /** ( 2) Renderer context wait for main thread signal timed out without rendering. */
+	BGFX_RENDER_FRAME_EXITING,                /** ( 3) Renderer context is getting destroyed. */
+
+	BGFX_RENDER_FRAME_COUNT
 
-BGFX_HANDLE_T(bgfx_dynamic_index_buffer_handle);
-BGFX_HANDLE_T(bgfx_dynamic_vertex_buffer_handle);
-BGFX_HANDLE_T(bgfx_frame_buffer_handle);
-BGFX_HANDLE_T(bgfx_index_buffer_handle);
-BGFX_HANDLE_T(bgfx_indirect_buffer_handle);
-BGFX_HANDLE_T(bgfx_occlusion_query_handle);
-BGFX_HANDLE_T(bgfx_program_handle);
-BGFX_HANDLE_T(bgfx_shader_handle);
-BGFX_HANDLE_T(bgfx_texture_handle);
-BGFX_HANDLE_T(bgfx_uniform_handle);
-BGFX_HANDLE_T(bgfx_vertex_buffer_handle);
-BGFX_HANDLE_T(bgfx_vertex_decl_handle);
+} bgfx_render_frame_t;
 
-#undef BGFX_HANDLE_T
 
 /**/
-typedef void (*bgfx_release_fn_t)(void* _ptr, void* _userData);
+typedef uint16_t bgfx_view_id_t;
 
 /**/
-typedef struct bgfx_memory_s
+typedef struct bgfx_allocator_interface_s
 {
-    uint8_t* data;
-    uint32_t size;
+    const struct bgfx_allocator_vtbl_s* vtbl;
 
-} bgfx_memory_t;
+} bgfx_allocator_interface_t;
 
 /**/
-typedef struct bgfx_transform_s
+typedef struct bgfx_allocator_vtbl_s
 {
-    float* data;
-    uint16_t num;
+    void* (*realloc)(bgfx_allocator_interface_t* _this, void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line);
 
-} bgfx_transform_t;
+} bgfx_allocator_vtbl_t;
 
 /**/
-typedef uint16_t bgfx_view_id_t;
+typedef struct bgfx_interface_vtbl bgfx_interface_vtbl_t;
 
 /**/
-typedef struct bgfx_view_stats_s
+typedef struct bgfx_callback_interface_s
 {
-    char           name[256];
-    bgfx_view_id_t view;
-    int64_t        cpuTimeElapsed;
-    int64_t        gpuTimeElapsed;
-
-} bgfx_view_stats_t;
+    const struct bgfx_callback_vtbl_s* vtbl;
 
-typedef struct bgfx_encoder_stats_s
-{
-    int64_t cpuTimeBegin;
-    int64_t cpuTimeEnd;
+} bgfx_callback_interface_t;
 
-} bgfx_encoder_stats_t;
 
 /**/
-typedef struct bgfx_stats_s
+typedef struct bgfx_callback_vtbl_s
 {
-    int64_t cpuTimeFrame;
-    int64_t cpuTimeBegin;
-    int64_t cpuTimeEnd;
-    int64_t cpuTimerFreq;
+    void (*fatal)(bgfx_callback_interface_t* _this, const char* _filePath, uint16_t _line, bgfx_fatal_t _code, const char* _str);
+    void (*trace_vargs)(bgfx_callback_interface_t* _this, const char* _filePath, uint16_t _line, const char* _format, va_list _argList);
+    void (*profiler_begin)(bgfx_callback_interface_t* _this, const char* _name, uint32_t _abgr, const char* _filePath, uint16_t _line);
+    void (*profiler_begin_literal)(bgfx_callback_interface_t* _this, const char* _name, uint32_t _abgr, const char* _filePath, uint16_t _line);
+    void (*profiler_end)(bgfx_callback_interface_t* _this);
+    uint32_t (*cache_read_size)(bgfx_callback_interface_t* _this, uint64_t _id);
+    bool (*cache_read)(bgfx_callback_interface_t* _this, uint64_t _id, void* _data, uint32_t _size);
+    void (*cache_write)(bgfx_callback_interface_t* _this, uint64_t _id, const void* _data, uint32_t _size);
+    void (*screen_shot)(bgfx_callback_interface_t* _this, const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data, uint32_t _size, bool _yflip);
+    void (*capture_begin)(bgfx_callback_interface_t* _this, uint32_t _width, uint32_t _height, uint32_t _pitch, bgfx_texture_format_t _format, bool _yflip);
+    void (*capture_end)(bgfx_callback_interface_t* _this);
+    void (*capture_frame)(bgfx_callback_interface_t* _this, const void* _data, uint32_t _size);
 
-    int64_t gpuTimeBegin;
-    int64_t gpuTimeEnd;
-    int64_t gpuTimerFreq;
+} bgfx_callback_vtbl_t;
 
-    int64_t waitRender;
-    int64_t waitSubmit;
+typedef struct bgfx_dynamic_index_buffer_handle_s { uint16_t idx; } bgfx_dynamic_index_buffer_handle_t;
 
-    uint32_t numDraw;
-    uint32_t numCompute;
-    uint32_t numBlit;
-    uint32_t maxGpuLatency;
+typedef struct bgfx_dynamic_vertex_buffer_handle_s { uint16_t idx; } bgfx_dynamic_vertex_buffer_handle_t;
 
-    uint16_t numDynamicIndexBuffers;
-    uint16_t numDynamicVertexBuffers;
-    uint16_t numFrameBuffers;
-    uint16_t numIndexBuffers;
-    uint16_t numOcclusionQueries;
-    uint16_t numPrograms;
-    uint16_t numShaders;
-    uint16_t numTextures;
-    uint16_t numUniforms;
-    uint16_t numVertexBuffers;
-    uint16_t numVertexDecls;
+typedef struct bgfx_frame_buffer_handle_s { uint16_t idx; } bgfx_frame_buffer_handle_t;
 
-    int64_t textureMemoryUsed;
-    int64_t rtMemoryUsed;
-    int32_t transientVbUsed;
-    int32_t transientIbUsed;
+typedef struct bgfx_index_buffer_handle_s { uint16_t idx; } bgfx_index_buffer_handle_t;
 
-    uint32_t numPrims[BGFX_TOPOLOGY_COUNT];
+typedef struct bgfx_indirect_buffer_handle_s { uint16_t idx; } bgfx_indirect_buffer_handle_t;
 
-    int64_t gpuMemoryMax;
-    int64_t gpuMemoryUsed;
+typedef struct bgfx_occlusion_query_handle_s { uint16_t idx; } bgfx_occlusion_query_handle_t;
 
-    uint16_t width;
-    uint16_t height;
-    uint16_t textWidth;
-    uint16_t textHeight;
+typedef struct bgfx_program_handle_s { uint16_t idx; } bgfx_program_handle_t;
 
-    uint16_t           numViews;
-    bgfx_view_stats_t* viewStats;
+typedef struct bgfx_shader_handle_s { uint16_t idx; } bgfx_shader_handle_t;
 
-    uint8_t               numEncoders;
-    bgfx_encoder_stats_t* encoderStats;
+typedef struct bgfx_texture_handle_s { uint16_t idx; } bgfx_texture_handle_t;
 
-} bgfx_stats_t;
+typedef struct bgfx_uniform_handle_s { uint16_t idx; } bgfx_uniform_handle_t;
 
-/**/
-typedef struct bgfx_vertex_decl_s
-{
-    uint32_t hash;
-    uint16_t stride;
-    uint16_t offset[BGFX_ATTRIB_COUNT];
-    uint16_t attributes[BGFX_ATTRIB_COUNT];
+typedef struct bgfx_vertex_buffer_handle_s { uint16_t idx; } bgfx_vertex_buffer_handle_t;
 
-} bgfx_vertex_decl_t;
+typedef struct bgfx_vertex_decl_handle_s { uint16_t idx; } bgfx_vertex_decl_handle_t;
 
-/**/
-typedef struct bgfx_transient_index_buffer_s
-{
-    uint8_t* data;
-    uint32_t size;
-    bgfx_index_buffer_handle_t handle;
-    uint32_t startIndex;
 
-} bgfx_transient_index_buffer_t;
+/**
+ * Memory release callback.
+ *
+ * @param[in] _ptr Pointer to allocated data.
+ * @param[in] _userData User defined data if needed.
+ *
+ */
+typedef void (*bgfx_release_fn_t)(void* _ptr, void* _userData);
 
-/**/
-typedef struct bgfx_transient_vertex_buffer_s
+/**
+ * GPU info.
+ *
+ */
+typedef struct bgfx_caps_gpu_s
 {
-    uint8_t* data;
-    uint32_t size;
-    uint32_t startVertex;
-    uint16_t stride;
-    bgfx_vertex_buffer_handle_t handle;
-    bgfx_vertex_decl_handle_t decl;
+	uint16_t             vendorId;           /** Vendor PCI id. See `BGFX_PCI_ID_*`.      */
+	uint16_t             deviceId;           /** Device id.                               */
 
-} bgfx_transient_vertex_buffer_t;
+} bgfx_caps_gpu_t;
 
-/**/
-typedef struct bgfx_instance_data_buffer_s
+/**
+ * Renderer capabilities limits.
+ *
+ */
+typedef struct bgfx_caps_limits_s
 {
-    uint8_t* data;
-    uint32_t size;
-    uint32_t offset;
-    uint32_t num;
-    uint16_t stride;
-    bgfx_vertex_buffer_handle_t handle;
+	uint32_t             maxDrawCalls;       /** Maximum number of draw calls.            */
+	uint32_t             maxBlits;           /** Maximum number of blit calls.            */
+	uint32_t             maxTextureSize;     /** Maximum texture size.                    */
+	uint32_t             maxTextureLayers;   /** Maximum texture layers.                  */
+	uint32_t             maxViews;           /** Maximum number of views.                 */
+	uint32_t             maxFrameBuffers;    /** Maximum number of frame buffer handles.  */
+	uint32_t             maxFBAttachments;   /** Maximum number of frame buffer attachments. */
+	uint32_t             maxPrograms;        /** Maximum number of program handles.       */
+	uint32_t             maxShaders;         /** Maximum number of shader handles.        */
+	uint32_t             maxTextures;        /** Maximum number of texture handles.       */
+	uint32_t             maxTextureSamplers; /** Maximum number of texture samplers.      */
+	uint32_t             maxComputeBindings; /** Maximum number of compute bindings.      */
+	uint32_t             maxVertexDecls;     /** Maximum number of vertex format declarations. */
+	uint32_t             maxVertexStreams;   /** Maximum number of vertex streams.        */
+	uint32_t             maxIndexBuffers;    /** Maximum number of index buffer handles.  */
+	uint32_t             maxVertexBuffers;   /** Maximum number of vertex buffer handles. */
+	uint32_t             maxDynamicIndexBuffers; /** Maximum number of dynamic index buffer handles. */
+	uint32_t             maxDynamicVertexBuffers; /** Maximum number of dynamic vertex buffer handles. */
+	uint32_t             maxUniforms;        /** Maximum number of uniform handles.       */
+	uint32_t             maxOcclusionQueries; /** Maximum number of occlusion query handles. */
+	uint32_t             maxEncoders;        /** Maximum number of encoder threads.       */
+	uint32_t             transientVbSize;    /** Maximum transient vertex buffer size.    */
+	uint32_t             transientIbSize;    /** Maximum transient index buffer size.     */
 
-} bgfx_instance_data_buffer_t;
+} bgfx_caps_limits_t;
 
-/**/
-typedef struct bgfx_texture_info_s
+/**
+ * Renderer capabilities.
+ *
+ */
+typedef struct bgfx_caps_s
 {
-    bgfx_texture_format_t format;
-    uint32_t storageSize;
-    uint16_t width;
-    uint16_t height;
-    uint16_t depth;
-    uint16_t numLayers;
-    uint8_t numMips;
-    uint8_t bitsPerPixel;
-    bool    cubeMap;
+	bgfx_renderer_type_t rendererType;       /** Renderer backend type. See: `bgfx::RendererType` */
+	
+	/**
+	 * Supported functionality.
+	 *   @attention See BGFX_CAPS_* flags at https://bkaradzic.github.io/bgfx/bgfx.html#available-caps
+	 */
+	uint64_t             supported;
+	uint16_t             vendorId;           /** Selected GPU vendor PCI id.              */
+	uint16_t             deviceId;           /** Selected GPU device id.                  */
+	bool                 homogeneousDepth;   /** True when NDC depth is in [-1, 1] range, otherwise its [0, 1]. */
+	bool                 originBottomLeft;   /** True when NDC origin is at bottom left.  */
+	uint8_t              numGPUs;            /** Number of enumerated GPUs.               */
+	bgfx_caps_gpu_t      gpu[4];             /** Enumerated GPUs.                         */
+	bgfx_caps_limits_t   limits;
+	
+	/**
+	 * 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.
+	 *   - `BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED` - Texture format is emulated.
+	 *   - `BGFX_CAPS_FORMAT_TEXTURE_3D` - Texture format is supported.
+	 *   - `BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB` - Texture as sRGB format is supported.
+	 *   - `BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED` - Texture format is emulated.
+	 *   - `BGFX_CAPS_FORMAT_TEXTURE_CUBE` - Texture format is supported.
+	 *   - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB` - Texture as sRGB format is supported.
+	 *   - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED` - Texture format is emulated.
+	 *   - `BGFX_CAPS_FORMAT_TEXTURE_VERTEX` - Texture format can be used from vertex shader.
+	 *   - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE` - Texture format can be used as image from compute
+	 *     shader.
+	 *   - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER` - Texture format can be used as frame
+	 *     buffer.
+	 *   - `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[BGFX_TEXTURE_FORMAT_COUNT];
 
-} bgfx_texture_info_t;
+} bgfx_caps_t;
 
-/**/
-typedef struct bgfx_uniform_info_s
+/**
+ * Internal data.
+ *
+ */
+typedef struct bgfx_internal_data_s
 {
-    char name[256];
-    bgfx_uniform_type_t type;
-    uint16_t num;
+	const bgfx_caps_t*   caps;               /** Renderer capabilities.                   */
+	void*                context;            /** GL context, or D3D device.               */
 
-} bgfx_uniform_info_t;
+} bgfx_internal_data_t;
 
-/**/
-typedef struct bgfx_attachment_s
+/**
+ * Platform data.
+ *
+ */
+typedef struct bgfx_platform_data_s
 {
-    bgfx_access_t access;
-    bgfx_texture_handle_t handle;
-    uint16_t mip;
-    uint16_t layer;
-    uint8_t  resolve;
+	void*                ndt;                /** Native display type.                     */
+	void*                nwh;                /** Native window handle.                    */
+	void*                context;            /** GL context, or D3D device.               */
+	void*                backBuffer;         /** GL backbuffer, or D3D render target view. */
+	void*                backBufferDS;       /** Backbuffer depth/stencil.                */
 
-} bgfx_attachment_t;
+} bgfx_platform_data_t;
 
-/**/
-typedef struct bgfx_caps_gpu_s
+/**
+ * Backbuffer resolution and reset parameters.
+ *
+ */
+typedef struct bgfx_resolution_s
 {
-    uint16_t vendorId;
-    uint16_t deviceId;
+	bgfx_texture_format_t format;            /** Backbuffer format.                       */
+	uint32_t             width;              /** Backbuffer width.                        */
+	uint32_t             height;             /** Backbuffer height.                       */
+	uint32_t             reset;              /** Reset parameters.                        */
+	uint8_t              numBackBuffers;     /** Number of back buffers.                  */
+	uint8_t              maxFrameLatency;    /** Maximum frame latency.                   */
 
-} bgfx_caps_gpu_t;
+} bgfx_resolution_t;
 
-typedef struct bgfx_caps_limits_s
+typedef struct bgfx_init_limits_s
 {
-    uint32_t maxDrawCalls;
-    uint32_t maxBlits;
-    uint32_t maxTextureSize;
-    uint32_t maxTextureLayers;
-    uint32_t maxViews;
-    uint32_t maxFrameBuffers;
-    uint32_t maxFBAttachments;
-    uint32_t maxPrograms;
-    uint32_t maxShaders;
-    uint32_t maxTextures;
-    uint32_t maxTextureSamplers;
-    uint32_t maxComputeBindings;
-    uint32_t maxVertexDecls;
-    uint32_t maxVertexStreams;
-    uint32_t maxIndexBuffers;
-    uint32_t maxVertexBuffers;
-    uint32_t maxDynamicIndexBuffers;
-    uint32_t maxDynamicVertexBuffers;
-    uint32_t maxUniforms;
-    uint32_t maxOcclusionQueries;
-    uint32_t maxEncoders;
-    uint32_t transientVbSize;
-    uint32_t transientIbSize;
+	uint16_t             maxEncoders;        /** Maximum number of encoder threads.       */
+	uint32_t             transientVbSize;    /** Maximum transient vertex buffer size.    */
+	uint32_t             transientIbSize;    /** Maximum transient index buffer size.     */
 
-} bgfx_caps_limits_t;
+} bgfx_init_limits_t;
 
-/**/
-typedef struct bgfx_caps_s
+/**
+ * Initialization parameters used by `bgfx::init`.
+ *
+ */
+typedef struct bgfx_init_s
 {
-    bgfx_renderer_type_t rendererType;
+	
+	/**
+	 * Select rendering backend. When set to RendererType::Count
+	 * a default rendering backend will be selected appropriate to the platform.
+	 * See: `bgfx::RendererType`
+	 */
+	bgfx_renderer_type_t type;
+	
+	/**
+	 * Vendor PCI id. If set to `BGFX_PCI_ID_NONE` it will select the first
+	 * device.
+	 *   - `BGFX_PCI_ID_NONE` - Autoselect adapter.
+	 *   - `BGFX_PCI_ID_SOFTWARE_RASTERIZER` - Software rasterizer.
+	 *   - `BGFX_PCI_ID_AMD` - AMD adapter.
+	 *   - `BGFX_PCI_ID_INTEL` - Intel adapter.
+	 *   - `BGFX_PCI_ID_NVIDIA` - nVidia adapter.
+	 */
+	uint16_t             vendorId;
+	
+	/**
+	 * Device id. If set to 0 it will select first device, or device with
+	 * matching id.
+	 */
+	uint16_t             deviceId;
+	bool                 debug;              /** Enable device for debuging.              */
+	bool                 profile;            /** Enable device for profiling.             */
+	bgfx_platform_data_t platformData;       /** Platform data.                           */
+	bgfx_resolution_t    resolution;         /** Backbuffer resolution and reset parameters. See: `bgfx::Resolution`. */
+	bgfx_init_limits_t   limits;
+	
+	/**
+	 * Provide application specific callback interface.
+	 * See: `bgfx::CallbackI`
+	 */
+	bgfx_callback_interface_t* callback;
+	
+	/**
+	 * Custom allocator. When a custom allocator is not
+	 * specified, bgfx uses the CRT allocator. Bgfx assumes
+	 * custom allocator is thread safe.
+	 */
+	bgfx_allocator_interface_t* allocator;
 
-    uint64_t supported;
+} bgfx_init_t;
 
-    uint16_t vendorId;
-    uint16_t deviceId;
-    bool     homogeneousDepth;
-    bool     originBottomLeft;
-    uint8_t  numGPUs;
+/**
+ * Memory must be obtained by calling `bgfx::alloc`, `bgfx::copy`, or `bgfx::makeRef`.
+ * @attention It is illegal to create this structure on stack and pass it to any bgfx API.
+ *
+ */
+typedef struct bgfx_memory_s
+{
+	uint8_t*             data;               /** Pointer to data.                         */
+	uint32_t             size;               /** Data size.                               */
 
-    bgfx_caps_gpu_t gpu[4];
-    bgfx_caps_limits_t limits;
+} bgfx_memory_t;
 
-    uint16_t formats[BGFX_TEXTURE_FORMAT_COUNT];
+/**
+ * Transient index buffer.
+ *
+ */
+typedef struct bgfx_transient_index_buffer_s
+{
+	int8_t*              data;               /** Pointer to data.                         */
+	uint32_t             size;               /** Data size.                               */
+	uint32_t             startIndex;         /** First index.                             */
+	bgfx_index_buffer_handle_t handle;       /** Index buffer handle.                     */
 
-} bgfx_caps_t;
+} bgfx_transient_index_buffer_t;
 
-/**/
-typedef enum bgfx_fatal_s
+/**
+ * Transient vertex buffer.
+ *
+ */
+typedef struct bgfx_transient_vertex_buffer_s
 {
-    BGFX_FATAL_DEBUG_CHECK,
-    BGFX_FATAL_INVALID_SHADER,
-    BGFX_FATAL_UNABLE_TO_INITIALIZE,
-    BGFX_FATAL_UNABLE_TO_CREATE_TEXTURE,
-    BGFX_FATAL_DEVICE_LOST,
-
-    BGFX_FATAL_COUNT
+	int8_t*              data;               /** Pointer to data.                         */
+	uint32_t             size;               /** Data size.                               */
+	uint32_t             startVertex;        /** First vertex.                            */
+	uint16_t             stride;             /** Vertex stride.                           */
+	bgfx_vertex_buffer_handle_t handle;      /** Vertex buffer handle.                    */
+	bgfx_vertex_decl_handle_t decl;          /** Vertex declaration handle.               */
 
-} bgfx_fatal_t;
+} bgfx_transient_vertex_buffer_t;
 
-/**/
-typedef struct bgfx_callback_interface_s
+/**
+ * Instance data buffer info.
+ *
+ */
+typedef struct bgfx_instance_data_buffer_s
 {
-    const struct bgfx_callback_vtbl_s* vtbl;
+	int8_t*              data;               /** Pointer to data.                         */
+	uint32_t             size;               /** Data size.                               */
+	uint32_t             offset;             /** Offset in vertex buffer.                 */
+	uint32_t             num;                /** Number of instances.                     */
+	uint16_t             stride;             /** Vertex buffer stride.                    */
+	bgfx_vertex_buffer_handle_t handle;      /** Vertex buffer object handle.             */
 
-} bgfx_callback_interface_t;
+} bgfx_instance_data_buffer_t;
 
-/**/
-typedef struct bgfx_callback_vtbl_s
+/**
+ * Texture info.
+ *
+ */
+typedef struct bgfx_texture_info_s
 {
-    void (*fatal)(bgfx_callback_interface_t* _this, const char* _filePath, uint16_t _line, bgfx_fatal_t _code, const char* _str);
-    void (*trace_vargs)(bgfx_callback_interface_t* _this, const char* _filePath, uint16_t _line, const char* _format, va_list _argList);
-    void (*profiler_begin)(bgfx_callback_interface_t* _this, const char* _name, uint32_t _abgr, const char* _filePath, uint16_t _line);
-    void (*profiler_begin_literal)(bgfx_callback_interface_t* _this, const char* _name, uint32_t _abgr, const char* _filePath, uint16_t _line);
-    void (*profiler_end)(bgfx_callback_interface_t* _this);
-    uint32_t (*cache_read_size)(bgfx_callback_interface_t* _this, uint64_t _id);
-    bool (*cache_read)(bgfx_callback_interface_t* _this, uint64_t _id, void* _data, uint32_t _size);
-    void (*cache_write)(bgfx_callback_interface_t* _this, uint64_t _id, const void* _data, uint32_t _size);
-    void (*screen_shot)(bgfx_callback_interface_t* _this, const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data, uint32_t _size, bool _yflip);
-    void (*capture_begin)(bgfx_callback_interface_t* _this, uint32_t _width, uint32_t _height, uint32_t _pitch, bgfx_texture_format_t _format, bool _yflip);
-    void (*capture_end)(bgfx_callback_interface_t* _this);
-    void (*capture_frame)(bgfx_callback_interface_t* _this, const void* _data, uint32_t _size);
+	bgfx_texture_format_t format;            /** Texture format.                          */
+	uint32_t             storageSize;        /** Total amount of bytes required to store texture. */
+	uint16_t             width;              /** Texture width.                           */
+	uint16_t             height;             /** Texture height.                          */
+	uint16_t             depth;              /** Texture depth.                           */
+	uint16_t             numLayers;          /** Number of layers in texture array.       */
+	uint8_t              numMips;            /** Number of MIP maps.                      */
+	uint8_t              bitsPerPixel;       /** Format bits per pixel.                   */
+	bool                 cubeMap;            /** Texture is cubemap.                      */
 
-} bgfx_callback_vtbl_t;
+} bgfx_texture_info_t;
 
-/**/
-typedef struct bgfx_allocator_interface_s
+/**
+ * Uniform info.
+ *
+ */
+typedef struct bgfx_uniform_info_s
 {
-    const struct bgfx_allocator_vtbl_s* vtbl;
+	char                 name[256];          /** Uniform name.                            */
+	bgfx_uniform_type_t  type;               /** Uniform type.                            */
+	uint16_t             num;                /** Number of elements in array.             */
 
-} bgfx_allocator_interface_t;
+} bgfx_uniform_info_t;
 
-/**/
-typedef struct bgfx_allocator_vtbl_s
+/**
+ * Frame buffer texture attachment info.
+ *
+ */
+typedef struct bgfx_attachment_s
 {
-    void* (*realloc)(bgfx_allocator_interface_t* _this, void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line);
+	bgfx_access_t        access;             /** Attachement access. See `Access::Enum`.  */
+	bgfx_texture_handle_t handle;            /** Render target texture handle.            */
+	uint16_t             mip;                /** Mip level.                               */
+	uint16_t             layer;              /** Cubemap side or depth layer/slice.       */
+	uint8_t              resolve;            /** Resolve flags. See: `BGFX_RESOLVE_*`     */
 
-} bgfx_allocator_vtbl_t;
+} bgfx_attachment_t;
 
-/**/
-typedef struct bgfx_platform_data
+/**
+ * Transform data.
+ *
+ */
+typedef struct bgfx_transform_s
 {
-    void* ndt;
-    void* nwh;
-    void* context;
-    void* backBuffer;
-    void* backBufferDS;
+	float*               data;               /** Pointer to first 4x4 matrix.             */
+	uint16_t             num;                /** Number of matrices.                      */
 
-} bgfx_platform_data_t;
+} bgfx_transform_t;
 
-/**/
-typedef struct bgfx_resolution_s
+/**
+ * View stats.
+ *
+ */
+typedef struct bgfx_view_stats_s
 {
-    bgfx_texture_format_t format;
-    uint32_t width;
-    uint32_t height;
-    uint32_t reset;
-    uint8_t  numBackBuffers;
-    uint8_t  maxFrameLatency;
+	char                 name[256];          /** View name.                               */
+	bgfx_view_id_t       view;               /** View id.                                 */
+	int64_t              cpuTimeElapsed;     /** CPU (submit) time elapsed.               */
+	int64_t              gpuTimeElapsed;     /** GPU time elapsed.                        */
 
-} bgfx_resolution_t;
+} bgfx_view_stats_t;
 
-/**/
-typedef struct bgfx_init_limits_s
+/**
+ * Encoder stats.
+ *
+ */
+typedef struct bgfx_encoder_stats_s
 {
-    uint16_t maxEncoders;
-    uint32_t transientVbSize;
-    uint32_t transientIbSize;
+	int64_t              cpuTimeBegin;       /** Encoder thread CPU submit begin time.    */
+	int64_t              cpuTimeEnd;         /** Encoder thread CPU submit end time.      */
 
-} bgfx_init_limits_t;
+} bgfx_encoder_stats_t;
 
-/**/
-typedef struct bgfx_init_s
+/**
+ * Renderer statistics data.
+ * @remarks All time values are high-resolution timestamps, while
+ * time frequencies define timestamps-per-second for that hardware.
+ *
+ */
+typedef struct bgfx_stats_s
 {
-    bgfx_renderer_type_t type;
-    uint16_t vendorId;
-    uint16_t deviceId;
-    bool debug;
-    bool profile;
+	int64_t              cpuTimeFrame;       /** CPU time between two `bgfx::frame` calls. */
+	int64_t              cpuTimeBegin;       /** Render thread CPU submit begin time.     */
+	int64_t              cpuTimeEnd;         /** Render thread CPU submit end time.       */
+	int64_t              cpuTimerFreq;       /** CPU timer frequency. Timestamps-per-second */
+	int64_t              gpuTimeBegin;       /** GPU frame begin time.                    */
+	int64_t              gpuTimeEnd;         /** GPU frame end time.                      */
+	int64_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             numBlit;            /** Number of blit calls submitted.          */
+	uint32_t             maxGpuLatency;      /** GPU driver latency.                      */
+	uint16_t             numDynamicIndexBuffers; /** Number of used dynamic index buffers.    */
+	uint16_t             numDynamicVertexBuffers; /** Number of used dynamic vertex buffers.   */
+	uint16_t             numFrameBuffers;    /** Number of used frame buffers.            */
+	uint16_t             numIndexBuffers;    /** Number of used index buffers.            */
+	uint16_t             numOcclusionQueries; /** Number of used occlusion queries.        */
+	uint16_t             numPrograms;        /** Number of used programs.                 */
+	uint16_t             numShaders;         /** Number of used shaders.                  */
+	uint16_t             numTextures;        /** Number of used textures.                 */
+	uint16_t             numUniforms;        /** Number of used uniforms.                 */
+	uint16_t             numVertexBuffers;   /** Number of used vertex buffers.           */
+	uint16_t             numVertexDecls;     /** Number of used vertex declarations.      */
+	int64_t              textureMemoryUsed;  /** Estimate of texture memory used.         */
+	int64_t              rtMemoryUsed;       /** Estimate of render target memory used.   */
+	int32_t              transientVbUsed;    /** Amount of transient vertex buffer used.  */
+	int32_t              transientIbUsed;    /** Amount of transient index buffer used.   */
+	uint32_t             numPrims[BGFX_TOPOLOGY_COUNT]; /** Number of primitives rendered.           */
+	int64_t              gpuMemoryMax;       /** Maximum available GPU memory for application. */
+	int64_t              gpuMemoryUsed;      /** Amount of GPU memory used by the application. */
+	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.         */
+	uint16_t             numViews;           /** Number of view stats.                    */
+	bgfx_view_stats_t*   viewStats;          /** Array of View stats.                     */
+	uint8_t              numEncoders;        /** Number of encoders used during frame.    */
+	bgfx_encoder_stats_t* encoderStats;      /** Array of encoder stats.                  */
 
-    bgfx_platform_data_t platformData;
-    bgfx_resolution_t    resolution;
-    bgfx_init_limits_t   limits;
+} bgfx_stats_t;
 
-    bgfx_callback_interface_t*  callback;
-    bgfx_allocator_interface_t* allocator;
+/**
+ * Vertex declaration.
+ *
+ */
+typedef struct bgfx_vertex_decl_s
+{
+	uint32_t             hash;               /** Hash.                                    */
+	uint16_t             stride;             /** Stride.                                  */
+	uint16_t             offset[BGFX_ATTRIB_COUNT]; /** Attribute offsets.                       */
+	uint16_t             attributes[BGFX_ATTRIB_COUNT]; /** Used attributes.                         */
 
-} bgfx_init_t;
+} bgfx_vertex_decl_t;
 
-/**/
-typedef enum bgfx_render_frame
+/**
+ * Encoders are used for submitting draw calls from multiple threads. Only one encoder
+ * per thread should be used. Use `bgfx::begin()` to obtain an encoder for a thread.
+ *
+ */
+typedef struct bgfx_encoder_s
 {
-    BGFX_RENDER_FRAME_NO_CONTEXT,
-    BGFX_RENDER_FRAME_RENDER,
-    BGFX_RENDER_FRAME_TIMEOUT,
-    BGFX_RENDER_FRAME_EXITING,
+	
 
-    BGFX_RENDER_FRAME_COUNT
+} bgfx_encoder_t;
 
-} bgfx_render_frame_t;
 
-/**/
-typedef struct bgfx_internal_data
-{
-    const struct bgfx_caps* caps;
-    void* context;
 
-} bgfx_internal_data_t;
+/**
+ * Init attachment.
+ *
+ * @param[in] _handle Render target texture handle.
+ * @param[in] _access Access. See `Access::Enum`.
+ * @param[in] _layer Cubemap side or depth layer/slice.
+ * @param[in] _mip Mip level.
+ * @param[in] _resolve Resolve flags. See: `BGFX_RESOLVE_*`
+ *
+ */
+BGFX_C_API void bgfx_attachment_init(bgfx_attachment_t* _this, bgfx_texture_handle_t _handle, bgfx_access_t _access, uint16_t _layer, uint16_t _mip, uint8_t _resolve);
 
-/**/
-typedef struct bgfx_encoder_s bgfx_encoder_t;
+/**
+ * Start VertexDecl.
+ *
+ * @param[in] _rendererType
+ *
+ */
+BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _this, bgfx_renderer_type_t _rendererType);
+
+/**
+ * Add attribute to VertexDecl.
+ * @remarks Must be called between begin/end.
+ *
+ * @param[in] _attrib Attribute semantics. See: `bgfx::Attrib`
+ * @param[in] _num Number of elements 1, 2, 3 or 4.
+ * @param[in] _type Element type.
+ * @param[in] _normalized 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.
+ * @param[in] _asInt Packaging rule for vertexPack, vertexUnpack, and
+ *  vertexConvert for AttribType::Uint8 and AttribType::Int16.
+ *  Unpacking code must be implemented inside vertex shader.
+ *
+ */
+BGFX_C_API void bgfx_vertex_decl_add(bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib, uint8_t _num, bgfx_attrib_type_t _type, bool _normalized, bool _asInt);
 
-#include "bgfx.idl.h"
+/**
+ * Decode attribute.
+ *
+ * @param[in] _attrib Attribute semantics. See: `bgfx::Attrib`
+ * @param[out] _num Number of elements.
+ * @param[out] _type Element type.
+ * @param[out] _normalized Attribute is normalized.
+ * @param[out] _asInt Attribute is packed as int.
+ *
+ */
+BGFX_C_API void bgfx_vertex_decl_decode(const bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib, uint8_t * _num, bgfx_attrib_type_t * _type, bool * _normalized, bool * _asInt);
+
+/**
+ * Returns true if VertexDecl contains attribute.
+ *
+ * @param[in] _attrib Attribute semantics. See: `bgfx::Attrib`
+ *
+ */
+BGFX_C_API bool bgfx_vertex_decl_has(const bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib);
+
+/**
+ * Skip `_num` bytes in vertex stream.
+ *
+ * @param[in] _num
+ *
+ */
+BGFX_C_API void bgfx_vertex_decl_skip(bgfx_vertex_decl_t* _this, uint8_t _num);
+
+/**
+ * End VertexDecl.
+ *
+ */
+BGFX_C_API void bgfx_vertex_decl_end(bgfx_vertex_decl_t* _this);
+
+/**
+ * Pack vertex attribute into vertex stream format.
+ *
+ * @param[in] _input Value to be packed into vertex stream.
+ * @param[in] _inputNormalized `true` if input value is already normalized.
+ * @param[in] _attr Attribute to pack.
+ * @param[in] _decl Vertex stream declaration.
+ * @param[in] _data Destination vertex stream where data will be packed.
+ * @param[in] _index Vertex index that will be modified.
+ *
+ */
+BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, void* _data, uint32_t _index);
+
+/**
+ * Unpack vertex attribute from vertex stream format.
+ *
+ * @param[out] _output Result of unpacking.
+ * @param[in] _attr Attribute to unpack.
+ * @param[in] _decl Vertex stream declaration.
+ * @param[in] _data Source vertex stream from where data will be unpacked.
+ * @param[in] _index Vertex index that will be unpacked.
+ *
+ */
+BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, const void* _data, uint32_t _index);
+
+/**
+ * Converts vertex stream data from one vertex stream format to another.
+ *
+ * @param[in] _dstDecl Destination vertex stream declaration.
+ * @param[in] _dstData Destination vertex stream.
+ * @param[in] _srcDecl Source vertex stream declaration.
+ * @param[in] _srcData Source vertex stream data.
+ * @param[in] _num Number of vertices to convert from source to destination.
+ *
+ */
+BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_decl_t * _dstDecl, void* _dstData, const bgfx_vertex_decl_t * _srcDecl, const void* _srcData, uint32_t _num);
+
+/**
+ * Weld vertices.
+ *
+ * @param[in] _output Welded vertices remapping table. The size of buffer
+ *  must be the same as number of vertices.
+ * @param[in] _decl Vertex stream declaration.
+ * @param[in] _data Vertex stream.
+ * @param[in] _num Number of vertices in vertex stream.
+ * @param[in] _epsilon Error tolerance for vertex position comparison.
+ *
+ * @returns Number of unique vertices after vertex welding.
+ *
+ */
+BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_decl_t * _decl, const void* _data, uint16_t _num, float _epsilon);
+
+/**
+ * Convert index buffer for use with different primitive topologies.
+ *
+ * @param[in] _conversion Conversion type, see `TopologyConvert::Enum`.
+ * @param[out] _dst Destination index buffer. If this argument is NULL
+ *  function will return number of indices after conversion.
+ * @param[in] _dstSize Destination index buffer in bytes. It must be
+ *  large enough to contain output indices. If destination size is
+ *  insufficient index buffer will be truncated.
+ * @param[in] _indices Source indices.
+ * @param[in] _numIndices Number of input indices.
+ * @param[in] _index32 Set to `true` if input indices are 32-bit.
+ *
+ * @returns Number of output indices after conversion.
+ *
+ */
+BGFX_C_API uint32_t bgfx_topology_convert(bgfx_topology_convert_t _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32);
+
+/**
+ * Sort indices.
+ *
+ * @param[in] _sort Sort order, see `TopologySort::Enum`.
+ * @param[out] _dst Destination index buffer.
+ * @param[in] _dstSize Destination index buffer in bytes. It must be
+ *  large enough to contain output indices. If destination size is
+ *  insufficient index buffer will be truncated.
+ * @param[in] _dir Direction (vector must be normalized).
+ * @param[in] _pos Position.
+ * @param[in] _vertices Pointer to first vertex represented as
+ *  float x, y, z. Must contain at least number of vertices
+ *  referencende by index buffer.
+ * @param[in] _stride Vertex stride.
+ * @param[in] _indices Source indices.
+ * @param[in] _numIndices Number of input indices.
+ * @param[in] _index32 Set to `true` if input indices are 32-bit.
+ *
+ */
+BGFX_C_API void bgfx_topology_sort_tri_list(bgfx_topology_sort_t _sort, void* _dst, uint32_t _dstSize, const float _dir[3], const float _pos[3], const void* _vertices, uint32_t _stride, const void* _indices, uint32_t _numIndices, bool _index32);
+
+/**
+ * Returns supported backend API renderers.
+ *
+ * @param[in] _max Maximum number of elements in _enum array.
+ * @param[inout] _enum Array where supported renderers will be written.
+ *
+ * @returns Number of supported renderers.
+ *
+ */
+BGFX_C_API uint8_t bgfx_get_supported_renderers(uint8_t _max, bgfx_renderer_type_t* _enum);
+
+/**
+ * Returns name of renderer.
+ *
+ * @param[in] _type Renderer backend type. See: `bgfx::RendererType`
+ *
+ * @returns Name of renderer.
+ *
+ */
+BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type);
+BGFX_C_API void bgfx_init_ctor(bgfx_init_t* _init);
+
+/**
+ * Initialize bgfx library.
+ *
+ * @param[in] _init Initialization parameters. See: `bgfx::Init` for more info.
+ *
+ * @returns `true` if initialization was successful.
+ *
+ */
+BGFX_C_API bool bgfx_init(const bgfx_init_t * _init);
+
+/**
+ * Shutdown bgfx library.
+ *
+ */
+BGFX_C_API void bgfx_shutdown();
+
+/**
+ * Reset graphic settings and back-buffer size.
+ * @attention This call doesn't actually change window size, it just
+ *   resizes back-buffer. Windowing code has to change window size.
+ *
+ * @param[in] _width Back-buffer width.
+ * @param[in] _height Back-buffer height.
+ * @param[in] _flags See: `BGFX_RESET_*` for more info.
+ *    - `BGFX_RESET_NONE` - No reset flags.
+ *    - `BGFX_RESET_FULLSCREEN` - Not supported yet.
+ *    - `BGFX_RESET_MSAA_X[2/4/8/16]` - Enable 2, 4, 8 or 16 x MSAA.
+ *    - `BGFX_RESET_VSYNC` - Enable V-Sync.
+ *    - `BGFX_RESET_MAXANISOTROPY` - Turn on/off max anisotropy.
+ *    - `BGFX_RESET_CAPTURE` - Begin screen capture.
+ *    - `BGFX_RESET_FLUSH_AFTER_RENDER` - Flush rendering after submitting to GPU.
+ *    - `BGFX_RESET_FLIP_AFTER_RENDER` - This flag  specifies where flip
+ *      occurs. Default behavior is that flip occurs before rendering new
+ *      frame. This flag only has effect when `BGFX_CONFIG_MULTITHREADED=0`.
+ *    - `BGFX_RESET_SRGB_BACKBUFFER` - Enable sRGB backbuffer.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags, bgfx_texture_format_t _format);
+
+/**
+ * Advance to next frame. When using multithreaded renderer, this call
+ * just swaps internal buffers, kicks render thread, and returns. In
+ * singlethreaded renderer this call does frame rendering.
+ *
+ * @param[in] _capture Capture frame with graphics debugger.
+ *
+ * @returns Current frame number. This might be used in conjunction with
+ *  double/multi buffering data outside the library and passing it to
+ *  library via `bgfx::makeRef` calls.
+ *
+ */
+BGFX_C_API uint32_t bgfx_frame(bool _capture);
+
+/**
+ * Returns current renderer backend API type.
+ * @remarks
+ *   Library must be initialized.
+ *
+ */
+BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type();
+
+/**
+ * Returns renderer capabilities.
+ * @remarks
+ *   Library must be initialized.
+ *
+ */
+BGFX_C_API const bgfx_caps_t* bgfx_get_caps();
+
+/**
+ * Returns performance counters.
+ * @attention Pointer returned is valid until `bgfx::frame` is called.
+ *
+ */
+BGFX_C_API const bgfx_stats_t* bgfx_get_stats();
+
+/**
+ * Allocate buffer to pass to bgfx calls. Data will be freed inside bgfx.
+ *
+ * @param[in] _size Size to allocate.
+ *
+ * @returns Allocated memory.
+ *
+ */
+BGFX_C_API const bgfx_memory_t* bgfx_alloc(uint32_t _size);
+
+/**
+ * Allocate buffer and copy data into it. Data will be freed inside bgfx.
+ *
+ * @param[in] _data Pointer to data to be copied.
+ * @param[in] _size Size of data to be copied.
+ *
+ * @returns Allocated memory.
+ *
+ */
+BGFX_C_API const bgfx_memory_t* bgfx_copy(const void* _data, uint32_t _size);
+
+/**
+ * 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.
+ * @attention Data passed must be available for at least 2 `bgfx::frame` calls.
+ *
+ * @param[in] _data Pointer to data.
+ * @param[in] _size Size of data.
+ *
+ * @returns Referenced memory.
+ *
+ */
+BGFX_C_API const bgfx_memory_t* bgfx_make_ref(const void* _data, uint32_t _size);
+
+/**
+ * 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.
+ * @attention Data passed must be available for at least 2 `bgfx::frame` calls.
+ *
+ * @param[in] _data Pointer to data.
+ * @param[in] _size Size of data.
+ * @param[in] _releaseFn Callback function to release memory after use.
+ * @param[in] _userData User data to be passed to callback function.
+ *
+ * @returns Referenced memory.
+ *
+ */
+BGFX_C_API const bgfx_memory_t* bgfx_make_ref_release(const void* _data, uint32_t _size, bgfx_release_fn_t _releaseFn, void* _userData);
+
+/**
+ * Set debug flags.
+ *
+ * @param[in] _debug Available flags:
+ *    - `BGFX_DEBUG_IFH` - Infinitely fast hardware. When this flag is set
+ *      all rendering calls will be skipped. This is useful when profiling
+ *      to quickly assess potential bottlenecks between CPU and GPU.
+ *    - `BGFX_DEBUG_PROFILER` - Enable profiler.
+ *    - `BGFX_DEBUG_STATS` - Display internal statistics.
+ *    - `BGFX_DEBUG_TEXT` - Display debug text.
+ *    - `BGFX_DEBUG_WIREFRAME` - Wireframe rendering. All rendering
+ *      primitives will be rendered as lines.
+ *
+ */
+BGFX_C_API void bgfx_set_debug(uint32_t _debug);
+
+/**
+ * Clear internal debug text buffer.
+ *
+ * @param[in] _attr Background color.
+ * @param[in] _small Default or 8x8 font.
+ *
+ */
+BGFX_C_API void bgfx_dbg_text_clear(uint8_t _attr, bool _small);
+
+/**
+ * Print formatted data to internal debug text character-buffer (VGA-compatible text mode).
+ *
+ * @param[in] _x Position x from the left corner of the window.
+ * @param[in] _y Position y from the top corner of the window.
+ * @param[in] _attr Color palette. Where top 4-bits represent index of background, and bottom
+ *  4-bits represent foreground color from standard VGA text palette (ANSI escape codes).
+ * @param[in] _format `printf` style format.
+ * @param[in] 
+ *
+ */
+BGFX_C_API void bgfx_dbg_text_printf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ... );
+
+/**
+ * Print formatted data from variable argument list to internal debug text character-buffer (VGA-compatible text mode).
+ *
+ * @param[in] _x Position x from the left corner of the window.
+ * @param[in] _y Position y from the top corner of the window.
+ * @param[in] _attr Color palette. Where top 4-bits represent index of background, and bottom
+ *  4-bits represent foreground color from standard VGA text palette (ANSI escape codes).
+ * @param[in] _format `printf` style format.
+ * @param[in] _argList Variable arguments list for format string.
+ *
+ */
+BGFX_C_API void bgfx_dbg_text_vprintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, va_list _argList);
+
+/**
+ * Draw image into internal debug text buffer.
+ *
+ * @param[in] _x Position x from the left corner of the window.
+ * @param[in] _y Position y from the top corner of the window.
+ * @param[in] _width Image width.
+ * @param[in] _height Image height.
+ * @param[in] _data Raw image data (character/attribute raw encoding).
+ * @param[in] _pitch Image pitch in bytes.
+ *
+ */
+BGFX_C_API void bgfx_dbg_text_image(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void* _data, uint16_t _pitch);
+
+/**
+ * Create static index buffer.
+ *
+ * @param[in] _mem Index buffer data.
+ * @param[in] _flags Buffer creation flags.
+ *    - `BGFX_BUFFER_NONE` - No flags.
+ *    - `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_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem, uint16_t _flags);
+
+/**
+ * Set static index buffer debug name.
+ *
+ * @param[in] _handle Static index buffer handle.
+ * @param[in] _name Static index buffer name.
+ * @param[in] _len Static index buffer name length (if length is INT32_MAX, it's expected
+ *  that _name is zero terminated string.
+ *
+ */
+BGFX_C_API void bgfx_set_index_buffer_name(bgfx_index_buffer_handle_t _handle, const char* _name, int32_t _len);
+
+/**
+ * Destroy static index buffer.
+ *
+ * @param[in] _handle Static index buffer handle.
+ *
+ */
+BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle);
+
+/**
+ * Create static vertex buffer.
+ *
+ * @param[in] _mem Vertex buffer data.
+ * @param[in] _decl Vertex declaration.
+ * @param[in] _flags Buffer creation flags.
+ *   - `BGFX_BUFFER_NONE` - No flags.
+ *   - `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.
+ *
+ * @returns Static vertex buffer handle.
+ *
+ */
+BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t * _decl, uint16_t _flags);
+
+/**
+ * Set static vertex buffer debug name.
+ *
+ * @param[in] _handle Static vertex buffer handle.
+ * @param[in] _name Static vertex buffer name.
+ * @param[in] _len Static vertex buffer name length (if length is INT32_MAX, it's expected
+ *  that _name is zero terminated string.
+ *
+ */
+BGFX_C_API void bgfx_set_vertex_buffer_name(bgfx_vertex_buffer_handle_t _handle, const char* _name, int32_t _len);
+
+/**
+ * Destroy static vertex buffer.
+ *
+ * @param[in] _handle Static vertex buffer handle.
+ *
+ */
+BGFX_C_API void bgfx_destroy_vertex_buffer(bgfx_vertex_buffer_handle_t _handle);
+
+/**
+ * Create empty dynamic index buffer.
+ *
+ * @param[in] _num Number of indices.
+ * @param[in] _flags Buffer creation flags.
+ *    - `BGFX_BUFFER_NONE` - No flags.
+ *    - `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.
+ *
+ * @returns Dynamic index buffer handle.
+ *
+ */
+BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num, uint16_t _flags);
+
+/**
+ * Create dynamic index buffer and initialized it.
+ *
+ * @param[in] _mem Index buffer data.
+ * @param[in] _flags Buffer creation flags.
+ *    - `BGFX_BUFFER_NONE` - No flags.
+ *    - `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.
+ *
+ * @returns Dynamic index buffer handle.
+ *
+ */
+BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem, uint16_t _flags);
+
+/**
+ * Update dynamic index buffer.
+ *
+ * @param[in] _handle Dynamic index buffer handle.
+ * @param[in] _startIndex Start index.
+ * @param[in] _mem Index buffer data.
+ *
+ */
+BGFX_C_API void bgfx_update_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _startIndex, const bgfx_memory_t* _mem);
+
+/**
+ * Destroy dynamic index buffer.
+ *
+ * @param[in] _handle Dynamic index buffer handle.
+ *
+ */
+BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle);
+
+/**
+ * Create empty dynamic vertex buffer.
+ *
+ * @param[in] _num Number of vertices.
+ * @param[in] _decl Vertex declaration.
+ * @param[in] _flags Buffer creation flags.
+ *    - `BGFX_BUFFER_NONE` - No flags.
+ *    - `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.
+ *
+ * @returns Dynamic vertex buffer handle.
+ *
+ */
+BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
+
+/**
+ * Create dynamic vertex buffer and initialize it.
+ *
+ * @param[in] _mem Vertex buffer data.
+ * @param[in] _decl Vertex declaration.
+ * @param[in] _flags Buffer creation flags.
+ *    - `BGFX_BUFFER_NONE` - No flags.
+ *    - `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.
+ *
+ * @returns Dynamic vertex buffer handle.
+ *
+ */
+BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
+
+/**
+ * Update dynamic vertex buffer.
+ *
+ * @param[in] _handle Dynamic vertex buffer handle.
+ * @param[in] _startVertex Start vertex.
+ * @param[in] _mem Vertex buffer data.
+ *
+ */
+BGFX_C_API void bgfx_update_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t* _mem);
+
+/**
+ * Destroy dynamic vertex buffer.
+ *
+ * @param[in] _handle Dynamic vertex buffer handle.
+ *
+ */
+BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle);
+
+/**
+ * Returns number of requested or maximum available indices.
+ *
+ * @param[in] _num Number of required indices.
+ *
+ * @returns Number of requested or maximum available indices.
+ *
+ */
+BGFX_C_API uint32_t bgfx_get_avail_transient_index_buffer(uint32_t _num);
+
+/**
+ * Returns number of requested or maximum available vertices.
+ *
+ * @param[in] _num Number of required vertices.
+ * @param[in] _decl Vertex declaration.
+ *
+ * @returns Number of requested or maximum available vertices.
+ *
+ */
+BGFX_C_API uint32_t bgfx_get_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t * _decl);
+
+/**
+ * Returns number of requested or maximum available instance buffer slots.
+ *
+ * @param[in] _num Number of required instances.
+ * @param[in] _stride Stride per instance.
+ *
+ * @returns Number of requested or maximum available instance buffer slots.
+ *
+ */
+BGFX_C_API uint32_t bgfx_get_avail_instance_data_buffer(uint32_t _num, uint16_t _stride);
+
+/**
+ * Allocate transient index buffer.
+ * @remarks
+ *   Only 16-bit index buffer is supported.
+ *
+ * @param[out] _tib TransientIndexBuffer structure is filled and is valid
+ *  for the duration of frame, and it can be reused for multiple draw
+ *  calls.
+ * @param[in] _num Number of indices to allocate.
+ *
+ */
+BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num);
+
+/**
+ * Allocate transient vertex buffer.
+ *
+ * @param[out] _tvb TransientVertexBuffer structure is filled and is valid
+ *  for the duration of frame, and it can be reused for multiple draw
+ *  calls.
+ * @param[in] _num Number of vertices to allocate.
+ * @param[in] _decl Vertex declaration.
+ *
+ */
+BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_decl_t * _decl);
+
+/**
+ * Check for required space and allocate transient vertex and index
+ * buffers. If both space requirements are satisfied function returns
+ * true.
+ * @remarks
+ *   Only 16-bit index buffer is supported.
+ *
+ * @param[out] _tvb TransientVertexBuffer structure is filled and is valid
+ *  for the duration of frame, and it can be reused for multiple draw
+ *  calls.
+ * @param[in] _decl Number of vertices to allocate.
+ * @param[in] _numVertices Vertex declaration.
+ * @param[out] _tib TransientIndexBuffer structure is filled and is valid
+ *  for the duration of frame, and it can be reused for multiple draw
+ *  calls.
+ * @param[in] _numIndices Number of indices to allocate.
+ *
+ */
+BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t * _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices);
+
+/**
+ * Allocate instance data buffer.
+ *
+ * @param[out] _idb InstanceDataBuffer structure is filled and is valid
+ *  for duration of frame, and it can be reused for multiple draw
+ *  calls.
+ * @param[in] _num Number of instances.
+ * @param[in] _stride Instance stride. Must be multiple of 16.
+ *
+ */
+BGFX_C_API void bgfx_alloc_instance_data_buffer(bgfx_instance_data_buffer_t* _idb, uint32_t _num, uint16_t _stride);
+
+/**
+ * Create draw indirect buffer.
+ *
+ * @param[in] _num Number of indirect calls.
+ *
+ * @returns Indirect buffer handle.
+ *
+ */
+BGFX_C_API bgfx_indirect_buffer_handle_t bgfx_create_indirect_buffer(uint32_t _num);
+
+/**
+ * Destroy draw indirect buffer.
+ *
+ * @param[in] _handle Indirect buffer handle.
+ *
+ */
+BGFX_C_API void bgfx_destroy_indirect_buffer(bgfx_indirect_buffer_handle_t _handle);
+
+/**
+ * Create shader from memory buffer.
+ *
+ * @param[in] _mem Shader binary.
+ *
+ * @returns Shader handle.
+ *
+ */
+BGFX_C_API bgfx_shader_handle_t bgfx_create_shader(const bgfx_memory_t* _mem);
+
+/**
+ * Returns the number of uniforms and uniform handles used inside a shader.
+ * @remarks
+ *   Only non-predefined uniforms are returned.
+ *
+ * @param[in] _handle Shader handle.
+ * @param[out] _uniforms UniformHandle array where data will be stored.
+ * @param[in] _max Maximum capacity of array.
+ *
+ * @returns Number of uniforms used by shader.
+ *
+ */
+BGFX_C_API uint16_t bgfx_get_shader_uniforms(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t* _uniforms, uint16_t _max);
+
+/**
+ * Set shader debug name.
+ *
+ * @param[in] _handle Shader handle.
+ * @param[in] _name Shader name.
+ * @param[in] _len Shader name length (if length is INT32_MAX, it's expected
+ *  that _name is zero terminated string).
+ *
+ */
+BGFX_C_API void bgfx_set_shader_name(bgfx_shader_handle_t _handle, const char* _name, int32_t _len);
+
+/**
+ * Destroy shader.
+ * @remark Once a shader program is created with _handle,
+ *   it is safe to destroy that shader.
+ *
+ * @param[in] _handle Shader handle.
+ *
+ */
+BGFX_C_API void bgfx_destroy_shader(bgfx_shader_handle_t _handle);
+
+/**
+ * Create program with vertex and fragment shaders.
+ *
+ * @param[in] _vsh Vertex shader.
+ * @param[in] _fsh Fragment shader.
+ * @param[in] _destroyShaders If true, shaders will be destroyed when program is destroyed.
+ *
+ * @returns Program handle if vertex shader output and fragment shader
+ *  input are matching, otherwise returns invalid program handle.
+ *
+ */
+BGFX_C_API bgfx_program_handle_t bgfx_create_program(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders);
+
+/**
+ * Create program with compute shader.
+ *
+ * @param[in] _csh Compute shader.
+ * @param[in] _destroyShaders If true, shaders will be destroyed when program is destroyed.
+ *
+ * @returns Program handle.
+ *
+ */
+BGFX_C_API bgfx_program_handle_t bgfx_create_compute_program(bgfx_shader_handle_t _csh, bool _destroyShaders);
+
+/**
+ * Destroy program.
+ *
+ * @param[in] _handle Program handle.
+ *
+ */
+BGFX_C_API void bgfx_destroy_program(bgfx_program_handle_t _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.
+ *
+ */
+BGFX_C_API bool bgfx_is_texture_valid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
+
+/**
+ * Calculate amount of memory required for texture.
+ *
+ * @param[out] _info Resulting texture info structure. See: `TextureInfo`.
+ * @param[in] _width Width.
+ * @param[in] _height Height.
+ * @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.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t * _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format);
+
+/**
+ * Create texture from memory buffer.
+ *
+ * @param[in] _mem DDS, KTX or PVR texture binary data.
+ * @param[in] _flags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+ *  flags. Default texture sampling mode is linear, and wrap mode is repeat.
+ *  - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+ *    mode.
+ *  - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+ *    sampling.
+ * @param[in] _skip Skip top level mips when parsing texture.
+ * @param[out] _info When non-`NULL` is specified it returns parsed texture information.
+ *
+ * @returns Texture handle.
+ *
+ */
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint64_t _flags, uint8_t _skip, bgfx_texture_info_t* _info);
+
+/**
+ * Create 2D texture.
+ *
+ * @param[in] _width Width.
+ * @param[in] _height Height.
+ * @param[in] _hasMips Indicates that texture contains full mip-map chain.
+ * @param[in] _numLayers Number of layers in texture array. Must be 1 if caps
+ *  `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ * @param[in] _flags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+ *  flags. Default texture sampling mode is linear, and wrap mode is repeat.
+ *  - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+ *    mode.
+ *  - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+ *    sampling.
+ * @param[in] _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.
+ *
+ * @returns Texture handle.
+ *
+ */
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
+
+/**
+ * Create texture with size based on backbuffer ratio. Texture will maintain ratio
+ * if back buffer resolution changes.
+ *
+ * @param[in] _ratio Texture size in respect to back-buffer size. See: `BackbufferRatio::Enum`.
+ * @param[in] _hasMips Indicates that texture contains full mip-map chain.
+ * @param[in] _numLayers Number of layers in texture array. Must be 1 if caps
+ *  `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ * @param[in] _flags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+ *  flags. Default texture sampling mode is linear, and wrap mode is repeat.
+ *  - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+ *    mode.
+ *  - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+ *    sampling.
+ *
+ * @returns Texture handle.
+ *
+ */
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d_scaled(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
+
+/**
+ * Create 3D texture.
+ *
+ * @param[in] _width Width.
+ * @param[in] _height Height.
+ * @param[in] _depth Depth.
+ * @param[in] _hasMips Indicates that texture contains full mip-map chain.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ * @param[in] _flags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+ *  flags. Default texture sampling mode is linear, and wrap mode is repeat.
+ *  - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+ *    mode.
+ *  - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+ *    sampling.
+ * @param[in] _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.
+ *
+ * @returns Texture handle.
+ *
+ */
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
+
+/**
+ * Create Cube texture.
+ *
+ * @param[in] _size Cube side size.
+ * @param[in] _hasMips Indicates that texture contains full mip-map chain.
+ * @param[in] _numLayers Number of layers in texture array. Must be 1 if caps
+ *  `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ * @param[in] _flags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+ *  flags. Default texture sampling mode is linear, and wrap mode is repeat.
+ *  - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+ *    mode.
+ *  - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+ *    sampling.
+ * @param[in] _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.
+ *
+ * @returns Texture handle.
+ *
+ */
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
+
+/**
+ * Update 2D texture.
+ *
+ * @param[in] _handle Texture handle.
+ * @param[in] _layer Layer in texture array.
+ * @param[in] _mip Mip level.
+ * @param[in] _x X offset in texture.
+ * @param[in] _y Y offset in texture.
+ * @param[in] _width Width of texture block.
+ * @param[in] _height Height of texture block.
+ * @param[in] _mem Texture update data.
+ * @param[in] _pitch Pitch of input image (bytes). When _pitch is set to
+ *  UINT16_MAX, it will be calculated internally based on _width.
+ *
+ */
+BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
+
+/**
+ * Update 3D texture.
+ *
+ * @param[in] _handle Texture handle.
+ * @param[in] _mip Mip level.
+ * @param[in] _x X offset in texture.
+ * @param[in] _y Y offset in texture.
+ * @param[in] _z Z offset in texture.
+ * @param[in] _width Width of texture block.
+ * @param[in] _height Height of texture block.
+ * @param[in] _depth Depth of texture block.
+ * @param[in] _mem Texture update data.
+ *
+ */
+BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t* _mem);
+
+/**
+ * Update Cube texture.
+ *
+ * @param[in] _handle Texture handle.
+ * @param[in] _layer Layer in texture array.
+ * @param[in] _side Cubemap side `BGFX_CUBE_MAP_<POSITIVE or NEGATIVE>_<X, Y or Z>`,
+ *    where 0 is +X, 1 is -X, 2 is +Y, 3 is -Y, 4 is +Z, and 5 is -Z.
+ *                   +----------+
+ *                   |-z       2|
+ *                   | ^  +y    |
+ *                   | |        |    Unfolded cube:
+ *                   | +---->+x |
+ *        +----------+----------+----------+----------+
+ *        |+y       1|+y       4|+y       0|+y       5|
+ *        | ^  -x    | ^  +z    | ^  +x    | ^  -z    |
+ *        | |        | |        | |        | |        |
+ *        | +---->+z | +---->+x | +---->-z | +---->-x |
+ *        +----------+----------+----------+----------+
+ *                   |+z       3|
+ *                   | ^  -y    |
+ *                   | |        |
+ *                   | +---->+x |
+ *                   +----------+
+ * @param[in] _mip Mip level.
+ * @param[in] _x X offset in texture.
+ * @param[in] _y Y offset in texture.
+ * @param[in] _width Width of texture block.
+ * @param[in] _height Height of texture block.
+ * @param[in] _mem Texture update data.
+ * @param[in] _pitch Pitch of input image (bytes). When _pitch is set to
+ *  UINT16_MAX, it will be calculated internally based on _width.
+ *
+ */
+BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
+
+/**
+ * Read back texture content.
+ * @attention Texture must be created with `BGFX_TEXTURE_READ_BACK` flag.
+ * @attention Availability depends on: `BGFX_CAPS_TEXTURE_READ_BACK`.
+ *
+ * @param[in] _handle Texture handle.
+ * @param[in] _data Destination buffer.
+ * @param[in] _mip Mip level.
+ *
+ * @returns Frame number when the result will be available. See: `bgfx::frame`.
+ *
+ */
+BGFX_C_API uint32_t bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data, uint8_t _mip);
+
+/**
+ * Set texture debug name.
+ *
+ * @param[in] _handle Texture handle.
+ * @param[in] _name Texture name.
+ * @param[in] _len Texture name length (if length is INT32_MAX, it's expected
+ *  that _name is zero terminated string.
+ *
+ */
+BGFX_C_API void bgfx_set_texture_name(bgfx_texture_handle_t _handle, const char* _name, int32_t _len);
+
+/**
+ * Returns texture direct access pointer.
+ * @attention Availability depends on: `BGFX_CAPS_TEXTURE_DIRECT_ACCESS`. This feature
+ *   is available on GPUs that have unified memory architecture (UMA) support.
+ *
+ * @param[in] _handle Texture handle.
+ *
+ * @returns 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.
+ *
+ */
+BGFX_C_API void* bgfx_get_direct_access_ptr(bgfx_texture_handle_t _handle);
+
+/**
+ * Destroy texture.
+ *
+ * @param[in] _handle Texture handle.
+ *
+ */
+BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle);
+
+/**
+ * Create frame buffer (simple).
+ *
+ * @param[in] _width Texture width.
+ * @param[in] _height Texture height.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ * @param[in] _textureFlags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+ *  flags. Default texture sampling mode is linear, and wrap mode is repeat.
+ *  - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+ *    mode.
+ *  - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+ *    sampling.
+ *
+ * @returns Frame buffer handle.
+ *
+ */
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint64_t _textureFlags);
+
+/**
+ * Create frame buffer with size based on backbuffer ratio. Frame buffer will maintain ratio
+ * if back buffer resolution changes.
+ *
+ * @param[in] _ratio Frame buffer size in respect to back-buffer size. See:
+ *  `BackbufferRatio::Enum`.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ * @param[in] _textureFlags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+ *  flags. Default texture sampling mode is linear, and wrap mode is repeat.
+ *  - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+ *    mode.
+ *  - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+ *    sampling.
+ *
+ * @returns Frame buffer handle.
+ *
+ */
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint64_t _textureFlags);
+
+/**
+ * Create MRT frame buffer from texture handles (simple).
+ *
+ * @param[in] _num Number of texture handles.
+ * @param[in] _handles Texture attachments.
+ * @param[in] _destroyTexture If true, textures will be destroyed when
+ *  frame buffer is destroyed.
+ *
+ * @returns Frame buffer handle.
+ *
+ */
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t* _handles, bool _destroyTexture);
+
+/**
+ * Create MRT frame buffer from texture handles with specific layer and
+ * mip level.
+ *
+ * @param[in] _num Number of attachements.
+ * @param[in] _attachment Attachment texture info. See: `bgfx::Attachment`.
+ * @param[in] _destroyTexture If true, textures will be destroyed when
+ *  frame buffer is destroyed.
+ *
+ * @returns Frame buffer handle.
+ *
+ */
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_attachment(uint8_t _num, const bgfx_attachment_t* _attachment, bool _destroyTexture);
+
+/**
+ * Create frame buffer for multiple window rendering.
+ * @remarks
+ *   Frame buffer cannot be used for sampling.
+ * @attention Availability depends on: `BGFX_CAPS_SWAP_CHAIN`.
+ *
+ * @param[in] _nwh OS' target native window handle.
+ * @param[in] _width Window back buffer width.
+ * @param[in] _height Window back buffer height.
+ * @param[in] _format Window back buffer color format.
+ * @param[in] _depthFormat Window back buffer depth format.
+ *
+ * @returns Frame buffer handle.
+ *
+ */
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, bgfx_texture_format_t _depthFormat);
+
+/**
+ * Set frame buffer debug name.
+ *
+ * @param[in] _handle Frame buffer handle.
+ * @param[in] _name Frame buffer name.
+ * @param[in] _len Frame buffer name length (if length is INT32_MAX, it's expected
+ *  that _name is zero terminated string.
+ *
+ */
+BGFX_C_API void bgfx_set_frame_buffer_name(bgfx_frame_buffer_handle_t _handle, const char* _name, int32_t _len);
+
+/**
+ * Obtain texture handle of frame buffer attachment.
+ *
+ * @param[in] _handle Frame buffer handle.
+ * @param[in] _attachment
+ *
+ */
+BGFX_C_API bgfx_texture_handle_t bgfx_get_texture(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment);
+
+/**
+ * Destroy frame buffer.
+ *
+ * @param[in] _handle Frame buffer handle.
+ *
+ */
+BGFX_C_API void bgfx_destroy_frame_buffer(bgfx_frame_buffer_handle_t _handle);
+
+/**
+ * Create shader uniform parameter.
+ * @remarks
+ *   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, in pixels.
+ *      - `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.
+ *
+ * @param[in] _name Uniform name in shader.
+ * @param[in] _type Type of uniform (See: `bgfx::UniformType`).
+ * @param[in] _num Number of elements in array.
+ *
+ * @returns Handle to uniform object.
+ *
+ */
+BGFX_C_API bgfx_uniform_handle_t bgfx_create_uniform(const char* _name, bgfx_uniform_type_t _type, uint16_t _num);
+
+/**
+ * Retrieve uniform info.
+ *
+ * @param[in] _handle Handle to uniform object.
+ * @param[out] _info Uniform info.
+ *
+ */
+BGFX_C_API void bgfx_get_uniform_info(bgfx_uniform_handle_t _handle, bgfx_uniform_info_t * _info);
+
+/**
+ * Destroy shader uniform parameter.
+ *
+ * @param[in] _handle Handle to uniform object.
+ *
+ */
+BGFX_C_API void bgfx_destroy_uniform(bgfx_uniform_handle_t _handle);
+
+/**
+ * Create occlusion query.
+ *
+ */
+BGFX_C_API bgfx_occlusion_query_handle_t bgfx_create_occlusion_query();
+
+/**
+ * Retrieve occlusion query result from previous frame.
+ *
+ * @param[in] _handle Handle to occlusion query object.
+ * @param[out] _result Number of pixels that passed test. This argument
+ *  can be `NULL` if result of occlusion query is not needed.
+ *
+ * @returns Occlusion query result.
+ *
+ */
+BGFX_C_API bgfx_occlusion_query_result_t bgfx_get_result(bgfx_occlusion_query_handle_t _handle, int32_t* _result);
+
+/**
+ * Destroy occlusion query.
+ *
+ * @param[in] _handle Handle to occlusion query object.
+ *
+ */
+BGFX_C_API void bgfx_destroy_occlusion_query(bgfx_occlusion_query_handle_t _handle);
+
+/**
+ * Set palette color value.
+ *
+ * @param[in] _index Index into palette.
+ * @param[in] _rgba RGBA floating point values.
+ *
+ */
+BGFX_C_API void bgfx_set_palette_color(uint8_t _index, const float _rgba[4]);
+
+/**
+ * Set palette color value.
+ *
+ * @param[in] _index Index into palette.
+ * @param[in] _rgba Packed 32-bit RGBA value.
+ *
+ */
+BGFX_C_API void bgfx_set_palette_color_rgba8(uint8_t _index, uint32_t _rgba);
+
+/**
+ * Set view name.
+ * @remarks
+ *   This is debug only feature.
+ *   In graphics debugger view name will appear as:
+ *       "nnnc <view name>"
+ *        ^  ^ ^
+ *        |  +--- compute (C)
+ *        +------ view id
+ *
+ * @param[in] _id View id.
+ * @param[in] _name View name.
+ *
+ */
+BGFX_C_API void bgfx_set_view_name(bgfx_view_id_t _id, const char* _name);
+
+/**
+ * Set view rectangle. Draw primitive outside view will be clipped.
+ *
+ * @param[in] _id View id.
+ * @param[in] _x Position x from the left corner of the window.
+ * @param[in] _y Position y from the top corner of the window.
+ * @param[in] _width Width of view port region.
+ * @param[in] _height Height of view port region.
+ *
+ */
+BGFX_C_API void bgfx_set_view_rect(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
+
+/**
+ * Set view rectangle. Draw primitive outside view will be clipped.
+ *
+ * @param[in] _id View id.
+ * @param[in] _x Position x from the left corner of the window.
+ * @param[in] _y Position y from the top corner of the window.
+ * @param[in] _ratio Width and height will be set in respect to back-buffer size.
+ *  See: `BackbufferRatio::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_set_view_rect_ratio(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, bgfx_backbuffer_ratio_t _ratio);
+
+/**
+ * Set view scissor. Draw primitive outside view will be clipped. When
+ * _x, _y, _width and _height are set to 0, scissor will be disabled.
+ *
+ * @param[in] _id View id.
+ * @param[in] _x Position x from the left corner of the window.
+ * @param[in] _y Position y from the top corner of the window.
+ * @param[in] _width Width of view scissor region.
+ * @param[in] _height Height of view scissor region.
+ *
+ */
+BGFX_C_API void bgfx_set_view_scissor(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
+
+/**
+ * Set view clear flags.
+ *
+ * @param[in] _id View id.
+ * @param[in] _flags Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear
+ *  operation. See: `BGFX_CLEAR_*`.
+ * @param[in] _rgba Color clear value.
+ * @param[in] _depth Depth clear value.
+ * @param[in] _stencil Stencil clear value.
+ *
+ */
+BGFX_C_API void bgfx_set_view_clear(bgfx_view_id_t _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil);
+
+/**
+ * Set view clear flags with different clear color for each
+ * frame buffer texture. Must use `bgfx::setPaletteColor` to setup clear color
+ * palette.
+ *
+ * @param[in] _id View id.
+ * @param[in] _flags Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear
+ *  operation. See: `BGFX_CLEAR_*`.
+ * @param[in] _depth Depth clear value.
+ * @param[in] _stencil Stencil clear value.
+ * @param[in] _c0 Palette index for frame buffer attachment 0.
+ * @param[in] _c1 Palette index for frame buffer attachment 1.
+ * @param[in] _c2 Palette index for frame buffer attachment 2.
+ * @param[in] _c3 Palette index for frame buffer attachment 3.
+ * @param[in] _c4 Palette index for frame buffer attachment 4.
+ * @param[in] _c5 Palette index for frame buffer attachment 5.
+ * @param[in] _c6 Palette index for frame buffer attachment 6.
+ * @param[in] _c7 Palette index for frame buffer attachment 7.
+ *
+ */
+BGFX_C_API void bgfx_set_view_clear_mrt(bgfx_view_id_t _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _c0, uint8_t _c1, uint8_t _c2, uint8_t _c3, uint8_t _c4, uint8_t _c5, uint8_t _c6, uint8_t _c7);
+
+/**
+ * Set view sorting mode.
+ * @remarks
+ *   View mode must be set prior calling `bgfx::submit` for the view.
+ *
+ * @param[in] _id View id.
+ * @param[in] _mode View sort mode. See `ViewMode::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_set_view_mode(bgfx_view_id_t _id, bgfx_view_mode_t _mode);
+
+/**
+ * Set view frame buffer.
+ * @remarks
+ *   Not persistent after `bgfx::reset` call.
+ *
+ * @param[in] _id View id.
+ * @param[in] _handle Frame buffer handle. Passing `BGFX_INVALID_HANDLE` as
+ *  frame buffer handle will draw primitives from this view into
+ *  default back buffer.
+ *
+ */
+BGFX_C_API void bgfx_set_view_frame_buffer(bgfx_view_id_t _id, bgfx_frame_buffer_handle_t _handle);
+
+/**
+ * Set view view and projection matrices, all draw primitives in this
+ * view will use these matrices.
+ *
+ * @param[in] _id View id.
+ * @param[in] _view View matrix.
+ * @param[in] _proj Projection matrix.
+ *
+ */
+BGFX_C_API void bgfx_set_view_transform(bgfx_view_id_t _id, const void* _view, const void* _proj);
+
+/**
+ * Post submit view reordering.
+ *
+ * @param[in] _id First view id.
+ * @param[in] _num Number of views to remap.
+ * @param[in] _order View remap id table. Passing `NULL` will reset view ids
+ *  to default state.
+ *
+ */
+BGFX_C_API void bgfx_set_view_order(bgfx_view_id_t _id, uint16_t _num, const bgfx_view_id_t* _order);
+
+/**
+ * Begin submitting draw calls from thread.
+ *
+ * @param[in] _forThread Explicitly request an encoder for a worker thread.
+ *
+ * @returns Encoder.
+ *
+ */
+BGFX_C_API bgfx_encoder_t* bgfx_encoder_begin(bool _forThread);
+
+/**
+ * End submitting draw calls from thread.
+ *
+ * @param[in] _encoder Encoder.
+ *
+ */
+BGFX_C_API void bgfx_encoder_end(bgfx_encoder_t* _encoder);
+
+/**
+ * Sets a debug marker. This allows you to group graphics calls together for easy browsing in
+ * graphics debugging tools.
+ *
+ * @param[in] _marker Marker string.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_marker(bgfx_encoder_t* _this, const char* _marker);
+
+/**
+ * Set render states for draw primitive.
+ * @remarks
+ *   1. To setup more complex states use:
+ *      `BGFX_STATE_ALPHA_REF(_ref)`,
+ *      `BGFX_STATE_POINT_SIZE(_size)`,
+ *      `BGFX_STATE_BLEND_FUNC(_src, _dst)`,
+ *      `BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA)`,
+ *      `BGFX_STATE_BLEND_EQUATION(_equation)`,
+ *      `BGFX_STATE_BLEND_EQUATION_SEPARATE(_equationRGB, _equationA)`
+ *   2. `BGFX_STATE_BLEND_EQUATION_ADD` is set when no other blend
+ *      equation is specified.
+ *
+ * @param[in] _state State flags. Default state for primitive type is
+ *    triangles. See: `BGFX_STATE_DEFAULT`.
+ *    - `BGFX_STATE_DEPTH_TEST_*` - Depth test function.
+ *    - `BGFX_STATE_BLEND_*` - See remark 1 about BGFX_STATE_BLEND_FUNC.
+ *    - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2.
+ *    - `BGFX_STATE_CULL_*` - Backface culling mode.
+ *    - `BGFX_STATE_WRITE_*` - Enable R, G, B, A or Z write.
+ *    - `BGFX_STATE_MSAA` - Enable hardware multisample antialiasing.
+ *    - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type.
+ * @param[in] _rgba Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and
+ *    `BGFX_STATE_BLEND_INV_FACTOR` blend modes.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_state(bgfx_encoder_t* _this, uint64_t _state, uint32_t _rgba);
+
+/**
+ * Set condition for rendering.
+ *
+ * @param[in] _handle Occlusion query handle.
+ * @param[in] _visible Render if occlusion query is visible.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_condition(bgfx_encoder_t* _this, bgfx_occlusion_query_handle_t _handle, bool _visible);
+
+/**
+ * Set stencil test state.
+ *
+ * @param[in] _fstencil Front stencil state.
+ * @param[in] _bstencil Back stencil state. If back is set to `BGFX_STENCIL_NONE`
+ *  _fstencil is applied to both front and back facing primitives.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_stencil(bgfx_encoder_t* _this, uint32_t _fstencil, uint32_t _bstencil);
+
+/**
+ * Set scissor for draw primitive.
+ * @remark
+ *   To scissor for all primitives in view see `bgfx::setViewScissor`.
+ *
+ * @param[in] _x Position x from the left corner of the window.
+ * @param[in] _y Position y from the top corner of the window.
+ * @param[in] _width Width of view scissor region.
+ * @param[in] _height Height of view scissor region.
+ *
+ * @returns Scissor cache index.
+ *
+ */
+BGFX_C_API uint16_t bgfx_encoder_set_scissor(bgfx_encoder_t* _this, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
+
+/**
+ * Set scissor from cache for draw primitive.
+ * @remark
+ *   To scissor for all primitives in view see `bgfx::setViewScissor`.
+ *
+ * @param[in] _cache Index in scissor cache.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_scissor_cached(bgfx_encoder_t* _this, uint16_t _cache);
+
+/**
+ * Set model matrix for draw primitive. If it is not called,
+ * the model will be rendered with an identity model matrix.
+ *
+ * @param[in] _mtx Pointer to first matrix in array.
+ * @param[in] _num Number of matrices in array.
+ *
+ * @returns Index into matrix cache in case the same model matrix has
+ *  to be used for other draw primitive call.
+ *
+ */
+BGFX_C_API uint32_t bgfx_encoder_set_transform(bgfx_encoder_t* _this, const void* _mtx, uint16_t _num);
+
+/**
+ *  Set model matrix from matrix cache for draw primitive.
+ *
+ * @param[in] _cache Index in matrix cache.
+ * @param[in] _num Number of matrices from cache.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_transform_cached(bgfx_encoder_t* _this, uint32_t _cache, uint16_t _num);
+
+/**
+ * Reserve matrices in internal matrix cache.
+ * @attention Pointer returned can be modifed until `bgfx::frame` is called.
+ *
+ * @param[out] _transform Pointer to `Transform` structure.
+ * @param[in] _num Number of matrices.
+ *
+ * @returns Index in matrix cache.
+ *
+ */
+BGFX_C_API uint32_t bgfx_encoder_alloc_transform(bgfx_encoder_t* _this, bgfx_transform_t* _transform, uint16_t _num);
+
+/**
+ * Set shader uniform parameter for draw primitive.
+ *
+ * @param[in] _handle Uniform.
+ * @param[in] _value Pointer to uniform data.
+ * @param[in] _num Number of elements. Passing `UINT16_MAX` will
+ *  use the _num passed on uniform creation.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_uniform(bgfx_encoder_t* _this, bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num);
+
+/**
+ * Set index buffer for draw primitive.
+ *
+ * @param[in] _handle Index buffer.
+ * @param[in] _firstIndex First index to render.
+ * @param[in] _numIndices Number of indices to render.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_index_buffer(bgfx_encoder_t* _this, bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
+
+/**
+ * Set index buffer for draw primitive.
+ *
+ * @param[in] _handle Dynamic index buffer.
+ * @param[in] _firstIndex First index to render.
+ * @param[in] _numIndices Number of indices to render.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_dynamic_index_buffer(bgfx_encoder_t* _this, bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
+
+/**
+ * Set index buffer for draw primitive.
+ *
+ * @param[in] _tib Transient index buffer.
+ * @param[in] _firstIndex First index to render.
+ * @param[in] _numIndices Number of indices to render.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_transient_index_buffer(bgfx_encoder_t* _this, const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices);
+
+/**
+ * Set vertex buffer for draw primitive.
+ *
+ * @param[in] _stream Vertex stream.
+ * @param[in] _handle Vertex buffer.
+ * @param[in] _startVertex First vertex to render.
+ * @param[in] _numVertices Number of vertices to render.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
+
+/**
+ * Set vertex buffer for draw primitive.
+ *
+ * @param[in] _stream Vertex stream.
+ * @param[in] _handle Dynamic vertex buffer.
+ * @param[in] _startVertex First vertex to render.
+ * @param[in] _numVertices Number of vertices to render.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_dynamic_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
+
+/**
+ * Set vertex buffer for draw primitive.
+ *
+ * @param[in] _stream Vertex stream.
+ * @param[in] _tvb Transient vertex buffer.
+ * @param[in] _startVertex First vertex to render.
+ * @param[in] _numVertices Number of vertices to render.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices);
+
+/**
+ * Set number of vertices for auto generated vertices use in conjuction
+ * with gl_VertexID.
+ * @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
+ *
+ * @param[in] _numVertices Number of vertices.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_vertex_count(bgfx_encoder_t* _this, uint32_t _numVertices);
+
+/**
+ * Set instance data buffer for draw primitive.
+ *
+ * @param[in] _idb Transient instance data buffer.
+ * @param[in] _start First instance data.
+ * @param[in] _num Number of data instances.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_instance_data_buffer(bgfx_encoder_t* _this, const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num);
+
+/**
+ * Set instance data buffer for draw primitive.
+ *
+ * @param[in] _handle Vertex buffer.
+ * @param[in] _startVertex First instance data.
+ * @param[in] _num Number of data instances.
+ *  Set instance data buffer for draw primitive.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_instance_data_from_vertex_buffer(bgfx_encoder_t* _this, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
+
+/**
+ * Set instance data buffer for draw primitive.
+ *
+ * @param[in] _handle Dynamic vertex buffer.
+ * @param[in] _startVertex First instance data.
+ * @param[in] _num Number of data instances.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_instance_data_from_dynamic_vertex_buffer(bgfx_encoder_t* _this, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
+
+/**
+ * Set number of instances for auto generated instances use in conjuction
+ * with gl_InstanceID.
+ * @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
+ *
+ * @param[in] _numInstances
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_instance_count(bgfx_encoder_t* _this, uint32_t _numInstances);
+
+/**
+ * Set texture stage for draw primitive.
+ *
+ * @param[in] _stage Texture unit.
+ * @param[in] _sampler Program sampler.
+ * @param[in] _handle Texture handle.
+ * @param[in] _flags Texture sampling mode. Default value UINT32_MAX uses
+ *    texture sampling settings from the texture.
+ *    - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+ *      mode.
+ *    - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+ *      sampling.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_texture(bgfx_encoder_t* _this, uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags);
+
+/**
+ * Submit an empty primitive for rendering. Uniforms and draw state
+ * will be applied but no geometry will be submitted.
+ * @remark
+ *   These empty draw calls will sort before ordinary draw calls.
+ *
+ * @param[in] _id View id.
+ *
+ */
+BGFX_C_API void bgfx_encoder_touch(bgfx_encoder_t* _this, bgfx_view_id_t _id);
+
+/**
+ * Submit primitive for rendering.
+ *
+ * @param[in] _id View id.
+ * @param[in] _program Program.
+ * @param[in] _depth Depth for sorting.
+ * @param[in] _preserveState Preserve internal draw state for next draw call submit.
+ *
+ */
+BGFX_C_API void bgfx_encoder_submit(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _depth, bool _preserveState);
+
+/**
+ * Submit primitive with occlusion query for rendering.
+ *
+ * @param[in] _id View id.
+ * @param[in] _program Program.
+ * @param[in] _occlusionQuery Occlusion query.
+ * @param[in] _depth Depth for sorting.
+ * @param[in] _preserveState Preserve internal draw state for next draw call submit.
+ *
+ */
+BGFX_C_API void bgfx_encoder_submit_occlusion_query(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState);
+
+/**
+ * Submit primitive for rendering with index and instance data info from
+ * indirect buffer.
+ *
+ * @param[in] _id View id.
+ * @param[in] _program Program.
+ * @param[in] _indirectHandle Indirect buffer.
+ * @param[in] _start First element in indirect buffer.
+ * @param[in] _num Number of dispatches.
+ * @param[in] _depth Depth for sorting.
+ * @param[in] _preserveState Preserve internal draw state for next draw call submit.
+ *
+ */
+BGFX_C_API void bgfx_encoder_submit_indirect(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState);
+
+/**
+ * Set compute index buffer.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Index buffer handle.
+ * @param[in] _access Buffer access. See `Access::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_compute_index_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access);
+
+/**
+ * Set compute vertex buffer.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Vertex buffer handle.
+ * @param[in] _access Buffer access. See `Access::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_compute_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access);
+
+/**
+ * Set compute dynamic index buffer.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Dynamic index buffer handle.
+ * @param[in] _access Buffer access. See `Access::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_compute_dynamic_index_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access);
+
+/**
+ * Set compute dynamic vertex buffer.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Dynamic vertex buffer handle.
+ * @param[in] _access Buffer access. See `Access::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_compute_dynamic_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access);
+
+/**
+ * Set compute indirect buffer.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Indirect buffer handle.
+ * @param[in] _access Buffer access. See `Access::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_compute_indirect_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access);
+
+/**
+ * Set compute image from texture.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Texture handle.
+ * @param[in] _mip Mip level.
+ * @param[in] _access Image access. See `Access::Enum`.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_encoder_set_image(bgfx_encoder_t* _this, uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
+
+/**
+ * Dispatch compute.
+ *
+ * @param[in] _id View id.
+ * @param[in] _program Compute program.
+ * @param[in] _numX Number of groups X.
+ * @param[in] _numY Number of groups Y.
+ * @param[in] _numZ Number of groups Z.
+ *
+ */
+BGFX_C_API void bgfx_encoder_dispatch(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
+
+/**
+ * Dispatch compute indirect.
+ *
+ * @param[in] _id View id.
+ * @param[in] _program Compute program.
+ * @param[in] _indirectHandle Indirect buffer.
+ * @param[in] _start First element in indirect buffer.
+ * @param[in] _num Number of dispatches.
+ *
+ */
+BGFX_C_API void bgfx_encoder_dispatch_indirect(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
+
+/**
+ * Discard all previously set state for draw or compute call.
+ *
+ */
+BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_t* _this);
+
+/**
+ * Blit 2D texture region between two 2D textures.
+ * @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag.
+ * @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`.
+ *
+ * @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 represents destination texture cube face. For 3D texture this argument
+ *  represents destination texture Z position.
+ * @param[in] _src Source texture handle.
+ * @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 represents source texture cube face. For 3D texture this argument
+ *  represents 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 represents depth of region, otherwise it's
+ *  unused.
+ *
+ */
+BGFX_C_API void bgfx_encoder_blit(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
+
+/**
+ * Request screen shot of window back buffer.
+ * @remarks
+ *   `bgfx::CallbackI::screenShot` must be implemented.
+ * @attention Frame buffer handle must be created with OS' target native window handle.
+ *
+ * @param[in] _handle Frame buffer handle. If handle is `BGFX_INVALID_HANDLE` request will be
+ *  made for main window back buffer.
+ * @param[in] _filePath Will be passed to `bgfx::CallbackI::screenShot` callback.
+ *
+ */
+BGFX_C_API void bgfx_request_screen_shot(bgfx_frame_buffer_handle_t _handle, const char* _filePath);
+
+/**
+ * Render frame.
+ * @attention `bgfx::renderFrame` is blocking call. It waits for
+ *   `bgfx::frame` to be called from API thread to process frame.
+ *   If timeout value is passed call will timeout and return even
+ *   if `bgfx::frame` is not called.
+ * @warning This call should be only used on platforms that don't
+ *   allow creating separate rendering thread. If it is called before
+ *   to bgfx::init, render thread won't be created by bgfx::init call.
+ *
+ * @param[in] _msecs Timeout in milliseconds.
+ *
+ * @returns Current renderer context state. See: `bgfx::RenderFrame`.
+ *
+ */
+BGFX_C_API bgfx_render_frame_t bgfx_render_frame(int32_t _msecs);
+
+/**
+ * Set platform data.
+ * @warning Must be called before `bgfx::init`.
+ *
+ * @param[in] _data Platform data.
+ *
+ */
+BGFX_C_API void bgfx_set_platform_data(const bgfx_platform_data_t * _data);
+
+/**
+ * Get internal data for interop.
+ * @attention It's expected you understand some bgfx internals before you
+ *   use this call.
+ * @warning Must be called only on render thread.
+ *
+ */
+BGFX_C_API const bgfx_internal_data_t* bgfx_get_internal_data();
+
+/**
+ * Override internal texture with externally created texture. Previously
+ * created internal texture will released.
+ * @attention It's expected you understand some bgfx internals before you
+ *   use this call.
+ * @warning Must be called only on render thread.
+ *
+ * @param[in] _handle Texture handle.
+ * @param[in] _ptr Native API pointer to texture.
+ *
+ * @returns Native API pointer to texture. If result is 0, texture is not created
+ *  yet from the main thread.
+ *
+ */
+BGFX_C_API uintptr_t bgfx_override_internal_texture_ptr(bgfx_texture_handle_t _handle, uintptr_t _ptr);
+
+/**
+ * Override internal texture by creating new texture. Previously created
+ * internal texture will released.
+ * @attention It's expected you understand some bgfx internals before you
+ *   use this call.
+ * @param[in] _handle Texture handle.
+ * @param[in] _width Width.
+ * @param[in] _height Height.
+ * @param[in] _numMips Number of mip-maps.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ * @param[in] _flags Default texture sampling mode is linear, and wrap mode
+ *   is repeat.
+ *   - `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.
+ * @returns Native API pointer to texture. If result is 0, texture is not created yet from the
+ *   main thread.
+ * @warning Must be called only on render thread.
+ *
+ * @param[in] _handle Texture handle.
+ * @param[in] _width Width.
+ * @param[in] _height Height.
+ * @param[in] _numMips Number of mip-maps.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ * @param[in] _flags Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+ *  flags. Default texture sampling mode is linear, and wrap mode is repeat.
+ *  - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+ *    mode.
+ *  - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+ *    sampling.
+ *
+ * @returns Native API pointer to texture. If result is 0, texture is not created
+ *  yet from the main thread.
+ *
+ */
+BGFX_C_API uintptr_t bgfx_override_internal_texture(bgfx_texture_handle_t _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint64_t _flags);
+
+/**
+ * Sets a debug marker. This allows you to group graphics calls together for easy browsing in
+ * graphics debugging tools.
+ *
+ * @param[in] _marker Marker string.
+ *
+ */
+BGFX_C_API void bgfx_set_marker(const char* _marker);
+
+/**
+ * Set render states for draw primitive.
+ * @remarks
+ *   1. To setup more complex states use:
+ *      `BGFX_STATE_ALPHA_REF(_ref)`,
+ *      `BGFX_STATE_POINT_SIZE(_size)`,
+ *      `BGFX_STATE_BLEND_FUNC(_src, _dst)`,
+ *      `BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA)`,
+ *      `BGFX_STATE_BLEND_EQUATION(_equation)`,
+ *      `BGFX_STATE_BLEND_EQUATION_SEPARATE(_equationRGB, _equationA)`
+ *   2. `BGFX_STATE_BLEND_EQUATION_ADD` is set when no other blend
+ *      equation is specified.
+ *
+ * @param[in] _state State flags. Default state for primitive type is
+ *    triangles. See: `BGFX_STATE_DEFAULT`.
+ *    - `BGFX_STATE_DEPTH_TEST_*` - Depth test function.
+ *    - `BGFX_STATE_BLEND_*` - See remark 1 about BGFX_STATE_BLEND_FUNC.
+ *    - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2.
+ *    - `BGFX_STATE_CULL_*` - Backface culling mode.
+ *    - `BGFX_STATE_WRITE_*` - Enable R, G, B, A or Z write.
+ *    - `BGFX_STATE_MSAA` - Enable hardware multisample antialiasing.
+ *    - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type.
+ * @param[in] _rgba Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and
+ *    `BGFX_STATE_BLEND_INV_FACTOR` blend modes.
+ *
+ */
+BGFX_C_API void bgfx_set_state(uint64_t _state, uint32_t _rgba);
+
+/**
+ * Set condition for rendering.
+ *
+ * @param[in] _handle Occlusion query handle.
+ * @param[in] _visible Render if occlusion query is visible.
+ *
+ */
+BGFX_C_API void bgfx_set_condition(bgfx_occlusion_query_handle_t _handle, bool _visible);
+
+/**
+ * Set stencil test state.
+ *
+ * @param[in] _fstencil Front stencil state.
+ * @param[in] _bstencil Back stencil state. If back is set to `BGFX_STENCIL_NONE`
+ *  _fstencil is applied to both front and back facing primitives.
+ *
+ */
+BGFX_C_API void bgfx_set_stencil(uint32_t _fstencil, uint32_t _bstencil);
+
+/**
+ * Set scissor for draw primitive.
+ * @remark
+ *   To scissor for all primitives in view see `bgfx::setViewScissor`.
+ *
+ * @param[in] _x Position x from the left corner of the window.
+ * @param[in] _y Position y from the top corner of the window.
+ * @param[in] _width Width of view scissor region.
+ * @param[in] _height Height of view scissor region.
+ *
+ * @returns Scissor cache index.
+ *
+ */
+BGFX_C_API uint16_t bgfx_set_scissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
+
+/**
+ * Set scissor from cache for draw primitive.
+ * @remark
+ *   To scissor for all primitives in view see `bgfx::setViewScissor`.
+ *
+ * @param[in] _cache Index in scissor cache.
+ *
+ */
+BGFX_C_API void bgfx_set_scissor_cached(uint16_t _cache);
+
+/**
+ * Set model matrix for draw primitive. If it is not called,
+ * the model will be rendered with an identity model matrix.
+ *
+ * @param[in] _mtx Pointer to first matrix in array.
+ * @param[in] _num Number of matrices in array.
+ *
+ * @returns Index into matrix cache in case the same model matrix has
+ *  to be used for other draw primitive call.
+ *
+ */
+BGFX_C_API uint32_t bgfx_set_transform(const void* _mtx, uint16_t _num);
+
+/**
+ *  Set model matrix from matrix cache for draw primitive.
+ *
+ * @param[in] _cache Index in matrix cache.
+ * @param[in] _num Number of matrices from cache.
+ *
+ */
+BGFX_C_API void bgfx_set_transform_cached(uint32_t _cache, uint16_t _num);
+
+/**
+ * Reserve matrices in internal matrix cache.
+ * @attention Pointer returned can be modifed until `bgfx::frame` is called.
+ *
+ * @param[out] _transform Pointer to `Transform` structure.
+ * @param[in] _num Number of matrices.
+ *
+ * @returns Index in matrix cache.
+ *
+ */
+BGFX_C_API uint32_t bgfx_alloc_transform(bgfx_transform_t* _transform, uint16_t _num);
+
+/**
+ * Set shader uniform parameter for draw primitive.
+ *
+ * @param[in] _handle Uniform.
+ * @param[in] _value Pointer to uniform data.
+ * @param[in] _num Number of elements. Passing `UINT16_MAX` will
+ *  use the _num passed on uniform creation.
+ *
+ */
+BGFX_C_API void bgfx_set_uniform(bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num);
+
+/**
+ * Set index buffer for draw primitive.
+ *
+ * @param[in] _handle Index buffer.
+ * @param[in] _firstIndex First index to render.
+ * @param[in] _numIndices Number of indices to render.
+ *
+ */
+BGFX_C_API void bgfx_set_index_buffer(bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
+
+/**
+ * Set index buffer for draw primitive.
+ *
+ * @param[in] _handle Dynamic index buffer.
+ * @param[in] _firstIndex First index to render.
+ * @param[in] _numIndices Number of indices to render.
+ *
+ */
+BGFX_C_API void bgfx_set_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
+
+/**
+ * Set index buffer for draw primitive.
+ *
+ * @param[in] _tib Transient index buffer.
+ * @param[in] _firstIndex First index to render.
+ * @param[in] _numIndices Number of indices to render.
+ *
+ */
+BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices);
+
+/**
+ * Set vertex buffer for draw primitive.
+ *
+ * @param[in] _stream Vertex stream.
+ * @param[in] _handle Vertex buffer.
+ * @param[in] _startVertex First vertex to render.
+ * @param[in] _numVertices Number of vertices to render.
+ *
+ */
+BGFX_C_API void bgfx_set_vertex_buffer(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
+
+/**
+ * Set vertex buffer for draw primitive.
+ *
+ * @param[in] _stream Vertex stream.
+ * @param[in] _handle Dynamic vertex buffer.
+ * @param[in] _startVertex First vertex to render.
+ * @param[in] _numVertices Number of vertices to render.
+ *
+ */
+BGFX_C_API void bgfx_set_dynamic_vertex_buffer(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
+
+/**
+ * Set vertex buffer for draw primitive.
+ *
+ * @param[in] _stream Vertex stream.
+ * @param[in] _tvb Transient vertex buffer.
+ * @param[in] _startVertex First vertex to render.
+ * @param[in] _numVertices Number of vertices to render.
+ *
+ */
+BGFX_C_API void bgfx_set_transient_vertex_buffer(uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices);
+
+/**
+ * Set number of vertices for auto generated vertices use in conjuction
+ * with gl_VertexID.
+ * @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
+ *
+ * @param[in] _numVertices Number of vertices.
+ *
+ */
+BGFX_C_API void bgfx_set_vertex_count(uint32_t _numVertices);
+
+/**
+ * Set instance data buffer for draw primitive.
+ *
+ * @param[in] _idb Transient instance data buffer.
+ * @param[in] _start First instance data.
+ * @param[in] _num Number of data instances.
+ *
+ */
+BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num);
+
+/**
+ * Set instance data buffer for draw primitive.
+ *
+ * @param[in] _handle Vertex buffer.
+ * @param[in] _startVertex First instance data.
+ * @param[in] _num Number of data instances.
+ *  Set instance data buffer for draw primitive.
+ *
+ */
+BGFX_C_API void bgfx_set_instance_data_from_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
+
+/**
+ * Set instance data buffer for draw primitive.
+ *
+ * @param[in] _handle Dynamic vertex buffer.
+ * @param[in] _startVertex First instance data.
+ * @param[in] _num Number of data instances.
+ *
+ */
+BGFX_C_API void bgfx_set_instance_data_from_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
+
+/**
+ * Set number of instances for auto generated instances use in conjuction
+ * with gl_InstanceID.
+ * @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
+ *
+ * @param[in] _numInstances
+ *
+ */
+BGFX_C_API void bgfx_set_instance_count(uint32_t _numInstances);
+
+/**
+ * Set texture stage for draw primitive.
+ *
+ * @param[in] _stage Texture unit.
+ * @param[in] _sampler Program sampler.
+ * @param[in] _handle Texture handle.
+ * @param[in] _flags Texture sampling mode. Default value UINT32_MAX uses
+ *    texture sampling settings from the texture.
+ *    - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+ *      mode.
+ *    - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+ *      sampling.
+ *
+ */
+BGFX_C_API void bgfx_set_texture(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags);
+
+/**
+ * Submit an empty primitive for rendering. Uniforms and draw state
+ * will be applied but no geometry will be submitted.
+ * @remark
+ *   These empty draw calls will sort before ordinary draw calls.
+ *
+ * @param[in] _id View id.
+ *
+ */
+BGFX_C_API void bgfx_touch(bgfx_view_id_t _id);
+
+/**
+ * Submit primitive for rendering.
+ *
+ * @param[in] _id View id.
+ * @param[in] _program Program.
+ * @param[in] _depth Depth for sorting.
+ * @param[in] _preserveState Preserve internal draw state for next draw call submit.
+ *
+ */
+BGFX_C_API void bgfx_submit(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _depth, bool _preserveState);
+
+/**
+ * Submit primitive with occlusion query for rendering.
+ *
+ * @param[in] _id View id.
+ * @param[in] _program Program.
+ * @param[in] _occlusionQuery Occlusion query.
+ * @param[in] _depth Depth for sorting.
+ * @param[in] _preserveState Preserve internal draw state for next draw call submit.
+ *
+ */
+BGFX_C_API void bgfx_submit_occlusion_query(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState);
+
+/**
+ * Submit primitive for rendering with index and instance data info from
+ * indirect buffer.
+ *
+ * @param[in] _id View id.
+ * @param[in] _program Program.
+ * @param[in] _indirectHandle Indirect buffer.
+ * @param[in] _start First element in indirect buffer.
+ * @param[in] _num Number of dispatches.
+ * @param[in] _depth Depth for sorting.
+ * @param[in] _preserveState Preserve internal draw state for next draw call submit.
+ *
+ */
+BGFX_C_API void bgfx_submit_indirect(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState);
+
+/**
+ * Set compute index buffer.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Index buffer handle.
+ * @param[in] _access Buffer access. See `Access::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_set_compute_index_buffer(uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access);
+
+/**
+ * Set compute vertex buffer.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Vertex buffer handle.
+ * @param[in] _access Buffer access. See `Access::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_set_compute_vertex_buffer(uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access);
+
+/**
+ * Set compute dynamic index buffer.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Dynamic index buffer handle.
+ * @param[in] _access Buffer access. See `Access::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_set_compute_dynamic_index_buffer(uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access);
+
+/**
+ * Set compute dynamic vertex buffer.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Dynamic vertex buffer handle.
+ * @param[in] _access Buffer access. See `Access::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_set_compute_dynamic_vertex_buffer(uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access);
+
+/**
+ * Set compute indirect buffer.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Indirect buffer handle.
+ * @param[in] _access Buffer access. See `Access::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_set_compute_indirect_buffer(uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access);
+
+/**
+ * Set compute image from texture.
+ *
+ * @param[in] _stage Compute stage.
+ * @param[in] _handle Texture handle.
+ * @param[in] _mip Mip level.
+ * @param[in] _access Image access. See `Access::Enum`.
+ * @param[in] _format Texture format. See: `TextureFormat::Enum`.
+ *
+ */
+BGFX_C_API void bgfx_set_image(uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
+
+/**
+ * Dispatch compute.
+ *
+ * @param[in] _id View id.
+ * @param[in] _program Compute program.
+ * @param[in] _numX Number of groups X.
+ * @param[in] _numY Number of groups Y.
+ * @param[in] _numZ Number of groups Z.
+ *
+ */
+BGFX_C_API void bgfx_dispatch(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
+
+/**
+ * Dispatch compute indirect.
+ *
+ * @param[in] _id View id.
+ * @param[in] _program Compute program.
+ * @param[in] _indirectHandle Indirect buffer.
+ * @param[in] _start First element in indirect buffer.
+ * @param[in] _num Number of dispatches.
+ *
+ */
+BGFX_C_API void bgfx_dispatch_indirect(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
+
+/**
+ * Discard all previously set state for draw or compute call.
+ *
+ */
+BGFX_C_API void bgfx_discard();
+
+/**
+ * Blit 2D texture region between two 2D textures.
+ * @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag.
+ * @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`.
+ *
+ * @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 represents destination texture cube face. For 3D texture this argument
+ *  represents destination texture Z position.
+ * @param[in] _src Source texture handle.
+ * @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 represents source texture cube face. For 3D texture this argument
+ *  represents 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 represents depth of region, otherwise it's
+ *  unused.
+ *
+ */
+BGFX_C_API void bgfx_blit(bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
+
+struct bgfx_interface_vtbl
+{
+	void (*attachment_init)(bgfx_attachment_t* _this, bgfx_texture_handle_t _handle, bgfx_access_t _access, uint16_t _layer, uint16_t _mip, uint8_t _resolve);
+	void (*vertex_decl_begin)(bgfx_vertex_decl_t* _this, bgfx_renderer_type_t _rendererType);
+	void (*vertex_decl_add)(bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib, uint8_t _num, bgfx_attrib_type_t _type, bool _normalized, bool _asInt);
+	void (*vertex_decl_decode)(const bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib, uint8_t * _num, bgfx_attrib_type_t * _type, bool * _normalized, bool * _asInt);
+	bool (*vertex_decl_has)(const bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib);
+	void (*vertex_decl_skip)(bgfx_vertex_decl_t* _this, uint8_t _num);
+	void (*vertex_decl_end)(bgfx_vertex_decl_t* _this);
+	void (*vertex_pack)(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, void* _data, uint32_t _index);
+	void (*vertex_unpack)(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, const void* _data, uint32_t _index);
+	void (*vertex_convert)(const bgfx_vertex_decl_t * _dstDecl, void* _dstData, const bgfx_vertex_decl_t * _srcDecl, const void* _srcData, uint32_t _num);
+	uint16_t (*weld_vertices)(uint16_t* _output, const bgfx_vertex_decl_t * _decl, const void* _data, uint16_t _num, float _epsilon);
+	uint32_t (*topology_convert)(bgfx_topology_convert_t _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32);
+	void (*topology_sort_tri_list)(bgfx_topology_sort_t _sort, void* _dst, uint32_t _dstSize, const float _dir[3], const float _pos[3], const void* _vertices, uint32_t _stride, const void* _indices, uint32_t _numIndices, bool _index32);
+	uint8_t (*get_supported_renderers)(uint8_t _max, bgfx_renderer_type_t* _enum);
+	const char* (*get_renderer_name)(bgfx_renderer_type_t _type);
+	void (*init_ctor)(bgfx_init_t* _init);
+	bool (*init)(const bgfx_init_t * _init);
+	void (*shutdown)();
+	void (*reset)(uint32_t _width, uint32_t _height, uint32_t _flags, bgfx_texture_format_t _format);
+	uint32_t (*frame)(bool _capture);
+	bgfx_renderer_type_t (*get_renderer_type)();
+	const bgfx_caps_t* (*get_caps)();
+	const bgfx_stats_t* (*get_stats)();
+	const bgfx_memory_t* (*alloc)(uint32_t _size);
+	const bgfx_memory_t* (*copy)(const void* _data, uint32_t _size);
+	const bgfx_memory_t* (*make_ref)(const void* _data, uint32_t _size);
+	const bgfx_memory_t* (*make_ref_release)(const void* _data, uint32_t _size, bgfx_release_fn_t _releaseFn, void* _userData);
+	void (*set_debug)(uint32_t _debug);
+	void (*dbg_text_clear)(uint8_t _attr, bool _small);
+	void (*dbg_text_printf)(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ... );
+	void (*dbg_text_vprintf)(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, va_list _argList);
+	void (*dbg_text_image)(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void* _data, uint16_t _pitch);
+	bgfx_index_buffer_handle_t (*create_index_buffer)(const bgfx_memory_t* _mem, uint16_t _flags);
+	void (*set_index_buffer_name)(bgfx_index_buffer_handle_t _handle, const char* _name, int32_t _len);
+	void (*destroy_index_buffer)(bgfx_index_buffer_handle_t _handle);
+	bgfx_vertex_buffer_handle_t (*create_vertex_buffer)(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t * _decl, uint16_t _flags);
+	void (*set_vertex_buffer_name)(bgfx_vertex_buffer_handle_t _handle, const char* _name, int32_t _len);
+	void (*destroy_vertex_buffer)(bgfx_vertex_buffer_handle_t _handle);
+	bgfx_dynamic_index_buffer_handle_t (*create_dynamic_index_buffer)(uint32_t _num, uint16_t _flags);
+	bgfx_dynamic_index_buffer_handle_t (*create_dynamic_index_buffer_mem)(const bgfx_memory_t* _mem, uint16_t _flags);
+	void (*update_dynamic_index_buffer)(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _startIndex, const bgfx_memory_t* _mem);
+	void (*destroy_dynamic_index_buffer)(bgfx_dynamic_index_buffer_handle_t _handle);
+	bgfx_dynamic_vertex_buffer_handle_t (*create_dynamic_vertex_buffer)(uint32_t _num, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
+	bgfx_dynamic_vertex_buffer_handle_t (*create_dynamic_vertex_buffer_mem)(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags);
+	void (*update_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t* _mem);
+	void (*destroy_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle);
+	uint32_t (*get_avail_transient_index_buffer)(uint32_t _num);
+	uint32_t (*get_avail_transient_vertex_buffer)(uint32_t _num, const bgfx_vertex_decl_t * _decl);
+	uint32_t (*get_avail_instance_data_buffer)(uint32_t _num, uint16_t _stride);
+	void (*alloc_transient_index_buffer)(bgfx_transient_index_buffer_t* _tib, uint32_t _num);
+	void (*alloc_transient_vertex_buffer)(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_decl_t * _decl);
+	bool (*alloc_transient_buffers)(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t * _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices);
+	void (*alloc_instance_data_buffer)(bgfx_instance_data_buffer_t* _idb, uint32_t _num, uint16_t _stride);
+	bgfx_indirect_buffer_handle_t (*create_indirect_buffer)(uint32_t _num);
+	void (*destroy_indirect_buffer)(bgfx_indirect_buffer_handle_t _handle);
+	bgfx_shader_handle_t (*create_shader)(const bgfx_memory_t* _mem);
+	uint16_t (*get_shader_uniforms)(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t* _uniforms, uint16_t _max);
+	void (*set_shader_name)(bgfx_shader_handle_t _handle, const char* _name, int32_t _len);
+	void (*destroy_shader)(bgfx_shader_handle_t _handle);
+	bgfx_program_handle_t (*create_program)(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders);
+	bgfx_program_handle_t (*create_compute_program)(bgfx_shader_handle_t _csh, bool _destroyShaders);
+	void (*destroy_program)(bgfx_program_handle_t _handle);
+	bool (*is_texture_valid)(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
+	void (*calc_texture_size)(bgfx_texture_info_t * _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format);
+	bgfx_texture_handle_t (*create_texture)(const bgfx_memory_t* _mem, uint64_t _flags, uint8_t _skip, bgfx_texture_info_t* _info);
+	bgfx_texture_handle_t (*create_texture_2d)(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
+	bgfx_texture_handle_t (*create_texture_2d_scaled)(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
+	bgfx_texture_handle_t (*create_texture_3d)(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
+	bgfx_texture_handle_t (*create_texture_cube)(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem);
+	void (*update_texture_2d)(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
+	void (*update_texture_3d)(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t* _mem);
+	void (*update_texture_cube)(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
+	uint32_t (*read_texture)(bgfx_texture_handle_t _handle, void* _data, uint8_t _mip);
+	void (*set_texture_name)(bgfx_texture_handle_t _handle, const char* _name, int32_t _len);
+	void* (*get_direct_access_ptr)(bgfx_texture_handle_t _handle);
+	void (*destroy_texture)(bgfx_texture_handle_t _handle);
+	bgfx_frame_buffer_handle_t (*create_frame_buffer)(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint64_t _textureFlags);
+	bgfx_frame_buffer_handle_t (*create_frame_buffer_scaled)(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint64_t _textureFlags);
+	bgfx_frame_buffer_handle_t (*create_frame_buffer_from_handles)(uint8_t _num, const bgfx_texture_handle_t* _handles, bool _destroyTexture);
+	bgfx_frame_buffer_handle_t (*create_frame_buffer_from_attachment)(uint8_t _num, const bgfx_attachment_t* _attachment, bool _destroyTexture);
+	bgfx_frame_buffer_handle_t (*create_frame_buffer_from_nwh)(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, bgfx_texture_format_t _depthFormat);
+	void (*set_frame_buffer_name)(bgfx_frame_buffer_handle_t _handle, const char* _name, int32_t _len);
+	bgfx_texture_handle_t (*get_texture)(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment);
+	void (*destroy_frame_buffer)(bgfx_frame_buffer_handle_t _handle);
+	bgfx_uniform_handle_t (*create_uniform)(const char* _name, bgfx_uniform_type_t _type, uint16_t _num);
+	void (*get_uniform_info)(bgfx_uniform_handle_t _handle, bgfx_uniform_info_t * _info);
+	void (*destroy_uniform)(bgfx_uniform_handle_t _handle);
+	bgfx_occlusion_query_handle_t (*create_occlusion_query)();
+	bgfx_occlusion_query_result_t (*get_result)(bgfx_occlusion_query_handle_t _handle, int32_t* _result);
+	void (*destroy_occlusion_query)(bgfx_occlusion_query_handle_t _handle);
+	void (*set_palette_color)(uint8_t _index, const float _rgba[4]);
+	void (*set_palette_color_rgba8)(uint8_t _index, uint32_t _rgba);
+	void (*set_view_name)(bgfx_view_id_t _id, const char* _name);
+	void (*set_view_rect)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
+	void (*set_view_rect_ratio)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, bgfx_backbuffer_ratio_t _ratio);
+	void (*set_view_scissor)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
+	void (*set_view_clear)(bgfx_view_id_t _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil);
+	void (*set_view_clear_mrt)(bgfx_view_id_t _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _c0, uint8_t _c1, uint8_t _c2, uint8_t _c3, uint8_t _c4, uint8_t _c5, uint8_t _c6, uint8_t _c7);
+	void (*set_view_mode)(bgfx_view_id_t _id, bgfx_view_mode_t _mode);
+	void (*set_view_frame_buffer)(bgfx_view_id_t _id, bgfx_frame_buffer_handle_t _handle);
+	void (*set_view_transform)(bgfx_view_id_t _id, const void* _view, const void* _proj);
+	void (*set_view_order)(bgfx_view_id_t _id, uint16_t _num, const bgfx_view_id_t* _order);
+	bgfx_encoder_t* (*encoder_begin)(bool _forThread);
+	void (*encoder_end)(bgfx_encoder_t* _encoder);
+	void (*encoder_set_marker)(bgfx_encoder_t* _this, const char* _marker);
+	void (*encoder_set_state)(bgfx_encoder_t* _this, uint64_t _state, uint32_t _rgba);
+	void (*encoder_set_condition)(bgfx_encoder_t* _this, bgfx_occlusion_query_handle_t _handle, bool _visible);
+	void (*encoder_set_stencil)(bgfx_encoder_t* _this, uint32_t _fstencil, uint32_t _bstencil);
+	uint16_t (*encoder_set_scissor)(bgfx_encoder_t* _this, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
+	void (*encoder_set_scissor_cached)(bgfx_encoder_t* _this, uint16_t _cache);
+	uint32_t (*encoder_set_transform)(bgfx_encoder_t* _this, const void* _mtx, uint16_t _num);
+	void (*encoder_set_transform_cached)(bgfx_encoder_t* _this, uint32_t _cache, uint16_t _num);
+	uint32_t (*encoder_alloc_transform)(bgfx_encoder_t* _this, bgfx_transform_t* _transform, uint16_t _num);
+	void (*encoder_set_uniform)(bgfx_encoder_t* _this, bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num);
+	void (*encoder_set_index_buffer)(bgfx_encoder_t* _this, bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
+	void (*encoder_set_dynamic_index_buffer)(bgfx_encoder_t* _this, bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
+	void (*encoder_set_transient_index_buffer)(bgfx_encoder_t* _this, const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices);
+	void (*encoder_set_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
+	void (*encoder_set_dynamic_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
+	void (*encoder_set_transient_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices);
+	void (*encoder_set_vertex_count)(bgfx_encoder_t* _this, uint32_t _numVertices);
+	void (*encoder_set_instance_data_buffer)(bgfx_encoder_t* _this, const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num);
+	void (*encoder_set_instance_data_from_vertex_buffer)(bgfx_encoder_t* _this, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
+	void (*encoder_set_instance_data_from_dynamic_vertex_buffer)(bgfx_encoder_t* _this, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
+	void (*encoder_set_instance_count)(bgfx_encoder_t* _this, uint32_t _numInstances);
+	void (*encoder_set_texture)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags);
+	void (*encoder_touch)(bgfx_encoder_t* _this, bgfx_view_id_t _id);
+	void (*encoder_submit)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _depth, bool _preserveState);
+	void (*encoder_submit_occlusion_query)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState);
+	void (*encoder_submit_indirect)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState);
+	void (*encoder_set_compute_index_buffer)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access);
+	void (*encoder_set_compute_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access);
+	void (*encoder_set_compute_dynamic_index_buffer)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access);
+	void (*encoder_set_compute_dynamic_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access);
+	void (*encoder_set_compute_indirect_buffer)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access);
+	void (*encoder_set_image)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
+	void (*encoder_dispatch)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
+	void (*encoder_dispatch_indirect)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
+	void (*encoder_discard)(bgfx_encoder_t* _this);
+	void (*encoder_blit)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
+	void (*request_screen_shot)(bgfx_frame_buffer_handle_t _handle, const char* _filePath);
+	bgfx_render_frame_t (*render_frame)(int32_t _msecs);
+	void (*set_platform_data)(const bgfx_platform_data_t * _data);
+	const bgfx_internal_data_t* (*get_internal_data)();
+	uintptr_t (*override_internal_texture_ptr)(bgfx_texture_handle_t _handle, uintptr_t _ptr);
+	uintptr_t (*override_internal_texture)(bgfx_texture_handle_t _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint64_t _flags);
+	void (*set_marker)(const char* _marker);
+	void (*set_state)(uint64_t _state, uint32_t _rgba);
+	void (*set_condition)(bgfx_occlusion_query_handle_t _handle, bool _visible);
+	void (*set_stencil)(uint32_t _fstencil, uint32_t _bstencil);
+	uint16_t (*set_scissor)(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
+	void (*set_scissor_cached)(uint16_t _cache);
+	uint32_t (*set_transform)(const void* _mtx, uint16_t _num);
+	void (*set_transform_cached)(uint32_t _cache, uint16_t _num);
+	uint32_t (*alloc_transform)(bgfx_transform_t* _transform, uint16_t _num);
+	void (*set_uniform)(bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num);
+	void (*set_index_buffer)(bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
+	void (*set_dynamic_index_buffer)(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
+	void (*set_transient_index_buffer)(const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices);
+	void (*set_vertex_buffer)(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
+	void (*set_dynamic_vertex_buffer)(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
+	void (*set_transient_vertex_buffer)(uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices);
+	void (*set_vertex_count)(uint32_t _numVertices);
+	void (*set_instance_data_buffer)(const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num);
+	void (*set_instance_data_from_vertex_buffer)(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
+	void (*set_instance_data_from_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
+	void (*set_instance_count)(uint32_t _numInstances);
+	void (*set_texture)(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags);
+	void (*touch)(bgfx_view_id_t _id);
+	void (*submit)(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _depth, bool _preserveState);
+	void (*submit_occlusion_query)(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState);
+	void (*submit_indirect)(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState);
+	void (*set_compute_index_buffer)(uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access);
+	void (*set_compute_vertex_buffer)(uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access);
+	void (*set_compute_dynamic_index_buffer)(uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access);
+	void (*set_compute_dynamic_vertex_buffer)(uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access);
+	void (*set_compute_indirect_buffer)(uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access);
+	void (*set_image)(uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
+	void (*dispatch)(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
+	void (*dispatch_indirect)(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
+	void (*discard)();
+	void (*blit)(bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
+};
 
 /**/
 typedef bgfx_interface_vtbl_t* (*PFN_BGFX_GET_INTERFACE)(uint32_t _version);

+ 0 - 734
include/bgfx/c99/bgfx.idl.h

@@ -1,734 +0,0 @@
-/*
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-/*
- *
- * AUTO GENERATED! DO NOT EDIT!
- *
- */
-
-/**/
-BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _this, bgfx_renderer_type_t _renderer);
-
-/**/
-BGFX_C_API void bgfx_vertex_decl_add(bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib, uint8_t _num, bgfx_attrib_type_t _type, bool _normalized, bool _asInt);
-
-/**/
-BGFX_C_API void bgfx_vertex_decl_decode(const bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib, uint8_t * _num, bgfx_attrib_type_t * _type, bool * _normalized, bool * _asInt);
-
-/**/
-BGFX_C_API bool bgfx_vertex_decl_has(const bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib);
-
-/**/
-BGFX_C_API void bgfx_vertex_decl_skip(bgfx_vertex_decl_t* _this, uint8_t _num);
-
-/**/
-BGFX_C_API void bgfx_vertex_decl_end(bgfx_vertex_decl_t* _this);
-
-/**/
-BGFX_C_API void bgfx_vertex_pack(const float * _input, bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, void * _data, uint32_t _index);
-
-/**/
-BGFX_C_API void bgfx_vertex_unpack(float * _output, bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, const void * _data, uint32_t _index);
-
-/**/
-BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_decl_t * _dstDecl, void * _dstData, const bgfx_vertex_decl_t * _srcDecl, const void * _srcData, uint32_t _num);
-
-/**/
-BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t * _output, const bgfx_vertex_decl_t * _decl, const void * _data, uint16_t _num, float _epsilon);
-
-/**/
-BGFX_C_API uint32_t bgfx_topology_convert(bgfx_topology_convert_t _conversion, void * _dst, uint32_t _dstSize, const void * _indices, uint32_t _numIndices, bool _index32);
-
-/**/
-BGFX_C_API void bgfx_topology_sort_tri_list(bgfx_topology_sort_t _sort, void * _dst, uint32_t _dstSize, const float * _dir, const float * _pos, const void * _vertices, uint32_t _stride, const void * _indices, uint32_t _numIndices, bool _index32);
-
-/**/
-BGFX_C_API uint8_t bgfx_get_supported_renderers(uint8_t _max, bgfx_renderer_type_t * _enum);
-
-/**/
-BGFX_C_API const char * bgfx_get_renderer_name(bgfx_renderer_type_t _type);
-
-/**/
-BGFX_C_API void bgfx_init_ctor(bgfx_init_t * _init);
-
-/**/
-BGFX_C_API bool bgfx_init(const bgfx_init_t * _init);
-
-/**/
-BGFX_C_API void bgfx_shutdown();
-
-/**/
-BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags, bgfx_texture_format_t _format);
-
-/**/
-BGFX_C_API uint32_t bgfx_frame(bool _capture);
-
-/**/
-BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type();
-
-/**/
-BGFX_C_API const bgfx_caps_t * bgfx_get_caps();
-
-/**/
-BGFX_C_API const bgfx_stats_t * bgfx_get_stats();
-
-/**/
-BGFX_C_API const bgfx_memory_t * bgfx_alloc(uint32_t _size);
-
-/**/
-BGFX_C_API const bgfx_memory_t * bgfx_copy(const void * _data, uint32_t _size);
-
-/**/
-BGFX_C_API const bgfx_memory_t * bgfx_make_ref(const void * _data, uint32_t _size);
-
-/**/
-BGFX_C_API const bgfx_memory_t * bgfx_make_ref_release(const void * _data, uint32_t _size, bgfx_release_fn_t _releaseFn, void * _userData);
-
-/**/
-BGFX_C_API void bgfx_set_debug(uint32_t _debug);
-
-/**/
-BGFX_C_API void bgfx_dbg_text_clear(uint8_t _attr, bool _small);
-
-/**/
-BGFX_C_API void bgfx_dbg_text_printf(uint16_t _x, uint16_t _y, uint8_t _attr, const char * _format, ... );
-
-/**/
-BGFX_C_API void bgfx_dbg_text_vprintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char * _format, va_list _argList);
-
-/**/
-BGFX_C_API void bgfx_dbg_text_image(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void * _data, uint16_t _pitch);
-
-/**/
-BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t * _mem, uint16_t _flags);
-
-/**/
-BGFX_C_API void bgfx_set_index_buffer_name(bgfx_index_buffer_handle_t _handle, const char * _name, int32_t _len);
-
-/**/
-BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle);
-
-/**/
-BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t * _mem, const bgfx_vertex_decl_t * _decl, uint16_t _flags);
-
-/**/
-BGFX_C_API void bgfx_set_vertex_buffer_name(bgfx_vertex_buffer_handle_t _handle, const char * _name, int32_t _len);
-
-/**/
-BGFX_C_API void bgfx_destroy_vertex_buffer(bgfx_vertex_buffer_handle_t _handle);
-
-/**/
-BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num, uint16_t _flags);
-
-/**/
-BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t * _mem, uint16_t _flags);
-
-/**/
-BGFX_C_API void bgfx_update_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _startIndex, const bgfx_memory_t * _mem);
-
-/**/
-BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle);
-
-/**/
-BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t * _decl, uint16_t _flags);
-
-/**/
-BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t * _mem, const bgfx_vertex_decl_t * _decl, uint16_t _flags);
-
-/**/
-BGFX_C_API void bgfx_update_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t * _mem);
-
-/**/
-BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle);
-
-/**/
-BGFX_C_API uint32_t bgfx_get_avail_transient_index_buffer(uint32_t _num);
-
-/**/
-BGFX_C_API uint32_t bgfx_get_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t * _decl);
-
-/**/
-BGFX_C_API uint32_t bgfx_get_avail_instance_data_buffer(uint32_t _num, uint16_t _stride);
-
-/**/
-BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t * _tib, uint32_t _num);
-
-/**/
-BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t * _tvb, uint32_t _num, const bgfx_vertex_decl_t * _decl);
-
-/**/
-BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t * _tvb, const bgfx_vertex_decl_t * _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t * _tib, uint32_t _numIndices);
-
-/**/
-BGFX_C_API void bgfx_alloc_instance_data_buffer(bgfx_instance_data_buffer_t * _idb, uint32_t _num, uint16_t _stride);
-
-/**/
-BGFX_C_API bgfx_indirect_buffer_handle_t bgfx_create_indirect_buffer(uint32_t _num);
-
-/**/
-BGFX_C_API void bgfx_destroy_indirect_buffer(bgfx_indirect_buffer_handle_t _handle);
-
-/**/
-BGFX_C_API bgfx_shader_handle_t bgfx_create_shader(const bgfx_memory_t * _mem);
-
-/**/
-BGFX_C_API uint16_t bgfx_get_shader_uniforms(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t * _uniforms, uint16_t _max);
-
-/**/
-BGFX_C_API void bgfx_set_shader_name(bgfx_shader_handle_t _handle, const char * _name, int32_t _len);
-
-/**/
-BGFX_C_API void bgfx_destroy_shader(bgfx_shader_handle_t _handle);
-
-/**/
-BGFX_C_API bgfx_program_handle_t bgfx_create_program(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders);
-
-/**/
-BGFX_C_API bgfx_program_handle_t bgfx_create_compute_program(bgfx_shader_handle_t _csh, bool _destroyShaders);
-
-/**/
-BGFX_C_API void bgfx_destroy_program(bgfx_program_handle_t _handle);
-
-/**/
-BGFX_C_API bool bgfx_is_texture_valid(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
-
-/**/
-BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t * _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format);
-
-/**/
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t * _mem, uint64_t _flags, uint8_t _skip, bgfx_texture_info_t * _info);
-
-/**/
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t * _mem);
-
-/**/
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d_scaled(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
-
-/**/
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t * _mem);
-
-/**/
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t * _mem);
-
-/**/
-BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t * _mem, uint16_t _pitch);
-
-/**/
-BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t * _mem);
-
-/**/
-BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t * _mem, uint16_t _pitch);
-
-/**/
-BGFX_C_API uint32_t bgfx_read_texture(bgfx_texture_handle_t _handle, void * _data, uint8_t _mip);
-
-/**/
-BGFX_C_API void bgfx_set_texture_name(bgfx_texture_handle_t _handle, const char * _name, int32_t _len);
-
-/**/
-BGFX_C_API void * bgfx_get_direct_access_ptr(bgfx_texture_handle_t _handle);
-
-/**/
-BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle);
-
-/**/
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint64_t _textureFlags);
-
-/**/
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint64_t _textureFlags);
-
-/**/
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t * _handles, bool _destroyTexture);
-
-/**/
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_attachment(uint8_t _num, const bgfx_attachment_t * _handles, bool _destroyTexture);
-
-/**/
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void * _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, bgfx_texture_format_t _depthFormat);
-
-/**/
-BGFX_C_API void bgfx_set_frame_buffer_name(bgfx_frame_buffer_handle_t _handle, const char * _name, int32_t _len);
-
-/**/
-BGFX_C_API bgfx_texture_handle_t bgfx_get_texture(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment);
-
-/**/
-BGFX_C_API void bgfx_destroy_frame_buffer(bgfx_frame_buffer_handle_t _handle);
-
-/**/
-BGFX_C_API bgfx_uniform_handle_t bgfx_create_uniform(const char * _name, bgfx_uniform_type_t _type, uint16_t _num);
-
-/**/
-BGFX_C_API void bgfx_get_uniform_info(bgfx_uniform_handle_t _handle, bgfx_uniform_info_t * _info);
-
-/**/
-BGFX_C_API void bgfx_destroy_uniform(bgfx_uniform_handle_t _handle);
-
-/**/
-BGFX_C_API bgfx_occlusion_query_handle_t bgfx_create_occlusion_query();
-
-/**/
-BGFX_C_API bgfx_occlusion_query_result_t bgfx_get_result(bgfx_occlusion_query_handle_t _handle, int32_t * _result);
-
-/**/
-BGFX_C_API void bgfx_destroy_occlusion_query(bgfx_occlusion_query_handle_t _handle);
-
-/**/
-BGFX_C_API void bgfx_set_palette_color(uint8_t _index, const float * _rgba);
-
-/**/
-BGFX_C_API void bgfx_set_view_name(bgfx_view_id_t _id, const char * _name);
-
-/**/
-BGFX_C_API void bgfx_set_view_rect(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
-
-/**/
-BGFX_C_API void bgfx_set_view_rect_ratio(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, bgfx_backbuffer_ratio_t _ratio);
-
-/**/
-BGFX_C_API void bgfx_set_view_scissor(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
-
-/**/
-BGFX_C_API void bgfx_set_view_clear(bgfx_view_id_t _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil);
-
-/**/
-BGFX_C_API void bgfx_set_view_clear_mrt(bgfx_view_id_t _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _c0, uint8_t _c1, uint8_t _c2, uint8_t _c3, uint8_t _c4, uint8_t _c5, uint8_t _c6, uint8_t _c7);
-
-/**/
-BGFX_C_API void bgfx_set_view_mode(bgfx_view_id_t _id, bgfx_view_mode_t _mode);
-
-/**/
-BGFX_C_API void bgfx_set_view_frame_buffer(bgfx_view_id_t _id, bgfx_frame_buffer_handle_t _handle);
-
-/**/
-BGFX_C_API void bgfx_set_view_transform(bgfx_view_id_t _id, const void * _view, const void * _proj);
-
-/**/
-BGFX_C_API void bgfx_set_view_order(bgfx_view_id_t _id, uint16_t _num, const bgfx_view_id_t * _order);
-
-/**/
-BGFX_C_API bgfx_encoder_t * bgfx_encoder_begin(bool _forThread);
-
-/**/
-BGFX_C_API void bgfx_encoder_end(bgfx_encoder_t * _encoder);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_marker(bgfx_encoder_t* _this, const char * _marker);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_state(bgfx_encoder_t* _this, uint64_t _state, uint32_t _rgba);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_condition(bgfx_encoder_t* _this, bgfx_occlusion_query_handle_t _handle, bool _visible);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_stencil(bgfx_encoder_t* _this, uint32_t _fstencil, uint32_t _bstencil);
-
-/**/
-BGFX_C_API uint16_t bgfx_encoder_set_scissor(bgfx_encoder_t* _this, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_scissor_cached(bgfx_encoder_t* _this, uint16_t _cache);
-
-/**/
-BGFX_C_API uint32_t bgfx_encoder_set_transform(bgfx_encoder_t* _this, const void * _mtx, uint16_t _num);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_transform_cached(bgfx_encoder_t* _this, uint32_t _cache, uint16_t _num);
-
-/**/
-BGFX_C_API uint32_t bgfx_encoder_alloc_transform(bgfx_encoder_t* _this, bgfx_transform_t * _transform, uint16_t _num);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_uniform(bgfx_encoder_t* _this, bgfx_uniform_handle_t _handle, const void * _value, uint16_t _num);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_index_buffer(bgfx_encoder_t* _this, bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_dynamic_index_buffer(bgfx_encoder_t* _this, bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_transient_index_buffer(bgfx_encoder_t* _this, const bgfx_transient_index_buffer_t * _tib, uint32_t _firstIndex, uint32_t _numIndices);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_dynamic_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t * _tvb, uint32_t _startVertex, uint32_t _numVertices);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_vertex_count(bgfx_encoder_t* _this, uint32_t _numVertices);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_instance_data_buffer(bgfx_encoder_t* _this, const bgfx_instance_data_buffer_t * _idb, uint32_t _start, uint32_t _num);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_instance_data_from_vertex_buffer(bgfx_encoder_t* _this, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_instance_data_from_dynamic_vertex_buffer(bgfx_encoder_t* _this, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_instance_count(bgfx_encoder_t* _this, uint32_t _numInstances);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_texture(bgfx_encoder_t* _this, uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags);
-
-/**/
-BGFX_C_API void bgfx_encoder_touch(bgfx_encoder_t* _this, bgfx_view_id_t _id);
-
-/**/
-BGFX_C_API void bgfx_encoder_submit(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _depth, bool _preserveState);
-
-/**/
-BGFX_C_API void bgfx_encoder_submit_occlusion_query(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState);
-
-/**/
-BGFX_C_API void bgfx_encoder_submit_indirect(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_compute_index_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_compute_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_compute_dynamic_index_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_compute_dynamic_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_compute_indirect_buffer(bgfx_encoder_t* _this, uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access);
-
-/**/
-BGFX_C_API void bgfx_encoder_set_image(bgfx_encoder_t* _this, uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
-
-/**/
-BGFX_C_API void bgfx_encoder_dispatch(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
-
-/**/
-BGFX_C_API void bgfx_encoder_dispatch_indirect(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
-
-/**/
-BGFX_C_API void bgfx_encoder_discard(bgfx_encoder_t* _this);
-
-/**/
-BGFX_C_API void bgfx_encoder_blit(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
-
-/**/
-BGFX_C_API void bgfx_request_screen_shot(bgfx_frame_buffer_handle_t _handle, const char * _filePath);
-
-/**/
-BGFX_C_API bgfx_render_frame_t bgfx_render_frame(int32_t _msecs);
-
-/**/
-BGFX_C_API void bgfx_set_platform_data(const bgfx_platform_data_t * _data);
-
-/**/
-BGFX_C_API const bgfx_internal_data_t * bgfx_get_internal_data();
-
-/**/
-BGFX_C_API uintptr_t bgfx_override_internal_texture_ptr(bgfx_texture_handle_t _handle, uintptr_t _ptr);
-
-/**/
-BGFX_C_API uintptr_t bgfx_override_internal_texture(bgfx_texture_handle_t _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags);
-
-/**/
-BGFX_C_API void bgfx_set_marker(const char * _marker);
-
-/**/
-BGFX_C_API void bgfx_set_state(uint64_t _state, uint32_t _rgba);
-
-/**/
-BGFX_C_API void bgfx_set_condition(bgfx_occlusion_query_handle_t _handle, bool _visible);
-
-/**/
-BGFX_C_API void bgfx_set_stencil(uint32_t _fstencil, uint32_t _bstencil);
-
-/**/
-BGFX_C_API uint16_t bgfx_set_scissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
-
-/**/
-BGFX_C_API void bgfx_set_scissor_cached(uint16_t _cache);
-
-/**/
-BGFX_C_API uint32_t bgfx_set_transform(const void * _mtx, uint16_t _num);
-
-/**/
-BGFX_C_API void bgfx_set_transform_cached(uint32_t _cache, uint16_t _num);
-
-/**/
-BGFX_C_API uint32_t bgfx_alloc_transform(bgfx_transform_t * _transform, uint16_t _num);
-
-/**/
-BGFX_C_API void bgfx_set_uniform(bgfx_uniform_handle_t _handle, const void * _value, uint16_t _num);
-
-/**/
-BGFX_C_API void bgfx_set_index_buffer(bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
-
-/**/
-BGFX_C_API void bgfx_set_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
-
-/**/
-BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffer_t * _tib, uint32_t _firstIndex, uint32_t _numIndices);
-
-/**/
-BGFX_C_API void bgfx_set_vertex_buffer(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
-
-/**/
-BGFX_C_API void bgfx_set_dynamic_vertex_buffer(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
-
-/**/
-BGFX_C_API void bgfx_set_transient_vertex_buffer(uint8_t _stream, const bgfx_transient_vertex_buffer_t * _tvb, uint32_t _startVertex, uint32_t _numVertices);
-
-/**/
-BGFX_C_API void bgfx_set_vertex_count(uint32_t _numVertices);
-
-/**/
-BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t * _idb, uint32_t _start, uint32_t _num);
-
-/**/
-BGFX_C_API void bgfx_set_instance_data_from_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
-
-/**/
-BGFX_C_API void bgfx_set_instance_data_from_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
-
-/**/
-BGFX_C_API void bgfx_set_instance_count(uint32_t _numInstances);
-
-/**/
-BGFX_C_API void bgfx_set_texture(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags);
-
-/**/
-BGFX_C_API void bgfx_touch(bgfx_view_id_t _id);
-
-/**/
-BGFX_C_API void bgfx_submit(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _depth, bool _preserveState);
-
-/**/
-BGFX_C_API void bgfx_submit_occlusion_query(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState);
-
-/**/
-BGFX_C_API void bgfx_submit_indirect(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState);
-
-/**/
-BGFX_C_API void bgfx_set_compute_index_buffer(uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access);
-
-/**/
-BGFX_C_API void bgfx_set_compute_vertex_buffer(uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access);
-
-/**/
-BGFX_C_API void bgfx_set_compute_dynamic_index_buffer(uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access);
-
-/**/
-BGFX_C_API void bgfx_set_compute_dynamic_vertex_buffer(uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access);
-
-/**/
-BGFX_C_API void bgfx_set_compute_indirect_buffer(uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access);
-
-/**/
-BGFX_C_API void bgfx_set_image(uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
-
-/**/
-BGFX_C_API void bgfx_dispatch(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
-
-/**/
-BGFX_C_API void bgfx_dispatch_indirect(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
-
-/**/
-BGFX_C_API void bgfx_discard();
-
-/**/
-BGFX_C_API void bgfx_blit(bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
-
-/**/
-typedef struct bgfx_interface_vtbl
-{
-	void (*vertex_decl_begin)(bgfx_vertex_decl_t* _this, bgfx_renderer_type_t _renderer);
-	void (*vertex_decl_add)(bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib, uint8_t _num, bgfx_attrib_type_t _type, bool _normalized, bool _asInt);
-	void (*vertex_decl_decode)(const bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib, uint8_t * _num, bgfx_attrib_type_t * _type, bool * _normalized, bool * _asInt);
-	bool (*vertex_decl_has)(const bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib);
-	void (*vertex_decl_skip)(bgfx_vertex_decl_t* _this, uint8_t _num);
-	void (*vertex_decl_end)(bgfx_vertex_decl_t* _this);
-	void (*vertex_pack)(const float * _input, bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, void * _data, uint32_t _index);
-	void (*vertex_unpack)(float * _output, bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, const void * _data, uint32_t _index);
-	void (*vertex_convert)(const bgfx_vertex_decl_t * _dstDecl, void * _dstData, const bgfx_vertex_decl_t * _srcDecl, const void * _srcData, uint32_t _num);
-	uint16_t (*weld_vertices)(uint16_t * _output, const bgfx_vertex_decl_t * _decl, const void * _data, uint16_t _num, float _epsilon);
-	uint32_t (*topology_convert)(bgfx_topology_convert_t _conversion, void * _dst, uint32_t _dstSize, const void * _indices, uint32_t _numIndices, bool _index32);
-	void (*topology_sort_tri_list)(bgfx_topology_sort_t _sort, void * _dst, uint32_t _dstSize, const float * _dir, const float * _pos, const void * _vertices, uint32_t _stride, const void * _indices, uint32_t _numIndices, bool _index32);
-	uint8_t (*get_supported_renderers)(uint8_t _max, bgfx_renderer_type_t * _enum);
-	const char * (*get_renderer_name)(bgfx_renderer_type_t _type);
-	void (*init_ctor)(bgfx_init_t * _init);
-	bool (*init)(const bgfx_init_t * _init);
-	void (*shutdown)();
-	void (*reset)(uint32_t _width, uint32_t _height, uint32_t _flags, bgfx_texture_format_t _format);
-	uint32_t (*frame)(bool _capture);
-	bgfx_renderer_type_t (*get_renderer_type)();
-	const bgfx_caps_t * (*get_caps)();
-	const bgfx_stats_t * (*get_stats)();
-	const bgfx_memory_t * (*alloc)(uint32_t _size);
-	const bgfx_memory_t * (*copy)(const void * _data, uint32_t _size);
-	const bgfx_memory_t * (*make_ref)(const void * _data, uint32_t _size);
-	const bgfx_memory_t * (*make_ref_release)(const void * _data, uint32_t _size, bgfx_release_fn_t _releaseFn, void * _userData);
-	void (*set_debug)(uint32_t _debug);
-	void (*dbg_text_clear)(uint8_t _attr, bool _small);
-	void (*dbg_text_printf)(uint16_t _x, uint16_t _y, uint8_t _attr, const char * _format, ... );
-	void (*dbg_text_vprintf)(uint16_t _x, uint16_t _y, uint8_t _attr, const char * _format, va_list _argList);
-	void (*dbg_text_image)(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void * _data, uint16_t _pitch);
-	bgfx_index_buffer_handle_t (*create_index_buffer)(const bgfx_memory_t * _mem, uint16_t _flags);
-	void (*set_index_buffer_name)(bgfx_index_buffer_handle_t _handle, const char * _name, int32_t _len);
-	void (*destroy_index_buffer)(bgfx_index_buffer_handle_t _handle);
-	bgfx_vertex_buffer_handle_t (*create_vertex_buffer)(const bgfx_memory_t * _mem, const bgfx_vertex_decl_t * _decl, uint16_t _flags);
-	void (*set_vertex_buffer_name)(bgfx_vertex_buffer_handle_t _handle, const char * _name, int32_t _len);
-	void (*destroy_vertex_buffer)(bgfx_vertex_buffer_handle_t _handle);
-	bgfx_dynamic_index_buffer_handle_t (*create_dynamic_index_buffer)(uint32_t _num, uint16_t _flags);
-	bgfx_dynamic_index_buffer_handle_t (*create_dynamic_index_buffer_mem)(const bgfx_memory_t * _mem, uint16_t _flags);
-	void (*update_dynamic_index_buffer)(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _startIndex, const bgfx_memory_t * _mem);
-	void (*destroy_dynamic_index_buffer)(bgfx_dynamic_index_buffer_handle_t _handle);
-	bgfx_dynamic_vertex_buffer_handle_t (*create_dynamic_vertex_buffer)(uint32_t _num, const bgfx_vertex_decl_t * _decl, uint16_t _flags);
-	bgfx_dynamic_vertex_buffer_handle_t (*create_dynamic_vertex_buffer_mem)(const bgfx_memory_t * _mem, const bgfx_vertex_decl_t * _decl, uint16_t _flags);
-	void (*update_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t * _mem);
-	void (*destroy_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle);
-	uint32_t (*get_avail_transient_index_buffer)(uint32_t _num);
-	uint32_t (*get_avail_transient_vertex_buffer)(uint32_t _num, const bgfx_vertex_decl_t * _decl);
-	uint32_t (*get_avail_instance_data_buffer)(uint32_t _num, uint16_t _stride);
-	void (*alloc_transient_index_buffer)(bgfx_transient_index_buffer_t * _tib, uint32_t _num);
-	void (*alloc_transient_vertex_buffer)(bgfx_transient_vertex_buffer_t * _tvb, uint32_t _num, const bgfx_vertex_decl_t * _decl);
-	bool (*alloc_transient_buffers)(bgfx_transient_vertex_buffer_t * _tvb, const bgfx_vertex_decl_t * _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t * _tib, uint32_t _numIndices);
-	void (*alloc_instance_data_buffer)(bgfx_instance_data_buffer_t * _idb, uint32_t _num, uint16_t _stride);
-	bgfx_indirect_buffer_handle_t (*create_indirect_buffer)(uint32_t _num);
-	void (*destroy_indirect_buffer)(bgfx_indirect_buffer_handle_t _handle);
-	bgfx_shader_handle_t (*create_shader)(const bgfx_memory_t * _mem);
-	uint16_t (*get_shader_uniforms)(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t * _uniforms, uint16_t _max);
-	void (*set_shader_name)(bgfx_shader_handle_t _handle, const char * _name, int32_t _len);
-	void (*destroy_shader)(bgfx_shader_handle_t _handle);
-	bgfx_program_handle_t (*create_program)(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders);
-	bgfx_program_handle_t (*create_compute_program)(bgfx_shader_handle_t _csh, bool _destroyShaders);
-	void (*destroy_program)(bgfx_program_handle_t _handle);
-	bool (*is_texture_valid)(uint16_t _depth, bool _cubeMap, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
-	void (*calc_texture_size)(bgfx_texture_info_t * _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format);
-	bgfx_texture_handle_t (*create_texture)(const bgfx_memory_t * _mem, uint64_t _flags, uint8_t _skip, bgfx_texture_info_t * _info);
-	bgfx_texture_handle_t (*create_texture_2d)(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t * _mem);
-	bgfx_texture_handle_t (*create_texture_2d_scaled)(bgfx_backbuffer_ratio_t _ratio, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags);
-	bgfx_texture_handle_t (*create_texture_3d)(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t * _mem);
-	bgfx_texture_handle_t (*create_texture_cube)(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t * _mem);
-	void (*update_texture_2d)(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t * _mem, uint16_t _pitch);
-	void (*update_texture_3d)(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t * _mem);
-	void (*update_texture_cube)(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t * _mem, uint16_t _pitch);
-	uint32_t (*read_texture)(bgfx_texture_handle_t _handle, void * _data, uint8_t _mip);
-	void (*set_texture_name)(bgfx_texture_handle_t _handle, const char * _name, int32_t _len);
-	void * (*get_direct_access_ptr)(bgfx_texture_handle_t _handle);
-	void (*destroy_texture)(bgfx_texture_handle_t _handle);
-	bgfx_frame_buffer_handle_t (*create_frame_buffer)(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint64_t _textureFlags);
-	bgfx_frame_buffer_handle_t (*create_frame_buffer_scaled)(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint64_t _textureFlags);
-	bgfx_frame_buffer_handle_t (*create_frame_buffer_from_handles)(uint8_t _num, const bgfx_texture_handle_t * _handles, bool _destroyTexture);
-	bgfx_frame_buffer_handle_t (*create_frame_buffer_from_attachment)(uint8_t _num, const bgfx_attachment_t * _handles, bool _destroyTexture);
-	bgfx_frame_buffer_handle_t (*create_frame_buffer_from_nwh)(void * _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, bgfx_texture_format_t _depthFormat);
-	void (*set_frame_buffer_name)(bgfx_frame_buffer_handle_t _handle, const char * _name, int32_t _len);
-	bgfx_texture_handle_t (*get_texture)(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment);
-	void (*destroy_frame_buffer)(bgfx_frame_buffer_handle_t _handle);
-	bgfx_uniform_handle_t (*create_uniform)(const char * _name, bgfx_uniform_type_t _type, uint16_t _num);
-	void (*get_uniform_info)(bgfx_uniform_handle_t _handle, bgfx_uniform_info_t * _info);
-	void (*destroy_uniform)(bgfx_uniform_handle_t _handle);
-	bgfx_occlusion_query_handle_t (*create_occlusion_query)();
-	bgfx_occlusion_query_result_t (*get_result)(bgfx_occlusion_query_handle_t _handle, int32_t * _result);
-	void (*destroy_occlusion_query)(bgfx_occlusion_query_handle_t _handle);
-	void (*set_palette_color)(uint8_t _index, const float * _rgba);
-	void (*set_view_name)(bgfx_view_id_t _id, const char * _name);
-	void (*set_view_rect)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
-	void (*set_view_rect_ratio)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, bgfx_backbuffer_ratio_t _ratio);
-	void (*set_view_scissor)(bgfx_view_id_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
-	void (*set_view_clear)(bgfx_view_id_t _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil);
-	void (*set_view_clear_mrt)(bgfx_view_id_t _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _c0, uint8_t _c1, uint8_t _c2, uint8_t _c3, uint8_t _c4, uint8_t _c5, uint8_t _c6, uint8_t _c7);
-	void (*set_view_mode)(bgfx_view_id_t _id, bgfx_view_mode_t _mode);
-	void (*set_view_frame_buffer)(bgfx_view_id_t _id, bgfx_frame_buffer_handle_t _handle);
-	void (*set_view_transform)(bgfx_view_id_t _id, const void * _view, const void * _proj);
-	void (*set_view_order)(bgfx_view_id_t _id, uint16_t _num, const bgfx_view_id_t * _order);
-	bgfx_encoder_t * (*encoder_begin)(bool _forThread);
-	void (*encoder_end)(bgfx_encoder_t * _encoder);
-	void (*encoder_set_marker)(bgfx_encoder_t* _this, const char * _marker);
-	void (*encoder_set_state)(bgfx_encoder_t* _this, uint64_t _state, uint32_t _rgba);
-	void (*encoder_set_condition)(bgfx_encoder_t* _this, bgfx_occlusion_query_handle_t _handle, bool _visible);
-	void (*encoder_set_stencil)(bgfx_encoder_t* _this, uint32_t _fstencil, uint32_t _bstencil);
-	uint16_t (*encoder_set_scissor)(bgfx_encoder_t* _this, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
-	void (*encoder_set_scissor_cached)(bgfx_encoder_t* _this, uint16_t _cache);
-	uint32_t (*encoder_set_transform)(bgfx_encoder_t* _this, const void * _mtx, uint16_t _num);
-	void (*encoder_set_transform_cached)(bgfx_encoder_t* _this, uint32_t _cache, uint16_t _num);
-	uint32_t (*encoder_alloc_transform)(bgfx_encoder_t* _this, bgfx_transform_t * _transform, uint16_t _num);
-	void (*encoder_set_uniform)(bgfx_encoder_t* _this, bgfx_uniform_handle_t _handle, const void * _value, uint16_t _num);
-	void (*encoder_set_index_buffer)(bgfx_encoder_t* _this, bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
-	void (*encoder_set_dynamic_index_buffer)(bgfx_encoder_t* _this, bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
-	void (*encoder_set_transient_index_buffer)(bgfx_encoder_t* _this, const bgfx_transient_index_buffer_t * _tib, uint32_t _firstIndex, uint32_t _numIndices);
-	void (*encoder_set_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
-	void (*encoder_set_dynamic_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
-	void (*encoder_set_transient_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t * _tvb, uint32_t _startVertex, uint32_t _numVertices);
-	void (*encoder_set_vertex_count)(bgfx_encoder_t* _this, uint32_t _numVertices);
-	void (*encoder_set_instance_data_buffer)(bgfx_encoder_t* _this, const bgfx_instance_data_buffer_t * _idb, uint32_t _start, uint32_t _num);
-	void (*encoder_set_instance_data_from_vertex_buffer)(bgfx_encoder_t* _this, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
-	void (*encoder_set_instance_data_from_dynamic_vertex_buffer)(bgfx_encoder_t* _this, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
-	void (*encoder_set_instance_count)(bgfx_encoder_t* _this, uint32_t _numInstances);
-	void (*encoder_set_texture)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags);
-	void (*encoder_touch)(bgfx_encoder_t* _this, bgfx_view_id_t _id);
-	void (*encoder_submit)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _depth, bool _preserveState);
-	void (*encoder_submit_occlusion_query)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState);
-	void (*encoder_submit_indirect)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState);
-	void (*encoder_set_compute_index_buffer)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access);
-	void (*encoder_set_compute_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access);
-	void (*encoder_set_compute_dynamic_index_buffer)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access);
-	void (*encoder_set_compute_dynamic_vertex_buffer)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access);
-	void (*encoder_set_compute_indirect_buffer)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access);
-	void (*encoder_set_image)(bgfx_encoder_t* _this, uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
-	void (*encoder_dispatch)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
-	void (*encoder_dispatch_indirect)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
-	void (*encoder_discard)(bgfx_encoder_t* _this);
-	void (*encoder_blit)(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
-	void (*request_screen_shot)(bgfx_frame_buffer_handle_t _handle, const char * _filePath);
-	bgfx_render_frame_t (*render_frame)(int32_t _msecs);
-	void (*set_platform_data)(const bgfx_platform_data_t * _data);
-	const bgfx_internal_data_t * (*get_internal_data)();
-	uintptr_t (*override_internal_texture_ptr)(bgfx_texture_handle_t _handle, uintptr_t _ptr);
-	uintptr_t (*override_internal_texture)(bgfx_texture_handle_t _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags);
-	void (*set_marker)(const char * _marker);
-	void (*set_state)(uint64_t _state, uint32_t _rgba);
-	void (*set_condition)(bgfx_occlusion_query_handle_t _handle, bool _visible);
-	void (*set_stencil)(uint32_t _fstencil, uint32_t _bstencil);
-	uint16_t (*set_scissor)(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height);
-	void (*set_scissor_cached)(uint16_t _cache);
-	uint32_t (*set_transform)(const void * _mtx, uint16_t _num);
-	void (*set_transform_cached)(uint32_t _cache, uint16_t _num);
-	uint32_t (*alloc_transform)(bgfx_transform_t * _transform, uint16_t _num);
-	void (*set_uniform)(bgfx_uniform_handle_t _handle, const void * _value, uint16_t _num);
-	void (*set_index_buffer)(bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
-	void (*set_dynamic_index_buffer)(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices);
-	void (*set_transient_index_buffer)(const bgfx_transient_index_buffer_t * _tib, uint32_t _firstIndex, uint32_t _numIndices);
-	void (*set_vertex_buffer)(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
-	void (*set_dynamic_vertex_buffer)(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
-	void (*set_transient_vertex_buffer)(uint8_t _stream, const bgfx_transient_vertex_buffer_t * _tvb, uint32_t _startVertex, uint32_t _numVertices);
-	void (*set_vertex_count)(uint32_t _numVertices);
-	void (*set_instance_data_buffer)(const bgfx_instance_data_buffer_t * _idb, uint32_t _start, uint32_t _num);
-	void (*set_instance_data_from_vertex_buffer)(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
-	void (*set_instance_data_from_dynamic_vertex_buffer)(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
-	void (*set_instance_count)(uint32_t _numInstances);
-	void (*set_texture)(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags);
-	void (*touch)(bgfx_view_id_t _id);
-	void (*submit)(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _depth, bool _preserveState);
-	void (*submit_occlusion_query)(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_occlusion_query_handle_t _occlusionQuery, uint32_t _depth, bool _preserveState);
-	void (*submit_indirect)(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint32_t _depth, bool _preserveState);
-	void (*set_compute_index_buffer)(uint8_t _stage, bgfx_index_buffer_handle_t _handle, bgfx_access_t _access);
-	void (*set_compute_vertex_buffer)(uint8_t _stage, bgfx_vertex_buffer_handle_t _handle, bgfx_access_t _access);
-	void (*set_compute_dynamic_index_buffer)(uint8_t _stage, bgfx_dynamic_index_buffer_handle_t _handle, bgfx_access_t _access);
-	void (*set_compute_dynamic_vertex_buffer)(uint8_t _stage, bgfx_dynamic_vertex_buffer_handle_t _handle, bgfx_access_t _access);
-	void (*set_compute_indirect_buffer)(uint8_t _stage, bgfx_indirect_buffer_handle_t _handle, bgfx_access_t _access);
-	void (*set_image)(uint8_t _stage, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format);
-	void (*dispatch)(bgfx_view_id_t _id, bgfx_program_handle_t _program, uint32_t _numX, uint32_t _numY, uint32_t _numZ);
-	void (*dispatch_indirect)(bgfx_view_id_t _id, bgfx_program_handle_t _program, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num);
-	void (*discard)();
-	void (*blit)(bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_t _dstMip, uint16_t _dstX, uint16_t _dstY, uint16_t _dstZ, bgfx_texture_handle_t _src, uint8_t _srcMip, uint16_t _srcX, uint16_t _srcY, uint16_t _srcZ, uint16_t _width, uint16_t _height, uint16_t _depth);
-} bgfx_interface_vtbl_t;

+ 1 - 1
include/bgfx/defines.h

@@ -6,7 +6,7 @@
 #ifndef BGFX_DEFINES_H_HEADER_GUARD
 #define BGFX_DEFINES_H_HEADER_GUARD
 
-#define BGFX_API_VERSION UINT32_C(95)
+#define BGFX_API_VERSION UINT32_C(96)
 
 /// Color RGB/alpha/depth write. When it's not specified write will be disabled.
 #define BGFX_STATE_WRITE_R                 UINT64_C(0x0000000000000001) //!< Enable R write.

+ 258 - 66
scripts/bgfx-idl.lua

@@ -1,97 +1,289 @@
 -- Copyright 2019 云风 https://github.com/cloudwu . All rights reserved.
 -- License (the same with bgfx) : https://github.com/bkaradzic/bgfx/blob/master/LICENSE
 
-function doIdl()
+local idl     = require "idl"
+local codegen = require "codegen"
+local doxygen = require "doxygen"
+
+local func_actions = {
+	c99 = "\n",
+	c99decl = "\n",
+	cppdecl = "\n",
+	interface_struct = "\n\t",
+	interface_import = ",\n\t\t\t",
+	c99_interface = "\n",
+	cpp_interface = "\n",
+}
+
+local type_actions = {
+	enums = "\n",
+	cenums = "\n",
+	structs = "\n",
+	cstructs = "\n",
+	handles = "\n",
+	chandles = "\n",
+	funcptrs = "\n",
+	cfuncptrs = "\n",
+}
 
-	local idl     = require "idl"
-	local codegen = require "codegen"
+do
+	local source = doxygen.load "bgfx.idl"
+	local f = assert(load(source, "bgfx.idl" , "t", idl))
+	f()
+end
 
-	assert(loadfile("bgfx.idl" , "t", idl))()
+codegen.nameconversion(idl.types, idl.funcs)
 
-	codegen.nameconversion(idl.types, idl.funcs)
+local function cfunc(f)
+	return function(func)
+		if not func.cpponly then
+			return f(func)
+		end
+	end
+end
 
-	local code_temp_include = [[
-/*
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
+local funcgen = {}
 
-/*
- *
- * AUTO GENERATED! DO NOT EDIT!
- *
- */
+local functemp = {}
 
-$c99decl
-/**/
-typedef struct bgfx_interface_vtbl
+functemp.interface_struct = "$CRET (*$CFUNCNAME)($CARGS);"
+functemp.interface_import = "bgfx_$CFUNCNAME"
+functemp.c99_interface = [[
+BGFX_C_API $CRET bgfx_$CFUNCNAME($CARGS)
 {
-	$interface_struct
-} bgfx_interface_vtbl_t;
+	$CONVERSIONCTOC
+	$PRERETCTOCg_interface->$CFUNCNAME($CALLARGS);
+	$POSTRETCTOC
+}
 ]]
 
-	local code_temp_impl = [[
-/*
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-/*
- *
- * AUTO GENERATED! DO NOT EDIT!
- *
- */
+for action,temp in pairs(functemp) do
+	funcgen[action] = cfunc(function(func)
+		return codegen.apply_functemp(func, temp)
+	end)
+end
 
-$c99
-/**/
-BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
+funcgen.cpp_interface= cfunc(function(func)
+	if not func.cfunc and not func.conly then
+		return codegen.apply_functemp(func, [[
+$RET $CLASSNAME$FUNCNAME($CPPARGS)$CONST
 {
-	if (_version == BGFX_API_VERSION)
-	{
-		static bgfx_interface_vtbl_t s_bgfx_interface =
-		{
-			$interface_import
-		};
-
-		return &s_bgfx_interface;
-	}
+	$CONVERSIONCTOCPP
+	$PRERETCPPTOCg_interface->$CFUNCNAME($CALLARGSCPPTOC);
+	$POSTRETCPPTOC
+}
+]])
+	end
+end)
 
-	return NULL;
+funcgen.c99 = cfunc(function(func)
+	local temp
+	if func.cfunc then
+		temp = "/* BGFX_C_API $CRET bgfx_$CFUNCNAME($CARGS) */\n"
+	else
+		temp = [[
+BGFX_C_API $CRET bgfx_$CFUNCNAME($CARGS)
+{
+	$CONVERSION
+	$PRERET$CPPFUNC($CALLARGSCTOCPP);
+	$POSTRET
 }
 ]]
+	end
+	return codegen.apply_functemp(func, temp)
+end)
+
+local function cppdecl(func)
+	local doc = func.comments
+	if not doc and func.comment then
+		doc = { func.comment }
+	end
+	if doc then
+		local cname
+		if not func.cpponly then
+			if func.multicfunc then
+				cname = {}
+				for _, name in ipairs(func.multicfunc) do
+					cname[#cname+1] = "bgfx_" .. name
+				end
+			else
+				cname = "bgfx_" .. func.cname
+			end
+		end
+		doc = codegen.doxygen_type(doc, func, cname)
+	end
+	local funcdecl = codegen.apply_functemp(func, "$RET $FUNCNAME($ARGS)$CONST;\n")
+	if doc then
+		return doc .. "\n" .. funcdecl
+	else
+		return funcdecl
+	end
+end
+
+function funcgen.cppdecl(func)
+	-- Don't generate member functions here
+	if not func.class and not func.conly then
+		return cppdecl(func)
+	end
+end
+
+funcgen.c99decl = cfunc(function(func)
+	local doc = func.comments
+	if not doc and func.comment then
+		doc = { func.comment }
+	end
+	if doc then
+		doc = codegen.doxygen_ctype(doc, func)
+	end
+	local funcdecl = codegen.apply_functemp(func, "BGFX_C_API $CRET bgfx_$CFUNCNAME($CARGS);")
+	if doc then
+		return "\n" .. doc .. "\n" .. funcdecl
+	else
+		return funcdecl
+	end
+end)
+
+local typegen = {}
+
+local function add_doxygen(typedef, define, cstyle, cname)
+		local func = cstyle and codegen.doxygen_ctype or codegen.doxygen_type
+		local doc = func(typedef.comments, typedef, cname or typedef.cname)
+		if doc then
+			return doc .. "\n" .. define
+		else
+			return define
+		end
+end
+
+function typegen.enums(typedef)
+	if typedef.enum then
+		return add_doxygen(typedef, codegen.gen_enum_define(typedef), false, "bgfx_" .. typedef.cname)
+	end
+end
+
+function typegen.cenums(typedef)
+	if typedef.enum then
+		return add_doxygen(typedef, codegen.gen_enum_cdefine(typedef), true)
+	end
+end
 
-	local function codes()
-		local temp = {}
-		local action = {
-			c99 = "\n",
-			c99decl = "\n",
-			interface_struct = "\n\t",
-			interface_import = ",\n\t\t\t",
-		}
-		for k in pairs(action) do
-			temp[k] = {}
+function typegen.structs(typedef)
+	if typedef.struct and not typedef.namespace then
+		local methods = typedef.methods
+		if methods then
+			local m = {}
+			for _, func in ipairs(methods) do
+				m[#m+1] = cppdecl(func)
+			end
+			methods = m
 		end
-		for _, f in ipairs(idl.funcs) do
-			for k in pairs(action) do
-				table.insert(temp[k], (codegen["gen_"..k](f)))
+		return add_doxygen(typedef, codegen.gen_struct_define(typedef, methods))
+	end
+end
+
+function typegen.cstructs(typedef)
+	if typedef.struct then
+		return add_doxygen(typedef, codegen.gen_struct_cdefine(typedef), true)
+	end
+end
+
+function typegen.handles(typedef)
+	if typedef.handle then
+		return codegen.gen_handle(typedef)
+	end
+end
+
+function typegen.chandles(typedef)
+	if typedef.handle then
+		return codegen.gen_chandle(typedef)
+	end
+end
+
+function typegen.funcptrs(typedef)
+	if typedef.args then
+		return add_doxygen(typedef, codegen.gen_funcptr(typedef))
+	end
+end
+
+function typegen.cfuncptrs(typedef)
+	if typedef.args then
+		return add_doxygen(typedef, codegen.gen_cfuncptr(typedef), true)
+	end
+end
+
+local function codes()
+	local temp = {}
+	for k in pairs(func_actions) do
+		temp[k] = {}
+	end
+
+	for k in pairs(type_actions) do
+		temp[k] = {}
+	end
+
+	-- call actions with func
+	for _, f in ipairs(idl.funcs) do
+		for k in pairs(func_actions) do
+			local funcgen = funcgen[k]
+			if funcgen then
+				table.insert(temp[k], (funcgen(f)))
 			end
 		end
+	end
+
+	-- call actions with type
 
-		for k, ident in pairs(action) do
-			temp[k] = table.concat(temp[k], ident)
+	for _, typedef in ipairs(idl.types) do
+		for k in pairs(type_actions) do
+			local typegen = typegen[k]
+			if typegen then
+				table.insert(temp[k], (typegen(typedef)))
+			end
 		end
+	end
 
-		return temp
+	for k, ident in pairs(func_actions) do
+		temp[k] = table.concat(temp[k], ident)
+	end
+	for k, ident in pairs(type_actions) do
+		temp[k] = table.concat(temp[k], ident)
 	end
 
-	local codes_tbl = codes()
+	return temp
+end
+
+local codes_tbl = codes()
+
+local function add_path(filename)
+	local path
+	if type(paths) == "string" then
+		path = paths
+	else
+		path = assert(paths[filename])
+	end
+	return path .. "/" .. filename
+end
 
-	for filename, temp in pairs {
-		["../include/bgfx/c99/bgfx.idl.h"] = code_temp_include ,
-		["../src/bgfx.idl.inl"] = code_temp_impl } do
+local function genidl(filename, outputfile)
+	local tempfile = "temp." .. filename
+	print ("Generate", outputfile, "from", tempfile)
+	local f = assert(io.open(tempfile, "rb"))
+	local temp = f:read "a"
+	f:close()
+	local out = assert(io.open(outputfile, "wb"))
+	codes_tbl.source = tempfile
+	out:write((temp:gsub("$([%l%d_]+)", codes_tbl)))
+	out:close()
+end
+
+function doIdl()
+	local files = {
+		["bgfx.h"] = "../include/bgfx/c99",
+		["bgfx.idl.inl"] = "../src",
+	}
 
-		print ("Generate " .. filename)
-		local out = io.open(filename, "wb")
-		out:write((temp:gsub("$([%l%d_]+)", codes_tbl)))
-		out:close()
+	for filename, path in pairs (files) do
+		genidl(filename, path .. "/" .. filename)
 	end
 
 	os.exit()

+ 2077 - 737
scripts/bgfx.idl

@@ -1,9 +1,12 @@
+-- vim: syntax=lua
 -- bgfx interface
 
 typedef "bool"
 typedef "char"
 typedef "float"
+typedef "int8_t"
 typedef "int32_t"
+typedef "int64_t"
 typedef "uint8_t"
 typedef "uint16_t"
 typedef "uint32_t"
@@ -12,1174 +15,2511 @@ typedef "uintptr_t"
 typedef "va_list"
 typedef "void"
 
-typedef "Attachment"
-typedef "Caps"
-typedef "Encoder"
-typedef "Init"
-typedef "InstanceDataBuffer"
-typedef "InternalData"
-typedef "Memory"
-typedef "PlatformData"
-typedef "ReleaseFn"
-typedef "Stats"
-typedef "TextureInfo"
-typedef "Transform"
-typedef "TransientIndexBuffer"
-typedef "TransientVertexBuffer"
-typedef "UniformInfo"
-typedef "VertexDecl"
 typedef "ViewId"
-
-typedef.Access               { enum }
-typedef.Attrib               { enum }
-typedef.AttribType           { enum }
-typedef.BackbufferRatio      { enum }
-typedef.OcclusionQueryResult { enum }
-typedef.RenderFrame          { enum }
-typedef.RendererType         { enum }
-typedef.TextureFormat        { enum }
-typedef.TopologyConvert      { enum }
-typedef.TopologySort         { enum }
-typedef.UniformType          { enum }
-typedef.ViewMode             { enum }
-
-typedef.DynamicIndexBufferHandle  { handle }
-typedef.DynamicVertexBufferHandle { handle }
-typedef.FrameBufferHandle         { handle }
-typedef.IndexBufferHandle         { handle }
-typedef.IndirectBufferHandle      { handle }
-typedef.OcclusionQueryHandle      { handle }
-typedef.ProgramHandle             { handle }
-typedef.ShaderHandle              { handle }
-typedef.TextureHandle             { handle }
-typedef.UniformHandle             { handle }
-typedef.VertexBufferHandle        { handle }
-typedef.VertexDeclHandle          { handle }
-
+typedef "CallbackI"      { cname = "callback_interface" }
+typedef "bx::AllocatorI" { cname = "allocator_interface" }
+
+--- Memory release callback.
+funcptr.ReleaseFn
+	"void"
+	.ptr        "void*" --- Pointer to allocated data.
+	.userData   "void*" --- User defined data if needed.
+
+--- Fatal error enum.
+enum.Fatal { underscore, comment = "" }
+	.DebugCheck
+	.InvalidShader
+	.UnableToInitialize
+	.UnableToCreateTexture
+	.DeviceLost
+	()	-- end of enum
+
+--- Renderer backend type enum.
+enum.RendererType { comment = "Renderer types:" }
+	.Noop       --- No rendering.
+	.Direct3D9  --- Direct3D 9.0
+	.Direct3D11 --- Direct3D 11.0
+	.Direct3D12 --- Direct3D 12.0
+	.Gnm        --- GNM
+	.Metal      --- Metal
+	.OpenGLES   --- OpenGL ES 2.0+
+	.OpenGL     --- OpenGL 2.1+
+	.Vulkan     --- Vulkan
+	()
+
+--- Access mode enum.
+enum.Access { comment = "Access:" }
+	.Read      --- Read.
+	.Write     --- Write.
+	.ReadWrite --- Read and write.
+	()
+
+--- Vertex attribute enum.
+enum.Attrib { comment = "Corresponds to vertex shader attribute." }
+	.Position  --- a_position
+	.Normal    --- a_normal
+	.Tangent   --- a_tangent
+	.Bitangent --- a_bitangent
+	.Color0    --- a_color0
+	.Color1    --- a_color1
+	.Color2    --- a_color2
+	.Color3    --- a_color3
+	.Indices   --- a_indices
+	.Weight    --- a_weight
+	.TexCoord0 --- a_texcoord0
+	.TexCoord1 --- a_texcoord1
+	.TexCoord2 --- a_texcoord2
+	.TexCoord3 --- a_texcoord3
+	.TexCoord4 --- a_texcoord4
+	.TexCoord5 --- a_texcoord5
+	.TexCoord6 --- a_texcoord6
+	.TexCoord7 --- a_texcoord7
+	()
+
+--- Vertex attribute type enum.
+enum.AttribType { comment = "Attribute types:" }
+	.Uint8  --- Uint8
+	.Uint10 --- Uint10, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_UINT10`.
+	.Int16  --- Int16
+	.Half   --- Half, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_HALF`.
+	.Float  --- Float
+	()
+
+--- Texture format enum.
+---
+--- Notation:
+---
+---       RGBA16S
+---       ^   ^ ^
+---       |   | +-- [ ]Unorm
+---       |   |     [F]loat
+---       |   |     [S]norm
+---       |   |     [I]nt
+---       |   |     [U]int
+---       |   +---- Number of bits per component
+---       +-------- Components
+---
+--- @attention Availability depends on Caps (see: formats).
+enum.TextureFormat { comment = "Texture formats:" }
+	.BC1                             --- DXT1
+	.BC2                             --- DXT3
+	.BC3                             --- DXT5
+	.BC4                             --- LATC1/ATI1
+	.BC5                             --- LATC2/ATI2
+	.BC6H                            --- BC6H
+	.BC7                             --- BC7
+	.ETC1                            --- ETC1 RGB8
+	.ETC2                            --- ETC2 RGB8
+	.ETC2A                           --- ETC2 RGBA8
+	.ETC2A1                          --- ETC2 RGB8A1
+	.PTC12                           --- PVRTC1 RGB 2BPP
+	.PTC14                           --- PVRTC1 RGB 4BPP
+	.PTC12A                          --- PVRTC1 RGBA 2BPP
+	.PTC14A                          --- PVRTC1 RGBA 4BPP
+	.PTC22                           --- PVRTC2 RGBA 2BPP
+	.PTC24                           --- PVRTC2 RGBA 4BPP
+	.ATC                             --- ATC RGB 4BPP
+	.ATCE                            --- ATCE RGBA 8 BPP explicit alpha
+	.ATCI                            --- ATCI RGBA 8 BPP interpolated alpha
+	.ASTC4x4                         --- ASTC 4x4 8.0 BPP
+	.ASTC5x5                         --- ASTC 5x5 5.12 BPP
+	.ASTC6x6                         --- ASTC 6x6 3.56 BPP
+	.ASTC8x5                         --- ASTC 8x5 3.20 BPP
+	.ASTC8x6                         --- ASTC 8x6 2.67 BPP
+	.ASTC10x5                        --- ASTC 10x5 2.56 BPP
+	.Unknown                         --- Compressed formats above.
+	.R1
+	.A8
+	.R8
+	.R8I
+	.R8U
+	.R8S
+	.R16
+	.R16I
+	.R16U
+	.R16F
+	.R16S
+	.R32I
+	.R32U
+	.R32F
+	.RG8
+	.RG8I
+	.RG8U
+	.RG8S
+	.RG16
+	.RG16I
+	.RG16U
+	.RG16F
+	.RG16S
+	.RG32I
+	.RG32U
+	.RG32F
+	.RGB8
+	.RGB8I
+	.RGB8U
+	.RGB8S
+	.RGB9E5F
+	.BGRA8
+	.RGBA8
+	.RGBA8I
+	.RGBA8U
+	.RGBA8S
+	.RGBA16
+	.RGBA16I
+	.RGBA16U
+	.RGBA16F
+	.RGBA16S
+	.RGBA32I
+	.RGBA32U
+	.RGBA32F
+	.R5G6B5
+	.RGBA4
+	.RGB5A1
+	.RGB10A2
+	.RG11B10F
+	.UnknownDepth --- Depth formats below.
+	.D16
+	.D24
+	.D24S8
+	.D32
+	.D16F
+	.D24F
+	.D32F
+	.D0S8
+	()
+
+--- Uniform type enum.
+enum.UniformType          { comment = "Uniform types:" }
+	.Sampler [[Sampler.]]
+	.End     [[Reserved, do not use.]]
+	.Vec4    [[4 floats vector.]]
+	.Mat3    [[3x3 matrix.]]
+	.Mat4    [[4x4 matrix.]]
+
+--- Backbuffer ratio enum.
+enum.BackbufferRatio      { comment = "Backbuffer ratios:" }
+	.Equal     [[Equal to backbuffer.]]
+	.Half      [[One half size of backbuffer.]]
+	.Quarter   [[One quarter size of backbuffer.]]
+	.Eighth    [[One eighth size of backbuffer.]]
+	.Sixteenth [[One sixteenth size of backbuffer.]]
+	.Double    [[Double size of backbuffer.]]
+
+--- Occlusion query result.
+enum.OcclusionQueryResult { comment = "Occlusion query results:" }
+	.Invisible [[Query failed test.]]
+	.Visible   [[Query passed test.]]
+	.NoResult  [[Query result is not available yet.]]
+
+--- Primitive topology.
+enum.Topology { underscore, comment = "Primitive topology:" }
+	.TriList   [[Triangle list.]]
+	.TriStrip  [[Triangle strip.]]
+	.LineList  [[Line list.]]
+	.LineStrip [[Line strip.]]
+	.PointList [[Point list.]]
+
+--- Topology conversion function.
+enum.TopologyConvert { underscore , comment = "Topology conversion functions:" }
+	.TriListFlipWinding  [[Flip winding order of triangle list.]]
+	.TriStripFlipWinding [[Flip winding order of trinagle strip.]]
+	.TriListToLineList   [[Convert triangle list to line list.]]
+	.TriStripToTriList   [[Convert triangle strip to triangle list.]]
+	.LineStripToLineList [[Convert line strip to line list.]]
+
+--- Topology sort order.
+enum.TopologySort { underscore, comment = "Topology sort order:" , }
+	.DirectionFrontToBackMin
+	.DirectionFrontToBackAvg
+	.DirectionFrontToBackMax
+	.DirectionBackToFrontMin
+	.DirectionBackToFrontAvg
+	.DirectionBackToFrontMax
+	.DistanceFrontToBackMin
+	.DistanceFrontToBackAvg
+	.DistanceFrontToBackMax
+	.DistanceBackToFrontMin
+	.DistanceBackToFrontAvg
+	.DistanceBackToFrontMax
+	()
+
+--- View mode sets draw call sort order.
+enum.ViewMode { underscore, comment = "View modes:" }
+	.Default         [[Default sort order.]]
+	.Sequential      [[Sort in the same order in which submit calls were called.]]
+	.DepthAscending   [[Sort draw call depth in ascending order.]]
+	.DepthDescending  [[Sort draw call depth in descending order.]]
+
+--- Render frame enum.
+enum.RenderFrame { underscore, comment = "" }
+	.NoContext --- Renderer context is not created yet.
+	.Render    --- Renderer context is created and rendering.
+	.Timeout   --- Renderer context wait for main thread signal timed out without rendering.
+	.Exiting   --- Renderer context is getting destroyed.
+	()
+
+--- GPU info.
+struct.GPU  { namespace = "Caps" }
+	.vendorId    "uint16_t"                --- Vendor PCI id. See `BGFX_PCI_ID_*`.
+	.deviceId    "uint16_t"                --- Device id.
+
+--- Renderer capabilities limits.
+struct.Limits  { namespace = "Caps" }
+	.maxDrawCalls            "uint32_t"    --- Maximum number of draw calls.
+	.maxBlits                "uint32_t"    --- Maximum number of blit calls.
+	.maxTextureSize          "uint32_t"    --- Maximum texture size.
+	.maxTextureLayers        "uint32_t"    --- Maximum texture layers.
+	.maxViews                "uint32_t"    --- Maximum number of views.
+	.maxFrameBuffers         "uint32_t"    --- Maximum number of frame buffer handles.
+	.maxFBAttachments        "uint32_t"    --- Maximum number of frame buffer attachments.
+	.maxPrograms             "uint32_t"    --- Maximum number of program handles.
+	.maxShaders              "uint32_t"    --- Maximum number of shader handles.
+	.maxTextures             "uint32_t"    --- Maximum number of texture handles.
+	.maxTextureSamplers      "uint32_t"    --- Maximum number of texture samplers.
+	.maxComputeBindings      "uint32_t"    --- Maximum number of compute bindings.
+	.maxVertexDecls          "uint32_t"    --- Maximum number of vertex format declarations.
+	.maxVertexStreams        "uint32_t"    --- Maximum number of vertex streams.
+	.maxIndexBuffers         "uint32_t"    --- Maximum number of index buffer handles.
+	.maxVertexBuffers        "uint32_t"    --- Maximum number of vertex buffer handles.
+	.maxDynamicIndexBuffers  "uint32_t"    --- Maximum number of dynamic index buffer handles.
+	.maxDynamicVertexBuffers "uint32_t"    --- Maximum number of dynamic vertex buffer handles.
+	.maxUniforms             "uint32_t"    --- Maximum number of uniform handles.
+	.maxOcclusionQueries     "uint32_t"    --- Maximum number of occlusion query handles.
+	.maxEncoders             "uint32_t"    --- Maximum number of encoder threads.
+	.transientVbSize         "uint32_t"    --- Maximum transient vertex buffer size.
+	.transientIbSize         "uint32_t"    --- Maximum transient index buffer size.
+
+--- Renderer capabilities.
+struct.Caps
+	.rendererType "RendererType::Enum" --- Renderer backend type. See: `bgfx::RendererType`
+	.supported    "uint64_t"           --- Supported functionality.
+	                                   ---   @attention See BGFX_CAPS_* flags at https://bkaradzic.github.io/bgfx/bgfx.html#available-caps
+	.vendorId     "uint16_t"           --- Selected GPU vendor PCI id.
+	.deviceId     "uint16_t"           --- Selected GPU device id.
+	.homogeneousDepth "bool"           --- True when NDC depth is in [-1, 1] range, otherwise its [0, 1].
+	.originBottomLeft "bool"           --- True when NDC origin is at bottom left.
+	.numGPUs      "uint8_t"            --- Number of enumerated GPUs.
+	.gpu          "GPU[4]"             --- Enumerated GPUs.
+	.limits       "Limits"
+	.formats      "uint16_t[TextureFormat::Count]"
+		--- 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.
+		---   - `BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED` - Texture format is emulated.
+		---   - `BGFX_CAPS_FORMAT_TEXTURE_3D` - Texture format is supported.
+		---   - `BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB` - Texture as sRGB format is supported.
+		---   - `BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED` - Texture format is emulated.
+		---   - `BGFX_CAPS_FORMAT_TEXTURE_CUBE` - Texture format is supported.
+		---   - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB` - Texture as sRGB format is supported.
+		---   - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED` - Texture format is emulated.
+		---   - `BGFX_CAPS_FORMAT_TEXTURE_VERTEX` - Texture format can be used from vertex shader.
+		---   - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE` - Texture format can be used as image from compute
+		---     shader.
+		---   - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER` - Texture format can be used as frame
+		---     buffer.
+		---   - `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.
+
+--- Internal data.
+struct.InternalData
+	.caps    "const Caps*" --- Renderer capabilities.
+	.context "void*"              --- GL context, or D3D device.
+
+--- Platform data.
+struct.PlatformData { ctor }
+	.ndt          "void*" --- Native display type.
+	.nwh          "void*" --- Native window handle.
+	.context      "void*" --- GL context, or D3D device.
+	.backBuffer   "void*" --- GL backbuffer, or D3D render target view.
+	.backBufferDS "void*" --- Backbuffer depth/stencil.
+
+--- Backbuffer resolution and reset parameters.
+struct.Resolution { ctor }
+	.format          "TextureFormat::Enum" --- Backbuffer format.
+	.width           "uint32_t"            --- Backbuffer width.
+	.height          "uint32_t"            --- Backbuffer height.
+	.reset           "uint32_t"            --- Reset parameters.
+	.numBackBuffers  "uint8_t"             --- Number of back buffers.
+	.maxFrameLatency "uint8_t"             --- Maximum frame latency.
+
+struct.Limits { namespace = "Init" }
+	.maxEncoders    "uint16_t"             --- Maximum number of encoder threads.
+	.transientVbSize "uint32_t"            --- Maximum transient vertex buffer size.
+	.transientIbSize "uint32_t"            --- Maximum transient index buffer size.
+
+--- Initialization parameters used by `bgfx::init`.
+struct.Init { ctor }
+	.type            "RendererType::Enum"  --- Select rendering backend. When set to RendererType::Count
+	                                       --- a default rendering backend will be selected appropriate to the platform.
+	                                       --- See: `bgfx::RendererType`
+
+	.vendorId       "uint16_t"             --- Vendor PCI id. If set to `BGFX_PCI_ID_NONE` it will select the first
+	                                       --- device.
+	                                       ---   - `BGFX_PCI_ID_NONE` - Autoselect adapter.
+	                                       ---   - `BGFX_PCI_ID_SOFTWARE_RASTERIZER` - Software rasterizer.
+	                                       ---   - `BGFX_PCI_ID_AMD` - AMD adapter.
+	                                       ---   - `BGFX_PCI_ID_INTEL` - Intel adapter.
+	                                       ---   - `BGFX_PCI_ID_NVIDIA` - nVidia adapter.
+
+	.deviceId       "uint16_t"             --- Device id. If set to 0 it will select first device, or device with
+	                                       --- matching id.
+
+	.debug          "bool"                 --- Enable device for debuging.
+	.profile        "bool"                 --- Enable device for profiling.
+	.platformData   "PlatformData"         --- Platform data.
+	.resolution     "Resolution"           --- Backbuffer resolution and reset parameters. See: `bgfx::Resolution`.
+	.limits         "Limits"
+	.callback       "CallbackI*"           --- Provide application specific callback interface.
+	                                       --- See: `bgfx::CallbackI`
+
+	.allocator      "bx::AllocatorI*"      --- Custom allocator. When a custom allocator is not
+	                                       --- specified, bgfx uses the CRT allocator. Bgfx assumes
+	                                       --- custom allocator is thread safe.
+
+--- Memory must be obtained by calling `bgfx::alloc`, `bgfx::copy`, or `bgfx::makeRef`.
+---
+--- @attention It is illegal to create this structure on stack and pass it to any bgfx API.
+struct.Memory
+	.data "uint8_t*" [[Pointer to data.]]
+	.size "uint32_t" [[Data size.]]
+
+--- Transient index buffer.
+struct.TransientIndexBuffer
+	.data       "int8_t*"           --- Pointer to data.
+	.size       "uint32_t"          --- Data size.
+	.startIndex "uint32_t"          --- First index.
+	.handle     "IndexBufferHandle" --- Index buffer handle.
+
+--- Transient vertex buffer.
+struct.TransientVertexBuffer
+	.data        "int8_t*"            --- Pointer to data.
+	.size        "uint32_t"           --- Data size.
+	.startVertex "uint32_t"           --- First vertex.
+	.stride      "uint16_t"           --- Vertex stride.
+	.handle      "VertexBufferHandle" --- Vertex buffer handle.
+	.decl        "VertexDeclHandle"   --- Vertex declaration handle.
+
+--- Instance data buffer info.
+struct.InstanceDataBuffer
+	.data   "int8_t*"            --- Pointer to data.
+	.size   "uint32_t"           --- Data size.
+	.offset "uint32_t"           --- Offset in vertex buffer.
+	.num    "uint32_t"           --- Number of instances.
+	.stride "uint16_t"           --- Vertex buffer stride.
+	.handle "VertexBufferHandle" --- Vertex buffer object handle.
+
+--- Texture info.
+struct.TextureInfo
+	.format       "TextureFormat::Enum" --- Texture format.
+	.storageSize  "uint32_t"            --- Total amount of bytes required to store texture.
+	.width        "uint16_t"            --- Texture width.
+	.height       "uint16_t"            --- Texture height.
+	.depth        "uint16_t"            --- Texture depth.
+	.numLayers    "uint16_t"            --- Number of layers in texture array.
+	.numMips      "uint8_t"             --- Number of MIP maps.
+	.bitsPerPixel "uint8_t"             --- Format bits per pixel.
+	.cubeMap      "bool"                --- Texture is cubemap.
+
+--- Uniform info.
+struct.UniformInfo
+	.name "char[256]"         --- Uniform name.
+	.type "UniformType::Enum" --- Uniform type.
+	.num  "uint16_t"          --- Number of elements in array.
+
+--- Frame buffer texture attachment info.
+struct.Attachment
+	.access  "Access::Enum"  --- Attachement access. See `Access::Enum`.
+	.handle  "TextureHandle" --- Render target texture handle.
+	.mip     "uint16_t"      --- Mip level.
+	.layer   "uint16_t"      --- Cubemap side or depth layer/slice.
+	.resolve "uint8_t"       --- Resolve flags. See: `BGFX_RESOLVE_*`
+
+--- Init attachment.
+func.Attachment.init
+	"void"
+	.handle "TextureHandle" --- Render target texture handle.
+	.access "Access::Enum"  --- Access. See `Access::Enum`.
+	 { default = "Access::Write" }
+	.layer "uint16_t"       --- Cubemap side or depth layer/slice.
+	 { default = 0 }
+	.mip "uint16_t"         --- Mip level.
+	 { default = 0 }
+	.resolve "uint8_t"      --- Resolve flags. See: `BGFX_RESOLVE_*`
+	 { default = "BGFX_RESOLVE_AUTO_GEN_MIPS" }
+
+--- Transform data.
+struct.Transform
+	.data "float*"  --- Pointer to first 4x4 matrix.
+	.num "uint16_t" --- Number of matrices.
+
+--- View stats.
+struct.ViewStats
+	.name           "char[256]" --- View name.
+	.view           "ViewId"    --- View id.
+	.cpuTimeElapsed "int64_t"   --- CPU (submit) time elapsed.
+	.gpuTimeElapsed "int64_t"   --- GPU time elapsed.
+
+--- Encoder stats.
+struct.EncoderStats
+	.cpuTimeBegin "int64_t" --- Encoder thread CPU submit begin time.
+	.cpuTimeEnd   "int64_t" --- Encoder thread CPU submit end time.
+
+--- Renderer statistics data.
+---
+--- @remarks All time values are high-resolution timestamps, while
+--- time frequencies define timestamps-per-second for that hardware.
+struct.Stats
+	.cpuTimeFrame            "int64_t"       --- CPU time between two `bgfx::frame` calls.
+	.cpuTimeBegin            "int64_t"       --- Render thread CPU submit begin time.
+	.cpuTimeEnd              "int64_t"       --- Render thread CPU submit end time.
+	.cpuTimerFreq            "int64_t"       --- CPU timer frequency. Timestamps-per-second
+
+	.gpuTimeBegin            "int64_t"       --- GPU frame begin time.
+	.gpuTimeEnd              "int64_t"       --- GPU frame end time.
+	.gpuTimerFreq            "int64_t"       --- GPU timer frequency.
+
+	.waitRender              "int64_t"       --- Time spent waiting for render backend thread to finish issuing draw commands to underlying graphics API.
+	.waitSubmit              "int64_t"       --- Time spent waiting for submit thread to advance to next frame.
+
+	.numDraw                 "uint32_t"      --- Number of draw calls submitted.
+	.numCompute              "uint32_t"      --- Number of compute calls submitted.
+	.numBlit                 "uint32_t"      --- Number of blit calls submitted.
+	.maxGpuLatency           "uint32_t"      --- GPU driver latency.
+
+	.numDynamicIndexBuffers  "uint16_t"      --- Number of used dynamic index buffers.
+	.numDynamicVertexBuffers "uint16_t"      --- Number of used dynamic vertex buffers.
+	.numFrameBuffers         "uint16_t"      --- Number of used frame buffers.
+	.numIndexBuffers         "uint16_t"      --- Number of used index buffers.
+	.numOcclusionQueries     "uint16_t"      --- Number of used occlusion queries.
+	.numPrograms             "uint16_t"      --- Number of used programs.
+	.numShaders              "uint16_t"      --- Number of used shaders.
+	.numTextures             "uint16_t"      --- Number of used textures.
+	.numUniforms             "uint16_t"      --- Number of used uniforms.
+	.numVertexBuffers        "uint16_t"      --- Number of used vertex buffers.
+	.numVertexDecls          "uint16_t"      --- Number of used vertex declarations.
+
+	.textureMemoryUsed       "int64_t"       --- Estimate of texture memory used.
+	.rtMemoryUsed            "int64_t"       --- Estimate of render target memory used.
+	.transientVbUsed         "int32_t"       --- Amount of transient vertex buffer used.
+	.transientIbUsed         "int32_t"       --- Amount of transient index buffer used.
+
+	.numPrims                "uint32_t[Topology::Count]" --- Number of primitives rendered.
+
+	.gpuMemoryMax            "int64_t"       --- Maximum available GPU memory for application.
+	.gpuMemoryUsed           "int64_t"       --- Amount of GPU memory used by the application.
+
+	.width                   "uint16_t"      --- Backbuffer width in pixels.
+	.height                  "uint16_t"      --- Backbuffer height in pixels.
+	.textWidth               "uint16_t"      --- Debug text width in characters.
+	.textHeight              "uint16_t"      --- Debug text height in characters.
+
+	.numViews                "uint16_t"      --- Number of view stats.
+	.viewStats               "ViewStats*"    --- Array of View stats.
+
+	.numEncoders             "uint8_t"       --- Number of encoders used during frame.
+	.encoderStats            "EncoderStats*" --- Array of encoder stats.
+
+--- Vertex declaration.
+struct.VertexDecl { ctor }
+	.hash       "uint32_t"                --- Hash.
+	.stride     "uint16_t"                --- Stride.
+	.offset     "uint16_t[Attrib::Count]" --- Attribute offsets.
+	.attributes "uint16_t[Attrib::Count]" --- Used attributes.
+
+--- Encoders are used for submitting draw calls from multiple threads. Only one encoder
+--- per thread should be used. Use `bgfx::begin()` to obtain an encoder for a thread.
+struct.Encoder {}
+
+handle "DynamicIndexBufferHandle"
+handle "DynamicVertexBufferHandle"
+handle "FrameBufferHandle"
+handle "IndexBufferHandle"
+handle "IndirectBufferHandle"
+handle "OcclusionQueryHandle"
+handle "ProgramHandle"
+handle "ShaderHandle"
+handle "TextureHandle"
+handle "UniformHandle"
+handle "VertexBufferHandle"
+handle "VertexDeclHandle"
+
+--- Start VertexDecl.
 func.VertexDecl.begin
 	"void"
-	.renderer        "RendererType::Enum"
+	.rendererType    "RendererType::Enum"
 
+--- Add attribute to VertexDecl.
+---
+--- @remarks Must be called between begin/end.
+---
 func.VertexDecl.add
 	"void"
-	.attrib          "Attrib::Enum"
-	.num             "uint8_t"
-	.type            "AttribType::Enum"
-	.normalized      "bool"
-	.asInt           "bool"
-
+	.attrib          "Attrib::Enum"     --- Attribute semantics. See: `bgfx::Attrib`
+	.num             "uint8_t"          --- Number of elements 1, 2, 3 or 4.
+	.type            "AttribType::Enum" --- Element type.
+	.normalized      "bool"             --- When using fixed point AttribType (f.e. Uint8)
+	 { default = false }                --- 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.
+	.asInt           "bool"             --- Packaging rule for vertexPack, vertexUnpack, and
+	 { default = false }                --- vertexConvert for AttribType::Uint8 and AttribType::Int16.
+	                                    --- Unpacking code must be implemented inside vertex shader.
+
+--- Decode attribute.
 func.VertexDecl.decode { const }
 	"void"
-	.attrib          "Attrib::Enum"
-	.num             "uint8_t &"          { out }
-	.type            "AttribType::Enum &" { out }
-	.normalized      "bool &"             { out }
-	.asInt           "bool &"             { out }
+	.attrib     "Attrib::Enum"               --- Attribute semantics. See: `bgfx::Attrib`
+	.num        "uint8_t &"          { out } --- Number of elements.
+	.type       "AttribType::Enum &" { out } --- Element type.
+	.normalized "bool &"             { out } --- Attribute is normalized.
+	.asInt      "bool &"             { out } --- Attribute is packed as int.
 
+--- Returns true if VertexDecl contains attribute.
 func.VertexDecl.has { const }
 	"bool"
-	.attrib          "Attrib::Enum"
+	.attrib "Attrib::Enum" --- Attribute semantics. See: `bgfx::Attrib`
 
+--- Skip `_num` bytes in vertex stream.
 func.VertexDecl.skip
 	"void"
-	.num             "uint8_t"
+	.num "uint8_t"
 
--- Notice: `end` is a keyword in lua
+-- Notice: `end` is a keyword in lua.
+--- End VertexDecl.
 func.VertexDecl["end"]
 	"void"
 
+--- Returns relative attribute offset from the vertex.
+func.VertexDecl.getOffset { const , cpponly }
+	"uint16_t"
+	.attrib    "Attrib::Enum" --- Attribute semantics. See: `bgfx::Attrib`
+
+--- Returns vertex stride.
+func.VertexDecl.getStride { const , cpponly }
+	"uint16_t"
+
+--- Returns size of vertex buffer for number of vertices.
+func.VertexDecl.getSize { const, cpponly }
+	"uint32_t"
+	.num       "uint32_t"
+
+--- Pack vertex attribute into vertex stream format.
 func.vertexPack
 	"void"
-	.input           "const float *"
-	.inputNormalized "bool"
-	.attr            "Attrib::Enum"
-	.decl            "const VertexDecl &"
-	.data            "void *"
-	.index           "uint32_t"
+	.input           "const float[4]"     --- Value to be packed into vertex stream.
+	.inputNormalized "bool"               --- `true` if input value is already normalized.
+	.attr            "Attrib::Enum"       --- Attribute to pack.
+	.decl            "const VertexDecl &" --- Vertex stream declaration.
+	.data            "void*"              --- Destination vertex stream where data will be packed.
+	.index           "uint32_t"           --- Vertex index that will be modified.
+	 { default = 0 }
 
+--- Unpack vertex attribute from vertex stream format.
 func.vertexUnpack
 	"void"
-	.output          "float *" { out }
-	.attr            "Attrib::Enum"
-	.decl            "const VertexDecl &"
-	.data            "const void *"
-	.index           "uint32_t"
+	.output "float[4]" { out }   --- Result of unpacking.
+	.attr   "Attrib::Enum"       --- Attribute to unpack.
+	.decl   "const VertexDecl &" --- Vertex stream declaration.
+	.data   "const void*"        --- Source vertex stream from where data will be unpacked.
+	.index  "uint32_t"           --- Vertex index that will be unpacked.
+	 { default = 0 }
 
+--- Converts vertex stream data from one vertex stream format to another.
 func.vertexConvert
 	"void"
-	.dstDecl "const VertexDecl &"
-	.dstData "void *"
-	.srcDecl "const VertexDecl &"
-	.srcData "const void *"
-	.num     "uint32_t"
+	.dstDecl "const VertexDecl &" --- Destination vertex stream declaration.
+	.dstData "void*"              --- Destination vertex stream.
+	.srcDecl "const VertexDecl &" --- Source vertex stream declaration.
+	.srcData "const void*"        --- Source vertex stream data.
+	.num     "uint32_t"           --- Number of vertices to convert from source to destination.
+	 { default = 1 }
 
+--- Weld vertices.
 func.weldVertices
-	"uint16_t"
-	.output  "uint16_t *"
-	.decl    "const VertexDecl &"
-	.data    "const void *"
-	.num     "uint16_t"
-	.epsilon "float"
-
+	"uint16_t"                    --- Number of unique vertices after vertex welding.
+	.output  "uint16_t*"          --- Welded vertices remapping table. The size of buffer
+	                              --- must be the same as number of vertices.
+	.decl    "const VertexDecl &" --- Vertex stream declaration.
+	.data    "const void*"        --- Vertex stream.
+	.num     "uint16_t"           --- Number of vertices in vertex stream.
+	.epsilon "float"              --- Error tolerance for vertex position comparison.
+	 { default = "0.001f" }
+
+--- Convert index buffer for use with different primitive topologies.
 func.topologyConvert
-	"uint32_t"
-	.conversion "TopologyConvert::Enum"
-	.dst        "void *" { out }
-	.dstSize    "uint32_t"
-	.indices    "const void *"
-	.numIndices "uint32_t"
-	.index32    "bool"
-
+	"uint32_t"                          --- Number of output indices after conversion.
+	.conversion "TopologyConvert::Enum" --- Conversion type, see `TopologyConvert::Enum`.
+	.dst        "void*" { out }         --- Destination index buffer. If this argument is NULL
+	                                    --- function will return number of indices after conversion.
+	.dstSize    "uint32_t"              --- Destination index buffer in bytes. It must be
+	                                    --- large enough to contain output indices. If destination size is
+	                                    --- insufficient index buffer will be truncated.
+	.indices    "const void*"           --- Source indices.
+	.numIndices "uint32_t"              --- Number of input indices.
+	.index32    "bool"                  --- Set to `true` if input indices are 32-bit.
+
+--- Sort indices.
 func.topologySortTriList
 	"void"
-	.sort       "TopologySort::Enum"
-	.dst        "void *" { out }
-	.dstSize    "uint32_t"
-	.dir        "const float *"
-	.pos        "const float *"
-	.vertices   "const void *"
-	.stride     "uint32_t"
-	.indices    "const void *"
-	.numIndices "uint32_t"
-	.index32    "bool"
-
+	.sort       "TopologySort::Enum" --- Sort order, see `TopologySort::Enum`.
+	.dst        "void*" { out }      --- Destination index buffer.
+	.dstSize    "uint32_t"           --- Destination index buffer in bytes. It must be
+	                                 --- large enough to contain output indices. If destination size is
+	                                 --- insufficient index buffer will be truncated.
+	.dir        "const float[3]"     --- Direction (vector must be normalized).
+	.pos        "const float[3]"     --- Position.
+	.vertices   "const void*"        --- Pointer to first vertex represented as
+	                                 --- float x, y, z. Must contain at least number of vertices
+	                                 --- referencende by index buffer.
+	.stride     "uint32_t"           --- Vertex stride.
+	.indices    "const void*"        --- Source indices.
+	.numIndices "uint32_t"           --- Number of input indices.
+	.index32    "bool"               --- Set to `true` if input indices are 32-bit.
+
+--- Returns supported backend API renderers.
 func.getSupportedRenderers
-	"uint8_t"
-	.max  "uint8_t"
-	.enum "RendererType::Enum *" { out }
+	"uint8_t"                             --- Number of supported renderers.
+	.max  "uint8_t"                       --- Maximum number of elements in _enum array.
+	 { default = 0 }
+	.enum "RendererType::Enum*" { inout } --- Array where supported renderers will be written.
+	 { default = NULL }
 
+--- Returns name of renderer.
 func.getRendererName
-	"const char *"
-	.type "RendererType::Enum"
-
-local init_ctor = [[
-	BX_PLACEMENT_NEW(_init, bgfx::Init);
-]]
-func.initCtor { cfunc = init_ctor }
-	"void"
-	.init "Init *"
-
-local init = [[
-	bgfx_init_t init = *_init;
-
-	if (init.callback != NULL)
-	{
-		static bgfx::CallbackC99 s_callback;
-		s_callback.m_interface = init.callback;
-		init.callback = reinterpret_cast<bgfx_callback_interface_t *>(&s_callback);
-	}
-
-	if (init.allocator != NULL)
-	{
-		static bgfx::AllocatorC99 s_allocator;
-		s_allocator.m_interface = init.allocator;
-		init.allocator = reinterpret_cast<bgfx_allocator_interface_t *>(&s_allocator);
-	}
-
-	union { const bgfx_init_t* c; const bgfx::Init* cpp; } in;
-	in.c = &init;
-
-	return bgfx::init(*in.cpp);
-]]
-func.init { cfunc = init }
-	"bool"
-	.init "const Init &"
+	"const char*"              --- Name of renderer.
+	.type "RendererType::Enum" --- Renderer backend type. See: `bgfx::RendererType`
 
+func.initCtor { cfunc }
+	"void"
+	.init "Init*"
+
+--- Initialize bgfx library.
+func.init { cfunc }
+	"bool"               --- `true` if initialization was successful.
+	.init "const Init &" --- Initialization parameters. See: `bgfx::Init` for more info.
+
+--- Shutdown bgfx library.
 func.shutdown
 	"void"
 
+--- Reset graphic settings and back-buffer size.
+---
+--- @attention This call doesn't actually change window size, it just
+---   resizes back-buffer. Windowing code has to change window size.
+---
 func.reset
 	"void"
-	.width  "uint32_t"
-	.height "uint32_t"
-	.flags  "uint32_t"
-	.format "TextureFormat::Enum"
-
+	.width  "uint32_t"               --- Back-buffer width.
+	.height "uint32_t"               --- Back-buffer height.
+	.flags  "uint32_t"               --- See: `BGFX_RESET_*` for more info.
+	 { default = "BGFX_RESET_NONE" } ---   - `BGFX_RESET_NONE` - No reset flags.
+	                                 ---   - `BGFX_RESET_FULLSCREEN` - Not supported yet.
+	                                 ---   - `BGFX_RESET_MSAA_X[2/4/8/16]` - Enable 2, 4, 8 or 16 x MSAA.
+	                                 ---   - `BGFX_RESET_VSYNC` - Enable V-Sync.
+	                                 ---   - `BGFX_RESET_MAXANISOTROPY` - Turn on/off max anisotropy.
+	                                 ---   - `BGFX_RESET_CAPTURE` - Begin screen capture.
+	                                 ---   - `BGFX_RESET_FLUSH_AFTER_RENDER` - Flush rendering after submitting to GPU.
+	                                 ---   - `BGFX_RESET_FLIP_AFTER_RENDER` - This flag  specifies where flip
+	                                 ---     occurs. Default behavior is that flip occurs before rendering new
+	                                 ---     frame. This flag only has effect when `BGFX_CONFIG_MULTITHREADED=0`.
+	                                 ---   - `BGFX_RESET_SRGB_BACKBUFFER` - Enable sRGB backbuffer.
+	.format "TextureFormat::Enum"    --- Texture format. See: `TextureFormat::Enum`.
+	 { default = "TextureFormat::Count" }
+
+--- Advance to next frame. When using multithreaded renderer, this call
+--- just swaps internal buffers, kicks render thread, and returns. In
+--- singlethreaded renderer this call does frame rendering.
 func.frame
-	"uint32_t"
-	.capture "bool"
-
+	"uint32_t"      --- Current frame number. This might be used in conjunction with
+	                --- double/multi buffering data outside the library and passing it to
+	                --- library via `bgfx::makeRef` calls.
+	.capture "bool" --- Capture frame with graphics debugger.
+	 { default = false }
+
+--- Returns current renderer backend API type.
+---
+--- @remarks
+---   Library must be initialized.
+---
 func.getRendererType
-	"RendererType::Enum"
+	"RendererType::Enum" --- Renderer backend type. See: `bgfx::RendererType`
 
+--- Returns renderer capabilities.
+---
+--- @remarks
+---   Library must be initialized.
+---
 func.getCaps
-	"const Caps *"
+	"const Caps*" --- Pointer to static `bgfx::Caps` structure.
 
+--- Returns performance counters.
+---
+--- @attention Pointer returned is valid until `bgfx::frame` is called.
+---
 func.getStats
-	"const Stats *"
+	"const Stats*" -- Performance counters.
 
+--- Allocate buffer to pass to bgfx calls. Data will be freed inside bgfx.
 func.alloc
-	"const Memory *"
-	.size "uint32_t"
+	"const Memory*"  --- Allocated memory.
+	.size "uint32_t" --- Size to allocate.
 
+--- Allocate buffer and copy data into it. Data will be freed inside bgfx.
 func.copy
-	"const Memory *"
-	.data "const void *"
-	.size "uint32_t"
-
-func.makeRef
-	"const Memory *"
-	.data "const void *"
-	.size "uint32_t"
-
+	"const Memory*"     --- Allocated memory.
+	.data "const void*" --- Pointer to data to be copied.
+	.size "uint32_t"    --- Size of data to be copied.
+
+--- 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.
+---
+--- @attention Data passed must be available for at least 2 `bgfx::frame` calls.
+---
+func.makeRef { conly }
+	"const Memory*"     --- Referenced memory.
+	.data "const void*" --- Pointer to data.
+	.size "uint32_t"    --- Size of data.
+
+--- 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.
+---
+--- @attention Data passed must be available for at least 2 `bgfx::frame` calls.
+---
 func.makeRef { cname = "make_ref_release" }
-	"const Memory *"
-	.data      "const void *"
-	.size      "uint32_t"
-	.releaseFn "ReleaseFn"
-	.userData  "void *"
-
+	"const Memory*"          --- Referenced memory.
+	.data      "const void*" --- Pointer to data.
+	.size      "uint32_t"    --- Size of data.
+	.releaseFn "ReleaseFn"   --- Callback function to release memory after use.
+	 { default = NULL }
+	.userData  "void*"       --- User data to be passed to callback function.
+	 { default = NULL }
+
+--- Set debug flags.
 func.setDebug
 	"void"
-	.debug "uint32_t"
-
+	.debug "uint32_t" --- Available flags:
+	                  ---   - `BGFX_DEBUG_IFH` - Infinitely fast hardware. When this flag is set
+	                  ---     all rendering calls will be skipped. This is useful when profiling
+	                  ---     to quickly assess potential bottlenecks between CPU and GPU.
+	                  ---   - `BGFX_DEBUG_PROFILER` - Enable profiler.
+	                  ---   - `BGFX_DEBUG_STATS` - Display internal statistics.
+	                  ---   - `BGFX_DEBUG_TEXT` - Display debug text.
+	                  ---   - `BGFX_DEBUG_WIREFRAME` - Wireframe rendering. All rendering
+	                  ---     primitives will be rendered as lines.
+
+--- Clear internal debug text buffer.
 func.dbgTextClear
 	"void"
-	.attr  "uint8_t"
-	.small "bool"
+	.attr  "uint8_t" --- Background color.
+	 { default = 0 }
+	.small "bool"    --- Default or 8x8 font.
+	 { dafault = false }
 
+--- Print formatted data to internal debug text character-buffer (VGA-compatible text mode).
 func.dbgTextPrintf { vararg = "dbgTextPrintfVargs" }
 	"void"
-	.x      "uint16_t"
-	.y      "uint16_t"
-	.attr   "uint8_t"
-	.format "const char *"
+	.x      "uint16_t"    --- Position x from the left corner of the window.
+	.y      "uint16_t"    --- Position y from the top corner of the window.
+	.attr   "uint8_t"     --- Color palette. Where top 4-bits represent index of background, and bottom
+	                      --- 4-bits represent foreground color from standard VGA text palette (ANSI escape codes).
+	.format "const char*" --- `printf` style format.
 
+--- Print formatted data from variable argument list to internal debug text character-buffer (VGA-compatible text mode).
 func.dbgTextPrintfVargs { cname = "dbg_text_vprintf" }
 	"void"
-	.x       "uint16_t"
-	.y       "uint16_t"
-	.attr    "uint8_t"
-	.format  "const char *"
-	.argList "va_list"
+	.x       "uint16_t"    --- Position x from the left corner of the window.
+	.y       "uint16_t"    --- Position y from the top corner of the window.
+	.attr    "uint8_t"     --- Color palette. Where top 4-bits represent index of background, and bottom
+                           --- 4-bits represent foreground color from standard VGA text palette (ANSI escape codes).
+	.format  "const char*" --- `printf` style format.
+	.argList "va_list"     --- Variable arguments list for format string.
 
+--- Draw image into internal debug text buffer.
 func.dbgTextImage
 	"void"
-	.x       "uint16_t"
-	.y       "uint16_t"
-	.width   "uint16_t"
-	.height  "uint16_t"
-	.data    "const void *"
-	.pitch   "uint16_t"
+	.x       "uint16_t"    --- Position x from the left corner of the window.
+	.y       "uint16_t"    --- Position y from the top corner of the window.
+	.width   "uint16_t"    --- Image width.
+	.height  "uint16_t"    --- Image height.
+	.data    "const void*" --- Raw image data (character/attribute raw encoding).
+	.pitch   "uint16_t"    --- Image pitch in bytes.
 
+--- Create static index buffer.
 func.createIndexBuffer
 	"IndexBufferHandle"
-	.mem   "const Memory *"
-	.flags "uint16_t"
-
+	.mem   "const Memory*"            --- Index buffer data.
+	.flags "uint16_t"                 --- Buffer creation flags.
+	 { default = "BGFX_BUFFER_NONE" } ---   - `BGFX_BUFFER_NONE` - No flags.
+	                                  ---   - `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.
+
+--- Set static index buffer debug name.
 func.setName { cname = "set_index_buffer_name" }
 	"void"
-	.handle "IndexBufferHandle"
-	.name   "const char *"
-	.len    "int32_t"
+	.handle "IndexBufferHandle" --- Static index buffer handle.
+	.name   "const char*"       --- Static index buffer name.
+	.len    "int32_t"           --- Static index buffer name length (if length is INT32_MAX, it's expected
+	 { default = INT32_MAX }    --- that _name is zero terminated string.
 
+--- Destroy static index buffer.
 func.destroy { cname = "destroy_index_buffer" }
 	"void"
-	.handle "IndexBufferHandle"
+	.handle "IndexBufferHandle" --- Static index buffer handle.
 
+--- Create static vertex buffer.
 func.createVertexBuffer
-	"VertexBufferHandle"
-	.mem   "const Memory *"
-	.decl  "const VertexDecl &"
-	.flags "uint16_t"
-
+	"VertexBufferHandle"              --- Static vertex buffer handle.
+	.mem   "const Memory*"            --- Vertex buffer data.
+	.decl  "const VertexDecl &"       --- Vertex declaration.
+	.flags "uint16_t"                 --- Buffer creation flags.
+	 { default = "BGFX_BUFFER_NONE" } ---  - `BGFX_BUFFER_NONE` - No flags.
+	                                  ---  - `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.
+
+--- Set static vertex buffer debug name.
 func.setName { cname = "set_vertex_buffer_name" }
 	"void"
-	.handle "VertexBufferHandle"
-	.name   "const char *"
-	.len    "int32_t"
+	.handle "VertexBufferHandle" --- Static vertex buffer handle.
+	.name   "const char*"        --- Static vertex buffer name.
+	.len    "int32_t"            --- Static vertex buffer name length (if length is INT32_MAX, it's expected
+	 { default = INT32_MAX }     --- that _name is zero terminated string.
 
+--- Destroy static vertex buffer.
 func.destroy { cname = "destroy_vertex_buffer" }
 	"void"
-	.handle "VertexBufferHandle"
+	.handle "VertexBufferHandle" --- Static vertex buffer handle.
 
+--- Create empty dynamic index buffer.
 func.createDynamicIndexBuffer
-	"DynamicIndexBufferHandle"
-	.num   "uint32_t"
-	.flags "uint16_t"
-
+	"DynamicIndexBufferHandle"        --- Dynamic index buffer handle.
+	.num   "uint32_t"                 --- Number of indices.
+	.flags "uint16_t"                 --- Buffer creation flags.
+	 { default = "BGFX_BUFFER_NONE" } ---   - `BGFX_BUFFER_NONE` - No flags.
+	                                  ---   - `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.
+
+--- Create dynamic index buffer and initialized it.
 func.createDynamicIndexBuffer { cname = "create_dynamic_index_buffer_mem" }
-	"DynamicIndexBufferHandle"
-	.mem   "const Memory *"
-	.flags "uint16_t"
-
+	"DynamicIndexBufferHandle"        --- Dynamic index buffer handle.
+	.mem   "const Memory*"            --- Index buffer data.
+	.flags "uint16_t"                 --- Buffer creation flags.
+	 { default = "BGFX_BUFFER_NONE" } ---   - `BGFX_BUFFER_NONE` - No flags.
+	                                  ---   - `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.
+
+--- Update dynamic index buffer.
 func.update { cname = "update_dynamic_index_buffer" }
 	"void"
-	.handle     "DynamicIndexBufferHandle"
-	.startIndex "uint32_t"
-	.mem        "const Memory *"
+	.handle     "DynamicIndexBufferHandle" --- Dynamic index buffer handle.
+	.startIndex "uint32_t"                 --- Start index.
+	.mem        "const Memory*"            --- Index buffer data.
 
+--- Destroy dynamic index buffer.
 func.destroy { cname = "destroy_dynamic_index_buffer" }
 	"void"
-	.handle "DynamicIndexBufferHandle"
+	.handle "DynamicIndexBufferHandle" --- Dynamic index buffer handle.
 
+--- Create empty dynamic vertex buffer.
 func.createDynamicVertexBuffer
-	"DynamicVertexBufferHandle"
-	.num   "uint32_t"
-	.decl  "const VertexDecl &"
-	.flags "uint16_t"
-
+	"DynamicVertexBufferHandle"       --- Dynamic vertex buffer handle.
+	.num   "uint32_t"                 --- Number of vertices.
+	.decl  "const VertexDecl&"        --- Vertex declaration.
+	.flags "uint16_t"                 --- Buffer creation flags.
+	 { default = "BGFX_BUFFER_NONE" } ---   - `BGFX_BUFFER_NONE` - No flags.
+	                                  ---   - `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.
+
+--- Create dynamic vertex buffer and initialize it.
 func.createDynamicVertexBuffer { cname = "create_dynamic_vertex_buffer_mem" }
-	"DynamicVertexBufferHandle"
-	.mem   "const Memory *"
-	.decl  "const VertexDecl &"
-	.flags "uint16_t"
-
+	"DynamicVertexBufferHandle"       --- Dynamic vertex buffer handle.
+	.mem   "const Memory*"            --- Vertex buffer data.
+	.decl  "const VertexDecl&"        --- Vertex declaration.
+	.flags "uint16_t"                 --- Buffer creation flags.
+	 { default = "BGFX_BUFFER_NONE" } ---   - `BGFX_BUFFER_NONE` - No flags.
+	                                  ---   - `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.
+
+--- Update dynamic vertex buffer.
 func.update { cname = "update_dynamic_vertex_buffer" }
 	"void"
-	.handle      "DynamicVertexBufferHandle"
-	.startVertex "uint32_t"
-	.mem         "const Memory *"
+	.handle      "DynamicVertexBufferHandle" --- Dynamic vertex buffer handle.
+	.startVertex "uint32_t"                  --- Start vertex.
+	.mem         "const Memory*"             --- Vertex buffer data.
 
+--- Destroy dynamic vertex buffer.
 func.destroy { cname = "destroy_dynamic_vertex_buffer" }
 	"void"
-	.handle "DynamicVertexBufferHandle"
+	.handle "DynamicVertexBufferHandle" --- Dynamic vertex buffer handle.
 
+--- Returns number of requested or maximum available indices.
 func.getAvailTransientIndexBuffer
-	"uint32_t"
-	.num "uint32_t"
+	"uint32_t"      --- Number of requested or maximum available indices.
+	.num "uint32_t" --- Number of required indices.
 
+--- Returns number of requested or maximum available vertices.
 func.getAvailTransientVertexBuffer
-	"uint32_t"
-	.num "uint32_t"
-	.decl  "const VertexDecl &"
+	"uint32_t"                  --- Number of requested or maximum available vertices.
+	.num "uint32_t"             --- Number of required vertices.
+	.decl  "const VertexDecl &" --- Vertex declaration.
 
+--- Returns number of requested or maximum available instance buffer slots.
 func.getAvailInstanceDataBuffer
-	"uint32_t"
-	.num    "uint32_t"
-	.stride "uint16_t"
-
+	"uint32_t"         --- Number of requested or maximum available instance buffer slots.
+	.num    "uint32_t" --- Number of required instances.
+	.stride "uint16_t" --- Stride per instance.
+
+--- Allocate transient index buffer.
+---
+--- @remarks
+---   Only 16-bit index buffer is supported.
+---
 func.allocTransientIndexBuffer
 	"void"
-	.tib "TransientIndexBuffer *" { out }
-	.num "uint32_t"
+	.tib "TransientIndexBuffer*" { out } --- TransientIndexBuffer structure is filled and is valid
+	                                     --- for the duration of frame, and it can be reused for multiple draw
+	                                     --- calls.
+	.num "uint32_t"                      --- Number of indices to allocate.
 
+--- Allocate transient vertex buffer.
 func.allocTransientVertexBuffer
 	"void"
-	.tvb  "TransientVertexBuffer *" { out }
-	.num  "uint32_t"
-	.decl "const VertexDecl &"
-
+	.tvb  "TransientVertexBuffer*" { out } --- TransientVertexBuffer structure is filled and is valid
+	                                       --- for the duration of frame, and it can be reused for multiple draw
+	                                       --- calls.
+	.num  "uint32_t"                       --- Number of vertices to allocate.
+	.decl "const VertexDecl &"             --- Vertex declaration.
+
+--- Check for required space and allocate transient vertex and index
+--- buffers. If both space requirements are satisfied function returns
+--- true.
+---
+--- @remarks
+---   Only 16-bit index buffer is supported.
+---
 func.allocTransientBuffers
 	"bool"
-	.tvb         "TransientVertexBuffer *" { out }
-	.decl        "const VertexDecl &"
-	.numVertices "uint32_t"
-	.tib         "TransientIndexBuffer *" { out }
-	.numIndices  "uint32_t"
-
+	.tvb         "TransientVertexBuffer*" { out } --- TransientVertexBuffer structure is filled and is valid
+	                                              --- for the duration of frame, and it can be reused for multiple draw
+	                                              --- calls.
+	.decl        "const VertexDecl &"             --- Number of vertices to allocate.
+	.numVertices "uint32_t"                       --- Vertex declaration.
+	.tib         "TransientIndexBuffer*" { out }  --- TransientIndexBuffer structure is filled and is valid
+	                                              --- for the duration of frame, and it can be reused for multiple draw
+	                                              --- calls.
+	.numIndices  "uint32_t"                       --- Number of indices to allocate.
+
+--- Allocate instance data buffer.
 func.allocInstanceDataBuffer
 	"void"
-	.idb    "InstanceDataBuffer *" { out }
-	.num    "uint32_t"
-	.stride "uint16_t"
+	.idb    "InstanceDataBuffer*" { out } --- InstanceDataBuffer structure is filled and is valid
+	                                      --- for duration of frame, and it can be reused for multiple draw
+	                                      --- calls.
+	.num    "uint32_t"                    --- Number of instances.
+	.stride "uint16_t"                    --- Instance stride. Must be multiple of 16.
 
+--- Create draw indirect buffer.
 func.createIndirectBuffer
-	"IndirectBufferHandle"
-	.num "uint32_t"
+	"IndirectBufferHandle" --- Indirect buffer handle.
+	.num "uint32_t"        --- Number of indirect calls.
 
+--- Destroy draw indirect buffer.
 func.destroy { cname = "destroy_indirect_buffer" }
 	"void"
-	.handle "IndirectBufferHandle"
+	.handle "IndirectBufferHandle" --- Indirect buffer handle.
 
+--- Create shader from memory buffer.
 func.createShader
-	"ShaderHandle"
-	.mem "const Memory *"
-
+	"ShaderHandle"       --- Shader handle.
+	.mem "const Memory*" --- Shader binary.
+
+--- Returns the number of uniforms and uniform handles used inside a shader.
+---
+--- @remarks
+---   Only non-predefined uniforms are returned.
+---
 func.getShaderUniforms
-	"uint16_t"
-	.handle   "ShaderHandle"
-	.uniforms "UniformHandle *" { out }
-	.max      "uint16_t"
-
+	"uint16_t"                         --- Number of uniforms used by shader.
+	.handle   "ShaderHandle"           --- Shader handle.
+	.uniforms "UniformHandle*" { out } --- UniformHandle array where data will be stored.
+	 { default = NULL }
+	.max      "uint16_t"               --- Maximum capacity of array.
+	 { default = 0 }
+
+--- Set shader debug name.
 func.setName { cname = "set_shader_name" }
 	"void"
-	.handle "ShaderHandle"
-	.name   "const char *"
-	.len    "int32_t"
+	.handle "ShaderHandle"   --- Shader handle.
+	.name   "const char*"    --- Shader name.
+	.len    "int32_t"        --- Shader name length (if length is INT32_MAX, it's expected
+	 { default = INT32_MAX } --- that _name is zero terminated string).
 
+--- Destroy shader.
+---
+--- @remark Once a shader program is created with _handle,
+---   it is safe to destroy that shader.
+---
 func.destroy { cname = "destroy_shader" }
 	"void"
-	.handle "ShaderHandle"
+	.handle "ShaderHandle" --- Shader handle.
 
+--- Create program with vertex and fragment shaders.
 func.createProgram
-	"ProgramHandle"
-	.vsh "ShaderHandle"
-	.fsh "ShaderHandle"
-	.destroyShaders "bool"
-
+	"ProgramHandle"        --- Program handle if vertex shader output and fragment shader
+	                       --- input are matching, otherwise returns invalid program handle.
+	.vsh "ShaderHandle"    --- Vertex shader.
+	.fsh "ShaderHandle"    --- Fragment shader.
+	.destroyShaders "bool" --- If true, shaders will be destroyed when program is destroyed.
+	 { default = false }
+
+--- Create program with compute shader.
 func.createProgram { cname = "create_compute_program" }
-	"ProgramHandle"
-	.csh "ShaderHandle"
-	.destroyShaders "bool"
+	"ProgramHandle"        --- Program handle.
+	.csh "ShaderHandle"    --- Compute shader.
+	.destroyShaders "bool" --- If true, shaders will be destroyed when program is destroyed.
+	 { default = false }
 
+--- Destroy program.
 func.destroy { cname = "destroy_program" }
 	"void"
-	.handle "ProgramHandle"
+	.handle "ProgramHandle" --- Program handle.
 
+--- Validate texture parameters.
 func.isTextureValid
-	"bool"
-	.depth     "uint16_t"
-	.cubeMap   "bool"
-	.numLayers "uint16_t"
-	.format    "TextureFormat::Enum"
-	.flags     "uint64_t"
-
+	"bool"                           --- True if texture can be successfully created.
+	.depth     "uint16_t"            --- Depth dimension of volume texture.
+	.cubeMap   "bool"                --- Indicates that texture contains cubemap.
+	.numLayers "uint16_t"            --- Number of layers in texture array.
+	.format    "TextureFormat::Enum" --- Texture format. See: `TextureFormat::Enum`.
+	.flags     "uint64_t"            --- Texture flags. See `BGFX_TEXTURE_*`.
+
+--- Calculate amount of memory required for texture.
 func.calcTextureSize
 	"void"
-	.info      "TextureInfo &" { out }
-	.width     "uint16_t"
-	.height    "uint16_t"
-	.depth     "uint16_t"
-	.cubeMap   "bool"
-	.hasMips   "bool"
-	.numLayers "uint16_t"
-	.format    "TextureFormat::Enum"
+	.info      "TextureInfo &" { out } --- Resulting texture info structure. See: `TextureInfo`.
+	.width     "uint16_t"              --- Width.
+	.height    "uint16_t"              --- Height.
+	.depth     "uint16_t"              --- Depth dimension of volume texture.
+	.cubeMap   "bool"                  --- Indicates that texture contains cubemap.
+	.hasMips   "bool"                  --- Indicates that texture contains full mip-map chain.
+	.numLayers "uint16_t"              --- Number of layers in texture array.
+	.format    "TextureFormat::Enum"   --- Texture format. See: `TextureFormat::Enum`.
 
+--- Create texture from memory buffer.
 func.createTexture
-	"TextureHandle"
-	.mem   "const Memory *"
-	.flags "uint64_t"
-	.skip  "uint8_t"
-	.info  "TextureInfo *" { out }
-
+	"TextureHandle"               --- Texture handle.
+	.mem   "const Memory*"        --- DDS, KTX or PVR texture binary data.
+	.flags "uint64_t"             --- Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+	                              --- flags. Default texture sampling mode is linear, and wrap mode is repeat.
+	                              --- - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+	                              ---   mode.
+	                              --- - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+	                              ---   sampling.
+	.skip  "uint8_t"              --- Skip top level mips when parsing texture.
+	.info  "TextureInfo*" { out } --- When non-`NULL` is specified it returns parsed texture information.
+
+--- Create 2D texture.
 func.createTexture2D
-	"TextureHandle"
-	.width     "uint16_t"
-	.height    "uint16_t"
-	.hasMips   "bool"
-	.numLayers "uint16_t"
-	.format    "TextureFormat::Enum"
-	.flags     "uint64_t"
-	.mem       "const Memory *"
-
+	"TextureHandle"                  --- Texture handle.
+	.width     "uint16_t"            --- Width.
+	.height    "uint16_t"            --- Height.
+	.hasMips   "bool"                --- Indicates that texture contains full mip-map chain.
+	.numLayers "uint16_t"            --- Number of layers in texture array. Must be 1 if caps
+	                                 --- `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.
+	.format    "TextureFormat::Enum" --- Texture format. See: `TextureFormat::Enum`.
+	.flags     "uint64_t"            --- Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+	                                 --- flags. Default texture sampling mode is linear, and wrap mode is repeat.
+	                                 --- - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+	                                 ---   mode.
+	                                 --- - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+	                                 ---   sampling.
+	.mem       "const Memory*"       --- 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.
+
+--- Create texture with size based on backbuffer ratio. Texture will maintain ratio
+--- if back buffer resolution changes.
 func.createTexture2D { cname = "create_texture_2d_scaled" }
-	"TextureHandle"
-	.ratio     "BackbufferRatio::Enum"
-	.hasMips   "bool"
-	.numLayers "uint16_t"
-	.format    "TextureFormat::Enum"
-	.flags     "uint64_t"
-
+	"TextureHandle"                    --- Texture handle.
+	.ratio     "BackbufferRatio::Enum" --- Texture size in respect to back-buffer size. See: `BackbufferRatio::Enum`.
+	.hasMips   "bool"                  --- Indicates that texture contains full mip-map chain.
+	.numLayers "uint16_t"              --- Number of layers in texture array. Must be 1 if caps
+	                                   --- `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.
+	.format    "TextureFormat::Enum"   --- Texture format. See: `TextureFormat::Enum`.
+	.flags     "uint64_t"              --- Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+	                                   --- flags. Default texture sampling mode is linear, and wrap mode is repeat.
+	                                   --- - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+	                                   ---   mode.
+	                                   --- - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+	                                   ---   sampling.
+
+--- Create 3D texture.
 func.createTexture3D
-	"TextureHandle"
-	.width     "uint16_t"
-	.height    "uint16_t"
-	.depth     "uint16_t"
-	.hasMips   "bool"
-	.format    "TextureFormat::Enum"
-	.flags     "uint64_t"
-	.mem       "const Memory *"
-
+	"TextureHandle"                  --- Texture handle.
+	.width     "uint16_t"            --- Width.
+	.height    "uint16_t"            --- Height.
+	.depth     "uint16_t"            --- Depth.
+	.hasMips   "bool"                --- Indicates that texture contains full mip-map chain.
+	.format    "TextureFormat::Enum" --- Texture format. See: `TextureFormat::Enum`.
+	.flags     "uint64_t"            --- Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+	                                 --- flags. Default texture sampling mode is linear, and wrap mode is repeat.
+	                                 --- - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+	                                 ---   mode.
+	                                 --- - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+	                                 ---   sampling.
+	.mem       "const Memory*"       --- 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.
+
+--- Create Cube texture.
 func.createTextureCube
-	"TextureHandle"
-	.size      "uint16_t"
-	.hasMips   "bool"
-	.numLayers "uint16_t"
-	.format    "TextureFormat::Enum"
-	.flags     "uint64_t"
-	.mem       "const Memory *"
-
+	"TextureHandle"                  --- Texture handle.
+	.size      "uint16_t"            --- Cube side size.
+	.hasMips   "bool"                --- Indicates that texture contains full mip-map chain.
+	.numLayers "uint16_t"            --- Number of layers in texture array. Must be 1 if caps
+	                                 --- `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.
+	.format    "TextureFormat::Enum" --- Texture format. See: `TextureFormat::Enum`.
+	.flags     "uint64_t"            --- Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+	                                 --- flags. Default texture sampling mode is linear, and wrap mode is repeat.
+	                                 --- - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+	                                 ---   mode.
+	                                 --- - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+	                                 ---   sampling.
+	.mem       "const Memory*"       --- 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.
+
+--- Update 2D texture.
 func.updateTexture2D
 	"void"
-	.handle "TextureHandle"
-	.layer  "uint16_t"
-	.mip    "uint8_t"
-	.x      "uint16_t"
-	.y      "uint16_t"
-	.width  "uint16_t"
-	.height "uint16_t"
-	.mem    "const Memory *"
-	.pitch  "uint16_t"
-
+	.handle "TextureHandle" --- Texture handle.
+	.layer  "uint16_t"      --- Layer in texture array.
+	.mip    "uint8_t"       --- Mip level.
+	.x      "uint16_t"      --- X offset in texture.
+	.y      "uint16_t"      --- Y offset in texture.
+	.width  "uint16_t"      --- Width of texture block.
+	.height "uint16_t"      --- Height of texture block.
+	.mem    "const Memory*" --- Texture update data.
+	.pitch  "uint16_t"      --- Pitch of input image (bytes). When _pitch is set to
+	                        --- UINT16_MAX, it will be calculated internally based on _width.
+	 { default = UINT16_MAX }
+
+--- Update 3D texture.
 func.updateTexture3D
 	"void"
-	.handle "TextureHandle"
-	.mip    "uint8_t"
-	.x      "uint16_t"
-	.y      "uint16_t"
-	.z      "uint16_t"
-	.width  "uint16_t"
-	.height "uint16_t"
-	.depth  "uint16_t"
-	.mem    "const Memory *"
-
+	.handle "TextureHandle" --- Texture handle.
+	.mip    "uint8_t"       --- Mip level.
+	.x      "uint16_t"      --- X offset in texture.
+	.y      "uint16_t"      --- Y offset in texture.
+	.z      "uint16_t"      --- Z offset in texture.
+	.width  "uint16_t"      --- Width of texture block.
+	.height "uint16_t"      --- Height of texture block.
+	.depth  "uint16_t"      --- Depth of texture block.
+	.mem    "const Memory*" --- Texture update data.
+
+--- Update Cube texture.
 func.updateTextureCube
 	"void"
-	.handle "TextureHandle"
-	.layer  "uint16_t"
-	.side   "uint8_t"
-	.mip    "uint8_t"
-	.x      "uint16_t"
-	.y      "uint16_t"
-	.width  "uint16_t"
-	.height "uint16_t"
-	.mem    "const Memory *"
-	.pitch  "uint16_t"
-
+	.handle "TextureHandle" --- Texture handle.
+	.layer  "uint16_t"      --- Layer in texture array.
+	.side   "uint8_t"       --- Cubemap side `BGFX_CUBE_MAP_<POSITIVE or NEGATIVE>_<X, Y or Z>`,
+	                        ---   where 0 is +X, 1 is -X, 2 is +Y, 3 is -Y, 4 is +Z, and 5 is -Z.
+	                        ---
+	                        ---                  +----------+
+	                        ---                  |-z       2|
+	                        ---                  | ^  +y    |
+	                        ---                  | |        |    Unfolded cube:
+	                        ---                  | +---->+x |
+	                        ---       +----------+----------+----------+----------+
+	                        ---       |+y       1|+y       4|+y       0|+y       5|
+	                        ---       | ^  -x    | ^  +z    | ^  +x    | ^  -z    |
+	                        ---       | |        | |        | |        | |        |
+	                        ---       | +---->+z | +---->+x | +---->-z | +---->-x |
+	                        ---       +----------+----------+----------+----------+
+	                        ---                  |+z       3|
+	                        ---                  | ^  -y    |
+	                        ---                  | |        |
+	                        ---                  | +---->+x |
+	                        ---                  +----------+
+	.mip    "uint8_t"       --- Mip level.
+	.x      "uint16_t"      --- X offset in texture.
+	.y      "uint16_t"      --- Y offset in texture.
+	.width  "uint16_t"      --- Width of texture block.
+	.height "uint16_t"      --- Height of texture block.
+	.mem    "const Memory*" --- Texture update data.
+	.pitch  "uint16_t"      --- Pitch of input image (bytes). When _pitch is set to
+	                        --- UINT16_MAX, it will be calculated internally based on _width.
+	 { default = UINT16_MAX }
+
+--- Read back texture content.
+---
+--- @attention Texture must be created with `BGFX_TEXTURE_READ_BACK` flag.
+--- @attention Availability depends on: `BGFX_CAPS_TEXTURE_READ_BACK`.
+---
 func.readTexture
-	"uint32_t"
-	.handle "TextureHandle"
-	.data   "void *"
-	.mip    "uint8_t"
+	"uint32_t"              --- Frame number when the result will be available. See: `bgfx::frame`.
+	.handle "TextureHandle" --- Texture handle.
+	.data   "void*"         --- Destination buffer.
+	.mip    "uint8_t"       --- Mip level.
+	 { default = 0 }
 
+--- Set texture debug name.
 func.setName { cname = "set_texture_name" }
 	"void"
-	.handle "TextureHandle"
-	.name   "const char *"
-	.len    "int32_t"
+	.handle "TextureHandle"  --- Texture handle.
+	.name   "const char*"    --- Texture name.
+	.len    "int32_t"        --- Texture name length (if length is INT32_MAX, it's expected
+	 { default = INT32_MAX } --- that _name is zero terminated string.
 
+--- Returns texture direct access pointer.
+---
+--- @attention Availability depends on: `BGFX_CAPS_TEXTURE_DIRECT_ACCESS`. This feature
+---   is available on GPUs that have unified memory architecture (UMA) support.
+---
 func.getDirectAccessPtr
-	"void *"
-	.handle "TextureHandle"
+	"void*"                 --- 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.
+	.handle "TextureHandle" --- Texture handle.
 
+--- Destroy texture.
 func.destroy { cname = "destroy_texture" }
 	"void"
-	.handle "TextureHandle"
+	.handle "TextureHandle" --- Texture handle.
 
+--- Create frame buffer (simple).
 func.createFrameBuffer
-	"FrameBufferHandle"
-	.width        "uint16_t"
-	.height       "uint16_t"
-	.format       "TextureFormat::Enum"
-	.textureFlags "uint64_t"
-
+	"FrameBufferHandle"                 --- Frame buffer handle.
+	.width        "uint16_t"            --- Texture width.
+	.height       "uint16_t"            --- Texture height.
+	.format       "TextureFormat::Enum" --- Texture format. See: `TextureFormat::Enum`.
+	.textureFlags "uint64_t"            --- Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+	                                    --- flags. Default texture sampling mode is linear, and wrap mode is repeat.
+	                                    --- - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+	                                    ---   mode.
+	                                    --- - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+	                                    ---   sampling.
+
+--- Create frame buffer with size based on backbuffer ratio. Frame buffer will maintain ratio
+--- if back buffer resolution changes.
 func.createFrameBuffer { cname = "create_frame_buffer_scaled" }
-	"FrameBufferHandle"
-	.ratio        "BackbufferRatio::Enum"
-	.format       "TextureFormat::Enum"
-	.textureFlags "uint64_t"
-
+	"FrameBufferHandle"                   --- Frame buffer handle.
+	.ratio        "BackbufferRatio::Enum" --- Frame buffer size in respect to back-buffer size. See:
+	                                      --- `BackbufferRatio::Enum`.
+	.format       "TextureFormat::Enum"   --- Texture format. See: `TextureFormat::Enum`.
+	.textureFlags "uint64_t"              --- Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+	                                      --- flags. Default texture sampling mode is linear, and wrap mode is repeat.
+	                                      --- - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+	                                      ---   mode.
+	                                      --- - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+	                                      ---   sampling.
+
+--- Create MRT frame buffer from texture handles (simple).
 func.createFrameBuffer { cname = "create_frame_buffer_from_handles" }
-	"FrameBufferHandle"
-	.num            "uint8_t"
-	.handles        "const TextureHandle *"
-	.destroyTexture "bool"
-
+	"FrameBufferHandle"                    --- Frame buffer handle.
+	.num            "uint8_t"              --- Number of texture handles.
+	.handles        "const TextureHandle*" --- Texture attachments.
+	.destroyTexture "bool"                 --- If true, textures will be destroyed when
+	 { default = false }                   --- frame buffer is destroyed.
+
+--- Create MRT frame buffer from texture handles with specific layer and
+--- mip level.
 func.createFrameBuffer { cname = "create_frame_buffer_from_attachment" }
-	"FrameBufferHandle"
-	.num            "uint8_t"
-	.handles        "const Attachment *"
-	.destroyTexture "bool"
-
+	"FrameBufferHandle"                 --- Frame buffer handle.
+	.num            "uint8_t"           --- Number of attachements.
+	.attachment     "const Attachment*" --- Attachment texture info. See: `bgfx::Attachment`.
+	.destroyTexture "bool"              --- If true, textures will be destroyed when
+	 { default = false }                --- frame buffer is destroyed.
+
+--- Create frame buffer for multiple window rendering.
+---
+--- @remarks
+---   Frame buffer cannot be used for sampling.
+---
+--- @attention Availability depends on: `BGFX_CAPS_SWAP_CHAIN`.
+---
 func.createFrameBuffer { cname = "create_frame_buffer_from_nwh" }
-	"FrameBufferHandle"
-	.nwh         "void *"
-	.width       "uint16_t"
-	.height      "uint16_t"
-	.format      "TextureFormat::Enum"
-	.depthFormat "TextureFormat::Enum"
-
+	"FrameBufferHandle"                --- Frame buffer handle.
+	.nwh         "void*"               --- OS' target native window handle.
+	.width       "uint16_t"            --- Window back buffer width.
+	.height      "uint16_t"            --- Window back buffer height.
+	.format      "TextureFormat::Enum" --- Window back buffer color format.
+	.depthFormat "TextureFormat::Enum" --- Window back buffer depth format.
+
+--- Set frame buffer debug name.
 func.setName { cname = "set_frame_buffer_name" }
 	"void"
-	.handle "FrameBufferHandle"
-	.name   "const char *"
-	.len    "int32_t"
+	.handle "FrameBufferHandle" --- Frame buffer handle.
+	.name   "const char*"       --- Frame buffer name.
+	.len    "int32_t"           --- Frame buffer name length (if length is INT32_MAX, it's expected
+	 { default = INT32_MAX }    --- that _name is zero terminated string.
 
+--- Obtain texture handle of frame buffer attachment.
 func.getTexture
 	"TextureHandle"
-	.handle     "FrameBufferHandle"
+	.handle     "FrameBufferHandle" --- Frame buffer handle.
 	.attachment "uint8_t"
 
+--- Destroy frame buffer.
 func.destroy { cname = "destroy_frame_buffer" }
 	"void"
-	.handle "FrameBufferHandle"
-
+	.handle "FrameBufferHandle" --- Frame buffer handle.
+
+--- Create shader uniform parameter.
+---
+--- @remarks
+---   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, in pixels.
+---      - `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.
+---
 func.createUniform
-	"UniformHandle"
-	.name "const char *"
-	.type "UniformType::Enum"
-	.num  "uint16_t"
+	"UniformHandle"           --- Handle to uniform object.
+	.name "const char*"       --- Uniform name in shader.
+	.type "UniformType::Enum" --- Type of uniform (See: `bgfx::UniformType`).
+	.num  "uint16_t"          --- Number of elements in array.
 
+--- Retrieve uniform info.
 func.getUniformInfo
 	"void"
-	.handle "UniformHandle"
-	.info   "UniformInfo &" { out }
+	.handle "UniformHandle"         --- Handle to uniform object.
+	.info   "UniformInfo &" { out } --- Uniform info.
 
+--- Destroy shader uniform parameter.
 func.destroy { cname = "destroy_uniform" }
 	"void"
-	.handle "UniformHandle"
+	.handle "UniformHandle" --- Handle to uniform object.
 
+--- Create occlusion query.
 func.createOcclusionQuery
-	"OcclusionQueryHandle"
+	"OcclusionQueryHandle" --- Handle to occlusion query object.
 
+--- Retrieve occlusion query result from previous frame.
 func.getResult
-	"OcclusionQueryResult::Enum"
-	.handle "OcclusionQueryHandle"
-	.result "int32_t *" { out }
+	"OcclusionQueryResult::Enum"   --- Occlusion query result.
+	.handle "OcclusionQueryHandle" --- Handle to occlusion query object.
+	.result "int32_t*" { out }     --- Number of pixels that passed test. This argument
+	                               --- can be `NULL` if result of occlusion query is not needed.
 
+--- Destroy occlusion query.
 func.destroy { cname = "destroy_occlusion_query" }
 	"void"
-	.handle "OcclusionQueryHandle"
+	.handle "OcclusionQueryHandle" --- Handle to occlusion query object.
 
+--- Set palette color value.
 func.setPaletteColor
 	"void"
-	.index "uint8_t"
-	.rgba  "const float *"
-
+	.index "uint8_t"        --- Index into palette.
+	.rgba  "const float[4]" --- RGBA floating point values.
+
+--- Set palette color value.
+func.setPaletteColor { cname = "set_palette_color_rgba8" }
+	"void"
+	.index "uint8_t"  --- Index into palette.
+	.rgba  "uint32_t" --- Packed 32-bit RGBA value.
+
+--- Set view name.
+---
+--- @remarks
+---   This is debug only feature.
+---
+---   In graphics debugger view name will appear as:
+---
+---       "nnnc <view name>"
+---        ^  ^ ^
+---        |  +--- compute (C)
+---        +------ view id
+---
 func.setViewName
 	"void"
-	.id   "ViewId"
-	.name "const char *"
+	.id   "ViewId"      --- View id.
+	.name "const char*" --- View name.
 
+--- Set view rectangle. Draw primitive outside view will be clipped.
 func.setViewRect
 	"void"
-	.id     "ViewId"
-	.x      "uint16_t"
-	.y      "uint16_t"
-	.width  "uint16_t"
-	.height "uint16_t"
+	.id     "ViewId"   --- View id.
+	.x      "uint16_t" --- Position x from the left corner of the window.
+	.y      "uint16_t" --- Position y from the top corner of the window.
+	.width  "uint16_t" --- Width of view port region.
+	.height "uint16_t" --- Height of view port region.
 
+--- Set view rectangle. Draw primitive outside view will be clipped.
 func.setViewRect { cname = "set_view_rect_ratio" }
 	"void"
-	.id    "ViewId"
-	.x     "uint16_t"
-	.y     "uint16_t"
-	.ratio "BackbufferRatio::Enum"
+	.id    "ViewId"                --- View id.
+	.x     "uint16_t"              --- Position x from the left corner of the window.
+	.y     "uint16_t"              --- Position y from the top corner of the window.
+	.ratio "BackbufferRatio::Enum" --- Width and height will be set in respect to back-buffer size.
+	                               --- See: `BackbufferRatio::Enum`.
 
+--- Set view scissor. Draw primitive outside view will be clipped. When
+--- _x, _y, _width and _height are set to 0, scissor will be disabled.
 func.setViewScissor
 	"void"
-	.id     "ViewId"
-	.x      "uint16_t"
-	.y      "uint16_t"
-	.width  "uint16_t"
-	.height "uint16_t"
+	.id     "ViewId"   --- View id.
+	.x      "uint16_t" --- Position x from the left corner of the window.
+	.y      "uint16_t" --- Position y from the top corner of the window.
+	.width  "uint16_t" --- Width of view scissor region.
+	.height "uint16_t" --- Height of view scissor region.
 
+--- Set view clear flags.
 func.setViewClear
 	"void"
-	.id      "ViewId"
-	.flags   "uint16_t"
-	.rgba    "uint32_t"
-	.depth   "float"
-	.stencil "uint8_t"
+	.id      "ViewId"   --- View id.
+	.flags   "uint16_t" --- Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear
+	                    --- operation. See: `BGFX_CLEAR_*`.
+	.rgba    "uint32_t" --- Color clear value.
+	.depth   "float"    --- Depth clear value.
+	.stencil "uint8_t"  --- Stencil clear value.
 
+--- Set view clear flags with different clear color for each
+--- frame buffer texture. Must use `bgfx::setPaletteColor` to setup clear color
+--- palette.
 func.setViewClear { cname = "set_view_clear_mrt" }
 	"void"
-	.id      "ViewId"
-	.flags   "uint16_t"
-	.depth   "float"
-	.stencil "uint8_t"
-	.c0      "uint8_t"
-	.c1      "uint8_t"
-	.c2      "uint8_t"
-	.c3      "uint8_t"
-	.c4      "uint8_t"
-	.c5      "uint8_t"
-	.c6      "uint8_t"
-	.c7      "uint8_t"
-
+	.id      "ViewId"   --- View id.
+	.flags   "uint16_t" --- Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear
+	                    --- operation. See: `BGFX_CLEAR_*`.
+	.depth   "float"    --- Depth clear value.
+	.stencil "uint8_t"  --- Stencil clear value.
+	.c0      "uint8_t"  --- Palette index for frame buffer attachment 0.
+	.c1      "uint8_t"  --- Palette index for frame buffer attachment 1.
+	.c2      "uint8_t"  --- Palette index for frame buffer attachment 2.
+	.c3      "uint8_t"  --- Palette index for frame buffer attachment 3.
+	.c4      "uint8_t"  --- Palette index for frame buffer attachment 4.
+	.c5      "uint8_t"  --- Palette index for frame buffer attachment 5.
+	.c6      "uint8_t"  --- Palette index for frame buffer attachment 6.
+	.c7      "uint8_t"  --- Palette index for frame buffer attachment 7.
+
+--- Set view sorting mode.
+---
+--- @remarks
+---   View mode must be set prior calling `bgfx::submit` for the view.
+---
 func.setViewMode
 	"void"
-	.id   "ViewId"
-	.mode "ViewMode::Enum"
+	.id   "ViewId"         --- View id.
+	.mode "ViewMode::Enum" --- View sort mode. See `ViewMode::Enum`.
 
+--- Set view frame buffer.
+---
+--- @remarks
+---   Not persistent after `bgfx::reset` call.
+---
 func.setViewFrameBuffer
 	"void"
-	.id     "ViewId"
-	.handle "FrameBufferHandle"
+	.id     "ViewId"            --- View id.
+	.handle "FrameBufferHandle" --- Frame buffer handle. Passing `BGFX_INVALID_HANDLE` as
+	                            --- frame buffer handle will draw primitives from this view into
+	                            --- default back buffer.
 
+--- Set view view and projection matrices, all draw primitives in this
+--- view will use these matrices.
 func.setViewTransform
 	"void"
-	.id   "ViewId"
-	.view "const void *"
-	.proj "const void *"
+	.id   "ViewId"      --- View id.
+	.view "const void*" --- View matrix.
+	.proj "const void*" --- Projection matrix.
 
+--- Post submit view reordering.
 func.setViewOrder
 	"void"
-	.id    "ViewId"
-	.num   "uint16_t"
-	.order "const ViewId *"
+	.id    "ViewId"        --- First view id.
+	.num   "uint16_t"      --- Number of views to remap.
+	.order "const ViewId*" --- View remap id table. Passing `NULL` will reset view ids
+	                       --- to default state.
 
+--- Begin submitting draw calls from thread.
 func.begin { cname = "encoder_begin" }
-	"Encoder *"
-	.forThread "bool"
+	"Encoder*"        --- Encoder.
+	.forThread "bool" --- Explicitly request an encoder for a worker thread.
 
+--- End submitting draw calls from thread.
 func["end"] { cname = "encoder_end" }
 	"void"
-	.encoder "Encoder *"
+	.encoder "Encoder*" --- Encoder.
 
+--- Sets a debug marker. This allows you to group graphics calls together for easy browsing in
+--- graphics debugging tools.
 func.Encoder.setMarker
 	"void"
-	.marker "const char *"
-
+	.marker "const char*" --- Marker string.
+
+--- Set render states for draw primitive.
+---
+--- @remarks
+---   1. To setup more complex states use:
+---      `BGFX_STATE_ALPHA_REF(_ref)`,
+---      `BGFX_STATE_POINT_SIZE(_size)`,
+---      `BGFX_STATE_BLEND_FUNC(_src, _dst)`,
+---      `BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA)`,
+---      `BGFX_STATE_BLEND_EQUATION(_equation)`,
+---      `BGFX_STATE_BLEND_EQUATION_SEPARATE(_equationRGB, _equationA)`
+---   2. `BGFX_STATE_BLEND_EQUATION_ADD` is set when no other blend
+---      equation is specified.
+---
 func.Encoder.setState
 	"void"
-	.state "uint64_t"
-	.rgba  "uint32_t"
-
+	.state "uint64_t" --- State flags. Default state for primitive type is
+	                  ---   triangles. See: `BGFX_STATE_DEFAULT`.
+	                  ---   - `BGFX_STATE_DEPTH_TEST_*` - Depth test function.
+	                  ---   - `BGFX_STATE_BLEND_*` - See remark 1 about BGFX_STATE_BLEND_FUNC.
+	                  ---   - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2.
+	                  ---   - `BGFX_STATE_CULL_*` - Backface culling mode.
+	                  ---   - `BGFX_STATE_WRITE_*` - Enable R, G, B, A or Z write.
+	                  ---   - `BGFX_STATE_MSAA` - Enable hardware multisample antialiasing.
+	                  ---   - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type.
+	.rgba  "uint32_t" --- Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and
+	                  ---   `BGFX_STATE_BLEND_INV_FACTOR` blend modes.
+
+--- Set condition for rendering.
 func.Encoder.setCondition
 	"void"
-	.handle  "OcclusionQueryHandle"
-	.visible "bool"
+	.handle  "OcclusionQueryHandle" --- Occlusion query handle.
+	.visible "bool"                 --- Render if occlusion query is visible.
 
+--- Set stencil test state.
 func.Encoder.setStencil
 	"void"
-	.fstencil "uint32_t"
-	.bstencil "uint32_t"
+	.fstencil "uint32_t" --- Front stencil state.
+	.bstencil "uint32_t" --- Back stencil state. If back is set to `BGFX_STENCIL_NONE`
+	                     --- _fstencil is applied to both front and back facing primitives.
 
+--- Set scissor for draw primitive.
+---
+--- @remark
+---   To scissor for all primitives in view see `bgfx::setViewScissor`.
+---
 func.Encoder.setScissor
-	"uint16_t"
-	.x      "uint16_t"
-	.y      "uint16_t"
-	.width  "uint16_t"
-	.height "uint16_t"
-
+	"uint16_t"         --- Scissor cache index.
+	.x      "uint16_t" --- Position x from the left corner of the window.
+	.y      "uint16_t" --- Position y from the top corner of the window.
+	.width  "uint16_t" --- Width of view scissor region.
+	.height "uint16_t" --- Height of view scissor region.
+
+--- Set scissor from cache for draw primitive.
+---
+--- @remark
+---   To scissor for all primitives in view see `bgfx::setViewScissor`.
+---
 func.Encoder.setScissor { cname = "set_scissor_cached" }
 	"void"
-	.cache "uint16_t"
+	.cache "uint16_t" --- Index in scissor cache.
 
+--- Set model matrix for draw primitive. If it is not called,
+--- the model will be rendered with an identity model matrix.
 func.Encoder.setTransform
-	"uint32_t"
-	.mtx "const void *"
-	.num "uint16_t"
+	"uint32_t"         --- Index into matrix cache in case the same model matrix has
+	                   --- to be used for other draw primitive call.
+	.mtx "const void*" --- Pointer to first matrix in array.
+	.num "uint16_t"    --- Number of matrices in array.
 
+---  Set model matrix from matrix cache for draw primitive.
 func.Encoder.setTransform { cname = "set_transform_cached" }
 	"void"
-	.cache "uint32_t"
-	.num   "uint16_t"
+	.cache "uint32_t" --- Index in matrix cache.
+	.num   "uint16_t" --- Number of matrices from cache.
 
+--- Reserve matrices in internal matrix cache.
+---
+--- @attention Pointer returned can be modifed until `bgfx::frame` is called.
+---
 func.Encoder.allocTransform
-	"uint32_t"
-	.transform "Transform *" { out }
-	.num       "uint16_t"
+	"uint32_t"                      --- Index in matrix cache.
+	.transform "Transform*" { out } --- Pointer to `Transform` structure.
+	.num       "uint16_t"           --- Number of matrices.
 
+--- Set shader uniform parameter for draw primitive.
 func.Encoder.setUniform
 	"void"
-	.handle "UniformHandle"
-	.value  "const void *"
-	.num    "uint16_t"
+	.handle "UniformHandle" --- Uniform.
+	.value  "const void*"   --- Pointer to uniform data.
+	.num    "uint16_t"      --- Number of elements. Passing `UINT16_MAX` will
+	                        --- use the _num passed on uniform creation.
 
+--- Set index buffer for draw primitive.
+func.Encoder.setIndexBuffer { cpponly }
+	"void"
+	.handle     "IndexBufferHandle" --- Index buffer.
+
+--- Set index buffer for draw primitive.
 func.Encoder.setIndexBuffer
 	"void"
-	.handle     "IndexBufferHandle"
-	.firstIndex "uint32_t"
-	.numIndices "uint32_t"
+	.handle     "IndexBufferHandle" --- Index buffer.
+	.firstIndex "uint32_t"          --- First index to render.
+	.numIndices "uint32_t"          --- Number of indices to render.
+
+--- Set index buffer for draw primitive.
+func.Encoder.setIndexBuffer { cpponly }
+	"void"
+	.handle     "DynamicIndexBufferHandle" --- Dynamic index buffer.
 
+--- Set index buffer for draw primitive.
 func.Encoder.setIndexBuffer { cname = "set_dynamic_index_buffer" }
 	"void"
-	.handle     "DynamicIndexBufferHandle"
-	.firstIndex "uint32_t"
-	.numIndices "uint32_t"
+	.handle     "DynamicIndexBufferHandle" --- Dynamic index buffer.
+	.firstIndex "uint32_t"                 --- First index to render.
+	.numIndices "uint32_t"                 --- Number of indices to render.
 
+--- Set index buffer for draw primitive.
+func.Encoder.setIndexBuffer { cpponly }
+	"void"
+	.tib        "const TransientIndexBuffer*" --- Transient index buffer.
+
+--- Set index buffer for draw primitive.
 func.Encoder.setIndexBuffer { cname = "set_transient_index_buffer" }
 	"void"
-	.tib        "const TransientIndexBuffer *"
-	.firstIndex "uint32_t"
-	.numIndices "uint32_t"
+	.tib        "const TransientIndexBuffer*" --- Transient index buffer.
+	.firstIndex "uint32_t"                    --- First index to render.
+	.numIndices "uint32_t"                    --- Number of indices to render.
+
+--- Set vertex buffer for draw primitive.
+func.Encoder.setVertexBuffer { cpponly }
+	"void"
+	.stream      "uint8_t"            --- Vertex stream.
+	.handle      "VertexBufferHandle" --- Vertex buffer.
 
+--- Set vertex buffer for draw primitive.
 func.Encoder.setVertexBuffer
 	"void"
-	.stream      "uint8_t"
-	.handle      "VertexBufferHandle"
-	.startVertex "uint32_t"
-	.numVertices "uint32_t"
+	.stream      "uint8_t"            --- Vertex stream.
+	.handle      "VertexBufferHandle" --- Vertex buffer.
+	.startVertex "uint32_t"           --- First vertex to render.
+	.numVertices "uint32_t"           --- Number of vertices to render.
 
+--- Set vertex buffer for draw primitive.
+func.Encoder.setVertexBuffer { cpponly }
+	"void"
+	.stream      "uint8_t"                   --- Vertex stream.
+	.handle      "DynamicVertexBufferHandle" --- Dynamic vertex buffer.
+
+--- Set vertex buffer for draw primitive.
 func.Encoder.setVertexBuffer { cname = "set_dynamic_vertex_buffer" }
 	"void"
-	.stream      "uint8_t"
-	.handle      "DynamicVertexBufferHandle"
-	.startVertex "uint32_t"
-	.numVertices "uint32_t"
+	.stream      "uint8_t"                   --- Vertex stream.
+	.handle      "DynamicVertexBufferHandle" --- Dynamic vertex buffer.
+	.startVertex "uint32_t"                  --- First vertex to render.
+	.numVertices "uint32_t"                  --- Number of vertices to render.
+
+--- Set vertex buffer for draw primitive.
+func.Encoder.setVertexBuffer { cpponly }
+	"void"
+	.stream      "uint8_t"                      --- Vertex stream.
+	.tvb         "const TransientVertexBuffer*" --- Transient vertex buffer.
 
+--- Set vertex buffer for draw primitive.
 func.Encoder.setVertexBuffer { cname = "set_transient_vertex_buffer" }
 	"void"
-	.stream      "uint8_t"
-	.tvb         "const TransientVertexBuffer *"
-	.startVertex "uint32_t"
-	.numVertices "uint32_t"
+	.stream      "uint8_t"                      --- Vertex stream.
+	.tvb         "const TransientVertexBuffer*" --- Transient vertex buffer.
+	.startVertex "uint32_t"                     --- First vertex to render.
+	.numVertices "uint32_t"                     --- Number of vertices to render.
 
+--- Set number of vertices for auto generated vertices use in conjuction
+--- with gl_VertexID.
+---
+--- @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
+---
 func.Encoder.setVertexCount
 	"void"
-	.numVertices "uint32_t"
+	.numVertices "uint32_t" --- Number of vertices.
 
+--- Set instance data buffer for draw primitive.
+func.Encoder.setInstanceDataBuffer { cpponly }
+	"void"
+	.idb   "const InstanceDataBuffer*" --- Transient instance data buffer.
+
+--- Set instance data buffer for draw primitive.
 func.Encoder.setInstanceDataBuffer
 	"void"
-	.idb   "const InstanceDataBuffer *"
-	.start "uint32_t"
-	.num   "uint32_t"
+	.idb   "const InstanceDataBuffer*" --- Transient instance data buffer.
+	.start "uint32_t"                  --- First instance data.
+	.num   "uint32_t"                  --- Number of data instances.
+
+--- Set instance data buffer for draw primitive.
+func.Encoder.setInstanceDataBuffer { cpponly }
+	"void"
+	.handle      "VertexBufferHandle" --- Vertex buffer.
 
+--- Set instance data buffer for draw primitive.
 func.Encoder.setInstanceDataBuffer { cname = "set_instance_data_from_vertex_buffer" }
 	"void"
-	.handle      "VertexBufferHandle"
-	.startVertex "uint32_t"
-	.num         "uint32_t"
+	.handle      "VertexBufferHandle" --- Vertex buffer.
+	.startVertex "uint32_t"           --- First instance data.
+	.num         "uint32_t"           --- Number of data instances.
 
+ --- Set instance data buffer for draw primitive.
+func.Encoder.setInstanceDataBuffer { cpponly }
+	"void"
+	.handle      "DynamicVertexBufferHandle" --- Dynamic vertex buffer.
+
+--- Set instance data buffer for draw primitive.
 func.Encoder.setInstanceDataBuffer { cname = "set_instance_data_from_dynamic_vertex_buffer" }
 	"void"
-	.handle      "DynamicVertexBufferHandle"
-	.startVertex "uint32_t"
-	.num         "uint32_t"
+	.handle      "DynamicVertexBufferHandle" --- Dynamic vertex buffer.
+	.startVertex "uint32_t"                  --- First instance data.
+	.num         "uint32_t"                  --- Number of data instances.
 
+--- Set number of instances for auto generated instances use in conjuction
+--- with gl_InstanceID.
+---
+--- @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
+---
 func.Encoder.setInstanceCount
 	"void"
-	.numInstances "uint32_t"
+	.numInstances "uint32_t" -- Number of instances.
 
+--- Set texture stage for draw primitive.
 func.Encoder.setTexture
 	"void"
-	.stage   "uint8_t"
-	.sampler "UniformHandle"
-	.handle  "TextureHandle"
-	.flags   "uint32_t"
-
+	.stage   "uint8_t"       --- Texture unit.
+	.sampler "UniformHandle" --- Program sampler.
+	.handle  "TextureHandle" --- Texture handle.
+	.flags   "uint32_t"      --- Texture sampling mode. Default value UINT32_MAX uses
+	                         ---   texture sampling settings from the texture.
+	                         ---   - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+	                         ---     mode.
+	                         ---   - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+	                         ---     sampling.
+
+--- Submit an empty primitive for rendering. Uniforms and draw state
+--- will be applied but no geometry will be submitted.
+---
+--- @remark
+---   These empty draw calls will sort before ordinary draw calls.
+---
 func.Encoder.touch
 	"void"
-	.id "ViewId"
+	.id "ViewId" --- View id.
 
+--- Submit primitive for rendering.
 func.Encoder.submit
 	"void"
-	.id            "ViewId"
-	.program       "ProgramHandle"
-	.depth         "uint32_t"
-	.preserveState "bool"
+	.id            "ViewId"        --- View id.
+	.program       "ProgramHandle" --- Program.
+	.depth         "uint32_t"      --- Depth for sorting.
+	.preserveState "bool"          --- Preserve internal draw state for next draw call submit.
 
+--- Submit primitive with occlusion query for rendering.
 func.Encoder.submit { cname = "submit_occlusion_query" }
 	"void"
-	.id             "ViewId"
-	.program        "ProgramHandle"
-	.occlusionQuery "OcclusionQueryHandle"
-	.depth          "uint32_t"
-	.preserveState  "bool"
+	.id             "ViewId"               --- View id.
+	.program        "ProgramHandle"        --- Program.
+	.occlusionQuery "OcclusionQueryHandle" --- Occlusion query.
+	.depth          "uint32_t"             --- Depth for sorting.
+	.preserveState  "bool"                 --- Preserve internal draw state for next draw call submit.
 
+--- Submit primitive for rendering with index and instance data info from
+--- indirect buffer.
 func.Encoder.submit { cname = "submit_indirect" }
 	"void"
-	.id             "ViewId"
-	.program        "ProgramHandle"
-	.indirectHandle "IndirectBufferHandle"
-	.start          "uint16_t"
-	.num            "uint16_t"
-	.depth          "uint32_t"
-	.preserveState  "bool"
+	.id             "ViewId"               --- View id.
+	.program        "ProgramHandle"        --- Program.
+	.indirectHandle "IndirectBufferHandle" --- Indirect buffer.
+	.start          "uint16_t"             --- First element in indirect buffer.
+	.num            "uint16_t"             --- Number of dispatches.
+	.depth          "uint32_t"             --- Depth for sorting.
+	.preserveState  "bool"                 --- Preserve internal draw state for next draw call submit.
 
+--- Set compute index buffer.
 func.Encoder.setBuffer { cname = "set_compute_index_buffer" }
 	"void"
-	.stage  "uint8_t"
-	.handle "IndexBufferHandle"
-	.access "Access::Enum"
+	.stage  "uint8_t"           --- Compute stage.
+	.handle "IndexBufferHandle" --- Index buffer handle.
+	.access "Access::Enum"      --- Buffer access. See `Access::Enum`.
 
+--- Set compute vertex buffer.
 func.Encoder.setBuffer { cname = "set_compute_vertex_buffer" }
 	"void"
-	.stage  "uint8_t"
-	.handle "VertexBufferHandle"
-	.access "Access::Enum"
+	.stage  "uint8_t"            --- Compute stage.
+	.handle "VertexBufferHandle" --- Vertex buffer handle.
+	.access "Access::Enum"       --- Buffer access. See `Access::Enum`.
 
+--- Set compute dynamic index buffer.
 func.Encoder.setBuffer { cname = "set_compute_dynamic_index_buffer" }
 	"void"
-	.stage  "uint8_t"
-	.handle "DynamicIndexBufferHandle"
-	.access "Access::Enum"
+	.stage  "uint8_t"                  --- Compute stage.
+	.handle "DynamicIndexBufferHandle" --- Dynamic index buffer handle.
+	.access "Access::Enum"             --- Buffer access. See `Access::Enum`.
 
+--- Set compute dynamic vertex buffer.
 func.Encoder.setBuffer { cname = "set_compute_dynamic_vertex_buffer" }
 	"void"
-	.stage  "uint8_t"
-	.handle "DynamicVertexBufferHandle"
-	.access "Access::Enum"
+	.stage  "uint8_t"                   --- Compute stage.
+	.handle "DynamicVertexBufferHandle" --- Dynamic vertex buffer handle.
+	.access "Access::Enum"              --- Buffer access. See `Access::Enum`.
 
+--- Set compute indirect buffer.
 func.Encoder.setBuffer { cname = "set_compute_indirect_buffer" }
 	"void"
-	.stage  "uint8_t"
-	.handle "IndirectBufferHandle"
-	.access "Access::Enum"
+	.stage  "uint8_t"              --- Compute stage.
+	.handle "IndirectBufferHandle" --- Indirect buffer handle.
+	.access "Access::Enum"         --- Buffer access. See `Access::Enum`.
 
+--- Set compute image from texture.
 func.Encoder.setImage
 	"void"
-	.stage  "uint8_t"
-	.handle "TextureHandle"
-	.mip    "uint8_t"
-	.access "Access::Enum"
-	.format "TextureFormat::Enum"
+	.stage  "uint8_t"       --- Compute stage.
+	.handle "TextureHandle" --- Texture handle.
+	.mip    "uint8_t"       --- Mip level.
+	.access "Access::Enum"  --- Image access. See `Access::Enum`.
+	.format "TextureFormat::Enum" { default = "TextureFormat::Count" } --- Texture format. See: `TextureFormat::Enum`.
 
+--- Dispatch compute.
 func.Encoder.dispatch
 	"void"
-	.id      "ViewId"
-	.program "ProgramHandle"
-	.numX    "uint32_t"
-	.numY    "uint32_t"
-	.numZ    "uint32_t"
+	.id      "ViewId"        --- View id.
+	.program "ProgramHandle" --- Compute program.
+	.numX    "uint32_t"      --- Number of groups X.
+	.numY    "uint32_t"      --- Number of groups Y.
+	.numZ    "uint32_t"      --- Number of groups Z.
 
+--- Dispatch compute indirect.
 func.Encoder.dispatch { cname = "dispatch_indirect" }
 	"void"
-	.id             "ViewId"
-	.program        "ProgramHandle"
-	.indirectHandle "IndirectBufferHandle"
-	.start          "uint16_t"
-	.num            "uint16_t"
+	.id             "ViewId"               --- View id.
+	.program        "ProgramHandle"        --- Compute program.
+	.indirectHandle "IndirectBufferHandle" --- Indirect buffer.
+	.start          "uint16_t"             --- First element in indirect buffer.
+	.num            "uint16_t"             --- Number of dispatches.
 
+--- Discard all previously set state for draw or compute call.
 func.Encoder.discard
 	"void"
 
+--- Blit 2D texture region between two 2D textures.
+---
+--- @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag.
+--- @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`.
+---
+func.Encoder.blit { cpponly }
+	"void"
+	.id     "ViewId"        --- View id.
+	.dst    "TextureHandle" --- Destination texture handle.
+	.dstX   "uint16_t"      --- Destination texture X position.
+	.dstY   "uint16_t"      --- Destination texture Y position.
+	.src    "TextureHandle" --- Source texture handle.
+	 { default = 0 }
+	.srcX   "uint16_t"      --- Source texture X position.
+	 { default = 0 }
+	.srcY   "uint16_t"      --- Source texture Y position.
+	 { default = 0 }
+	.width  "uint16_t"      --- Width of region.
+	 { default = UINT16_MAX }
+	.height "uint16_t"      --- Height of region.
+	 { default = UINT16_MAX }
+
+--- Blit 2D texture region between two 2D textures.
+---
+--- @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag.
+--- @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`.
+---
 func.Encoder.blit
 	"void"
-	.id     "ViewId"
-	.dst    "TextureHandle"
-	.dstMip "uint8_t"
-	.dstX   "uint16_t"
-	.dstY   "uint16_t"
-	.dstZ   "uint16_t"
-	.src    "TextureHandle"
-	.srcMip "uint8_t"
-	.srcX   "uint16_t"
-	.srcY   "uint16_t"
-	.srcZ   "uint16_t"
-	.width  "uint16_t"
-	.height "uint16_t"
-	.depth  "uint16_t"
-
+	.id     "ViewId"        --- View id.
+	.dst    "TextureHandle" --- Destination texture handle.
+	.dstMip "uint8_t"       --- Destination texture mip level.
+	.dstX   "uint16_t"      --- Destination texture X position.
+	.dstY   "uint16_t"      --- Destination texture Y position.
+	.dstZ   "uint16_t"      --- 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    "TextureHandle" --- Source texture handle.
+	.srcMip "uint8_t"       --- Source texture mip level.
+	 { default = 0 }
+	.srcX   "uint16_t"      --- Source texture X position.
+	 { default = 0 }
+	.srcY   "uint16_t"      --- Source texture Y position.
+	 { default = 0 }
+	.srcZ   "uint16_t"      --- 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.
+	 { default = 0 }
+	.width  "uint16_t"      --- Width of region.
+	 { default = UINT16_MAX }
+	.height "uint16_t"      --- Height of region.
+	 { default = UINT16_MAX }
+	.depth  "uint16_t"      --- If texture is 3D this argument represents depth of region, otherwise it's
+	                        --- unused.
+	 { default = UINT16_MAX }
+
+--- Request screen shot of window back buffer.
+---
+--- @remarks
+---   `bgfx::CallbackI::screenShot` must be implemented.
+--- @attention Frame buffer handle must be created with OS' target native window handle.
+---
 func.requestScreenShot
 	"void"
-	.handle   "FrameBufferHandle"
-	.filePath "const char *"
-
+	.handle   "FrameBufferHandle" --- Frame buffer handle. If handle is `BGFX_INVALID_HANDLE` request will be
+	                              --- made for main window back buffer.
+	.filePath "const char*"       --- Will be passed to `bgfx::CallbackI::screenShot` callback.
+
+--- Render frame.
+---
+--- @attention `bgfx::renderFrame` is blocking call. It waits for
+---   `bgfx::frame` to be called from API thread to process frame.
+---   If timeout value is passed call will timeout and return even
+---   if `bgfx::frame` is not called.
+---
+--- @warning This call should be only used on platforms that don't
+---   allow creating separate rendering thread. If it is called before
+---   to bgfx::init, render thread won't be created by bgfx::init call.
+---
 func.renderFrame
-	"RenderFrame::Enum"
-	.msecs "int32_t"
+	"RenderFrame::Enum" --- Current renderer context state. See: `bgfx::RenderFrame`.
+	.msecs "int32_t"    --- Timeout in milliseconds.
 
+--- Set platform data.
+---
+--- @warning Must be called before `bgfx::init`.
+---
 func.setPlatformData
 	"void"
-	.data "const PlatformData &"
+	.data "const PlatformData &" --- Platform data.
 
+--- Get internal data for interop.
+---
+--- @attention It's expected you understand some bgfx internals before you
+---   use this call.
+---
+--- @warning Must be called only on render thread.
+---
 func.getInternalData
-	"const InternalData *"
-
+	"const InternalData*" --- Internal data.
+
+--- Override internal texture with externally created texture. Previously
+--- created internal texture will released.
+---
+--- @attention It's expected you understand some bgfx internals before you
+---   use this call.
+---
+--- @warning Must be called only on render thread.
+---
 func.overrideInternal { cname = "override_internal_texture_ptr" }
-	"uintptr_t"
-	.handle "TextureHandle"
-	.ptr    "uintptr_t"
-
+	"uintptr_t"             --- Native API pointer to texture. If result is 0, texture is not created
+	                        --- yet from the main thread.
+	.handle "TextureHandle" --- Texture handle.
+	.ptr    "uintptr_t"     --- Native API pointer to texture.
+
+--- Override internal texture by creating new texture. Previously created
+--- internal texture will released.
+---
+--- @attention It's expected you understand some bgfx internals before you
+---   use this call.
+---
+--- @param[in] _handle Texture handle.
+--- @param[in] _width Width.
+--- @param[in] _height Height.
+--- @param[in] _numMips Number of mip-maps.
+--- @param[in] _format Texture format. See: `TextureFormat::Enum`.
+--- @param[in] _flags Default texture sampling mode is linear, and wrap mode
+---   is repeat.
+---   - `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.
+---
+--- @returns Native API pointer to texture. If result is 0, texture is not created yet from the
+---   main thread.
+---
+--- @warning Must be called only on render thread.
+---
 func.overrideInternal { cname = "override_internal_texture" }
-	"uintptr_t"
-	.handle  "TextureHandle"
-	.width   "uint16_t"
-	.height  "uint16_t"
-	.numMips "uint8_t"
-	.format  "TextureFormat::Enum"
-	.flags   "uint32_t"
-
+	"uintptr_t"                    --- Native API pointer to texture. If result is 0, texture is not created
+	                               --- yet from the main thread.
+	.handle  "TextureHandle"       --- Texture handle.
+	.width   "uint16_t"            --- Width.
+	.height  "uint16_t"            --- Height.
+	.numMips "uint8_t"             --- Number of mip-maps.
+	.format  "TextureFormat::Enum" --- Texture format. See: `TextureFormat::Enum`.
+	.flags   "uint64_t"            --- Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`)
+	                               --- flags. Default texture sampling mode is linear, and wrap mode is repeat.
+	                               --- - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+	                               ---   mode.
+	                               --- - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+	                               ---   sampling.
 
 
 -- Legacy API:
 
+--- Sets a debug marker. This allows you to group graphics calls together for easy browsing in
+--- graphics debugging tools.
 func.setMarker
 	"void"
-	.marker "const char *"
-
+	.marker "const char*" --- Marker string.
+
+--- Set render states for draw primitive.
+---
+--- @remarks
+---   1. To setup more complex states use:
+---      `BGFX_STATE_ALPHA_REF(_ref)`,
+---      `BGFX_STATE_POINT_SIZE(_size)`,
+---      `BGFX_STATE_BLEND_FUNC(_src, _dst)`,
+---      `BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA)`,
+---      `BGFX_STATE_BLEND_EQUATION(_equation)`,
+---      `BGFX_STATE_BLEND_EQUATION_SEPARATE(_equationRGB, _equationA)`
+---   2. `BGFX_STATE_BLEND_EQUATION_ADD` is set when no other blend
+---      equation is specified.
+---
 func.setState
 	"void"
-	.state "uint64_t"
-	.rgba  "uint32_t"
-
+	.state "uint64_t" --- State flags. Default state for primitive type is
+	                  ---   triangles. See: `BGFX_STATE_DEFAULT`.
+	                  ---   - `BGFX_STATE_DEPTH_TEST_*` - Depth test function.
+	                  ---   - `BGFX_STATE_BLEND_*` - See remark 1 about BGFX_STATE_BLEND_FUNC.
+	                  ---   - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2.
+	                  ---   - `BGFX_STATE_CULL_*` - Backface culling mode.
+	                  ---   - `BGFX_STATE_WRITE_*` - Enable R, G, B, A or Z write.
+	                  ---   - `BGFX_STATE_MSAA` - Enable hardware multisample antialiasing.
+	                  ---   - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type.
+	.rgba  "uint32_t" --- Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and
+	                  ---   `BGFX_STATE_BLEND_INV_FACTOR` blend modes.
+
+--- Set condition for rendering.
 func.setCondition
 	"void"
-	.handle  "OcclusionQueryHandle"
-	.visible "bool"
+	.handle  "OcclusionQueryHandle" --- Occlusion query handle.
+	.visible "bool"                 --- Render if occlusion query is visible.
 
+--- Set stencil test state.
 func.setStencil
 	"void"
-	.fstencil "uint32_t"
-	.bstencil "uint32_t"
+	.fstencil "uint32_t" --- Front stencil state.
+	.bstencil "uint32_t" --- Back stencil state. If back is set to `BGFX_STENCIL_NONE`
+	                     --- _fstencil is applied to both front and back facing primitives.
 
+--- Set scissor for draw primitive.
+---
+--- @remark
+---   To scissor for all primitives in view see `bgfx::setViewScissor`.
+---
 func.setScissor
-	"uint16_t"
-	.x      "uint16_t"
-	.y      "uint16_t"
-	.width  "uint16_t"
-	.height "uint16_t"
-
+	"uint16_t"         --- Scissor cache index.
+	.x      "uint16_t" --- Position x from the left corner of the window.
+	.y      "uint16_t" --- Position y from the top corner of the window.
+	.width  "uint16_t" --- Width of view scissor region.
+	.height "uint16_t" --- Height of view scissor region.
+
+--- Set scissor from cache for draw primitive.
+---
+--- @remark
+---   To scissor for all primitives in view see `bgfx::setViewScissor`.
+---
 func.setScissor { cname = "set_scissor_cached" }
 	"void"
-	.cache "uint16_t"
+	.cache "uint16_t" --- Index in scissor cache.
 
+--- Set model matrix for draw primitive. If it is not called,
+--- the model will be rendered with an identity model matrix.
 func.setTransform
-	"uint32_t"
-	.mtx "const void *"
-	.num "uint16_t"
+	"uint32_t"         --- Index into matrix cache in case the same model matrix has
+	                   --- to be used for other draw primitive call.
+	.mtx "const void*" --- Pointer to first matrix in array.
+	.num "uint16_t"    --- Number of matrices in array.
 
+---  Set model matrix from matrix cache for draw primitive.
 func.setTransform { cname = "set_transform_cached" }
 	"void"
-	.cache "uint32_t"
-	.num   "uint16_t"
+	.cache "uint32_t" --- Index in matrix cache.
+	.num   "uint16_t" --- Number of matrices from cache.
 
+--- Reserve matrices in internal matrix cache.
+---
+--- @attention Pointer returned can be modifed until `bgfx::frame` is called.
+---
 func.allocTransform
-	"uint32_t"
-	.transform "Transform *" { out }
-	.num       "uint16_t"
+	"uint32_t"                      --- Index in matrix cache.
+	.transform "Transform*" { out } --- Pointer to `Transform` structure.
+	.num       "uint16_t"           --- Number of matrices.
 
+--- Set shader uniform parameter for draw primitive.
 func.setUniform
 	"void"
-	.handle "UniformHandle"
-	.value  "const void *"
-	.num    "uint16_t"
+	.handle "UniformHandle" --- Uniform.
+	.value  "const void*"   --- Pointer to uniform data.
+	.num    "uint16_t"      --- Number of elements. Passing `UINT16_MAX` will
+	                        --- use the _num passed on uniform creation.
 
+--- Set index buffer for draw primitive.
+func.setIndexBuffer { cpponly }
+	"void"
+	.handle     "IndexBufferHandle" --- Index buffer.
+
+--- Set index buffer for draw primitive.
 func.setIndexBuffer
 	"void"
-	.handle     "IndexBufferHandle"
-	.firstIndex "uint32_t"
-	.numIndices "uint32_t"
+	.handle     "IndexBufferHandle" --- Index buffer.
+	.firstIndex "uint32_t"          --- First index to render.
+	.numIndices "uint32_t"          --- Number of indices to render.
+
+--- Set index buffer for draw primitive.
+func.setIndexBuffer { cpponly }
+	"void"
+	.handle     "DynamicIndexBufferHandle" --- Dynamic index buffer.
 
+--- Set index buffer for draw primitive.
 func.setIndexBuffer { cname = "set_dynamic_index_buffer" }
 	"void"
-	.handle     "DynamicIndexBufferHandle"
-	.firstIndex "uint32_t"
-	.numIndices "uint32_t"
+	.handle     "DynamicIndexBufferHandle" --- Dynamic index buffer.
+	.firstIndex "uint32_t"                 --- First index to render.
+	.numIndices "uint32_t"                 --- Number of indices to render.
 
+--- Set index buffer for draw primitive.
+func.setIndexBuffer { cpponly }
+	"void"
+	.tib        "const TransientIndexBuffer*" --- Transient index buffer.
+
+--- Set index buffer for draw primitive.
 func.setIndexBuffer { cname = "set_transient_index_buffer" }
 	"void"
-	.tib        "const TransientIndexBuffer *"
-	.firstIndex "uint32_t"
-	.numIndices "uint32_t"
+	.tib        "const TransientIndexBuffer*" --- Transient index buffer.
+	.firstIndex "uint32_t"                    --- First index to render.
+	.numIndices "uint32_t"                    --- Number of indices to render.
+
+--- Set vertex buffer for draw primitive.
+func.setVertexBuffer { cpponly }
+	"void"
+	.stream      "uint8_t"            --- Vertex stream.
+	.handle      "VertexBufferHandle" --- Vertex buffer.
 
+--- Set vertex buffer for draw primitive.
 func.setVertexBuffer
 	"void"
-	.stream      "uint8_t"
-	.handle      "VertexBufferHandle"
-	.startVertex "uint32_t"
-	.numVertices "uint32_t"
+	.stream      "uint8_t"            --- Vertex stream.
+	.handle      "VertexBufferHandle" --- Vertex buffer.
+	.startVertex "uint32_t"           --- First vertex to render.
+	.numVertices "uint32_t"           --- Number of vertices to render.
 
+--- Set vertex buffer for draw primitive.
+func.setVertexBuffer { cpponly }
+	"void"
+	.stream      "uint8_t"                   --- Vertex stream.
+	.handle      "DynamicVertexBufferHandle" --- Dynamic vertex buffer.
+
+--- Set vertex buffer for draw primitive.
 func.setVertexBuffer { cname = "set_dynamic_vertex_buffer" }
 	"void"
-	.stream      "uint8_t"
-	.handle      "DynamicVertexBufferHandle"
-	.startVertex "uint32_t"
-	.numVertices "uint32_t"
+	.stream      "uint8_t"                   --- Vertex stream.
+	.handle      "DynamicVertexBufferHandle" --- Dynamic vertex buffer.
+	.startVertex "uint32_t"                  --- First vertex to render.
+	.numVertices "uint32_t"                  --- Number of vertices to render.
+
+--- Set vertex buffer for draw primitive.
+func.setVertexBuffer { cpponly }
+	"void"
+	.stream      "uint8_t"                      --- Vertex stream.
+	.tvb         "const TransientVertexBuffer*" --- Transient vertex buffer.
 
+--- Set vertex buffer for draw primitive.
 func.setVertexBuffer { cname = "set_transient_vertex_buffer" }
 	"void"
-	.stream      "uint8_t"
-	.tvb         "const TransientVertexBuffer *"
-	.startVertex "uint32_t"
-	.numVertices "uint32_t"
+	.stream      "uint8_t"                      --- Vertex stream.
+	.tvb         "const TransientVertexBuffer*" --- Transient vertex buffer.
+	.startVertex "uint32_t"                     --- First vertex to render.
+	.numVertices "uint32_t"                     --- Number of vertices to render.
 
+--- Set number of vertices for auto generated vertices use in conjuction
+--- with gl_VertexID.
+---
+--- @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
+---
 func.setVertexCount
 	"void"
-	.numVertices "uint32_t"
+	.numVertices "uint32_t" --- Number of vertices.
 
+--- Set instance data buffer for draw primitive.
+func.setInstanceDataBuffer { cpponly }
+	"void"
+	.idb   "const InstanceDataBuffer*" --- Transient instance data buffer.
+
+--- Set instance data buffer for draw primitive.
 func.setInstanceDataBuffer
 	"void"
-	.idb   "const InstanceDataBuffer *"
-	.start "uint32_t"
-	.num   "uint32_t"
+	.idb   "const InstanceDataBuffer*" --- Transient instance data buffer.
+	.start "uint32_t"                  --- First instance data.
+	.num   "uint32_t"                  --- Number of data instances.
+
+--- Set instance data buffer for draw primitive.
+func.setInstanceDataBuffer { cpponly }
+	"void"
+	.handle      "VertexBufferHandle" --- Vertex buffer.
 
+--- Set instance data buffer for draw primitive.
 func.setInstanceDataBuffer { cname = "set_instance_data_from_vertex_buffer" }
 	"void"
-	.handle      "VertexBufferHandle"
-	.startVertex "uint32_t"
-	.num         "uint32_t"
+	.handle      "VertexBufferHandle" --- Vertex buffer.
+	.startVertex "uint32_t"           --- First instance data.
+	.num         "uint32_t"           --- Number of data instances.
 
+ --- Set instance data buffer for draw primitive.
+func.setInstanceDataBuffer { cpponly }
+	"void"
+	.handle      "DynamicVertexBufferHandle" --- Dynamic vertex buffer.
+
+--- Set instance data buffer for draw primitive.
 func.setInstanceDataBuffer { cname = "set_instance_data_from_dynamic_vertex_buffer" }
 	"void"
-	.handle      "DynamicVertexBufferHandle"
-	.startVertex "uint32_t"
-	.num         "uint32_t"
+	.handle      "DynamicVertexBufferHandle" --- Dynamic vertex buffer.
+	.startVertex "uint32_t"                  --- First instance data.
+	.num         "uint32_t"                  --- Number of data instances.
 
+--- Set number of instances for auto generated instances use in conjuction
+--- with gl_InstanceID.
+---
+--- @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
+---
 func.setInstanceCount
 	"void"
-	.numInstances "uint32_t"
+	.numInstances "uint32_t" -- Number of instances.
 
+--- Set texture stage for draw primitive.
 func.setTexture
 	"void"
-	.stage   "uint8_t"
-	.sampler "UniformHandle"
-	.handle  "TextureHandle"
-	.flags   "uint32_t"
-
+	.stage   "uint8_t"       --- Texture unit.
+	.sampler "UniformHandle" --- Program sampler.
+	.handle  "TextureHandle" --- Texture handle.
+	.flags   "uint32_t"      --- Texture sampling mode. Default value UINT32_MAX uses
+	                         ---   texture sampling settings from the texture.
+	                         ---   - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap
+	                         ---     mode.
+	                         ---   - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
+	                         ---     sampling.
+
+--- Submit an empty primitive for rendering. Uniforms and draw state
+--- will be applied but no geometry will be submitted.
+---
+--- @remark
+---   These empty draw calls will sort before ordinary draw calls.
+---
 func.touch
 	"void"
-	.id "ViewId"
+	.id "ViewId" --- View id.
 
+--- Submit primitive for rendering.
 func.submit
 	"void"
-	.id            "ViewId"
-	.program       "ProgramHandle"
-	.depth         "uint32_t"
-	.preserveState "bool"
+	.id            "ViewId"        --- View id.
+	.program       "ProgramHandle" --- Program.
+	.depth         "uint32_t"      --- Depth for sorting.
+	.preserveState "bool"          --- Preserve internal draw state for next draw call submit.
 
+--- Submit primitive with occlusion query for rendering.
 func.submit { cname = "submit_occlusion_query" }
 	"void"
-	.id             "ViewId"
-	.program        "ProgramHandle"
-	.occlusionQuery "OcclusionQueryHandle"
-	.depth          "uint32_t"
-	.preserveState  "bool"
+	.id             "ViewId"               --- View id.
+	.program        "ProgramHandle"        --- Program.
+	.occlusionQuery "OcclusionQueryHandle" --- Occlusion query.
+	.depth          "uint32_t"             --- Depth for sorting.
+	.preserveState  "bool"                 --- Preserve internal draw state for next draw call submit.
 
+--- Submit primitive for rendering with index and instance data info from
+--- indirect buffer.
 func.submit { cname = "submit_indirect" }
 	"void"
-	.id             "ViewId"
-	.program        "ProgramHandle"
-	.indirectHandle "IndirectBufferHandle"
-	.start          "uint16_t"
-	.num            "uint16_t"
-	.depth          "uint32_t"
-	.preserveState  "bool"
+	.id             "ViewId"               --- View id.
+	.program        "ProgramHandle"        --- Program.
+	.indirectHandle "IndirectBufferHandle" --- Indirect buffer.
+	.start          "uint16_t"             --- First element in indirect buffer.
+	.num            "uint16_t"             --- Number of dispatches.
+	.depth          "uint32_t"             --- Depth for sorting.
+	.preserveState  "bool"                 --- Preserve internal draw state for next draw call submit.
 
+--- Set compute index buffer.
 func.setBuffer { cname = "set_compute_index_buffer" }
 	"void"
-	.stage  "uint8_t"
-	.handle "IndexBufferHandle"
-	.access "Access::Enum"
+	.stage  "uint8_t"           --- Compute stage.
+	.handle "IndexBufferHandle" --- Index buffer handle.
+	.access "Access::Enum"      --- Buffer access. See `Access::Enum`.
 
+--- Set compute vertex buffer.
 func.setBuffer { cname = "set_compute_vertex_buffer" }
 	"void"
-	.stage  "uint8_t"
-	.handle "VertexBufferHandle"
-	.access "Access::Enum"
+	.stage  "uint8_t"            --- Compute stage.
+	.handle "VertexBufferHandle" --- Vertex buffer handle.
+	.access "Access::Enum"       --- Buffer access. See `Access::Enum`.
 
+--- Set compute dynamic index buffer.
 func.setBuffer { cname = "set_compute_dynamic_index_buffer" }
 	"void"
-	.stage  "uint8_t"
-	.handle "DynamicIndexBufferHandle"
-	.access "Access::Enum"
+	.stage  "uint8_t"                  --- Compute stage.
+	.handle "DynamicIndexBufferHandle" --- Dynamic index buffer handle.
+	.access "Access::Enum"             --- Buffer access. See `Access::Enum`.
 
+--- Set compute dynamic vertex buffer.
 func.setBuffer { cname = "set_compute_dynamic_vertex_buffer" }
 	"void"
-	.stage  "uint8_t"
-	.handle "DynamicVertexBufferHandle"
-	.access "Access::Enum"
+	.stage  "uint8_t"                   --- Compute stage.
+	.handle "DynamicVertexBufferHandle" --- Dynamic vertex buffer handle.
+	.access "Access::Enum"              --- Buffer access. See `Access::Enum`.
 
+--- Set compute indirect buffer.
 func.setBuffer { cname = "set_compute_indirect_buffer" }
 	"void"
-	.stage  "uint8_t"
-	.handle "IndirectBufferHandle"
-	.access "Access::Enum"
+	.stage  "uint8_t"              --- Compute stage.
+	.handle "IndirectBufferHandle" --- Indirect buffer handle.
+	.access "Access::Enum"         --- Buffer access. See `Access::Enum`.
 
+--- Set compute image from texture.
 func.setImage
 	"void"
-	.stage  "uint8_t"
-	.handle "TextureHandle"
-	.mip    "uint8_t"
-	.access "Access::Enum"
-	.format "TextureFormat::Enum"
+	.stage  "uint8_t"       --- Compute stage.
+	.handle "TextureHandle" --- Texture handle.
+	.mip    "uint8_t"       --- Mip level.
+	.access "Access::Enum"  --- Image access. See `Access::Enum`.
+	.format "TextureFormat::Enum" { default = "TextureFormat::Count" } --- Texture format. See: `TextureFormat::Enum`.
 
+--- Dispatch compute.
 func.dispatch
 	"void"
-	.id      "ViewId"
-	.program "ProgramHandle"
-	.numX    "uint32_t"
-	.numY    "uint32_t"
-	.numZ    "uint32_t"
+	.id      "ViewId"        --- View id.
+	.program "ProgramHandle" --- Compute program.
+	.numX    "uint32_t"      --- Number of groups X.
+	.numY    "uint32_t"      --- Number of groups Y.
+	.numZ    "uint32_t"      --- Number of groups Z.
 
+--- Dispatch compute indirect.
 func.dispatch { cname = "dispatch_indirect" }
 	"void"
-	.id             "ViewId"
-	.program        "ProgramHandle"
-	.indirectHandle "IndirectBufferHandle"
-	.start          "uint16_t"
-	.num            "uint16_t"
+	.id             "ViewId"               --- View id.
+	.program        "ProgramHandle"        --- Compute program.
+	.indirectHandle "IndirectBufferHandle" --- Indirect buffer.
+	.start          "uint16_t"             --- First element in indirect buffer.
+	.num            "uint16_t"             --- Number of dispatches.
 
+--- Discard all previously set state for draw or compute call.
 func.discard
 	"void"
 
+--- Blit 2D texture region between two 2D textures.
+---
+--- @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag.
+--- @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`.
+---
+func.blit { cpponly }
+	"void"
+	.id     "ViewId"        --- View id.
+	.dst    "TextureHandle" --- Destination texture handle.
+	.dstX   "uint16_t"      --- Destination texture X position.
+	.dstY   "uint16_t"      --- Destination texture Y position.
+	.src    "TextureHandle" --- Source texture handle.
+	 { default = 0 }
+	.srcX   "uint16_t"      --- Source texture X position.
+	 { default = 0 }
+	.srcY   "uint16_t"      --- Source texture Y position.
+	 { default = 0 }
+	.width  "uint16_t"      --- Width of region.
+	 { default = UINT16_MAX }
+	.height "uint16_t"      --- Height of region.
+	 { default = UINT16_MAX }
+
+--- Blit 2D texture region between two 2D textures.
+---
+--- @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag.
+--- @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`.
+---
 func.blit
 	"void"
-	.id     "ViewId"
-	.dst    "TextureHandle"
-	.dstMip "uint8_t"
-	.dstX   "uint16_t"
-	.dstY   "uint16_t"
-	.dstZ   "uint16_t"
-	.src    "TextureHandle"
-	.srcMip "uint8_t"
-	.srcX   "uint16_t"
-	.srcY   "uint16_t"
-	.srcZ   "uint16_t"
-	.width  "uint16_t"
-	.height "uint16_t"
-	.depth  "uint16_t"
+	.id     "ViewId"        --- View id.
+	.dst    "TextureHandle" --- Destination texture handle.
+	.dstMip "uint8_t"       --- Destination texture mip level.
+	.dstX   "uint16_t"      --- Destination texture X position.
+	.dstY   "uint16_t"      --- Destination texture Y position.
+	.dstZ   "uint16_t"      --- 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    "TextureHandle" --- Source texture handle.
+	.srcMip "uint8_t"       --- Source texture mip level.
+	 { default = 0 }
+	.srcX   "uint16_t"      --- Source texture X position.
+	 { default = 0 }
+	.srcY   "uint16_t"      --- Source texture Y position.
+	 { default = 0 }
+	.srcZ   "uint16_t"      --- 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.
+	 { default = 0 }
+	.width  "uint16_t"      --- Width of region.
+	 { default = UINT16_MAX }
+	.height "uint16_t"      --- Height of region.
+	 { default = UINT16_MAX }
+	.depth  "uint16_t"      --- If texture is 3D this argument represents depth of region, otherwise it's
+	                        --- unused.
+	 { default = UINT16_MAX }

+ 574 - 77
scripts/codegen.lua

@@ -3,6 +3,13 @@
 
 local codegen = {}
 
+local NAMEALIGN = 20
+
+local function namealign(name, align)
+	align = align or NAMEALIGN
+	return string.rep(" ", align - #name)
+end
+
 local function camelcase_to_underscorecase(name)
 	local tmp = {}
 	for v in name:gmatch "[%u%d]+%l*" do
@@ -11,20 +18,25 @@ local function camelcase_to_underscorecase(name)
 	return table.concat(tmp, "_")
 end
 
-local function convert_typename(name)
-	if name:match "^%u" then
-		return "bgfx_" .. camelcase_to_underscorecase(name) .. "_t"
-	else
-		return name
-	end
-end
-
 local function convert_funcname(name)
 	name = name:gsub("^%l", string.upper)	-- Change to upper CamlCase
 	return camelcase_to_underscorecase(name)
 end
 
-local function convert_arg(all_types, arg, what)
+local function convert_arg(all_types, arg, namespace)
+	local fulltype, array = arg.fulltype:match "(.-)%s*(%[%s*[%d%a_:]*%s*%])"
+	if array then
+		arg.fulltype = fulltype
+		arg.array = array
+		local enum, value = array:match "%[%s*([%a%d]+)::([%a%d]+)%]"
+		if enum then
+			local typedef = all_types[ enum .. "::Enum" ]
+			if typedef == nil then
+				error ("Unknown Enum " .. enum)
+			end
+			arg.carray = "[BGFX_" .. camelcase_to_underscorecase(enum):upper() .. "_" .. value:upper() .. "]"
+		end
+	end
 	local t, postfix = arg.fulltype:match "(%a[%a%d_:]*)%s*([*&]+)%s*$"
 	if t then
 		arg.type = t
@@ -32,11 +44,23 @@ local function convert_arg(all_types, arg, what)
 			arg.ref = true
 		end
 	else
-		arg.type = arg.fulltype
+		local prefix, t = arg.fulltype:match "^%s*(%a+)%s+(%S+)"
+		if prefix then
+			arg.type = t
+		else
+			arg.type = arg.fulltype
+		end
+	end
+	local ctype
+	local substruct = namespace.substruct
+	if substruct then
+		ctype = substruct[arg.type]
 	end
-	local ctype = all_types[arg.type]
 	if not ctype then
-		error ("Undefined type " .. arg.fulltype .. " for " .. what)
+		ctype = all_types[arg.type]
+	end
+	if not ctype then
+		error ("Undefined type " .. arg.fulltype .. " in " .. namespace.name)
 	end
 	arg.ctype = arg.fulltype:gsub(arg.type, ctype.cname):gsub("&", "*")
 	if ctype.cname ~= arg.type then
@@ -60,45 +84,66 @@ end
 local function gen_arg_conversion(all_types, arg)
 	if arg.ctype == arg.fulltype then
 		-- do not need conversion
-		arg.aname = arg.name
 		return
 	end
 	local ctype = all_types[arg.type]
 	if ctype.handle and arg.type == arg.fulltype then
 		local aname = alternative_name(arg.name)
 		arg.aname = aname .. ".cpp"
+		arg.aname_cpp2c = aname .. ".c"
 		arg.conversion = string.format(
 			"union { %s c; bgfx::%s cpp; } %s = { %s };" ,
 			ctype.cname, arg.type, aname, arg.name)
+		arg.conversion_back = string.format(
+			"union { bgfx::%s cpp; %s c; } %s = { %s };" ,
+			arg.type, ctype.cname, aname, arg.name)
 	elseif arg.ref then
 		if ctype.cname == arg.type then
 			arg.aname = "*" .. arg.name
+			arg.aname_cpp2c = "&" .. arg.name
 		elseif arg.out and ctype.enum then
 			local aname = alternative_name(arg.name)
 			local cpptype = arg.cpptype:match "(.-)%s*&"	-- remove &
+			local c99type = arg.ctype:match "(.-)%s*%*"	-- remove *
 			arg.aname = aname
+			arg.aname_cpp2c = "&" .. aname
 			arg.conversion = string.format("%s %s;", cpptype, aname)
+			arg.conversion_back = string.format("%s %s;", c99type, aname);
 			arg.out_conversion = string.format("*%s = (%s)%s;", arg.name, ctype.cname, aname)
+			arg.out_conversion_back = string.format("%s = (%s)%s;", arg.name, c99type, aname)
 		else
 			arg.aname = alternative_name(arg.name)
+			arg.aname_cpp2c = string.format("(%s)&%s" , arg.ctype , arg.name)
 			arg.conversion = string.format(
 				"%s %s = *(%s)%s;",
 				arg.cpptype, arg.aname, arg.ptype, arg.name)
 		end
 	else
+		local cpptype = arg.cpptype
+		local ctype = arg.ctype
+		if arg.array then
+			cpptype = cpptype .. "*"
+			ctype = ctype .. "*"
+		end
 		arg.aname = string.format(
 			"(%s)%s",
-			arg.cpptype, arg.name)
+			cpptype, arg.name)
+		arg.aname_cpp2c = string.format(
+			"(%s)%s",
+			ctype, arg.name)
 	end
 end
 
 local function gen_ret_conversion(all_types, func)
 	local postfix = { func.vararg and "va_end(argList);" }
+	local postfix_cpp2c = { postfix[1] }
 	func.ret_postfix = postfix
+	func.ret_postfix_cpp2c = postfix_cpp2c
 
 	for _, arg in ipairs(func.args) do
 		if arg.out_conversion then
 			postfix[#postfix+1] = arg.out_conversion
+			postfix_cpp2c[#postfix_cpp2c+1] = arg.out_conversion_back
 		end
 	end
 
@@ -106,79 +151,182 @@ local function gen_ret_conversion(all_types, func)
 	if ctype.handle then
 		func.ret_conversion = string.format(
 			"union { %s c; bgfx::%s cpp; } handle_ret;" ,
-			ctype.cname, func.ret.type)
+			ctype.cname, ctype.name)
+		func.ret_conversion_cpp2c = string.format(
+			"union { bgfx::%s cpp; %s c; } handle_ret;" ,
+			ctype.name, ctype.cname)
 		func.ret_prefix = "handle_ret.cpp = "
+		func.ret_prefix_cpp2c = "handle_ret.c = "
 		postfix[#postfix+1] = "return handle_ret.c;"
+		postfix_cpp2c[#postfix_cpp2c+1] = "return handle_ret.cpp;"
 	elseif func.ret.fulltype ~= "void" then
-		local ctype_conversion = func.ret.type == func.ret.ctype and "" or ("(" ..  func.ret.ctype .. ")")
+		local ctype_conversion = ctype.name == ctype.cname and "" or ("(" ..  func.ret.ctype .. ")")
+		local conversion_back = ctype.name == ctype.cname and "" or ("(" ..  func.ret.cpptype .. ")")
 		if #postfix > 0 then
 			func.ret_prefix = string.format("%s retValue = %s", func.ret.ctype , ctype_conversion)
-			postfix[#postfix+1] = "return retValue;"
+			func.ret_prefix_cpp2c = string.format("%s retValue = %s", func.ret.cpptype , conversion_back)
+			local ret = "return retValue;"
+			postfix[#postfix+1] = ret
+			postfix_cpp2c[#postfix_cpp2c+1] = ret
 		else
 			func.ret_prefix = string.format("return %s", ctype_conversion)
+			func.ret_prefix_cpp2c = string.format("return %s", conversion_back)
 		end
 	end
 end
 
+local function convert_vararg(v)
+	if v.vararg then
+		local args = v.args
+		local vararg = {
+			name = "",
+			fulltype = "...",
+			type = "...",
+			ctype = "...",
+			aname = "argList",
+			conversion = string.format(
+				"va_list argList;\n\tva_start(argList, %s);",
+				args[#args].name),
+		}
+		args[#args + 1] = vararg
+		v.alter_name = v.vararg
+	end
+end
+
 function codegen.nameconversion(all_types, all_funcs)
-	local enums = {}
-	for k,v in pairs(all_types) do
-		if not v.cname then
-			v.cname = convert_typename(k)
+	for _,v in ipairs(all_types) do
+		local name = v.name
+		local cname = v.cname
+		if cname == nil then
+			if name:match "^%u" then
+				cname = camelcase_to_underscorecase(name)
+			else
+				v.cname = name
+			end
+		end
+		if cname then
+			if v.namespace then
+				cname = camelcase_to_underscorecase(v.namespace) .. "_" .. cname
+			end
+			v.cname = "bgfx_".. cname .. "_t"
 		end
 		if v.enum then
-			enums[#enums+1] = k
+			v.name = v.name .. "::Enum"
 		end
 	end
-	for _, e in ipairs(enums) do
-		local t = all_types[e]
-		all_types[e] = nil
-		all_types[e .. "::Enum"] = t
+
+	-- make index
+	for _,v in ipairs(all_types) do
+		if not v.namespace then
+			if all_types[v.name] then
+				error ("Duplicate type " .. v.name)
+			end
+			all_types[v.name] = v
+		end
+	end
+
+	-- make sub struct index
+	for _,v in ipairs(all_types) do
+		if v.namespace then
+			local super = all_types[v.namespace]
+			if not super then
+				error ("Define " .. v.namespace .. " first")
+			end
+			local substruct = super.substruct
+			if not substruct then
+				substruct = {}
+				super.substruct = substruct
+			end
+			if substruct[v.name] then
+				error ( "Duplicate sub struct " .. v.name .. " in " .. v.namespace)
+			end
+			substruct[#substruct+1] = v
+			substruct[v.name] = v
+		end
+	end
+
+	for _,v in ipairs(all_types) do
+		if v.struct then
+			for _, item in ipairs(v.struct) do
+				convert_arg(all_types, item, v)
+			end
+		elseif v.args then
+			-- funcptr
+			for _, arg in ipairs(v.args) do
+				convert_arg(all_types, arg, v)
+			end
+			convert_vararg(v)
+			convert_arg(all_types, v.ret, v)
+		end
 	end
 
+	local funcs = {}
+	local funcs_conly = {}
+	local funcs_alter = {}
+
 	for _,v in ipairs(all_funcs) do
 		if v.cname == nil then
 			v.cname = convert_funcname(v.name)
 		end
 		if v.class then
 			v.cname = convert_funcname(v.class) .. "_" .. v.cname
+			local classtype = all_types[v.class]
+			if classtype then
+				local methods = classtype.methods
+				if not methods then
+					methods = {}
+					classtype.methods = methods
+				end
+				methods[#methods+1] = v
+			end
+		elseif not v.conly then
+			funcs[v.name] = v
 		end
+
+		if v.conly then
+			table.insert(funcs_conly, v)
+		end
+
 		for _, arg in ipairs(v.args) do
-			convert_arg(all_types, arg, v.name)
+			convert_arg(all_types, arg, v)
 			gen_arg_conversion(all_types, arg)
 		end
-		if v.vararg then
-			local args = v.args
-			local vararg = {
-				name = "",
-				ctype = "...",
-				aname = "argList",
-				conversion = string.format(
-					"va_list argList;\n\tva_start(argList, %s);",
-					args[#args].name),
-			}
-			args[#args + 1] = vararg
-			v.implname = v.vararg
-		else
-			v.implname = v.name
+		convert_vararg(v)
+		if v.alter_name then
+			funcs_alter[#funcs_alter+1] = v
 		end
-		convert_arg(all_types, v.ret, v.name .. "@rettype")
+		convert_arg(all_types, v.ret, v)
 		gen_ret_conversion(all_types, v)
-		if v.class then
-			local classname = v.class
+		local namespace = v.class
+		if namespace then
+			local classname = namespace
 			if v.const then
 				classname = "const " .. classname
 			end
 			local classtype = { fulltype = classname .. "*" }
-			convert_arg(all_types, classtype, "class member " .. v.name)
+			convert_arg(all_types, classtype, v)
 			v.this = classtype.ctype .. " _this"
 			v.this_conversion = string.format( "%s This = (%s)_this;", classtype.cpptype, classtype.cpptype)
+			v.this_to_c = string.format("(%s)this", classtype.ctype)
+		end
+	end
+
+	for _, v in ipairs(funcs_conly) do
+		local func = funcs[v.name]
+		if func then
+			func.multicfunc = func.multicfunc or { func.cname }
+			table.insert(func.multicfunc, v.cname)
 		end
 	end
+
+	for _, v in ipairs(funcs_alter) do
+		local func = funcs[v.alter_name]
+		v.alter_cname = func.cname
+	end
 end
 
 local function lines(tbl)
-	if #tbl == 0 then
+	if not tbl or #tbl == 0 then
 		return "//EMPTYLINE"
 	else
 		return table.concat(tbl, "\n\t")
@@ -191,34 +339,113 @@ end
 
 local function codetemp(func)
 	local conversion = {}
+	local conversion_c2cpp = {}
 	local args = {}
+	local cargs = {}
+	local callargs_conversion = {}
+	local callargs_conversion_back = {}
 	local callargs = {}
 	local cppfunc
+	local classname
+
 	if func.class then
 		-- It's a member function
-		args[1] = func.this
+		cargs[1] = func.this
 		conversion[1] = func.this_conversion
 		cppfunc = "This->" .. func.name
+		callargs[1] = "_this"
+		callargs_conversion_back[1] = func.this_to_c
+		classname = func.class .. "::"
 	else
-		cppfunc = "bgfx::" .. func.implname
+		cppfunc = "bgfx::" .. tostring(func.alter_name or func.name)
+		classname = ""
 	end
 	for _, arg in ipairs(func.args) do
 		conversion[#conversion+1] = arg.conversion
-		args[#args+1] = arg.ctype .. " " .. arg.name
-		callargs[#callargs+1] = arg.aname
+		conversion_c2cpp[#conversion_c2cpp+1] = arg.conversion_back
+		local cname = arg.ctype .. " " .. arg.name
+		if arg.array then
+			cname = cname .. (arg.carray or arg.array)
+		end
+		local name = arg.fulltype .. " " .. arg.name
+		if arg.array then
+			name = name .. arg.array
+		end
+		if arg.default then
+			name = name .. " = " .. arg.default
+		end
+		cargs[#cargs+1] = cname
+		args[#args+1] = name
+		callargs_conversion[#callargs_conversion+1] = arg.aname or arg.name
+		callargs_conversion_back[#callargs_conversion_back+1] = arg.aname_cpp2c or arg.name
+		callargs[#callargs+1] = arg.name
 	end
 	conversion[#conversion+1] = func.ret_conversion
+	conversion_c2cpp[#conversion_c2cpp+1] = func.ret_conversion_cpp2c
+
+	local ARGS
+	local args_n = #args
+	if args_n == 0 then
+		ARGS = ""
+	elseif args_n == 1 then
+		ARGS = args[1]
+	else
+		ARGS = "\n\t  " .. table.concat(args, "\n\t, ") .. "\n\t"
+	end
+
+	local preret_c2c
+	local postret_c2c = {}
+	local conversion_c2c = {}
+	local callfunc_c2c
+
+	if func.vararg then
+		postret_c2c[1] = "va_end(argList);"
+		local vararg = func.args[#func.args]
+		callargs[#callargs] = vararg.aname
+		callargs_conversion_back[#callargs_conversion_back] = vararg.aname
+		conversion_c2c[1] = vararg.conversion
+		conversion_c2cpp[1] = vararg.conversion
+
+		if func.ret.fulltype == "void" then
+			preret_c2c = ""
+		else
+			preret_c2c = func.ret.ctype .. " retValue = "
+			postret_c2c[#postret_c2c+1] = "return retValue;"
+		end
+		callfunc_c2c = func.alter_cname or func.cname
+	else
+		if func.ret.fulltype == "void" then
+			preret_c2c = ""
+		else
+			preret_c2c = "return "
+		end
+		callfunc_c2c = func.cname
+	end
 
 	return {
-		RET = func.ret.ctype,
-		FUNCNAME = func.cname,
-		ARGS = table.concat(args, ", "),
+		RET = func.ret.fulltype,
+		CRET = func.ret.ctype,
+		CFUNCNAME = func.cname,
+		FUNCNAME = func.name,
+		CARGS = table.concat(cargs, ", "),
+		CPPARGS = table.concat(args, ", "),
+		ARGS = ARGS,
 		CONVERSION = lines(conversion),
+		CONVERSIONCTOC = lines(conversion_c2c),
+		CONVERSIONCTOCPP = lines(conversion_c2cpp),
 		PRERET = func.ret_prefix or "",
+		PRERETCPPTOC = func.ret_prefix_cpp2c or "",
 		CPPFUNC = cppfunc,
+		CALLFUNCCTOC = callfunc_c2c,
+		CALLARGSCTOCPP = table.concat(callargs_conversion, ", "),
+		CALLARGSCPPTOC = table.concat(callargs_conversion_back, ", "),
 		CALLARGS = table.concat(callargs, ", "),
 		POSTRET = lines(func.ret_postfix),
-		CODE = func.cfunc,
+		POSTRETCPPTOC = lines(func.ret_postfix_cpp2c),
+		PRERETCTOC = preret_c2c,
+		POSTRETCTOC = lines(postret_c2c),
+		CLASSNAME = classname,
+		CONST = func.const and " const" or "",
 	}
 end
 
@@ -227,45 +454,315 @@ local function apply_template(func, temp)
 	return (temp:gsub("$(%u+)", func.codetemp))
 end
 
-local c99temp = [[
-BGFX_C_API $RET bgfx_$FUNCNAME($ARGS)
+function codegen.apply_functemp(func, temp)
+		return remove_emptylines(apply_template(func, temp))
+end
+
+function codegen.gen_funcptr(funcptr)
+	return apply_template(funcptr, "typedef $RET (*$FUNCNAME)($ARGS);")
+end
+
+function codegen.gen_cfuncptr(funcptr)
+	return apply_template(funcptr, "typedef $CRET (*$CFUNCNAME)($CARGS);")
+end
+
+local function doxygen_funcret(r, func, prefix)
+	if not func or func.ret.fulltype == "void" or func.ret.comment == nil then
+		return
+	end
+	r[#r+1] = prefix
+	if type(func.ret.comment) == "string" then
+		r[#r+1] = string.format("%s @returns %s", prefix, func.ret.comment)
+	else
+		r[#r+1] = string.format("%s @returns %s", prefix, func.ret.comment[1])
+		for i = 2,#func.ret.comment do
+			r[#r+1] = string.format("%s  %s", prefix, func.ret.comment[i])
+		end
+	end
+	return r
+end
+
+local function doxygen_func(r, func, prefix)
+	if not func or not func.args or #func.args == 0 then
+		return
+	end
+	r[#r+1] = prefix
+	for _, arg in ipairs(func.args) do
+		local inout
+		if arg.out then
+			inout = "out"
+		elseif arg.inout then
+			inout = "inout"
+		else
+			inout = "in"
+		end
+		local comment = string.format("%s @param[%s] %s", prefix, inout, arg.name)
+		if arg.comment then
+			if type(arg.comment) == "string" then
+				r[#r+1] = comment .. " " .. arg.comment
+			else
+				r[#r+1] = comment .. " " .. arg.comment[1]
+				for i = 2,#arg.comment do
+					r[#r+1] = string.format("%s  %s", prefix, arg.comment[i])
+				end
+			end
+		else
+			r[#r+1] = comment
+		end
+	end
+	doxygen_funcret(r, func, prefix)
+	return r
+end
+
+function codegen.doxygen_type(doxygen, func, cname)
+	if doxygen == nil then
+		return
+	end
+	local result = {}
+	for _, line in ipairs(doxygen) do
+		result[#result+1] = "/// " .. line
+	end
+	doxygen_func(result, func, "///")
+	if cname then
+		result[#result+1] = "///"
+		if type(cname) == "string" then
+			result[#result+1] = string.format("/// @attention C99 equivalent is `%s`.", cname)
+		else
+			local names = {}
+			for _, v in ipairs(cname) do
+				names[#names+1] = "`" .. v .. "`"
+			end
+			result[#result+1] = string.format("/// @attention C99 equivalent are %s.", table.concat(names, ","))
+		end
+	end
+	result[#result+1] = "///"
+	return table.concat(result, "\n")
+end
+
+function codegen.doxygen_ctype(doxygen, func)
+	if doxygen == nil then
+		return
+	end
+	local result = {
+		"/**",
+	}
+	for _, line in ipairs(doxygen) do
+		result[#result+1] = " * " .. line
+	end
+	doxygen_func(result, func, " *")
+	result[#result+1] = " *"
+	result[#result+1] = " */"
+	return table.concat(result, "\n")
+end
+
+local enum_temp = [[
+struct $NAME
 {
-	$CONVERSION
-	$PRERET$CPPFUNC($CALLARGS);
-	$POSTRET
-}
+	$COMMENT
+	enum Enum
+	{
+		$ITEMS
+
+		Count
+	};
+};
 ]]
 
-local c99usertemp = [[
-BGFX_C_API $RET bgfx_$FUNCNAME($ARGS)
+function codegen.gen_enum_define(enum)
+	assert(type(enum.enum) == "table", "Not an enum")
+	local items = {}
+	for _, item in ipairs(enum.enum) do
+		local text
+		if not item.comment then
+			text = item.name .. ","
+		else
+			text = string.format("%s,%s //!< %s",
+				item.name, namealign(item.name), item.comment)
+		end
+		items[#items+1] = text
+	end
+	local comment = ""
+	if enum.comment then
+		comment = "/// " .. enum.comment
+	end
+	local temp = {
+		NAME = enum.name,
+		COMMENT = comment,
+		ITEMS = table.concat(items, "\n\t\t"),
+	}
+	return (enum_temp:gsub("$(%u+)", temp))
+end
+
+local cenum_temp = [[
+typedef enum $NAME
 {
-$CODE
-}
+	$ITEMS
+
+	$COUNT
+
+} $NAME_t;
 ]]
+function codegen.gen_enum_cdefine(enum)
+	assert(type(enum.enum) == "table", "Not an enum")
+	local cname = enum.cname:match "(.-)_t$"
+	local uname = cname:upper()
+	local items = {}
+	for index , item in ipairs(enum.enum) do
+		local comment = item.comment or ""
+		local ename = item.cname
+		if not ename then
+			if enum.underscore then
+				ename = camelcase_to_underscorecase(item.name)
+			else
+				ename = item.name
+			end
+			ename = ename:upper()
+		end
+		local name = uname .. "_" .. ename
+		items[#items+1] = string.format("%s,%s /** (%2d) %s%s */",
+			name,
+			namealign(name, 40),
+			index - 1,
+			comment,
+			namealign(comment, 30))
+	end
 
-function codegen.gen_c99(func)
-	if func.cfunc then
-		return apply_template(func, c99usertemp)
+	local temp = {
+		NAME = cname,
+		COUNT = uname .. "_COUNT",
+		ITEMS = table.concat(items, "\n\t"),
+	}
+
+	return (cenum_temp:gsub("$(%u+)", temp))
+end
+
+local function text_with_comments(items, item, cstyle, is_classmember)
+	local name = item.name
+	if item.array then
+		if cstyle then
+			name = name .. (item.carray or item.array)
+		else
+			name = name .. item.array
+		end
+	end
+	local typename
+	if cstyle then
+		typename = item.ctype
 	else
-		return remove_emptylines(apply_template(func, c99temp))
+		typename = item.fulltype
+	end
+	if is_classmember then
+		name = "m_" .. name
 	end
+	local text = string.format("%s%s %s;", typename, namealign(typename), name)
+	if item.comment then
+		if type(item.comment) == "table" then
+			table.insert(items, "")
+			if cstyle then
+				table.insert(items, "/**")
+				for _, c in ipairs(item.comment) do
+					table.insert(items, " * " .. c)
+				end
+				table.insert(items, " */")
+			else
+				for _, c in ipairs(item.comment) do
+					table.insert(items, "/// " .. c)
+				end
+			end
+		else
+			text = string.format(
+				cstyle and "%s %s/** %s%s */" or "%s %s//!< %s",
+				text, namealign(text, 40),  item.comment, namealign(item.comment, 40))
+		end
+	end
+	items[#items+1] = text
 end
 
-local template_function_declaration = [[
-/**/
-BGFX_C_API $RET bgfx_$FUNCNAME($ARGS);
+local struct_temp = [[
+struct $NAME
+{
+	$METHODS
+	$SUBSTRUCTS
+	$ITEMS
+};
 ]]
 
-function codegen.gen_c99decl(func)
-	return apply_template(func, template_function_declaration)
+function codegen.gen_struct_define(struct, methods)
+	assert(type(struct.struct) == "table", "Not a struct")
+	local items = {}
+	for _, item in ipairs(struct.struct) do
+		text_with_comments(items, item, false, methods ~= nil)
+	end
+	local ctor = {}
+	if struct.ctor then
+		ctor[1] = struct.name .. "();"
+		ctor[2] = ""
+	end
+	if methods then
+		for _, m in ipairs(methods) do
+			if m:sub(-1) ~= "\n" then
+				m = m .. "\n"
+			end
+			for line in m:gmatch "(.-)\n" do
+				ctor[#ctor+1] = line
+			end
+			ctor[#ctor+1] = ""
+		end
+	end
+	local subs = {}
+	if struct.substruct then
+		for _, v in ipairs(struct.substruct) do
+			local s = codegen.gen_struct_define(v)
+			s = s:gsub("\n", "\n\t")
+			subs[#subs+1] = s
+		end
+	end
+
+	local temp = {
+		NAME = struct.name,
+		SUBSTRUCTS = lines(subs),
+		ITEMS = table.concat(items, "\n\t"),
+		METHODS = lines(ctor),
+	}
+	return remove_emptylines(struct_temp:gsub("$(%u+)", temp))
 end
 
-function codegen.gen_interface_struct(func)
-	return apply_template(func, "$RET (*$FUNCNAME)($ARGS);")
+local cstruct_temp = [[
+typedef struct $NAME_s
+{
+	$ITEMS
+
+} $NAME_t;
+]]
+function codegen.gen_struct_cdefine(struct)
+	assert(type(struct.struct) == "table", "Not a struct")
+	local cname = struct.cname:match "(.-)_t$"
+	local items = {}
+	for _, item in ipairs(struct.struct) do
+		text_with_comments(items, item, true)
+	end
+	local temp = {
+		NAME = cname,
+		ITEMS = table.concat(items, "\n\t"),
+	}
+	return (cstruct_temp:gsub("$(%u+)", temp))
 end
 
-function codegen.gen_interface_import(func)
-	return "bgfx_" .. func.cname
+local chandle_temp = [[
+typedef struct $NAME_s { uint16_t idx; } $NAME_t;
+]]
+function codegen.gen_chandle(handle)
+	assert(handle.handle, "Not a handle")
+	return (chandle_temp:gsub("$(%u+)", { NAME = handle.cname:match "(.-)_t$" }))
+end
+
+local handle_temp = [[
+struct $NAME { uint16_t idx; };
+inline bool isValid($NAME _handle) { return bgfx::kInvalidHandle != _handle.idx; }
+]]
+function codegen.gen_handle(handle)
+	assert(handle.handle, "Not a handle")
+	return (handle_temp:gsub("$(%u+)", { NAME = handle.name }))
 end
 
 return codegen

+ 21 - 0
scripts/doxygen.lua

@@ -0,0 +1,21 @@
+local idl = require "idl"
+
+local doxygen = {}
+
+function doxygen.load(filename)
+	local lines = {}
+	for line in io.lines(filename) do
+		local code, comment = line:match "(.-)%-%-%-[ \t](.*)"
+		if code then
+			if code == "" then
+				line = string.format("comment [[%s]]", comment)
+			else
+				line = string.format("%s [[%s]]", code, comment)
+			end
+		end
+		lines[#lines+1] = line
+	end
+	return table.concat(lines, "\n")
+end
+
+return doxygen

+ 192 - 57
scripts/idl.lua

@@ -3,17 +3,50 @@
 
 local idl = {}
 
+local comments = {}
+
+function idl.comment(c)
+	comments[#comments+1] = c
+end
+
 local all_types = {}
 
+local function copy_attribs(to, from)
+	assert(type(from) == "table", "Attribs should be a table")
+	for k, v in pairs(from) do
+		if type(k) == "number" then
+			to[v] = true
+		else
+			to[k] = v
+		end
+	end
+end
+
+local function classdef(item, def)
+	local function class(_, methodname)
+		item.class = item.name
+		item.name = methodname
+		return def
+	end
+
+	return setmetatable({} , { __index = class, __call = function(_, value) return def(value) end })
+end
+
+local function new_type(typename)
+	local t = { name = typename }
+	if #comments > 0 then
+		t.comments = comments
+		comments = {}
+	end
+	all_types[#all_types+1] = t
+	return t
+end
+
 local function typedef(_, typename)
-	assert(all_types[typename] == nil, "Duplicate type")
-	local t = {}
-	all_types[typename] = t
+	local t = new_type(typename)
+
 	local function type_attrib(attrib)
-		assert(type(attrib) == "table", "type attrib should be a table")
-		for _, a in ipairs(attrib) do
-			t[a] = true
-		end
+		copy_attribs(t, attrib)
 	end
 	return function(cname)
 		local typ = type(cname)
@@ -30,75 +63,177 @@ end
 idl.typedef = setmetatable({} , { __index = typedef, __call = typedef })
 idl.types = all_types
 
-local all_funcs = {}
-
-local function duplicate_arg_name(name)
-	error ("Duplicate arg name " .. name)
+local function add_comment(item, comment)
+	-- strip space
+	comment = comment:match "(.-)%s*$"
+	local last = item.comment
+	if last then
+		if type(last) == "string" then
+			item.comment = { last, comment }
+		else
+			table.insert(item.comment, comment)
+		end
+	else
+		item.comment = comment
+	end
 end
 
-local function funcdef(_, funcname)
-	local f = { name = funcname , args = {} }
-	all_funcs[#all_funcs+1] = f
-	local args
-	local function args_desc(obj, args_name)
-		obj[args_name] = duplicate_arg_name
-		return function (fulltype)
-			local arg = {
-				name = "_" .. args_name,
-				fulltype = fulltype,
-			}
-			f.args[#f.args+1] = arg
-			local function arg_attrib(_, attrib )
-				assert(type(attrib) == "table", "Arg attributes should be a table")
-				for _, a in ipairs(attrib) do
-					arg[a] = true
-				end
-				return args
+local function enumdef(_, typename)
+	local t = new_type(typename)
+	t.enum = {}
+
+	local function enum_attrib(obj, attribs)
+		copy_attribs(t, attribs)
+		return obj
+	end
+
+	local function new_enum_item(_, itemname)
+		local item = { name = itemname }
+		t.enum[#t.enum + 1] = item
+		local function add_attrib_or_comment(obj , attribs)
+			if type(attribs) == "string" then
+				add_comment(item, attribs)
+			elseif attribs then
+				copy_attribs(item, attribs)
 			end
-			return setmetatable( {} , {
-				__index = function(_, name)
-					return args_desc(obj, name)
-				end
-				, __call = arg_attrib } )
+			return obj
 		end
+		return setmetatable({}, { __index = new_enum_item, __call = add_attrib_or_comment })
 	end
-	args = setmetatable({}, { __index = args_desc })
-	local function rettype(value)
-		assert(type(value) == "string", "Need return type")
-		f.ret = { fulltype = value }
-		return args
+
+	return setmetatable({}, { __index = new_enum_item , __call = enum_attrib })
+end
+
+idl.enum = setmetatable({} , { __index = enumdef, __call = enumdef })
+
+local function structdef(_, typename)
+	local t = new_type(typename)
+	t.struct = {}
+
+	local function struct_attrib(obj, attribs)
+		copy_attribs(t, attribs)
+		return obj
 	end
 
-	local function funcdef(value)
-		if type(value) == "table" then
-			for k,v in pairs(value) do
-				if type(k) == "number" then
-					f[v] = true
-				else
-					f[k] = v
-				end
+	local function new_struct_item(_, itemname)
+		local item = { name = itemname }
+		t.struct[#t.struct + 1] = item
+
+		local function item_attrib(obj, attribs)
+			if type(attribs) == "string" then
+				add_comment(item, attribs)
+			else
+				copy_attribs(item, attribs)
 			end
-			return rettype
+			return obj
+		end
+
+		return function (itemtype)
+			item.fulltype = itemtype
+			return setmetatable({}, { __index = new_struct_item, __call = item_attrib })
 		end
-		return rettype(value)
 	end
 
-	local function classfunc(_, methodname)
-		f.class = f.name
-		f.name = methodname
-		return funcdef
+	return setmetatable({}, { __index = new_struct_item , __call = struct_attrib })
+end
+
+idl.struct = setmetatable({}, { __index = structdef , __call = structdef })
+
+local function handledef(_, typename)
+	local t = new_type(typename)
+	t.handle = true
+
+	return function (attribs)
+		copy_attribs(t, attribs)
+		return obj
+	end
+end
+
+idl.handle = setmetatable({} , { __index = handledef, __call = handledef })
+
+local all_funcs = {}
+
+local function duplicate_arg_name(_, name)
+	error ("Duplicate arg name " .. name)
+end
+
+local function attribs_setter(args, arg, args_desc)
+	local attribs_setter
+	local function arg_attrib_or_comment(_, attrib_or_comment )
+		if type(attrib_or_comment) == "string" then
+			add_comment(arg, attrib_or_comment)
+		else
+			copy_attribs(arg, attrib_or_comment)
+		end
+		return attribs_setter
 	end
+	-- next field (__index) or attrib/comment (__call)
+	attribs_setter = setmetatable( {} , {
+		__index = function(_, name)
+			return args_desc(args, name)
+		end
+		, __call = arg_attrib_or_comment } )
+	return attribs_setter
+end
+
+local function func(sets)
+	return function (_, funcname)
+		local f = { name = funcname , args = {} }
+		if #comments > 0 then
+			f.comments = comments
+			comments = {}
+		end
+		sets[#sets+1] = f
+		local args
+		local function args_desc(_, args_name)
+			args[args_name] = duplicate_arg_name
+			return function (fulltype)
+				local arg = {
+					name = "_" .. args_name,
+					fulltype = fulltype,
+				}
+				f.args[#f.args+1] = arg
+				return attribs_setter(args, arg, args_desc)
+			end
+		end
+		args = setmetatable({}, { __index = args_desc })
+		local function rettype(value)
+			assert(type(value) == "string", "Need return type")
+			local ret = { fulltype = value }
+			f.ret = ret
+			return attribs_setter(args, ret, args_desc)
+		end
 
-	return setmetatable({} , { __index = classfunc, __call = function(_, value) return funcdef(value) end })
+		local function funcdef(value)
+			if type(value) == "table" then
+				copy_attribs(f, value)
+				return rettype
+			end
+			return rettype(value)
+		end
+
+		return classdef(f, funcdef)
+	end
 end
 
-idl.func = setmetatable({}, { __index = funcdef })
+idl.funcptr = setmetatable({}, { __index = func(all_types) })
+idl.func = setmetatable({}, { __index = func(all_funcs) })
 idl.funcs = all_funcs
 
-idl.handle = "handle"
-idl.enum = "enum"
+idl.vararg = "vararg"
 idl.out = "out"
+idl.inout = "inout"
 idl.const = "const"
+idl.ctor = "ctor"
+idl.cfunc = "cfunc"
+idl.underscore = "underscore"
+idl.conly = "conly"
+idl.cpponly = "cpponly"
+idl.NULL = "NULL"
+idl.UINT16_MAX = "UINT16_MAX"
+idl.INT32_MAX = "INT32_MAX"
+idl.UINT32_MAX = "UINT32_MAX"
+idl.UINT8_MAX = "UINT8_MAX"
 
 return setmetatable(idl , { __index = function (_, keyword)
 	error (tostring(keyword) .. " is invalid")

+ 127 - 0
scripts/temp.bgfx.h

@@ -0,0 +1,127 @@
+/*
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
+ *
+ * vim: set tabstop=4 expandtab:
+ */
+
+/*
+ *
+ * AUTO GENERATED! DO NOT EDIT! ( source : $source )
+ *
+ */
+
+#ifndef BGFX_C99_H_HEADER_GUARD
+#define BGFX_C99_H_HEADER_GUARD
+
+#include <stdarg.h>  // va_list
+#include <stdbool.h> // bool
+#include <stdint.h>  // uint32_t
+#include <stdlib.h>  // size_t
+
+#include <bx/platform.h>
+
+#if !defined(BGFX_INVALID_HANDLE)
+#   define BGFX_INVALID_HANDLE { UINT16_MAX }
+#endif // !defined(BGFX_INVALID_HANDLE)
+
+#ifndef BGFX_SHARED_LIB_BUILD
+#    define BGFX_SHARED_LIB_BUILD 0
+#endif // BGFX_SHARED_LIB_BUILD
+
+#ifndef BGFX_SHARED_LIB_USE
+#    define BGFX_SHARED_LIB_USE 0
+#endif // BGFX_SHARED_LIB_USE
+
+#if BX_PLATFORM_WINDOWS
+#   define BGFX_SYMBOL_EXPORT __declspec(dllexport)
+#   define BGFX_SYMBOL_IMPORT __declspec(dllimport)
+#else
+#   define BGFX_SYMBOL_EXPORT __attribute__((visibility("default")))
+#   define BGFX_SYMBOL_IMPORT
+#endif // BX_PLATFORM_WINDOWS
+
+#if BGFX_SHARED_LIB_BUILD
+#   define BGFX_SHARED_LIB_API BGFX_SYMBOL_EXPORT
+#elif BGFX_SHARED_LIB_USE
+#   define BGFX_SHARED_LIB_API BGFX_SYMBOL_IMPORT
+#else
+#   define BGFX_SHARED_LIB_API
+#endif // BGFX_SHARED_LIB_*
+
+#if defined(__cplusplus)
+#   define BGFX_C_API extern "C" BGFX_SHARED_LIB_API
+#else
+#   define BGFX_C_API BGFX_SHARED_LIB_API
+#endif // defined(__cplusplus)
+
+#include "../defines.h"
+
+$cenums
+
+/**/
+typedef uint16_t bgfx_view_id_t;
+
+/**/
+typedef struct bgfx_allocator_interface_s
+{
+    const struct bgfx_allocator_vtbl_s* vtbl;
+
+} bgfx_allocator_interface_t;
+
+/**/
+typedef struct bgfx_allocator_vtbl_s
+{
+    void* (*realloc)(bgfx_allocator_interface_t* _this, void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line);
+
+} bgfx_allocator_vtbl_t;
+
+/**/
+typedef struct bgfx_interface_vtbl bgfx_interface_vtbl_t;
+
+/**/
+typedef struct bgfx_callback_interface_s
+{
+    const struct bgfx_callback_vtbl_s* vtbl;
+
+} bgfx_callback_interface_t;
+
+
+/**/
+typedef struct bgfx_callback_vtbl_s
+{
+    void (*fatal)(bgfx_callback_interface_t* _this, const char* _filePath, uint16_t _line, bgfx_fatal_t _code, const char* _str);
+    void (*trace_vargs)(bgfx_callback_interface_t* _this, const char* _filePath, uint16_t _line, const char* _format, va_list _argList);
+    void (*profiler_begin)(bgfx_callback_interface_t* _this, const char* _name, uint32_t _abgr, const char* _filePath, uint16_t _line);
+    void (*profiler_begin_literal)(bgfx_callback_interface_t* _this, const char* _name, uint32_t _abgr, const char* _filePath, uint16_t _line);
+    void (*profiler_end)(bgfx_callback_interface_t* _this);
+    uint32_t (*cache_read_size)(bgfx_callback_interface_t* _this, uint64_t _id);
+    bool (*cache_read)(bgfx_callback_interface_t* _this, uint64_t _id, void* _data, uint32_t _size);
+    void (*cache_write)(bgfx_callback_interface_t* _this, uint64_t _id, const void* _data, uint32_t _size);
+    void (*screen_shot)(bgfx_callback_interface_t* _this, const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data, uint32_t _size, bool _yflip);
+    void (*capture_begin)(bgfx_callback_interface_t* _this, uint32_t _width, uint32_t _height, uint32_t _pitch, bgfx_texture_format_t _format, bool _yflip);
+    void (*capture_end)(bgfx_callback_interface_t* _this);
+    void (*capture_frame)(bgfx_callback_interface_t* _this, const void* _data, uint32_t _size);
+
+} bgfx_callback_vtbl_t;
+
+$chandles
+
+$cfuncptrs
+
+$cstructs
+
+$c99decl
+
+struct bgfx_interface_vtbl
+{
+	$interface_struct
+};
+
+/**/
+typedef bgfx_interface_vtbl_t* (*PFN_BGFX_GET_INTERFACE)(uint32_t _version);
+
+/**/
+BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version);
+
+#endif // BGFX_C99_H_HEADER_GUARD

+ 59 - 0
scripts/temp.bgfx.idl.inl

@@ -0,0 +1,59 @@
+/*
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+/*
+ *
+ * AUTO GENERATED! DO NOT EDIT!
+ *
+ */
+
+$c99
+
+/* user define functions */
+BGFX_C_API void bgfx_init_ctor(bgfx_init_t* _init)
+{
+	BX_PLACEMENT_NEW(_init, bgfx::Init);
+
+}
+
+BGFX_C_API bool bgfx_init(const bgfx_init_t * _init)
+{
+	bgfx_init_t init =*_init;
+
+	if (init.callback != NULL)
+	{
+		static bgfx::CallbackC99 s_callback;
+		s_callback.m_interface = init.callback;
+		init.callback = reinterpret_cast<bgfx_callback_interface_t*>(&s_callback);
+	}
+
+	if (init.allocator != NULL)
+	{
+		static bgfx::AllocatorC99 s_allocator;
+		s_allocator.m_interface = init.allocator;
+		init.allocator = reinterpret_cast<bgfx_allocator_interface_t*>(&s_allocator);
+	}
+
+	union { const bgfx_init_t* c; const bgfx::Init* cpp; } in;
+	in.c = &init;
+
+	return bgfx::init(*in.cpp);
+
+}
+
+/**/
+BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
+{
+	if (_version == BGFX_API_VERSION)
+	{
+		static bgfx_interface_vtbl_t s_bgfx_interface =
+		{
+			$interface_import
+		};
+
+		return &s_bgfx_interface;
+	}
+
+	return NULL;
+}

+ 167 - 147
src/bgfx.idl.inl

@@ -8,10 +8,17 @@
  *
  */
 
-BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _this, bgfx_renderer_type_t _renderer)
+BGFX_C_API void bgfx_attachment_init(bgfx_attachment_t* _this, bgfx_texture_handle_t _handle, bgfx_access_t _access, uint16_t _layer, uint16_t _mip, uint8_t _resolve)
+{
+	bgfx::Attachment* This = (bgfx::Attachment*)_this;
+	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
+	This->init(handle.cpp, (bgfx::Access::Enum)_access, _layer, _mip, _resolve);
+}
+
+BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _this, bgfx_renderer_type_t _rendererType)
 {
 	bgfx::VertexDecl* This = (bgfx::VertexDecl*)_this;
-	This->begin((bgfx::RendererType::Enum)_renderer);
+	This->begin((bgfx::RendererType::Enum)_rendererType);
 }
 
 BGFX_C_API void bgfx_vertex_decl_add(bgfx_vertex_decl_t* _this, bgfx_attrib_t _attrib, uint8_t _num, bgfx_attrib_type_t _type, bool _normalized, bool _asInt)
@@ -46,81 +53,54 @@ BGFX_C_API void bgfx_vertex_decl_end(bgfx_vertex_decl_t* _this)
 	This->end();
 }
 
-BGFX_C_API void bgfx_vertex_pack(const float * _input, bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, void * _data, uint32_t _index)
+BGFX_C_API void bgfx_vertex_pack(const float _input[4], bool _inputNormalized, bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, void* _data, uint32_t _index)
 {
 	const bgfx::VertexDecl & decl = *(const bgfx::VertexDecl *)_decl;
 	bgfx::vertexPack(_input, _inputNormalized, (bgfx::Attrib::Enum)_attr, decl, _data, _index);
 }
 
-BGFX_C_API void bgfx_vertex_unpack(float * _output, bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, const void * _data, uint32_t _index)
+BGFX_C_API void bgfx_vertex_unpack(float _output[4], bgfx_attrib_t _attr, const bgfx_vertex_decl_t * _decl, const void* _data, uint32_t _index)
 {
 	const bgfx::VertexDecl & decl = *(const bgfx::VertexDecl *)_decl;
 	bgfx::vertexUnpack(_output, (bgfx::Attrib::Enum)_attr, decl, _data, _index);
 }
 
-BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_decl_t * _dstDecl, void * _dstData, const bgfx_vertex_decl_t * _srcDecl, const void * _srcData, uint32_t _num)
+BGFX_C_API void bgfx_vertex_convert(const bgfx_vertex_decl_t * _dstDecl, void* _dstData, const bgfx_vertex_decl_t * _srcDecl, const void* _srcData, uint32_t _num)
 {
 	const bgfx::VertexDecl & dstDecl = *(const bgfx::VertexDecl *)_dstDecl;
 	const bgfx::VertexDecl & srcDecl = *(const bgfx::VertexDecl *)_srcDecl;
 	bgfx::vertexConvert(dstDecl, _dstData, srcDecl, _srcData, _num);
 }
 
-BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t * _output, const bgfx_vertex_decl_t * _decl, const void * _data, uint16_t _num, float _epsilon)
+BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_decl_t * _decl, const void* _data, uint16_t _num, float _epsilon)
 {
 	const bgfx::VertexDecl & decl = *(const bgfx::VertexDecl *)_decl;
 	return bgfx::weldVertices(_output, decl, _data, _num, _epsilon);
 }
 
-BGFX_C_API uint32_t bgfx_topology_convert(bgfx_topology_convert_t _conversion, void * _dst, uint32_t _dstSize, const void * _indices, uint32_t _numIndices, bool _index32)
+BGFX_C_API uint32_t bgfx_topology_convert(bgfx_topology_convert_t _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32)
 {
 	return bgfx::topologyConvert((bgfx::TopologyConvert::Enum)_conversion, _dst, _dstSize, _indices, _numIndices, _index32);
 }
 
-BGFX_C_API void bgfx_topology_sort_tri_list(bgfx_topology_sort_t _sort, void * _dst, uint32_t _dstSize, const float * _dir, const float * _pos, const void * _vertices, uint32_t _stride, const void * _indices, uint32_t _numIndices, bool _index32)
+BGFX_C_API void bgfx_topology_sort_tri_list(bgfx_topology_sort_t _sort, void* _dst, uint32_t _dstSize, const float _dir[3], const float _pos[3], const void* _vertices, uint32_t _stride, const void* _indices, uint32_t _numIndices, bool _index32)
 {
 	bgfx::topologySortTriList((bgfx::TopologySort::Enum)_sort, _dst, _dstSize, _dir, _pos, _vertices, _stride, _indices, _numIndices, _index32);
 }
 
-BGFX_C_API uint8_t bgfx_get_supported_renderers(uint8_t _max, bgfx_renderer_type_t * _enum)
+BGFX_C_API uint8_t bgfx_get_supported_renderers(uint8_t _max, bgfx_renderer_type_t* _enum)
 {
-	return bgfx::getSupportedRenderers(_max, (bgfx::RendererType::Enum *)_enum);
+	return bgfx::getSupportedRenderers(_max, (bgfx::RendererType::Enum*)_enum);
 }
 
-BGFX_C_API const char * bgfx_get_renderer_name(bgfx_renderer_type_t _type)
+BGFX_C_API const char* bgfx_get_renderer_name(bgfx_renderer_type_t _type)
 {
-	return (const char *)bgfx::getRendererName((bgfx::RendererType::Enum)_type);
-}
-
-BGFX_C_API void bgfx_init_ctor(bgfx_init_t * _init)
-{
-	BX_PLACEMENT_NEW(_init, bgfx::Init);
-
+	return bgfx::getRendererName((bgfx::RendererType::Enum)_type);
 }
 
-BGFX_C_API bool bgfx_init(const bgfx_init_t * _init)
-{
-	bgfx_init_t init = *_init;
-
-	if (init.callback != NULL)
-	{
-		static bgfx::CallbackC99 s_callback;
-		s_callback.m_interface = init.callback;
-		init.callback = reinterpret_cast<bgfx_callback_interface_t *>(&s_callback);
-	}
-
-	if (init.allocator != NULL)
-	{
-		static bgfx::AllocatorC99 s_allocator;
-		s_allocator.m_interface = init.allocator;
-		init.allocator = reinterpret_cast<bgfx_allocator_interface_t *>(&s_allocator);
-	}
-
-	union { const bgfx_init_t* c; const bgfx::Init* cpp; } in;
-	in.c = &init;
-
-	return bgfx::init(*in.cpp);
+/* BGFX_C_API void bgfx_init_ctor(bgfx_init_t* _init) */
 
-}
+/* BGFX_C_API bool bgfx_init(const bgfx_init_t * _init) */
 
 BGFX_C_API void bgfx_shutdown()
 {
@@ -142,34 +122,34 @@ BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type()
 	return (bgfx_renderer_type_t)bgfx::getRendererType();
 }
 
-BGFX_C_API const bgfx_caps_t * bgfx_get_caps()
+BGFX_C_API const bgfx_caps_t* bgfx_get_caps()
 {
-	return (const bgfx_caps_t *)bgfx::getCaps();
+	return (const bgfx_caps_t*)bgfx::getCaps();
 }
 
-BGFX_C_API const bgfx_stats_t * bgfx_get_stats()
+BGFX_C_API const bgfx_stats_t* bgfx_get_stats()
 {
-	return (const bgfx_stats_t *)bgfx::getStats();
+	return (const bgfx_stats_t*)bgfx::getStats();
 }
 
-BGFX_C_API const bgfx_memory_t * bgfx_alloc(uint32_t _size)
+BGFX_C_API const bgfx_memory_t* bgfx_alloc(uint32_t _size)
 {
-	return (const bgfx_memory_t *)bgfx::alloc(_size);
+	return (const bgfx_memory_t*)bgfx::alloc(_size);
 }
 
-BGFX_C_API const bgfx_memory_t * bgfx_copy(const void * _data, uint32_t _size)
+BGFX_C_API const bgfx_memory_t* bgfx_copy(const void* _data, uint32_t _size)
 {
-	return (const bgfx_memory_t *)bgfx::copy(_data, _size);
+	return (const bgfx_memory_t*)bgfx::copy(_data, _size);
 }
 
-BGFX_C_API const bgfx_memory_t * bgfx_make_ref(const void * _data, uint32_t _size)
+BGFX_C_API const bgfx_memory_t* bgfx_make_ref(const void* _data, uint32_t _size)
 {
-	return (const bgfx_memory_t *)bgfx::makeRef(_data, _size);
+	return (const bgfx_memory_t*)bgfx::makeRef(_data, _size);
 }
 
-BGFX_C_API const bgfx_memory_t * bgfx_make_ref_release(const void * _data, uint32_t _size, bgfx_release_fn_t _releaseFn, void * _userData)
+BGFX_C_API const bgfx_memory_t* bgfx_make_ref_release(const void* _data, uint32_t _size, bgfx_release_fn_t _releaseFn, void* _userData)
 {
-	return (const bgfx_memory_t *)bgfx::makeRef(_data, _size, (bgfx::ReleaseFn)_releaseFn, _userData);
+	return (const bgfx_memory_t*)bgfx::makeRef(_data, _size, (bgfx::ReleaseFn)_releaseFn, _userData);
 }
 
 BGFX_C_API void bgfx_set_debug(uint32_t _debug)
@@ -182,7 +162,7 @@ BGFX_C_API void bgfx_dbg_text_clear(uint8_t _attr, bool _small)
 	bgfx::dbgTextClear(_attr, _small);
 }
 
-BGFX_C_API void bgfx_dbg_text_printf(uint16_t _x, uint16_t _y, uint8_t _attr, const char * _format, ... )
+BGFX_C_API void bgfx_dbg_text_printf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ... )
 {
 	va_list argList;
 	va_start(argList, _format);
@@ -190,24 +170,24 @@ BGFX_C_API void bgfx_dbg_text_printf(uint16_t _x, uint16_t _y, uint8_t _attr, co
 	va_end(argList);
 }
 
-BGFX_C_API void bgfx_dbg_text_vprintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char * _format, va_list _argList)
+BGFX_C_API void bgfx_dbg_text_vprintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, va_list _argList)
 {
 	bgfx::dbgTextPrintfVargs(_x, _y, _attr, _format, _argList);
 }
 
-BGFX_C_API void bgfx_dbg_text_image(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void * _data, uint16_t _pitch)
+BGFX_C_API void bgfx_dbg_text_image(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const void* _data, uint16_t _pitch)
 {
 	bgfx::dbgTextImage(_x, _y, _width, _height, _data, _pitch);
 }
 
-BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t * _mem, uint16_t _flags)
+BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem, uint16_t _flags)
 {
 	union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle_ret;
-	handle_ret.cpp = bgfx::createIndexBuffer((const bgfx::Memory *)_mem, _flags);
+	handle_ret.cpp = bgfx::createIndexBuffer((const bgfx::Memory*)_mem, _flags);
 	return handle_ret.c;
 }
 
-BGFX_C_API void bgfx_set_index_buffer_name(bgfx_index_buffer_handle_t _handle, const char * _name, int32_t _len)
+BGFX_C_API void bgfx_set_index_buffer_name(bgfx_index_buffer_handle_t _handle, const char* _name, int32_t _len)
 {
 	union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle };
 	bgfx::setName(handle.cpp, _name, _len);
@@ -219,15 +199,15 @@ BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle)
 	bgfx::destroy(handle.cpp);
 }
 
-BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t * _mem, const bgfx_vertex_decl_t * _decl, uint16_t _flags)
+BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t * _decl, uint16_t _flags)
 {
 	const bgfx::VertexDecl & decl = *(const bgfx::VertexDecl *)_decl;
 	union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle_ret;
-	handle_ret.cpp = bgfx::createVertexBuffer((const bgfx::Memory *)_mem, decl, _flags);
+	handle_ret.cpp = bgfx::createVertexBuffer((const bgfx::Memory*)_mem, decl, _flags);
 	return handle_ret.c;
 }
 
-BGFX_C_API void bgfx_set_vertex_buffer_name(bgfx_vertex_buffer_handle_t _handle, const char * _name, int32_t _len)
+BGFX_C_API void bgfx_set_vertex_buffer_name(bgfx_vertex_buffer_handle_t _handle, const char* _name, int32_t _len)
 {
 	union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle };
 	bgfx::setName(handle.cpp, _name, _len);
@@ -246,17 +226,17 @@ BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(u
 	return handle_ret.c;
 }
 
-BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t * _mem, uint16_t _flags)
+BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem, uint16_t _flags)
 {
 	union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle_ret;
-	handle_ret.cpp = bgfx::createDynamicIndexBuffer((const bgfx::Memory *)_mem, _flags);
+	handle_ret.cpp = bgfx::createDynamicIndexBuffer((const bgfx::Memory*)_mem, _flags);
 	return handle_ret.c;
 }
 
-BGFX_C_API void bgfx_update_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _startIndex, const bgfx_memory_t * _mem)
+BGFX_C_API void bgfx_update_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _startIndex, const bgfx_memory_t* _mem)
 {
 	union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle };
-	bgfx::update(handle.cpp, _startIndex, (const bgfx::Memory *)_mem);
+	bgfx::update(handle.cpp, _startIndex, (const bgfx::Memory*)_mem);
 }
 
 BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle)
@@ -265,26 +245,26 @@ BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_hand
 	bgfx::destroy(handle.cpp);
 }
 
-BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t * _decl, uint16_t _flags)
+BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl, uint16_t _flags)
 {
-	const bgfx::VertexDecl & decl = *(const bgfx::VertexDecl *)_decl;
+	const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
 	union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle_ret;
 	handle_ret.cpp = bgfx::createDynamicVertexBuffer(_num, decl, _flags);
 	return handle_ret.c;
 }
 
-BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t * _mem, const bgfx_vertex_decl_t * _decl, uint16_t _flags)
+BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl, uint16_t _flags)
 {
-	const bgfx::VertexDecl & decl = *(const bgfx::VertexDecl *)_decl;
+	const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl;
 	union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle_ret;
-	handle_ret.cpp = bgfx::createDynamicVertexBuffer((const bgfx::Memory *)_mem, decl, _flags);
+	handle_ret.cpp = bgfx::createDynamicVertexBuffer((const bgfx::Memory*)_mem, decl, _flags);
 	return handle_ret.c;
 }
 
-BGFX_C_API void bgfx_update_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t * _mem)
+BGFX_C_API void bgfx_update_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, const bgfx_memory_t* _mem)
 {
 	union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
-	bgfx::update(handle.cpp, _startVertex, (const bgfx::Memory *)_mem);
+	bgfx::update(handle.cpp, _startVertex, (const bgfx::Memory*)_mem);
 }
 
 BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle)
@@ -309,26 +289,26 @@ BGFX_C_API uint32_t bgfx_get_avail_instance_data_buffer(uint32_t _num, uint16_t
 	return bgfx::getAvailInstanceDataBuffer(_num, _stride);
 }
 
-BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t * _tib, uint32_t _num)
+BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num)
 {
-	bgfx::allocTransientIndexBuffer((bgfx::TransientIndexBuffer *)_tib, _num);
+	bgfx::allocTransientIndexBuffer((bgfx::TransientIndexBuffer*)_tib, _num);
 }
 
-BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t * _tvb, uint32_t _num, const bgfx_vertex_decl_t * _decl)
+BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_decl_t * _decl)
 {
 	const bgfx::VertexDecl & decl = *(const bgfx::VertexDecl *)_decl;
-	bgfx::allocTransientVertexBuffer((bgfx::TransientVertexBuffer *)_tvb, _num, decl);
+	bgfx::allocTransientVertexBuffer((bgfx::TransientVertexBuffer*)_tvb, _num, decl);
 }
 
-BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t * _tvb, const bgfx_vertex_decl_t * _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t * _tib, uint32_t _numIndices)
+BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t * _decl, uint32_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint32_t _numIndices)
 {
 	const bgfx::VertexDecl & decl = *(const bgfx::VertexDecl *)_decl;
-	return bgfx::allocTransientBuffers((bgfx::TransientVertexBuffer *)_tvb, decl, _numVertices, (bgfx::TransientIndexBuffer *)_tib, _numIndices);
+	return bgfx::allocTransientBuffers((bgfx::TransientVertexBuffer*)_tvb, decl, _numVertices, (bgfx::TransientIndexBuffer*)_tib, _numIndices);
 }
 
-BGFX_C_API void bgfx_alloc_instance_data_buffer(bgfx_instance_data_buffer_t * _idb, uint32_t _num, uint16_t _stride)
+BGFX_C_API void bgfx_alloc_instance_data_buffer(bgfx_instance_data_buffer_t* _idb, uint32_t _num, uint16_t _stride)
 {
-	bgfx::allocInstanceDataBuffer((bgfx::InstanceDataBuffer *)_idb, _num, _stride);
+	bgfx::allocInstanceDataBuffer((bgfx::InstanceDataBuffer*)_idb, _num, _stride);
 }
 
 BGFX_C_API bgfx_indirect_buffer_handle_t bgfx_create_indirect_buffer(uint32_t _num)
@@ -344,20 +324,20 @@ BGFX_C_API void bgfx_destroy_indirect_buffer(bgfx_indirect_buffer_handle_t _hand
 	bgfx::destroy(handle.cpp);
 }
 
-BGFX_C_API bgfx_shader_handle_t bgfx_create_shader(const bgfx_memory_t * _mem)
+BGFX_C_API bgfx_shader_handle_t bgfx_create_shader(const bgfx_memory_t* _mem)
 {
 	union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle_ret;
-	handle_ret.cpp = bgfx::createShader((const bgfx::Memory *)_mem);
+	handle_ret.cpp = bgfx::createShader((const bgfx::Memory*)_mem);
 	return handle_ret.c;
 }
 
-BGFX_C_API uint16_t bgfx_get_shader_uniforms(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t * _uniforms, uint16_t _max)
+BGFX_C_API uint16_t bgfx_get_shader_uniforms(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t* _uniforms, uint16_t _max)
 {
 	union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle = { _handle };
-	return bgfx::getShaderUniforms(handle.cpp, (bgfx::UniformHandle *)_uniforms, _max);
+	return bgfx::getShaderUniforms(handle.cpp, (bgfx::UniformHandle*)_uniforms, _max);
 }
 
-BGFX_C_API void bgfx_set_shader_name(bgfx_shader_handle_t _handle, const char * _name, int32_t _len)
+BGFX_C_API void bgfx_set_shader_name(bgfx_shader_handle_t _handle, const char* _name, int32_t _len)
 {
 	union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle = { _handle };
 	bgfx::setName(handle.cpp, _name, _len);
@@ -403,17 +383,17 @@ BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t * _info, uint16_t _wi
 	bgfx::calcTextureSize(info, _width, _height, _depth, _cubeMap, _hasMips, _numLayers, (bgfx::TextureFormat::Enum)_format);
 }
 
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t * _mem, uint64_t _flags, uint8_t _skip, bgfx_texture_info_t * _info)
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint64_t _flags, uint8_t _skip, bgfx_texture_info_t* _info)
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle_ret;
-	handle_ret.cpp = bgfx::createTexture((const bgfx::Memory *)_mem, _flags, _skip, (bgfx::TextureInfo *)_info);
+	handle_ret.cpp = bgfx::createTexture((const bgfx::Memory*)_mem, _flags, _skip, (bgfx::TextureInfo*)_info);
 	return handle_ret.c;
 }
 
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t * _mem)
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle_ret;
-	handle_ret.cpp = bgfx::createTexture2D(_width, _height, _hasMips, _numLayers, (bgfx::TextureFormat::Enum)_format, _flags, (const bgfx::Memory *)_mem);
+	handle_ret.cpp = bgfx::createTexture2D(_width, _height, _hasMips, _numLayers, (bgfx::TextureFormat::Enum)_format, _flags, (const bgfx::Memory*)_mem);
 	return handle_ret.c;
 }
 
@@ -424,54 +404,54 @@ BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d_scaled(bgfx_backbuffer_r
 	return handle_ret.c;
 }
 
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t * _mem)
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle_ret;
-	handle_ret.cpp = bgfx::createTexture3D(_width, _height, _depth, _hasMips, (bgfx::TextureFormat::Enum)_format, _flags, (const bgfx::Memory *)_mem);
+	handle_ret.cpp = bgfx::createTexture3D(_width, _height, _depth, _hasMips, (bgfx::TextureFormat::Enum)_format, _flags, (const bgfx::Memory*)_mem);
 	return handle_ret.c;
 }
 
-BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t * _mem)
+BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, bool _hasMips, uint16_t _numLayers, bgfx_texture_format_t _format, uint64_t _flags, const bgfx_memory_t* _mem)
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle_ret;
-	handle_ret.cpp = bgfx::createTextureCube(_size, _hasMips, _numLayers, (bgfx::TextureFormat::Enum)_format, _flags, (const bgfx::Memory *)_mem);
+	handle_ret.cpp = bgfx::createTextureCube(_size, _hasMips, _numLayers, (bgfx::TextureFormat::Enum)_format, _flags, (const bgfx::Memory*)_mem);
 	return handle_ret.c;
 }
 
-BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t * _mem, uint16_t _pitch)
+BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch)
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
-	bgfx::updateTexture2D(handle.cpp, _layer, _mip, _x, _y, _width, _height, (const bgfx::Memory *)_mem, _pitch);
+	bgfx::updateTexture2D(handle.cpp, _layer, _mip, _x, _y, _width, _height, (const bgfx::Memory*)_mem, _pitch);
 }
 
-BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t * _mem)
+BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t* _mem)
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
-	bgfx::updateTexture3D(handle.cpp, _mip, _x, _y, _z, _width, _height, _depth, (const bgfx::Memory *)_mem);
+	bgfx::updateTexture3D(handle.cpp, _mip, _x, _y, _z, _width, _height, _depth, (const bgfx::Memory*)_mem);
 }
 
-BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t * _mem, uint16_t _pitch)
+BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint16_t _layer, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch)
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
-	bgfx::updateTextureCube(handle.cpp, _layer, _side, _mip, _x, _y, _width, _height, (const bgfx::Memory *)_mem, _pitch);
+	bgfx::updateTextureCube(handle.cpp, _layer, _side, _mip, _x, _y, _width, _height, (const bgfx::Memory*)_mem, _pitch);
 }
 
-BGFX_C_API uint32_t bgfx_read_texture(bgfx_texture_handle_t _handle, void * _data, uint8_t _mip)
+BGFX_C_API uint32_t bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data, uint8_t _mip)
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
 	return bgfx::readTexture(handle.cpp, _data, _mip);
 }
 
-BGFX_C_API void bgfx_set_texture_name(bgfx_texture_handle_t _handle, const char * _name, int32_t _len)
+BGFX_C_API void bgfx_set_texture_name(bgfx_texture_handle_t _handle, const char* _name, int32_t _len)
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
 	bgfx::setName(handle.cpp, _name, _len);
 }
 
-BGFX_C_API void * bgfx_get_direct_access_ptr(bgfx_texture_handle_t _handle)
+BGFX_C_API void* bgfx_get_direct_access_ptr(bgfx_texture_handle_t _handle)
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
-	return (void *)bgfx::getDirectAccessPtr(handle.cpp);
+	return bgfx::getDirectAccessPtr(handle.cpp);
 }
 
 BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle)
@@ -494,28 +474,28 @@ BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backb
 	return handle_ret.c;
 }
 
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t * _handles, bool _destroyTexture)
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t* _handles, bool _destroyTexture)
 {
 	union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle_ret;
-	handle_ret.cpp = bgfx::createFrameBuffer(_num, (const bgfx::TextureHandle *)_handles, _destroyTexture);
+	handle_ret.cpp = bgfx::createFrameBuffer(_num, (const bgfx::TextureHandle*)_handles, _destroyTexture);
 	return handle_ret.c;
 }
 
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_attachment(uint8_t _num, const bgfx_attachment_t * _handles, bool _destroyTexture)
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_attachment(uint8_t _num, const bgfx_attachment_t* _attachment, bool _destroyTexture)
 {
 	union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle_ret;
-	handle_ret.cpp = bgfx::createFrameBuffer(_num, (const bgfx::Attachment *)_handles, _destroyTexture);
+	handle_ret.cpp = bgfx::createFrameBuffer(_num, (const bgfx::Attachment*)_attachment, _destroyTexture);
 	return handle_ret.c;
 }
 
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void * _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, bgfx_texture_format_t _depthFormat)
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, bgfx_texture_format_t _depthFormat)
 {
 	union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle_ret;
 	handle_ret.cpp = bgfx::createFrameBuffer(_nwh, _width, _height, (bgfx::TextureFormat::Enum)_format, (bgfx::TextureFormat::Enum)_depthFormat);
 	return handle_ret.c;
 }
 
-BGFX_C_API void bgfx_set_frame_buffer_name(bgfx_frame_buffer_handle_t _handle, const char * _name, int32_t _len)
+BGFX_C_API void bgfx_set_frame_buffer_name(bgfx_frame_buffer_handle_t _handle, const char* _name, int32_t _len)
 {
 	union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
 	bgfx::setName(handle.cpp, _name, _len);
@@ -535,7 +515,7 @@ BGFX_C_API void bgfx_destroy_frame_buffer(bgfx_frame_buffer_handle_t _handle)
 	bgfx::destroy(handle.cpp);
 }
 
-BGFX_C_API bgfx_uniform_handle_t bgfx_create_uniform(const char * _name, bgfx_uniform_type_t _type, uint16_t _num)
+BGFX_C_API bgfx_uniform_handle_t bgfx_create_uniform(const char* _name, bgfx_uniform_type_t _type, uint16_t _num)
 {
 	union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle_ret;
 	handle_ret.cpp = bgfx::createUniform(_name, (bgfx::UniformType::Enum)_type, _num);
@@ -562,7 +542,7 @@ BGFX_C_API bgfx_occlusion_query_handle_t bgfx_create_occlusion_query()
 	return handle_ret.c;
 }
 
-BGFX_C_API bgfx_occlusion_query_result_t bgfx_get_result(bgfx_occlusion_query_handle_t _handle, int32_t * _result)
+BGFX_C_API bgfx_occlusion_query_result_t bgfx_get_result(bgfx_occlusion_query_handle_t _handle, int32_t* _result)
 {
 	union { bgfx_occlusion_query_handle_t c; bgfx::OcclusionQueryHandle cpp; } handle = { _handle };
 	return (bgfx_occlusion_query_result_t)bgfx::getResult(handle.cpp, _result);
@@ -574,12 +554,17 @@ BGFX_C_API void bgfx_destroy_occlusion_query(bgfx_occlusion_query_handle_t _hand
 	bgfx::destroy(handle.cpp);
 }
 
-BGFX_C_API void bgfx_set_palette_color(uint8_t _index, const float * _rgba)
+BGFX_C_API void bgfx_set_palette_color(uint8_t _index, const float _rgba[4])
 {
 	bgfx::setPaletteColor(_index, _rgba);
 }
 
-BGFX_C_API void bgfx_set_view_name(bgfx_view_id_t _id, const char * _name)
+BGFX_C_API void bgfx_set_palette_color_rgba8(uint8_t _index, uint32_t _rgba)
+{
+	bgfx::setPaletteColor(_index, _rgba);
+}
+
+BGFX_C_API void bgfx_set_view_name(bgfx_view_id_t _id, const char* _name)
 {
 	bgfx::setViewName((bgfx::ViewId)_id, _name);
 }
@@ -620,27 +605,27 @@ BGFX_C_API void bgfx_set_view_frame_buffer(bgfx_view_id_t _id, bgfx_frame_buffer
 	bgfx::setViewFrameBuffer((bgfx::ViewId)_id, handle.cpp);
 }
 
-BGFX_C_API void bgfx_set_view_transform(bgfx_view_id_t _id, const void * _view, const void * _proj)
+BGFX_C_API void bgfx_set_view_transform(bgfx_view_id_t _id, const void* _view, const void* _proj)
 {
 	bgfx::setViewTransform((bgfx::ViewId)_id, _view, _proj);
 }
 
-BGFX_C_API void bgfx_set_view_order(bgfx_view_id_t _id, uint16_t _num, const bgfx_view_id_t * _order)
+BGFX_C_API void bgfx_set_view_order(bgfx_view_id_t _id, uint16_t _num, const bgfx_view_id_t* _order)
 {
-	bgfx::setViewOrder((bgfx::ViewId)_id, _num, (const bgfx::ViewId *)_order);
+	bgfx::setViewOrder((bgfx::ViewId)_id, _num, (const bgfx::ViewId*)_order);
 }
 
-BGFX_C_API bgfx_encoder_t * bgfx_encoder_begin(bool _forThread)
+BGFX_C_API bgfx_encoder_t* bgfx_encoder_begin(bool _forThread)
 {
-	return (bgfx_encoder_t *)bgfx::begin(_forThread);
+	return (bgfx_encoder_t*)bgfx::begin(_forThread);
 }
 
-BGFX_C_API void bgfx_encoder_end(bgfx_encoder_t * _encoder)
+BGFX_C_API void bgfx_encoder_end(bgfx_encoder_t* _encoder)
 {
-	bgfx::end((bgfx::Encoder *)_encoder);
+	bgfx::end((bgfx::Encoder*)_encoder);
 }
 
-BGFX_C_API void bgfx_encoder_set_marker(bgfx_encoder_t* _this, const char * _marker)
+BGFX_C_API void bgfx_encoder_set_marker(bgfx_encoder_t* _this, const char* _marker)
 {
 	bgfx::Encoder* This = (bgfx::Encoder*)_this;
 	This->setMarker(_marker);
@@ -677,7 +662,7 @@ BGFX_C_API void bgfx_encoder_set_scissor_cached(bgfx_encoder_t* _this, uint16_t
 	This->setScissor(_cache);
 }
 
-BGFX_C_API uint32_t bgfx_encoder_set_transform(bgfx_encoder_t* _this, const void * _mtx, uint16_t _num)
+BGFX_C_API uint32_t bgfx_encoder_set_transform(bgfx_encoder_t* _this, const void* _mtx, uint16_t _num)
 {
 	bgfx::Encoder* This = (bgfx::Encoder*)_this;
 	return This->setTransform(_mtx, _num);
@@ -689,13 +674,13 @@ BGFX_C_API void bgfx_encoder_set_transform_cached(bgfx_encoder_t* _this, uint32_
 	This->setTransform(_cache, _num);
 }
 
-BGFX_C_API uint32_t bgfx_encoder_alloc_transform(bgfx_encoder_t* _this, bgfx_transform_t * _transform, uint16_t _num)
+BGFX_C_API uint32_t bgfx_encoder_alloc_transform(bgfx_encoder_t* _this, bgfx_transform_t* _transform, uint16_t _num)
 {
 	bgfx::Encoder* This = (bgfx::Encoder*)_this;
-	return This->allocTransform((bgfx::Transform *)_transform, _num);
+	return This->allocTransform((bgfx::Transform*)_transform, _num);
 }
 
-BGFX_C_API void bgfx_encoder_set_uniform(bgfx_encoder_t* _this, bgfx_uniform_handle_t _handle, const void * _value, uint16_t _num)
+BGFX_C_API void bgfx_encoder_set_uniform(bgfx_encoder_t* _this, bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num)
 {
 	bgfx::Encoder* This = (bgfx::Encoder*)_this;
 	union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle };
@@ -716,10 +701,10 @@ BGFX_C_API void bgfx_encoder_set_dynamic_index_buffer(bgfx_encoder_t* _this, bgf
 	This->setIndexBuffer(handle.cpp, _firstIndex, _numIndices);
 }
 
-BGFX_C_API void bgfx_encoder_set_transient_index_buffer(bgfx_encoder_t* _this, const bgfx_transient_index_buffer_t * _tib, uint32_t _firstIndex, uint32_t _numIndices)
+BGFX_C_API void bgfx_encoder_set_transient_index_buffer(bgfx_encoder_t* _this, const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices)
 {
 	bgfx::Encoder* This = (bgfx::Encoder*)_this;
-	This->setIndexBuffer((const bgfx::TransientIndexBuffer *)_tib, _firstIndex, _numIndices);
+	This->setIndexBuffer((const bgfx::TransientIndexBuffer*)_tib, _firstIndex, _numIndices);
 }
 
 BGFX_C_API void bgfx_encoder_set_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices)
@@ -736,10 +721,10 @@ BGFX_C_API void bgfx_encoder_set_dynamic_vertex_buffer(bgfx_encoder_t* _this, ui
 	This->setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices);
 }
 
-BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t * _tvb, uint32_t _startVertex, uint32_t _numVertices)
+BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(bgfx_encoder_t* _this, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices)
 {
 	bgfx::Encoder* This = (bgfx::Encoder*)_this;
-	This->setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer *)_tvb, _startVertex, _numVertices);
+	This->setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer*)_tvb, _startVertex, _numVertices);
 }
 
 BGFX_C_API void bgfx_encoder_set_vertex_count(bgfx_encoder_t* _this, uint32_t _numVertices)
@@ -748,10 +733,10 @@ BGFX_C_API void bgfx_encoder_set_vertex_count(bgfx_encoder_t* _this, uint32_t _n
 	This->setVertexCount(_numVertices);
 }
 
-BGFX_C_API void bgfx_encoder_set_instance_data_buffer(bgfx_encoder_t* _this, const bgfx_instance_data_buffer_t * _idb, uint32_t _start, uint32_t _num)
+BGFX_C_API void bgfx_encoder_set_instance_data_buffer(bgfx_encoder_t* _this, const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num)
 {
 	bgfx::Encoder* This = (bgfx::Encoder*)_this;
-	This->setInstanceDataBuffer((const bgfx::InstanceDataBuffer *)_idb, _start, _num);
+	This->setInstanceDataBuffer((const bgfx::InstanceDataBuffer*)_idb, _start, _num);
 }
 
 BGFX_C_API void bgfx_encoder_set_instance_data_from_vertex_buffer(bgfx_encoder_t* _this, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
@@ -882,7 +867,7 @@ BGFX_C_API void bgfx_encoder_blit(bgfx_encoder_t* _this, bgfx_view_id_t _id, bgf
 	This->blit((bgfx::ViewId)_id, dst.cpp, _dstMip, _dstX, _dstY, _dstZ, src.cpp, _srcMip, _srcX, _srcY, _srcZ, _width, _height, _depth);
 }
 
-BGFX_C_API void bgfx_request_screen_shot(bgfx_frame_buffer_handle_t _handle, const char * _filePath)
+BGFX_C_API void bgfx_request_screen_shot(bgfx_frame_buffer_handle_t _handle, const char* _filePath)
 {
 	union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
 	bgfx::requestScreenShot(handle.cpp, _filePath);
@@ -899,9 +884,9 @@ BGFX_C_API void bgfx_set_platform_data(const bgfx_platform_data_t * _data)
 	bgfx::setPlatformData(data);
 }
 
-BGFX_C_API const bgfx_internal_data_t * bgfx_get_internal_data()
+BGFX_C_API const bgfx_internal_data_t* bgfx_get_internal_data()
 {
-	return (const bgfx_internal_data_t *)bgfx::getInternalData();
+	return (const bgfx_internal_data_t*)bgfx::getInternalData();
 }
 
 BGFX_C_API uintptr_t bgfx_override_internal_texture_ptr(bgfx_texture_handle_t _handle, uintptr_t _ptr)
@@ -910,13 +895,13 @@ BGFX_C_API uintptr_t bgfx_override_internal_texture_ptr(bgfx_texture_handle_t _h
 	return bgfx::overrideInternal(handle.cpp, _ptr);
 }
 
-BGFX_C_API uintptr_t bgfx_override_internal_texture(bgfx_texture_handle_t _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags)
+BGFX_C_API uintptr_t bgfx_override_internal_texture(bgfx_texture_handle_t _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint64_t _flags)
 {
 	union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
 	return bgfx::overrideInternal(handle.cpp, _width, _height, _numMips, (bgfx::TextureFormat::Enum)_format, _flags);
 }
 
-BGFX_C_API void bgfx_set_marker(const char * _marker)
+BGFX_C_API void bgfx_set_marker(const char* _marker)
 {
 	bgfx::setMarker(_marker);
 }
@@ -947,7 +932,7 @@ BGFX_C_API void bgfx_set_scissor_cached(uint16_t _cache)
 	bgfx::setScissor(_cache);
 }
 
-BGFX_C_API uint32_t bgfx_set_transform(const void * _mtx, uint16_t _num)
+BGFX_C_API uint32_t bgfx_set_transform(const void* _mtx, uint16_t _num)
 {
 	return bgfx::setTransform(_mtx, _num);
 }
@@ -957,12 +942,12 @@ BGFX_C_API void bgfx_set_transform_cached(uint32_t _cache, uint16_t _num)
 	bgfx::setTransform(_cache, _num);
 }
 
-BGFX_C_API uint32_t bgfx_alloc_transform(bgfx_transform_t * _transform, uint16_t _num)
+BGFX_C_API uint32_t bgfx_alloc_transform(bgfx_transform_t* _transform, uint16_t _num)
 {
-	return bgfx::allocTransform((bgfx::Transform *)_transform, _num);
+	return bgfx::allocTransform((bgfx::Transform*)_transform, _num);
 }
 
-BGFX_C_API void bgfx_set_uniform(bgfx_uniform_handle_t _handle, const void * _value, uint16_t _num)
+BGFX_C_API void bgfx_set_uniform(bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num)
 {
 	union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle };
 	bgfx::setUniform(handle.cpp, _value, _num);
@@ -980,9 +965,9 @@ BGFX_C_API void bgfx_set_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t
 	bgfx::setIndexBuffer(handle.cpp, _firstIndex, _numIndices);
 }
 
-BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffer_t * _tib, uint32_t _firstIndex, uint32_t _numIndices)
+BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices)
 {
-	bgfx::setIndexBuffer((const bgfx::TransientIndexBuffer *)_tib, _firstIndex, _numIndices);
+	bgfx::setIndexBuffer((const bgfx::TransientIndexBuffer*)_tib, _firstIndex, _numIndices);
 }
 
 BGFX_C_API void bgfx_set_vertex_buffer(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices)
@@ -997,9 +982,9 @@ BGFX_C_API void bgfx_set_dynamic_vertex_buffer(uint8_t _stream, bgfx_dynamic_ver
 	bgfx::setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices);
 }
 
-BGFX_C_API void bgfx_set_transient_vertex_buffer(uint8_t _stream, const bgfx_transient_vertex_buffer_t * _tvb, uint32_t _startVertex, uint32_t _numVertices)
+BGFX_C_API void bgfx_set_transient_vertex_buffer(uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices)
 {
-	bgfx::setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer *)_tvb, _startVertex, _numVertices);
+	bgfx::setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer*)_tvb, _startVertex, _numVertices);
 }
 
 BGFX_C_API void bgfx_set_vertex_count(uint32_t _numVertices)
@@ -1007,9 +992,9 @@ BGFX_C_API void bgfx_set_vertex_count(uint32_t _numVertices)
 	bgfx::setVertexCount(_numVertices);
 }
 
-BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t * _idb, uint32_t _start, uint32_t _num)
+BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num)
 {
-	bgfx::setInstanceDataBuffer((const bgfx::InstanceDataBuffer *)_idb, _start, _num);
+	bgfx::setInstanceDataBuffer((const bgfx::InstanceDataBuffer*)_idb, _start, _num);
 }
 
 BGFX_C_API void bgfx_set_instance_data_from_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
@@ -1122,6 +1107,39 @@ BGFX_C_API void bgfx_blit(bgfx_view_id_t _id, bgfx_texture_handle_t _dst, uint8_
 	bgfx::blit((bgfx::ViewId)_id, dst.cpp, _dstMip, _dstX, _dstY, _dstZ, src.cpp, _srcMip, _srcX, _srcY, _srcZ, _width, _height, _depth);
 }
 
+
+/* user define functions */
+BGFX_C_API void bgfx_init_ctor(bgfx_init_t* _init)
+{
+	BX_PLACEMENT_NEW(_init, bgfx::Init);
+
+}
+
+BGFX_C_API bool bgfx_init(const bgfx_init_t * _init)
+{
+	bgfx_init_t init =*_init;
+
+	if (init.callback != NULL)
+	{
+		static bgfx::CallbackC99 s_callback;
+		s_callback.m_interface = init.callback;
+		init.callback = reinterpret_cast<bgfx_callback_interface_t*>(&s_callback);
+	}
+
+	if (init.allocator != NULL)
+	{
+		static bgfx::AllocatorC99 s_allocator;
+		s_allocator.m_interface = init.allocator;
+		init.allocator = reinterpret_cast<bgfx_allocator_interface_t*>(&s_allocator);
+	}
+
+	union { const bgfx_init_t* c; const bgfx::Init* cpp; } in;
+	in.c = &init;
+
+	return bgfx::init(*in.cpp);
+
+}
+
 /**/
 BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
 {
@@ -1129,6 +1147,7 @@ BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
 	{
 		static bgfx_interface_vtbl_t s_bgfx_interface =
 		{
+			bgfx_attachment_init,
 			bgfx_vertex_decl_begin,
 			bgfx_vertex_decl_add,
 			bgfx_vertex_decl_decode,
@@ -1219,6 +1238,7 @@ BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
 			bgfx_get_result,
 			bgfx_destroy_occlusion_query,
 			bgfx_set_palette_color,
+			bgfx_set_palette_color_rgba8,
 			bgfx_set_view_name,
 			bgfx_set_view_rect,
 			bgfx_set_view_rect_ratio,