1 /* 2 * Copyright (c) 2014 Derelict Developers 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * * Neither the names 'Derelict', 'DerelictILUT', nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 module derelict.bgfx.types; 33 34 35 alias uint8_t = ubyte; 36 alias uint16_t = ushort; 37 alias uint32_t = uint; 38 alias uint64_t = ulong; 39 alias int8_t = byte; 40 alias int16_t = short; 41 alias int32_t = int; 42 alias int64_t = long; 43 44 // bgfxdefines.h 45 46 enum ulong BGFX_STATE_RGB_WRITE = 0x0000000000000001; 47 enum ulong BGFX_STATE_ALPHA_WRITE = 0x0000000000000002; 48 enum ulong BGFX_STATE_DEPTH_WRITE = 0x0000000000000004; 49 enum ulong BGFX_STATE_DEPTH_TEST_LESS = 0x0000000000000010; 50 enum ulong BGFX_STATE_DEPTH_TEST_LEQUAL = 0x0000000000000020; 51 enum ulong BGFX_STATE_DEPTH_TEST_EQUAL = 0x0000000000000030; 52 enum ulong BGFX_STATE_DEPTH_TEST_GEQUAL = 0x0000000000000040; 53 enum ulong BGFX_STATE_DEPTH_TEST_GREATER = 0x0000000000000050; 54 enum ulong BGFX_STATE_DEPTH_TEST_NOTEQUAL = 0x0000000000000060; 55 enum ulong BGFX_STATE_DEPTH_TEST_NEVER = 0x0000000000000070; 56 enum ulong BGFX_STATE_DEPTH_TEST_ALWAYS = 0x0000000000000080; 57 enum BGFX_STATE_DEPTH_TEST_SHIFT = 4; 58 enum ulong BGFX_STATE_DEPTH_TEST_MASK = 0x00000000000000f0; 59 enum ulong BGFX_STATE_BLEND_ZERO = 0x0000000000001000; 60 enum ulong BGFX_STATE_BLEND_ONE = 0x0000000000002000; 61 enum ulong BGFX_STATE_BLEND_SRC_COLOR = 0x0000000000003000; 62 enum ulong BGFX_STATE_BLEND_INV_SRC_COLOR = 0x0000000000004000; 63 enum ulong BGFX_STATE_BLEND_SRC_ALPHA = 0x0000000000005000; 64 enum ulong BGFX_STATE_BLEND_INV_SRC_ALPHA = 0x0000000000006000; 65 enum ulong BGFX_STATE_BLEND_DST_ALPHA = 0x0000000000007000; 66 enum ulong BGFX_STATE_BLEND_INV_DST_ALPHA = 0x0000000000008000; 67 enum ulong BGFX_STATE_BLEND_DST_COLOR = 0x0000000000009000; 68 enum ulong BGFX_STATE_BLEND_INV_DST_COLOR = 0x000000000000a000; 69 enum ulong BGFX_STATE_BLEND_SRC_ALPHA_SAT = 0x000000000000b000; 70 enum ulong BGFX_STATE_BLEND_FACTOR = 0x000000000000c000; 71 enum ulong BGFX_STATE_BLEND_INV_FACTOR = 0x000000000000d000; 72 enum BGFX_STATE_BLEND_SHIFT = 12; 73 enum ulong BGFX_STATE_BLEND_MASK = 0x000000000ffff000; 74 75 enum ulong BGFX_STATE_BLEND_EQUATION_SUB = 0x0000000010000000; 76 enum ulong BGFX_STATE_BLEND_EQUATION_REVSUB = 0x0000000020000000; 77 enum ulong BGFX_STATE_BLEND_EQUATION_MIN = 0x0000000030000000; 78 enum ulong BGFX_STATE_BLEND_EQUATION_MAX = 0x0000000040000000; 79 enum BGFX_STATE_BLEND_EQUATION_SHIFT = 28; 80 enum ulong BGFX_STATE_BLEND_EQUATION_MASK = 0x00000003f0000000; 81 82 enum ulong BGFX_STATE_BLEND_INDEPENDENT = 0x0000000400000000; 83 84 enum ulong BGFX_STATE_CULL_CW = 0x0000001000000000; 85 enum ulong BGFX_STATE_CULL_CCW = 0x0000002000000000; 86 enum BGFX_STATE_CULL_SHIFT = 36; 87 enum ulong BGFX_STATE_CULL_MASK = 0x0000003000000000; 88 89 enum BGFX_STATE_ALPHA_REF_SHIFT = 40; 90 enum ulong BGFX_STATE_ALPHA_REF_MASK = 0x0000ff0000000000; 91 92 enum ulong BGFX_STATE_PT_TRISTRIP = 0x0001000000000000; 93 enum ulong BGFX_STATE_PT_LINES = 0x0002000000000000; 94 enum ulong BGFX_STATE_PT_POINTS = 0x0003000000000000; 95 enum BGFX_STATE_PT_SHIFT = 48; 96 enum ulong BGFX_STATE_PT_MASK = 0x0003000000000000; 97 98 enum BGFX_STATE_POINT_SIZE_SHIFT = 52; 99 enum ulong BGFX_STATE_POINT_SIZE_MASK = 0x0ff0000000000000; 100 101 enum ulong BGFX_STATE_MSAA = 0x1000000000000000; 102 103 enum ulong BGFX_STATE_RESERVED_MASK = 0xe000000000000000; 104 105 enum ulong BGFX_STATE_NONE = 0x0000000000000000; 106 enum ulong BGFX_STATE_MASK = 0xffffffffffffffff; 107 enum ulong BGFX_STATE_DEFAULT = 0 108 | BGFX_STATE_RGB_WRITE 109 | BGFX_STATE_ALPHA_WRITE 110 | BGFX_STATE_DEPTH_TEST_LESS 111 | BGFX_STATE_DEPTH_WRITE 112 | BGFX_STATE_CULL_CW 113 | BGFX_STATE_MSAA; 114 115 ulong BGFX_STATE_ALPHA_REF(ulong _ref) pure nothrow 116 { 117 return (_ref << BGFX_STATE_ALPHA_REF_SHIFT) & BGFX_STATE_ALPHA_REF_MASK; 118 } 119 120 ulong BGFX_STATE_POINT_SIZE(ulong _size) pure nothrow 121 { 122 return (_size << BGFX_STATE_POINT_SIZE_SHIFT) & BGFX_STATE_POINT_SIZE_MASK; 123 } 124 125 ulong BGFX_STATE_BLEND_FUNC_SEPARATE(ulong _srcRGB, ulong _dstRGB, ulong _srcA, ulong _dstA) pure nothrow 126 { 127 return _srcRGB | (_dstRGB << 4) | (_srcA << 8) | (_dstA << 12); 128 } 129 130 ulong BGFX_STATE_BLEND_EQUATION_SEPARATE(ulong _rgb, ulong _a) pure nothrow 131 { 132 return _rgb | (_a << 3); 133 } 134 135 ulong BGFX_STATE_BLEND_FUNC(ulong _src, ulong _dst) pure nothrow 136 { 137 return BGFX_STATE_BLEND_FUNC_SEPARATE(_src, _dst, _src, _dst); 138 } 139 140 ulong BGFX_STATE_BLEND_EQUATION(ulong _equation) pure nothrow 141 { 142 return BGFX_STATE_BLEND_EQUATION_SEPARATE(_equation, _equation); 143 } 144 145 146 enum ulong BGFX_STATE_BLEND_ADD = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE ); 147 enum ulong BGFX_STATE_BLEND_ALPHA = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA); 148 enum ulong BGFX_STATE_BLEND_DARKEN = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE ) | BGFX_STATE_BLEND_EQUATION(BGFX_STATE_BLEND_EQUATION_MIN); 149 enum ulong BGFX_STATE_BLEND_LIGHTEN = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE ) | BGFX_STATE_BLEND_EQUATION(BGFX_STATE_BLEND_EQUATION_MAX); 150 enum ulong BGFX_STATE_BLEND_MULTIPLY = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_DST_COLOR, BGFX_STATE_BLEND_ZERO ); 151 enum ulong BGFX_STATE_BLEND_NORMAL = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_INV_SRC_ALPHA); 152 enum ulong BGFX_STATE_BLEND_SCREEN = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_INV_SRC_COLOR); 153 enum ulong BGFX_STATE_BLEND_LINEAR_BURN = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_DST_COLOR, BGFX_STATE_BLEND_INV_DST_COLOR) | BGFX_STATE_BLEND_EQUATION(BGFX_STATE_BLEND_EQUATION_SUB); 154 155 156 uint BGFX_STATE_BLEND_FUNC_RT_x(uint _src, uint _dst) pure nothrow 157 { 158 return (_src >> BGFX_STATE_BLEND_SHIFT) | ((_dst >> BGFX_STATE_BLEND_SHIFT) << 4); 159 } 160 161 uint BGFX_STATE_BLEND_FUNC_RT_xE(uint _src, uint _dst, uint _equation) pure nothrow 162 { 163 return BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst) | ((_equation >> BGFX_STATE_BLEND_EQUATION_SHIFT) << 8); 164 } 165 166 uint BGFX_STATE_BLEND_FUNC_RT_1(uint _src, uint _dst) pure nothrow 167 { 168 return BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst) << 0; 169 } 170 171 uint BGFX_STATE_BLEND_FUNC_RT_2(uint _src, uint _dst) pure nothrow 172 { 173 return BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst) << 11; 174 } 175 176 uint BGFX_STATE_BLEND_FUNC_RT_3(uint _src, uint _dst) pure nothrow 177 { 178 return BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst) << 22; 179 } 180 181 uint BGFX_STATE_BLEND_FUNC_RT_1E(uint _src, uint _dst, uint _equation) pure nothrow 182 { 183 return BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation) << 0; 184 } 185 186 uint BGFX_STATE_BLEND_FUNC_RT_2E(uint _src, uint _dst, uint _equation) pure nothrow 187 { 188 return BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation) << 11; 189 } 190 191 uint BGFX_STATE_BLEND_FUNC_RT_3E(uint _src, uint _dst, uint _equation) pure nothrow 192 { 193 return BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation) << 22; 194 } 195 196 /// 197 enum BGFX_STENCIL_FUNC_REF_SHIFT = 0; 198 enum uint BGFX_STENCIL_FUNC_REF_MASK = 0x000000ff; 199 enum BGFX_STENCIL_FUNC_RMASK_SHIFT = 8; 200 enum uint BGFX_STENCIL_FUNC_RMASK_MASK = 0x0000ff00; 201 202 enum uint BGFX_STENCIL_TEST_LESS = 0x00010000; 203 enum uint BGFX_STENCIL_TEST_LEQUAL = 0x00020000; 204 enum uint BGFX_STENCIL_TEST_EQUAL = 0x00030000; 205 enum uint BGFX_STENCIL_TEST_GEQUAL = 0x00040000; 206 enum uint BGFX_STENCIL_TEST_GREATER = 0x00050000; 207 enum uint BGFX_STENCIL_TEST_NOTEQUAL = 0x00060000; 208 enum uint BGFX_STENCIL_TEST_NEVER = 0x00070000; 209 enum uint BGFX_STENCIL_TEST_ALWAYS = 0x00080000; 210 enum BGFX_STENCIL_TEST_SHIFT = 16; 211 enum uint BGFX_STENCIL_TEST_MASK = 0x000f0000; 212 213 enum uint BGFX_STENCIL_OP_FAIL_S_ZERO = 0x00000000; 214 enum uint BGFX_STENCIL_OP_FAIL_S_KEEP = 0x00100000; 215 enum uint BGFX_STENCIL_OP_FAIL_S_REPLACE = 0x00200000; 216 enum uint BGFX_STENCIL_OP_FAIL_S_INCR = 0x00300000; 217 enum uint BGFX_STENCIL_OP_FAIL_S_INCRSAT = 0x00400000; 218 enum uint BGFX_STENCIL_OP_FAIL_S_DECR = 0x00500000; 219 enum uint BGFX_STENCIL_OP_FAIL_S_DECRSAT = 0x00600000; 220 enum uint BGFX_STENCIL_OP_FAIL_S_INVERT = 0x00700000; 221 enum BGFX_STENCIL_OP_FAIL_S_SHIFT = 20; 222 enum uint BGFX_STENCIL_OP_FAIL_S_MASK = 0x00f00000; 223 224 enum uint BGFX_STENCIL_OP_FAIL_Z_ZERO = 0x00000000; 225 enum uint BGFX_STENCIL_OP_FAIL_Z_KEEP = 0x01000000; 226 enum uint BGFX_STENCIL_OP_FAIL_Z_REPLACE = 0x02000000; 227 enum uint BGFX_STENCIL_OP_FAIL_Z_INCR = 0x03000000; 228 enum uint BGFX_STENCIL_OP_FAIL_Z_INCRSAT = 0x04000000; 229 enum uint BGFX_STENCIL_OP_FAIL_Z_DECR = 0x05000000; 230 enum uint BGFX_STENCIL_OP_FAIL_Z_DECRSAT = 0x06000000; 231 enum uint BGFX_STENCIL_OP_FAIL_Z_INVERT = 0x07000000; 232 enum BGFX_STENCIL_OP_FAIL_Z_SHIFT = 24; 233 enum uint BGFX_STENCIL_OP_FAIL_Z_MASK = 0x0f000000; 234 235 enum uint BGFX_STENCIL_OP_PASS_Z_ZERO = 0x00000000; 236 enum uint BGFX_STENCIL_OP_PASS_Z_KEEP = 0x10000000; 237 enum uint BGFX_STENCIL_OP_PASS_Z_REPLACE = 0x20000000; 238 enum uint BGFX_STENCIL_OP_PASS_Z_INCR = 0x30000000; 239 enum uint BGFX_STENCIL_OP_PASS_Z_INCRSAT = 0x40000000; 240 enum uint BGFX_STENCIL_OP_PASS_Z_DECR = 0x50000000; 241 enum uint BGFX_STENCIL_OP_PASS_Z_DECRSAT = 0x60000000; 242 enum uint BGFX_STENCIL_OP_PASS_Z_INVERT = 0x70000000; 243 enum BGFX_STENCIL_OP_PASS_Z_SHIFT = 28; 244 enum uint BGFX_STENCIL_OP_PASS_Z_MASK = 0xf0000000; 245 246 enum uint BGFX_STENCIL_NONE = 0x00000000; 247 enum uint BGFX_STENCIL_MASK = 0xffffffff; 248 enum uint BGFX_STENCIL_DEFAULT = 0x00000000; 249 250 uint BGFX_STENCIL_FUNC_REF(uint _ref) pure nothrow 251 { 252 return (_ref << BGFX_STENCIL_FUNC_REF_SHIFT) & BGFX_STENCIL_FUNC_REF_MASK; 253 } 254 255 uint BGFX_STENCIL_FUNC_RMASK(uint _mask) pure nothrow 256 { 257 return (_mask << BGFX_STENCIL_FUNC_RMASK_SHIFT) & BGFX_STENCIL_FUNC_RMASK_MASK; 258 } 259 260 261 enum ubyte BGFX_CLEAR_NONE = 0x00; 262 enum ubyte BGFX_CLEAR_COLOR_BIT = 0x01; 263 enum ubyte BGFX_CLEAR_DEPTH_BIT = 0x02; 264 enum ubyte BGFX_CLEAR_STENCIL_BIT = 0x04; 265 266 enum uint BGFX_DEBUG_NONE = 0x00000000; 267 enum uint BGFX_DEBUG_WIREFRAME = 0x00000001; 268 enum uint BGFX_DEBUG_IFH = 0x00000002; 269 enum uint BGFX_DEBUG_STATS = 0x00000004; 270 enum uint BGFX_DEBUG_TEXT = 0x00000008; 271 272 enum uint BGFX_TEXTURE_NONE = 0x00000000; 273 enum uint BGFX_TEXTURE_U_MIRROR = 0x00000001; 274 enum uint BGFX_TEXTURE_U_CLAMP = 0x00000002; 275 enum BGFX_TEXTURE_U_SHIFT = 0; 276 enum uint BGFX_TEXTURE_U_MASK = 0x00000003; 277 enum uint BGFX_TEXTURE_V_MIRROR = 0x00000004; 278 enum uint BGFX_TEXTURE_V_CLAMP = 0x00000008; 279 enum BGFX_TEXTURE_V_SHIFT = 2; 280 enum uint BGFX_TEXTURE_V_MASK = 0x0000000c; 281 enum uint BGFX_TEXTURE_W_MIRROR = 0x00000010; 282 enum uint BGFX_TEXTURE_W_CLAMP = 0x00000020; 283 enum BGFX_TEXTURE_W_SHIFT = 4; 284 enum uint BGFX_TEXTURE_W_MASK = 0x00000030; 285 enum uint BGFX_TEXTURE_MIN_POINT = 0x00000040; 286 enum uint BGFX_TEXTURE_MIN_ANISOTROPIC = 0x00000080; 287 enum BGFX_TEXTURE_MIN_SHIFT = 6; 288 enum uint BGFX_TEXTURE_MIN_MASK = 0x000000c0; 289 enum uint BGFX_TEXTURE_MAG_POINT = 0x00000100; 290 enum uint BGFX_TEXTURE_MAG_ANISOTROPIC = 0x00000200; 291 enum BGFX_TEXTURE_MAG_SHIFT = 8; 292 enum uint BGFX_TEXTURE_MAG_MASK = 0x00000300; 293 enum uint BGFX_TEXTURE_MIP_POINT = 0x00000400; 294 enum BGFX_TEXTURE_MIP_SHIFT = 10; 295 enum uint BGFX_TEXTURE_MIP_MASK = 0x00000400; 296 enum uint BGFX_TEXTURE_RT = 0x00001000; 297 enum uint BGFX_TEXTURE_RT_MSAA_X2 = 0x00002000; 298 enum uint BGFX_TEXTURE_RT_MSAA_X4 = 0x00003000; 299 enum uint BGFX_TEXTURE_RT_MSAA_X8 = 0x00004000; 300 enum uint BGFX_TEXTURE_RT_MSAA_X16 = 0x00005000; 301 enum BGFX_TEXTURE_RT_MSAA_SHIFT = 12; 302 enum uint BGFX_TEXTURE_RT_MSAA_MASK = 0x00007000; 303 enum uint BGFX_TEXTURE_RT_BUFFER_ONLY = 0x00008000; 304 enum uint BGFX_TEXTURE_RT_MASK = 0x0000f000; 305 enum uint BGFX_TEXTURE_COMPARE_LESS = 0x00010000; 306 enum uint BGFX_TEXTURE_COMPARE_LEQUAL = 0x00020000; 307 enum uint BGFX_TEXTURE_COMPARE_EQUAL = 0x00030000; 308 enum uint BGFX_TEXTURE_COMPARE_GEQUAL = 0x00040000; 309 enum uint BGFX_TEXTURE_COMPARE_GREATER = 0x00050000; 310 enum uint BGFX_TEXTURE_COMPARE_NOTEQUAL = 0x00060000; 311 enum uint BGFX_TEXTURE_COMPARE_NEVER = 0x00070000; 312 enum uint BGFX_TEXTURE_COMPARE_ALWAYS = 0x00080000; 313 enum BGFX_TEXTURE_COMPARE_SHIFT = 16; 314 enum uint BGFX_TEXTURE_COMPARE_MASK = 0x000f0000; 315 enum BGFX_TEXTURE_RESERVED_SHIFT = 24; 316 enum uint BGFX_TEXTURE_RESERVED_MASK = 0xff000000; 317 318 enum uint BGFX_TEXTURE_SAMPLER_BITS_MASK = 0 319 | BGFX_TEXTURE_U_MASK 320 | BGFX_TEXTURE_V_MASK 321 | BGFX_TEXTURE_W_MASK 322 | BGFX_TEXTURE_MIN_MASK 323 | BGFX_TEXTURE_MAG_MASK 324 | BGFX_TEXTURE_MIP_MASK 325 | BGFX_TEXTURE_COMPARE_MASK; 326 327 enum uint BGFX_RESET_NONE = 0x00000000; 328 enum uint BGFX_RESET_FULLSCREEN = 0x00000001; 329 enum BGFX_RESET_FULLSCREEN_SHIFT = 0; 330 enum uint BGFX_RESET_FULLSCREEN_MASK = 0x00000001; 331 enum uint BGFX_RESET_MSAA_X2 = 0x00000010; 332 enum uint BGFX_RESET_MSAA_X4 = 0x00000020; 333 enum uint BGFX_RESET_MSAA_X8 = 0x00000030; 334 enum uint BGFX_RESET_MSAA_X16 = 0x00000040; 335 enum BGFX_RESET_MSAA_SHIFT = 4; 336 enum uint BGFX_RESET_MSAA_MASK = 0x00000070; 337 enum uint BGFX_RESET_VSYNC = 0x00000080; 338 enum uint BGFX_RESET_CAPTURE = 0x00000100; 339 340 enum ulong BGFX_CAPS_TEXTURE_FORMAT_BC1 = 0x0000000000000001; 341 enum ulong BGFX_CAPS_TEXTURE_FORMAT_BC2 = 0x0000000000000002; 342 enum ulong BGFX_CAPS_TEXTURE_FORMAT_BC3 = 0x0000000000000004; 343 enum ulong BGFX_CAPS_TEXTURE_FORMAT_BC4 = 0x0000000000000008; 344 enum ulong BGFX_CAPS_TEXTURE_FORMAT_BC5 = 0x0000000000000010; 345 enum ulong BGFX_CAPS_TEXTURE_FORMAT_ETC1 = 0x0000000000000020; 346 enum ulong BGFX_CAPS_TEXTURE_FORMAT_ETC2 = 0x0000000000000040; 347 enum ulong BGFX_CAPS_TEXTURE_FORMAT_ETC2A = 0x0000000000000080; 348 enum ulong BGFX_CAPS_TEXTURE_FORMAT_ETC2A1 = 0x0000000000000100; 349 enum ulong BGFX_CAPS_TEXTURE_FORMAT_PTC12 = 0x0000000000000200; 350 enum ulong BGFX_CAPS_TEXTURE_FORMAT_PTC14 = 0x0000000000000400; 351 enum ulong BGFX_CAPS_TEXTURE_FORMAT_PTC14A = 0x0000000000000800; 352 enum ulong BGFX_CAPS_TEXTURE_FORMAT_PTC12A = 0x0000000000001000; 353 enum ulong BGFX_CAPS_TEXTURE_FORMAT_PTC22 = 0x0000000000002000; 354 enum ulong BGFX_CAPS_TEXTURE_FORMAT_PTC24 = 0x0000000000004000; 355 enum ulong BGFX_CAPS_TEXTURE_FORMAT_D16 = 0x0000000000008000; 356 enum ulong BGFX_CAPS_TEXTURE_FORMAT_D24 = 0x0000000000010000; 357 enum ulong BGFX_CAPS_TEXTURE_FORMAT_D24S8 = 0x0000000000020000; 358 enum ulong BGFX_CAPS_TEXTURE_FORMAT_D32 = 0x0000000000040000; 359 enum ulong BGFX_CAPS_TEXTURE_FORMAT_D16F = 0x0000000000080000; 360 enum ulong BGFX_CAPS_TEXTURE_FORMAT_D24F = 0x0000000000100000; 361 enum ulong BGFX_CAPS_TEXTURE_FORMAT_D32F = 0x0000000000200000; 362 enum ulong BGFX_CAPS_TEXTURE_FORMAT_D0S8 = 0x0000000000400000; 363 enum ulong BGFX_CAPS_TEXTURE_COMPARE_LEQUAL = 0x0000000001000000; 364 enum ulong BGFX_CAPS_TEXTURE_COMPARE_ALL = 0x0000000003000000; 365 enum ulong BGFX_CAPS_TEXTURE_3D = 0x0000000004000000; 366 enum ulong BGFX_CAPS_VERTEX_ATTRIB_HALF = 0x0000000008000000; 367 enum ulong BGFX_CAPS_INSTANCING = 0x0000000010000000; 368 enum ulong BGFX_CAPS_RENDERER_MULTITHREADED = 0x0000000020000000; 369 enum ulong BGFX_CAPS_FRAGMENT_DEPTH = 0x0000000040000000; 370 enum ulong BGFX_CAPS_BLEND_INDEPENDENT = 0x0000000080000000; 371 372 enum ulong BGFX_CAPS_TEXTURE_DEPTH_MASK = 0 373 | BGFX_CAPS_TEXTURE_FORMAT_D16 374 | BGFX_CAPS_TEXTURE_FORMAT_D24 375 | BGFX_CAPS_TEXTURE_FORMAT_D24S8 376 | BGFX_CAPS_TEXTURE_FORMAT_D32 377 | BGFX_CAPS_TEXTURE_FORMAT_D16F 378 | BGFX_CAPS_TEXTURE_FORMAT_D24F 379 | BGFX_CAPS_TEXTURE_FORMAT_D32F 380 | BGFX_CAPS_TEXTURE_FORMAT_D0S8; 381 382 // bgfx.c99.h 383 384 alias bgfx_renderer_type_t = int; 385 enum : bgfx_renderer_type_t 386 { 387 BGFX_RENDERER_TYPE_NULL, 388 BGFX_RENDERER_TYPE_DIRECT3D9, 389 BGFX_RENDERER_TYPE_DIRECT3D11, 390 BGFX_RENDERER_TYPE_OPENGLES, 391 BGFX_RENDERER_TYPE_OPENGL, 392 393 BGFX_RENDERER_TYPE_COUNT 394 395 } 396 397 alias bgfx_attrib_t = int; 398 enum : bgfx_attrib_t 399 { 400 BGFX_ATTRIB_POSITION, 401 BGFX_ATTRIB_NORMAL, 402 BGFX_ATTRIB_TANGENT, 403 BGFX_ATTRIB_COLOR0, 404 BGFX_ATTRIB_COLOR1, 405 BGFX_ATTRIB_INDICES, 406 BGFX_ATTRIB_WEIGHT, 407 BGFX_ATTRIB_TEXCOORD0, 408 BGFX_ATTRIB_TEXCOORD1, 409 BGFX_ATTRIB_TEXCOORD2, 410 BGFX_ATTRIB_TEXCOORD3, 411 BGFX_ATTRIB_TEXCOORD4, 412 BGFX_ATTRIB_TEXCOORD5, 413 BGFX_ATTRIB_TEXCOORD6, 414 BGFX_ATTRIB_TEXCOORD7, 415 416 BGFX_ATTRIB_COUNT 417 418 } 419 420 alias bgfx_attrib_type_t = int; 421 enum : bgfx_attrib_type_t 422 { 423 BGFX_ATTRIB_TYPE_UINT8, 424 BGFX_ATTRIB_TYPE_INT16, 425 BGFX_ATTRIB_TYPE_HALF, 426 BGFX_ATTRIB_TYPE_FLOAT, 427 428 BGFX_ATTRIB_TYPE_COUNT 429 430 } 431 432 alias bgfx_texture_format_t = int; 433 enum : bgfx_texture_format_t 434 { 435 BGFX_TEXTURE_FORMAT_BC1, 436 BGFX_TEXTURE_FORMAT_BC2, 437 BGFX_TEXTURE_FORMAT_BC3, 438 BGFX_TEXTURE_FORMAT_BC4, 439 BGFX_TEXTURE_FORMAT_BC5, 440 BGFX_TEXTURE_FORMAT_ETC1, 441 BGFX_TEXTURE_FORMAT_ETC2, 442 BGFX_TEXTURE_FORMAT_ETC2A, 443 BGFX_TEXTURE_FORMAT_ETC2A1, 444 BGFX_TEXTURE_FORMAT_PTC12, 445 BGFX_TEXTURE_FORMAT_PTC14, 446 BGFX_TEXTURE_FORMAT_PTC12A, 447 BGFX_TEXTURE_FORMAT_PTC14A, 448 BGFX_TEXTURE_FORMAT_PTC22, 449 BGFX_TEXTURE_FORMAT_PTC24, 450 451 BGFX_TEXTURE_FORMAT_UNKNOWN, 452 453 BGFX_TEXTURE_FORMAT_R8, 454 BGFX_TEXTURE_FORMAT_R16, 455 BGFX_TEXTURE_FORMAT_R16F, 456 BGFX_TEXTURE_FORMAT_BGRA8, 457 BGFX_TEXTURE_FORMAT_RGBA16, 458 BGFX_TEXTURE_FORMAT_RGBA16F, 459 BGFX_TEXTURE_FORMAT_R5G6B5, 460 BGFX_TEXTURE_FORMAT_RGBA4, 461 BGFX_TEXTURE_FORMAT_RGB5A1, 462 BGFX_TEXTURE_FORMAT_RGB10A2, 463 464 BGFX_TEXTURE_FORMAT_UNKNOWN_DEPTH, 465 466 BGFX_TEXTURE_FORMAT_D16, 467 BGFX_TEXTURE_FORMAT_D24, 468 BGFX_TEXTURE_FORMAT_D24S8, 469 BGFX_TEXTURE_FORMAT_D32, 470 BGFX_TEXTURE_FORMAT_D16F, 471 BGFX_TEXTURE_FORMAT_D24F, 472 BGFX_TEXTURE_FORMAT_D32F, 473 BGFX_TEXTURE_FORMAT_D0S8, 474 475 BGFX_TEXTURE_FORMAT_COUNT 476 477 } 478 479 alias bgfx_uniform_type_t = int; 480 enum : bgfx_uniform_type_t 481 { 482 BGFX_UNIFORM_TYPE_UNIFORM1I, 483 BGFX_UNIFORM_TYPE_UNIFORM1F, 484 BGFX_UNIFORM_TYPE_END, 485 486 BGFX_UNIFORM_TYPE_UNIFORM1IV, 487 BGFX_UNIFORM_TYPE_UNIFORM1FV, 488 BGFX_UNIFORM_TYPE_UNIFORM2FV, 489 BGFX_UNIFORM_TYPE_UNIFORM3FV, 490 BGFX_UNIFORM_TYPE_UNIFORM4FV, 491 BGFX_UNIFORM_TYPE_UNIFORM3X3FV, 492 BGFX_UNIFORM_TYPE_UNIFORM4X4FV, 493 494 BGFX_UNIFORM_TYPE_COUNT 495 496 } 497 498 struct bgfx_dynamic_index_buffer_handle_t 499 { 500 ushort idx; 501 } 502 503 struct bgfx_dynamic_vertex_buffer_handle_t 504 { 505 ushort idx; 506 } 507 508 struct bgfx_frame_buffer_handle_t 509 { 510 ushort idx; 511 } 512 513 struct bgfx_index_buffer_handle_t 514 { 515 ushort idx; 516 } 517 518 struct bgfx_program_handle_t 519 { 520 ushort idx; 521 } 522 523 struct bgfx_shader_handle_t 524 { 525 ushort idx; 526 } 527 528 struct bgfx_texture_handle_t 529 { 530 ushort idx; 531 } 532 533 struct bgfx_uniform_handle_t 534 { 535 ushort idx; 536 } 537 538 struct bgfx_vertex_buffer_handle_t 539 { 540 ushort idx; 541 } 542 543 struct bgfx_vertex_decl_handle_t 544 { 545 ushort idx; 546 } 547 548 struct bgfx_memory_t 549 { 550 uint8_t* data; 551 uint32_t size; 552 } 553 554 /** 555 * Vertex declaration. 556 */ 557 struct bgfx_vertex_decl_t 558 { 559 uint32_t hash; 560 uint16_t stride; 561 uint16_t offset[BGFX_ATTRIB_COUNT]; 562 uint8_t attributes[BGFX_ATTRIB_COUNT]; 563 } 564 565 /** 566 */ 567 struct bgfx_transient_index_buffer_t 568 { 569 uint8_t* data; 570 uint32_t size; 571 bgfx_index_buffer_handle_t handle; 572 uint32_t startIndex; 573 } 574 575 /** 576 */ 577 struct bgfx_transient_vertex_buffer_t 578 { 579 uint8_t* data; 580 uint32_t size; 581 uint32_t startVertex; 582 uint16_t stride; 583 bgfx_vertex_buffer_handle_t handle; 584 bgfx_vertex_decl_handle_t decl; 585 586 } 587 588 /** 589 */ 590 struct bgfx_instance_data_buffer_t 591 { 592 uint8_t* data; 593 uint32_t size; 594 uint32_t offset; 595 uint16_t stride; 596 uint16_t num; 597 bgfx_vertex_buffer_handle_t handle; 598 599 } 600 601 /** 602 */ 603 struct bgfx_texture_info_t 604 { 605 bgfx_texture_format_t format; 606 uint32_t storageSize; 607 uint16_t width; 608 uint16_t height; 609 uint16_t depth; 610 uint8_t numMips; 611 uint8_t bitsPerPixel; 612 613 } 614 615 /** 616 * Renderer capabilities. 617 */ 618 struct bgfx_caps_t 619 { 620 /** 621 * Renderer backend type. 622 */ 623 bgfx_renderer_type_t rendererType; 624 625 /** 626 * Supported functionality, it includes emulated functionality. 627 * Checking supported and not emulated will give functionality 628 * natively supported by renderer. 629 */ 630 uint64_t supported; 631 632 /** 633 * Emulated functionality. For example some texture compression 634 * modes are not natively supported by all renderers. The library 635 * internally decompresses texture into supported format. 636 */ 637 uint64_t emulated; 638 639 uint16_t maxTextureSize; /* < Maximum texture size. */ 640 uint16_t maxDrawCalls; /* < Maximum draw calls. */ 641 uint8_t maxFBAttachments; /* < Maximum frame buffer attachments. */ 642 643 } 644 645 /** 646 */ 647 648 alias bgfx_fatal_t = int; 649 enum : bgfx_fatal_t 650 { 651 BGFX_FATAL_DEBUG_CHECK, 652 BGFX_FATAL_MINIMUM_REQUIRED_SPECS, 653 BGFX_FATAL_INVALID_SHADER, 654 BGFX_FATAL_UNABLE_TO_INITIALIZE, 655 BGFX_FATAL_UNABLE_TO_CREATE_TEXTURE, 656 } 657 658 //TODO: use namespace when DMD 2.066 is released 659 extern(C++)/*, bgfx)*/ interface CallbackI 660 { 661 void fatal(bgfx_fatal_t _code, const(char)* _str); 662 uint32_t cacheReadSize(uint64_t _id); 663 bool cacheRead(uint64_t _id, void* _data, uint32_t _size); 664 void cacheWrite(uint64_t _id, const(void)* _data, uint32_t _size); 665 void screenShot(const(char)* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const(void)* _data, uint32_t _size, bool _yflip); 666 void captureBegin(uint32_t _width, uint32_t _height, uint32_t _pitch, bgfx_texture_format_t _format, bool _yflip); 667 void captureEnd(); 668 void captureFrame(const(void)* _data, uint32_t _size); 669 } 670 671 //TODO: use namespace when DMD 2.066 is released 672 extern(C++ /*, bx */) interface ReallocatorI 673 { 674 void* alloc(size_t _size, size_t _align, const(char)* _file, uint32_t _line); 675 void free(void* _ptr, size_t _align, const(char)* _file, uint32_t _line); 676 void* realloc(void* _ptr, size_t _size, size_t _align, const(char)* _file, uint32_t _line); 677 } 678 679 // bgfxplatform.c99.h 680 681 alias bgfx_render_frame_t = int; 682 enum : bgfx_render_frame_t 683 { 684 BGFX_RENDER_FRAME_NO_CONTEXT, 685 BGFX_RENDER_FRAME_RENDER, 686 BGFX_RENDER_FRAME_EXITING, 687 688 BGFX_RENDER_FRAME_COUNT 689 } 690