├── .gitignore ├── LICENSE.txt ├── dub.json ├── readme.md └── source └── bindbc └── bgfx ├── dynload.d ├── funcs.d ├── package.d └── types.d /.gitignore: -------------------------------------------------------------------------------- 1 | .dub/ 2 | lib 3 | dub.selections.json -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bindbc-bgfx", 3 | "description": "Dynamic and static D bindings for bgfx.", 4 | "homepage": "https://github.com/GoaLitiuM/bindbc-bgfx", 5 | "authors": [ "Ari Vuollet" ], 6 | "license": "BSL-1.0", 7 | 8 | "targetType": "staticLibrary", 9 | "targetPath": "lib", 10 | "targetName": "BindBC_bgfx", 11 | 12 | "configurations": [ 13 | { 14 | "name": "dynamic", 15 | "dependencies": { 16 | "bindbc-loader": "~>0.3.0" 17 | } 18 | }, 19 | { 20 | "name": "dynamicBC", 21 | "dependencies": { 22 | "bindbc-loader": "~>0.3.0" 23 | }, 24 | "subConfigurations": { 25 | "bindbc-loader": "yesBC" 26 | }, 27 | "dflags": [ "-betterC" ] 28 | }, 29 | { 30 | "name": "static", 31 | "versions": [ "BindBgfx_Static" ], 32 | "excludedSourceFiles": [ "source/bindbc/bgfx/dynload.d" ] 33 | }, 34 | { 35 | "name": "staticBC", 36 | "dflags": [ "-betterC" ], 37 | "versions": [ "BindBgfx_Static" ], 38 | "excludedSourceFiles": [ "source/bindbc/bgfx/dynload.d" ] 39 | } 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # bindbc-bgfx 2 | Dynamic and static D bindings for [bgfx](https://github.com/bkaradzic/bgfx). 3 | 4 | These bindings target bgfx API version **115** (commit [d95a643603e5b1dbe847d622ffb5860765ee7f62](https://github.com/bkaradzic/bgfx/tree/d95a643603e5b1dbe847d622ffb5860765ee7f62)). 5 | 6 | ## Usage (DUB) 7 | To install this library with DUB, simply run the following command: 8 | ``` 9 | dub add bindbc-bgfx 10 | ``` 11 | 12 | The library is configured to `dynamic` configuration by default, and should work out of box if you have the dynamic library installed properly (e.g. on Windows, the .DLL files are accessible by the application). 13 | 14 | ## Static bindings 15 | 16 | For static linking, `static` configuration must be enabled: 17 | 18 | __dub.json__ 19 | ``` 20 | "subConfigurations": { 21 | "bindbc-bgfx": "static" 22 | }, 23 | 24 | "libs": [ 25 | "bgfxRelease", "bxRelease", "bimgRelease" 26 | ] 27 | ``` 28 | 29 | Make sure to link against all the necessary system libraries needed by bgfx, and setup the library paths for linker: 30 | ``` 31 | "libs-windows": [ 32 | "User32", "Gdi32" 33 | ], 34 | "lflags-windows": [ 35 | "/LIBPATH:example\\path\\to\\bgfx\\.build\\win64_vs2019\\bin\\" 36 | ], 37 | 38 | "libs-linux": [ 39 | "stdc++", "GL", "X11" 40 | ], 41 | "lflags-linux": [ 42 | "-L/example/path/to/bgfx/bgfx/.build/linux64_gcc/bin" 43 | ] 44 | ``` 45 | 46 | The bindings also support `-betterC`, which can be enabled with `staticBC` and `dynamicBC` configurations. 47 | 48 | ## Usage 49 | 50 | ```d 51 | import bindbc.bgfx; 52 | 53 | loadBgfx(); // required with dynamically linked bgfx 54 | 55 | bgfx_init_t init; 56 | bgfx_init_ctor(&init); 57 | 58 | bgfx_init(&init); 59 | bgfx_reset(1280, 720, BGFX_RESET_NONE, init.resolution.format); 60 | 61 | bgfx_shutdown(); 62 | 63 | unloadBgfx(); // optional, only needed with dynamically linked bgfx 64 | ``` 65 | 66 | This is a very simple sample of how to use these bindings with bgfx. The sample code does not render or output anything but merely demonstrates how the bindings are initialized for proper use. To setup a window, libraries like SDL2 are often used with bgfx to provide the window for bgfx to use with rendering. Please see [this C++ example](https://github.com/bkaradzic/bgfx/blob/master/examples/common/entry/entry_sdl.cpp#L75) on how to setup bgfx with SDL2. 67 | 68 | If you need more in-depth tutorial of how to use bgfx, please see the [bgfx examples here.](https://bkaradzic.github.io/bgfx/examples.html) 69 | 70 | ## Generating bindings 71 | 72 | The main bgfx repository already contains the latest generated binding definitions for D, so these files can be copied from `bgfx/bindings/d/` over the files in `bindbc-bgfx/source/bindbc/bgfx` when pairing these bindings with custom versions of bgfx. If you need to regenerate the bindings, you can run `genie idl` in bgfx project folder, and copy the regenerated files to previously mentioned location. -------------------------------------------------------------------------------- /source/bindbc/bgfx/dynload.d: -------------------------------------------------------------------------------- 1 | module bindbc.bgfx.dynload; 2 | 3 | version(BindBgfx_Static) 4 | { 5 | // these functions do nothing with statically-linked library 6 | 7 | @disable bool loadBgfx(); 8 | @disable bool loadBgfx(const(char)* libName); 9 | @disable void unloadBgfx(); 10 | @disable bool isBgfxLoaded(); 11 | } 12 | else: 13 | 14 | import bindbc.loader; 15 | import bindbc.bgfx.funcs; 16 | 17 | private SharedLib lib; 18 | 19 | bool loadBgfx() 20 | { 21 | version (Windows) 22 | { 23 | const(char)[][4] libNames = 24 | [ 25 | "bgfx.dll", 26 | "bgfx-shared-libRelease.dll", 27 | "bgfx_debug.dll", 28 | "bgfx-shared-libDebug.dll" 29 | ]; 30 | } 31 | else version (OSX) 32 | { 33 | const(char)[][2] libNames = 34 | [ 35 | "libbgfx-shared-libRelease.dylib", 36 | "libbgfx-shared-libDebug.dylib" 37 | ]; 38 | } 39 | else version (linux) 40 | { 41 | const(char)[][4] libNames = 42 | [ 43 | "libbgfx-shared-libRelease.so", 44 | "libbgfx-shared-libDebug.so", 45 | "./libbgfx-shared-libRelease.so", 46 | "./libbgfx-shared-libDebug.so" 47 | ]; 48 | } 49 | else 50 | static assert(0, "bindbc-bgfx is not supported on this platform."); 51 | 52 | foreach (libName; libNames) 53 | { 54 | bool success = loadBgfx(libName.ptr); 55 | if (success) 56 | return success; 57 | } 58 | return false; 59 | } 60 | 61 | bool loadBgfx(const(char)* libName) 62 | { 63 | lib = load(libName); 64 | if (lib == invalidHandle) 65 | return false; 66 | 67 | size_t errors = errorCount(); 68 | 69 | import std.algorithm.searching : startsWith; 70 | static foreach (m; __traits(allMembers, bindbc.bgfx.funcs)) 71 | { 72 | static if (m.startsWith("da_")) 73 | lib.bindSymbol(cast(void**)&__traits(getMember, bindbc.bgfx.funcs, m[3..$]), __traits(getMember, bindbc.bgfx.funcs, m[3..$]).stringof); 74 | } 75 | 76 | return errors == errorCount(); 77 | } 78 | 79 | void unloadBgfx() 80 | { 81 | if(lib != invalidHandle) 82 | lib.unload(); 83 | } 84 | 85 | bool isBgfxLoaded() 86 | { 87 | return lib != invalidHandle; 88 | } -------------------------------------------------------------------------------- /source/bindbc/bgfx/package.d: -------------------------------------------------------------------------------- 1 | module bindbc.bgfx; 2 | 3 | public import bindbc.bgfx.types; 4 | public import bindbc.bgfx.funcs; 5 | public import bindbc.bgfx.dynload; 6 | -------------------------------------------------------------------------------- /source/bindbc/bgfx/types.d: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AUTO GENERATED! DO NOT EDIT! 4 | * 5 | */ 6 | 7 | module bindbc.bgfx.types; 8 | 9 | public import core.stdc.stdarg : va_list; 10 | 11 | enum expandEnum(EnumType, string fqnEnumType = EnumType.stringof) = (){ 12 | string expandEnum; 13 | foreach(m; __traits(allMembers, EnumType)){ 14 | expandEnum ~= "alias " ~ m ~ " = " ~ fqnEnumType ~ "." ~ m ~ ";"; 15 | } 16 | return expandEnum; 17 | }(); 18 | 19 | extern(C) @nogc nothrow: 20 | 21 | enum uint BGFX_API_VERSION = 118; 22 | 23 | alias bgfx_view_id_t = ushort; 24 | 25 | //NOTE: TEMPORARY fix to some missing preprocessor function-macros... 26 | static BGFX_STATE_BLEND_FUNC_SEPARATE(ulong _srcRGB, ulong _dstRGB, ulong _srcA, ulong _dstA){ 27 | return (0UL 28 | | ( ( cast(ulong)_srcRGB | ( cast(ulong)_dstRGB<<4) ) ) 29 | | ( ( cast(ulong)_srcA | ( cast(ulong)_dstA <<4) )<<8) 30 | ); 31 | } 32 | 33 | /// Blend equation separate. 34 | static BGFX_STATE_BLEND_EQUATION_SEPARATE(ulong _equationRGB, ulong _equationA){ return ( cast(ulong)_equationRGB | (cast(ulong)_equationA<<3) ); } 35 | 36 | /// Blend function. 37 | static BGFX_STATE_BLEND_FUNC(ulong _src, ulong _dst){ return BGFX_STATE_BLEND_FUNC_SEPARATE(_src, _dst, _src, _dst); } 38 | 39 | /// Blend equation. 40 | static BGFX_STATE_BLEND_EQUATION(ulong _equation){ return BGFX_STATE_BLEND_EQUATION_SEPARATE(_equation, _equation); } 41 | 42 | /// Utility predefined blend modes. 43 | 44 | /// Additive blending. 45 | static BGFX_STATE_BLEND_ADD(){ return (0 | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE)); } 46 | 47 | /// Alpha blend. 48 | static BGFX_STATE_BLEND_ALPHA(){ return (0 | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)); } 49 | 50 | /// Memory release callback. 51 | 52 | /// Color RGB/alpha/depth write. When it's not specified write will be disabled. 53 | enum ulong BGFX_STATE_WRITE_R = 0x0000000000000001; /// Enable R write. 54 | enum ulong BGFX_STATE_WRITE_G = 0x0000000000000002; /// Enable G write. 55 | enum ulong BGFX_STATE_WRITE_B = 0x0000000000000004; /// Enable B write. 56 | enum ulong BGFX_STATE_WRITE_A = 0x0000000000000008; /// Enable alpha write. 57 | enum ulong BGFX_STATE_WRITE_Z = 0x0000004000000000; /// Enable depth write. 58 | enum ulong BGFX_STATE_WRITE_RGB = 0x0000000000000007; /// Enable RGB write. 59 | enum ulong BGFX_STATE_WRITE_MASK = 0x000000400000000f; /// Write all channels mask. 60 | 61 | /// Depth test state. When `BGFX_STATE_DEPTH_` is not specified depth test will be disabled. 62 | enum ulong BGFX_STATE_DEPTH_TEST_LESS = 0x0000000000000010; /// Enable depth test, less. 63 | enum ulong BGFX_STATE_DEPTH_TEST_LEQUAL = 0x0000000000000020; /// Enable depth test, less or equal. 64 | enum ulong BGFX_STATE_DEPTH_TEST_EQUAL = 0x0000000000000030; /// Enable depth test, equal. 65 | enum ulong BGFX_STATE_DEPTH_TEST_GEQUAL = 0x0000000000000040; /// Enable depth test, greater or equal. 66 | enum ulong BGFX_STATE_DEPTH_TEST_GREATER = 0x0000000000000050; /// Enable depth test, greater. 67 | enum ulong BGFX_STATE_DEPTH_TEST_NOTEQUAL = 0x0000000000000060; /// Enable depth test, not equal. 68 | enum ulong BGFX_STATE_DEPTH_TEST_NEVER = 0x0000000000000070; /// Enable depth test, never. 69 | enum ulong BGFX_STATE_DEPTH_TEST_ALWAYS = 0x0000000000000080; /// Enable depth test, always. 70 | enum ulong BGFX_STATE_DEPTH_TEST_SHIFT = 4; /// Depth test state bit shift 71 | enum ulong BGFX_STATE_DEPTH_TEST_MASK = 0x00000000000000f0; /// Depth test state bit mask 72 | 73 | /** 74 | * Use BGFX_STATE_BLEND_FUNC(_src, _dst) or BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA) 75 | * helper macros. 76 | */ 77 | enum ulong BGFX_STATE_BLEND_ZERO = 0x0000000000001000; /// 0, 0, 0, 0 78 | enum ulong BGFX_STATE_BLEND_ONE = 0x0000000000002000; /// 1, 1, 1, 1 79 | enum ulong BGFX_STATE_BLEND_SRC_COLOR = 0x0000000000003000; /// Rs, Gs, Bs, As 80 | enum ulong BGFX_STATE_BLEND_INV_SRC_COLOR = 0x0000000000004000; /// 1-Rs, 1-Gs, 1-Bs, 1-As 81 | enum ulong BGFX_STATE_BLEND_SRC_ALPHA = 0x0000000000005000; /// As, As, As, As 82 | enum ulong BGFX_STATE_BLEND_INV_SRC_ALPHA = 0x0000000000006000; /// 1-As, 1-As, 1-As, 1-As 83 | enum ulong BGFX_STATE_BLEND_DST_ALPHA = 0x0000000000007000; /// Ad, Ad, Ad, Ad 84 | enum ulong BGFX_STATE_BLEND_INV_DST_ALPHA = 0x0000000000008000; /// 1-Ad, 1-Ad, 1-Ad ,1-Ad 85 | enum ulong BGFX_STATE_BLEND_DST_COLOR = 0x0000000000009000; /// Rd, Gd, Bd, Ad 86 | enum ulong BGFX_STATE_BLEND_INV_DST_COLOR = 0x000000000000a000; /// 1-Rd, 1-Gd, 1-Bd, 1-Ad 87 | enum ulong BGFX_STATE_BLEND_SRC_ALPHA_SAT = 0x000000000000b000; /// f, f, f, 1; f = min(As, 1-Ad) 88 | enum ulong BGFX_STATE_BLEND_FACTOR = 0x000000000000c000; /// Blend factor 89 | enum ulong BGFX_STATE_BLEND_INV_FACTOR = 0x000000000000d000; /// 1-Blend factor 90 | enum ulong BGFX_STATE_BLEND_SHIFT = 12; /// Blend state bit shift 91 | enum ulong BGFX_STATE_BLEND_MASK = 0x000000000ffff000; /// Blend state bit mask 92 | 93 | /** 94 | * Use BGFX_STATE_BLEND_EQUATION(_equation) or BGFX_STATE_BLEND_EQUATION_SEPARATE(_equationRGB, _equationA) 95 | * helper macros. 96 | */ 97 | enum ulong BGFX_STATE_BLEND_EQUATION_ADD = 0x0000000000000000; /// Blend add: src + dst. 98 | enum ulong BGFX_STATE_BLEND_EQUATION_SUB = 0x0000000010000000; /// Blend subtract: src - dst. 99 | enum ulong BGFX_STATE_BLEND_EQUATION_REVSUB = 0x0000000020000000; /// Blend reverse subtract: dst - src. 100 | enum ulong BGFX_STATE_BLEND_EQUATION_MIN = 0x0000000030000000; /// Blend min: min(src, dst). 101 | enum ulong BGFX_STATE_BLEND_EQUATION_MAX = 0x0000000040000000; /// Blend max: max(src, dst). 102 | enum ulong BGFX_STATE_BLEND_EQUATION_SHIFT = 28; /// Blend equation bit shift 103 | enum ulong BGFX_STATE_BLEND_EQUATION_MASK = 0x00000003f0000000; /// Blend equation bit mask 104 | 105 | /// Cull state. When `BGFX_STATE_CULL_*` is not specified culling will be disabled. 106 | enum ulong BGFX_STATE_CULL_CW = 0x0000001000000000; /// Cull clockwise triangles. 107 | enum ulong BGFX_STATE_CULL_CCW = 0x0000002000000000; /// Cull counter-clockwise triangles. 108 | enum ulong BGFX_STATE_CULL_SHIFT = 36; /// Culling mode bit shift 109 | enum ulong BGFX_STATE_CULL_MASK = 0x0000003000000000; /// Culling mode bit mask 110 | 111 | /// Alpha reference value. 112 | enum ulong BGFX_STATE_ALPHA_REF_SHIFT = 40; /// Alpha reference bit shift 113 | enum ulong BGFX_STATE_ALPHA_REF_MASK = 0x0000ff0000000000; /// Alpha reference bit mask 114 | ulong BGFX_STATE_ALPHA_REF (ulong v) { return (v << BGFX_STATE_ALPHA_REF_SHIFT) & BGFX_STATE_ALPHA_REF_MASK; } 115 | 116 | enum ulong BGFX_STATE_PT_TRISTRIP = 0x0001000000000000; /// Tristrip. 117 | enum ulong BGFX_STATE_PT_LINES = 0x0002000000000000; /// Lines. 118 | enum ulong BGFX_STATE_PT_LINESTRIP = 0x0003000000000000; /// Line strip. 119 | enum ulong BGFX_STATE_PT_POINTS = 0x0004000000000000; /// Points. 120 | enum ulong BGFX_STATE_PT_SHIFT = 48; /// Primitive type bit shift 121 | enum ulong BGFX_STATE_PT_MASK = 0x0007000000000000; /// Primitive type bit mask 122 | 123 | /// Point size value. 124 | enum ulong BGFX_STATE_POINT_SIZE_SHIFT = 52; /// Point size bit shift 125 | enum ulong BGFX_STATE_POINT_SIZE_MASK = 0x00f0000000000000; /// Point size bit mask 126 | ulong BGFX_STATE_POINT_SIZE (ulong v) { return (v << BGFX_STATE_POINT_SIZE_SHIFT) & BGFX_STATE_POINT_SIZE_MASK; } 127 | 128 | /** 129 | * Enable MSAA write when writing into MSAA frame buffer. 130 | * This flag is ignored when not writing into MSAA frame buffer. 131 | */ 132 | enum ulong BGFX_STATE_MSAA = 0x0100000000000000; /// Enable MSAA rasterization. 133 | enum ulong BGFX_STATE_LINEAA = 0x0200000000000000; /// Enable line AA rasterization. 134 | enum ulong BGFX_STATE_CONSERVATIVE_RASTER = 0x0400000000000000; /// Enable conservative rasterization. 135 | enum ulong BGFX_STATE_NONE = 0x0000000000000000; /// No state. 136 | enum ulong BGFX_STATE_FRONT_CCW = 0x0000008000000000; /// Front counter-clockwise (default is clockwise). 137 | enum ulong BGFX_STATE_BLEND_INDEPENDENT = 0x0000000400000000; /// Enable blend independent. 138 | enum ulong BGFX_STATE_BLEND_ALPHA_TO_COVERAGE = 0x0000000800000000; /// Enable alpha to coverage. 139 | /** 140 | * Default state is write to RGB, alpha, and depth with depth test less enabled, with clockwise 141 | * culling and MSAA (when writing into MSAA frame buffer, otherwise this flag is ignored). 142 | */ 143 | enum ulong BGFX_STATE_DEFAULT = BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A | BGFX_STATE_WRITE_Z | BGFX_STATE_DEPTH_TEST_LESS | BGFX_STATE_CULL_CW | BGFX_STATE_MSAA; 144 | enum ulong BGFX_STATE_MASK = 0xffffffffffffffff; /// State bit mask 145 | 146 | /// Do not use! 147 | enum ulong BGFX_STATE_RESERVED_SHIFT = 61; 148 | enum ulong BGFX_STATE_RESERVED_MASK = 0xe000000000000000; 149 | 150 | /// Set stencil ref value. 151 | enum uint BGFX_STENCIL_FUNC_REF_SHIFT = 0; 152 | enum uint BGFX_STENCIL_FUNC_REF_MASK = 0x000000ff; 153 | uint BGFX_STENCIL_FUNC_REF (uint v) { return (v << BGFX_STENCIL_FUNC_REF_SHIFT) & BGFX_STENCIL_FUNC_REF_MASK; } 154 | 155 | /// Set stencil rmask value. 156 | enum uint BGFX_STENCIL_FUNC_RMASK_SHIFT = 8; 157 | enum uint BGFX_STENCIL_FUNC_RMASK_MASK = 0x0000ff00; 158 | uint BGFX_STENCIL_FUNC_RMASK (uint v) { return (v << BGFX_STENCIL_FUNC_RMASK_SHIFT) & BGFX_STENCIL_FUNC_RMASK_MASK; } 159 | 160 | enum uint BGFX_STENCIL_NONE = 0x00000000; 161 | enum uint BGFX_STENCIL_MASK = 0xffffffff; 162 | enum uint BGFX_STENCIL_DEFAULT = 0x00000000; 163 | 164 | enum uint BGFX_STENCIL_TEST_LESS = 0x00010000; /// Enable stencil test, less. 165 | enum uint BGFX_STENCIL_TEST_LEQUAL = 0x00020000; /// Enable stencil test, less or equal. 166 | enum uint BGFX_STENCIL_TEST_EQUAL = 0x00030000; /// Enable stencil test, equal. 167 | enum uint BGFX_STENCIL_TEST_GEQUAL = 0x00040000; /// Enable stencil test, greater or equal. 168 | enum uint BGFX_STENCIL_TEST_GREATER = 0x00050000; /// Enable stencil test, greater. 169 | enum uint BGFX_STENCIL_TEST_NOTEQUAL = 0x00060000; /// Enable stencil test, not equal. 170 | enum uint BGFX_STENCIL_TEST_NEVER = 0x00070000; /// Enable stencil test, never. 171 | enum uint BGFX_STENCIL_TEST_ALWAYS = 0x00080000; /// Enable stencil test, always. 172 | enum uint BGFX_STENCIL_TEST_SHIFT = 16; /// Stencil test bit shift 173 | enum uint BGFX_STENCIL_TEST_MASK = 0x000f0000; /// Stencil test bit mask 174 | 175 | enum uint BGFX_STENCIL_OP_FAIL_S_ZERO = 0x00000000; /// Zero. 176 | enum uint BGFX_STENCIL_OP_FAIL_S_KEEP = 0x00100000; /// Keep. 177 | enum uint BGFX_STENCIL_OP_FAIL_S_REPLACE = 0x00200000; /// Replace. 178 | enum uint BGFX_STENCIL_OP_FAIL_S_INCR = 0x00300000; /// Increment and wrap. 179 | enum uint BGFX_STENCIL_OP_FAIL_S_INCRSAT = 0x00400000; /// Increment and clamp. 180 | enum uint BGFX_STENCIL_OP_FAIL_S_DECR = 0x00500000; /// Decrement and wrap. 181 | enum uint BGFX_STENCIL_OP_FAIL_S_DECRSAT = 0x00600000; /// Decrement and clamp. 182 | enum uint BGFX_STENCIL_OP_FAIL_S_INVERT = 0x00700000; /// Invert. 183 | enum uint BGFX_STENCIL_OP_FAIL_S_SHIFT = 20; /// Stencil operation fail bit shift 184 | enum uint BGFX_STENCIL_OP_FAIL_S_MASK = 0x00f00000; /// Stencil operation fail bit mask 185 | 186 | enum uint BGFX_STENCIL_OP_FAIL_Z_ZERO = 0x00000000; /// Zero. 187 | enum uint BGFX_STENCIL_OP_FAIL_Z_KEEP = 0x01000000; /// Keep. 188 | enum uint BGFX_STENCIL_OP_FAIL_Z_REPLACE = 0x02000000; /// Replace. 189 | enum uint BGFX_STENCIL_OP_FAIL_Z_INCR = 0x03000000; /// Increment and wrap. 190 | enum uint BGFX_STENCIL_OP_FAIL_Z_INCRSAT = 0x04000000; /// Increment and clamp. 191 | enum uint BGFX_STENCIL_OP_FAIL_Z_DECR = 0x05000000; /// Decrement and wrap. 192 | enum uint BGFX_STENCIL_OP_FAIL_Z_DECRSAT = 0x06000000; /// Decrement and clamp. 193 | enum uint BGFX_STENCIL_OP_FAIL_Z_INVERT = 0x07000000; /// Invert. 194 | enum uint BGFX_STENCIL_OP_FAIL_Z_SHIFT = 24; /// Stencil operation depth fail bit shift 195 | enum uint BGFX_STENCIL_OP_FAIL_Z_MASK = 0x0f000000; /// Stencil operation depth fail bit mask 196 | 197 | enum uint BGFX_STENCIL_OP_PASS_Z_ZERO = 0x00000000; /// Zero. 198 | enum uint BGFX_STENCIL_OP_PASS_Z_KEEP = 0x10000000; /// Keep. 199 | enum uint BGFX_STENCIL_OP_PASS_Z_REPLACE = 0x20000000; /// Replace. 200 | enum uint BGFX_STENCIL_OP_PASS_Z_INCR = 0x30000000; /// Increment and wrap. 201 | enum uint BGFX_STENCIL_OP_PASS_Z_INCRSAT = 0x40000000; /// Increment and clamp. 202 | enum uint BGFX_STENCIL_OP_PASS_Z_DECR = 0x50000000; /// Decrement and wrap. 203 | enum uint BGFX_STENCIL_OP_PASS_Z_DECRSAT = 0x60000000; /// Decrement and clamp. 204 | enum uint BGFX_STENCIL_OP_PASS_Z_INVERT = 0x70000000; /// Invert. 205 | enum uint BGFX_STENCIL_OP_PASS_Z_SHIFT = 28; /// Stencil operation depth pass bit shift 206 | enum uint BGFX_STENCIL_OP_PASS_Z_MASK = 0xf0000000; /// Stencil operation depth pass bit mask 207 | 208 | enum ushort BGFX_CLEAR_NONE = 0x0000; /// No clear flags. 209 | enum ushort BGFX_CLEAR_COLOR = 0x0001; /// Clear color. 210 | enum ushort BGFX_CLEAR_DEPTH = 0x0002; /// Clear depth. 211 | enum ushort BGFX_CLEAR_STENCIL = 0x0004; /// Clear stencil. 212 | enum ushort BGFX_CLEAR_DISCARD_COLOR_0 = 0x0008; /// Discard frame buffer attachment 0. 213 | enum ushort BGFX_CLEAR_DISCARD_COLOR_1 = 0x0010; /// Discard frame buffer attachment 1. 214 | enum ushort BGFX_CLEAR_DISCARD_COLOR_2 = 0x0020; /// Discard frame buffer attachment 2. 215 | enum ushort BGFX_CLEAR_DISCARD_COLOR_3 = 0x0040; /// Discard frame buffer attachment 3. 216 | enum ushort BGFX_CLEAR_DISCARD_COLOR_4 = 0x0080; /// Discard frame buffer attachment 4. 217 | enum ushort BGFX_CLEAR_DISCARD_COLOR_5 = 0x0100; /// Discard frame buffer attachment 5. 218 | enum ushort BGFX_CLEAR_DISCARD_COLOR_6 = 0x0200; /// Discard frame buffer attachment 6. 219 | enum ushort BGFX_CLEAR_DISCARD_COLOR_7 = 0x0400; /// Discard frame buffer attachment 7. 220 | enum ushort BGFX_CLEAR_DISCARD_DEPTH = 0x0800; /// Discard frame buffer depth attachment. 221 | enum ushort BGFX_CLEAR_DISCARD_STENCIL = 0x1000; /// Discard frame buffer stencil attachment. 222 | enum ushort BGFX_CLEAR_DISCARD_COLOR_MASK = 0x07f8; 223 | enum ushort BGFX_CLEAR_DISCARD_MASK = 0x1ff8; 224 | 225 | /** 226 | * Rendering state discard. When state is preserved in submit, rendering states can be discarded 227 | * on a finer grain. 228 | */ 229 | enum ubyte BGFX_DISCARD_NONE = 0x00; /// Preserve everything. 230 | enum ubyte BGFX_DISCARD_BINDINGS = 0x01; /// Discard texture sampler and buffer bindings. 231 | enum ubyte BGFX_DISCARD_INDEX_BUFFER = 0x02; /// Discard index buffer. 232 | enum ubyte BGFX_DISCARD_INSTANCE_DATA = 0x04; /// Discard instance data. 233 | enum ubyte BGFX_DISCARD_STATE = 0x08; /// Discard state and uniform bindings. 234 | enum ubyte BGFX_DISCARD_TRANSFORM = 0x10; /// Discard transform. 235 | enum ubyte BGFX_DISCARD_VERTEX_STREAMS = 0x20; /// Discard vertex streams. 236 | enum ubyte BGFX_DISCARD_ALL = 0xff; /// Discard all states. 237 | 238 | enum uint BGFX_DEBUG_NONE = 0x00000000; /// No debug. 239 | enum uint BGFX_DEBUG_WIREFRAME = 0x00000001; /// Enable wireframe for all primitives. 240 | /** 241 | * Enable infinitely fast hardware test. No draw calls will be submitted to driver. 242 | * It's useful when profiling to quickly assess bottleneck between CPU and GPU. 243 | */ 244 | enum uint BGFX_DEBUG_IFH = 0x00000002; 245 | enum uint BGFX_DEBUG_STATS = 0x00000004; /// Enable statistics display. 246 | enum uint BGFX_DEBUG_TEXT = 0x00000008; /// Enable debug text display. 247 | enum uint BGFX_DEBUG_PROFILER = 0x00000010; /// Enable profiler. This causes per-view statistics to be collected, available through `bgfx::Stats::ViewStats`. This is unrelated to the profiler functions in `bgfx::CallbackI`. 248 | 249 | enum ushort BGFX_BUFFER_COMPUTE_FORMAT_8X1 = 0x0001; /// 1 8-bit value 250 | enum ushort BGFX_BUFFER_COMPUTE_FORMAT_8X2 = 0x0002; /// 2 8-bit values 251 | enum ushort BGFX_BUFFER_COMPUTE_FORMAT_8X4 = 0x0003; /// 4 8-bit values 252 | enum ushort BGFX_BUFFER_COMPUTE_FORMAT_16X1 = 0x0004; /// 1 16-bit value 253 | enum ushort BGFX_BUFFER_COMPUTE_FORMAT_16X2 = 0x0005; /// 2 16-bit values 254 | enum ushort BGFX_BUFFER_COMPUTE_FORMAT_16X4 = 0x0006; /// 4 16-bit values 255 | enum ushort BGFX_BUFFER_COMPUTE_FORMAT_32X1 = 0x0007; /// 1 32-bit value 256 | enum ushort BGFX_BUFFER_COMPUTE_FORMAT_32X2 = 0x0008; /// 2 32-bit values 257 | enum ushort BGFX_BUFFER_COMPUTE_FORMAT_32X4 = 0x0009; /// 4 32-bit values 258 | enum ushort BGFX_BUFFER_COMPUTE_FORMAT_SHIFT = 0; 259 | enum ushort BGFX_BUFFER_COMPUTE_FORMAT_MASK = 0x000f; 260 | 261 | enum ushort BGFX_BUFFER_COMPUTE_TYPE_INT = 0x0010; /// Type `int`. 262 | enum ushort BGFX_BUFFER_COMPUTE_TYPE_UINT = 0x0020; /// Type `uint`. 263 | enum ushort BGFX_BUFFER_COMPUTE_TYPE_FLOAT = 0x0030; /// Type `float`. 264 | enum ushort BGFX_BUFFER_COMPUTE_TYPE_SHIFT = 4; 265 | enum ushort BGFX_BUFFER_COMPUTE_TYPE_MASK = 0x0030; 266 | 267 | enum ushort BGFX_BUFFER_NONE = 0x0000; 268 | enum ushort BGFX_BUFFER_COMPUTE_READ = 0x0100; /// Buffer will be read by shader. 269 | enum ushort BGFX_BUFFER_COMPUTE_WRITE = 0x0200; /// Buffer will be used for writing. 270 | enum ushort BGFX_BUFFER_DRAW_INDIRECT = 0x0400; /// Buffer will be used for storing draw indirect commands. 271 | enum ushort BGFX_BUFFER_ALLOW_RESIZE = 0x0800; /// Allow dynamic index/vertex buffer resize during update. 272 | enum ushort BGFX_BUFFER_INDEX32 = 0x1000; /// Index buffer contains 32-bit indices. 273 | enum ushort BGFX_BUFFER_COMPUTE_READ_WRITE = 0x0300; 274 | 275 | enum ulong BGFX_TEXTURE_NONE = 0x0000000000000000; 276 | enum ulong BGFX_TEXTURE_MSAA_SAMPLE = 0x0000000800000000; /// Texture will be used for MSAA sampling. 277 | enum ulong BGFX_TEXTURE_RT = 0x0000001000000000; /// Render target no MSAA. 278 | enum ulong BGFX_TEXTURE_COMPUTE_WRITE = 0x0000100000000000; /// Texture will be used for compute write. 279 | enum ulong BGFX_TEXTURE_SRGB = 0x0000200000000000; /// Sample texture as sRGB. 280 | enum ulong BGFX_TEXTURE_BLIT_DST = 0x0000400000000000; /// Texture will be used as blit destination. 281 | enum ulong BGFX_TEXTURE_READ_BACK = 0x0000800000000000; /// Texture will be used for read back from GPU. 282 | 283 | enum ulong BGFX_TEXTURE_RT_MSAA_X2 = 0x0000002000000000; /// Render target MSAAx2 mode. 284 | enum ulong BGFX_TEXTURE_RT_MSAA_X4 = 0x0000003000000000; /// Render target MSAAx4 mode. 285 | enum ulong BGFX_TEXTURE_RT_MSAA_X8 = 0x0000004000000000; /// Render target MSAAx8 mode. 286 | enum ulong BGFX_TEXTURE_RT_MSAA_X16 = 0x0000005000000000; /// Render target MSAAx16 mode. 287 | enum ulong BGFX_TEXTURE_RT_MSAA_SHIFT = 36; 288 | enum ulong BGFX_TEXTURE_RT_MSAA_MASK = 0x0000007000000000; 289 | 290 | enum ulong BGFX_TEXTURE_RT_WRITE_ONLY = 0x0000008000000000; /// Render target will be used for writing 291 | enum ulong BGFX_TEXTURE_RT_SHIFT = 36; 292 | enum ulong BGFX_TEXTURE_RT_MASK = 0x000000f000000000; 293 | 294 | /// Sampler flags. 295 | enum uint BGFX_SAMPLER_U_MIRROR = 0x00000001; /// Wrap U mode: Mirror 296 | enum uint BGFX_SAMPLER_U_CLAMP = 0x00000002; /// Wrap U mode: Clamp 297 | enum uint BGFX_SAMPLER_U_BORDER = 0x00000003; /// Wrap U mode: Border 298 | enum uint BGFX_SAMPLER_U_SHIFT = 0; 299 | enum uint BGFX_SAMPLER_U_MASK = 0x00000003; 300 | 301 | enum uint BGFX_SAMPLER_V_MIRROR = 0x00000004; /// Wrap V mode: Mirror 302 | enum uint BGFX_SAMPLER_V_CLAMP = 0x00000008; /// Wrap V mode: Clamp 303 | enum uint BGFX_SAMPLER_V_BORDER = 0x0000000c; /// Wrap V mode: Border 304 | enum uint BGFX_SAMPLER_V_SHIFT = 2; 305 | enum uint BGFX_SAMPLER_V_MASK = 0x0000000c; 306 | 307 | enum uint BGFX_SAMPLER_W_MIRROR = 0x00000010; /// Wrap W mode: Mirror 308 | enum uint BGFX_SAMPLER_W_CLAMP = 0x00000020; /// Wrap W mode: Clamp 309 | enum uint BGFX_SAMPLER_W_BORDER = 0x00000030; /// Wrap W mode: Border 310 | enum uint BGFX_SAMPLER_W_SHIFT = 4; 311 | enum uint BGFX_SAMPLER_W_MASK = 0x00000030; 312 | 313 | enum uint BGFX_SAMPLER_MIN_POINT = 0x00000040; /// Min sampling mode: Point 314 | enum uint BGFX_SAMPLER_MIN_ANISOTROPIC = 0x00000080; /// Min sampling mode: Anisotropic 315 | enum uint BGFX_SAMPLER_MIN_SHIFT = 6; 316 | enum uint BGFX_SAMPLER_MIN_MASK = 0x000000c0; 317 | 318 | enum uint BGFX_SAMPLER_MAG_POINT = 0x00000100; /// Mag sampling mode: Point 319 | enum uint BGFX_SAMPLER_MAG_ANISOTROPIC = 0x00000200; /// Mag sampling mode: Anisotropic 320 | enum uint BGFX_SAMPLER_MAG_SHIFT = 8; 321 | enum uint BGFX_SAMPLER_MAG_MASK = 0x00000300; 322 | 323 | enum uint BGFX_SAMPLER_MIP_POINT = 0x00000400; /// Mip sampling mode: Point 324 | enum uint BGFX_SAMPLER_MIP_SHIFT = 10; 325 | enum uint BGFX_SAMPLER_MIP_MASK = 0x00000400; 326 | 327 | enum uint BGFX_SAMPLER_COMPARE_LESS = 0x00010000; /// Compare when sampling depth texture: less. 328 | enum uint BGFX_SAMPLER_COMPARE_LEQUAL = 0x00020000; /// Compare when sampling depth texture: less or equal. 329 | enum uint BGFX_SAMPLER_COMPARE_EQUAL = 0x00030000; /// Compare when sampling depth texture: equal. 330 | enum uint BGFX_SAMPLER_COMPARE_GEQUAL = 0x00040000; /// Compare when sampling depth texture: greater or equal. 331 | enum uint BGFX_SAMPLER_COMPARE_GREATER = 0x00050000; /// Compare when sampling depth texture: greater. 332 | enum uint BGFX_SAMPLER_COMPARE_NOTEQUAL = 0x00060000; /// Compare when sampling depth texture: not equal. 333 | enum uint BGFX_SAMPLER_COMPARE_NEVER = 0x00070000; /// Compare when sampling depth texture: never. 334 | enum uint BGFX_SAMPLER_COMPARE_ALWAYS = 0x00080000; /// Compare when sampling depth texture: always. 335 | enum uint BGFX_SAMPLER_COMPARE_SHIFT = 16; 336 | enum uint BGFX_SAMPLER_COMPARE_MASK = 0x000f0000; 337 | 338 | enum uint BGFX_SAMPLER_BORDER_COLOR_SHIFT = 24; 339 | enum uint BGFX_SAMPLER_BORDER_COLOR_MASK = 0x0f000000; 340 | uint BGFX_SAMPLER_BORDER_COLOR (uint v) { return (v << BGFX_SAMPLER_BORDER_COLOR_SHIFT) & BGFX_SAMPLER_BORDER_COLOR_MASK; } 341 | 342 | enum uint BGFX_SAMPLER_RESERVED_SHIFT = 28; 343 | enum uint BGFX_SAMPLER_RESERVED_MASK = 0xf0000000; 344 | 345 | enum uint BGFX_SAMPLER_NONE = 0x00000000; 346 | enum uint BGFX_SAMPLER_SAMPLE_STENCIL = 0x00100000; /// Sample stencil instead of depth. 347 | enum uint BGFX_SAMPLER_POINT = BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT; 348 | enum uint BGFX_SAMPLER_UVW_MIRROR = BGFX_SAMPLER_U_MIRROR | BGFX_SAMPLER_V_MIRROR | BGFX_SAMPLER_W_MIRROR; 349 | enum uint BGFX_SAMPLER_UVW_CLAMP = BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP | BGFX_SAMPLER_W_CLAMP; 350 | enum uint BGFX_SAMPLER_UVW_BORDER = BGFX_SAMPLER_U_BORDER | BGFX_SAMPLER_V_BORDER | BGFX_SAMPLER_W_BORDER; 351 | enum uint BGFX_SAMPLER_BITS_MASK = BGFX_SAMPLER_U_MASK | BGFX_SAMPLER_V_MASK | BGFX_SAMPLER_W_MASK | BGFX_SAMPLER_MIN_MASK | BGFX_SAMPLER_MAG_MASK | BGFX_SAMPLER_MIP_MASK | BGFX_SAMPLER_COMPARE_MASK; 352 | 353 | enum uint BGFX_RESET_MSAA_X2 = 0x00000010; /// Enable 2x MSAA. 354 | enum uint BGFX_RESET_MSAA_X4 = 0x00000020; /// Enable 4x MSAA. 355 | enum uint BGFX_RESET_MSAA_X8 = 0x00000030; /// Enable 8x MSAA. 356 | enum uint BGFX_RESET_MSAA_X16 = 0x00000040; /// Enable 16x MSAA. 357 | enum uint BGFX_RESET_MSAA_SHIFT = 4; 358 | enum uint BGFX_RESET_MSAA_MASK = 0x00000070; 359 | 360 | enum uint BGFX_RESET_NONE = 0x00000000; /// No reset flags. 361 | enum uint BGFX_RESET_FULLSCREEN = 0x00000001; /// Not supported yet. 362 | enum uint BGFX_RESET_VSYNC = 0x00000080; /// Enable V-Sync. 363 | enum uint BGFX_RESET_MAXANISOTROPY = 0x00000100; /// Turn on/off max anisotropy. 364 | enum uint BGFX_RESET_CAPTURE = 0x00000200; /// Begin screen capture. 365 | enum uint BGFX_RESET_FLUSH_AFTER_RENDER = 0x00002000; /// Flush rendering after submitting to GPU. 366 | /** 367 | * This flag specifies where flip occurs. Default behaviour is that flip occurs 368 | * before rendering new frame. This flag only has effect when `BGFX_CONFIG_MULTITHREADED=0`. 369 | */ 370 | enum uint BGFX_RESET_FLIP_AFTER_RENDER = 0x00004000; 371 | enum uint BGFX_RESET_SRGB_BACKBUFFER = 0x00008000; /// Enable sRGB backbuffer. 372 | enum uint BGFX_RESET_HDR10 = 0x00010000; /// Enable HDR10 rendering. 373 | enum uint BGFX_RESET_HIDPI = 0x00020000; /// Enable HiDPI rendering. 374 | enum uint BGFX_RESET_DEPTH_CLAMP = 0x00040000; /// Enable depth clamp. 375 | enum uint BGFX_RESET_SUSPEND = 0x00080000; /// Suspend rendering. 376 | enum uint BGFX_RESET_TRANSPARENT_BACKBUFFER = 0x00100000; /// Transparent backbuffer. Availability depends on: `BGFX_CAPS_TRANSPARENT_BACKBUFFER`. 377 | 378 | enum uint BGFX_RESET_FULLSCREEN_SHIFT = 0; 379 | enum uint BGFX_RESET_FULLSCREEN_MASK = 0x00000001; 380 | 381 | enum uint BGFX_RESET_RESERVED_SHIFT = 31; /// Internal bit shift 382 | enum uint BGFX_RESET_RESERVED_MASK = 0x80000000; /// Internal bit mask 383 | 384 | enum ulong BGFX_CAPS_ALPHA_TO_COVERAGE = 0x0000000000000001; /// Alpha to coverage is supported. 385 | enum ulong BGFX_CAPS_BLEND_INDEPENDENT = 0x0000000000000002; /// Blend independent is supported. 386 | enum ulong BGFX_CAPS_COMPUTE = 0x0000000000000004; /// Compute shaders are supported. 387 | enum ulong BGFX_CAPS_CONSERVATIVE_RASTER = 0x0000000000000008; /// Conservative rasterization is supported. 388 | enum ulong BGFX_CAPS_DRAW_INDIRECT = 0x0000000000000010; /// Draw indirect is supported. 389 | enum ulong BGFX_CAPS_FRAGMENT_DEPTH = 0x0000000000000020; /// Fragment depth is available in fragment shader. 390 | enum ulong BGFX_CAPS_FRAGMENT_ORDERING = 0x0000000000000040; /// Fragment ordering is available in fragment shader. 391 | enum ulong BGFX_CAPS_GRAPHICS_DEBUGGER = 0x0000000000000080; /// Graphics debugger is present. 392 | enum ulong BGFX_CAPS_HDR10 = 0x0000000000000100; /// HDR10 rendering is supported. 393 | enum ulong BGFX_CAPS_HIDPI = 0x0000000000000200; /// HiDPI rendering is supported. 394 | enum ulong BGFX_CAPS_IMAGE_RW = 0x0000000000000400; /// Image Read/Write is supported. 395 | enum ulong BGFX_CAPS_INDEX32 = 0x0000000000000800; /// 32-bit indices are supported. 396 | enum ulong BGFX_CAPS_INSTANCING = 0x0000000000001000; /// Instancing is supported. 397 | enum ulong BGFX_CAPS_OCCLUSION_QUERY = 0x0000000000002000; /// Occlusion query is supported. 398 | enum ulong BGFX_CAPS_RENDERER_MULTITHREADED = 0x0000000000004000; /// Renderer is on separate thread. 399 | enum ulong BGFX_CAPS_SWAP_CHAIN = 0x0000000000008000; /// Multiple windows are supported. 400 | enum ulong BGFX_CAPS_TEXTURE_2D_ARRAY = 0x0000000000010000; /// 2D texture array is supported. 401 | enum ulong BGFX_CAPS_TEXTURE_3D = 0x0000000000020000; /// 3D textures are supported. 402 | enum ulong BGFX_CAPS_TEXTURE_BLIT = 0x0000000000040000; /// Texture blit is supported. 403 | enum ulong BGFX_CAPS_TRANSPARENT_BACKBUFFER = 0x0000000000080000; /// Transparent back buffer supported. 404 | enum ulong BGFX_CAPS_TEXTURE_COMPARE_RESERVED = 0x0000000000100000; 405 | enum ulong BGFX_CAPS_TEXTURE_COMPARE_LEQUAL = 0x0000000000200000; /// Texture compare less equal mode is supported. 406 | enum ulong BGFX_CAPS_TEXTURE_CUBE_ARRAY = 0x0000000000400000; /// Cubemap texture array is supported. 407 | enum ulong BGFX_CAPS_TEXTURE_DIRECT_ACCESS = 0x0000000000800000; /// CPU direct access to GPU texture memory. 408 | enum ulong BGFX_CAPS_TEXTURE_READ_BACK = 0x0000000001000000; /// Read-back texture is supported. 409 | enum ulong BGFX_CAPS_VERTEX_ATTRIB_HALF = 0x0000000002000000; /// Vertex attribute half-float is supported. 410 | enum ulong BGFX_CAPS_VERTEX_ATTRIB_UINT10 = 0x0000000004000000; /// Vertex attribute 10_10_10_2 is supported. 411 | enum ulong BGFX_CAPS_VERTEX_ID = 0x0000000008000000; /// Rendering with VertexID only is supported. 412 | enum ulong BGFX_CAPS_VIEWPORT_LAYER_ARRAY = 0x0000000010000000; /// Viewport layer is available in vertex shader. 413 | enum ulong BGFX_CAPS_DRAW_INDIRECT_COUNT = 0x0000000020000000; /// Draw indirect with indirect count is supported. 414 | enum ulong BGFX_CAPS_TEXTURE_COMPARE_ALL = 0x0000000000300000; /// All texture compare modes are supported. 415 | 416 | enum uint BGFX_CAPS_FORMAT_TEXTURE_NONE = 0x00000000; /// Texture format is not supported. 417 | enum uint BGFX_CAPS_FORMAT_TEXTURE_2D = 0x00000001; /// Texture format is supported. 418 | enum uint BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB = 0x00000002; /// Texture as sRGB format is supported. 419 | enum uint BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED = 0x00000004; /// Texture format is emulated. 420 | enum uint BGFX_CAPS_FORMAT_TEXTURE_3D = 0x00000008; /// Texture format is supported. 421 | enum uint BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB = 0x00000010; /// Texture as sRGB format is supported. 422 | enum uint BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED = 0x00000020; /// Texture format is emulated. 423 | enum uint BGFX_CAPS_FORMAT_TEXTURE_CUBE = 0x00000040; /// Texture format is supported. 424 | enum uint BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB = 0x00000080; /// Texture as sRGB format is supported. 425 | enum uint BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED = 0x00000100; /// Texture format is emulated. 426 | enum uint BGFX_CAPS_FORMAT_TEXTURE_VERTEX = 0x00000200; /// Texture format can be used from vertex shader. 427 | enum uint BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ = 0x00000400; /// Texture format can be used as image and read from. 428 | enum uint BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE = 0x00000800; /// Texture format can be used as image and written to. 429 | enum uint BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER = 0x00001000; /// Texture format can be used as frame buffer. 430 | enum uint BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA = 0x00002000; /// Texture format can be used as MSAA frame buffer. 431 | enum uint BGFX_CAPS_FORMAT_TEXTURE_MSAA = 0x00004000; /// Texture can be sampled as MSAA. 432 | enum uint BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN = 0x00008000; /// Texture format supports auto-generated mips. 433 | 434 | enum ubyte BGFX_RESOLVE_NONE = 0x00; /// No resolve flags. 435 | enum ubyte BGFX_RESOLVE_AUTO_GEN_MIPS = 0x01; /// Auto-generate mip maps on resolve. 436 | 437 | enum ushort BGFX_PCI_ID_NONE = 0x0000; /// Autoselect adapter. 438 | enum ushort BGFX_PCI_ID_SOFTWARE_RASTERIZER = 0x0001; /// Software rasterizer. 439 | enum ushort BGFX_PCI_ID_AMD = 0x1002; /// AMD adapter. 440 | enum ushort BGFX_PCI_ID_APPLE = 0x106b; /// Apple adapter. 441 | enum ushort BGFX_PCI_ID_INTEL = 0x8086; /// Intel adapter. 442 | enum ushort BGFX_PCI_ID_NVIDIA = 0x10de; /// nVidia adapter. 443 | enum ushort BGFX_PCI_ID_MICROSOFT = 0x1414; /// Microsoft adapter. 444 | enum ushort BGFX_PCI_ID_ARM = 0x13b5; /// ARM adapter. 445 | 446 | enum ubyte BGFX_CUBE_MAP_POSITIVE_X = 0x00; /// Cubemap +x. 447 | enum ubyte BGFX_CUBE_MAP_NEGATIVE_X = 0x01; /// Cubemap -x. 448 | enum ubyte BGFX_CUBE_MAP_POSITIVE_Y = 0x02; /// Cubemap +y. 449 | enum ubyte BGFX_CUBE_MAP_NEGATIVE_Y = 0x03; /// Cubemap -y. 450 | enum ubyte BGFX_CUBE_MAP_POSITIVE_Z = 0x04; /// Cubemap +z. 451 | enum ubyte BGFX_CUBE_MAP_NEGATIVE_Z = 0x05; /// Cubemap -z. 452 | 453 | /// Fatal error enum. 454 | enum bgfx_fatal_t 455 | { 456 | BGFX_FATAL_DEBUGCHECK, 457 | BGFX_FATAL_INVALIDSHADER, 458 | BGFX_FATAL_UNABLETOINITIALIZE, 459 | BGFX_FATAL_UNABLETOCREATETEXTURE, 460 | BGFX_FATAL_DEVICELOST, 461 | 462 | BGFX_FATAL_COUNT 463 | } 464 | mixin(expandEnum!bgfx_fatal_t); 465 | 466 | /// Renderer backend type enum. 467 | enum bgfx_renderer_type_t 468 | { 469 | BGFX_RENDERER_TYPE_NOOP, /// No rendering. 470 | BGFX_RENDERER_TYPE_AGC, /// AGC 471 | BGFX_RENDERER_TYPE_DIRECT3D9, /// Direct3D 9.0 472 | BGFX_RENDERER_TYPE_DIRECT3D11, /// Direct3D 11.0 473 | BGFX_RENDERER_TYPE_DIRECT3D12, /// Direct3D 12.0 474 | BGFX_RENDERER_TYPE_GNM, /// GNM 475 | BGFX_RENDERER_TYPE_METAL, /// Metal 476 | BGFX_RENDERER_TYPE_NVN, /// NVN 477 | BGFX_RENDERER_TYPE_OPENGLES, /// OpenGL ES 2.0+ 478 | BGFX_RENDERER_TYPE_OPENGL, /// OpenGL 2.1+ 479 | BGFX_RENDERER_TYPE_VULKAN, /// Vulkan 480 | BGFX_RENDERER_TYPE_WEBGPU, /// WebGPU 481 | 482 | BGFX_RENDERER_TYPE_COUNT 483 | } 484 | mixin(expandEnum!bgfx_renderer_type_t); 485 | 486 | /// Access mode enum. 487 | enum bgfx_access_t 488 | { 489 | BGFX_ACCESS_READ, /// Read. 490 | BGFX_ACCESS_WRITE, /// Write. 491 | BGFX_ACCESS_READWRITE, /// Read and write. 492 | 493 | BGFX_ACCESS_COUNT 494 | } 495 | mixin(expandEnum!bgfx_access_t); 496 | 497 | /// Vertex attribute enum. 498 | enum bgfx_attrib_t 499 | { 500 | BGFX_ATTRIB_POSITION, /// a_position 501 | BGFX_ATTRIB_NORMAL, /// a_normal 502 | BGFX_ATTRIB_TANGENT, /// a_tangent 503 | BGFX_ATTRIB_BITANGENT, /// a_bitangent 504 | BGFX_ATTRIB_COLOR0, /// a_color0 505 | BGFX_ATTRIB_COLOR1, /// a_color1 506 | BGFX_ATTRIB_COLOR2, /// a_color2 507 | BGFX_ATTRIB_COLOR3, /// a_color3 508 | BGFX_ATTRIB_INDICES, /// a_indices 509 | BGFX_ATTRIB_WEIGHT, /// a_weight 510 | BGFX_ATTRIB_TEXCOORD0, /// a_texcoord0 511 | BGFX_ATTRIB_TEXCOORD1, /// a_texcoord1 512 | BGFX_ATTRIB_TEXCOORD2, /// a_texcoord2 513 | BGFX_ATTRIB_TEXCOORD3, /// a_texcoord3 514 | BGFX_ATTRIB_TEXCOORD4, /// a_texcoord4 515 | BGFX_ATTRIB_TEXCOORD5, /// a_texcoord5 516 | BGFX_ATTRIB_TEXCOORD6, /// a_texcoord6 517 | BGFX_ATTRIB_TEXCOORD7, /// a_texcoord7 518 | 519 | BGFX_ATTRIB_COUNT 520 | } 521 | mixin(expandEnum!bgfx_attrib_t); 522 | 523 | /// Vertex attribute type enum. 524 | enum bgfx_attrib_type_t 525 | { 526 | BGFX_ATTRIB_TYPE_UINT8, /// Uint8 527 | BGFX_ATTRIB_TYPE_UINT10, /// Uint10, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_UINT10`. 528 | BGFX_ATTRIB_TYPE_INT16, /// Int16 529 | BGFX_ATTRIB_TYPE_HALF, /// Half, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_HALF`. 530 | BGFX_ATTRIB_TYPE_FLOAT, /// Float 531 | 532 | BGFX_ATTRIB_TYPE_COUNT 533 | } 534 | mixin(expandEnum!bgfx_attrib_type_t); 535 | 536 | /** 537 | * Texture format enum. 538 | * Notation: 539 | * RGBA16S 540 | * ^ ^ ^ 541 | * | | +-- [ ]Unorm 542 | * | | [F]loat 543 | * | | [S]norm 544 | * | | [I]nt 545 | * | | [U]int 546 | * | +---- Number of bits per component 547 | * +-------- Components 548 | * @attention Availability depends on Caps (see: formats). 549 | */ 550 | enum bgfx_texture_format_t 551 | { 552 | BGFX_TEXTURE_FORMAT_BC1, /// DXT1 R5G6B5A1 553 | BGFX_TEXTURE_FORMAT_BC2, /// DXT3 R5G6B5A4 554 | BGFX_TEXTURE_FORMAT_BC3, /// DXT5 R5G6B5A8 555 | BGFX_TEXTURE_FORMAT_BC4, /// LATC1/ATI1 R8 556 | BGFX_TEXTURE_FORMAT_BC5, /// LATC2/ATI2 RG8 557 | BGFX_TEXTURE_FORMAT_BC6H, /// BC6H RGB16F 558 | BGFX_TEXTURE_FORMAT_BC7, /// BC7 RGB 4-7 bits per color channel, 0-8 bits alpha 559 | BGFX_TEXTURE_FORMAT_ETC1, /// ETC1 RGB8 560 | BGFX_TEXTURE_FORMAT_ETC2, /// ETC2 RGB8 561 | BGFX_TEXTURE_FORMAT_ETC2A, /// ETC2 RGBA8 562 | BGFX_TEXTURE_FORMAT_ETC2A1, /// ETC2 RGB8A1 563 | BGFX_TEXTURE_FORMAT_PTC12, /// PVRTC1 RGB 2BPP 564 | BGFX_TEXTURE_FORMAT_PTC14, /// PVRTC1 RGB 4BPP 565 | BGFX_TEXTURE_FORMAT_PTC12A, /// PVRTC1 RGBA 2BPP 566 | BGFX_TEXTURE_FORMAT_PTC14A, /// PVRTC1 RGBA 4BPP 567 | BGFX_TEXTURE_FORMAT_PTC22, /// PVRTC2 RGBA 2BPP 568 | BGFX_TEXTURE_FORMAT_PTC24, /// PVRTC2 RGBA 4BPP 569 | BGFX_TEXTURE_FORMAT_ATC, /// ATC RGB 4BPP 570 | BGFX_TEXTURE_FORMAT_ATCE, /// ATCE RGBA 8 BPP explicit alpha 571 | BGFX_TEXTURE_FORMAT_ATCI, /// ATCI RGBA 8 BPP interpolated alpha 572 | BGFX_TEXTURE_FORMAT_ASTC4X4, /// ASTC 4x4 8.0 BPP 573 | BGFX_TEXTURE_FORMAT_ASTC5X4, /// ASTC 5x4 6.40 BPP 574 | BGFX_TEXTURE_FORMAT_ASTC5X5, /// ASTC 5x5 5.12 BPP 575 | BGFX_TEXTURE_FORMAT_ASTC6X5, /// ASTC 6x5 4.27 BPP 576 | BGFX_TEXTURE_FORMAT_ASTC6X6, /// ASTC 6x6 3.56 BPP 577 | BGFX_TEXTURE_FORMAT_ASTC8X5, /// ASTC 8x5 3.20 BPP 578 | BGFX_TEXTURE_FORMAT_ASTC8X6, /// ASTC 8x6 2.67 BPP 579 | BGFX_TEXTURE_FORMAT_ASTC8X8, /// ASTC 8x8 2.00 BPP 580 | BGFX_TEXTURE_FORMAT_ASTC10X5, /// ASTC 10x5 2.56 BPP 581 | BGFX_TEXTURE_FORMAT_ASTC10X6, /// ASTC 10x6 2.13 BPP 582 | BGFX_TEXTURE_FORMAT_ASTC10X8, /// ASTC 10x8 1.60 BPP 583 | BGFX_TEXTURE_FORMAT_ASTC10X10, /// ASTC 10x10 1.28 BPP 584 | BGFX_TEXTURE_FORMAT_ASTC12X10, /// ASTC 12x10 1.07 BPP 585 | BGFX_TEXTURE_FORMAT_ASTC12X12, /// ASTC 12x12 0.89 BPP 586 | BGFX_TEXTURE_FORMAT_UNKNOWN, /// Compressed formats above. 587 | BGFX_TEXTURE_FORMAT_R1, 588 | BGFX_TEXTURE_FORMAT_A8, 589 | BGFX_TEXTURE_FORMAT_R8, 590 | BGFX_TEXTURE_FORMAT_R8I, 591 | BGFX_TEXTURE_FORMAT_R8U, 592 | BGFX_TEXTURE_FORMAT_R8S, 593 | BGFX_TEXTURE_FORMAT_R16, 594 | BGFX_TEXTURE_FORMAT_R16I, 595 | BGFX_TEXTURE_FORMAT_R16U, 596 | BGFX_TEXTURE_FORMAT_R16F, 597 | BGFX_TEXTURE_FORMAT_R16S, 598 | BGFX_TEXTURE_FORMAT_R32I, 599 | BGFX_TEXTURE_FORMAT_R32U, 600 | BGFX_TEXTURE_FORMAT_R32F, 601 | BGFX_TEXTURE_FORMAT_RG8, 602 | BGFX_TEXTURE_FORMAT_RG8I, 603 | BGFX_TEXTURE_FORMAT_RG8U, 604 | BGFX_TEXTURE_FORMAT_RG8S, 605 | BGFX_TEXTURE_FORMAT_RG16, 606 | BGFX_TEXTURE_FORMAT_RG16I, 607 | BGFX_TEXTURE_FORMAT_RG16U, 608 | BGFX_TEXTURE_FORMAT_RG16F, 609 | BGFX_TEXTURE_FORMAT_RG16S, 610 | BGFX_TEXTURE_FORMAT_RG32I, 611 | BGFX_TEXTURE_FORMAT_RG32U, 612 | BGFX_TEXTURE_FORMAT_RG32F, 613 | BGFX_TEXTURE_FORMAT_RGB8, 614 | BGFX_TEXTURE_FORMAT_RGB8I, 615 | BGFX_TEXTURE_FORMAT_RGB8U, 616 | BGFX_TEXTURE_FORMAT_RGB8S, 617 | BGFX_TEXTURE_FORMAT_RGB9E5F, 618 | BGFX_TEXTURE_FORMAT_BGRA8, 619 | BGFX_TEXTURE_FORMAT_RGBA8, 620 | BGFX_TEXTURE_FORMAT_RGBA8I, 621 | BGFX_TEXTURE_FORMAT_RGBA8U, 622 | BGFX_TEXTURE_FORMAT_RGBA8S, 623 | BGFX_TEXTURE_FORMAT_RGBA16, 624 | BGFX_TEXTURE_FORMAT_RGBA16I, 625 | BGFX_TEXTURE_FORMAT_RGBA16U, 626 | BGFX_TEXTURE_FORMAT_RGBA16F, 627 | BGFX_TEXTURE_FORMAT_RGBA16S, 628 | BGFX_TEXTURE_FORMAT_RGBA32I, 629 | BGFX_TEXTURE_FORMAT_RGBA32U, 630 | BGFX_TEXTURE_FORMAT_RGBA32F, 631 | BGFX_TEXTURE_FORMAT_B5G6R5, 632 | BGFX_TEXTURE_FORMAT_R5G6B5, 633 | BGFX_TEXTURE_FORMAT_BGRA4, 634 | BGFX_TEXTURE_FORMAT_RGBA4, 635 | BGFX_TEXTURE_FORMAT_BGR5A1, 636 | BGFX_TEXTURE_FORMAT_RGB5A1, 637 | BGFX_TEXTURE_FORMAT_RGB10A2, 638 | BGFX_TEXTURE_FORMAT_RG11B10F, 639 | BGFX_TEXTURE_FORMAT_UNKNOWNDEPTH, /// Depth formats below. 640 | BGFX_TEXTURE_FORMAT_D16, 641 | BGFX_TEXTURE_FORMAT_D24, 642 | BGFX_TEXTURE_FORMAT_D24S8, 643 | BGFX_TEXTURE_FORMAT_D32, 644 | BGFX_TEXTURE_FORMAT_D16F, 645 | BGFX_TEXTURE_FORMAT_D24F, 646 | BGFX_TEXTURE_FORMAT_D32F, 647 | BGFX_TEXTURE_FORMAT_D0S8, 648 | 649 | BGFX_TEXTURE_FORMAT_COUNT 650 | } 651 | mixin(expandEnum!bgfx_texture_format_t); 652 | 653 | /// Uniform type enum. 654 | enum bgfx_uniform_type_t 655 | { 656 | BGFX_UNIFORM_TYPE_SAMPLER, /// Sampler. 657 | BGFX_UNIFORM_TYPE_END, /// Reserved, do not use. 658 | BGFX_UNIFORM_TYPE_VEC4, /// 4 floats vector. 659 | BGFX_UNIFORM_TYPE_MAT3, /// 3x3 matrix. 660 | BGFX_UNIFORM_TYPE_MAT4, /// 4x4 matrix. 661 | 662 | BGFX_UNIFORM_TYPE_COUNT 663 | } 664 | mixin(expandEnum!bgfx_uniform_type_t); 665 | 666 | /// Backbuffer ratio enum. 667 | enum bgfx_backbuffer_ratio_t 668 | { 669 | BGFX_BACKBUFFER_RATIO_EQUAL, /// Equal to backbuffer. 670 | BGFX_BACKBUFFER_RATIO_HALF, /// One half size of backbuffer. 671 | BGFX_BACKBUFFER_RATIO_QUARTER, /// One quarter size of backbuffer. 672 | BGFX_BACKBUFFER_RATIO_EIGHTH, /// One eighth size of backbuffer. 673 | BGFX_BACKBUFFER_RATIO_SIXTEENTH, /// One sixteenth size of backbuffer. 674 | BGFX_BACKBUFFER_RATIO_DOUBLE, /// Double size of backbuffer. 675 | 676 | BGFX_BACKBUFFER_RATIO_COUNT 677 | } 678 | mixin(expandEnum!bgfx_backbuffer_ratio_t); 679 | 680 | /// Occlusion query result. 681 | enum bgfx_occlusion_query_result_t 682 | { 683 | BGFX_OCCLUSION_QUERY_RESULT_INVISIBLE, /// Query failed test. 684 | BGFX_OCCLUSION_QUERY_RESULT_VISIBLE, /// Query passed test. 685 | BGFX_OCCLUSION_QUERY_RESULT_NORESULT, /// Query result is not available yet. 686 | 687 | BGFX_OCCLUSION_QUERY_RESULT_COUNT 688 | } 689 | mixin(expandEnum!bgfx_occlusion_query_result_t); 690 | 691 | /// Primitive topology. 692 | enum bgfx_topology_t 693 | { 694 | BGFX_TOPOLOGY_TRILIST, /// Triangle list. 695 | BGFX_TOPOLOGY_TRISTRIP, /// Triangle strip. 696 | BGFX_TOPOLOGY_LINELIST, /// Line list. 697 | BGFX_TOPOLOGY_LINESTRIP, /// Line strip. 698 | BGFX_TOPOLOGY_POINTLIST, /// Point list. 699 | 700 | BGFX_TOPOLOGY_COUNT 701 | } 702 | mixin(expandEnum!bgfx_topology_t); 703 | 704 | /// Topology conversion function. 705 | enum bgfx_topology_convert_t 706 | { 707 | BGFX_TOPOLOGY_CONVERT_TRILISTFLIPWINDING, /// Flip winding order of triangle list. 708 | BGFX_TOPOLOGY_CONVERT_TRISTRIPFLIPWINDING, /// Flip winding order of triangle strip. 709 | BGFX_TOPOLOGY_CONVERT_TRILISTTOLINELIST, /// Convert triangle list to line list. 710 | BGFX_TOPOLOGY_CONVERT_TRISTRIPTOTRILIST, /// Convert triangle strip to triangle list. 711 | BGFX_TOPOLOGY_CONVERT_LINESTRIPTOLINELIST, /// Convert line strip to line list. 712 | 713 | BGFX_TOPOLOGY_CONVERT_COUNT 714 | } 715 | mixin(expandEnum!bgfx_topology_convert_t); 716 | 717 | /// Topology sort order. 718 | enum bgfx_topology_sort_t 719 | { 720 | BGFX_TOPOLOGY_SORT_DIRECTIONFRONTTOBACKMIN, 721 | BGFX_TOPOLOGY_SORT_DIRECTIONFRONTTOBACKAVG, 722 | BGFX_TOPOLOGY_SORT_DIRECTIONFRONTTOBACKMAX, 723 | BGFX_TOPOLOGY_SORT_DIRECTIONBACKTOFRONTMIN, 724 | BGFX_TOPOLOGY_SORT_DIRECTIONBACKTOFRONTAVG, 725 | BGFX_TOPOLOGY_SORT_DIRECTIONBACKTOFRONTMAX, 726 | BGFX_TOPOLOGY_SORT_DISTANCEFRONTTOBACKMIN, 727 | BGFX_TOPOLOGY_SORT_DISTANCEFRONTTOBACKAVG, 728 | BGFX_TOPOLOGY_SORT_DISTANCEFRONTTOBACKMAX, 729 | BGFX_TOPOLOGY_SORT_DISTANCEBACKTOFRONTMIN, 730 | BGFX_TOPOLOGY_SORT_DISTANCEBACKTOFRONTAVG, 731 | BGFX_TOPOLOGY_SORT_DISTANCEBACKTOFRONTMAX, 732 | 733 | BGFX_TOPOLOGY_SORT_COUNT 734 | } 735 | mixin(expandEnum!bgfx_topology_sort_t); 736 | 737 | /// View mode sets draw call sort order. 738 | enum bgfx_view_mode_t 739 | { 740 | BGFX_VIEW_MODE_DEFAULT, /// Default sort order. 741 | BGFX_VIEW_MODE_SEQUENTIAL, /// Sort in the same order in which submit calls were called. 742 | BGFX_VIEW_MODE_DEPTHASCENDING, /// Sort draw call depth in ascending order. 743 | BGFX_VIEW_MODE_DEPTHDESCENDING, /// Sort draw call depth in descending order. 744 | 745 | BGFX_VIEW_MODE_COUNT 746 | } 747 | mixin(expandEnum!bgfx_view_mode_t); 748 | 749 | /// Render frame enum. 750 | enum bgfx_render_frame_t 751 | { 752 | BGFX_RENDER_FRAME_NOCONTEXT, /// Renderer context is not created yet. 753 | BGFX_RENDER_FRAME_RENDER, /// Renderer context is created and rendering. 754 | BGFX_RENDER_FRAME_TIMEOUT, /// Renderer context wait for main thread signal timed out without rendering. 755 | BGFX_RENDER_FRAME_EXITING, /// Renderer context is getting destroyed. 756 | 757 | BGFX_RENDER_FRAME_COUNT 758 | } 759 | mixin(expandEnum!bgfx_render_frame_t); 760 | 761 | /// GPU info. 762 | struct bgfx_caps_gpu_t 763 | { 764 | ushort vendorId; /// Vendor PCI id. See `BGFX_PCI_ID_*`. 765 | ushort deviceId; /// Device id. 766 | } 767 | 768 | /// Renderer runtime limits. 769 | struct bgfx_caps_limits_t 770 | { 771 | uint maxDrawCalls; /// Maximum number of draw calls. 772 | uint maxBlits; /// Maximum number of blit calls. 773 | uint maxTextureSize; /// Maximum texture size. 774 | uint maxTextureLayers; /// Maximum texture layers. 775 | uint maxViews; /// Maximum number of views. 776 | uint maxFrameBuffers; /// Maximum number of frame buffer handles. 777 | uint maxFBAttachments; /// Maximum number of frame buffer attachments. 778 | uint maxPrograms; /// Maximum number of program handles. 779 | uint maxShaders; /// Maximum number of shader handles. 780 | uint maxTextures; /// Maximum number of texture handles. 781 | uint maxTextureSamplers; /// Maximum number of texture samplers. 782 | uint maxComputeBindings; /// Maximum number of compute bindings. 783 | uint maxVertexLayouts; /// Maximum number of vertex format layouts. 784 | uint maxVertexStreams; /// Maximum number of vertex streams. 785 | uint maxIndexBuffers; /// Maximum number of index buffer handles. 786 | uint maxVertexBuffers; /// Maximum number of vertex buffer handles. 787 | uint maxDynamicIndexBuffers; /// Maximum number of dynamic index buffer handles. 788 | uint maxDynamicVertexBuffers; /// Maximum number of dynamic vertex buffer handles. 789 | uint maxUniforms; /// Maximum number of uniform handles. 790 | uint maxOcclusionQueries; /// Maximum number of occlusion query handles. 791 | uint maxEncoders; /// Maximum number of encoder threads. 792 | uint minResourceCbSize; /// Minimum resource command buffer size. 793 | uint transientVbSize; /// Maximum transient vertex buffer size. 794 | uint transientIbSize; /// Maximum transient index buffer size. 795 | } 796 | 797 | /// Renderer capabilities. 798 | struct bgfx_caps_t 799 | { 800 | bgfx_renderer_type_t rendererType; /// Renderer backend type. See: `bgfx::RendererType` 801 | 802 | /** 803 | * Supported functionality. 804 | * @attention See `BGFX_CAPS_*` flags at https://bkaradzic.github.io/bgfx/bgfx.html#available-caps 805 | */ 806 | ulong supported; 807 | ushort vendorId; /// Selected GPU vendor PCI id. 808 | ushort deviceId; /// Selected GPU device id. 809 | bool homogeneousDepth; /// True when NDC depth is in [-1, 1] range, otherwise its [0, 1]. 810 | bool originBottomLeft; /// True when NDC origin is at bottom left. 811 | ubyte numGPUs; /// Number of enumerated GPUs. 812 | bgfx_caps_gpu_t[4] gpu; /// Enumerated GPUs. 813 | bgfx_caps_limits_t limits; /// Renderer runtime limits. 814 | 815 | /** 816 | * Supported texture format capabilities flags: 817 | * - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - Texture format is not supported. 818 | * - `BGFX_CAPS_FORMAT_TEXTURE_2D` - Texture format is supported. 819 | * - `BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB` - Texture as sRGB format is supported. 820 | * - `BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED` - Texture format is emulated. 821 | * - `BGFX_CAPS_FORMAT_TEXTURE_3D` - Texture format is supported. 822 | * - `BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB` - Texture as sRGB format is supported. 823 | * - `BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED` - Texture format is emulated. 824 | * - `BGFX_CAPS_FORMAT_TEXTURE_CUBE` - Texture format is supported. 825 | * - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB` - Texture as sRGB format is supported. 826 | * - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED` - Texture format is emulated. 827 | * - `BGFX_CAPS_FORMAT_TEXTURE_VERTEX` - Texture format can be used from vertex shader. 828 | * - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ` - Texture format can be used as image 829 | * and read from. 830 | * - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE` - Texture format can be used as image 831 | * and written to. 832 | * - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER` - Texture format can be used as frame 833 | * buffer. 834 | * - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA` - Texture format can be used as MSAA 835 | * frame buffer. 836 | * - `BGFX_CAPS_FORMAT_TEXTURE_MSAA` - Texture can be sampled as MSAA. 837 | * - `BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN` - Texture format supports auto-generated 838 | * mips. 839 | */ 840 | ushort[bgfx_texture_format_t.BGFX_TEXTURE_FORMAT_COUNT] formats; 841 | } 842 | 843 | /// Internal data. 844 | struct bgfx_internal_data_t 845 | { 846 | const(bgfx_caps_t)* caps; /// Renderer capabilities. 847 | void* context; /// GL context, or D3D device. 848 | } 849 | 850 | /// Platform data. 851 | struct bgfx_platform_data_t 852 | { 853 | void* ndt; /// Native display type (*nix specific). 854 | 855 | /** 856 | * Native window handle. If `NULL`, bgfx will create a headless 857 | * context/device, provided the rendering API supports it. 858 | */ 859 | void* nwh; 860 | 861 | /** 862 | * GL context, D3D device, or Vulkan device. If `NULL`, bgfx 863 | * will create context/device. 864 | */ 865 | void* context; 866 | 867 | /** 868 | * GL back-buffer, or D3D render target view. If `NULL` bgfx will 869 | * create back-buffer color surface. 870 | */ 871 | void* backBuffer; 872 | 873 | /** 874 | * Backbuffer depth/stencil. If `NULL`, bgfx will create a back-buffer 875 | * depth/stencil surface. 876 | */ 877 | void* backBufferDS; 878 | } 879 | 880 | /// Backbuffer resolution and reset parameters. 881 | struct bgfx_resolution_t 882 | { 883 | bgfx_texture_format_t format; /// Backbuffer format. 884 | uint width; /// Backbuffer width. 885 | uint height; /// Backbuffer height. 886 | uint reset; /// Reset parameters. 887 | ubyte numBackBuffers; /// Number of back buffers. 888 | ubyte maxFrameLatency; /// Maximum frame latency. 889 | } 890 | 891 | /// Configurable runtime limits parameters. 892 | struct bgfx_init_limits_t 893 | { 894 | ushort maxEncoders; /// Maximum number of encoder threads. 895 | uint minResourceCbSize; /// Minimum resource command buffer size. 896 | uint transientVbSize; /// Maximum transient vertex buffer size. 897 | uint transientIbSize; /// Maximum transient index buffer size. 898 | } 899 | 900 | /// Initialization parameters used by `bgfx::init`. 901 | struct bgfx_init_t 902 | { 903 | 904 | /** 905 | * Select rendering backend. When set to RendererType::Count 906 | * a default rendering backend will be selected appropriate to the platform. 907 | * See: `bgfx::RendererType` 908 | */ 909 | bgfx_renderer_type_t type; 910 | 911 | /** 912 | * Vendor PCI ID. If set to `BGFX_PCI_ID_NONE`, discrete and integrated 913 | * GPUs will be prioritised. 914 | * - `BGFX_PCI_ID_NONE` - Autoselect adapter. 915 | * - `BGFX_PCI_ID_SOFTWARE_RASTERIZER` - Software rasterizer. 916 | * - `BGFX_PCI_ID_AMD` - AMD adapter. 917 | * - `BGFX_PCI_ID_APPLE` - Apple adapter. 918 | * - `BGFX_PCI_ID_INTEL` - Intel adapter. 919 | * - `BGFX_PCI_ID_NVIDIA` - NVIDIA adapter. 920 | * - `BGFX_PCI_ID_MICROSOFT` - Microsoft adapter. 921 | */ 922 | ushort vendorId; 923 | 924 | /** 925 | * Device ID. If set to 0 it will select first device, or device with 926 | * matching ID. 927 | */ 928 | ushort deviceId; 929 | ulong capabilities; /// Capabilities initialization mask (default: UINT64_MAX). 930 | bool debug_; /// Enable device for debugging. 931 | bool profile; /// Enable device for profiling. 932 | bgfx_platform_data_t platformData; /// Platform data. 933 | bgfx_resolution_t resolution; /// Backbuffer resolution and reset parameters. See: `bgfx::Resolution`. 934 | bgfx_init_limits_t limits; /// Configurable runtime limits parameters. 935 | 936 | /** 937 | * Provide application specific callback interface. 938 | * See: `bgfx::CallbackI` 939 | */ 940 | void* callback; 941 | 942 | /** 943 | * Custom allocator. When a custom allocator is not 944 | * specified, bgfx uses the CRT allocator. Bgfx assumes 945 | * custom allocator is thread safe. 946 | */ 947 | void* allocator; 948 | } 949 | 950 | /** 951 | * Memory must be obtained by calling `bgfx::alloc`, `bgfx::copy`, or `bgfx::makeRef`. 952 | * @attention It is illegal to create this structure on stack and pass it to any bgfx API. 953 | */ 954 | struct bgfx_memory_t 955 | { 956 | ubyte* data; /// Pointer to data. 957 | uint size; /// Data size. 958 | } 959 | 960 | /// Transient index buffer. 961 | struct bgfx_transient_index_buffer_t 962 | { 963 | ubyte* data; /// Pointer to data. 964 | uint size; /// Data size. 965 | uint startIndex; /// First index. 966 | bgfx_index_buffer_handle_t handle; /// Index buffer handle. 967 | bool isIndex16; /// Index buffer format is 16-bits if true, otherwise it is 32-bit. 968 | } 969 | 970 | /// Transient vertex buffer. 971 | struct bgfx_transient_vertex_buffer_t 972 | { 973 | ubyte* data; /// Pointer to data. 974 | uint size; /// Data size. 975 | uint startVertex; /// First vertex. 976 | ushort stride; /// Vertex stride. 977 | bgfx_vertex_buffer_handle_t handle; /// Vertex buffer handle. 978 | bgfx_vertex_layout_handle_t layoutHandle; /// Vertex layout handle. 979 | } 980 | 981 | /// Instance data buffer info. 982 | struct bgfx_instance_data_buffer_t 983 | { 984 | ubyte* data; /// Pointer to data. 985 | uint size; /// Data size. 986 | uint offset; /// Offset in vertex buffer. 987 | uint num; /// Number of instances. 988 | ushort stride; /// Vertex buffer stride. 989 | bgfx_vertex_buffer_handle_t handle; /// Vertex buffer object handle. 990 | } 991 | 992 | /// Texture info. 993 | struct bgfx_texture_info_t 994 | { 995 | bgfx_texture_format_t format; /// Texture format. 996 | uint storageSize; /// Total amount of bytes required to store texture. 997 | ushort width; /// Texture width. 998 | ushort height; /// Texture height. 999 | ushort depth; /// Texture depth. 1000 | ushort numLayers; /// Number of layers in texture array. 1001 | ubyte numMips; /// Number of MIP maps. 1002 | ubyte bitsPerPixel; /// Format bits per pixel. 1003 | bool cubeMap; /// Texture is cubemap. 1004 | } 1005 | 1006 | /// Uniform info. 1007 | struct bgfx_uniform_info_t 1008 | { 1009 | char[256] name; /// Uniform name. 1010 | bgfx_uniform_type_t type; /// Uniform type. 1011 | ushort num; /// Number of elements in array. 1012 | } 1013 | 1014 | /// Frame buffer texture attachment info. 1015 | struct bgfx_attachment_t 1016 | { 1017 | bgfx_access_t access; /// Attachment access. See `Access::Enum`. 1018 | bgfx_texture_handle_t handle; /// Render target texture handle. 1019 | ushort mip; /// Mip level. 1020 | ushort layer; /// Cubemap side or depth layer/slice to use. 1021 | ushort numLayers; /// Number of texture layer/slice(s) in array to use. 1022 | ubyte resolve; /// Resolve flags. See: `BGFX_RESOLVE_*` 1023 | } 1024 | 1025 | /// Transform data. 1026 | struct bgfx_transform_t 1027 | { 1028 | float* data; /// Pointer to first 4x4 matrix. 1029 | ushort num; /// Number of matrices. 1030 | } 1031 | 1032 | /// View stats. 1033 | struct bgfx_view_stats_t 1034 | { 1035 | char[256] name; /// View name. 1036 | bgfx_view_id_t view; /// View id. 1037 | long cpuTimeBegin; /// CPU (submit) begin time. 1038 | long cpuTimeEnd; /// CPU (submit) end time. 1039 | long gpuTimeBegin; /// GPU begin time. 1040 | long gpuTimeEnd; /// GPU end time. 1041 | uint gpuFrameNum; /// Frame which generated gpuTimeBegin, gpuTimeEnd. 1042 | } 1043 | 1044 | /// Encoder stats. 1045 | struct bgfx_encoder_stats_t 1046 | { 1047 | long cpuTimeBegin; /// Encoder thread CPU submit begin time. 1048 | long cpuTimeEnd; /// Encoder thread CPU submit end time. 1049 | } 1050 | 1051 | /** 1052 | * Renderer statistics data. 1053 | * @remarks All time values are high-resolution timestamps, while 1054 | * time frequencies define timestamps-per-second for that hardware. 1055 | */ 1056 | struct bgfx_stats_t 1057 | { 1058 | long cpuTimeFrame; /// CPU time between two `bgfx::frame` calls. 1059 | long cpuTimeBegin; /// Render thread CPU submit begin time. 1060 | long cpuTimeEnd; /// Render thread CPU submit end time. 1061 | long cpuTimerFreq; /// CPU timer frequency. Timestamps-per-second 1062 | long gpuTimeBegin; /// GPU frame begin time. 1063 | long gpuTimeEnd; /// GPU frame end time. 1064 | long gpuTimerFreq; /// GPU timer frequency. 1065 | long waitRender; /// Time spent waiting for render backend thread to finish issuing draw commands to underlying graphics API. 1066 | long waitSubmit; /// Time spent waiting for submit thread to advance to next frame. 1067 | uint numDraw; /// Number of draw calls submitted. 1068 | uint numCompute; /// Number of compute calls submitted. 1069 | uint numBlit; /// Number of blit calls submitted. 1070 | uint maxGpuLatency; /// GPU driver latency. 1071 | uint gpuFrameNum; /// Frame which generated gpuTimeBegin, gpuTimeEnd. 1072 | ushort numDynamicIndexBuffers; /// Number of used dynamic index buffers. 1073 | ushort numDynamicVertexBuffers; /// Number of used dynamic vertex buffers. 1074 | ushort numFrameBuffers; /// Number of used frame buffers. 1075 | ushort numIndexBuffers; /// Number of used index buffers. 1076 | ushort numOcclusionQueries; /// Number of used occlusion queries. 1077 | ushort numPrograms; /// Number of used programs. 1078 | ushort numShaders; /// Number of used shaders. 1079 | ushort numTextures; /// Number of used textures. 1080 | ushort numUniforms; /// Number of used uniforms. 1081 | ushort numVertexBuffers; /// Number of used vertex buffers. 1082 | ushort numVertexLayouts; /// Number of used vertex layouts. 1083 | long textureMemoryUsed; /// Estimate of texture memory used. 1084 | long rtMemoryUsed; /// Estimate of render target memory used. 1085 | int transientVbUsed; /// Amount of transient vertex buffer used. 1086 | int transientIbUsed; /// Amount of transient index buffer used. 1087 | uint[bgfx_topology_t.BGFX_TOPOLOGY_COUNT] numPrims; /// Number of primitives rendered. 1088 | long gpuMemoryMax; /// Maximum available GPU memory for application. 1089 | long gpuMemoryUsed; /// Amount of GPU memory used by the application. 1090 | ushort width; /// Backbuffer width in pixels. 1091 | ushort height; /// Backbuffer height in pixels. 1092 | ushort textWidth; /// Debug text width in characters. 1093 | ushort textHeight; /// Debug text height in characters. 1094 | ushort numViews; /// Number of view stats. 1095 | bgfx_view_stats_t* viewStats; /// Array of View stats. 1096 | ubyte numEncoders; /// Number of encoders used during frame. 1097 | bgfx_encoder_stats_t* encoderStats; /// Array of encoder stats. 1098 | } 1099 | 1100 | /// Vertex layout. 1101 | struct bgfx_vertex_layout_t 1102 | { 1103 | uint hash; /// Hash. 1104 | ushort stride; /// Stride. 1105 | ushort[bgfx_attrib_t.BGFX_ATTRIB_COUNT] offset; /// Attribute offsets. 1106 | ushort[bgfx_attrib_t.BGFX_ATTRIB_COUNT] attributes; /// Used attributes. 1107 | } 1108 | 1109 | /** 1110 | * Encoders are used for submitting draw calls from multiple threads. Only one encoder 1111 | * per thread should be used. Use `bgfx::begin()` to obtain an encoder for a thread. 1112 | */ 1113 | struct bgfx_encoder_t 1114 | { 1115 | } 1116 | 1117 | struct bgfx_dynamic_index_buffer_handle_t { ushort idx; } 1118 | 1119 | struct bgfx_dynamic_vertex_buffer_handle_t { ushort idx; } 1120 | 1121 | struct bgfx_frame_buffer_handle_t { ushort idx; } 1122 | 1123 | struct bgfx_index_buffer_handle_t { ushort idx; } 1124 | 1125 | struct bgfx_indirect_buffer_handle_t { ushort idx; } 1126 | 1127 | struct bgfx_occlusion_query_handle_t { ushort idx; } 1128 | 1129 | struct bgfx_program_handle_t { ushort idx; } 1130 | 1131 | struct bgfx_shader_handle_t { ushort idx; } 1132 | 1133 | struct bgfx_texture_handle_t { ushort idx; } 1134 | 1135 | struct bgfx_uniform_handle_t { ushort idx; } 1136 | 1137 | struct bgfx_vertex_buffer_handle_t { ushort idx; } 1138 | 1139 | struct bgfx_vertex_layout_handle_t { ushort idx; } 1140 | 1141 | --------------------------------------------------------------------------------