bgfx.c3 126 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332
  1. /*
  2. * Copyright 2011-2026 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
  4. */
  5. /*
  6. *
  7. * AUTO GENERATED! DO NOT EDIT!
  8. *
  9. */
  10. module bgfx;
  11. enum StateFlags : const ulong
  12. {
  13. // Enable R write.
  14. WRITER = 0x0000000000000001,
  15. // Enable G write.
  16. WRITEG = 0x0000000000000002,
  17. // Enable B write.
  18. WRITEB = 0x0000000000000004,
  19. // Enable alpha write.
  20. WRITEA = 0x0000000000000008,
  21. // Enable depth write.
  22. WRITEZ = 0x0000004000000000,
  23. // Enable RGB write.
  24. WRITERGB = 0x0000000000000007,
  25. // Write all channels mask.
  26. WRITEMASK = 0x000000400000000f,
  27. // Enable depth test, less.
  28. DEPTHTESTLESS = 0x0000000000000010,
  29. // Enable depth test, less or equal.
  30. DEPTHTESTLEQUAL = 0x0000000000000020,
  31. // Enable depth test, equal.
  32. DEPTHTESTEQUAL = 0x0000000000000030,
  33. // Enable depth test, greater or equal.
  34. DEPTHTESTGEQUAL = 0x0000000000000040,
  35. // Enable depth test, greater.
  36. DEPTHTESTGREATER = 0x0000000000000050,
  37. // Enable depth test, not equal.
  38. DEPTHTESTNOTEQUAL = 0x0000000000000060,
  39. // Enable depth test, never.
  40. DEPTHTESTNEVER = 0x0000000000000070,
  41. // Enable depth test, always.
  42. DEPTHTESTALWAYS = 0x0000000000000080,
  43. DEPTHTESTSHIFT = 4,
  44. DEPTHTESTMASK = 0x00000000000000f0,
  45. // 0, 0, 0, 0
  46. BLENDZERO = 0x0000000000001000,
  47. // 1, 1, 1, 1
  48. BLENDONE = 0x0000000000002000,
  49. // Rs, Gs, Bs, As
  50. BLENDSRCCOLOR = 0x0000000000003000,
  51. // 1-Rs, 1-Gs, 1-Bs, 1-As
  52. BLENDINVSRCCOLOR = 0x0000000000004000,
  53. // As, As, As, As
  54. BLENDSRCALPHA = 0x0000000000005000,
  55. // 1-As, 1-As, 1-As, 1-As
  56. BLENDINVSRCALPHA = 0x0000000000006000,
  57. // Ad, Ad, Ad, Ad
  58. BLENDDSTALPHA = 0x0000000000007000,
  59. // 1-Ad, 1-Ad, 1-Ad ,1-Ad
  60. BLENDINVDSTALPHA = 0x0000000000008000,
  61. // Rd, Gd, Bd, Ad
  62. BLENDDSTCOLOR = 0x0000000000009000,
  63. // 1-Rd, 1-Gd, 1-Bd, 1-Ad
  64. BLENDINVDSTCOLOR = 0x000000000000a000,
  65. // f, f, f, 1; f = min(As, 1-Ad)
  66. BLENDSRCALPHASAT = 0x000000000000b000,
  67. // Blend factor
  68. BLENDFACTOR = 0x000000000000c000,
  69. // 1-Blend factor
  70. BLENDINVFACTOR = 0x000000000000d000,
  71. BLENDSHIFT = 12,
  72. BLENDMASK = 0x000000000ffff000,
  73. // Blend add: src + dst.
  74. BLENDEQUATIONADD = 0x0000000000000000,
  75. // Blend subtract: src - dst.
  76. BLENDEQUATIONSUB = 0x0000000010000000,
  77. // Blend reverse subtract: dst - src.
  78. BLENDEQUATIONREVSUB = 0x0000000020000000,
  79. // Blend min: min(src, dst).
  80. BLENDEQUATIONMIN = 0x0000000030000000,
  81. // Blend max: max(src, dst).
  82. BLENDEQUATIONMAX = 0x0000000040000000,
  83. BLENDEQUATIONSHIFT = 28,
  84. BLENDEQUATIONMASK = 0x00000003f0000000,
  85. // Cull clockwise triangles.
  86. CULLCW = 0x0000001000000000,
  87. // Cull counter-clockwise triangles.
  88. CULLCCW = 0x0000002000000000,
  89. CULLSHIFT = 36,
  90. CULLMASK = 0x0000003000000000,
  91. ALPHAREFSHIFT = 40,
  92. ALPHAREFMASK = 0x0000ff0000000000,
  93. // Tristrip.
  94. PTTRISTRIP = 0x0001000000000000,
  95. // Lines.
  96. PTLINES = 0x0002000000000000,
  97. // Line strip.
  98. PTLINESTRIP = 0x0003000000000000,
  99. // Points.
  100. PTPOINTS = 0x0004000000000000,
  101. PTSHIFT = 48,
  102. PTMASK = 0x0007000000000000,
  103. POINTSIZESHIFT = 52,
  104. POINTSIZEMASK = 0x00f0000000000000,
  105. // Enable MSAA rasterization.
  106. MSAA = 0x0100000000000000,
  107. // Enable line AA rasterization.
  108. LINEAA = 0x0200000000000000,
  109. // Enable conservative rasterization.
  110. CONSERVATIVERASTER = 0x0400000000000000,
  111. // No state.
  112. NONE = 0x0000000000000000,
  113. // Front counter-clockwise (default is clockwise).
  114. FRONTCCW = 0x0000008000000000,
  115. // Enable blend independent.
  116. BLENDINDEPENDENT = 0x0000000400000000,
  117. // Enable alpha to coverage.
  118. BLENDALPHATOCOVERAGE = 0x0000000800000000,
  119. // Default state is write to RGB, alpha, and depth with depth test less enabled, with clockwise
  120. // culling and MSAA (when writing into MSAA frame buffer, otherwise this flag is ignored).
  121. DEFAULT = 0x010000500000001f,
  122. MASK = 0xffffffffffffffff,
  123. RESERVEDSHIFT = 61,
  124. RESERVEDMASK = 0xe000000000000000,
  125. }
  126. enum StencilFlags : const uint
  127. {
  128. FUNCREFSHIFT = 0,
  129. FUNCREFMASK = 0x000000ff,
  130. FUNCRMASKSHIFT = 8,
  131. FUNCRMASKMASK = 0x0000ff00,
  132. NONE = 0x00000000,
  133. MASK = 0xffffffff,
  134. DEFAULT = 0x00000000,
  135. // Enable stencil test, less.
  136. TESTLESS = 0x00010000,
  137. // Enable stencil test, less or equal.
  138. TESTLEQUAL = 0x00020000,
  139. // Enable stencil test, equal.
  140. TESTEQUAL = 0x00030000,
  141. // Enable stencil test, greater or equal.
  142. TESTGEQUAL = 0x00040000,
  143. // Enable stencil test, greater.
  144. TESTGREATER = 0x00050000,
  145. // Enable stencil test, not equal.
  146. TESTNOTEQUAL = 0x00060000,
  147. // Enable stencil test, never.
  148. TESTNEVER = 0x00070000,
  149. // Enable stencil test, always.
  150. TESTALWAYS = 0x00080000,
  151. TESTSHIFT = 16,
  152. TESTMASK = 0x000f0000,
  153. // Zero.
  154. OPFAILSZERO = 0x00000000,
  155. // Keep.
  156. OPFAILSKEEP = 0x00100000,
  157. // Replace.
  158. OPFAILSREPLACE = 0x00200000,
  159. // Increment and wrap.
  160. OPFAILSINCR = 0x00300000,
  161. // Increment and clamp.
  162. OPFAILSINCRSAT = 0x00400000,
  163. // Decrement and wrap.
  164. OPFAILSDECR = 0x00500000,
  165. // Decrement and clamp.
  166. OPFAILSDECRSAT = 0x00600000,
  167. // Invert.
  168. OPFAILSINVERT = 0x00700000,
  169. OPFAILSSHIFT = 20,
  170. OPFAILSMASK = 0x00f00000,
  171. // Zero.
  172. OPFAILZZERO = 0x00000000,
  173. // Keep.
  174. OPFAILZKEEP = 0x01000000,
  175. // Replace.
  176. OPFAILZREPLACE = 0x02000000,
  177. // Increment and wrap.
  178. OPFAILZINCR = 0x03000000,
  179. // Increment and clamp.
  180. OPFAILZINCRSAT = 0x04000000,
  181. // Decrement and wrap.
  182. OPFAILZDECR = 0x05000000,
  183. // Decrement and clamp.
  184. OPFAILZDECRSAT = 0x06000000,
  185. // Invert.
  186. OPFAILZINVERT = 0x07000000,
  187. OPFAILZSHIFT = 24,
  188. OPFAILZMASK = 0x0f000000,
  189. // Zero.
  190. OPPASSZZERO = 0x00000000,
  191. // Keep.
  192. OPPASSZKEEP = 0x10000000,
  193. // Replace.
  194. OPPASSZREPLACE = 0x20000000,
  195. // Increment and wrap.
  196. OPPASSZINCR = 0x30000000,
  197. // Increment and clamp.
  198. OPPASSZINCRSAT = 0x40000000,
  199. // Decrement and wrap.
  200. OPPASSZDECR = 0x50000000,
  201. // Decrement and clamp.
  202. OPPASSZDECRSAT = 0x60000000,
  203. // Invert.
  204. OPPASSZINVERT = 0x70000000,
  205. OPPASSZSHIFT = 28,
  206. OPPASSZMASK = 0xf0000000,
  207. }
  208. enum ClearFlags : const ushort
  209. {
  210. // No clear flags.
  211. NONE = 0x0000,
  212. // Clear color.
  213. COLOR = 0x0001,
  214. // Clear depth.
  215. DEPTH = 0x0002,
  216. // Clear stencil.
  217. STENCIL = 0x0004,
  218. // Discard frame buffer attachment 0.
  219. DISCARDCOLOR_0 = 0x0008,
  220. // Discard frame buffer attachment 1.
  221. DISCARDCOLOR_1 = 0x0010,
  222. // Discard frame buffer attachment 2.
  223. DISCARDCOLOR_2 = 0x0020,
  224. // Discard frame buffer attachment 3.
  225. DISCARDCOLOR_3 = 0x0040,
  226. // Discard frame buffer attachment 4.
  227. DISCARDCOLOR_4 = 0x0080,
  228. // Discard frame buffer attachment 5.
  229. DISCARDCOLOR_5 = 0x0100,
  230. // Discard frame buffer attachment 6.
  231. DISCARDCOLOR_6 = 0x0200,
  232. // Discard frame buffer attachment 7.
  233. DISCARDCOLOR_7 = 0x0400,
  234. // Discard frame buffer depth attachment.
  235. DISCARDDEPTH = 0x0800,
  236. // Discard frame buffer stencil attachment.
  237. DISCARDSTENCIL = 0x1000,
  238. DISCARDCOLORMASK = 0x07f8,
  239. DISCARDMASK = 0x1ff8,
  240. }
  241. enum DiscardFlags : const uint
  242. {
  243. // Preserve everything.
  244. NONE = 0x00000000,
  245. // Discard texture sampler and buffer bindings.
  246. BINDINGS = 0x00000001,
  247. // Discard index buffer.
  248. INDEXBUFFER = 0x00000002,
  249. // Discard instance data.
  250. INSTANCEDATA = 0x00000004,
  251. // Discard state and uniform bindings.
  252. STATE = 0x00000008,
  253. // Discard transform.
  254. TRANSFORM = 0x00000010,
  255. // Discard vertex streams.
  256. VERTEXSTREAMS = 0x00000020,
  257. // Discard all states.
  258. ALL = 0x000000ff,
  259. }
  260. enum DebugFlags : const uint
  261. {
  262. // No debug.
  263. NONE = 0x00000000,
  264. // Enable wireframe for all primitives.
  265. WIREFRAME = 0x00000001,
  266. // Enable infinitely fast hardware test. No draw calls will be submitted to driver.
  267. // It's useful when profiling to quickly assess bottleneck between CPU and GPU.
  268. IFH = 0x00000002,
  269. // Enable statistics display.
  270. STATS = 0x00000004,
  271. // Enable debug text display.
  272. TEXT = 0x00000008,
  273. // 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`.
  274. PROFILER = 0x00000010,
  275. }
  276. enum BufferFlags : const ushort
  277. {
  278. // 1 x 8-bit value
  279. COMPUTEFORMAT8X1 = 0x0001,
  280. // 2 x 8-bit values
  281. COMPUTEFORMAT8X2 = 0x0002,
  282. // 4 x 8-bit values
  283. COMPUTEFORMAT8X4 = 0x0003,
  284. // 1 x 16-bit value
  285. COMPUTEFORMAT16X1 = 0x0004,
  286. // 2 x 16-bit values
  287. COMPUTEFORMAT16X2 = 0x0005,
  288. // 4 x 16-bit values
  289. COMPUTEFORMAT16X4 = 0x0006,
  290. // 1 x 32-bit value
  291. COMPUTEFORMAT32X1 = 0x0007,
  292. // 2 x 32-bit values
  293. COMPUTEFORMAT32X2 = 0x0008,
  294. // 4 x 32-bit values
  295. COMPUTEFORMAT32X4 = 0x0009,
  296. COMPUTEFORMATSHIFT = 0,
  297. COMPUTEFORMATMASK = 0x000f,
  298. // Type `int`.
  299. COMPUTETYPEINT = 0x0010,
  300. // Type `uint`.
  301. COMPUTETYPEUINT = 0x0020,
  302. // Type `float`.
  303. COMPUTETYPEFLOAT = 0x0030,
  304. COMPUTETYPESHIFT = 4,
  305. COMPUTETYPEMASK = 0x0030,
  306. NONE = 0x0000,
  307. // Buffer will be read by shader.
  308. COMPUTEREAD = 0x0100,
  309. // Buffer will be used for writing.
  310. COMPUTEWRITE = 0x0200,
  311. // Buffer will be used for storing draw indirect commands.
  312. DRAWINDIRECT = 0x0400,
  313. // Allow dynamic index/vertex buffer resize during update.
  314. ALLOWRESIZE = 0x0800,
  315. // Index buffer contains 32-bit indices.
  316. INDEX32 = 0x1000,
  317. COMPUTEREADWRITE = 0x0300,
  318. }
  319. enum TextureFlags : const ulong
  320. {
  321. NONE = 0x0000000000000000,
  322. // Texture will be used for MSAA sampling.
  323. MSAASAMPLE = 0x0000000800000000,
  324. // Render target no MSAA.
  325. RT = 0x0000001000000000,
  326. // Texture will be used for compute write.
  327. COMPUTEWRITE = 0x0000100000000000,
  328. // Sample texture as sRGB.
  329. SRGB = 0x0000200000000000,
  330. // Texture will be used as blit destination.
  331. BLITDST = 0x0000400000000000,
  332. // Texture will be used for read back from GPU.
  333. READBACK = 0x0000800000000000,
  334. // Render target MSAAx2 mode.
  335. RTMSAAX2 = 0x0000002000000000,
  336. // Render target MSAAx4 mode.
  337. RTMSAAX4 = 0x0000003000000000,
  338. // Render target MSAAx8 mode.
  339. RTMSAAX8 = 0x0000004000000000,
  340. // Render target MSAAx16 mode.
  341. RTMSAAX16 = 0x0000005000000000,
  342. RTMSAASHIFT = 36,
  343. RTMSAAMASK = 0x0000007000000000,
  344. // Render target will be used for writing
  345. RTWRITEONLY = 0x0000008000000000,
  346. RTSHIFT = 36,
  347. RTMASK = 0x000000f000000000,
  348. }
  349. enum SamplerFlags : const uint
  350. {
  351. // Wrap U mode: Mirror
  352. UMIRROR = 0x00000001,
  353. // Wrap U mode: Clamp
  354. UCLAMP = 0x00000002,
  355. // Wrap U mode: Border
  356. UBORDER = 0x00000003,
  357. USHIFT = 0,
  358. UMASK = 0x00000003,
  359. // Wrap V mode: Mirror
  360. VMIRROR = 0x00000004,
  361. // Wrap V mode: Clamp
  362. VCLAMP = 0x00000008,
  363. // Wrap V mode: Border
  364. VBORDER = 0x0000000c,
  365. VSHIFT = 2,
  366. VMASK = 0x0000000c,
  367. // Wrap W mode: Mirror
  368. WMIRROR = 0x00000010,
  369. // Wrap W mode: Clamp
  370. WCLAMP = 0x00000020,
  371. // Wrap W mode: Border
  372. WBORDER = 0x00000030,
  373. WSHIFT = 4,
  374. WMASK = 0x00000030,
  375. // Min sampling mode: Point
  376. MINPOINT = 0x00000040,
  377. // Min sampling mode: Anisotropic
  378. MINANISOTROPIC = 0x00000080,
  379. MINSHIFT = 6,
  380. MINMASK = 0x000000c0,
  381. // Mag sampling mode: Point
  382. MAGPOINT = 0x00000100,
  383. // Mag sampling mode: Anisotropic
  384. MAGANISOTROPIC = 0x00000200,
  385. MAGSHIFT = 8,
  386. MAGMASK = 0x00000300,
  387. // Mip sampling mode: Point
  388. MIPPOINT = 0x00000400,
  389. MIPSHIFT = 10,
  390. MIPMASK = 0x00000400,
  391. // Compare when sampling depth texture: less.
  392. COMPARELESS = 0x00010000,
  393. // Compare when sampling depth texture: less or equal.
  394. COMPARELEQUAL = 0x00020000,
  395. // Compare when sampling depth texture: equal.
  396. COMPAREEQUAL = 0x00030000,
  397. // Compare when sampling depth texture: greater or equal.
  398. COMPAREGEQUAL = 0x00040000,
  399. // Compare when sampling depth texture: greater.
  400. COMPAREGREATER = 0x00050000,
  401. // Compare when sampling depth texture: not equal.
  402. COMPARENOTEQUAL = 0x00060000,
  403. // Compare when sampling depth texture: never.
  404. COMPARENEVER = 0x00070000,
  405. // Compare when sampling depth texture: always.
  406. COMPAREALWAYS = 0x00080000,
  407. COMPARESHIFT = 16,
  408. COMPAREMASK = 0x000f0000,
  409. BORDERCOLORSHIFT = 24,
  410. BORDERCOLORMASK = 0x0f000000,
  411. RESERVEDSHIFT = 28,
  412. RESERVEDMASK = 0xf0000000,
  413. NONE = 0x00000000,
  414. // Sample stencil instead of depth.
  415. SAMPLESTENCIL = 0x00100000,
  416. POINT = 0x00000540,
  417. UVWMIRROR = 0x00000015,
  418. UVWCLAMP = 0x0000002a,
  419. UVWBORDER = 0x0000003f,
  420. BITSMASK = 0x000f07ff,
  421. }
  422. enum ResetFlags : const uint
  423. {
  424. // Enable 2x MSAA.
  425. MSAAX2 = 0x00000010,
  426. // Enable 4x MSAA.
  427. MSAAX4 = 0x00000020,
  428. // Enable 8x MSAA.
  429. MSAAX8 = 0x00000030,
  430. // Enable 16x MSAA.
  431. MSAAX16 = 0x00000040,
  432. MSAASHIFT = 4,
  433. MSAAMASK = 0x00000070,
  434. // No reset flags.
  435. NONE = 0x00000000,
  436. // Not supported yet.
  437. FULLSCREEN = 0x00000001,
  438. // Enable V-Sync.
  439. VSYNC = 0x00000080,
  440. // Turn on/off max anisotropy.
  441. MAXANISOTROPY = 0x00000100,
  442. // Begin screen capture.
  443. CAPTURE = 0x00000200,
  444. // Flush rendering after submitting to GPU.
  445. FLUSHAFTERRENDER = 0x00002000,
  446. // This flag specifies where flip occurs. Default behaviour is that flip occurs
  447. // before rendering new frame. This flag only has effect when `BGFX_CONFIG_MULTITHREADED=0`.
  448. FLIPAFTERRENDER = 0x00004000,
  449. // Enable sRGB backbuffer.
  450. SRGBBACKBUFFER = 0x00008000,
  451. // Enable HDR10 rendering.
  452. HDR10 = 0x00010000,
  453. // Enable HiDPI rendering.
  454. HIDPI = 0x00020000,
  455. // Enable depth clamp.
  456. DEPTHCLAMP = 0x00040000,
  457. // Suspend rendering.
  458. SUSPEND = 0x00080000,
  459. // Transparent backbuffer. Availability depends on: `BGFX_CAPS_TRANSPARENT_BACKBUFFER`.
  460. TRANSPARENTBACKBUFFER = 0x00100000,
  461. FULLSCREENSHIFT = 0,
  462. FULLSCREENMASK = 0x00000001,
  463. RESERVEDSHIFT = 31,
  464. RESERVEDMASK = 0x80000000,
  465. }
  466. enum CapsFlags : const ulong
  467. {
  468. // Alpha to coverage is supported.
  469. ALPHATOCOVERAGE = 0x0000000000000001,
  470. // Blend independent is supported.
  471. BLENDINDEPENDENT = 0x0000000000000002,
  472. // Compute shaders are supported.
  473. COMPUTE = 0x0000000000000004,
  474. // Conservative rasterization is supported.
  475. CONSERVATIVERASTER = 0x0000000000000008,
  476. // Draw indirect is supported.
  477. DRAWINDIRECT = 0x0000000000000010,
  478. // Draw indirect with indirect count is supported.
  479. DRAWINDIRECTCOUNT = 0x0000000000000020,
  480. // Fragment depth is available in fragment shader.
  481. FRAGMENTDEPTH = 0x0000000000000040,
  482. // Fragment ordering is available in fragment shader.
  483. FRAGMENTORDERING = 0x0000000000000080,
  484. // Graphics debugger is present.
  485. GRAPHICSDEBUGGER = 0x0000000000000100,
  486. // HDR10 rendering is supported.
  487. HDR10 = 0x0000000000000200,
  488. // HiDPI rendering is supported.
  489. HIDPI = 0x0000000000000400,
  490. // Image Read/Write is supported.
  491. IMAGERW = 0x0000000000000800,
  492. // 32-bit indices are supported.
  493. INDEX32 = 0x0000000000001000,
  494. // Instancing is supported.
  495. INSTANCING = 0x0000000000002000,
  496. // Occlusion query is supported.
  497. OCCLUSIONQUERY = 0x0000000000004000,
  498. // PrimitiveID is available in fragment shader.
  499. PRIMITIVEID = 0x0000000000008000,
  500. // Renderer is on separate thread.
  501. RENDERERMULTITHREADED = 0x0000000000010000,
  502. // Multiple windows are supported.
  503. SWAPCHAIN = 0x0000000000020000,
  504. // Texture blit is supported.
  505. TEXTUREBLIT = 0x0000000000040000,
  506. // Texture compare less equal mode is supported.
  507. TEXTURECOMPARELEQUAL = 0x0000000000080000,
  508. TEXTURECOMPARERESERVED = 0x0000000000100000,
  509. // Cubemap texture array is supported.
  510. TEXTURECUBEARRAY = 0x0000000000200000,
  511. // CPU direct access to GPU texture memory.
  512. TEXTUREDIRECTACCESS = 0x0000000000400000,
  513. // Read-back texture is supported.
  514. TEXTUREREADBACK = 0x0000000000800000,
  515. // 2D texture array is supported.
  516. TEXTURE_2DARRAY = 0x0000000001000000,
  517. // 3D textures are supported.
  518. TEXTURE_3D = 0x0000000002000000,
  519. // Transparent back buffer supported.
  520. TRANSPARENTBACKBUFFER = 0x0000000004000000,
  521. // Variable Rate Shading
  522. VARIABLERATESHADING = 0x0000000008000000,
  523. // Vertex attribute half-float is supported.
  524. VERTEXATTRIBHALF = 0x0000000010000000,
  525. // Vertex attribute 10_10_10_2 is supported.
  526. VERTEXATTRIBUINT10 = 0x0000000020000000,
  527. // Rendering with VertexID only is supported.
  528. VERTEXID = 0x0000000040000000,
  529. // Viewport layer is available in vertex shader.
  530. VIEWPORTLAYERARRAY = 0x0000000080000000,
  531. // All texture compare modes are supported.
  532. TEXTURECOMPAREALL = 0x0000000000180000,
  533. }
  534. enum CapsFormatFlags : const uint
  535. {
  536. // Texture format is not supported.
  537. TEXTURENONE = 0x00000000,
  538. // Texture format is supported.
  539. TEXTURE_2D = 0x00000001,
  540. // Texture as sRGB format is supported.
  541. TEXTURE_2DSRGB = 0x00000002,
  542. // Texture format is emulated.
  543. TEXTURE_2DEMULATED = 0x00000004,
  544. // Texture format is supported.
  545. TEXTURE_3D = 0x00000008,
  546. // Texture as sRGB format is supported.
  547. TEXTURE_3DSRGB = 0x00000010,
  548. // Texture format is emulated.
  549. TEXTURE_3DEMULATED = 0x00000020,
  550. // Texture format is supported.
  551. TEXTURECUBE = 0x00000040,
  552. // Texture as sRGB format is supported.
  553. TEXTURECUBESRGB = 0x00000080,
  554. // Texture format is emulated.
  555. TEXTURECUBEEMULATED = 0x00000100,
  556. // Texture format can be used from vertex shader.
  557. TEXTUREVERTEX = 0x00000200,
  558. // Texture format can be used as image and read from.
  559. TEXTUREIMAGEREAD = 0x00000400,
  560. // Texture format can be used as image and written to.
  561. TEXTUREIMAGEWRITE = 0x00000800,
  562. // Texture format can be used as frame buffer.
  563. TEXTUREFRAMEBUFFER = 0x00001000,
  564. // Texture format can be used as MSAA frame buffer.
  565. TEXTUREFRAMEBUFFERMSAA = 0x00002000,
  566. // Texture can be sampled as MSAA.
  567. TEXTUREMSAA = 0x00004000,
  568. // Texture format supports auto-generated mips.
  569. TEXTUREMIPAUTOGEN = 0x00008000,
  570. }
  571. enum ResolveFlags : const uint
  572. {
  573. // No resolve flags.
  574. NONE = 0x00000000,
  575. // Auto-generate mip maps on resolve.
  576. AUTOGENMIPS = 0x00000001,
  577. }
  578. enum PciIdFlags : const ushort
  579. {
  580. // Autoselect adapter.
  581. NONE = 0x0000,
  582. // Software rasterizer.
  583. SOFTWARERASTERIZER = 0x0001,
  584. // AMD adapter.
  585. AMD = 0x1002,
  586. // Apple adapter.
  587. APPLE = 0x106b,
  588. // Intel adapter.
  589. INTEL = 0x8086,
  590. // nVidia adapter.
  591. NVIDIA = 0x10de,
  592. // Microsoft adapter.
  593. MICROSOFT = 0x1414,
  594. // ARM adapter.
  595. ARM = 0x13b5,
  596. }
  597. enum CubeMapFlags : const uint
  598. {
  599. // Cubemap +x.
  600. POSITIVEX = 0x00000000,
  601. // Cubemap -x.
  602. NEGATIVEX = 0x00000001,
  603. // Cubemap +y.
  604. POSITIVEY = 0x00000002,
  605. // Cubemap -y.
  606. NEGATIVEY = 0x00000003,
  607. // Cubemap +z.
  608. POSITIVEZ = 0x00000004,
  609. // Cubemap -z.
  610. NEGATIVEZ = 0x00000005,
  611. }
  612. enum Fatal : uint
  613. {
  614. DEBUGCHECK,
  615. INVALIDSHADER,
  616. UNABLETOINITIALIZE,
  617. UNABLETOCREATETEXTURE,
  618. DEVICELOST,
  619. COUNT
  620. }
  621. enum RendererType : uint
  622. {
  623. // No rendering.
  624. NOOP,
  625. // AGC
  626. AGC,
  627. // Direct3D 11.0
  628. DIRECT3D11,
  629. // Direct3D 12.0
  630. DIRECT3D12,
  631. // GNM
  632. GNM,
  633. // Metal
  634. METAL,
  635. // NVN
  636. NVN,
  637. // OpenGL ES 2.0+
  638. OPENGLES,
  639. // OpenGL 2.1+
  640. OPENGL,
  641. // Vulkan
  642. VULKAN,
  643. // WebGPU
  644. WEBGPU,
  645. COUNT
  646. }
  647. enum Access : uint
  648. {
  649. // Read.
  650. READ,
  651. // Write.
  652. WRITE,
  653. // Read and write.
  654. READWRITE,
  655. COUNT
  656. }
  657. enum Attrib : uint
  658. {
  659. // a_position
  660. POSITION,
  661. // a_normal
  662. NORMAL,
  663. // a_tangent
  664. TANGENT,
  665. // a_bitangent
  666. BITANGENT,
  667. // a_color0
  668. COLOR0,
  669. // a_color1
  670. COLOR1,
  671. // a_color2
  672. COLOR2,
  673. // a_color3
  674. COLOR3,
  675. // a_indices
  676. INDICES,
  677. // a_weight
  678. WEIGHT,
  679. // a_texcoord0
  680. TEXCOORD0,
  681. // a_texcoord1
  682. TEXCOORD1,
  683. // a_texcoord2
  684. TEXCOORD2,
  685. // a_texcoord3
  686. TEXCOORD3,
  687. // a_texcoord4
  688. TEXCOORD4,
  689. // a_texcoord5
  690. TEXCOORD5,
  691. // a_texcoord6
  692. TEXCOORD6,
  693. // a_texcoord7
  694. TEXCOORD7,
  695. COUNT
  696. }
  697. enum AttribType : uint
  698. {
  699. // Uint8
  700. UINT8,
  701. // Uint10, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_UINT10`.
  702. UINT10,
  703. // Int16
  704. INT16,
  705. // Half, availability depends on: `BGFX_CAPS_VERTEX_ATTRIB_HALF`.
  706. HALF,
  707. // Float
  708. FLOAT,
  709. COUNT
  710. }
  711. enum TextureFormat : uint
  712. {
  713. // DXT1 R5G6B5A1
  714. BC1,
  715. // DXT3 R5G6B5A4
  716. BC2,
  717. // DXT5 R5G6B5A8
  718. BC3,
  719. // LATC1/ATI1 R8
  720. BC4,
  721. // LATC2/ATI2 RG8
  722. BC5,
  723. // BC6H RGB16F
  724. BC6H,
  725. // BC7 RGB 4-7 bits per color channel, 0-8 bits alpha
  726. BC7,
  727. // ETC1 RGB8
  728. ETC1,
  729. // ETC2 RGB8
  730. ETC2,
  731. // ETC2 RGBA8
  732. ETC2A,
  733. // ETC2 RGB8A1
  734. ETC2A1,
  735. // EAC R11 UNORM
  736. EACR11,
  737. // EAC R11 SNORM
  738. EACR11S,
  739. // EAC RG11 UNORM
  740. EACRG11,
  741. // EAC RG11 SNORM
  742. EACRG11S,
  743. // PVRTC1 RGB 2BPP
  744. PTC12,
  745. // PVRTC1 RGB 4BPP
  746. PTC14,
  747. // PVRTC1 RGBA 2BPP
  748. PTC12A,
  749. // PVRTC1 RGBA 4BPP
  750. PTC14A,
  751. // PVRTC2 RGBA 2BPP
  752. PTC22,
  753. // PVRTC2 RGBA 4BPP
  754. PTC24,
  755. // ATC RGB 4BPP
  756. ATC,
  757. // ATCE RGBA 8 BPP explicit alpha
  758. ATCE,
  759. // ATCI RGBA 8 BPP interpolated alpha
  760. ATCI,
  761. // ASTC 4x4 8.0 BPP
  762. ASTC4X4,
  763. // ASTC 5x4 6.40 BPP
  764. ASTC5X4,
  765. // ASTC 5x5 5.12 BPP
  766. ASTC5X5,
  767. // ASTC 6x5 4.27 BPP
  768. ASTC6X5,
  769. // ASTC 6x6 3.56 BPP
  770. ASTC6X6,
  771. // ASTC 8x5 3.20 BPP
  772. ASTC8X5,
  773. // ASTC 8x6 2.67 BPP
  774. ASTC8X6,
  775. // ASTC 8x8 2.00 BPP
  776. ASTC8X8,
  777. // ASTC 10x5 2.56 BPP
  778. ASTC10X5,
  779. // ASTC 10x6 2.13 BPP
  780. ASTC10X6,
  781. // ASTC 10x8 1.60 BPP
  782. ASTC10X8,
  783. // ASTC 10x10 1.28 BPP
  784. ASTC10X10,
  785. // ASTC 12x10 1.07 BPP
  786. ASTC12X10,
  787. // ASTC 12x12 0.89 BPP
  788. ASTC12X12,
  789. // Compressed formats above.
  790. UNKNOWN,
  791. R1,
  792. A8,
  793. R8,
  794. R8I,
  795. R8U,
  796. R8S,
  797. R16,
  798. R16I,
  799. R16U,
  800. R16F,
  801. R16S,
  802. R32I,
  803. R32U,
  804. R32F,
  805. RG8,
  806. RG8I,
  807. RG8U,
  808. RG8S,
  809. RG16,
  810. RG16I,
  811. RG16U,
  812. RG16F,
  813. RG16S,
  814. RG32I,
  815. RG32U,
  816. RG32F,
  817. RGB8,
  818. RGB8I,
  819. RGB8U,
  820. RGB8S,
  821. RGB9E5F,
  822. BGRA8,
  823. RGBA8,
  824. RGBA8I,
  825. RGBA8U,
  826. RGBA8S,
  827. RGBA16,
  828. RGBA16I,
  829. RGBA16U,
  830. RGBA16F,
  831. RGBA16S,
  832. RGBA32I,
  833. RGBA32U,
  834. RGBA32F,
  835. B5G6R5,
  836. R5G6B5,
  837. BGRA4,
  838. RGBA4,
  839. BGR5A1,
  840. RGB5A1,
  841. RGB10A2,
  842. RG11B10F,
  843. // Depth formats below.
  844. UNKNOWNDEPTH,
  845. D16,
  846. D24,
  847. D24S8,
  848. D32,
  849. D16F,
  850. D24F,
  851. D32F,
  852. D0S8,
  853. COUNT
  854. }
  855. enum UniformType : uint
  856. {
  857. // Sampler.
  858. SAMPLER,
  859. // Reserved, do not use.
  860. END,
  861. // 4 floats vector.
  862. VEC4,
  863. // 3x3 matrix.
  864. MAT3,
  865. // 4x4 matrix.
  866. MAT4,
  867. COUNT
  868. }
  869. enum UniformFreq : uint
  870. {
  871. // Changing per draw call.
  872. DRAW,
  873. // Changing per view.
  874. VIEW,
  875. // Changing per frame.
  876. FRAME,
  877. COUNT
  878. }
  879. enum BackbufferRatio : uint
  880. {
  881. // Equal to backbuffer.
  882. EQUAL,
  883. // One half size of backbuffer.
  884. HALF,
  885. // One quarter size of backbuffer.
  886. QUARTER,
  887. // One eighth size of backbuffer.
  888. EIGHTH,
  889. // One sixteenth size of backbuffer.
  890. SIXTEENTH,
  891. // Double size of backbuffer.
  892. DOUBLE,
  893. COUNT
  894. }
  895. enum OcclusionQueryResult : uint
  896. {
  897. // Query failed test.
  898. INVISIBLE,
  899. // Query passed test.
  900. VISIBLE,
  901. // Query result is not available yet.
  902. NORESULT,
  903. COUNT
  904. }
  905. enum Topology : uint
  906. {
  907. // Triangle list.
  908. TRILIST,
  909. // Triangle strip.
  910. TRISTRIP,
  911. // Line list.
  912. LINELIST,
  913. // Line strip.
  914. LINESTRIP,
  915. // Point list.
  916. POINTLIST,
  917. COUNT
  918. }
  919. enum TopologyConvert : uint
  920. {
  921. // Flip winding order of triangle list.
  922. TRILISTFLIPWINDING,
  923. // Flip winding order of triangle strip.
  924. TRISTRIPFLIPWINDING,
  925. // Convert triangle list to line list.
  926. TRILISTTOLINELIST,
  927. // Convert triangle strip to triangle list.
  928. TRISTRIPTOTRILIST,
  929. // Convert line strip to line list.
  930. LINESTRIPTOLINELIST,
  931. COUNT
  932. }
  933. enum TopologySort : uint
  934. {
  935. DIRECTIONFRONTTOBACKMIN,
  936. DIRECTIONFRONTTOBACKAVG,
  937. DIRECTIONFRONTTOBACKMAX,
  938. DIRECTIONBACKTOFRONTMIN,
  939. DIRECTIONBACKTOFRONTAVG,
  940. DIRECTIONBACKTOFRONTMAX,
  941. DISTANCEFRONTTOBACKMIN,
  942. DISTANCEFRONTTOBACKAVG,
  943. DISTANCEFRONTTOBACKMAX,
  944. DISTANCEBACKTOFRONTMIN,
  945. DISTANCEBACKTOFRONTAVG,
  946. DISTANCEBACKTOFRONTMAX,
  947. COUNT
  948. }
  949. enum ViewMode : uint
  950. {
  951. // Default sort order.
  952. DEFAULT,
  953. // Sort in the same order in which submit calls were called.
  954. SEQUENTIAL,
  955. // Sort draw call depth in ascending order.
  956. DEPTHASCENDING,
  957. // Sort draw call depth in descending order.
  958. DEPTHDESCENDING,
  959. COUNT
  960. }
  961. enum ShadingRate : uint
  962. {
  963. // 1x1
  964. RATE1X1,
  965. // 1x2
  966. RATE1X2,
  967. // 2x1
  968. RATE2X1,
  969. // 2x2
  970. RATE2X2,
  971. // 2x4
  972. RATE2X4,
  973. // 4x2
  974. RATE4X2,
  975. // 4x4
  976. RATE4X4,
  977. COUNT
  978. }
  979. enum NativeWindowHandleType : uint
  980. {
  981. // Platform default handle type (X11 on Linux).
  982. DEFAULT,
  983. // Wayland.
  984. WAYLAND,
  985. COUNT
  986. }
  987. enum RenderFrame : uint
  988. {
  989. // Renderer context is not created yet.
  990. NOCONTEXT,
  991. // Renderer context is created and rendering.
  992. RENDER,
  993. // Renderer context wait for main thread signal timed out without rendering.
  994. TIMEOUT,
  995. // Renderer context is getting destroyed.
  996. EXITING,
  997. COUNT
  998. }
  999. // GPU info.
  1000. struct CapsGPU
  1001. {
  1002. // Vendor PCI id. See `BGFX_PCI_ID_*`.
  1003. ushort vendorId;
  1004. // Device id.
  1005. ushort deviceId;
  1006. }
  1007. // Renderer runtime limits.
  1008. struct CapsLimits
  1009. {
  1010. // Maximum number of draw calls.
  1011. uint maxDrawCalls;
  1012. // Maximum number of blit calls.
  1013. uint maxBlits;
  1014. // Maximum texture size.
  1015. uint maxTextureSize;
  1016. // Maximum texture layers.
  1017. uint maxTextureLayers;
  1018. // Maximum number of views.
  1019. uint maxViews;
  1020. // Maximum number of frame buffer handles.
  1021. uint maxFrameBuffers;
  1022. // Maximum number of frame buffer attachments.
  1023. uint maxFBAttachments;
  1024. // Maximum number of program handles.
  1025. uint maxPrograms;
  1026. // Maximum number of shader handles.
  1027. uint maxShaders;
  1028. // Maximum number of texture handles.
  1029. uint maxTextures;
  1030. // Maximum number of texture samplers.
  1031. uint maxTextureSamplers;
  1032. // Maximum number of compute bindings.
  1033. uint maxComputeBindings;
  1034. // Maximum number of vertex format layouts.
  1035. uint maxVertexLayouts;
  1036. // Maximum number of vertex streams.
  1037. uint maxVertexStreams;
  1038. // Maximum number of index buffer handles.
  1039. uint maxIndexBuffers;
  1040. // Maximum number of vertex buffer handles.
  1041. uint maxVertexBuffers;
  1042. // Maximum number of dynamic index buffer handles.
  1043. uint maxDynamicIndexBuffers;
  1044. // Maximum number of dynamic vertex buffer handles.
  1045. uint maxDynamicVertexBuffers;
  1046. // Maximum number of uniform handles.
  1047. uint maxUniforms;
  1048. // Maximum number of occlusion query handles.
  1049. uint maxOcclusionQueries;
  1050. // Maximum number of encoder threads.
  1051. uint maxEncoders;
  1052. // Minimum resource command buffer size.
  1053. uint minResourceCbSize;
  1054. // Maximum transient vertex buffer size.
  1055. uint maxTransientVbSize;
  1056. // Maximum transient index buffer size.
  1057. uint maxTansientIbSize;
  1058. // Mimimum uniform buffer size.
  1059. uint minUniformBufferSize;
  1060. }
  1061. // Renderer capabilities.
  1062. struct Caps
  1063. {
  1064. // Renderer backend type. See: `bgfx::RendererType`
  1065. RendererType rendererType;
  1066. // Supported functionality.
  1067. // @attention See `BGFX_CAPS_*` flags at https://bkaradzic.github.io/bgfx/bgfx.html#available-caps
  1068. ulong supported;
  1069. // Selected GPU vendor PCI id.
  1070. ushort vendorId;
  1071. // Selected GPU device id.
  1072. ushort deviceId;
  1073. // True when NDC depth is in [-1, 1] range, otherwise its [0, 1].
  1074. bool homogeneousDepth;
  1075. // True when NDC origin is at bottom left.
  1076. bool originBottomLeft;
  1077. // Number of enumerated GPUs.
  1078. char numGPUs;
  1079. // Enumerated GPUs.
  1080. uint[4] gpu;
  1081. // Renderer runtime limits.
  1082. CapsLimits limits;
  1083. // Supported texture format capabilities flags:
  1084. // - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - Texture format is not supported.
  1085. // - `BGFX_CAPS_FORMAT_TEXTURE_2D` - Texture format is supported.
  1086. // - `BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB` - Texture as sRGB format is supported.
  1087. // - `BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED` - Texture format is emulated.
  1088. // - `BGFX_CAPS_FORMAT_TEXTURE_3D` - Texture format is supported.
  1089. // - `BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB` - Texture as sRGB format is supported.
  1090. // - `BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED` - Texture format is emulated.
  1091. // - `BGFX_CAPS_FORMAT_TEXTURE_CUBE` - Texture format is supported.
  1092. // - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB` - Texture as sRGB format is supported.
  1093. // - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED` - Texture format is emulated.
  1094. // - `BGFX_CAPS_FORMAT_TEXTURE_VERTEX` - Texture format can be used from vertex shader.
  1095. // - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ` - Texture format can be used as image
  1096. // and read from.
  1097. // - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE` - Texture format can be used as image
  1098. // and written to.
  1099. // - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER` - Texture format can be used as frame
  1100. // buffer.
  1101. // - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA` - Texture format can be used as MSAA
  1102. // frame buffer.
  1103. // - `BGFX_CAPS_FORMAT_TEXTURE_MSAA` - Texture can be sampled as MSAA.
  1104. // - `BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN` - Texture format supports auto-generated
  1105. // mips.
  1106. ushort[100] formats;
  1107. }
  1108. // Internal data.
  1109. struct InternalData
  1110. {
  1111. // Renderer capabilities.
  1112. Caps* caps;
  1113. // GL context, or D3D device.
  1114. void* context;
  1115. }
  1116. // Platform data.
  1117. struct PlatformData
  1118. {
  1119. // Native display type (*nix specific).
  1120. void* ndt;
  1121. // Native window handle. If `NULL`, bgfx will create a headless
  1122. // context/device, provided the rendering API supports it.
  1123. void* nwh;
  1124. // GL context, D3D device, or Vulkan device. If `NULL`, bgfx
  1125. // will create context/device.
  1126. void* context;
  1127. // GL back-buffer, or D3D render target view. If `NULL` bgfx will
  1128. // create back-buffer color surface.
  1129. void* backBuffer;
  1130. // Backbuffer depth/stencil. If `NULL`, bgfx will create a back-buffer
  1131. // depth/stencil surface.
  1132. void* backBufferDS;
  1133. // Handle type. Needed for platforms having more than one option.
  1134. NativeWindowHandleType type;
  1135. }
  1136. // Backbuffer resolution and reset parameters.
  1137. struct Resolution
  1138. {
  1139. // Backbuffer color format.
  1140. TextureFormat formatColor;
  1141. // Backbuffer depth/stencil format.
  1142. TextureFormat formatDepthStencil;
  1143. // Backbuffer width.
  1144. uint width;
  1145. // Backbuffer height.
  1146. uint height;
  1147. // Reset parameters.
  1148. uint reset;
  1149. // Number of back buffers.
  1150. char numBackBuffers;
  1151. // Maximum frame latency.
  1152. char maxFrameLatency;
  1153. // Scale factor for debug text.
  1154. char debugTextScale;
  1155. }
  1156. // Configurable runtime limits parameters.
  1157. struct InitLimits
  1158. {
  1159. // Maximum number of encoder threads.
  1160. ushort maxEncoders;
  1161. // Minimum resource command buffer size.
  1162. uint minResourceCbSize;
  1163. // Maximum transient vertex buffer size.
  1164. uint maxTransientVbSize;
  1165. // Maximum transient index buffer size.
  1166. uint maxTransientIbSize;
  1167. // Mimimum uniform buffer size.
  1168. uint minUniformBufferSize;
  1169. }
  1170. // Initialization parameters used by `bgfx::init`.
  1171. struct Init
  1172. {
  1173. // Select rendering backend. When set to RendererType::Count
  1174. // a default rendering backend will be selected appropriate to the platform.
  1175. // See: `bgfx::RendererType`
  1176. RendererType type;
  1177. // Vendor PCI ID. If set to `BGFX_PCI_ID_NONE`, discrete and integrated
  1178. // GPUs will be prioritised.
  1179. // - `BGFX_PCI_ID_NONE` - Autoselect adapter.
  1180. // - `BGFX_PCI_ID_SOFTWARE_RASTERIZER` - Software rasterizer.
  1181. // - `BGFX_PCI_ID_AMD` - AMD adapter.
  1182. // - `BGFX_PCI_ID_APPLE` - Apple adapter.
  1183. // - `BGFX_PCI_ID_INTEL` - Intel adapter.
  1184. // - `BGFX_PCI_ID_NVIDIA` - NVIDIA adapter.
  1185. // - `BGFX_PCI_ID_MICROSOFT` - Microsoft adapter.
  1186. ushort vendorId;
  1187. // Device ID. If set to 0 it will select first device, or device with
  1188. // matching ID.
  1189. ushort deviceId;
  1190. // Capabilities initialization mask (default: UINT64_MAX).
  1191. ulong capabilities;
  1192. // Enable device for debugging.
  1193. bool debug;
  1194. // Enable device for profiling.
  1195. bool profile;
  1196. // Enable fallback to next available renderer.
  1197. bool fallback;
  1198. // Platform data.
  1199. PlatformData platformData;
  1200. // Backbuffer resolution and reset parameters. See: `bgfx::Resolution`.
  1201. Resolution resolution;
  1202. // Configurable runtime limits parameters.
  1203. InitLimits limits;
  1204. // Provide application specific callback interface.
  1205. // See: `bgfx::CallbackI`
  1206. void* callback;
  1207. // Custom allocator. When a custom allocator is not
  1208. // specified, bgfx uses the CRT allocator. Bgfx assumes
  1209. // custom allocator is thread safe.
  1210. void* allocator;
  1211. }
  1212. // Memory must be obtained by calling `bgfx::alloc`, `bgfx::copy`, or `bgfx::makeRef`.
  1213. // @attention It is illegal to create this structure on stack and pass it to any bgfx API.
  1214. struct Memory
  1215. {
  1216. // Pointer to data.
  1217. char* data;
  1218. // Data size.
  1219. uint size;
  1220. }
  1221. // Transient index buffer.
  1222. struct TransientIndexBuffer
  1223. {
  1224. // Pointer to data.
  1225. char* data;
  1226. // Data size.
  1227. uint size;
  1228. // First index.
  1229. uint startIndex;
  1230. // Index buffer handle.
  1231. IndexBufferHandle handle;
  1232. // Index buffer format is 16-bits if true, otherwise it is 32-bit.
  1233. bool isIndex16;
  1234. }
  1235. // Transient vertex buffer.
  1236. struct TransientVertexBuffer
  1237. {
  1238. // Pointer to data.
  1239. char* data;
  1240. // Data size.
  1241. uint size;
  1242. // First vertex.
  1243. uint startVertex;
  1244. // Vertex stride.
  1245. ushort stride;
  1246. // Vertex buffer handle.
  1247. VertexBufferHandle handle;
  1248. // Vertex layout handle.
  1249. VertexLayoutHandle layoutHandle;
  1250. }
  1251. // Instance data buffer info.
  1252. struct InstanceDataBuffer
  1253. {
  1254. // Pointer to data.
  1255. char* data;
  1256. // Data size.
  1257. uint size;
  1258. // Offset in vertex buffer.
  1259. uint offset;
  1260. // Number of instances.
  1261. uint num;
  1262. // Vertex buffer stride.
  1263. ushort stride;
  1264. // Vertex buffer object handle.
  1265. VertexBufferHandle handle;
  1266. }
  1267. // Texture info.
  1268. struct TextureInfo
  1269. {
  1270. // Texture format.
  1271. TextureFormat format;
  1272. // Total amount of bytes required to store texture.
  1273. uint storageSize;
  1274. // Texture width.
  1275. ushort width;
  1276. // Texture height.
  1277. ushort height;
  1278. // Texture depth.
  1279. ushort depth;
  1280. // Number of layers in texture array.
  1281. ushort numLayers;
  1282. // Number of MIP maps.
  1283. char numMips;
  1284. // Format bits per pixel.
  1285. char bitsPerPixel;
  1286. // Texture is cubemap.
  1287. bool cubeMap;
  1288. }
  1289. // Uniform info.
  1290. struct UniformInfo
  1291. {
  1292. // Uniform name.
  1293. char[256] name;
  1294. // Uniform type.
  1295. UniformType type;
  1296. // Number of elements in array.
  1297. ushort num;
  1298. }
  1299. // Frame buffer texture attachment info.
  1300. struct Attachment
  1301. {
  1302. // Attachment access. See `Access::Enum`.
  1303. Access access;
  1304. // Render target texture handle.
  1305. TextureHandle handle;
  1306. // Mip level.
  1307. ushort mip;
  1308. // Cubemap side or depth layer/slice to use.
  1309. ushort layer;
  1310. // Number of texture layer/slice(s) in array to use.
  1311. ushort numLayers;
  1312. // Resolve flags. See: `BGFX_RESOLVE_*`
  1313. char resolve;
  1314. }
  1315. // Transform data.
  1316. struct Transform
  1317. {
  1318. // Pointer to first 4x4 matrix.
  1319. float* data;
  1320. // Number of matrices.
  1321. ushort num;
  1322. }
  1323. // View stats.
  1324. struct ViewStats
  1325. {
  1326. // View name.
  1327. char[256] name;
  1328. // View id.
  1329. ushort view;
  1330. // CPU (submit) begin time.
  1331. long cpuTimeBegin;
  1332. // CPU (submit) end time.
  1333. long cpuTimeEnd;
  1334. // GPU begin time.
  1335. long gpuTimeBegin;
  1336. // GPU end time.
  1337. long gpuTimeEnd;
  1338. // Frame which generated gpuTimeBegin, gpuTimeEnd.
  1339. uint gpuFrameNum;
  1340. }
  1341. // Encoder stats.
  1342. struct EncoderStats
  1343. {
  1344. // Encoder thread CPU submit begin time.
  1345. long cpuTimeBegin;
  1346. // Encoder thread CPU submit end time.
  1347. long cpuTimeEnd;
  1348. }
  1349. // Renderer statistics data.
  1350. // @remarks All time values are high-resolution timestamps, while
  1351. // time frequencies define timestamps-per-second for that hardware.
  1352. struct Stats
  1353. {
  1354. // CPU time between two `bgfx::frame` calls.
  1355. long cpuTimeFrame;
  1356. // Render thread CPU submit begin time.
  1357. long cpuTimeBegin;
  1358. // Render thread CPU submit end time.
  1359. long cpuTimeEnd;
  1360. // CPU timer frequency. Timestamps-per-second
  1361. long cpuTimerFreq;
  1362. // GPU frame begin time.
  1363. long gpuTimeBegin;
  1364. // GPU frame end time.
  1365. long gpuTimeEnd;
  1366. // GPU timer frequency.
  1367. long gpuTimerFreq;
  1368. // Time spent waiting for render backend thread to finish issuing draw commands to underlying graphics API.
  1369. long waitRender;
  1370. // Time spent waiting for submit thread to advance to next frame.
  1371. long waitSubmit;
  1372. // Number of draw calls submitted.
  1373. uint numDraw;
  1374. // Number of compute calls submitted.
  1375. uint numCompute;
  1376. // Number of blit calls submitted.
  1377. uint numBlit;
  1378. // GPU driver latency.
  1379. uint maxGpuLatency;
  1380. // Frame which generated gpuTimeBegin, gpuTimeEnd.
  1381. uint gpuFrameNum;
  1382. // Number of used dynamic index buffers.
  1383. ushort numDynamicIndexBuffers;
  1384. // Number of used dynamic vertex buffers.
  1385. ushort numDynamicVertexBuffers;
  1386. // Number of used frame buffers.
  1387. ushort numFrameBuffers;
  1388. // Number of used index buffers.
  1389. ushort numIndexBuffers;
  1390. // Number of used occlusion queries.
  1391. ushort numOcclusionQueries;
  1392. // Number of used programs.
  1393. ushort numPrograms;
  1394. // Number of used shaders.
  1395. ushort numShaders;
  1396. // Number of used textures.
  1397. ushort numTextures;
  1398. // Number of used uniforms.
  1399. ushort numUniforms;
  1400. // Number of used vertex buffers.
  1401. ushort numVertexBuffers;
  1402. // Number of used vertex layouts.
  1403. ushort numVertexLayouts;
  1404. // Estimate of texture memory used.
  1405. long textureMemoryUsed;
  1406. // Estimate of render target memory used.
  1407. long rtMemoryUsed;
  1408. // Amount of transient vertex buffer used.
  1409. int transientVbUsed;
  1410. // Amount of transient index buffer used.
  1411. int transientIbUsed;
  1412. // Number of primitives rendered.
  1413. uint[5] numPrims;
  1414. // Maximum available GPU memory for application.
  1415. long gpuMemoryMax;
  1416. // Amount of GPU memory used by the application.
  1417. long gpuMemoryUsed;
  1418. // Backbuffer width in pixels.
  1419. ushort width;
  1420. // Backbuffer height in pixels.
  1421. ushort height;
  1422. // Debug text width in characters.
  1423. ushort textWidth;
  1424. // Debug text height in characters.
  1425. ushort textHeight;
  1426. // Number of view stats.
  1427. ushort numViews;
  1428. // Array of View stats.
  1429. ViewStats* viewStats;
  1430. // Number of encoders used during frame.
  1431. char numEncoders;
  1432. // Array of encoder stats.
  1433. EncoderStats* encoderStats;
  1434. }
  1435. // Vertex layout.
  1436. struct VertexLayout
  1437. {
  1438. // Hash.
  1439. uint hash;
  1440. // Stride.
  1441. ushort stride;
  1442. // Attribute offsets.
  1443. ushort[18] offset;
  1444. // Used attributes.
  1445. ushort[18] attributes;
  1446. }
  1447. // Encoders are used for submitting draw calls from multiple threads. Only one encoder
  1448. // per thread should be used. Use `bgfx::begin()` to obtain an encoder for a thread.
  1449. alias Encoder = any;
  1450. struct DynamicIndexBufferHandle {
  1451. ushort idx;
  1452. }
  1453. struct DynamicVertexBufferHandle {
  1454. ushort idx;
  1455. }
  1456. struct FrameBufferHandle {
  1457. ushort idx;
  1458. }
  1459. struct IndexBufferHandle {
  1460. ushort idx;
  1461. }
  1462. struct IndirectBufferHandle {
  1463. ushort idx;
  1464. }
  1465. struct OcclusionQueryHandle {
  1466. ushort idx;
  1467. }
  1468. struct ProgramHandle {
  1469. ushort idx;
  1470. }
  1471. struct ShaderHandle {
  1472. ushort idx;
  1473. }
  1474. struct TextureHandle {
  1475. ushort idx;
  1476. }
  1477. struct UniformHandle {
  1478. ushort idx;
  1479. }
  1480. struct VertexBufferHandle {
  1481. ushort idx;
  1482. }
  1483. struct VertexLayoutHandle {
  1484. ushort idx;
  1485. }
  1486. // Init attachment.
  1487. // _handle : `Render target texture handle.`
  1488. // _access : `Access. See `Access::Enum`.`
  1489. // _layer : `Cubemap side or depth layer/slice to use.`
  1490. // _numLayers : `Number of texture layer/slice(s) in array to use.`
  1491. // _mip : `Mip level.`
  1492. // _resolve : `Resolve flags. See: `BGFX_RESOLVE_*``
  1493. extern fn void attachment_init(Attachment* _this, TextureHandle _handle, Access _access, ushort _layer, ushort _numLayers, ushort _mip, char _resolve) @extern("bgfx_attachment_init");
  1494. // Start VertexLayout.
  1495. // _rendererType : `Renderer backend type. See: `bgfx::RendererType``
  1496. extern fn VertexLayout* vertex_layout_begin(VertexLayout* _this, RendererType _rendererType) @extern("bgfx_vertex_layout_begin");
  1497. // Add attribute to VertexLayout.
  1498. // @remarks Must be called between begin/end.
  1499. // _attrib : `Attribute semantics. See: `bgfx::Attrib``
  1500. // _num : `Number of elements 1, 2, 3 or 4.`
  1501. // _type : `Element type.`
  1502. // _normalized : `When using fixed point AttribType (f.e. Uint8) value will be normalized for vertex shader usage. When normalized is set to true, AttribType::Uint8 value in range 0-255 will be in range 0.0-1.0 in vertex shader.`
  1503. // _asInt : `Packaging rule for vertexPack, vertexUnpack, and vertexConvert for AttribType::Uint8 and AttribType::Int16. Unpacking code must be implemented inside vertex shader.`
  1504. extern fn VertexLayout* vertex_layout_add(VertexLayout* _this, Attrib _attrib, char _num, AttribType _type, bool _normalized, bool _asInt) @extern("bgfx_vertex_layout_add");
  1505. // Decode attribute.
  1506. // _attrib : `Attribute semantics. See: `bgfx::Attrib``
  1507. // _num : `Number of elements.`
  1508. // _type : `Element type.`
  1509. // _normalized : `Attribute is normalized.`
  1510. // _asInt : `Attribute is packed as int.`
  1511. extern fn void vertex_layout_decode(VertexLayout* _this, Attrib _attrib, char * _num, AttribType* _type, bool* _normalized, bool* _asInt) @extern("bgfx_vertex_layout_decode");
  1512. // Skip `_num` bytes in vertex stream.
  1513. // _num : `Number of bytes to skip.`
  1514. extern fn VertexLayout* vertex_layout_skip(VertexLayout* _this, char _num) @extern("bgfx_vertex_layout_skip");
  1515. // End VertexLayout.
  1516. extern fn void vertex_layout_end(VertexLayout* _this) @extern("bgfx_vertex_layout_end");
  1517. // Pack vertex attribute into vertex stream format.
  1518. // _input : `Value to be packed into vertex stream.`
  1519. // _inputNormalized : ``true` if input value is already normalized.`
  1520. // _attr : `Attribute to pack.`
  1521. // _layout : `Vertex stream layout.`
  1522. // _data : `Destination vertex stream where data will be packed.`
  1523. // _index : `Vertex index that will be modified.`
  1524. extern fn void vertex_pack(float _input, bool _inputNormalized, Attrib _attr, VertexLayout* _layout, void* _data, uint _index) @extern("bgfx_vertex_pack");
  1525. // Unpack vertex attribute from vertex stream format.
  1526. // _output : `Result of unpacking.`
  1527. // _attr : `Attribute to unpack.`
  1528. // _layout : `Vertex stream layout.`
  1529. // _data : `Source vertex stream from where data will be unpacked.`
  1530. // _index : `Vertex index that will be unpacked.`
  1531. extern fn void vertex_unpack(float _output, Attrib _attr, VertexLayout* _layout, void* _data, uint _index) @extern("bgfx_vertex_unpack");
  1532. // Converts vertex stream data from one vertex stream format to another.
  1533. // _dstLayout : `Destination vertex stream layout.`
  1534. // _dstData : `Destination vertex stream.`
  1535. // _srcLayout : `Source vertex stream layout.`
  1536. // _srcData : `Source vertex stream data.`
  1537. // _num : `Number of vertices to convert from source to destination.`
  1538. extern fn void vertex_convert(VertexLayout* _dstLayout, void* _dstData, VertexLayout* _srcLayout, void* _srcData, uint _num) @extern("bgfx_vertex_convert");
  1539. // Weld vertices.
  1540. // _output : `Welded vertices remapping table. The size of buffer must be the same as number of vertices.`
  1541. // _layout : `Vertex stream layout.`
  1542. // _data : `Vertex stream.`
  1543. // _num : `Number of vertices in vertex stream.`
  1544. // _index32 : `Set to `true` if input indices are 32-bit.`
  1545. // _epsilon : `Error tolerance for vertex position comparison.`
  1546. extern fn uint weld_vertices(void* _output, VertexLayout* _layout, void* _data, uint _num, bool _index32, float _epsilon) @extern("bgfx_weld_vertices");
  1547. // Convert index buffer for use with different primitive topologies.
  1548. // _conversion : `Conversion type, see `TopologyConvert::Enum`.`
  1549. // _dst : `Destination index buffer. If this argument is NULL function will return number of indices after conversion.`
  1550. // _dstSize : `Destination index buffer in bytes. It must be large enough to contain output indices. If destination size is insufficient index buffer will be truncated.`
  1551. // _indices : `Source indices.`
  1552. // _numIndices : `Number of input indices.`
  1553. // _index32 : `Set to `true` if input indices are 32-bit.`
  1554. extern fn uint topology_convert(TopologyConvert _conversion, void* _dst, uint _dstSize, void* _indices, uint _numIndices, bool _index32) @extern("bgfx_topology_convert");
  1555. // Sort indices.
  1556. // _sort : `Sort order, see `TopologySort::Enum`.`
  1557. // _dst : `Destination index buffer.`
  1558. // _dstSize : `Destination index buffer in bytes. It must be large enough to contain output indices. If destination size is insufficient index buffer will be truncated.`
  1559. // _dir : `Direction (vector must be normalized).`
  1560. // _pos : `Position.`
  1561. // _vertices : `Pointer to first vertex represented as float x, y, z. Must contain at least number of vertices referencende by index buffer.`
  1562. // _stride : `Vertex stride.`
  1563. // _indices : `Source indices.`
  1564. // _numIndices : `Number of input indices.`
  1565. // _index32 : `Set to `true` if input indices are 32-bit.`
  1566. extern fn void topology_sort_tri_list(TopologySort _sort, void* _dst, uint _dstSize, float _dir, float _pos, void* _vertices, uint _stride, void* _indices, uint _numIndices, bool _index32) @extern("bgfx_topology_sort_tri_list");
  1567. // Returns supported backend API renderers.
  1568. // _max : `Maximum number of elements in _enum array.`
  1569. // _enum : `Array where supported renderers will be written.`
  1570. extern fn char get_supported_renderers(char _max, RendererType* _enum) @extern("bgfx_get_supported_renderers");
  1571. // Returns name of renderer.
  1572. // _type : `Renderer backend type. See: `bgfx::RendererType``
  1573. extern fn ZString get_renderer_name(RendererType _type) @extern("bgfx_get_renderer_name");
  1574. // Fill bgfx::Init struct with default values, before using it to initialize the library.
  1575. // _init : `Pointer to structure to be initialized. See: `bgfx::Init` for more info.`
  1576. extern fn void init_ctor(Init* _init) @extern("bgfx_init_ctor");
  1577. // Initialize the bgfx library.
  1578. // _init : `Initialization parameters. See: `bgfx::Init` for more info.`
  1579. extern fn bool init(Init* _init) @extern("bgfx_init");
  1580. // Shutdown bgfx library.
  1581. extern fn void shutdown() @extern("bgfx_shutdown");
  1582. // Reset graphic settings and back-buffer size.
  1583. // @attention This call doesn’t change the window size, it just resizes
  1584. // the back-buffer. Your windowing code controls the window size.
  1585. // _width : `Back-buffer width.`
  1586. // _height : `Back-buffer height.`
  1587. // _flags : `See: `BGFX_RESET_*` for more info. - `BGFX_RESET_NONE` - No reset flags. - `BGFX_RESET_FULLSCREEN` - Not supported yet. - `BGFX_RESET_MSAA_X[2/4/8/16]` - Enable 2, 4, 8 or 16 x MSAA. - `BGFX_RESET_VSYNC` - Enable V-Sync. - `BGFX_RESET_MAXANISOTROPY` - Turn on/off max anisotropy. - `BGFX_RESET_CAPTURE` - Begin screen capture. - `BGFX_RESET_FLUSH_AFTER_RENDER` - Flush rendering after submitting to GPU. - `BGFX_RESET_FLIP_AFTER_RENDER` - This flag specifies where flip occurs. Default behaviour is that flip occurs before rendering new frame. This flag only has effect when `BGFX_CONFIG_MULTITHREADED=0`. - `BGFX_RESET_SRGB_BACKBUFFER` - Enable sRGB back-buffer.`
  1588. // _format : `Texture format. See: `TextureFormat::Enum`.`
  1589. extern fn void reset(uint _width, uint _height, uint _flags, TextureFormat _format) @extern("bgfx_reset");
  1590. // Advance to next frame. When using multithreaded renderer, this call
  1591. // just swaps internal buffers, kicks render thread, and returns. In
  1592. // singlethreaded renderer this call does frame rendering.
  1593. // _capture : `Capture frame with graphics debugger.`
  1594. extern fn uint frame(bool _capture) @extern("bgfx_frame");
  1595. // Returns current renderer backend API type.
  1596. // @remarks
  1597. // Library must be initialized.
  1598. extern fn RendererType get_renderer_type() @extern("bgfx_get_renderer_type");
  1599. // Returns renderer capabilities.
  1600. // @remarks
  1601. // Library must be initialized.
  1602. extern fn Caps* get_caps() @extern("bgfx_get_caps");
  1603. // Returns performance counters.
  1604. // @attention Pointer returned is valid until `bgfx::frame` is called.
  1605. extern fn Stats* get_stats() @extern("bgfx_get_stats");
  1606. // Allocate buffer to pass to bgfx calls. Data will be freed inside bgfx.
  1607. // _size : `Size to allocate.`
  1608. extern fn Memory* alloc(uint _size) @extern("bgfx_alloc");
  1609. // Allocate buffer and copy data into it. Data will be freed inside bgfx.
  1610. // _data : `Pointer to data to be copied.`
  1611. // _size : `Size of data to be copied.`
  1612. extern fn Memory* copy(void* _data, uint _size) @extern("bgfx_copy");
  1613. // Make reference to data to pass to bgfx. Unlike `bgfx::alloc`, this call
  1614. // doesn't allocate memory for data. It just copies the _data pointer. You
  1615. // can pass `ReleaseFn` function pointer to release this memory after it's
  1616. // consumed, otherwise you must make sure _data is available for at least 2
  1617. // `bgfx::frame` calls. `ReleaseFn` function must be able to be called
  1618. // from any thread.
  1619. // @attention Data passed must be available for at least 2 `bgfx::frame` calls.
  1620. // _data : `Pointer to data.`
  1621. // _size : `Size of data.`
  1622. extern fn Memory* make_ref(void* _data, uint _size) @extern("bgfx_make_ref");
  1623. // Make reference to data to pass to bgfx. Unlike `bgfx::alloc`, this call
  1624. // doesn't allocate memory for data. It just copies the _data pointer. You
  1625. // can pass `ReleaseFn` function pointer to release this memory after it's
  1626. // consumed, otherwise you must make sure _data is available for at least 2
  1627. // `bgfx::frame` calls. `ReleaseFn` function must be able to be called
  1628. // from any thread.
  1629. // @attention Data passed must be available for at least 2 `bgfx::frame` calls.
  1630. // _data : `Pointer to data.`
  1631. // _size : `Size of data.`
  1632. // _releaseFn : `Callback function to release memory after use.`
  1633. // _userData : `User data to be passed to callback function.`
  1634. extern fn Memory* make_ref_release(void* _data, uint _size, void* _releaseFn, void* _userData) @extern("bgfx_make_ref_release");
  1635. // Set debug flags.
  1636. // _debug : `Available flags: - `BGFX_DEBUG_IFH` - Infinitely fast hardware. When this flag is set all rendering calls will be skipped. This is useful when profiling to quickly assess potential bottlenecks between CPU and GPU. - `BGFX_DEBUG_PROFILER` - Enable profiler. - `BGFX_DEBUG_STATS` - Display internal statistics. - `BGFX_DEBUG_TEXT` - Display debug text. - `BGFX_DEBUG_WIREFRAME` - Wireframe rendering. All rendering primitives will be rendered as lines.`
  1637. extern fn void set_debug(uint _debug) @extern("bgfx_set_debug");
  1638. // Clear internal debug text buffer.
  1639. // _attr : `Background color.`
  1640. // _small : `Default 8x16 or 8x8 font.`
  1641. extern fn void dbg_text_clear(char _attr, bool _small) @extern("bgfx_dbg_text_clear");
  1642. // Print formatted data to internal debug text character-buffer (VGA-compatible text mode).
  1643. // _x : `Position x from the left corner of the window.`
  1644. // _y : `Position y from the top corner of the window.`
  1645. // _attr : `Color palette. Where top 4-bits represent index of background, and bottom 4-bits represent foreground color from standard VGA text palette (ANSI escape codes).`
  1646. // _format : ``printf` style format.`
  1647. extern fn void dbg_text_printf(ushort _x, ushort _y, char _attr, ZString _format, ... ) @extern("bgfx_dbg_text_printf");
  1648. // Print formatted data from variable argument list to internal debug text character-buffer (VGA-compatible text mode).
  1649. // _x : `Position x from the left corner of the window.`
  1650. // _y : `Position y from the top corner of the window.`
  1651. // _attr : `Color palette. Where top 4-bits represent index of background, and bottom 4-bits represent foreground color from standard VGA text palette (ANSI escape codes).`
  1652. // _format : ``printf` style format.`
  1653. // _argList : `Variable arguments list for format string.`
  1654. extern fn void dbg_text_vprintf(ushort _x, ushort _y, char _attr, ZString _format, void* _argList) @extern("bgfx_dbg_text_vprintf");
  1655. // Draw image into internal debug text buffer.
  1656. // _x : `Position x from the left corner of the window.`
  1657. // _y : `Position y from the top corner of the window.`
  1658. // _width : `Image width.`
  1659. // _height : `Image height.`
  1660. // _data : `Raw image data (character/attribute raw encoding).`
  1661. // _pitch : `Image pitch in bytes.`
  1662. extern fn void dbg_text_image(ushort _x, ushort _y, ushort _width, ushort _height, void* _data, ushort _pitch) @extern("bgfx_dbg_text_image");
  1663. // Create static index buffer.
  1664. // _mem : `Index buffer data.`
  1665. // _flags : `Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.`
  1666. extern fn IndexBufferHandle create_index_buffer(Memory* _mem, ushort _flags) @extern("bgfx_create_index_buffer");
  1667. // Set static index buffer debug name.
  1668. // _handle : `Static index buffer handle.`
  1669. // _name : `Static index buffer name.`
  1670. // _len : `Static index buffer name length (if length is INT32_MAX, it's expected that _name is zero terminated string.`
  1671. extern fn void set_index_buffer_name(IndexBufferHandle _handle, ZString _name, int _len) @extern("bgfx_set_index_buffer_name");
  1672. // Destroy static index buffer.
  1673. // _handle : `Static index buffer handle.`
  1674. extern fn void destroy_index_buffer(IndexBufferHandle _handle) @extern("bgfx_destroy_index_buffer");
  1675. // Create vertex layout.
  1676. // _layout : `Vertex layout.`
  1677. extern fn VertexLayoutHandle create_vertex_layout(VertexLayout* _layout) @extern("bgfx_create_vertex_layout");
  1678. // Destroy vertex layout.
  1679. // _layoutHandle : `Vertex layout handle.`
  1680. extern fn void destroy_vertex_layout(VertexLayoutHandle _layoutHandle) @extern("bgfx_destroy_vertex_layout");
  1681. // Create static vertex buffer.
  1682. // _mem : `Vertex buffer data.`
  1683. // _layout : `Vertex layout.`
  1684. // _flags : `Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.`
  1685. extern fn VertexBufferHandle create_vertex_buffer(Memory* _mem, VertexLayout* _layout, ushort _flags) @extern("bgfx_create_vertex_buffer");
  1686. // Set static vertex buffer debug name.
  1687. // _handle : `Static vertex buffer handle.`
  1688. // _name : `Static vertex buffer name.`
  1689. // _len : `Static vertex buffer name length (if length is INT32_MAX, it's expected that _name is zero terminated string.`
  1690. extern fn void set_vertex_buffer_name(VertexBufferHandle _handle, ZString _name, int _len) @extern("bgfx_set_vertex_buffer_name");
  1691. // Destroy static vertex buffer.
  1692. // _handle : `Static vertex buffer handle.`
  1693. extern fn void destroy_vertex_buffer(VertexBufferHandle _handle) @extern("bgfx_destroy_vertex_buffer");
  1694. // Create empty dynamic index buffer.
  1695. // _num : `Number of indices.`
  1696. // _flags : `Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.`
  1697. extern fn DynamicIndexBufferHandle create_dynamic_index_buffer(uint _num, ushort _flags) @extern("bgfx_create_dynamic_index_buffer");
  1698. // Create a dynamic index buffer and initialize it.
  1699. // _mem : `Index buffer data.`
  1700. // _flags : `Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.`
  1701. extern fn DynamicIndexBufferHandle create_dynamic_index_buffer_mem(Memory* _mem, ushort _flags) @extern("bgfx_create_dynamic_index_buffer_mem");
  1702. // Update dynamic index buffer.
  1703. // _handle : `Dynamic index buffer handle.`
  1704. // _startIndex : `Start index.`
  1705. // _mem : `Index buffer data.`
  1706. extern fn void update_dynamic_index_buffer(DynamicIndexBufferHandle _handle, uint _startIndex, Memory* _mem) @extern("bgfx_update_dynamic_index_buffer");
  1707. // Destroy dynamic index buffer.
  1708. // _handle : `Dynamic index buffer handle.`
  1709. extern fn void destroy_dynamic_index_buffer(DynamicIndexBufferHandle _handle) @extern("bgfx_destroy_dynamic_index_buffer");
  1710. // Create empty dynamic vertex buffer.
  1711. // _num : `Number of vertices.`
  1712. // _layout : `Vertex layout.`
  1713. // _flags : `Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.`
  1714. extern fn DynamicVertexBufferHandle create_dynamic_vertex_buffer(uint _num, VertexLayout* _layout, ushort _flags) @extern("bgfx_create_dynamic_vertex_buffer");
  1715. // Create dynamic vertex buffer and initialize it.
  1716. // _mem : `Vertex buffer data.`
  1717. // _layout : `Vertex layout.`
  1718. // _flags : `Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.`
  1719. extern fn DynamicVertexBufferHandle create_dynamic_vertex_buffer_mem(Memory* _mem, VertexLayout* _layout, ushort _flags) @extern("bgfx_create_dynamic_vertex_buffer_mem");
  1720. // Update dynamic vertex buffer.
  1721. // _handle : `Dynamic vertex buffer handle.`
  1722. // _startVertex : `Start vertex.`
  1723. // _mem : `Vertex buffer data.`
  1724. extern fn void update_dynamic_vertex_buffer(DynamicVertexBufferHandle _handle, uint _startVertex, Memory* _mem) @extern("bgfx_update_dynamic_vertex_buffer");
  1725. // Destroy dynamic vertex buffer.
  1726. // _handle : `Dynamic vertex buffer handle.`
  1727. extern fn void destroy_dynamic_vertex_buffer(DynamicVertexBufferHandle _handle) @extern("bgfx_destroy_dynamic_vertex_buffer");
  1728. // Returns number of requested or maximum available indices.
  1729. // _num : `Number of required indices.`
  1730. // _index32 : `Set to `true` if input indices will be 32-bit.`
  1731. extern fn uint get_avail_transient_index_buffer(uint _num, bool _index32) @extern("bgfx_get_avail_transient_index_buffer");
  1732. // Returns number of requested or maximum available vertices.
  1733. // _num : `Number of required vertices.`
  1734. // _layout : `Vertex layout.`
  1735. extern fn uint get_avail_transient_vertex_buffer(uint _num, VertexLayout* _layout) @extern("bgfx_get_avail_transient_vertex_buffer");
  1736. // Returns number of requested or maximum available instance buffer slots.
  1737. // _num : `Number of required instances.`
  1738. // _stride : `Stride per instance.`
  1739. extern fn uint get_avail_instance_data_buffer(uint _num, ushort _stride) @extern("bgfx_get_avail_instance_data_buffer");
  1740. // Allocate transient index buffer.
  1741. // _tib : `TransientIndexBuffer structure will be filled, and will be valid for the duration of frame, and can be reused for multiple draw calls.`
  1742. // _num : `Number of indices to allocate.`
  1743. // _index32 : `Set to `true` if input indices will be 32-bit.`
  1744. extern fn void alloc_transient_index_buffer(TransientIndexBuffer* _tib, uint _num, bool _index32) @extern("bgfx_alloc_transient_index_buffer");
  1745. // Allocate transient vertex buffer.
  1746. // _tvb : `TransientVertexBuffer structure will be filled, and will be valid for the duration of frame, and can be reused for multiple draw calls.`
  1747. // _num : `Number of vertices to allocate.`
  1748. // _layout : `Vertex layout.`
  1749. extern fn void alloc_transient_vertex_buffer(TransientVertexBuffer* _tvb, uint _num, VertexLayout* _layout) @extern("bgfx_alloc_transient_vertex_buffer");
  1750. // Check for required space and allocate transient vertex and index
  1751. // buffers. If both space requirements are satisfied function returns
  1752. // true.
  1753. // _tvb : `TransientVertexBuffer structure will be filled, and will be valid for the duration of frame, and can be reused for multiple draw calls.`
  1754. // _layout : `Vertex layout.`
  1755. // _numVertices : `Number of vertices to allocate.`
  1756. // _tib : `TransientIndexBuffer structure will be filled, and will be valid for the duration of frame, and can be reused for multiple draw calls.`
  1757. // _numIndices : `Number of indices to allocate.`
  1758. // _index32 : `Set to `true` if input indices will be 32-bit.`
  1759. extern fn bool alloc_transient_buffers(TransientVertexBuffer* _tvb, VertexLayout* _layout, uint _numVertices, TransientIndexBuffer* _tib, uint _numIndices, bool _index32) @extern("bgfx_alloc_transient_buffers");
  1760. // Allocate instance data buffer.
  1761. // _idb : `InstanceDataBuffer structure will be filled, and will be valid for duration of frame, and can be reused for multiple draw calls.`
  1762. // _num : `Number of instances.`
  1763. // _stride : `Instance stride. Must be multiple of 16.`
  1764. extern fn void alloc_instance_data_buffer(InstanceDataBuffer* _idb, uint _num, ushort _stride) @extern("bgfx_alloc_instance_data_buffer");
  1765. // Create draw indirect buffer.
  1766. // _num : `Number of indirect calls.`
  1767. extern fn IndirectBufferHandle create_indirect_buffer(uint _num) @extern("bgfx_create_indirect_buffer");
  1768. // Destroy draw indirect buffer.
  1769. // _handle : `Indirect buffer handle.`
  1770. extern fn void destroy_indirect_buffer(IndirectBufferHandle _handle) @extern("bgfx_destroy_indirect_buffer");
  1771. // Create shader from memory buffer.
  1772. // @remarks
  1773. // Shader binary is obtained by compiling shader offline with shaderc command line tool.
  1774. // _mem : `Shader binary.`
  1775. extern fn ShaderHandle create_shader(Memory* _mem) @extern("bgfx_create_shader");
  1776. // Returns the number of uniforms and uniform handles used inside a shader.
  1777. // @remarks
  1778. // Only non-predefined uniforms are returned.
  1779. // _handle : `Shader handle.`
  1780. // _uniforms : `UniformHandle array where data will be stored.`
  1781. // _max : `Maximum capacity of array.`
  1782. extern fn ushort get_shader_uniforms(ShaderHandle _handle, UniformHandle* _uniforms, ushort _max) @extern("bgfx_get_shader_uniforms");
  1783. // Set shader debug name.
  1784. // _handle : `Shader handle.`
  1785. // _name : `Shader name.`
  1786. // _len : `Shader name length (if length is INT32_MAX, it's expected that _name is zero terminated string).`
  1787. extern fn void set_shader_name(ShaderHandle _handle, ZString _name, int _len) @extern("bgfx_set_shader_name");
  1788. // Destroy shader.
  1789. // @remark Once a shader program is created with _handle,
  1790. // it is safe to destroy that shader.
  1791. // _handle : `Shader handle.`
  1792. extern fn void destroy_shader(ShaderHandle _handle) @extern("bgfx_destroy_shader");
  1793. // Create program with vertex and fragment shaders.
  1794. // _vsh : `Vertex shader.`
  1795. // _fsh : `Fragment shader.`
  1796. // _destroyShaders : `If true, shaders will be destroyed when program is destroyed.`
  1797. extern fn ProgramHandle create_program(ShaderHandle _vsh, ShaderHandle _fsh, bool _destroyShaders) @extern("bgfx_create_program");
  1798. // Create program with compute shader.
  1799. // _csh : `Compute shader.`
  1800. // _destroyShaders : `If true, shaders will be destroyed when program is destroyed.`
  1801. extern fn ProgramHandle create_compute_program(ShaderHandle _csh, bool _destroyShaders) @extern("bgfx_create_compute_program");
  1802. // Destroy program.
  1803. // _handle : `Program handle.`
  1804. extern fn void destroy_program(ProgramHandle _handle) @extern("bgfx_destroy_program");
  1805. // Validate texture parameters.
  1806. // _depth : `Depth dimension of volume texture.`
  1807. // _cubeMap : `Indicates that texture contains cubemap.`
  1808. // _numLayers : `Number of layers in texture array.`
  1809. // _format : `Texture format. See: `TextureFormat::Enum`.`
  1810. // _flags : `Texture flags. See `BGFX_TEXTURE_*`.`
  1811. extern fn bool is_texture_valid(ushort _depth, bool _cubeMap, ushort _numLayers, TextureFormat _format, ulong _flags) @extern("bgfx_is_texture_valid");
  1812. // Validate frame buffer parameters.
  1813. // _num : `Number of attachments.`
  1814. // _attachment : `Attachment texture info. See: `bgfx::Attachment`.`
  1815. extern fn bool is_frame_buffer_valid(char _num, Attachment* _attachment) @extern("bgfx_is_frame_buffer_valid");
  1816. // Calculate amount of memory required for texture.
  1817. // _info : `Resulting texture info structure. See: `TextureInfo`.`
  1818. // _width : `Width.`
  1819. // _height : `Height.`
  1820. // _depth : `Depth dimension of volume texture.`
  1821. // _cubeMap : `Indicates that texture contains cubemap.`
  1822. // _hasMips : `Indicates that texture contains full mip-map chain.`
  1823. // _numLayers : `Number of layers in texture array.`
  1824. // _format : `Texture format. See: `TextureFormat::Enum`.`
  1825. extern fn void calc_texture_size(TextureInfo* _info, ushort _width, ushort _height, ushort _depth, bool _cubeMap, bool _hasMips, ushort _numLayers, TextureFormat _format) @extern("bgfx_calc_texture_size");
  1826. // Create texture from memory buffer.
  1827. // _mem : `DDS, KTX or PVR texture binary data.`
  1828. // _flags : `Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
  1829. // _skip : `Skip top level mips when parsing texture.`
  1830. // _info : `When non-`NULL` is specified it returns parsed texture information.`
  1831. extern fn TextureHandle create_texture(Memory* _mem, ulong _flags, char _skip, TextureInfo* _info) @extern("bgfx_create_texture");
  1832. // Create 2D texture.
  1833. // _width : `Width.`
  1834. // _height : `Height.`
  1835. // _hasMips : `Indicates that texture contains full mip-map chain.`
  1836. // _numLayers : `Number of layers in texture array. Must be 1 if caps `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.`
  1837. // _format : `Texture format. See: `TextureFormat::Enum`.`
  1838. // _flags : `Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
  1839. // _mem : `Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.`
  1840. extern fn TextureHandle create_texture_2d(ushort _width, ushort _height, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem) @extern("bgfx_create_texture_2d");
  1841. // Create texture with size based on back-buffer ratio. Texture will maintain ratio
  1842. // if back buffer resolution changes.
  1843. // _ratio : `Texture size in respect to back-buffer size. See: `BackbufferRatio::Enum`.`
  1844. // _hasMips : `Indicates that texture contains full mip-map chain.`
  1845. // _numLayers : `Number of layers in texture array. Must be 1 if caps `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.`
  1846. // _format : `Texture format. See: `TextureFormat::Enum`.`
  1847. // _flags : `Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
  1848. extern fn TextureHandle create_texture_2d_scaled(BackbufferRatio _ratio, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags) @extern("bgfx_create_texture_2d_scaled");
  1849. // Create 3D texture.
  1850. // _width : `Width.`
  1851. // _height : `Height.`
  1852. // _depth : `Depth.`
  1853. // _hasMips : `Indicates that texture contains full mip-map chain.`
  1854. // _format : `Texture format. See: `TextureFormat::Enum`.`
  1855. // _flags : `Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
  1856. // _mem : `Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.`
  1857. extern fn TextureHandle create_texture_3d(ushort _width, ushort _height, ushort _depth, bool _hasMips, TextureFormat _format, ulong _flags, Memory* _mem) @extern("bgfx_create_texture_3d");
  1858. // Create Cube texture.
  1859. // _size : `Cube side size.`
  1860. // _hasMips : `Indicates that texture contains full mip-map chain.`
  1861. // _numLayers : `Number of layers in texture array. Must be 1 if caps `BGFX_CAPS_TEXTURE_2D_ARRAY` flag is not set.`
  1862. // _format : `Texture format. See: `TextureFormat::Enum`.`
  1863. // _flags : `Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
  1864. // _mem : `Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.`
  1865. extern fn TextureHandle create_texture_cube(ushort _size, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem) @extern("bgfx_create_texture_cube");
  1866. // Update 2D texture.
  1867. // @attention It's valid to update only mutable texture. See `bgfx::createTexture2D` for more info.
  1868. // _handle : `Texture handle.`
  1869. // _layer : `Layer in texture array.`
  1870. // _mip : `Mip level.`
  1871. // _x : `X offset in texture.`
  1872. // _y : `Y offset in texture.`
  1873. // _width : `Width of texture block.`
  1874. // _height : `Height of texture block.`
  1875. // _mem : `Texture update data.`
  1876. // _pitch : `Pitch of input image (bytes). When _pitch is set to UINT16_MAX, it will be calculated internally based on _width.`
  1877. extern fn void update_texture_2d(TextureHandle _handle, ushort _layer, char _mip, ushort _x, ushort _y, ushort _width, ushort _height, Memory* _mem, ushort _pitch) @extern("bgfx_update_texture_2d");
  1878. // Update 3D texture.
  1879. // @attention It's valid to update only mutable texture. See `bgfx::createTexture3D` for more info.
  1880. // _handle : `Texture handle.`
  1881. // _mip : `Mip level.`
  1882. // _x : `X offset in texture.`
  1883. // _y : `Y offset in texture.`
  1884. // _z : `Z offset in texture.`
  1885. // _width : `Width of texture block.`
  1886. // _height : `Height of texture block.`
  1887. // _depth : `Depth of texture block.`
  1888. // _mem : `Texture update data.`
  1889. extern fn void update_texture_3d(TextureHandle _handle, char _mip, ushort _x, ushort _y, ushort _z, ushort _width, ushort _height, ushort _depth, Memory* _mem) @extern("bgfx_update_texture_3d");
  1890. // Update Cube texture.
  1891. // @attention It's valid to update only mutable texture. See `bgfx::createTextureCube` for more info.
  1892. // _handle : `Texture handle.`
  1893. // _layer : `Layer in texture array.`
  1894. // _side : `Cubemap side `BGFX_CUBE_MAP_<POSITIVE or NEGATIVE>_<X, Y or Z>`, where 0 is +X, 1 is -X, 2 is +Y, 3 is -Y, 4 is +Z, and 5 is -Z. +----------+ |-z 2| | ^ +y | | | | Unfolded cube: | +---->+x | +----------+----------+----------+----------+ |+y 1|+y 4|+y 0|+y 5| | ^ -x | ^ +z | ^ +x | ^ -z | | | | | | | | | | | +---->+z | +---->+x | +---->-z | +---->-x | +----------+----------+----------+----------+ |+z 3| | ^ -y | | | | | +---->+x | +----------+`
  1895. // _mip : `Mip level.`
  1896. // _x : `X offset in texture.`
  1897. // _y : `Y offset in texture.`
  1898. // _width : `Width of texture block.`
  1899. // _height : `Height of texture block.`
  1900. // _mem : `Texture update data.`
  1901. // _pitch : `Pitch of input image (bytes). When _pitch is set to UINT16_MAX, it will be calculated internally based on _width.`
  1902. extern fn void update_texture_cube(TextureHandle _handle, ushort _layer, char _side, char _mip, ushort _x, ushort _y, ushort _width, ushort _height, Memory* _mem, ushort _pitch) @extern("bgfx_update_texture_cube");
  1903. // Read back texture content.
  1904. // @attention Texture must be created with `BGFX_TEXTURE_READ_BACK` flag.
  1905. // @attention Availability depends on: `BGFX_CAPS_TEXTURE_READ_BACK`.
  1906. // _handle : `Texture handle.`
  1907. // _data : `Destination buffer.`
  1908. // _mip : `Mip level.`
  1909. extern fn uint read_texture(TextureHandle _handle, void* _data, char _mip) @extern("bgfx_read_texture");
  1910. // Set texture debug name.
  1911. // _handle : `Texture handle.`
  1912. // _name : `Texture name.`
  1913. // _len : `Texture name length (if length is INT32_MAX, it's expected that _name is zero terminated string.`
  1914. extern fn void set_texture_name(TextureHandle _handle, ZString _name, int _len) @extern("bgfx_set_texture_name");
  1915. // Returns texture direct access pointer.
  1916. // @attention Availability depends on: `BGFX_CAPS_TEXTURE_DIRECT_ACCESS`. This feature
  1917. // is available on GPUs that have unified memory architecture (UMA) support.
  1918. // _handle : `Texture handle.`
  1919. extern fn void* get_direct_access_ptr(TextureHandle _handle) @extern("bgfx_get_direct_access_ptr");
  1920. // Destroy texture.
  1921. // _handle : `Texture handle.`
  1922. extern fn void destroy_texture(TextureHandle _handle) @extern("bgfx_destroy_texture");
  1923. // Create frame buffer (simple).
  1924. // _width : `Texture width.`
  1925. // _height : `Texture height.`
  1926. // _format : `Texture format. See: `TextureFormat::Enum`.`
  1927. // _textureFlags : `Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
  1928. extern fn FrameBufferHandle create_frame_buffer(ushort _width, ushort _height, TextureFormat _format, ulong _textureFlags) @extern("bgfx_create_frame_buffer");
  1929. // Create frame buffer with size based on back-buffer ratio. Frame buffer will maintain ratio
  1930. // if back buffer resolution changes.
  1931. // _ratio : `Frame buffer size in respect to back-buffer size. See: `BackbufferRatio::Enum`.`
  1932. // _format : `Texture format. See: `TextureFormat::Enum`.`
  1933. // _textureFlags : `Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
  1934. extern fn FrameBufferHandle create_frame_buffer_scaled(BackbufferRatio _ratio, TextureFormat _format, ulong _textureFlags) @extern("bgfx_create_frame_buffer_scaled");
  1935. // Create MRT frame buffer from texture handles (simple).
  1936. // _num : `Number of texture handles.`
  1937. // _handles : `Texture attachments.`
  1938. // _destroyTexture : `If true, textures will be destroyed when frame buffer is destroyed.`
  1939. extern fn FrameBufferHandle create_frame_buffer_from_handles(char _num, TextureHandle* _handles, bool _destroyTexture) @extern("bgfx_create_frame_buffer_from_handles");
  1940. // Create MRT frame buffer from texture handles with specific layer and
  1941. // mip level.
  1942. // _num : `Number of attachments.`
  1943. // _attachment : `Attachment texture info. See: `bgfx::Attachment`.`
  1944. // _destroyTexture : `If true, textures will be destroyed when frame buffer is destroyed.`
  1945. extern fn FrameBufferHandle create_frame_buffer_from_attachment(char _num, Attachment* _attachment, bool _destroyTexture) @extern("bgfx_create_frame_buffer_from_attachment");
  1946. // Create frame buffer for multiple window rendering.
  1947. // @remarks
  1948. // Frame buffer cannot be used for sampling.
  1949. // @attention Availability depends on: `BGFX_CAPS_SWAP_CHAIN`.
  1950. // _nwh : `OS' target native window handle.`
  1951. // _width : `Window back buffer width.`
  1952. // _height : `Window back buffer height.`
  1953. // _format : `Window back buffer color format.`
  1954. // _depthFormat : `Window back buffer depth format.`
  1955. extern fn FrameBufferHandle create_frame_buffer_from_nwh(void* _nwh, ushort _width, ushort _height, TextureFormat _format, TextureFormat _depthFormat) @extern("bgfx_create_frame_buffer_from_nwh");
  1956. // Set frame buffer debug name.
  1957. // _handle : `Frame buffer handle.`
  1958. // _name : `Frame buffer name.`
  1959. // _len : `Frame buffer name length (if length is INT32_MAX, it's expected that _name is zero terminated string.`
  1960. extern fn void set_frame_buffer_name(FrameBufferHandle _handle, ZString _name, int _len) @extern("bgfx_set_frame_buffer_name");
  1961. // Obtain texture handle of frame buffer attachment.
  1962. // _handle : `Frame buffer handle.`
  1963. extern fn TextureHandle get_texture(FrameBufferHandle _handle, char _attachment) @extern("bgfx_get_texture");
  1964. // Destroy frame buffer.
  1965. // _handle : `Frame buffer handle.`
  1966. extern fn void destroy_frame_buffer(FrameBufferHandle _handle) @extern("bgfx_destroy_frame_buffer");
  1967. // Create shader uniform parameter.
  1968. // @remarks
  1969. // 1. Uniform names are unique. It's valid to call `bgfx::createUniform`
  1970. // multiple times with the same uniform name. The library will always
  1971. // return the same handle, but the handle reference count will be
  1972. // incremented. This means that the same number of `bgfx::destroyUniform`
  1973. // must be called to properly destroy the uniform.
  1974. // 2. Predefined uniforms (declared in `bgfx_shader.sh`):
  1975. // - `u_viewRect vec4(x, y, width, height)` - view rectangle for current
  1976. // view, in pixels.
  1977. // - `u_viewTexel vec4(1.0/width, 1.0/height, undef, undef)` - inverse
  1978. // width and height
  1979. // - `u_view mat4` - view matrix
  1980. // - `u_invView mat4` - inverted view matrix
  1981. // - `u_proj mat4` - projection matrix
  1982. // - `u_invProj mat4` - inverted projection matrix
  1983. // - `u_viewProj mat4` - concatenated view projection matrix
  1984. // - `u_invViewProj mat4` - concatenated inverted view projection matrix
  1985. // - `u_model mat4[BGFX_CONFIG_MAX_BONES]` - array of model matrices.
  1986. // - `u_modelView mat4` - concatenated model view matrix, only first
  1987. // model matrix from array is used.
  1988. // - `u_invModelView mat4` - inverted concatenated model view matrix.
  1989. // - `u_modelViewProj mat4` - concatenated model view projection matrix.
  1990. // - `u_alphaRef float` - alpha reference value for alpha test.
  1991. // _name : `Uniform name in shader.`
  1992. // _type : `Type of uniform (See: `bgfx::UniformType`).`
  1993. // _num : `Number of elements in array.`
  1994. extern fn UniformHandle create_uniform(ZString _name, UniformType _type, ushort _num) @extern("bgfx_create_uniform");
  1995. // Create shader uniform parameter.
  1996. // @remarks
  1997. // 1. Uniform names are unique. It's valid to call `bgfx::createUniform`
  1998. // multiple times with the same uniform name. The library will always
  1999. // return the same handle, but the handle reference count will be
  2000. // incremented. This means that the same number of `bgfx::destroyUniform`
  2001. // must be called to properly destroy the uniform.
  2002. // 2. Predefined uniforms (declared in `bgfx_shader.sh`):
  2003. // - `u_viewRect vec4(x, y, width, height)` - view rectangle for current
  2004. // view, in pixels.
  2005. // - `u_viewTexel vec4(1.0/width, 1.0/height, undef, undef)` - inverse
  2006. // width and height
  2007. // - `u_view mat4` - view matrix
  2008. // - `u_invView mat4` - inverted view matrix
  2009. // - `u_proj mat4` - projection matrix
  2010. // - `u_invProj mat4` - inverted projection matrix
  2011. // - `u_viewProj mat4` - concatenated view projection matrix
  2012. // - `u_invViewProj mat4` - concatenated inverted view projection matrix
  2013. // - `u_model mat4[BGFX_CONFIG_MAX_BONES]` - array of model matrices.
  2014. // - `u_modelView mat4` - concatenated model view matrix, only first
  2015. // model matrix from array is used.
  2016. // - `u_invModelView mat4` - inverted concatenated model view matrix.
  2017. // - `u_modelViewProj mat4` - concatenated model view projection matrix.
  2018. // - `u_alphaRef float` - alpha reference value for alpha test.
  2019. // _name : `Uniform name in shader.`
  2020. // _freq : `Uniform change frequency (See: `bgfx::UniformFreq`).`
  2021. // _type : `Type of uniform (See: `bgfx::UniformType`).`
  2022. // _num : `Number of elements in array.`
  2023. extern fn UniformHandle create_uniform_with_freq(ZString _name, UniformFreq _freq, UniformType _type, ushort _num) @extern("bgfx_create_uniform_with_freq");
  2024. // Retrieve uniform info.
  2025. // _handle : `Handle to uniform object.`
  2026. // _info : `Uniform info.`
  2027. extern fn void get_uniform_info(UniformHandle _handle, UniformInfo* _info) @extern("bgfx_get_uniform_info");
  2028. // Destroy shader uniform parameter.
  2029. // _handle : `Handle to uniform object.`
  2030. extern fn void destroy_uniform(UniformHandle _handle) @extern("bgfx_destroy_uniform");
  2031. // Create occlusion query.
  2032. extern fn OcclusionQueryHandle create_occlusion_query() @extern("bgfx_create_occlusion_query");
  2033. // Retrieve occlusion query result from previous frame.
  2034. // _handle : `Handle to occlusion query object.`
  2035. // _result : `Number of pixels that passed test. This argument can be `NULL` if result of occlusion query is not needed.`
  2036. extern fn OcclusionQueryResult get_result(OcclusionQueryHandle _handle, int* _result) @extern("bgfx_get_result");
  2037. // Destroy occlusion query.
  2038. // _handle : `Handle to occlusion query object.`
  2039. extern fn void destroy_occlusion_query(OcclusionQueryHandle _handle) @extern("bgfx_destroy_occlusion_query");
  2040. // Set palette color value.
  2041. // _index : `Index into palette.`
  2042. // _rgba : `RGBA floating point values.`
  2043. extern fn void set_palette_color(char _index, float _rgba) @extern("bgfx_set_palette_color");
  2044. // Set palette color value.
  2045. // _index : `Index into palette.`
  2046. // _r : `Red value (RGBA floating point values)`
  2047. // _g : `Green value (RGBA floating point values)`
  2048. // _b : `Blue value (RGBA floating point values)`
  2049. // _a : `Alpha value (RGBA floating point values)`
  2050. extern fn void set_palette_color_rgba32f(char _index, float _r, float _g, float _b, float _a) @extern("bgfx_set_palette_color_rgba32f");
  2051. // Set palette color value.
  2052. // _index : `Index into palette.`
  2053. // _rgba : `Packed 32-bit RGBA value.`
  2054. extern fn void set_palette_color_rgba8(char _index, uint _rgba) @extern("bgfx_set_palette_color_rgba8");
  2055. // Set view name.
  2056. // @remarks
  2057. // This is debug only feature.
  2058. // In graphics debugger view name will appear as:
  2059. // "nnnc <view name>"
  2060. // ^ ^ ^
  2061. // | +--- compute (C)
  2062. // +------ view id
  2063. // _id : `View id.`
  2064. // _name : `View name.`
  2065. // _len : `View name length (if length is INT32_MAX, it's expected that _name is zero terminated string.`
  2066. extern fn void set_view_name(ushort _id, ZString _name, int _len) @extern("bgfx_set_view_name");
  2067. // Set view rectangle. Draw primitive outside view will be clipped.
  2068. // _id : `View id.`
  2069. // _x : `Position x from the left corner of the window.`
  2070. // _y : `Position y from the top corner of the window.`
  2071. // _width : `Width of view port region.`
  2072. // _height : `Height of view port region.`
  2073. extern fn void set_view_rect(ushort _id, ushort _x, ushort _y, ushort _width, ushort _height) @extern("bgfx_set_view_rect");
  2074. // Set view rectangle. Draw primitive outside view will be clipped.
  2075. // _id : `View id.`
  2076. // _x : `Position x from the left corner of the window.`
  2077. // _y : `Position y from the top corner of the window.`
  2078. // _ratio : `Width and height will be set in respect to back-buffer size. See: `BackbufferRatio::Enum`.`
  2079. extern fn void set_view_rect_ratio(ushort _id, ushort _x, ushort _y, BackbufferRatio _ratio) @extern("bgfx_set_view_rect_ratio");
  2080. // Set view scissor. Draw primitive outside view will be clipped. When
  2081. // _x, _y, _width and _height are set to 0, scissor will be disabled.
  2082. // _id : `View id.`
  2083. // _x : `Position x from the left corner of the window.`
  2084. // _y : `Position y from the top corner of the window.`
  2085. // _width : `Width of view scissor region.`
  2086. // _height : `Height of view scissor region.`
  2087. extern fn void set_view_scissor(ushort _id, ushort _x, ushort _y, ushort _width, ushort _height) @extern("bgfx_set_view_scissor");
  2088. // Set view clear flags.
  2089. // _id : `View id.`
  2090. // _flags : `Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear operation. See: `BGFX_CLEAR_*`.`
  2091. // _rgba : `Color clear value.`
  2092. // _depth : `Depth clear value.`
  2093. // _stencil : `Stencil clear value.`
  2094. extern fn void set_view_clear(ushort _id, ushort _flags, uint _rgba, float _depth, char _stencil) @extern("bgfx_set_view_clear");
  2095. // Set view clear flags with different clear color for each
  2096. // frame buffer texture. `bgfx::setPaletteColor` must be used to set up a
  2097. // clear color palette.
  2098. // _id : `View id.`
  2099. // _flags : `Clear flags. Use `BGFX_CLEAR_NONE` to remove any clear operation. See: `BGFX_CLEAR_*`.`
  2100. // _depth : `Depth clear value.`
  2101. // _stencil : `Stencil clear value.`
  2102. // _c0 : `Palette index for frame buffer attachment 0.`
  2103. // _c1 : `Palette index for frame buffer attachment 1.`
  2104. // _c2 : `Palette index for frame buffer attachment 2.`
  2105. // _c3 : `Palette index for frame buffer attachment 3.`
  2106. // _c4 : `Palette index for frame buffer attachment 4.`
  2107. // _c5 : `Palette index for frame buffer attachment 5.`
  2108. // _c6 : `Palette index for frame buffer attachment 6.`
  2109. // _c7 : `Palette index for frame buffer attachment 7.`
  2110. extern fn void set_view_clear_mrt(ushort _id, ushort _flags, float _depth, char _stencil, char _c0, char _c1, char _c2, char _c3, char _c4, char _c5, char _c6, char _c7) @extern("bgfx_set_view_clear_mrt");
  2111. // Set view sorting mode.
  2112. // @remarks
  2113. // View mode must be set prior calling `bgfx::submit` for the view.
  2114. // _id : `View id.`
  2115. // _mode : `View sort mode. See `ViewMode::Enum`.`
  2116. extern fn void set_view_mode(ushort _id, ViewMode _mode) @extern("bgfx_set_view_mode");
  2117. // Set view frame buffer.
  2118. // @remarks
  2119. // Not persistent after `bgfx::reset` call.
  2120. // _id : `View id.`
  2121. // _handle : `Frame buffer handle. Passing `BGFX_INVALID_HANDLE` as frame buffer handle will draw primitives from this view into default back buffer.`
  2122. extern fn void set_view_frame_buffer(ushort _id, FrameBufferHandle _handle) @extern("bgfx_set_view_frame_buffer");
  2123. // Set view's view matrix and projection matrix,
  2124. // all draw primitives in this view will use these two matrices.
  2125. // _id : `View id.`
  2126. // _view : `View matrix.`
  2127. // _proj : `Projection matrix.`
  2128. extern fn void set_view_transform(ushort _id, void* _view, void* _proj) @extern("bgfx_set_view_transform");
  2129. // Post submit view reordering.
  2130. // _id : `First view id.`
  2131. // _num : `Number of views to remap.`
  2132. // _order : `View remap id table. Passing `NULL` will reset view ids to default state.`
  2133. extern fn void set_view_order(ushort _id, ushort _num, ushort* _order) @extern("bgfx_set_view_order");
  2134. // Set view shading rate.
  2135. // @attention Availability depends on: `BGFX_CAPS_VARIABLE_RATE_SHADING`.
  2136. // _id : `View id.`
  2137. // _shadingRate : `Shading rate.`
  2138. extern fn void set_view_shading_rate(ushort _id, ShadingRate _shadingRate) @extern("bgfx_set_view_shading_rate");
  2139. // Reset all view settings to default.
  2140. // _id : `_id View id.`
  2141. extern fn void reset_view(ushort _id) @extern("bgfx_reset_view");
  2142. // Begin submitting draw calls from thread.
  2143. // _forThread : `Explicitly request an encoder for a worker thread.`
  2144. extern fn Encoder* encoder_begin(bool _forThread) @extern("bgfx_encoder_begin");
  2145. // End submitting draw calls from thread.
  2146. // _encoder : `Encoder.`
  2147. extern fn void encoder_end(Encoder* _encoder) @extern("bgfx_encoder_end");
  2148. // Sets a debug marker. This allows you to group graphics calls together for easy browsing in
  2149. // graphics debugging tools.
  2150. // _name : `Marker name.`
  2151. // _len : `Marker name length (if length is INT32_MAX, it's expected that _name is zero terminated string.`
  2152. extern fn void encoder_set_marker(Encoder* _this, ZString _name, int _len) @extern("bgfx_encoder_set_marker");
  2153. // Set render states for draw primitive.
  2154. // @remarks
  2155. // 1. To set up more complex states use:
  2156. // `BGFX_STATE_ALPHA_REF(_ref)`,
  2157. // `BGFX_STATE_POINT_SIZE(_size)`,
  2158. // `BGFX_STATE_BLEND_FUNC(_src, _dst)`,
  2159. // `BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA)`,
  2160. // `BGFX_STATE_BLEND_EQUATION(_equation)`,
  2161. // `BGFX_STATE_BLEND_EQUATION_SEPARATE(_equationRGB, _equationA)`
  2162. // 2. `BGFX_STATE_BLEND_EQUATION_ADD` is set when no other blend
  2163. // equation is specified.
  2164. // _state : `State flags. Default state for primitive type is triangles. See: `BGFX_STATE_DEFAULT`. - `BGFX_STATE_DEPTH_TEST_*` - Depth test function. - `BGFX_STATE_BLEND_*` - See remark 1 about BGFX_STATE_BLEND_FUNC. - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2. - `BGFX_STATE_CULL_*` - Backface culling mode. - `BGFX_STATE_WRITE_*` - Enable R, G, B, A or Z write. - `BGFX_STATE_MSAA` - Enable hardware multisample antialiasing. - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type.`
  2165. // _rgba : `Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and `BGFX_STATE_BLEND_INV_FACTOR` blend modes.`
  2166. extern fn void encoder_set_state(Encoder* _this, ulong _state, uint _rgba) @extern("bgfx_encoder_set_state");
  2167. // Set condition for rendering.
  2168. // _handle : `Occlusion query handle.`
  2169. // _visible : `Render if occlusion query is visible.`
  2170. extern fn void encoder_set_condition(Encoder* _this, OcclusionQueryHandle _handle, bool _visible) @extern("bgfx_encoder_set_condition");
  2171. // Set stencil test state.
  2172. // _fstencil : `Front stencil state.`
  2173. // _bstencil : `Back stencil state. If back is set to `BGFX_STENCIL_NONE` _fstencil is applied to both front and back facing primitives.`
  2174. extern fn void encoder_set_stencil(Encoder* _this, uint _fstencil, uint _bstencil) @extern("bgfx_encoder_set_stencil");
  2175. // Set scissor for draw primitive.
  2176. // @remark
  2177. // To scissor for all primitives in view see `bgfx::setViewScissor`.
  2178. // _x : `Position x from the left corner of the window.`
  2179. // _y : `Position y from the top corner of the window.`
  2180. // _width : `Width of view scissor region.`
  2181. // _height : `Height of view scissor region.`
  2182. extern fn ushort encoder_set_scissor(Encoder* _this, ushort _x, ushort _y, ushort _width, ushort _height) @extern("bgfx_encoder_set_scissor");
  2183. // Set scissor from cache for draw primitive.
  2184. // @remark
  2185. // To scissor for all primitives in view see `bgfx::setViewScissor`.
  2186. // _cache : `Index in scissor cache.`
  2187. extern fn void encoder_set_scissor_cached(Encoder* _this, ushort _cache) @extern("bgfx_encoder_set_scissor_cached");
  2188. // Set model matrix for draw primitive. If it is not called,
  2189. // the model will be rendered with an identity model matrix.
  2190. // _mtx : `Pointer to first matrix in array.`
  2191. // _num : `Number of matrices in array.`
  2192. extern fn uint encoder_set_transform(Encoder* _this, void* _mtx, ushort _num) @extern("bgfx_encoder_set_transform");
  2193. // Set model matrix from matrix cache for draw primitive.
  2194. // _cache : `Index in matrix cache.`
  2195. // _num : `Number of matrices from cache.`
  2196. extern fn void encoder_set_transform_cached(Encoder* _this, uint _cache, ushort _num) @extern("bgfx_encoder_set_transform_cached");
  2197. // Reserve matrices in internal matrix cache.
  2198. // @attention Pointer returned can be modified until `bgfx::frame` is called.
  2199. // _transform : `Pointer to `Transform` structure.`
  2200. // _num : `Number of matrices.`
  2201. extern fn uint encoder_alloc_transform(Encoder* _this, Transform* _transform, ushort _num) @extern("bgfx_encoder_alloc_transform");
  2202. // Set shader uniform parameter for draw primitive.
  2203. // _handle : `Uniform.`
  2204. // _value : `Pointer to uniform data.`
  2205. // _num : `Number of elements. Passing `UINT16_MAX` will use the _num passed on uniform creation.`
  2206. extern fn void encoder_set_uniform(Encoder* _this, UniformHandle _handle, void* _value, ushort _num) @extern("bgfx_encoder_set_uniform");
  2207. // Set shader uniform parameter for view.
  2208. // @attention Uniform must be created with `bgfx::UniformFreq::View` argument.
  2209. // _id : `View id.`
  2210. // _handle : `Uniform.`
  2211. // _value : `Pointer to uniform data.`
  2212. // _num : `Number of elements. Passing `UINT16_MAX` will use the _num passed on uniform creation.`
  2213. extern fn void set_view_uniform(ushort _id, UniformHandle _handle, void* _value, ushort _num) @extern("bgfx_set_view_uniform");
  2214. // Set shader uniform parameter for frame.
  2215. // @attention Uniform must be created with `bgfx::UniformFreq::View` argument.
  2216. // _handle : `Uniform.`
  2217. // _value : `Pointer to uniform data.`
  2218. // _num : `Number of elements. Passing `UINT16_MAX` will use the _num passed on uniform creation.`
  2219. extern fn void set_frame_uniform(UniformHandle _handle, void* _value, ushort _num) @extern("bgfx_set_frame_uniform");
  2220. // Set index buffer for draw primitive.
  2221. // _handle : `Index buffer.`
  2222. // _firstIndex : `First index to render.`
  2223. // _numIndices : `Number of indices to render.`
  2224. extern fn void encoder_set_index_buffer(Encoder* _this, IndexBufferHandle _handle, uint _firstIndex, uint _numIndices) @extern("bgfx_encoder_set_index_buffer");
  2225. // Set index buffer for draw primitive.
  2226. // _handle : `Dynamic index buffer.`
  2227. // _firstIndex : `First index to render.`
  2228. // _numIndices : `Number of indices to render.`
  2229. extern fn void encoder_set_dynamic_index_buffer(Encoder* _this, DynamicIndexBufferHandle _handle, uint _firstIndex, uint _numIndices) @extern("bgfx_encoder_set_dynamic_index_buffer");
  2230. // Set index buffer for draw primitive.
  2231. // _tib : `Transient index buffer.`
  2232. // _firstIndex : `First index to render.`
  2233. // _numIndices : `Number of indices to render.`
  2234. extern fn void encoder_set_transient_index_buffer(Encoder* _this, TransientIndexBuffer* _tib, uint _firstIndex, uint _numIndices) @extern("bgfx_encoder_set_transient_index_buffer");
  2235. // Set vertex buffer for draw primitive.
  2236. // _stream : `Vertex stream.`
  2237. // _handle : `Vertex buffer.`
  2238. // _startVertex : `First vertex to render.`
  2239. // _numVertices : `Number of vertices to render.`
  2240. extern fn void encoder_set_vertex_buffer(Encoder* _this, char _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices) @extern("bgfx_encoder_set_vertex_buffer");
  2241. // Set vertex buffer for draw primitive.
  2242. // _stream : `Vertex stream.`
  2243. // _handle : `Vertex buffer.`
  2244. // _startVertex : `First vertex to render.`
  2245. // _numVertices : `Number of vertices to render.`
  2246. // _layoutHandle : `Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used.`
  2247. extern fn void encoder_set_vertex_buffer_with_layout(Encoder* _this, char _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle) @extern("bgfx_encoder_set_vertex_buffer_with_layout");
  2248. // Set vertex buffer for draw primitive.
  2249. // _stream : `Vertex stream.`
  2250. // _handle : `Dynamic vertex buffer.`
  2251. // _startVertex : `First vertex to render.`
  2252. // _numVertices : `Number of vertices to render.`
  2253. extern fn void encoder_set_dynamic_vertex_buffer(Encoder* _this, char _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices) @extern("bgfx_encoder_set_dynamic_vertex_buffer");
  2254. extern fn void encoder_set_dynamic_vertex_buffer_with_layout(Encoder* _this, char _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle) @extern("bgfx_encoder_set_dynamic_vertex_buffer_with_layout");
  2255. // Set vertex buffer for draw primitive.
  2256. // _stream : `Vertex stream.`
  2257. // _tvb : `Transient vertex buffer.`
  2258. // _startVertex : `First vertex to render.`
  2259. // _numVertices : `Number of vertices to render.`
  2260. extern fn void encoder_set_transient_vertex_buffer(Encoder* _this, char _stream, TransientVertexBuffer* _tvb, uint _startVertex, uint _numVertices) @extern("bgfx_encoder_set_transient_vertex_buffer");
  2261. // Set vertex buffer for draw primitive.
  2262. // _stream : `Vertex stream.`
  2263. // _tvb : `Transient vertex buffer.`
  2264. // _startVertex : `First vertex to render.`
  2265. // _numVertices : `Number of vertices to render.`
  2266. // _layoutHandle : `Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used.`
  2267. extern fn void encoder_set_transient_vertex_buffer_with_layout(Encoder* _this, char _stream, TransientVertexBuffer* _tvb, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle) @extern("bgfx_encoder_set_transient_vertex_buffer_with_layout");
  2268. // Set number of vertices for auto generated vertices use in conjunction
  2269. // with gl_VertexID.
  2270. // @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
  2271. // _numVertices : `Number of vertices.`
  2272. extern fn void encoder_set_vertex_count(Encoder* _this, uint _numVertices) @extern("bgfx_encoder_set_vertex_count");
  2273. // Set instance data buffer for draw primitive.
  2274. // _idb : `Transient instance data buffer.`
  2275. // _start : `First instance data.`
  2276. // _num : `Number of data instances.`
  2277. extern fn void encoder_set_instance_data_buffer(Encoder* _this, InstanceDataBuffer* _idb, uint _start, uint _num) @extern("bgfx_encoder_set_instance_data_buffer");
  2278. // Set instance data buffer for draw primitive.
  2279. // _handle : `Vertex buffer.`
  2280. // _startVertex : `First instance data.`
  2281. // _num : `Number of data instances.`
  2282. extern fn void encoder_set_instance_data_from_vertex_buffer(Encoder* _this, VertexBufferHandle _handle, uint _startVertex, uint _num) @extern("bgfx_encoder_set_instance_data_from_vertex_buffer");
  2283. // Set instance data buffer for draw primitive.
  2284. // _handle : `Dynamic vertex buffer.`
  2285. // _startVertex : `First instance data.`
  2286. // _num : `Number of data instances.`
  2287. extern fn void encoder_set_instance_data_from_dynamic_vertex_buffer(Encoder* _this, DynamicVertexBufferHandle _handle, uint _startVertex, uint _num) @extern("bgfx_encoder_set_instance_data_from_dynamic_vertex_buffer");
  2288. // Set number of instances for auto generated instances use in conjunction
  2289. // with gl_InstanceID.
  2290. // @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
  2291. // _numInstances : `Number of instances.`
  2292. extern fn void encoder_set_instance_count(Encoder* _this, uint _numInstances) @extern("bgfx_encoder_set_instance_count");
  2293. // Set texture stage for draw primitive.
  2294. // _stage : `Texture unit.`
  2295. // _sampler : `Program sampler.`
  2296. // _handle : `Texture handle.`
  2297. // _flags : `Texture sampling mode. Default value UINT32_MAX uses texture sampling settings from the texture. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
  2298. extern fn void encoder_set_texture(Encoder* _this, char _stage, UniformHandle _sampler, TextureHandle _handle, uint _flags) @extern("bgfx_encoder_set_texture");
  2299. // Submit an empty primitive for rendering. Uniforms and draw state
  2300. // will be applied but no geometry will be submitted. Useful in cases
  2301. // when no other draw/compute primitive is submitted to view, but it's
  2302. // desired to execute clear view.
  2303. // @remark
  2304. // These empty draw calls will sort before ordinary draw calls.
  2305. // _id : `View id.`
  2306. extern fn void encoder_touch(Encoder* _this, ushort _id) @extern("bgfx_encoder_touch");
  2307. // Submit primitive for rendering.
  2308. // _id : `View id.`
  2309. // _program : `Program.`
  2310. // _depth : `Depth for sorting.`
  2311. // _flags : `Discard or preserve states. See `BGFX_DISCARD_*`.`
  2312. extern fn void encoder_submit(Encoder* _this, ushort _id, ProgramHandle _program, uint _depth, char _flags) @extern("bgfx_encoder_submit");
  2313. // Submit primitive with occlusion query for rendering.
  2314. // _id : `View id.`
  2315. // _program : `Program.`
  2316. // _occlusionQuery : `Occlusion query.`
  2317. // _depth : `Depth for sorting.`
  2318. // _flags : `Discard or preserve states. See `BGFX_DISCARD_*`.`
  2319. extern fn void encoder_submit_occlusion_query(Encoder* _this, ushort _id, ProgramHandle _program, OcclusionQueryHandle _occlusionQuery, uint _depth, char _flags) @extern("bgfx_encoder_submit_occlusion_query");
  2320. // Submit primitive for rendering with index and instance data info from
  2321. // indirect buffer.
  2322. // @attention Availability depends on: `BGFX_CAPS_DRAW_INDIRECT`.
  2323. // _id : `View id.`
  2324. // _program : `Program.`
  2325. // _indirectHandle : `Indirect buffer.`
  2326. // _start : `First element in indirect buffer.`
  2327. // _num : `Number of draws.`
  2328. // _depth : `Depth for sorting.`
  2329. // _flags : `Discard or preserve states. See `BGFX_DISCARD_*`.`
  2330. extern fn void encoder_submit_indirect(Encoder* _this, ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, uint _num, uint _depth, char _flags) @extern("bgfx_encoder_submit_indirect");
  2331. // Submit primitive for rendering with index and instance data info and
  2332. // draw count from indirect buffers.
  2333. // @attention Availability depends on: `BGFX_CAPS_DRAW_INDIRECT_COUNT`.
  2334. // _id : `View id.`
  2335. // _program : `Program.`
  2336. // _indirectHandle : `Indirect buffer.`
  2337. // _start : `First element in indirect buffer.`
  2338. // _numHandle : `Buffer for number of draws. Must be created with `BGFX_BUFFER_INDEX32` and `BGFX_BUFFER_DRAW_INDIRECT`.`
  2339. // _numIndex : `Element in number buffer.`
  2340. // _numMax : `Max number of draws.`
  2341. // _depth : `Depth for sorting.`
  2342. // _flags : `Discard or preserve states. See `BGFX_DISCARD_*`.`
  2343. extern fn void encoder_submit_indirect_count(Encoder* _this, ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, IndexBufferHandle _numHandle, uint _numIndex, uint _numMax, uint _depth, char _flags) @extern("bgfx_encoder_submit_indirect_count");
  2344. // Set compute index buffer.
  2345. // _stage : `Compute stage.`
  2346. // _handle : `Index buffer handle.`
  2347. // _access : `Buffer access. See `Access::Enum`.`
  2348. extern fn void encoder_set_compute_index_buffer(Encoder* _this, char _stage, IndexBufferHandle _handle, Access _access) @extern("bgfx_encoder_set_compute_index_buffer");
  2349. // Set compute vertex buffer.
  2350. // _stage : `Compute stage.`
  2351. // _handle : `Vertex buffer handle.`
  2352. // _access : `Buffer access. See `Access::Enum`.`
  2353. extern fn void encoder_set_compute_vertex_buffer(Encoder* _this, char _stage, VertexBufferHandle _handle, Access _access) @extern("bgfx_encoder_set_compute_vertex_buffer");
  2354. // Set compute dynamic index buffer.
  2355. // _stage : `Compute stage.`
  2356. // _handle : `Dynamic index buffer handle.`
  2357. // _access : `Buffer access. See `Access::Enum`.`
  2358. extern fn void encoder_set_compute_dynamic_index_buffer(Encoder* _this, char _stage, DynamicIndexBufferHandle _handle, Access _access) @extern("bgfx_encoder_set_compute_dynamic_index_buffer");
  2359. // Set compute dynamic vertex buffer.
  2360. // _stage : `Compute stage.`
  2361. // _handle : `Dynamic vertex buffer handle.`
  2362. // _access : `Buffer access. See `Access::Enum`.`
  2363. extern fn void encoder_set_compute_dynamic_vertex_buffer(Encoder* _this, char _stage, DynamicVertexBufferHandle _handle, Access _access) @extern("bgfx_encoder_set_compute_dynamic_vertex_buffer");
  2364. // Set compute indirect buffer.
  2365. // _stage : `Compute stage.`
  2366. // _handle : `Indirect buffer handle.`
  2367. // _access : `Buffer access. See `Access::Enum`.`
  2368. extern fn void encoder_set_compute_indirect_buffer(Encoder* _this, char _stage, IndirectBufferHandle _handle, Access _access) @extern("bgfx_encoder_set_compute_indirect_buffer");
  2369. // Set compute image from texture.
  2370. // _stage : `Compute stage.`
  2371. // _handle : `Texture handle.`
  2372. // _mip : `Mip level.`
  2373. // _access : `Image access. See `Access::Enum`.`
  2374. // _format : `Texture format. See: `TextureFormat::Enum`.`
  2375. extern fn void encoder_set_image(Encoder* _this, char _stage, TextureHandle _handle, char _mip, Access _access, TextureFormat _format) @extern("bgfx_encoder_set_image");
  2376. // Dispatch compute.
  2377. // _id : `View id.`
  2378. // _program : `Compute program.`
  2379. // _numX : `Number of groups X.`
  2380. // _numY : `Number of groups Y.`
  2381. // _numZ : `Number of groups Z.`
  2382. // _flags : `Discard or preserve states. See `BGFX_DISCARD_*`.`
  2383. extern fn void encoder_dispatch(Encoder* _this, ushort _id, ProgramHandle _program, uint _numX, uint _numY, uint _numZ, char _flags) @extern("bgfx_encoder_dispatch");
  2384. // Dispatch compute indirect.
  2385. // _id : `View id.`
  2386. // _program : `Compute program.`
  2387. // _indirectHandle : `Indirect buffer.`
  2388. // _start : `First element in indirect buffer.`
  2389. // _num : `Number of dispatches.`
  2390. // _flags : `Discard or preserve states. See `BGFX_DISCARD_*`.`
  2391. extern fn void encoder_dispatch_indirect(Encoder* _this, ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, uint _num, char _flags) @extern("bgfx_encoder_dispatch_indirect");
  2392. // Discard previously set state for draw or compute call.
  2393. // _flags : `Discard or preserve states. See `BGFX_DISCARD_*`.`
  2394. extern fn void encoder_discard(Encoder* _this, char _flags) @extern("bgfx_encoder_discard");
  2395. // Blit 2D texture region between two 2D textures.
  2396. // @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag.
  2397. // @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`.
  2398. // _id : `View id.`
  2399. // _dst : `Destination texture handle.`
  2400. // _dstMip : `Destination texture mip level.`
  2401. // _dstX : `Destination texture X position.`
  2402. // _dstY : `Destination texture Y position.`
  2403. // _dstZ : `If texture is 2D this argument should be 0. If destination texture is cube this argument represents destination texture cube face. For 3D texture this argument represents destination texture Z position.`
  2404. // _src : `Source texture handle.`
  2405. // _srcMip : `Source texture mip level.`
  2406. // _srcX : `Source texture X position.`
  2407. // _srcY : `Source texture Y position.`
  2408. // _srcZ : `If texture is 2D this argument should be 0. If source texture is cube this argument represents source texture cube face. For 3D texture this argument represents source texture Z position.`
  2409. // _width : `Width of region.`
  2410. // _height : `Height of region.`
  2411. // _depth : `If texture is 3D this argument represents depth of region, otherwise it's unused.`
  2412. extern fn void encoder_blit(Encoder* _this, ushort _id, TextureHandle _dst, char _dstMip, ushort _dstX, ushort _dstY, ushort _dstZ, TextureHandle _src, char _srcMip, ushort _srcX, ushort _srcY, ushort _srcZ, ushort _width, ushort _height, ushort _depth) @extern("bgfx_encoder_blit");
  2413. // Request screen shot of window back buffer.
  2414. // @remarks
  2415. // `bgfx::CallbackI::screenShot` must be implemented.
  2416. // @attention Frame buffer handle must be created with OS' target native window handle.
  2417. // _handle : `Frame buffer handle. If handle is `BGFX_INVALID_HANDLE` request will be made for main window back buffer.`
  2418. // _filePath : `Will be passed to `bgfx::CallbackI::screenShot` callback.`
  2419. extern fn void request_screen_shot(FrameBufferHandle _handle, ZString _filePath) @extern("bgfx_request_screen_shot");
  2420. // Render frame.
  2421. // @attention `bgfx::renderFrame` is blocking call. It waits for
  2422. // `bgfx::frame` to be called from API thread to process frame.
  2423. // If timeout value is passed call will timeout and return even
  2424. // if `bgfx::frame` is not called.
  2425. // @warning This call should be only used on platforms that don't
  2426. // allow creating separate rendering thread. If it is called before
  2427. // to bgfx::init, render thread won't be created by bgfx::init call.
  2428. // _msecs : `Timeout in milliseconds.`
  2429. extern fn RenderFrame render_frame(int _msecs) @extern("bgfx_render_frame");
  2430. // Set platform data.
  2431. // @warning Must be called before `bgfx::init`.
  2432. // _data : `Platform data.`
  2433. extern fn void set_platform_data(PlatformData* _data) @extern("bgfx_set_platform_data");
  2434. // Get internal data for interop.
  2435. // @attention It's expected you understand some bgfx internals before you
  2436. // use this call.
  2437. // @warning Must be called only on render thread.
  2438. extern fn InternalData* get_internal_data() @extern("bgfx_get_internal_data");
  2439. // Override internal texture with externally created texture. Previously
  2440. // created internal texture will released.
  2441. // @attention It's expected you understand some bgfx internals before you
  2442. // use this call.
  2443. // @warning Must be called only on render thread.
  2444. // _handle : `Texture handle.`
  2445. // _ptr : `Native API pointer to texture.`
  2446. // _layerIndex : `Layer index for texture arrays (only implemented for D3D11).`
  2447. extern fn uptr override_internal_texture_ptr(TextureHandle _handle, uptr _ptr, ushort _layerIndex) @extern("bgfx_override_internal_texture_ptr");
  2448. // Override internal texture by creating new texture. Previously created
  2449. // internal texture will released.
  2450. // @attention It's expected you understand some bgfx internals before you
  2451. // use this call.
  2452. // @returns Native API pointer to texture. If result is 0, texture is not created yet from the
  2453. // main thread.
  2454. // @warning Must be called only on render thread.
  2455. // _handle : `Texture handle.`
  2456. // _width : `Width.`
  2457. // _height : `Height.`
  2458. // _numMips : `Number of mip-maps.`
  2459. // _format : `Texture format. See: `TextureFormat::Enum`.`
  2460. // _flags : `Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
  2461. extern fn uptr override_internal_texture(TextureHandle _handle, ushort _width, ushort _height, char _numMips, TextureFormat _format, ulong _flags) @extern("bgfx_override_internal_texture");
  2462. // Sets a debug marker. This allows you to group graphics calls together for easy browsing in
  2463. // graphics debugging tools.
  2464. // _name : `Marker name.`
  2465. // _len : `Marker name length (if length is INT32_MAX, it's expected that _name is zero terminated string.`
  2466. extern fn void set_marker(ZString _name, int _len) @extern("bgfx_set_marker");
  2467. // Set render states for draw primitive.
  2468. // @remarks
  2469. // 1. To set up more complex states use:
  2470. // `BGFX_STATE_ALPHA_REF(_ref)`,
  2471. // `BGFX_STATE_POINT_SIZE(_size)`,
  2472. // `BGFX_STATE_BLEND_FUNC(_src, _dst)`,
  2473. // `BGFX_STATE_BLEND_FUNC_SEPARATE(_srcRGB, _dstRGB, _srcA, _dstA)`,
  2474. // `BGFX_STATE_BLEND_EQUATION(_equation)`,
  2475. // `BGFX_STATE_BLEND_EQUATION_SEPARATE(_equationRGB, _equationA)`
  2476. // 2. `BGFX_STATE_BLEND_EQUATION_ADD` is set when no other blend
  2477. // equation is specified.
  2478. // _state : `State flags. Default state for primitive type is triangles. See: `BGFX_STATE_DEFAULT`. - `BGFX_STATE_DEPTH_TEST_*` - Depth test function. - `BGFX_STATE_BLEND_*` - See remark 1 about BGFX_STATE_BLEND_FUNC. - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2. - `BGFX_STATE_CULL_*` - Backface culling mode. - `BGFX_STATE_WRITE_*` - Enable R, G, B, A or Z write. - `BGFX_STATE_MSAA` - Enable hardware multisample antialiasing. - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type.`
  2479. // _rgba : `Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and `BGFX_STATE_BLEND_INV_FACTOR` blend modes.`
  2480. extern fn void set_state(ulong _state, uint _rgba) @extern("bgfx_set_state");
  2481. // Set condition for rendering.
  2482. // _handle : `Occlusion query handle.`
  2483. // _visible : `Render if occlusion query is visible.`
  2484. extern fn void set_condition(OcclusionQueryHandle _handle, bool _visible) @extern("bgfx_set_condition");
  2485. // Set stencil test state.
  2486. // _fstencil : `Front stencil state.`
  2487. // _bstencil : `Back stencil state. If back is set to `BGFX_STENCIL_NONE` _fstencil is applied to both front and back facing primitives.`
  2488. extern fn void set_stencil(uint _fstencil, uint _bstencil) @extern("bgfx_set_stencil");
  2489. // Set scissor for draw primitive.
  2490. // @remark
  2491. // To scissor for all primitives in view see `bgfx::setViewScissor`.
  2492. // _x : `Position x from the left corner of the window.`
  2493. // _y : `Position y from the top corner of the window.`
  2494. // _width : `Width of view scissor region.`
  2495. // _height : `Height of view scissor region.`
  2496. extern fn ushort set_scissor(ushort _x, ushort _y, ushort _width, ushort _height) @extern("bgfx_set_scissor");
  2497. // Set scissor from cache for draw primitive.
  2498. // @remark
  2499. // To scissor for all primitives in view see `bgfx::setViewScissor`.
  2500. // _cache : `Index in scissor cache.`
  2501. extern fn void set_scissor_cached(ushort _cache) @extern("bgfx_set_scissor_cached");
  2502. // Set model matrix for draw primitive. If it is not called,
  2503. // the model will be rendered with an identity model matrix.
  2504. // _mtx : `Pointer to first matrix in array.`
  2505. // _num : `Number of matrices in array.`
  2506. extern fn uint set_transform(void* _mtx, ushort _num) @extern("bgfx_set_transform");
  2507. // Set model matrix from matrix cache for draw primitive.
  2508. // _cache : `Index in matrix cache.`
  2509. // _num : `Number of matrices from cache.`
  2510. extern fn void set_transform_cached(uint _cache, ushort _num) @extern("bgfx_set_transform_cached");
  2511. // Reserve matrices in internal matrix cache.
  2512. // @attention Pointer returned can be modified until `bgfx::frame` is called.
  2513. // _transform : `Pointer to `Transform` structure.`
  2514. // _num : `Number of matrices.`
  2515. extern fn uint alloc_transform(Transform* _transform, ushort _num) @extern("bgfx_alloc_transform");
  2516. // Set shader uniform parameter for draw primitive.
  2517. // _handle : `Uniform.`
  2518. // _value : `Pointer to uniform data.`
  2519. // _num : `Number of elements. Passing `UINT16_MAX` will use the _num passed on uniform creation.`
  2520. extern fn void set_uniform(UniformHandle _handle, void* _value, ushort _num) @extern("bgfx_set_uniform");
  2521. // Set index buffer for draw primitive.
  2522. // _handle : `Index buffer.`
  2523. // _firstIndex : `First index to render.`
  2524. // _numIndices : `Number of indices to render.`
  2525. extern fn void set_index_buffer(IndexBufferHandle _handle, uint _firstIndex, uint _numIndices) @extern("bgfx_set_index_buffer");
  2526. // Set index buffer for draw primitive.
  2527. // _handle : `Dynamic index buffer.`
  2528. // _firstIndex : `First index to render.`
  2529. // _numIndices : `Number of indices to render.`
  2530. extern fn void set_dynamic_index_buffer(DynamicIndexBufferHandle _handle, uint _firstIndex, uint _numIndices) @extern("bgfx_set_dynamic_index_buffer");
  2531. // Set index buffer for draw primitive.
  2532. // _tib : `Transient index buffer.`
  2533. // _firstIndex : `First index to render.`
  2534. // _numIndices : `Number of indices to render.`
  2535. extern fn void set_transient_index_buffer(TransientIndexBuffer* _tib, uint _firstIndex, uint _numIndices) @extern("bgfx_set_transient_index_buffer");
  2536. // Set vertex buffer for draw primitive.
  2537. // _stream : `Vertex stream.`
  2538. // _handle : `Vertex buffer.`
  2539. // _startVertex : `First vertex to render.`
  2540. // _numVertices : `Number of vertices to render.`
  2541. extern fn void set_vertex_buffer(char _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices) @extern("bgfx_set_vertex_buffer");
  2542. // Set vertex buffer for draw primitive.
  2543. // _stream : `Vertex stream.`
  2544. // _handle : `Vertex buffer.`
  2545. // _startVertex : `First vertex to render.`
  2546. // _numVertices : `Number of vertices to render.`
  2547. // _layoutHandle : `Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used.`
  2548. extern fn void set_vertex_buffer_with_layout(char _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle) @extern("bgfx_set_vertex_buffer_with_layout");
  2549. // Set vertex buffer for draw primitive.
  2550. // _stream : `Vertex stream.`
  2551. // _handle : `Dynamic vertex buffer.`
  2552. // _startVertex : `First vertex to render.`
  2553. // _numVertices : `Number of vertices to render.`
  2554. extern fn void set_dynamic_vertex_buffer(char _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices) @extern("bgfx_set_dynamic_vertex_buffer");
  2555. // Set vertex buffer for draw primitive.
  2556. // _stream : `Vertex stream.`
  2557. // _handle : `Dynamic vertex buffer.`
  2558. // _startVertex : `First vertex to render.`
  2559. // _numVertices : `Number of vertices to render.`
  2560. // _layoutHandle : `Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used.`
  2561. extern fn void set_dynamic_vertex_buffer_with_layout(char _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle) @extern("bgfx_set_dynamic_vertex_buffer_with_layout");
  2562. // Set vertex buffer for draw primitive.
  2563. // _stream : `Vertex stream.`
  2564. // _tvb : `Transient vertex buffer.`
  2565. // _startVertex : `First vertex to render.`
  2566. // _numVertices : `Number of vertices to render.`
  2567. extern fn void set_transient_vertex_buffer(char _stream, TransientVertexBuffer* _tvb, uint _startVertex, uint _numVertices) @extern("bgfx_set_transient_vertex_buffer");
  2568. // Set vertex buffer for draw primitive.
  2569. // _stream : `Vertex stream.`
  2570. // _tvb : `Transient vertex buffer.`
  2571. // _startVertex : `First vertex to render.`
  2572. // _numVertices : `Number of vertices to render.`
  2573. // _layoutHandle : `Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used.`
  2574. extern fn void set_transient_vertex_buffer_with_layout(char _stream, TransientVertexBuffer* _tvb, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle) @extern("bgfx_set_transient_vertex_buffer_with_layout");
  2575. // Set number of vertices for auto generated vertices use in conjunction
  2576. // with gl_VertexID.
  2577. // @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
  2578. // _numVertices : `Number of vertices.`
  2579. extern fn void set_vertex_count(uint _numVertices) @extern("bgfx_set_vertex_count");
  2580. // Set instance data buffer for draw primitive.
  2581. // _idb : `Transient instance data buffer.`
  2582. // _start : `First instance data.`
  2583. // _num : `Number of data instances.`
  2584. extern fn void set_instance_data_buffer(InstanceDataBuffer* _idb, uint _start, uint _num) @extern("bgfx_set_instance_data_buffer");
  2585. // Set instance data buffer for draw primitive.
  2586. // _handle : `Vertex buffer.`
  2587. // _startVertex : `First instance data.`
  2588. // _num : `Number of data instances.`
  2589. extern fn void set_instance_data_from_vertex_buffer(VertexBufferHandle _handle, uint _startVertex, uint _num) @extern("bgfx_set_instance_data_from_vertex_buffer");
  2590. // Set instance data buffer for draw primitive.
  2591. // _handle : `Dynamic vertex buffer.`
  2592. // _startVertex : `First instance data.`
  2593. // _num : `Number of data instances.`
  2594. extern fn void set_instance_data_from_dynamic_vertex_buffer(DynamicVertexBufferHandle _handle, uint _startVertex, uint _num) @extern("bgfx_set_instance_data_from_dynamic_vertex_buffer");
  2595. // Set number of instances for auto generated instances use in conjunction
  2596. // with gl_InstanceID.
  2597. // @attention Availability depends on: `BGFX_CAPS_VERTEX_ID`.
  2598. // _numInstances : `Number of instances.`
  2599. extern fn void set_instance_count(uint _numInstances) @extern("bgfx_set_instance_count");
  2600. // Set texture stage for draw primitive.
  2601. // _stage : `Texture unit.`
  2602. // _sampler : `Program sampler.`
  2603. // _handle : `Texture handle.`
  2604. // _flags : `Texture sampling mode. Default value UINT32_MAX uses texture sampling settings from the texture. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.`
  2605. extern fn void set_texture(char _stage, UniformHandle _sampler, TextureHandle _handle, uint _flags) @extern("bgfx_set_texture");
  2606. // Submit an empty primitive for rendering. Uniforms and draw state
  2607. // will be applied but no geometry will be submitted.
  2608. // @remark
  2609. // These empty draw calls will sort before ordinary draw calls.
  2610. // _id : `View id.`
  2611. extern fn void touch(ushort _id) @extern("bgfx_touch");
  2612. // Submit primitive for rendering.
  2613. // _id : `View id.`
  2614. // _program : `Program.`
  2615. // _depth : `Depth for sorting.`
  2616. // _flags : `Which states to discard for next draw. See `BGFX_DISCARD_*`.`
  2617. extern fn void submit(ushort _id, ProgramHandle _program, uint _depth, char _flags) @extern("bgfx_submit");
  2618. // Submit primitive with occlusion query for rendering.
  2619. // _id : `View id.`
  2620. // _program : `Program.`
  2621. // _occlusionQuery : `Occlusion query.`
  2622. // _depth : `Depth for sorting.`
  2623. // _flags : `Which states to discard for next draw. See `BGFX_DISCARD_*`.`
  2624. extern fn void submit_occlusion_query(ushort _id, ProgramHandle _program, OcclusionQueryHandle _occlusionQuery, uint _depth, char _flags) @extern("bgfx_submit_occlusion_query");
  2625. // Submit primitive for rendering with index and instance data info from
  2626. // indirect buffer.
  2627. // @attention Availability depends on: `BGFX_CAPS_DRAW_INDIRECT`.
  2628. // _id : `View id.`
  2629. // _program : `Program.`
  2630. // _indirectHandle : `Indirect buffer.`
  2631. // _start : `First element in indirect buffer.`
  2632. // _num : `Number of draws.`
  2633. // _depth : `Depth for sorting.`
  2634. // _flags : `Which states to discard for next draw. See `BGFX_DISCARD_*`.`
  2635. extern fn void submit_indirect(ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, uint _num, uint _depth, char _flags) @extern("bgfx_submit_indirect");
  2636. // Submit primitive for rendering with index and instance data info and
  2637. // draw count from indirect buffers.
  2638. // @attention Availability depends on: `BGFX_CAPS_DRAW_INDIRECT_COUNT`.
  2639. // _id : `View id.`
  2640. // _program : `Program.`
  2641. // _indirectHandle : `Indirect buffer.`
  2642. // _start : `First element in indirect buffer.`
  2643. // _numHandle : `Buffer for number of draws. Must be created with `BGFX_BUFFER_INDEX32` and `BGFX_BUFFER_DRAW_INDIRECT`.`
  2644. // _numIndex : `Element in number buffer.`
  2645. // _numMax : `Max number of draws.`
  2646. // _depth : `Depth for sorting.`
  2647. // _flags : `Which states to discard for next draw. See `BGFX_DISCARD_*`.`
  2648. extern fn void submit_indirect_count(ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, IndexBufferHandle _numHandle, uint _numIndex, uint _numMax, uint _depth, char _flags) @extern("bgfx_submit_indirect_count");
  2649. // Set compute index buffer.
  2650. // _stage : `Compute stage.`
  2651. // _handle : `Index buffer handle.`
  2652. // _access : `Buffer access. See `Access::Enum`.`
  2653. extern fn void set_compute_index_buffer(char _stage, IndexBufferHandle _handle, Access _access) @extern("bgfx_set_compute_index_buffer");
  2654. // Set compute vertex buffer.
  2655. // _stage : `Compute stage.`
  2656. // _handle : `Vertex buffer handle.`
  2657. // _access : `Buffer access. See `Access::Enum`.`
  2658. extern fn void set_compute_vertex_buffer(char _stage, VertexBufferHandle _handle, Access _access) @extern("bgfx_set_compute_vertex_buffer");
  2659. // Set compute dynamic index buffer.
  2660. // _stage : `Compute stage.`
  2661. // _handle : `Dynamic index buffer handle.`
  2662. // _access : `Buffer access. See `Access::Enum`.`
  2663. extern fn void set_compute_dynamic_index_buffer(char _stage, DynamicIndexBufferHandle _handle, Access _access) @extern("bgfx_set_compute_dynamic_index_buffer");
  2664. // Set compute dynamic vertex buffer.
  2665. // _stage : `Compute stage.`
  2666. // _handle : `Dynamic vertex buffer handle.`
  2667. // _access : `Buffer access. See `Access::Enum`.`
  2668. extern fn void set_compute_dynamic_vertex_buffer(char _stage, DynamicVertexBufferHandle _handle, Access _access) @extern("bgfx_set_compute_dynamic_vertex_buffer");
  2669. // Set compute indirect buffer.
  2670. // _stage : `Compute stage.`
  2671. // _handle : `Indirect buffer handle.`
  2672. // _access : `Buffer access. See `Access::Enum`.`
  2673. extern fn void set_compute_indirect_buffer(char _stage, IndirectBufferHandle _handle, Access _access) @extern("bgfx_set_compute_indirect_buffer");
  2674. // Set compute image from texture.
  2675. // _stage : `Compute stage.`
  2676. // _handle : `Texture handle.`
  2677. // _mip : `Mip level.`
  2678. // _access : `Image access. See `Access::Enum`.`
  2679. // _format : `Texture format. See: `TextureFormat::Enum`.`
  2680. extern fn void set_image(char _stage, TextureHandle _handle, char _mip, Access _access, TextureFormat _format) @extern("bgfx_set_image");
  2681. // Dispatch compute.
  2682. // _id : `View id.`
  2683. // _program : `Compute program.`
  2684. // _numX : `Number of groups X.`
  2685. // _numY : `Number of groups Y.`
  2686. // _numZ : `Number of groups Z.`
  2687. // _flags : `Discard or preserve states. See `BGFX_DISCARD_*`.`
  2688. extern fn void dispatch(ushort _id, ProgramHandle _program, uint _numX, uint _numY, uint _numZ, char _flags) @extern("bgfx_dispatch");
  2689. // Dispatch compute indirect.
  2690. // _id : `View id.`
  2691. // _program : `Compute program.`
  2692. // _indirectHandle : `Indirect buffer.`
  2693. // _start : `First element in indirect buffer.`
  2694. // _num : `Number of dispatches.`
  2695. // _flags : `Discard or preserve states. See `BGFX_DISCARD_*`.`
  2696. extern fn void dispatch_indirect(ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, uint _num, char _flags) @extern("bgfx_dispatch_indirect");
  2697. // Discard previously set state for draw or compute call.
  2698. // _flags : `Draw/compute states to discard.`
  2699. extern fn void discard(char _flags) @extern("bgfx_discard");
  2700. // Blit 2D texture region between two 2D textures.
  2701. // @attention Destination texture must be created with `BGFX_TEXTURE_BLIT_DST` flag.
  2702. // @attention Availability depends on: `BGFX_CAPS_TEXTURE_BLIT`.
  2703. // _id : `View id.`
  2704. // _dst : `Destination texture handle.`
  2705. // _dstMip : `Destination texture mip level.`
  2706. // _dstX : `Destination texture X position.`
  2707. // _dstY : `Destination texture Y position.`
  2708. // _dstZ : `If texture is 2D this argument should be 0. If destination texture is cube this argument represents destination texture cube face. For 3D texture this argument represents destination texture Z position.`
  2709. // _src : `Source texture handle.`
  2710. // _srcMip : `Source texture mip level.`
  2711. // _srcX : `Source texture X position.`
  2712. // _srcY : `Source texture Y position.`
  2713. // _srcZ : `If texture is 2D this argument should be 0. If source texture is cube this argument represents source texture cube face. For 3D texture this argument represents source texture Z position.`
  2714. // _width : `Width of region.`
  2715. // _height : `Height of region.`
  2716. // _depth : `If texture is 3D this argument represents depth of region, otherwise it's unused.`
  2717. extern fn void blit(ushort _id, TextureHandle _dst, char _dstMip, ushort _dstX, ushort _dstY, ushort _dstZ, TextureHandle _src, char _srcMip, ushort _srcX, ushort _srcY, ushort _srcZ, ushort _width, ushort _height, ushort _depth) @extern("bgfx_blit");