diff options
Diffstat (limited to '3rdparty/bgfx/scripts')
-rw-r--r-- | 3rdparty/bgfx/scripts/bgfx.idl | 292 | ||||
-rw-r--r-- | 3rdparty/bgfx/scripts/bindings-cs.lua | 1 | ||||
-rw-r--r-- | 3rdparty/bgfx/scripts/bindings-d.lua | 414 | ||||
-rw-r--r-- | 3rdparty/bgfx/scripts/genie.lua | 4 | ||||
-rw-r--r-- | 3rdparty/bgfx/scripts/temp.bgfx.h | 9 | ||||
-rw-r--r-- | 3rdparty/bgfx/scripts/temp.bgfx.idl.inl | 6 | ||||
-rw-r--r-- | 3rdparty/bgfx/scripts/temp.defines.h | 9 |
7 files changed, 589 insertions, 146 deletions
diff --git a/3rdparty/bgfx/scripts/bgfx.idl b/3rdparty/bgfx/scripts/bgfx.idl index 23a1ecee285..e02d257de65 100644 --- a/3rdparty/bgfx/scripts/bgfx.idl +++ b/3rdparty/bgfx/scripts/bgfx.idl @@ -1,7 +1,7 @@ -- vim: syntax=lua -- bgfx interface -version(100) +version(102) typedef "bool" typedef "char" @@ -79,18 +79,18 @@ flag.StateBlendEquation { bits = 64, shift = 28, range = 6, base = 0, desc = "Bl --- Cull state. When `BGFX_STATE_CULL_*` is not specified culling will be disabled. flag.StateCull { bits = 64, shift = 36, range = 2, base = 1, desc = "Culling mode" } - .Cw --- Cull clockwise triangles. - .Ccw --- Cull counter-clockwise triangles. + .Cw --- Cull clockwise triangles. + .Ccw --- Cull counter-clockwise triangles. () --- Alpha reference value. flag.StateAlphaRef { bits = 64, shift = 40, range = 8, desc = "Alpha reference", "helper" } flag.StatePt { bits = 64, shift = 48, range = 3, base = 1, desc = "Primitive type" } - .Tristrip --- Tristrip. - .Lines --- Lines. - .Linestrip --- Line strip. - .Points --- Points. + .Tristrip --- Tristrip. + .Lines --- Lines. + .Linestrip --- Line strip. + .Points --- Points. () --- Point size value. @@ -99,16 +99,16 @@ flag.StatePointSize { bits = 64, shift = 52, range = 4, desc = "Point size", "he --- Enable MSAA write when writing into MSAA frame buffer. --- This flag is ignored when not writing into MSAA frame buffer. flag.State { bits = 64 , range = 64 , desc = "State" } - .Msaa (57) --- Enable MSAA rasterization. - .Lineaa (58) --- Enable line AA rasterization. - .ConservativeRaster (59) --- Enable conservative rasterization. - .None (0) --- No state. - .BlendIndependent(35) --- Enable blend independent. - .BlendAlphaToCoverage (36) --- Enable alpha to coverage. + .Msaa (57) --- Enable MSAA rasterization. + .Lineaa (58) --- Enable line AA rasterization. + .ConservativeRaster (59) --- Enable conservative rasterization. + .None (0) --- No state. + .FrontCcw(40) --- Front counter-clockwise (default is clockwise). + .BlendIndependent(35) --- Enable blend independent. + .BlendAlphaToCoverage (36) --- Enable alpha to coverage. .Default { "WriteRgb", "WriteA", "WriteZ", "DepthTestLess", "CullCw", "Msaa" } - --- Default state is write to RGB, alpha, and depth with depth test less enabled, with clockwise - --- culling and MSAA (when writing into MSAA frame buffer, otherwise this flag is ignored). - + --- Default state is write to RGB, alpha, and depth with depth test less enabled, with clockwise + --- culling and MSAA (when writing into MSAA frame buffer, otherwise this flag is ignored). --- Do not use! flag.StateReserved { bits = 64, shift = 61, range = 3 } @@ -120,69 +120,69 @@ flag.StencilFuncRef { bits = 32, shift = 0, range = 8, "helper" } flag.StencilFuncRmask { bits = 32, shift = 8, range = 8, "helper" } flag.Stencil { bits = 32, const } - .None (0x00000000) - .Mask (0xffffffff) - .Default (0x00000000) + .None (0x00000000) + .Mask (0xffffffff) + .Default (0x00000000) flag.StencilTest { bits = 32, shift = 16, range = 4 , base = 1, desc = "Stencil test" } - .Less --- Enable stencil test, less. - .Lequal --- Enable stencil test, less or equal. - .Equal --- Enable stencil test, equal. - .Gequal --- Enable stencil test, greater or equal. - .Greater --- Enable stencil test, greater. - .Notequal --- Enable stencil test, not equal. - .Never --- Enable stencil test, never. - .Always --- Enable stencil test, always. + .Less --- Enable stencil test, less. + .Lequal --- Enable stencil test, less or equal. + .Equal --- Enable stencil test, equal. + .Gequal --- Enable stencil test, greater or equal. + .Greater --- Enable stencil test, greater. + .Notequal --- Enable stencil test, not equal. + .Never --- Enable stencil test, never. + .Always --- Enable stencil test, always. () flag.StencilOpFailS { bits = 32, shift = 20, range = 4, base = 0, desc = "Stencil operation fail" } - .Zero --- Zero. - .Keep --- Keep. - .Replace --- Replace. - .Incr --- Increment and wrap. - .Incrsat --- Increment and clamp. - .Decr --- Decrement and wrap. - .Decrsat --- Decrement and clamp. - .Invert --- Invert. + .Zero --- Zero. + .Keep --- Keep. + .Replace --- Replace. + .Incr --- Increment and wrap. + .Incrsat --- Increment and clamp. + .Decr --- Decrement and wrap. + .Decrsat --- Decrement and clamp. + .Invert --- Invert. () flag.StencilOpFailZ { bits = 32, shift = 24, range = 4, base = 0, desc = "Stencil operation depth fail" } - .Zero --- Zero. - .Keep --- Keep. - .Replace --- Replace. - .Incr --- Increment and wrap. - .Incrsat --- Increment and clamp. - .Decr --- Decrement and wrap. - .Decrsat --- Decrement and clamp. - .Invert --- Invert. + .Zero --- Zero. + .Keep --- Keep. + .Replace --- Replace. + .Incr --- Increment and wrap. + .Incrsat --- Increment and clamp. + .Decr --- Decrement and wrap. + .Decrsat --- Decrement and clamp. + .Invert --- Invert. () flag.StencilOpPassZ { bits = 32, shift = 28, range = 4 , base = 0, desc = "Stencil operation depth pass" } - .Zero --- Zero. - .Keep --- Keep. - .Replace --- Replace. - .Incr --- Increment and wrap. - .Incrsat --- Increment and clamp. - .Decr --- Decrement and wrap. - .Decrsat --- Decrement and clamp. - .Invert --- Invert. + .Zero --- Zero. + .Keep --- Keep. + .Replace --- Replace. + .Incr --- Increment and wrap. + .Incrsat --- Increment and clamp. + .Decr --- Decrement and wrap. + .Decrsat --- Decrement and clamp. + .Invert --- Invert. () flag.Clear { bits = 16 } - .None --- No clear flags. - .Color --- Clear color. - .Depth --- Clear depth. - .Stencil --- Clear stencil. - .DiscardColor_0 --- Discard frame buffer attachment 0. - .DiscardColor_1 --- Discard frame buffer attachment 1. - .DiscardColor_2 --- Discard frame buffer attachment 2. - .DiscardColor_3 --- Discard frame buffer attachment 3. - .DiscardColor_4 --- Discard frame buffer attachment 4. - .DiscardColor_5 --- Discard frame buffer attachment 5. - .DiscardColor_6 --- Discard frame buffer attachment 6. - .DiscardColor_7 --- Discard frame buffer attachment 7. - .DiscardDepth --- Discard frame buffer depth attachment. - .DiscardStencil --- Discard frame buffer stencil attachment. + .None --- No clear flags. + .Color --- Clear color. + .Depth --- Clear depth. + .Stencil --- Clear stencil. + .DiscardColor_0 --- Discard frame buffer attachment 0. + .DiscardColor_1 --- Discard frame buffer attachment 1. + .DiscardColor_2 --- Discard frame buffer attachment 2. + .DiscardColor_3 --- Discard frame buffer attachment 3. + .DiscardColor_4 --- Discard frame buffer attachment 4. + .DiscardColor_5 --- Discard frame buffer attachment 5. + .DiscardColor_6 --- Discard frame buffer attachment 6. + .DiscardColor_7 --- Discard frame buffer attachment 7. + .DiscardDepth --- Discard frame buffer depth attachment. + .DiscardStencil --- Discard frame buffer stencil attachment. .DiscardColorMask { "DiscardColor_0", "DiscardColor_1", @@ -200,31 +200,31 @@ flag.Clear { bits = 16 } } flag.Debug { bits = 32 } - .None --- No debug. - .Wireframe --- Enable wireframe for all primitives. - .Ifh --- Enable infinitely fast hardware test. No draw calls will be submitted to driver. - --- It's useful when profiling to quickly assess bottleneck between CPU and GPU. - .Stats --- Enable statistics display. - .Text --- Enable debug text display. - .Profiler --- Enable profiler. + .None --- No debug. + .Wireframe --- Enable wireframe for all primitives. + .Ifh --- Enable infinitely fast hardware test. No draw calls will be submitted to driver. + --- It's useful when profiling to quickly assess bottleneck between CPU and GPU. + .Stats --- Enable statistics display. + .Text --- Enable debug text display. + .Profiler --- Enable profiler. () flag.BufferComputeFormat { bits = 16, shift = 0, range = 4, base = 1 } - ._8x1 --- 1 8-bit value - ._8x2 --- 2 8-bit values - ._8x4 --- 4 8-bit values - ._16x1 --- 1 16-bit value - ._16x2 --- 2 16-bit values - ._16x4 --- 4 16-bit values - ._32x1 --- 1 32-bit value - ._32x2 --- 2 32-bit values - ._32x4 --- 4 32-bit values + ._8x1 --- 1 8-bit value + ._8x2 --- 2 8-bit values + ._8x4 --- 4 8-bit values + ._16x1 --- 1 16-bit value + ._16x2 --- 2 16-bit values + ._16x4 --- 4 16-bit values + ._32x1 --- 1 32-bit value + ._32x2 --- 2 32-bit values + ._32x4 --- 4 32-bit values () flag.BufferComputeType { bits = 16, shift = 4, range = 2, base = 1 } - .Int --- Type `int`. - .Uint --- Type `uint`. - .Float --- Type `float`. + .Int --- Type `int`. + .Uint --- Type `uint`. + .Float --- Type `float`. () flag.Buffer { bits = 16, base = 8 } @@ -239,66 +239,66 @@ flag.Buffer { bits = 16, base = 8 } flag.Texture { bits = 64 } .None (0) - .MsaaSample (36) --- Texture will be used for MSAA sampling. - .Rt (37) --- Render target no MSAA. - .ComputeWrite (45) --- Texture will be used for compute write. - .Srgb (46) --- Sample texture as sRGB. - .BlitDst (47) --- Texture will be used as blit destination. - .ReadBack (48) --- Texture will be used for read back from GPU. + .MsaaSample (36) --- Texture will be used for MSAA sampling. + .Rt (37) --- Render target no MSAA. + .ComputeWrite (45) --- Texture will be used for compute write. + .Srgb (46) --- Sample texture as sRGB. + .BlitDst (47) --- Texture will be used as blit destination. + .ReadBack (48) --- Texture will be used for read back from GPU. () flag.TextureRtMsaa { bits = 64, shift = 36, range = 3 , base = 2 } - .X2 --- Render target MSAAx2 mode. - .X4 --- Render target MSAAx4 mode. - .X8 --- Render target MSAAx8 mode. - .X16 --- Render target MSAAx16 mode. + .X2 --- Render target MSAAx2 mode. + .X4 --- Render target MSAAx4 mode. + .X8 --- Render target MSAAx8 mode. + .X16 --- Render target MSAAx16 mode. () flag.TextureRt { bits = 64, shift = 36, range = 4 } - .WriteOnly (9) --- Render target will be used for writing + .WriteOnly (9) --- Render target will be used for writing --- Sampler flags. flag.SamplerU { bits = 32, shift = 0, range = 2, base = 1 } - .Mirror --- Wrap U mode: Mirror - .Clamp --- Wrap U mode: Clamp - .Border --- Wrap U mode: Border + .Mirror --- Wrap U mode: Mirror + .Clamp --- Wrap U mode: Clamp + .Border --- Wrap U mode: Border () flag.SamplerV { bits = 32, shift = 2, range = 2, base = 1 } - .Mirror --- Wrap V mode: Mirror - .Clamp --- Wrap V mode: Clamp - .Border --- Wrap V mode: Border + .Mirror --- Wrap V mode: Mirror + .Clamp --- Wrap V mode: Clamp + .Border --- Wrap V mode: Border () flag.SamplerW { bits = 32, shift = 4, range = 2, base = 1 } - .Mirror --- Wrap W mode: Mirror - .Clamp --- Wrap W mode: Clamp - .Border --- Wrap W mode: Border + .Mirror --- Wrap W mode: Mirror + .Clamp --- Wrap W mode: Clamp + .Border --- Wrap W mode: Border () flag.SamplerMin { bits = 32, shift = 6, range = 2, base = 1 } - .Point --- Min sampling mode: Point - .Anisotropic --- Min sampling mode: Anisotropic + .Point --- Min sampling mode: Point + .Anisotropic --- Min sampling mode: Anisotropic () flag.SamplerMag { bits = 32, shift = 8, range = 2, base = 1 } - .Point --- Mag sampling mode: Point - .Anisotropic --- Mag sampling mode: Anisotropic + .Point --- Mag sampling mode: Point + .Anisotropic --- Mag sampling mode: Anisotropic () flag.SamplerMip { bits = 32, shift = 10, range = 1, base = 1 } - .Point --- Mip sampling mode: Point + .Point --- Mip sampling mode: Point () flag.SamplerCompare { bits = 32 , shift = 16, range = 4, base = 1 } - .Less --- Compare when sampling depth texture: less. - .Lequal --- Compare when sampling depth texture: less or equal. - .Equal --- Compare when sampling depth texture: equal. - .Gequal --- Compare when sampling depth texture: greater or equal. - .Greater --- Compare when sampling depth texture: greater. - .Notequal --- Compare when sampling depth texture: not equal. - .Never --- Compare when sampling depth texture: never. - .Always --- Compare when sampling depth texture: always. + .Less --- Compare when sampling depth texture: less. + .Lequal --- Compare when sampling depth texture: less or equal. + .Equal --- Compare when sampling depth texture: equal. + .Gequal --- Compare when sampling depth texture: greater or equal. + .Greater --- Compare when sampling depth texture: greater. + .Notequal --- Compare when sampling depth texture: not equal. + .Never --- Compare when sampling depth texture: never. + .Always --- Compare when sampling depth texture: always. () flag.SamplerBorderColor { bits = 32, shift = 24, range = 4, "helper" } @@ -307,35 +307,43 @@ flag.SamplerReserved { bits = 32, shift = 28, range = 4 } flag.Sampler { bits = 32 } .None .SampleStencil (21) --- Sample stencil instead of depth. - .Point { "MinPoint", "MagPoint", "MipPoint" } - .UvwMirror { "UMirror", "VMirror", "WMirror" } - .UvwClamp { "UClamp", "VClamp", "WClamp" } - .UvwBorder { "UBorder", "VBorder", "WBorder" } - .BitsMask { "UMask", "VMask", "WMask", "MinMask", "MagMask", "MipMask", "CompareMask" } + .Point { "MinPoint", "MagPoint", "MipPoint" } + .UvwMirror { "UMirror", "VMirror", "WMirror" } + .UvwClamp { "UClamp", "VClamp", "WClamp" } + .UvwBorder { "UBorder", "VBorder", "WBorder" } + .BitsMask { + "UMask", + "VMask", + "WMask", + "MinMask", + "MagMask", + "MipMask", + "CompareMask" + } () flag.ResetMsaa { bits = 32, shift = 4, range = 3, base = 1 } - .X2 --- Enable 2x MSAA. - .X4 --- Enable 4x MSAA. - .X8 --- Enable 8x MSAA. - .X16 --- Enable 16x MSAA. + .X2 --- Enable 2x MSAA. + .X4 --- Enable 4x MSAA. + .X8 --- Enable 8x MSAA. + .X16 --- Enable 16x MSAA. () flag.Reset { bits = 32 } - .None (0) --- No reset flags. - .Fullscreen (1) --- Not supported yet. - .Vsync (8) --- Enable V-Sync. - .Maxanisotropy (9) --- Turn on/off max anisotropy. - .Capture (10) --- Begin screen capture. - .FlushAfterRender (14) --- Flush rendering after submitting to GPU. - .FlipAfterRender (15) --- 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`. - .SrgbBackbuffer (16) --- Enable sRGB backbuffer. - .Hdr10 (17) --- Enable HDR10 rendering. - .Hidpi (18) --- Enable HiDPI rendering. - .DepthClamp (19) --- Enable depth clamp. - .Suspend (20) --- Suspend rendering. + .None ( 0) --- No reset flags. + .Fullscreen ( 1) --- Not supported yet. + .Vsync ( 8) --- Enable V-Sync. + .Maxanisotropy ( 9) --- Turn on/off max anisotropy. + .Capture (10) --- Begin screen capture. + .FlushAfterRender (14) --- Flush rendering after submitting to GPU. + .FlipAfterRender (15) --- 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`. + .SrgbBackbuffer (16) --- Enable sRGB backbuffer. + .Hdr10 (17) --- Enable HDR10 rendering. + .Hidpi (18) --- Enable HiDPI rendering. + .DepthClamp (19) --- Enable depth clamp. + .Suspend (20) --- Suspend rendering. () flag.ResetFullscreen { bits = 32, shift = 0, range = 1, base = 1 } @@ -852,8 +860,10 @@ struct.Transform struct.ViewStats .name "char[256]" --- View name. .view "ViewId" --- View id. - .cpuTimeElapsed "int64_t" --- CPU (submit) time elapsed. - .gpuTimeElapsed "int64_t" --- GPU time elapsed. + .cpuTimeBegin "int64_t" --- CPU (submit) begin time. + .cpuTimeEnd "int64_t" --- CPU (submit) end time. + .gpuTimeBegin "int64_t" --- GPU begin time. + .gpuTimeEnd "int64_t" --- GPU end time. --- Encoder stats. struct.EncoderStats diff --git a/3rdparty/bgfx/scripts/bindings-cs.lua b/3rdparty/bgfx/scripts/bindings-cs.lua index 8e6bfc47b1a..6a006fe694e 100644 --- a/3rdparty/bgfx/scripts/bindings-cs.lua +++ b/3rdparty/bgfx/scripts/bindings-cs.lua @@ -415,6 +415,7 @@ function gen.write(codes, outputfile) local out = assert(io.open(outputfile, "wb")) out:write(codes) out:close() + print("Generating: " .. outputfile) end if (...) == nil then diff --git a/3rdparty/bgfx/scripts/bindings-d.lua b/3rdparty/bgfx/scripts/bindings-d.lua new file mode 100644 index 00000000000..9858e4974bb --- /dev/null +++ b/3rdparty/bgfx/scripts/bindings-d.lua @@ -0,0 +1,414 @@ +local codegen = require "codegen" +local idl = codegen.idl "bgfx.idl" + +local d_types_template = [[ +/* + * + * AUTO GENERATED! DO NOT EDIT! + * + */ + +module bindbc.bgfx.types; + +public import core.stdc.stdarg : va_list; + +extern(C) @nogc nothrow: + +$version + +alias bgfx_view_id_t = ushort; + +$types +]] + +local d_funcs_template = [[ +/* + * + * AUTO GENERATED! DO NOT EDIT! + * + */ + +module bindbc.bgfx.funcs; + +private import bindbc.bgfx.types; + +extern(C) @nogc nothrow: + +version(BindBgfx_Static) +{ + $funcs_static +} +else +{ + __gshared + { + $funcs_dynamic + } +} +]] + +local function hasPrefix(str, prefix) + return prefix == "" or str:sub(1, #prefix) == prefix +end + +local function hasSuffix(str, suffix) + return suffix == "" or str:sub(-#suffix) == suffix +end + +local function to_underscorecase(name) + local tmp = {} + for v in name:gmatch "[_%u][%l%d]*" do + if v:byte() == 95 then -- '_' + v = v:sub(2) -- remove _ + end + tmp[#tmp+1] = v + end + return table.concat(tmp, "_") +end + +local function convert_array(member) + if string.find(member.array, "::") then + local name = "bgfx_" .. to_underscorecase(string.gsub(member.array, "::.*", "")):lower() .. "_t" + return "[" .. name .. ".BGFX_" .. to_underscorecase(member.array):upper() .. "]" + else + return member.array + end +end + +local function convert_type(arg) + local ctype = arg.ctype:gsub("%s%*", "*") + if arg.fulltype == "bx::AllocatorI*" or arg.fulltype == "CallbackI*" or arg.fulltype == "ReleaseFn" then + ctype = "void*" + elseif hasPrefix(ctype, "uint64_t") then + ctype = ctype:gsub("uint64_t", "ulong") + elseif hasPrefix(ctype, "int64_t") then + ctype = ctype:gsub("int64_t", "long") + elseif hasPrefix(ctype, "uint32_t") then + ctype = ctype:gsub("uint32_t", "uint") + elseif hasPrefix(ctype, "int32_t") then + ctype = ctype:gsub("int32_t", "int") + elseif hasPrefix(ctype, "uint16_t") then + ctype = ctype:gsub("uint16_t", "ushort") + elseif hasPrefix(ctype, "uint8_t") then + ctype = ctype:gsub("uint8_t", "byte") + elseif hasPrefix(ctype, "uintptr_t") then + ctype = ctype:gsub("uintptr_t", "ulong") + elseif hasPrefix(ctype, "const ") and hasSuffix(ctype, "*") then + ctype = "const(" .. string.sub(ctype:gsub("const ", "", 1), 1, -2) .. ")*" + end + + if arg.array ~= nil then + ctype = ctype .. convert_array(arg) + end + + return ctype +end + +local function convert_struct_type(arg) + return convert_type(arg) +end + +local function convert_ret_type(arg) + return convert_type(arg) +end + +local function convert_name(arg) + if arg == "debug" then + return arg .. "_" + end + return arg +end + +local function convert_struct_member(member) + return convert_struct_type(member) .. " " .. convert_name(member.name) +end + +local function gen_version() + return "enum uint BGFX_API_VERSION = " .. (idl._version or 0) .. ";" +end + +local converter = {} +local yield = coroutine.yield +local gen = {} + +function gen.gen(template) + local indent = "" + local idx = 1; + local r = template:gsub("$([a-zA-Z_]+)", function(what) + local tmp = {} + + local ind_end = template:find("$"..what, idx, true) + local ind_start = ind_end + for j = 1, ind_end-1 do + local i = 1+ind_end-1-j + local c = string.sub(template, i, i) + if c ~= ' ' and c ~= '\t' then + ind_start = i + break + end + end + + indent = string.sub(template, ind_start+1, ind_end-1) + + local what_idl = what:gsub("funcs_dynamic", "funcs"):gsub("funcs_static", "funcs") + + if (what == "version") then + return gen_version() + end + + for _, object in ipairs(idl[what_idl]) do + local co = coroutine.create(converter[what]) + local any + while true do + local ok, v = coroutine.resume(co, object) + assert(ok, debug.traceback(co, v)) + if not v then + break + end + table.insert(tmp, v) + any = true + end + if any and tmp[#tmp] ~= "" then + table.insert(tmp, "") + end + end + return table.concat(tmp, "\n" .. indent) + end) + return r +end + +function gen.gen_types() + return gen.gen(d_types_template) +end + +function gen.gen_funcs() + return gen.gen(d_funcs_template) +end + +function converter.types(typ) + if typ.comments ~= nil then + if #typ.comments == 1 then + yield("/// " .. typ.comments[1]) + else + yield("/**") + for _, comment in ipairs(typ.comments) do + yield(" * " .. comment) + end + yield(" */") + end + end + + if typ.handle then + yield("struct " .. typ.cname .. " { ushort idx; }") + elseif typ.enum then + local prefix = "BGFX_" .. to_underscorecase(string.gsub(typ.name, "::Enum", "")):upper() + yield("enum " .. typ.cname) + yield("{") + for idx, enum in ipairs(typ.enum) do + local comments = "" + if enum.comment ~= nil then + if #enum.comment == 1 then + comments = " /// " .. enum.comment[1]; + else + yield("\t/**") + for _, comment in ipairs(enum.comment) do + yield("\t * " .. comment) + end + yield("\t */") + end + end + + local enumname + if enum.underscore then + enumname = to_underscorecase(enum.name):upper() + else + enumname = enum.name:upper() + end + + yield("\t" .. prefix .. "_" .. enumname .. "," .. comments) + end + yield(""); + --yield("\t" .. prefix .. "_COUNT = " .. #typ.enum) + yield("\t" .. prefix .. "_COUNT") + yield("}") + + elseif typ.bits ~= nil then + local prefix = "BGFX_" .. to_underscorecase(typ.name):upper() + local enumType = "uint" + format = "%u" + if typ.bits == 64 then + format = "0x%016x" + enumType = "ulong" + elseif typ.bits == 32 then + format = "0x%08x" + enumType = "uint" + elseif typ.bits == 16 then + format = "0x%04x" + enumType = "ushort" + elseif typ.bits == 8 then + format = "0x%02x" + enumType = "ubyte" + end + + for idx, flag in ipairs(typ.flag) do + local value = flag.value + if value ~= nil then + value = string.format(flag.format or format, value) + else + for _, name in ipairs(flag) do + local fixedname = prefix .. "_" .. to_underscorecase(name):upper() + if value ~= nil then + value = value .. " | " .. fixedname + else + value = fixedname + end + end + end + local comments = "" + if flag.comment ~= nil then + if #flag.comment == 1 then + comments = " /// " .. flag.comment[1] + else + yield("/**") + for _, comment in ipairs(flag.comment) do + yield(" * " .. comment) + end + yield(" */") + end + end + yield("enum " .. enumType .. " " .. prefix .. "_" .. to_underscorecase(flag.name):upper() .. " = " .. value .. ";" .. comments) + end + + if typ.shift then + local name = prefix .. "_SHIFT" + local value = typ.shift + local comments = "" + if typ.desc then + comments = string.format(" /// %s bit shift", typ.desc) + end + yield("enum " .. enumType .. " " .. name .. " = " .. value .. ";" .. comments) + end + if typ.range then + local name = prefix .. "_MASK" + local value = string.format(format, typ.mask) + local comments = "" + if typ.desc then + comments = string.format(" /// %s bit mask", typ.desc) + end + yield("enum " .. enumType .. " " .. name .. " = " .. value .. ";" .. comments) + end + + if typ.helper then + yield(string.format( + "%s %s (%s v) { return (v << %s) & %s; }", + enumType, + prefix, + enumType, + (prefix .. "_SHIFT"), + (prefix .. "_MASK"))) + end + elseif typ.struct ~= nil then + yield("struct " .. typ.cname) + yield("{") + + for _, member in ipairs(typ.struct) do + local comments = "" + if member.comment ~= nil then + if #member.comment == 1 then + comments = " /// " .. member.comment[1] + else + yield("\n\t/**") + for _, comment in ipairs(member.comment) do + yield("\t * " .. comment) + end + yield("\t */") + end + end + yield("\t" .. convert_struct_member(member) .. ";" .. comments) + end + + yield("}") + end +end + +function converter.funcs_static(func) + return converter.funcs(func, true) +end + +function converter.funcs_dynamic(func) + return converter.funcs(func, false) +end + +function converter.funcs(func, static) + if func.cpponly then + return + end + + if func.comments ~= nil then + yield("/**") + for _, line in ipairs(func.comments) do + local line = line:gsub("@remarks", "Remarks:") + line = line:gsub("@remark", "Remarks:") + line = line:gsub("@(%l)(%l+)", function(a, b) return a:upper()..b..":" end) + yield(" * " .. line) + end + + local hasParamsComments = false + for _, arg in ipairs(func.args) do + if arg.comment ~= nil then + hasParamsComments = true + break + end + end + + if hasParamsComments then + yield(" * Params:") + end + + for _, arg in ipairs(func.args) do + if arg.comment ~= nil then + yield(" * " .. convert_name(arg.name) .. " = " .. arg.comment[1]) + for i, comment in ipairs(arg.comment) do + if (i > 1) then + yield(" * " .. comment) + end + end + end + end + + yield(" */") + end + + local args = {} + if func.this ~= nil then + args[1] = convert_type(func.this_type) .. " _this" + end + for _, arg in ipairs(func.args) do + table.insert(args, convert_type(arg) .. " " .. convert_name(arg.name)) + end + + if static then + yield(convert_ret_type(func.ret) .. " bgfx_" .. func.cname .. "(" .. table.concat(args, ", ") .. ");") + else + yield("alias da_bgfx_" .. func.cname .. " = " .. convert_ret_type(func.ret) .. " function(" .. table.concat(args, ", ") .. ");") + yield("da_bgfx_" .. func.cname .. " bgfx_" .. func.cname .. ";") + end +end + +-- printtable("idl types", idl.types) +-- printtable("idl funcs", idl.funcs) + +function gen.write(codes, outputfile) + local out = assert(io.open(outputfile, "wb")) + out:write(codes) + out:close() + print("Generating: " .. outputfile) +end + +if (...) == nil then + -- run `lua bindings-d.lua` in command line + print(gen.gen_types()) + print(gen.gen_funcs()) +end + +return gen diff --git a/3rdparty/bgfx/scripts/genie.lua b/3rdparty/bgfx/scripts/genie.lua index 516833df6dc..d6d10a4d841 100644 --- a/3rdparty/bgfx/scripts/genie.lua +++ b/3rdparty/bgfx/scripts/genie.lua @@ -69,6 +69,10 @@ newaction { do local csgen = require "bindings-cs" csgen.write(csgen.gen(), "../bindings/cs/bgfx.cs") + + local dgen = require "bindings-d" + dgen.write(dgen.gen_types(), "../bindings/d/types.d") + dgen.write(dgen.gen_funcs(), "../bindings/d/funcs.d") end os.exit() diff --git a/3rdparty/bgfx/scripts/temp.bgfx.h b/3rdparty/bgfx/scripts/temp.bgfx.h index e1dde4ccf6b..736845cf6aa 100644 --- a/3rdparty/bgfx/scripts/temp.bgfx.h +++ b/3rdparty/bgfx/scripts/temp.bgfx.h @@ -1,13 +1,14 @@ /* * Copyright 2011-2019 Branimir Karadzic. All rights reserved. - * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE - * - * vim: set tabstop=4 expandtab: + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause */ /* * - * AUTO GENERATED! DO NOT EDIT! ( source : $source ) + * AUTO GENERATED FROM IDL! DO NOT EDIT! (source : $source) + * + * More info about IDL: + * https://gist.github.com/bkaradzic/05a1c86a6dd57bf86e2d828878e88dc2#bgfx-is-switching-to-idl-to-generate-api * */ diff --git a/3rdparty/bgfx/scripts/temp.bgfx.idl.inl b/3rdparty/bgfx/scripts/temp.bgfx.idl.inl index 63e180c2748..0a7b7228b01 100644 --- a/3rdparty/bgfx/scripts/temp.bgfx.idl.inl +++ b/3rdparty/bgfx/scripts/temp.bgfx.idl.inl @@ -1,10 +1,14 @@ /* + * Copyright 2011-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause */ /* * - * AUTO GENERATED! DO NOT EDIT! + * AUTO GENERATED FROM IDL! DO NOT EDIT! (source : $source) + * + * More info about IDL: + * https://gist.github.com/bkaradzic/05a1c86a6dd57bf86e2d828878e88dc2#bgfx-is-switching-to-idl-to-generate-api * */ diff --git a/3rdparty/bgfx/scripts/temp.defines.h b/3rdparty/bgfx/scripts/temp.defines.h index 4437bfa7894..6806ed8409f 100644 --- a/3rdparty/bgfx/scripts/temp.defines.h +++ b/3rdparty/bgfx/scripts/temp.defines.h @@ -3,6 +3,15 @@ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause */ +/* + * + * AUTO GENERATED FROM IDL! DO NOT EDIT! (source : $source) + * + * More info about IDL: + * https://gist.github.com/bkaradzic/05a1c86a6dd57bf86e2d828878e88dc2#bgfx-is-switching-to-idl-to-generate-api + * + */ + #ifndef BGFX_DEFINES_H_HEADER_GUARD #define BGFX_DEFINES_H_HEADER_GUARD |