sokol_gl.h 234 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018
  1. #if defined(SOKOL_IMPL) && !defined(SOKOL_GL_IMPL)
  2. #define SOKOL_GL_IMPL
  3. #endif
  4. #ifndef SOKOL_GL_INCLUDED
  5. /*
  6. sokol_gl.h -- OpenGL 1.x style rendering on top of sokol_gfx.h
  7. Project URL: https://github.com/floooh/sokol
  8. Do this:
  9. #define SOKOL_IMPL or
  10. #define SOKOL_GL_IMPL
  11. before you include this file in *one* C or C++ file to create the
  12. implementation.
  13. The following defines are used by the implementation to select the
  14. platform-specific embedded shader code (these are the same defines as
  15. used by sokol_gfx.h and sokol_app.h):
  16. SOKOL_GLCORE
  17. SOKOL_GLES3
  18. SOKOL_D3D11
  19. SOKOL_METAL
  20. SOKOL_WGPU
  21. SOKOL_VULKAN
  22. ...optionally provide the following macros to override defaults:
  23. SOKOL_ASSERT(c) - your own assert macro (default: assert(c))
  24. SOKOL_GL_API_DECL - public function declaration prefix (default: extern)
  25. SOKOL_API_DECL - same as SOKOL_GL_API_DECL
  26. SOKOL_API_IMPL - public function implementation prefix (default: -)
  27. SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false))
  28. If sokol_gl.h is compiled as a DLL, define the following before
  29. including the declaration or implementation:
  30. SOKOL_DLL
  31. On Windows, SOKOL_DLL will define SOKOL_GL_API_DECL as __declspec(dllexport)
  32. or __declspec(dllimport) as needed.
  33. Include the following headers before including sokol_gl.h:
  34. sokol_gfx.h
  35. Matrix functions have been taken from MESA and Regal.
  36. FEATURE OVERVIEW:
  37. =================
  38. sokol_gl.h implements a subset of the OpenGLES 1.x feature set useful for
  39. when you just want to quickly render a bunch of triangles or
  40. lines without having to mess with buffers and shaders.
  41. The current feature set is mostly useful for debug visualizations
  42. and simple UI-style 2D rendering:
  43. What's implemented:
  44. - vertex components:
  45. - position (x, y, z)
  46. - 2D texture coords (u, v)
  47. - color (r, g, b, a)
  48. - primitive types:
  49. - triangle list and strip
  50. - line list and strip
  51. - quad list (TODO: quad strips)
  52. - point list
  53. - one texture layer (no multi-texturing)
  54. - viewport and scissor-rect with selectable origin (top-left or bottom-left)
  55. - all GL 1.x matrix stack functions, and additionally equivalent
  56. functions for gluPerspective and gluLookat
  57. Notable GLES 1.x features that are *NOT* implemented:
  58. - vertex lighting (this is the most likely GL feature that might be added later)
  59. - vertex arrays (although providing whole chunks of vertex data at once
  60. might be a useful feature for a later version)
  61. - texture coordinate generation
  62. - line width
  63. - all pixel store functions
  64. - no ALPHA_TEST
  65. - no clear functions (clearing is handled by the sokol-gfx render pass)
  66. - fog
  67. Notable differences to GL:
  68. - No "enum soup" for render states etc, instead there's a
  69. 'pipeline stack', this is similar to GL's matrix stack,
  70. but for pipeline-state-objects. The pipeline object at
  71. the top of the pipeline stack defines the active set of render states
  72. - All angles are in radians, not degrees (note the sgl_rad() and
  73. sgl_deg() conversion functions)
  74. - No enable/disable state for scissor test, this is always enabled
  75. STEP BY STEP:
  76. =============
  77. --- To initialize sokol-gl, call:
  78. sgl_setup(const sgl_desc_t* desc)
  79. NOTE that sgl_setup() must be called *after* initializing sokol-gfx
  80. (via sg_setup). This is because sgl_setup() needs to create
  81. sokol-gfx resource objects.
  82. If you're intending to render to the default pass, and also don't
  83. want to tweak memory usage, and don't want any logging output you can
  84. just keep sgl_desc_t zero-initialized:
  85. sgl_setup(&(sgl_desc_t*){ 0 });
  86. In this case, sokol-gl will create internal sg_pipeline objects that
  87. are compatible with the sokol-app default framebuffer.
  88. I would recommend to at least install a logging callback so that
  89. you'll see any warnings and errors. The easiest way is through
  90. sokol_log.h:
  91. #include "sokol_log.h"
  92. sgl_setup(&(sgl_desc_t){
  93. .logger.func = slog_func.
  94. });
  95. If you want to render into a framebuffer with different pixel-format
  96. and MSAA attributes you need to provide the matching attributes in the
  97. sgl_setup() call:
  98. sgl_setup(&(sgl_desc_t*){
  99. .color_format = SG_PIXELFORMAT_...,
  100. .depth_format = SG_PIXELFORMAT_...,
  101. .sample_count = ...,
  102. });
  103. To reduce memory usage, or if you need to create more then the default number of
  104. contexts, pipelines, vertices or draw commands, set the following sgl_desc_t
  105. members:
  106. .context_pool_size (default: 4)
  107. .pipeline_pool_size (default: 64)
  108. .max_vertices (default: 64k)
  109. .max_commands (default: 16k)
  110. Finally you can change the face winding for front-facing triangles
  111. and quads:
  112. .face_winding - default is SG_FACEWINDING_CCW
  113. The default winding for front faces is counter-clock-wise. This is
  114. the same as OpenGL's default, but different from sokol-gfx.
  115. --- Optionally create additional context objects if you want to render into
  116. multiple sokol-gfx render passes (or generally if you want to
  117. use multiple independent sokol-gl "state buckets")
  118. sgl_context ctx = sgl_make_context(const sgl_context_desc_t* desc)
  119. For details on rendering with sokol-gl contexts, search below for
  120. WORKING WITH CONTEXTS.
  121. --- Optionally create pipeline-state-objects if you need render state
  122. that differs from sokol-gl's default state:
  123. sgl_pipeline pip = sgl_make_pipeline(const sg_pipeline_desc* desc)
  124. ...this creates a pipeline object that's compatible with the currently
  125. active context, alternatively call:
  126. sgl_pipeline_pip = sgl_context_make_pipeline(sgl_context ctx, const sg_pipeline_desc* desc)
  127. ...to create a pipeline object that's compatible with an explicitly
  128. provided context.
  129. The similarity with sokol_gfx.h's sg_pipeline type and sg_make_pipeline()
  130. function is intended. sgl_make_pipeline() also takes a standard
  131. sokol-gfx sg_pipeline_desc object to describe the render state, but
  132. without:
  133. - shader
  134. - vertex layout
  135. - color- and depth-pixel-formats
  136. - primitive type (lines, triangles, ...)
  137. - MSAA sample count
  138. Those will be filled in by sgl_make_pipeline(). Note that each
  139. call to sgl_make_pipeline() needs to create several sokol-gfx
  140. pipeline objects (one for each primitive type).
  141. 'depth.write_enabled' will be forced to 'false' if the context this
  142. pipeline object is intended for has its depth pixel format set to
  143. SG_PIXELFORMAT_NONE (which means the framebuffer this context is used
  144. with doesn't have a depth-stencil surface).
  145. --- if you need to destroy sgl_pipeline objects before sgl_shutdown():
  146. sgl_destroy_pipeline(sgl_pipeline pip)
  147. --- After sgl_setup() you can call any of the sokol-gl functions anywhere
  148. in a frame, *except* sgl_draw(). The 'vanilla' functions
  149. will only change internal sokol-gl state, and not call any sokol-gfx
  150. functions.
  151. --- Unlike OpenGL, sokol-gl has a function to reset internal state to
  152. a known default. This is useful at the start of a sequence of
  153. rendering operations:
  154. void sgl_defaults(void)
  155. This will set the following default state:
  156. - current texture coordinate to u=0.0f, v=0.0f
  157. - current color to white (rgba all 1.0f)
  158. - current point size to 1.0f
  159. - unbind the current texture and texturing will be disabled
  160. - *all* matrices will be set to identity (also the projection matrix)
  161. - the default render state will be set by loading the 'default pipeline'
  162. into the top of the pipeline stack
  163. The current matrix- and pipeline-stack-depths will not be changed by
  164. sgl_defaults().
  165. --- change the currently active renderstate through the
  166. pipeline-stack functions, this works similar to the
  167. traditional GL matrix stack:
  168. ...load the default pipeline state on the top of the pipeline stack:
  169. sgl_load_default_pipeline()
  170. ...load a specific pipeline on the top of the pipeline stack:
  171. sgl_load_pipeline(sgl_pipeline pip)
  172. ...push and pop the pipeline stack:
  173. sgl_push_pipeline()
  174. sgl_pop_pipeline()
  175. --- control texturing with:
  176. sgl_enable_texture()
  177. sgl_disable_texture()
  178. sgl_texture(sg_view tex_view, sg_sampler smp)
  179. NOTE: the tex_view and smp handles can be invalid (SG_INVALID_ID), in this
  180. case, sokol-gl will fall back to the internal default (white) texture
  181. and sampler.
  182. --- set the current viewport and scissor rect with:
  183. sgl_viewport(int x, int y, int w, int h, bool origin_top_left)
  184. sgl_scissor_rect(int x, int y, int w, int h, bool origin_top_left)
  185. ...or call these alternatives which take float arguments (this might allow
  186. to avoid casting between float and integer in more strongly typed languages
  187. when floating point pixel coordinates are used):
  188. sgl_viewportf(float x, float y, float w, float h, bool origin_top_left)
  189. sgl_scissor_rectf(float x, float y, float w, float h, bool origin_top_left)
  190. ...these calls add a new command to the internal command queue, so
  191. that the viewport or scissor rect are set at the right time relative
  192. to other sokol-gl calls.
  193. --- adjust the transform matrices, matrix manipulation works just like
  194. the OpenGL matrix stack:
  195. ...set the current matrix mode:
  196. sgl_matrix_mode_modelview()
  197. sgl_matrix_mode_projection()
  198. sgl_matrix_mode_texture()
  199. ...load the identity matrix into the current matrix:
  200. sgl_load_identity()
  201. ...translate, rotate and scale the current matrix:
  202. sgl_translate(float x, float y, float z)
  203. sgl_rotate(float angle_rad, float x, float y, float z)
  204. sgl_scale(float x, float y, float z)
  205. NOTE that all angles in sokol-gl are in radians, not in degree.
  206. Convert between radians and degree with the helper functions:
  207. float sgl_rad(float deg) - degrees to radians
  208. float sgl_deg(float rad) - radians to degrees
  209. ...directly load the current matrix from a float[16] array:
  210. sgl_load_matrix(const float m[16])
  211. sgl_load_transpose_matrix(const float m[16])
  212. ...directly multiply the current matrix from a float[16] array:
  213. sgl_mult_matrix(const float m[16])
  214. sgl_mult_transpose_matrix(const float m[16])
  215. The memory layout of those float[16] arrays is the same as in OpenGL.
  216. ...more matrix functions:
  217. sgl_frustum(float left, float right, float bottom, float top, float near, float far)
  218. sgl_ortho(float left, float right, float bottom, float top, float near, float far)
  219. sgl_perspective(float fov_y, float aspect, float near, float far)
  220. sgl_lookat(float eye_x, float eye_y, float eye_z, float center_x, float center_y, float center_z, float up_x, float up_y, float up_z)
  221. These functions work the same as glFrustum(), glOrtho(), gluPerspective()
  222. and gluLookAt().
  223. ...and finally to push / pop the current matrix stack:
  224. sgl_push_matrix(void)
  225. sgl_pop_matrix(void)
  226. Again, these work the same as glPushMatrix() and glPopMatrix().
  227. --- perform primitive rendering:
  228. ...set the current texture coordinate and color 'registers' with or
  229. point size with:
  230. sgl_t2f(float u, float v) - set current texture coordinate
  231. sgl_c*(...) - set current color
  232. sgl_point_size(float size) - set current point size
  233. There are several functions for setting the color (as float values,
  234. unsigned byte values, packed as unsigned 32-bit integer, with
  235. and without alpha).
  236. NOTE that these are the only functions that can be called both inside
  237. sgl_begin_*() / sgl_end() and outside.
  238. Also NOTE that point size is currently hardwired to 1.0f if the D3D11
  239. backend is used.
  240. ...start a primitive vertex sequence with:
  241. sgl_begin_points()
  242. sgl_begin_lines()
  243. sgl_begin_line_strip()
  244. sgl_begin_triangles()
  245. sgl_begin_triangle_strip()
  246. sgl_begin_quads()
  247. ...after sgl_begin_*() specify vertices:
  248. sgl_v*(...)
  249. sgl_v*_t*(...)
  250. sgl_v*_c*(...)
  251. sgl_v*_t*_c*(...)
  252. These functions write a new vertex to sokol-gl's internal vertex buffer,
  253. optionally with texture-coords and color. If the texture coordinate
  254. and/or color is missing, it will be taken from the current texture-coord
  255. and color 'register'.
  256. ...finally, after specifying vertices, call:
  257. sgl_end()
  258. This will record a new draw command in sokol-gl's internal command
  259. list, or it will extend the previous draw command if no relevant
  260. state has changed since the last sgl_begin/end pair.
  261. --- inside a sokol-gfx rendering pass, call the sgl_draw() function
  262. to render the currently active context:
  263. sgl_draw()
  264. ...or alternatively call:
  265. sgl_context_draw(ctx)
  266. ...to render an explicitly provided context.
  267. This will render everything that has been recorded in the context since
  268. the last call to sgl_draw() through sokol-gfx, and will 'rewind' the internal
  269. vertex-, uniform- and command-buffers.
  270. --- each sokol-gl context tracks internal error states which can
  271. be obtains via:
  272. sgl_error_t sgl_error()
  273. ...alternatively with an explicit context argument:
  274. sgl_error_t sgl_context_error(ctx);
  275. ...this returns a struct with the following booleans:
  276. .any - true if any of the below errors is true
  277. .vertices_full - internal vertex buffer is full (checked in sgl_end())
  278. .uniforms_full - the internal uniforms buffer is full (checked in sgl_end())
  279. .commands_full - the internal command buffer is full (checked in sgl_end())
  280. .stack_overflow - matrix- or pipeline-stack overflow
  281. .stack_underflow - matrix- or pipeline-stack underflow
  282. .no_context - the active context no longer exists
  283. ...depending on the above error state, sgl_draw() may skip rendering
  284. completely, or only draw partial geometry
  285. --- you can get the number of recorded vertices and draw commands in the current
  286. frame and active sokol-gl context via:
  287. int sgl_num_vertices()
  288. int sgl_num_commands()
  289. ...this allows you to check whether the vertex or command pools are running
  290. full before the overflow actually happens (in this case you could also
  291. check the error booleans in the result of sgl_error()).
  292. RENDER LAYERS
  293. =============
  294. Render layers allow to split sokol-gl rendering into separate draw-command
  295. groups which can then be rendered separately in a sokol-gfx draw pass. This
  296. allows to mix/interleave sokol-gl rendering with other render operations.
  297. Layered rendering is controlled through two functions:
  298. sgl_layer(int layer_id)
  299. sgl_draw_layer(int layer_id)
  300. (and the context-variant sgl_draw_layer(): sgl_context_draw_layer()
  301. The sgl_layer() function sets the 'current layer', any sokol-gl calls
  302. which internally record draw commands will also store the current layer
  303. in the draw command, and later in a sokol-gfx render pass, a call
  304. to sgl_draw_layer() will only render the draw commands that have
  305. a matching layer.
  306. The default layer is '0', this is active after sokol-gl setup, and
  307. is also restored at the start of a new frame (but *not* by calling
  308. sgl_defaults()).
  309. NOTE that calling sgl_draw() is equivalent with sgl_draw_layer(0)
  310. (in general you should either use either use sgl_draw() or
  311. sgl_draw_layer() in an application, but not both).
  312. WORKING WITH CONTEXTS:
  313. ======================
  314. If you want to render to more than one sokol-gfx render pass you need to
  315. work with additional sokol-gl context objects (one context object for
  316. each offscreen rendering pass, in addition to the implicitly created
  317. 'default context'.
  318. All sokol-gl state is tracked per context, and there is always a "current
  319. context" (with the notable exception that the currently set context is
  320. destroyed, more on that later).
  321. Using multiple contexts can also be useful if you only render in
  322. a single pass, but want to maintain multiple independent "state buckets".
  323. To create new context object, call:
  324. sgl_context ctx = sgl_make_context(&(sgl_context_desc){
  325. .max_vertices = ..., // default: 64k
  326. .max_commands = ..., // default: 16k
  327. .color_format = ...,
  328. .depth_format = ...,
  329. .sample_count = ...,
  330. });
  331. The color_format, depth_format and sample_count items must be compatible
  332. with the render pass the sgl_draw() or sgL_context_draw() function
  333. will be called in.
  334. Creating a context does *not* make the context current. To do this, call:
  335. sgl_set_context(ctx);
  336. The currently active context will implicitly be used by most sokol-gl functions
  337. which don't take an explicit context handle as argument.
  338. To switch back to the default context, pass the global constant SGL_DEFAULT_CONTEXT:
  339. sgl_set_context(SGL_DEFAULT_CONTEXT);
  340. ...or alternatively use the function sgl_default_context() instead of the
  341. global constant:
  342. sgl_set_context(sgl_default_context());
  343. To get the currently active context, call:
  344. sgl_context cur_ctx = sgl_get_context();
  345. The following functions exist in two variants, one which use the currently
  346. active context (set with sgl_set_context()), and another version which
  347. takes an explicit context handle instead:
  348. sgl_make_pipeline() vs sgl_context_make_pipeline()
  349. sgl_error() vs sgl_context_error();
  350. sgl_draw() vs sgl_context_draw();
  351. Except for using the currently active context versus a provided context
  352. handle, the two variants are exactlyidentical, e.g. the following
  353. code sequences do the same thing:
  354. sgl_set_context(ctx);
  355. sgl_pipeline pip = sgl_make_pipeline(...);
  356. sgl_error_t err = sgl_error();
  357. sgl_draw();
  358. vs
  359. sgl_pipeline pip = sgl_context_make_pipeline(ctx, ...);
  360. sgl_error_t err = sgl_context_error(ctx);
  361. sgl_context_draw(ctx);
  362. Destroying the currently active context is a 'soft error'. All following
  363. calls which require a currently active context will silently fail,
  364. and sgl_error() will return SGL_ERROR_NO_CONTEXT.
  365. UNDER THE HOOD:
  366. ===============
  367. sokol_gl.h works by recording vertex data and rendering commands into
  368. memory buffers, and then drawing the recorded commands via sokol_gfx.h
  369. The only functions which call into sokol_gfx.h are:
  370. - sgl_setup()
  371. - sgl_shutdown()
  372. - sgl_draw() (and variants)
  373. sgl_setup() must be called after initializing sokol-gfx.
  374. sgl_shutdown() must be called before shutting down sokol-gfx.
  375. sgl_draw() must be called once per frame inside a sokol-gfx render pass.
  376. All other sokol-gl function can be called anywhere in a frame, since
  377. they just record data into memory buffers owned by sokol-gl.
  378. What happens in:
  379. sgl_setup():
  380. Unique resources shared by all contexts are created:
  381. - a shader object (using embedded shader source or byte code)
  382. - an 8x8 white default texture
  383. The default context is created, which involves:
  384. - 3 memory buffers are created, one for vertex data,
  385. one for uniform data, and one for commands
  386. - a dynamic vertex buffer is created
  387. - the default sgl_pipeline object is created, which involves
  388. creating 5 sg_pipeline objects
  389. One vertex is 24 bytes:
  390. - float3 position
  391. - float2 texture coords
  392. - uint32_t color
  393. One uniform block is 128 bytes:
  394. - mat4 model-view-projection matrix
  395. - mat4 texture matrix
  396. One draw command is ca. 24 bytes for the actual
  397. command code plus command arguments.
  398. Each sgl_end() consumes one command, and one uniform block
  399. (only when the matrices have changed).
  400. The required size for one sgl_begin/end pair is (at most):
  401. (152 + 24 * num_verts) bytes
  402. sgl_shutdown():
  403. - all sokol-gfx resources (buffer, shader, default-texture and
  404. all pipeline objects) are destroyed
  405. - the 3 memory buffers are freed
  406. sgl_draw() (and variants)
  407. - copy all recorded vertex data into the dynamic sokol-gfx buffer
  408. via a call to sg_update_buffer()
  409. - for each recorded command:
  410. - if the layer number stored in the command doesn't match
  411. the layer that's to be rendered, skip to the next
  412. command
  413. - if it's a viewport command, call sg_apply_viewport()
  414. - if it's a scissor-rect command, call sg_apply_scissor_rect()
  415. - if it's a draw command:
  416. - depending on what has changed since the last draw command,
  417. call sg_apply_pipeline(), sg_apply_bindings() and
  418. sg_apply_uniforms()
  419. - finally call sg_draw()
  420. All other functions only modify the internally tracked state, add
  421. data to the vertex, uniform and command buffers, or manipulate
  422. the matrix stack.
  423. ON DRAW COMMAND MERGING
  424. =======================
  425. Not every call to sgl_end() will automatically record a new draw command.
  426. If possible, the previous draw command will simply be extended,
  427. resulting in fewer actual draw calls later in sgl_draw().
  428. A draw command will be merged with the previous command if "no relevant
  429. state has changed" since the last sgl_end(), meaning:
  430. - no calls to sgl_viewport() and sgl_scissor_rect()
  431. - the primitive type hasn't changed
  432. - the primitive type isn't a 'strip type' (no line or triangle strip)
  433. - the pipeline state object hasn't changed
  434. - the current layer hasn't changed
  435. - none of the matrices has changed
  436. - none of the texture state has changed
  437. Merging a draw command simply means that the number of vertices
  438. to render in the previous draw command will be incremented by the
  439. number of vertices in the new draw command.
  440. MEMORY ALLOCATION OVERRIDE
  441. ==========================
  442. You can override the memory allocation functions at initialization time
  443. like this:
  444. void* my_alloc(size_t size, void* user_data) {
  445. return malloc(size);
  446. }
  447. void my_free(void* ptr, void* user_data) {
  448. free(ptr);
  449. }
  450. ...
  451. sgl_setup(&(sgl_desc_t){
  452. // ...
  453. .allocator = {
  454. .alloc_fn = my_alloc,
  455. .free_fn = my_free,
  456. .user_data = ...;
  457. }
  458. });
  459. ...
  460. If no overrides are provided, malloc and free will be used.
  461. ERROR REPORTING AND LOGGING
  462. ===========================
  463. To get any logging information at all you need to provide a logging callback in the setup call,
  464. the easiest way is to use sokol_log.h:
  465. #include "sokol_log.h"
  466. sgl_setup(&(sgl_desc_t){
  467. // ...
  468. .logger.func = slog_func
  469. });
  470. To override logging with your own callback, first write a logging function like this:
  471. void my_log(const char* tag, // e.g. 'sgl'
  472. uint32_t log_level, // 0=panic, 1=error, 2=warn, 3=info
  473. uint32_t log_item_id, // SGL_LOGITEM_*
  474. const char* message_or_null, // a message string, may be nullptr in release mode
  475. uint32_t line_nr, // line number in sokol_gl.h
  476. const char* filename_or_null, // source filename, may be nullptr in release mode
  477. void* user_data)
  478. {
  479. ...
  480. }
  481. ...and then setup sokol-gl like this:
  482. sgl_setup(&(sgl_desc_t){
  483. .logger = {
  484. .func = my_log,
  485. .user_data = my_user_data,
  486. }
  487. });
  488. The provided logging function must be reentrant (e.g. be callable from
  489. different threads).
  490. If you don't want to provide your own custom logger it is highly recommended to use
  491. the standard logger in sokol_log.h instead, otherwise you won't see any warnings or
  492. errors.
  493. LICENSE
  494. =======
  495. zlib/libpng license
  496. Copyright (c) 2018 Andre Weissflog
  497. This software is provided 'as-is', without any express or implied warranty.
  498. In no event will the authors be held liable for any damages arising from the
  499. use of this software.
  500. Permission is granted to anyone to use this software for any purpose,
  501. including commercial applications, and to alter it and redistribute it
  502. freely, subject to the following restrictions:
  503. 1. The origin of this software must not be misrepresented; you must not
  504. claim that you wrote the original software. If you use this software in a
  505. product, an acknowledgment in the product documentation would be
  506. appreciated but is not required.
  507. 2. Altered source versions must be plainly marked as such, and must not
  508. be misrepresented as being the original software.
  509. 3. This notice may not be removed or altered from any source
  510. distribution.
  511. */
  512. #define SOKOL_GL_INCLUDED (1)
  513. #include <stdint.h>
  514. #include <stdbool.h>
  515. #include <stddef.h> // size_t, offsetof
  516. #if !defined(SOKOL_GFX_INCLUDED)
  517. #error "Please include sokol_gfx.h before sokol_gl.h"
  518. #endif
  519. #if defined(SOKOL_API_DECL) && !defined(SOKOL_GL_API_DECL)
  520. #define SOKOL_GL_API_DECL SOKOL_API_DECL
  521. #endif
  522. #ifndef SOKOL_GL_API_DECL
  523. #if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_GL_IMPL)
  524. #define SOKOL_GL_API_DECL __declspec(dllexport)
  525. #elif defined(_WIN32) && defined(SOKOL_DLL)
  526. #define SOKOL_GL_API_DECL __declspec(dllimport)
  527. #else
  528. #define SOKOL_GL_API_DECL extern
  529. #endif
  530. #endif
  531. #ifdef __cplusplus
  532. extern "C" {
  533. #endif
  534. /*
  535. sgl_log_item_t
  536. Log items are defined via X-Macros, and expanded to an
  537. enum 'sgl_log_item' - and in debug mode only - corresponding strings.
  538. Used as parameter in the logging callback.
  539. */
  540. #define _SGL_LOG_ITEMS \
  541. _SGL_LOGITEM_XMACRO(OK, "Ok") \
  542. _SGL_LOGITEM_XMACRO(MALLOC_FAILED, "memory allocation failed") \
  543. _SGL_LOGITEM_XMACRO(MAKE_PIPELINE_FAILED, "sg_make_pipeline() failed") \
  544. _SGL_LOGITEM_XMACRO(PIPELINE_POOL_EXHAUSTED, "pipeline pool exhausted (use sgl_desc_t.pipeline_pool_size to adjust)") \
  545. _SGL_LOGITEM_XMACRO(ADD_COMMIT_LISTENER_FAILED, "sg_add_commit_listener() failed") \
  546. _SGL_LOGITEM_XMACRO(CONTEXT_POOL_EXHAUSTED, "context pool exhausted (use sgl_desc_t.context_pool_size to adjust)") \
  547. _SGL_LOGITEM_XMACRO(CANNOT_DESTROY_DEFAULT_CONTEXT, "cannot destroy default context") \
  548. #define _SGL_LOGITEM_XMACRO(item,msg) SGL_LOGITEM_##item,
  549. typedef enum sgl_log_item_t {
  550. _SGL_LOG_ITEMS
  551. } sgl_log_item_t;
  552. #undef _SGL_LOGITEM_XMACRO
  553. /*
  554. sgl_logger_t
  555. Used in sgl_desc_t to provide a custom logging and error reporting
  556. callback to sokol-gl.
  557. */
  558. typedef struct sgl_logger_t {
  559. void (*func)(
  560. const char* tag, // always "sgl"
  561. uint32_t log_level, // 0=panic, 1=error, 2=warning, 3=info
  562. uint32_t log_item_id, // SGL_LOGITEM_*
  563. const char* message_or_null, // a message string, may be nullptr in release mode
  564. uint32_t line_nr, // line number in sokol_gl.h
  565. const char* filename_or_null, // source filename, may be nullptr in release mode
  566. void* user_data);
  567. void* user_data;
  568. } sgl_logger_t;
  569. /* sokol_gl pipeline handle (created with sgl_make_pipeline()) */
  570. typedef struct sgl_pipeline { uint32_t id; } sgl_pipeline;
  571. /* a context handle (created with sgl_make_context()) */
  572. typedef struct sgl_context { uint32_t id; } sgl_context;
  573. /*
  574. sgl_error_t
  575. Errors are reset each frame after calling sgl_draw(),
  576. get the last error code with sgl_error()
  577. */
  578. typedef struct sgl_error_t {
  579. bool any;
  580. bool vertices_full;
  581. bool uniforms_full;
  582. bool commands_full;
  583. bool stack_overflow;
  584. bool stack_underflow;
  585. bool no_context;
  586. } sgl_error_t;
  587. /*
  588. sgl_context_desc_t
  589. Describes the initialization parameters of a rendering context.
  590. Creating additional contexts is useful if you want to render
  591. in separate sokol-gfx passes.
  592. */
  593. typedef struct sgl_context_desc_t {
  594. int max_vertices; // default: 64k
  595. int max_commands; // default: 16k
  596. sg_pixel_format color_format;
  597. sg_pixel_format depth_format;
  598. int sample_count;
  599. } sgl_context_desc_t;
  600. /*
  601. sgl_allocator_t
  602. Used in sgl_desc_t to provide custom memory-alloc and -free functions
  603. to sokol_gl.h. If memory management should be overridden, both the
  604. alloc and free function must be provided (e.g. it's not valid to
  605. override one function but not the other).
  606. */
  607. typedef struct sgl_allocator_t {
  608. void* (*alloc_fn)(size_t size, void* user_data);
  609. void (*free_fn)(void* ptr, void* user_data);
  610. void* user_data;
  611. } sgl_allocator_t;
  612. typedef struct sgl_desc_t {
  613. int max_vertices; // default: 64k
  614. int max_commands; // default: 16k
  615. int context_pool_size; // max number of contexts (including default context), default: 4
  616. int pipeline_pool_size; // size of internal pipeline pool, default: 64
  617. sg_pixel_format color_format;
  618. sg_pixel_format depth_format;
  619. int sample_count;
  620. sg_face_winding face_winding; // default: SG_FACEWINDING_CCW
  621. sgl_allocator_t allocator; // optional memory allocation overrides (default: malloc/free)
  622. sgl_logger_t logger; // optional log function override (default: NO LOGGING)
  623. } sgl_desc_t;
  624. /* the default context handle */
  625. static const sgl_context SGL_DEFAULT_CONTEXT = { 0x00010001 };
  626. /* setup/shutdown/misc */
  627. SOKOL_GL_API_DECL void sgl_setup(const sgl_desc_t* desc);
  628. SOKOL_GL_API_DECL void sgl_shutdown(void);
  629. SOKOL_GL_API_DECL float sgl_rad(float deg);
  630. SOKOL_GL_API_DECL float sgl_deg(float rad);
  631. SOKOL_GL_API_DECL sgl_error_t sgl_error(void);
  632. SOKOL_GL_API_DECL sgl_error_t sgl_context_error(sgl_context ctx);
  633. /* context functions */
  634. SOKOL_GL_API_DECL sgl_context sgl_make_context(const sgl_context_desc_t* desc);
  635. SOKOL_GL_API_DECL void sgl_destroy_context(sgl_context ctx);
  636. SOKOL_GL_API_DECL void sgl_set_context(sgl_context ctx);
  637. SOKOL_GL_API_DECL sgl_context sgl_get_context(void);
  638. SOKOL_GL_API_DECL sgl_context sgl_default_context(void);
  639. /* get information about recorded vertices and commands in current context */
  640. SOKOL_GL_API_DECL int sgl_num_vertices(void);
  641. SOKOL_GL_API_DECL int sgl_num_commands(void);
  642. /* draw recorded commands (call inside a sokol-gfx render pass) */
  643. SOKOL_GL_API_DECL void sgl_draw(void);
  644. SOKOL_GL_API_DECL void sgl_context_draw(sgl_context ctx);
  645. SOKOL_GL_API_DECL void sgl_draw_layer(int layer_id);
  646. SOKOL_GL_API_DECL void sgl_context_draw_layer(sgl_context ctx, int layer_id);
  647. /* create and destroy pipeline objects */
  648. SOKOL_GL_API_DECL sgl_pipeline sgl_make_pipeline(const sg_pipeline_desc* desc);
  649. SOKOL_GL_API_DECL sgl_pipeline sgl_context_make_pipeline(sgl_context ctx, const sg_pipeline_desc* desc);
  650. SOKOL_GL_API_DECL void sgl_destroy_pipeline(sgl_pipeline pip);
  651. /* render state functions */
  652. SOKOL_GL_API_DECL void sgl_defaults(void);
  653. SOKOL_GL_API_DECL void sgl_viewport(int x, int y, int w, int h, bool origin_top_left);
  654. SOKOL_GL_API_DECL void sgl_viewportf(float x, float y, float w, float h, bool origin_top_left);
  655. SOKOL_GL_API_DECL void sgl_scissor_rect(int x, int y, int w, int h, bool origin_top_left);
  656. SOKOL_GL_API_DECL void sgl_scissor_rectf(float x, float y, float w, float h, bool origin_top_left);
  657. SOKOL_GL_API_DECL void sgl_enable_texture(void);
  658. SOKOL_GL_API_DECL void sgl_disable_texture(void);
  659. SOKOL_GL_API_DECL void sgl_texture(sg_view tex_view, sg_sampler smp);
  660. SOKOL_GL_API_DECL void sgl_layer(int layer_id);
  661. /* pipeline stack functions */
  662. SOKOL_GL_API_DECL void sgl_load_default_pipeline(void);
  663. SOKOL_GL_API_DECL void sgl_load_pipeline(sgl_pipeline pip);
  664. SOKOL_GL_API_DECL void sgl_push_pipeline(void);
  665. SOKOL_GL_API_DECL void sgl_pop_pipeline(void);
  666. /* matrix stack functions */
  667. SOKOL_GL_API_DECL void sgl_matrix_mode_modelview(void);
  668. SOKOL_GL_API_DECL void sgl_matrix_mode_projection(void);
  669. SOKOL_GL_API_DECL void sgl_matrix_mode_texture(void);
  670. SOKOL_GL_API_DECL void sgl_load_identity(void);
  671. SOKOL_GL_API_DECL void sgl_load_matrix(const float m[16]);
  672. SOKOL_GL_API_DECL void sgl_load_transpose_matrix(const float m[16]);
  673. SOKOL_GL_API_DECL void sgl_mult_matrix(const float m[16]);
  674. SOKOL_GL_API_DECL void sgl_mult_transpose_matrix(const float m[16]);
  675. SOKOL_GL_API_DECL void sgl_rotate(float angle_rad, float x, float y, float z);
  676. SOKOL_GL_API_DECL void sgl_scale(float x, float y, float z);
  677. SOKOL_GL_API_DECL void sgl_translate(float x, float y, float z);
  678. SOKOL_GL_API_DECL void sgl_frustum(float l, float r, float b, float t, float n, float f);
  679. SOKOL_GL_API_DECL void sgl_ortho(float l, float r, float b, float t, float n, float f);
  680. SOKOL_GL_API_DECL void sgl_perspective(float fov_y, float aspect, float z_near, float z_far);
  681. SOKOL_GL_API_DECL void sgl_lookat(float eye_x, float eye_y, float eye_z, float center_x, float center_y, float center_z, float up_x, float up_y, float up_z);
  682. SOKOL_GL_API_DECL void sgl_push_matrix(void);
  683. SOKOL_GL_API_DECL void sgl_pop_matrix(void);
  684. /* these functions only set the internal 'current texcoord / color / point size' (valid inside or outside begin/end) */
  685. SOKOL_GL_API_DECL void sgl_t2f(float u, float v);
  686. SOKOL_GL_API_DECL void sgl_c3f(float r, float g, float b);
  687. SOKOL_GL_API_DECL void sgl_c4f(float r, float g, float b, float a);
  688. SOKOL_GL_API_DECL void sgl_c3b(uint8_t r, uint8_t g, uint8_t b);
  689. SOKOL_GL_API_DECL void sgl_c4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
  690. SOKOL_GL_API_DECL void sgl_c1i(uint32_t rgba);
  691. SOKOL_GL_API_DECL void sgl_point_size(float s);
  692. /* define primitives, each begin/end is one draw command */
  693. SOKOL_GL_API_DECL void sgl_begin_points(void);
  694. SOKOL_GL_API_DECL void sgl_begin_lines(void);
  695. SOKOL_GL_API_DECL void sgl_begin_line_strip(void);
  696. SOKOL_GL_API_DECL void sgl_begin_triangles(void);
  697. SOKOL_GL_API_DECL void sgl_begin_triangle_strip(void);
  698. SOKOL_GL_API_DECL void sgl_begin_quads(void);
  699. SOKOL_GL_API_DECL void sgl_v2f(float x, float y);
  700. SOKOL_GL_API_DECL void sgl_v3f(float x, float y, float z);
  701. SOKOL_GL_API_DECL void sgl_v2f_t2f(float x, float y, float u, float v);
  702. SOKOL_GL_API_DECL void sgl_v3f_t2f(float x, float y, float z, float u, float v);
  703. SOKOL_GL_API_DECL void sgl_v2f_c3f(float x, float y, float r, float g, float b);
  704. SOKOL_GL_API_DECL void sgl_v2f_c3b(float x, float y, uint8_t r, uint8_t g, uint8_t b);
  705. SOKOL_GL_API_DECL void sgl_v2f_c4f(float x, float y, float r, float g, float b, float a);
  706. SOKOL_GL_API_DECL void sgl_v2f_c4b(float x, float y, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
  707. SOKOL_GL_API_DECL void sgl_v2f_c1i(float x, float y, uint32_t rgba);
  708. SOKOL_GL_API_DECL void sgl_v3f_c3f(float x, float y, float z, float r, float g, float b);
  709. SOKOL_GL_API_DECL void sgl_v3f_c3b(float x, float y, float z, uint8_t r, uint8_t g, uint8_t b);
  710. SOKOL_GL_API_DECL void sgl_v3f_c4f(float x, float y, float z, float r, float g, float b, float a);
  711. SOKOL_GL_API_DECL void sgl_v3f_c4b(float x, float y, float z, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
  712. SOKOL_GL_API_DECL void sgl_v3f_c1i(float x, float y, float z, uint32_t rgba);
  713. SOKOL_GL_API_DECL void sgl_v2f_t2f_c3f(float x, float y, float u, float v, float r, float g, float b);
  714. SOKOL_GL_API_DECL void sgl_v2f_t2f_c3b(float x, float y, float u, float v, uint8_t r, uint8_t g, uint8_t b);
  715. SOKOL_GL_API_DECL void sgl_v2f_t2f_c4f(float x, float y, float u, float v, float r, float g, float b, float a);
  716. SOKOL_GL_API_DECL void sgl_v2f_t2f_c4b(float x, float y, float u, float v, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
  717. SOKOL_GL_API_DECL void sgl_v2f_t2f_c1i(float x, float y, float u, float v, uint32_t rgba);
  718. SOKOL_GL_API_DECL void sgl_v3f_t2f_c3f(float x, float y, float z, float u, float v, float r, float g, float b);
  719. SOKOL_GL_API_DECL void sgl_v3f_t2f_c3b(float x, float y, float z, float u, float v, uint8_t r, uint8_t g, uint8_t b);
  720. SOKOL_GL_API_DECL void sgl_v3f_t2f_c4f(float x, float y, float z, float u, float v, float r, float g, float b, float a);
  721. SOKOL_GL_API_DECL void sgl_v3f_t2f_c4b(float x, float y, float z, float u, float v, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
  722. SOKOL_GL_API_DECL void sgl_v3f_t2f_c1i(float x, float y, float z, float u, float v, uint32_t rgba);
  723. SOKOL_GL_API_DECL void sgl_end(void);
  724. #ifdef __cplusplus
  725. } /* extern "C" */
  726. /* reference-based equivalents for C++ */
  727. inline void sgl_setup(const sgl_desc_t& desc) { return sgl_setup(&desc); }
  728. inline sgl_context sgl_make_context(const sgl_context_desc_t& desc) { return sgl_make_context(&desc); }
  729. inline sgl_pipeline sgl_make_pipeline(const sg_pipeline_desc& desc) { return sgl_make_pipeline(&desc); }
  730. inline sgl_pipeline sgl_context_make_pipeline(sgl_context ctx, const sg_pipeline_desc& desc) { return sgl_context_make_pipeline(ctx, &desc); }
  731. #endif
  732. #endif /* SOKOL_GL_INCLUDED */
  733. // ██ ███ ███ ██████ ██ ███████ ███ ███ ███████ ███ ██ ████████ █████ ████████ ██ ██████ ███ ██
  734. // ██ ████ ████ ██ ██ ██ ██ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██
  735. // ██ ██ ████ ██ ██████ ██ █████ ██ ████ ██ █████ ██ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██
  736. // ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
  737. // ██ ██ ██ ██ ███████ ███████ ██ ██ ███████ ██ ████ ██ ██ ██ ██ ██ ██████ ██ ████
  738. //
  739. // >>implementation
  740. #ifdef SOKOL_GL_IMPL
  741. #define SOKOL_GL_IMPL_INCLUDED (1)
  742. #if defined(SOKOL_MALLOC) || defined(SOKOL_CALLOC) || defined(SOKOL_FREE)
  743. #error "SOKOL_MALLOC/CALLOC/FREE macros are no longer supported, please use sgl_desc_t.allocator to override memory allocation functions"
  744. #endif
  745. #include <stdlib.h> // malloc/free
  746. #include <string.h> // memset
  747. #include <math.h> // M_PI, sqrtf, sinf, cosf
  748. #ifndef M_PI
  749. #define M_PI 3.14159265358979323846264338327
  750. #endif
  751. #ifndef SOKOL_API_IMPL
  752. #define SOKOL_API_IMPL
  753. #endif
  754. #ifndef SOKOL_DEBUG
  755. #ifndef NDEBUG
  756. #define SOKOL_DEBUG
  757. #endif
  758. #endif
  759. #ifndef SOKOL_ASSERT
  760. #include <assert.h>
  761. #define SOKOL_ASSERT(c) assert(c)
  762. #endif
  763. #define _sgl_def(val, def) (((val) == 0) ? (def) : (val))
  764. #define _SGL_INIT_COOKIE (0xABCDABCD)
  765. /*
  766. Embedded source code compiled with:
  767. sokol-shdc -i sgl.glsl -o sgl.h -l glsl410:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgsl:spirv_vk -b
  768. (not that for Metal and D3D11 byte code, sokol-shdc must be run
  769. on macOS and Windows)
  770. @vs vs
  771. layout(binding=0) uniform vs_params {
  772. mat4 mvp;
  773. mat4 tm;
  774. };
  775. in vec4 position;
  776. in vec2 texcoord0;
  777. in vec4 color0;
  778. in float psize;
  779. out vec4 uv;
  780. out vec4 color;
  781. void main() {
  782. gl_Position = mvp * position;
  783. #ifndef SOKOL_WGSL
  784. gl_PointSize = psize;
  785. #endif
  786. uv = tm * vec4(texcoord0, 0.0, 1.0);
  787. color = color0;
  788. }
  789. @end
  790. @fs fs
  791. layout(binding=0) uniform texture2D tex;
  792. layout(binding=0) uniform sampler smp;
  793. in vec4 uv;
  794. in vec4 color;
  795. out vec4 frag_color;
  796. void main() {
  797. frag_color = texture(sampler2D(tex, smp), uv.xy) * color;
  798. }
  799. @end
  800. @program sgl vs fs
  801. */
  802. #if defined(SOKOL_GLCORE)
  803. /*
  804. #version 410
  805. uniform vec4 vs_params[8];
  806. layout(location = 0) in vec4 position;
  807. layout(location = 3) in float psize;
  808. layout(location = 0) out vec4 uv;
  809. layout(location = 1) in vec2 texcoord0;
  810. layout(location = 1) out vec4 color;
  811. layout(location = 2) in vec4 color0;
  812. void main()
  813. {
  814. gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * position;
  815. gl_PointSize = psize;
  816. uv = mat4(vs_params[4], vs_params[5], vs_params[6], vs_params[7]) * vec4(texcoord0, 0.0, 1.0);
  817. color = color0;
  818. }
  819. */
  820. static const uint8_t _sgl_vs_source_glsl410[520] = {
  821. 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,0x0a,0x75,0x6e,
  822. 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61,
  823. 0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
  824. 0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,
  825. 0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,
  826. 0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,
  827. 0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x70,0x73,
  828. 0x69,0x7a,0x65,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
  829. 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
  830. 0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,
  831. 0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,
  832. 0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6c,
  833. 0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
  834. 0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,
  835. 0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,
  836. 0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,
  837. 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,
  838. 0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,
  839. 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,
  840. 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,
  841. 0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,
  842. 0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
  843. 0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
  844. 0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74,0x53,
  845. 0x69,0x7a,0x65,0x20,0x3d,0x20,0x70,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,
  846. 0x20,0x75,0x76,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,
  847. 0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
  848. 0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
  849. 0x5b,0x36,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,
  850. 0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x74,0x65,0x78,0x63,0x6f,0x6f,
  851. 0x72,0x64,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,
  852. 0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,
  853. 0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
  854. };
  855. /*
  856. #version 410
  857. uniform sampler2D tex_smp;
  858. layout(location = 0) out vec4 frag_color;
  859. layout(location = 0) in vec4 uv;
  860. layout(location = 1) in vec4 color;
  861. void main()
  862. {
  863. frag_color = texture(tex_smp, uv.xy) * color;
  864. }
  865. */
  866. static const uint8_t _sgl_fs_source_glsl410[222] = {
  867. 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,0x0a,0x75,0x6e,
  868. 0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,
  869. 0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
  870. 0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,
  871. 0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
  872. 0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,
  873. 0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,
  874. 0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
  875. 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,
  876. 0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,
  877. 0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,
  878. 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
  879. 0x28,0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x75,0x76,0x2e,0x78,0x79,0x29,
  880. 0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
  881. };
  882. #elif defined(SOKOL_GLES3)
  883. /*
  884. #version 300 es
  885. uniform vec4 vs_params[8];
  886. layout(location = 0) in vec4 position;
  887. layout(location = 3) in float psize;
  888. out vec4 uv;
  889. layout(location = 1) in vec2 texcoord0;
  890. out vec4 color;
  891. layout(location = 2) in vec4 color0;
  892. void main()
  893. {
  894. gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * position;
  895. gl_PointSize = psize;
  896. uv = mat4(vs_params[4], vs_params[5], vs_params[6], vs_params[7]) * vec4(texcoord0, 0.0, 1.0);
  897. color = color0;
  898. }
  899. */
  900. static const uint8_t _sgl_vs_source_glsl300es[481] = {
  901. 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
  902. 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,
  903. 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
  904. 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,
  905. 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
  906. 0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
  907. 0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74,
  908. 0x20,0x70,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,
  909. 0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
  910. 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,
  911. 0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,
  912. 0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,
  913. 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,
  914. 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,
  915. 0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,
  916. 0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
  917. 0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
  918. 0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
  919. 0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,
  920. 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,
  921. 0x2a,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,
  922. 0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,0x65,0x20,0x3d,0x20,0x70,
  923. 0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x6d,
  924. 0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,
  925. 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20,
  926. 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x76,0x73,
  927. 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,
  928. 0x63,0x34,0x28,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2c,0x20,0x30,0x2e,
  929. 0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,
  930. 0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,
  931. 0x00,
  932. };
  933. /*
  934. #version 300 es
  935. precision mediump float;
  936. precision highp int;
  937. uniform highp sampler2D tex_smp;
  938. layout(location = 0) out highp vec4 frag_color;
  939. in highp vec4 uv;
  940. in highp vec4 color;
  941. void main()
  942. {
  943. frag_color = texture(tex_smp, uv.xy) * color;
  944. }
  945. */
  946. static const uint8_t _sgl_fs_source_glsl300es[253] = {
  947. 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
  948. 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
  949. 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
  950. 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
  951. 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
  952. 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,0x3b,0x0a,
  953. 0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
  954. 0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
  955. 0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,
  956. 0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x75,
  957. 0x76,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,
  958. 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,
  959. 0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,
  960. 0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,
  961. 0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x75,0x76,0x2e,0x78,0x79,0x29,0x20,
  962. 0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
  963. };
  964. #elif defined(SOKOL_METAL)
  965. /*
  966. #include <metal_stdlib>
  967. #include <simd/simd.h>
  968. using namespace metal;
  969. struct vs_params
  970. {
  971. float4x4 mvp;
  972. float4x4 tm;
  973. };
  974. struct main0_out
  975. {
  976. float4 uv [[user(locn0)]];
  977. float4 color [[user(locn1)]];
  978. float4 gl_Position [[position]];
  979. float gl_PointSize [[point_size]];
  980. };
  981. struct main0_in
  982. {
  983. float4 position [[attribute(0)]];
  984. float2 texcoord0 [[attribute(1)]];
  985. float4 color0 [[attribute(2)]];
  986. float psize [[attribute(3)]];
  987. };
  988. vertex main0_out main0(main0_in in [[stage_in]], constant vs_params& _19 [[buffer(0)]])
  989. {
  990. main0_out out = {};
  991. out.gl_Position = _19.mvp * in.position;
  992. out.gl_PointSize = in.psize;
  993. out.uv = _19.tm * float4(in.texcoord0, 0.0, 1.0);
  994. out.color = in.color0;
  995. return out;
  996. }
  997. */
  998. static const uint8_t _sgl_vs_bytecode_metal_macos[3381] = {
  999. 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1000. 0x35,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1001. 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1002. 0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
  1003. 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
  1004. 0x20,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00,
  1005. 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45,
  1006. 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0x59,0xf1,0xe4,0x22,0x0f,0x75,0x42,
  1007. 0x53,0x9c,0x2a,0x05,0xe4,0xbd,0x91,0x28,0x82,0x06,0x3f,0x0d,0xb9,0xef,0x34,0xbd,
  1008. 0xe8,0xfa,0x46,0x5c,0x66,0x1f,0xc6,0xde,0x3a,0x4f,0x46,0x46,0x54,0x18,0x00,0x00,
  1009. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1010. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08,
  1011. 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x40,0x00,0x00,0x00,0x56,0x41,0x54,
  1012. 0x54,0x2a,0x00,0x04,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x00,0x80,
  1013. 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80,0x63,0x6f,0x6c,0x6f,
  1014. 0x72,0x30,0x00,0x02,0x80,0x70,0x73,0x69,0x7a,0x65,0x00,0x03,0x80,0x56,0x41,0x54,
  1015. 0x59,0x06,0x00,0x04,0x00,0x06,0x04,0x06,0x03,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,
  1016. 0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,
  1017. 0x00,0x04,0x0c,0x00,0x00,0xff,0xff,0xff,0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,
  1018. 0x00,0xfe,0x02,0x00,0x00,0x0b,0x82,0x20,0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,
  1019. 0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,
  1020. 0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,
  1021. 0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,
  1022. 0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,
  1023. 0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00,0x51,0x18,0x00,0x00,0x68,0x00,0x00,
  1024. 0x00,0x1b,0x7e,0x24,0xf8,0xff,0xff,0xff,0xff,0x01,0x90,0x00,0x8a,0x08,0x07,0x78,
  1025. 0x80,0x07,0x79,0x78,0x07,0x7c,0x68,0x03,0x73,0xa8,0x07,0x77,0x18,0x87,0x36,0x30,
  1026. 0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,
  1027. 0x01,0x20,0xda,0x21,0x1d,0xdc,0xa1,0x0d,0xd8,0xa1,0x1c,0xce,0x21,0x1c,0xd8,0xa1,
  1028. 0x0d,0xec,0xa1,0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e,0xda,0xe0,0x1e,0xd2,0x81,0x1c,
  1029. 0xe8,0x01,0x1d,0x80,0x38,0x90,0x03,0x3c,0x00,0x06,0x77,0x78,0x87,0x36,0x10,0x87,
  1030. 0x7a,0x48,0x07,0x76,0xa0,0x87,0x74,0x70,0x87,0x79,0x00,0x08,0x77,0x78,0x87,0x36,
  1031. 0x30,0x07,0x79,0x08,0x87,0x76,0x28,0x87,0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,
  1032. 0x87,0x72,0x90,0x87,0x36,0x28,0x07,0x76,0x48,0x87,0x76,0x00,0xe8,0x41,0x1e,0xea,
  1033. 0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,
  1034. 0x0d,0xe0,0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,
  1035. 0xd2,0xa1,0x1d,0xda,0xc0,0x1d,0xde,0xc1,0x1d,0xda,0x80,0x1d,0xca,0x21,0x1c,0xcc,
  1036. 0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,
  1037. 0x30,0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,
  1038. 0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xdc,0x21,0x1c,0xdc,
  1039. 0x61,0x1e,0xda,0xc0,0x1c,0xe0,0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,
  1040. 0x90,0x87,0x7a,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x79,0x48,0x87,0x73,0x70,
  1041. 0x87,0x72,0x20,0x87,0x36,0xd0,0x87,0x72,0x90,0x87,0x77,0x98,0x87,0x36,0x30,0x07,
  1042. 0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,
  1043. 0x20,0xdc,0xe1,0x1d,0xda,0x80,0x1e,0xe4,0x21,0x1c,0xe0,0x01,0x1e,0xd2,0xc1,0x1d,
  1044. 0xce,0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,
  1045. 0x80,0x98,0x07,0x7a,0x08,0x87,0x71,0x58,0x87,0x36,0x80,0x07,0x79,0x78,0x07,0x7a,
  1046. 0x28,0x87,0x71,0xa0,0x87,0x77,0x90,0x87,0x36,0x10,0x87,0x7a,0x30,0x07,0x73,0x28,
  1047. 0x07,0x79,0x68,0x83,0x79,0x48,0x07,0x7d,0x28,0x07,0x00,0x0f,0x00,0xa2,0x1e,0xdc,
  1048. 0x61,0x1e,0xc2,0xc1,0x1c,0xca,0xa1,0x0d,0xcc,0x01,0x1e,0xda,0xa0,0x1d,0xc2,0x81,
  1049. 0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x36,0x18,0x42,0x01,0x2c,0x40,
  1050. 0x05,0x49,0x18,0x00,0x00,0x01,0x00,0x00,0x00,0x13,0x84,0x40,0x00,0x89,0x20,0x00,
  1051. 0x00,0x20,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,
  1052. 0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,
  1053. 0x4c,0x10,0x44,0x33,0x00,0xc3,0x08,0x04,0x60,0x89,0x10,0x02,0x18,0x46,0x10,0x80,
  1054. 0x24,0x08,0x33,0x51,0xf3,0x40,0x0f,0xf2,0x50,0x0f,0xe3,0x40,0x0f,0x6e,0xd0,0x0e,
  1055. 0xe5,0x40,0x0f,0xe1,0xc0,0x0e,0x7a,0xa0,0x07,0xed,0x10,0x0e,0xf4,0x20,0x0f,0xe9,
  1056. 0x80,0x0f,0x28,0x20,0x07,0x49,0x53,0x44,0x09,0x93,0x5f,0x49,0xff,0x03,0x44,0x00,
  1057. 0x23,0x21,0xa1,0x94,0x41,0x04,0x43,0x28,0x86,0x08,0x23,0x80,0x43,0x68,0x20,0x60,
  1058. 0x8e,0x00,0x0c,0x52,0x60,0xcd,0x11,0x80,0xc2,0x20,0x42,0x20,0x0c,0x23,0x10,0xcb,
  1059. 0x08,0x00,0x00,0x00,0x00,0x13,0xb2,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,
  1060. 0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x76,0x08,0x87,0x71,0x78,0x87,0x79,
  1061. 0xc0,0x87,0x38,0x80,0x03,0x37,0x88,0x83,0x38,0x70,0x03,0x38,0xd8,0x70,0x1b,0xe5,
  1062. 0xd0,0x06,0xf0,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,
  1063. 0x07,0x6d,0x90,0x0e,0x71,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,0xe9,0x80,0x07,
  1064. 0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,
  1065. 0xa0,0x07,0x71,0x60,0x07,0x6d,0x90,0x0e,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,
  1066. 0x07,0x73,0x20,0x07,0x6d,0x90,0x0e,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,
  1067. 0x76,0x40,0x07,0x6d,0x60,0x0e,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,
  1068. 0x20,0x07,0x6d,0x60,0x0e,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,
  1069. 0x07,0x6d,0x60,0x0f,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,
  1070. 0x6d,0x60,0x0f,0x72,0x40,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,
  1071. 0x60,0x0f,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,
  1072. 0x0f,0x74,0x80,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,
  1073. 0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x79,
  1074. 0x60,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,
  1075. 0x0f,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,
  1076. 0x78,0xd0,0x06,0xf6,0x10,0x07,0x79,0x20,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,
  1077. 0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,
  1078. 0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x50,0x07,0x71,0x20,0x07,
  1079. 0x7a,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x6d,0x60,0x0f,0x71,
  1080. 0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,0x00,
  1081. 0x07,0x72,0x40,0x07,0x6d,0xe0,0x0e,0x78,0xa0,0x07,0x71,0x60,0x07,0x7a,0x30,0x07,
  1082. 0x72,0x30,0x84,0x49,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0xc8,0x02,0x01,0x00,
  1083. 0x00,0x0b,0x00,0x00,0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,
  1084. 0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02,0x50,0x04,0x05,0x18,0x50,0x08,0x65,0x50,
  1085. 0x80,0x02,0x05,0x51,0x20,0xd4,0x46,0x00,0x88,0x8d,0x25,0x3c,0x00,0x00,0x00,0x00,
  1086. 0x00,0x79,0x18,0x00,0x00,0x01,0x01,0x00,0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,
  1087. 0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x32,0x28,0x00,0xb3,0x50,
  1088. 0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x2c,0x81,0x22,0x2c,
  1089. 0x05,0xe3,0x20,0x08,0x0e,0x8e,0xad,0x0c,0xa4,0xad,0x8c,0x2e,0x8c,0x0d,0xc4,0xae,
  1090. 0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x46,0x06,0x46,0x66,0xc6,0x65,0x66,0xa6,0x06,
  1091. 0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x65,0x46,0x06,0x46,0x66,0xc6,0x65,
  1092. 0x66,0xa6,0x26,0x65,0x88,0xa0,0x10,0x43,0x8c,0x25,0x58,0x90,0x45,0x60,0xd1,0x54,
  1093. 0x46,0x17,0xc6,0x36,0x04,0x51,0x8e,0x25,0x58,0x82,0x45,0xe0,0x16,0x96,0x26,0xe7,
  1094. 0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,
  1095. 0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x50,0x12,0x72,0x61,0x69,0x72,0x2e,
  1096. 0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,
  1097. 0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x04,0x65,0x61,0x19,0x84,0xa5,0xc9,
  1098. 0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,
  1099. 0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x91,0xa5,0xcd,0x85,0x89,
  1100. 0xb1,0x95,0x0d,0x11,0x94,0x86,0x51,0x58,0x9a,0x9c,0x8b,0x5d,0x99,0x1c,0x5d,0x19,
  1101. 0xde,0xd7,0x5b,0x1d,0x1d,0x5c,0x1d,0x1d,0x97,0xba,0xb9,0x32,0x39,0x14,0xb6,0xb7,
  1102. 0x31,0x37,0x98,0x14,0x46,0x61,0x69,0x72,0x2e,0x61,0x72,0x67,0x5f,0x74,0x79,0x70,
  1103. 0x65,0x5f,0x6e,0x61,0x6d,0x65,0x34,0xcc,0xd8,0xde,0xc2,0xe8,0x68,0xc8,0x84,0xa5,
  1104. 0xc9,0xb9,0x84,0xc9,0x9d,0x7d,0xb9,0x85,0xb5,0x95,0x51,0xa8,0xb3,0x1b,0xc2,0x28,
  1105. 0x8f,0x02,0x29,0x91,0x22,0x29,0x93,0x42,0x71,0xa9,0x9b,0x2b,0x93,0x43,0x61,0x7b,
  1106. 0x1b,0x73,0x8b,0x49,0x61,0x31,0xf6,0xc6,0xf6,0x26,0x37,0x84,0x51,0x1e,0xc5,0x52,
  1107. 0x22,0x45,0x52,0x26,0xe5,0x22,0x13,0x96,0x26,0xe7,0x02,0xf7,0x36,0x97,0x46,0x97,
  1108. 0xf6,0xe6,0xc6,0xe5,0x8c,0xed,0x0b,0xea,0x6d,0x2e,0x8d,0x2e,0xed,0xcd,0x6d,0x88,
  1109. 0xa2,0x64,0x4a,0xa4,0x48,0xca,0xa4,0x68,0x74,0xc2,0xd2,0xe4,0x5c,0xe0,0xde,0xd2,
  1110. 0xdc,0xe8,0xbe,0xe6,0xd2,0xf4,0xca,0x58,0x98,0xb1,0xbd,0x85,0xd1,0x91,0x39,0x63,
  1111. 0xfb,0x82,0x7a,0x4b,0x73,0xa3,0x9b,0x4a,0xd3,0x2b,0x1b,0xa2,0x28,0x9c,0x12,0x29,
  1112. 0x9d,0x32,0x29,0xde,0x10,0x44,0xa9,0x14,0x4c,0xd9,0x94,0x8f,0x50,0x58,0x9a,0x9c,
  1113. 0x8b,0x5d,0x99,0x1c,0x5d,0x19,0xde,0x57,0x9a,0x1b,0x5c,0x1d,0x1d,0xa5,0xb0,0x34,
  1114. 0x39,0x17,0xb6,0xb7,0xb1,0x30,0xba,0xb4,0x37,0xb7,0xaf,0x34,0x37,0xb2,0x32,0x3c,
  1115. 0x7a,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x64,0x28,0x5f,0x5f,0x61,0x69,0x72,
  1116. 0x5f,0x70,0x6c,0x61,0x63,0x65,0x68,0x6f,0x6c,0x64,0x65,0x72,0x5f,0x5f,0x29,0x44,
  1117. 0xe0,0xde,0xe6,0xd2,0xe8,0xd2,0xde,0xdc,0x86,0x50,0x8b,0xa0,0x84,0x81,0x22,0x06,
  1118. 0x8b,0xb0,0x04,0xca,0x18,0x28,0x91,0x22,0x29,0x93,0x42,0x06,0x34,0xcc,0xd8,0xde,
  1119. 0xc2,0xe8,0x64,0x98,0xd0,0x95,0xe1,0x8d,0xbd,0xbd,0xc9,0x91,0xc1,0x0c,0xa1,0x96,
  1120. 0x40,0x09,0x03,0x45,0x0c,0x96,0x60,0x09,0x94,0x31,0x50,0x22,0xc5,0x0c,0x94,0x49,
  1121. 0x39,0x03,0x1a,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x43,0xa8,0x65,0x50,0xc2,0x40,0x11,
  1122. 0x83,0x65,0x58,0x02,0x65,0x0c,0x94,0x48,0x91,0x94,0x49,0x49,0x03,0x16,0x70,0x73,
  1123. 0x69,0x7a,0x65,0x43,0xa8,0xc5,0x50,0xc2,0x40,0x11,0x83,0xc5,0x58,0x02,0x65,0x0c,
  1124. 0x94,0x48,0xe9,0x94,0x49,0x59,0x03,0x2a,0x61,0x69,0x72,0x2e,0x62,0x75,0x66,0x66,
  1125. 0x65,0x72,0x7c,0xc2,0xd2,0xe4,0x5c,0xc4,0xea,0xcc,0xcc,0xca,0xe4,0xbe,0xe6,0xd2,
  1126. 0xf4,0xca,0x88,0x84,0xa5,0xc9,0xb9,0xc8,0x95,0x85,0x91,0x91,0x0a,0x4b,0x93,0x73,
  1127. 0x99,0xa3,0x93,0xab,0x1b,0xa3,0xfb,0xa2,0xcb,0x83,0x2b,0xfb,0x4a,0x73,0x33,0x7b,
  1128. 0x23,0x62,0xc6,0xf6,0x16,0x46,0x47,0x83,0x47,0xc3,0xa1,0xcd,0x0e,0x8e,0x02,0x5d,
  1129. 0xdb,0x10,0x6a,0x11,0x16,0x62,0x11,0x94,0x38,0x50,0xe4,0x60,0x21,0x16,0x62,0x11,
  1130. 0x94,0x38,0x50,0xe6,0x80,0x51,0x58,0x9a,0x9c,0x4b,0x98,0xdc,0xd9,0x17,0x5d,0x1e,
  1131. 0x5c,0xd9,0xd7,0x5c,0x9a,0x5e,0x19,0xaf,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,
  1132. 0xba,0x3c,0xb8,0xb2,0xaf,0x30,0xb6,0xb4,0x33,0xb7,0xaf,0xb9,0x34,0xbd,0x32,0x26,
  1133. 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x1c,0xbe,0x62,0x72,0x86,0x90,0xc1,
  1134. 0x52,0x28,0x6d,0xa0,0xb8,0xc1,0x72,0x28,0x62,0xb0,0x08,0x4b,0xa0,0xbc,0x81,0x02,
  1135. 0x07,0x0a,0x1d,0x28,0x75,0xb0,0x1c,0x8a,0x1d,0x2c,0x89,0x12,0x29,0x77,0xa0,0x4c,
  1136. 0x0a,0x1e,0x0c,0x51,0x94,0x32,0x50,0xd0,0x40,0x51,0x03,0x85,0x0d,0x94,0x3c,0x18,
  1137. 0x62,0x24,0x80,0x02,0x06,0x8a,0x1e,0xf0,0x79,0x6b,0x73,0x4b,0x83,0x7b,0xa3,0x2b,
  1138. 0x73,0xa3,0x03,0x19,0x43,0x0b,0x93,0xe3,0x33,0x95,0xd6,0x06,0xc7,0x56,0x06,0x32,
  1139. 0xb4,0xb2,0x02,0x42,0x25,0x14,0x14,0x34,0x44,0x50,0xfa,0x60,0x88,0xa1,0xf0,0x81,
  1140. 0xe2,0x07,0x8d,0x32,0xc4,0x50,0xfe,0x40,0xf9,0x83,0x46,0x19,0x11,0xb1,0x03,0x3b,
  1141. 0xd8,0x43,0x3b,0xb8,0x41,0x3b,0xbc,0x03,0x39,0xd4,0x03,0x3b,0x94,0x83,0x1b,0x98,
  1142. 0x03,0x3b,0x84,0xc3,0x39,0xcc,0xc3,0x14,0x21,0x18,0x46,0x28,0xec,0xc0,0x0e,0xf6,
  1143. 0xd0,0x0e,0x6e,0x90,0x0e,0xe4,0x50,0x0e,0xee,0x40,0x0f,0x53,0x82,0x62,0xc4,0x12,
  1144. 0x0e,0xe9,0x20,0x0f,0x6e,0x60,0x0f,0xe5,0x20,0x0f,0xf3,0x90,0x0e,0xef,0xe0,0x0e,
  1145. 0x53,0x02,0x63,0x04,0x15,0x0e,0xe9,0x20,0x0f,0x6e,0xc0,0x0e,0xe1,0xe0,0x0e,0xe7,
  1146. 0x50,0x0f,0xe1,0x70,0x0e,0xe5,0xf0,0x0b,0xf6,0x50,0x0e,0xf2,0x30,0x0f,0xe9,0xf0,
  1147. 0x0e,0xee,0x30,0x25,0x40,0x46,0x4c,0xe1,0x90,0x0e,0xf2,0xe0,0x06,0xe3,0xf0,0x0e,
  1148. 0xed,0x00,0x0f,0xe9,0xc0,0x0e,0xe5,0xf0,0x0b,0xef,0x00,0x0f,0xf4,0x90,0x0e,0xef,
  1149. 0xe0,0x0e,0xf3,0x30,0x65,0x50,0x18,0x67,0x84,0x12,0x0e,0xe9,0x20,0x0f,0x6e,0x60,
  1150. 0x0f,0xe5,0x20,0x0f,0xf4,0x50,0x0e,0xf8,0x30,0x25,0xd8,0x03,0x00,0x79,0x18,0x00,
  1151. 0x00,0xa5,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,
  1152. 0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,
  1153. 0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,
  1154. 0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,
  1155. 0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,
  1156. 0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,
  1157. 0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,
  1158. 0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,
  1159. 0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,
  1160. 0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,
  1161. 0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,
  1162. 0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,
  1163. 0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,
  1164. 0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,
  1165. 0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,
  1166. 0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,
  1167. 0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,
  1168. 0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,
  1169. 0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,
  1170. 0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,
  1171. 0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,
  1172. 0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,
  1173. 0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,
  1174. 0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,
  1175. 0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,
  1176. 0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,
  1177. 0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,
  1178. 0x07,0x7a,0x28,0x07,0x72,0x98,0x81,0x5c,0xe3,0x10,0x0e,0xec,0xc0,0x0e,0xe5,0x50,
  1179. 0x0e,0xf3,0x30,0x23,0xc1,0xd2,0x41,0x1e,0xe4,0xe1,0x17,0xd8,0xe1,0x1d,0xde,0x01,
  1180. 0x1e,0x66,0x48,0x19,0x3b,0xb0,0x83,0x3d,0xb4,0x83,0x1b,0x84,0xc3,0x38,0x8c,0x43,
  1181. 0x39,0xcc,0xc3,0x3c,0xb8,0xc1,0x39,0xc8,0xc3,0x3b,0xd4,0x03,0x3c,0xcc,0x48,0xb4,
  1182. 0x71,0x08,0x07,0x76,0x60,0x07,0x71,0x08,0x87,0x71,0x58,0x87,0x19,0xdb,0xc6,0x0e,
  1183. 0xec,0x60,0x0f,0xed,0xe0,0x06,0xf0,0x20,0x0f,0xe5,0x30,0x0f,0xe5,0x20,0x0f,0xf6,
  1184. 0x50,0x0e,0x6e,0x10,0x0e,0xe3,0x30,0x0e,0xe5,0x30,0x0f,0xf3,0xe0,0x06,0xe9,0xe0,
  1185. 0x0e,0xe4,0x50,0x0e,0xf8,0x30,0x23,0xe2,0xec,0x61,0x1c,0xc2,0x81,0x1d,0xd8,0xe1,
  1186. 0x17,0xec,0x21,0x1d,0xe6,0x21,0x1d,0xc4,0x21,0x1d,0xd8,0x21,0x1d,0xe8,0x21,0x1f,
  1187. 0x66,0x20,0x9d,0x3b,0xbc,0x43,0x3d,0xb8,0x03,0x39,0x94,0x83,0x39,0xcc,0x58,0xbc,
  1188. 0x70,0x70,0x07,0x77,0x78,0x07,0x7a,0x08,0x07,0x7a,0x48,0x87,0x77,0x70,0x87,0x19,
  1189. 0xce,0x87,0x0e,0xe5,0x10,0x0e,0xf0,0x10,0x0e,0xec,0xc0,0x0e,0xef,0x30,0x0e,0xf3,
  1190. 0x90,0x0e,0xf4,0x50,0x0e,0x33,0x28,0x30,0x08,0x87,0x74,0x90,0x07,0x37,0x30,0x87,
  1191. 0x7a,0x70,0x87,0x71,0xa0,0x87,0x74,0x78,0x07,0x77,0xf8,0x85,0x73,0x90,0x87,0x77,
  1192. 0xa8,0x07,0x78,0x98,0x07,0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00,
  1193. 0x00,0x06,0x50,0x30,0x00,0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x3e,0x00,0x00,
  1194. 0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xf4,0xc6,0x22,
  1195. 0x86,0x61,0x18,0xc6,0x22,0x04,0x41,0x10,0xc6,0x22,0x82,0x20,0x08,0x46,0x00,0xa8,
  1196. 0x95,0x40,0x19,0x14,0x01,0x8d,0x19,0x00,0x12,0x33,0x00,0x14,0x66,0x00,0x66,0x00,
  1197. 0x00,0xe3,0x15,0x8c,0xa4,0x69,0x12,0x05,0x65,0x90,0x41,0x22,0x14,0x13,0x02,0xf9,
  1198. 0x8c,0x57,0x40,0x96,0xe7,0x2d,0x14,0x94,0x41,0x06,0xeb,0x78,0x4c,0x08,0xe4,0x63,
  1199. 0x41,0x01,0x9f,0xf1,0x8a,0x6a,0x1b,0x83,0x31,0x70,0x28,0x28,0x83,0x0c,0x1b,0x53,
  1200. 0x99,0x10,0xc8,0xc7,0x8a,0x00,0x3e,0xe3,0x15,0x1a,0x18,0xa0,0x01,0x1a,0x50,0x14,
  1201. 0x94,0x41,0x06,0x30,0x88,0x36,0x13,0x02,0xf9,0x58,0x11,0xc0,0x67,0xbc,0xe2,0x2b,
  1202. 0x03,0x37,0x68,0x83,0x32,0xa0,0xa0,0x0c,0x32,0x90,0x41,0xd6,0x99,0x10,0xc8,0x67,
  1203. 0xbc,0x62,0x0c,0xd2,0x40,0x0e,0xe2,0xc0,0xa3,0xa0,0x0c,0x32,0xa0,0x41,0x27,0x06,
  1204. 0x26,0x04,0xf2,0xb1,0xa0,0x80,0xcf,0x78,0x05,0x1a,0xb8,0xc1,0x1d,0xd8,0x81,0x18,
  1205. 0x50,0x50,0x6c,0x08,0xe0,0x33,0xdb,0x20,0x06,0x01,0x30,0xdb,0x10,0xb8,0x41,0x30,
  1206. 0xdb,0x10,0x3c,0xc2,0x6c,0x43,0xf0,0x06,0x43,0x06,0x01,0x31,0x00,0x09,0x00,0x00,
  1207. 0x00,0x5b,0x86,0x20,0x00,0x85,0x2d,0x43,0x11,0x80,0xc2,0x96,0x41,0x09,0x40,0x61,
  1208. 0xcb,0xf0,0x04,0xa0,0xb0,0x65,0xa0,0x02,0x50,0xd8,0x32,0x60,0x01,0x28,0x6c,0x19,
  1209. 0xba,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1210. 0x00,0x00,0x00,0x00,0x00,
  1211. };
  1212. /*
  1213. #include <metal_stdlib>
  1214. #include <simd/simd.h>
  1215. using namespace metal;
  1216. struct main0_out
  1217. {
  1218. float4 frag_color [[color(0)]];
  1219. };
  1220. struct main0_in
  1221. {
  1222. float4 uv [[user(locn0)]];
  1223. float4 color [[user(locn1)]];
  1224. };
  1225. fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler smp [[sampler(0)]])
  1226. {
  1227. main0_out out = {};
  1228. out.frag_color = tex.sample(smp, in.uv.xy) * in.color;
  1229. return out;
  1230. }
  1231. */
  1232. static const uint8_t _sgl_fs_bytecode_metal_macos[3033] = {
  1233. 0x4d,0x54,0x4c,0x42,0x01,0x80,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1234. 0xd9,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1235. 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1236. 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1237. 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1238. 0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00,
  1239. 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45,
  1240. 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0x43,0x4f,0xc0,0x79,0x15,0x0f,0x7e,
  1241. 0x56,0x86,0x83,0xab,0x09,0x97,0xeb,0xad,0x1f,0xad,0xc5,0x99,0xa0,0x69,0x5d,0x31,
  1242. 0x4f,0x5e,0x5b,0x06,0x1b,0x6c,0x91,0x10,0xa7,0x4f,0x46,0x46,0x54,0x18,0x00,0x00,
  1243. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1244. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08,
  1245. 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,
  1246. 0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b,0x00,0x00,0x00,
  1247. 0x00,0x14,0x00,0x00,0x00,0xe4,0x0a,0x00,0x00,0xff,0xff,0xff,0xff,0x42,0x43,0xc0,
  1248. 0xde,0x21,0x0c,0x00,0x00,0xb6,0x02,0x00,0x00,0x0b,0x82,0x20,0x00,0x02,0x00,0x00,
  1249. 0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49,0x06,0x10,0x32,
  1250. 0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62,0x80,0x14,0x45,
  1251. 0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49,0x0a,0x32,0x44,
  1252. 0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72,0x24,0x07,0xc8,
  1253. 0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00,0x51,0x18,0x00,
  1254. 0x00,0x74,0x00,0x00,0x00,0x1b,0xc2,0x24,0xf8,0xff,0xff,0xff,0xff,0x01,0x60,0x00,
  1255. 0x09,0xa8,0x88,0x70,0x80,0x07,0x78,0x90,0x87,0x77,0xc0,0x87,0x36,0x30,0x87,0x7a,
  1256. 0x70,0x87,0x71,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,
  1257. 0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xa2,0x1d,0xd2,0xc1,0x1d,0xda,0x80,0x1d,0xca,
  1258. 0xe1,0x1c,0xc2,0x81,0x1d,0xda,0xc0,0x1e,0xca,0x61,0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,
  1259. 0x0d,0xee,0x21,0x1d,0xc8,0x81,0x1e,0xd0,0x01,0x88,0x03,0x39,0xc0,0x03,0x60,0x70,
  1260. 0x87,0x77,0x68,0x03,0x71,0xa8,0x87,0x74,0x60,0x07,0x7a,0x48,0x07,0x77,0x98,0x07,
  1261. 0x80,0x70,0x87,0x77,0x68,0x03,0x73,0x90,0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,
  1262. 0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07,0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,
  1263. 0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0xc0,0x1c,0xe4,
  1264. 0x21,0x1c,0xda,0xa1,0x1c,0xda,0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81,0x1e,0xca,0x41,
  1265. 0x1e,0xda,0xa0,0x1c,0xd8,0x21,0x1d,0xda,0xa1,0x0d,0xdc,0xe1,0x1d,0xdc,0xa1,0x0d,
  1266. 0xd8,0xa1,0x1c,0xc2,0xc1,0x1c,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80,0x70,0x87,
  1267. 0x77,0x68,0x83,0x74,0x70,0x07,0x73,0x98,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,
  1268. 0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,
  1269. 0xda,0xc0,0x1d,0xc2,0xc1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda,0xa0,0x1d,0xc2,
  1270. 0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,
  1271. 0x98,0x87,0x74,0x38,0x07,0x77,0x28,0x07,0x72,0x68,0x03,0x7d,0x28,0x07,0x79,0x78,
  1272. 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,
  1273. 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xe8,0x41,0x1e,0xc2,0x01,
  1274. 0x1e,0xe0,0x21,0x1d,0xdc,0xe1,0x1c,0xda,0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,
  1275. 0x07,0x79,0xa8,0x87,0x72,0x00,0x88,0x79,0xa0,0x87,0x70,0x18,0x87,0x75,0x68,0x03,
  1276. 0x78,0x90,0x87,0x77,0xa0,0x87,0x72,0x18,0x07,0x7a,0x78,0x07,0x79,0x68,0x03,0x71,
  1277. 0xa8,0x07,0x73,0x30,0x87,0x72,0x90,0x87,0x36,0x98,0x87,0x74,0xd0,0x87,0x72,0x00,
  1278. 0xf0,0x00,0x20,0xea,0xc1,0x1d,0xe6,0x21,0x1c,0xcc,0xa1,0x1c,0xda,0xc0,0x1c,0xe0,
  1279. 0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,
  1280. 0x83,0x21,0x0c,0xc0,0x02,0x54,0x1b,0x8c,0x81,0x00,0x16,0xa0,0xda,0x80,0x10,0xff,
  1281. 0xff,0xff,0xff,0x3f,0x00,0x0c,0x20,0x01,0xd5,0x06,0xa3,0x08,0x80,0x05,0xa8,0x36,
  1282. 0x18,0x86,0x00,0x2c,0x40,0xb5,0x01,0x39,0xfe,0xff,0xff,0xff,0x7f,0x00,0x18,0x40,
  1283. 0x02,0x2a,0x00,0x00,0x00,0x49,0x18,0x00,0x00,0x04,0x00,0x00,0x00,0x13,0x86,0x40,
  1284. 0x18,0x26,0x0c,0x44,0x61,0x4c,0x18,0x8e,0xc2,0x00,0x00,0x00,0x00,0x89,0x20,0x00,
  1285. 0x00,0x1d,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,
  1286. 0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,
  1287. 0x4c,0x10,0x48,0x33,0x00,0xc3,0x08,0x04,0x60,0x83,0x70,0x94,0x34,0x45,0x94,0x30,
  1288. 0xf9,0xff,0x44,0x5c,0x13,0x15,0x11,0xbf,0x3d,0xfc,0xd3,0x18,0x01,0x30,0x88,0x30,
  1289. 0x04,0x17,0x49,0x53,0x44,0x09,0x93,0xff,0x4b,0x00,0xf3,0x2c,0x44,0xf4,0x4f,0x63,
  1290. 0x04,0xc0,0x20,0x42,0x21,0x94,0x42,0x84,0x40,0x0c,0x9d,0x61,0x04,0x01,0x98,0x23,
  1291. 0x08,0xe6,0x08,0xc0,0x60,0x18,0x41,0x58,0x0a,0x12,0x88,0x49,0x8a,0x29,0x40,0x6d,
  1292. 0x20,0x20,0x05,0xd6,0x08,0x00,0x00,0x00,0x00,0x13,0xb2,0x70,0x48,0x07,0x79,0xb0,
  1293. 0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x76,0x08,0x87,
  1294. 0x71,0x78,0x87,0x79,0xc0,0x87,0x38,0x80,0x03,0x37,0x88,0x83,0x38,0x70,0x03,0x38,
  1295. 0xd8,0x70,0x1b,0xe5,0xd0,0x06,0xf0,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,
  1296. 0xa0,0x07,0x76,0x40,0x07,0x6d,0x90,0x0e,0x71,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,
  1297. 0x06,0xe9,0x80,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x71,0x60,0x07,
  1298. 0x7a,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x6d,0x90,0x0e,0x73,0x20,0x07,0x7a,
  1299. 0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x90,0x0e,0x76,0x40,0x07,0x7a,0x60,
  1300. 0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0e,0x73,0x20,0x07,0x7a,0x30,0x07,
  1301. 0x72,0xa0,0x07,0x73,0x20,0x07,0x6d,0x60,0x0e,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,
  1302. 0xa0,0x07,0x76,0x40,0x07,0x6d,0x60,0x0f,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xa0,
  1303. 0x07,0x71,0x60,0x07,0x6d,0x60,0x0f,0x72,0x40,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,
  1304. 0x73,0x20,0x07,0x6d,0x60,0x0f,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xa0,0x07,0x73,
  1305. 0x20,0x07,0x6d,0x60,0x0f,0x74,0x80,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,
  1306. 0x07,0x6d,0x60,0x0f,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,
  1307. 0x6d,0x60,0x0f,0x79,0x60,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,
  1308. 0x80,0x07,0x6d,0x60,0x0f,0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xa0,
  1309. 0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x79,0x20,0x07,0x7a,0x20,0x07,
  1310. 0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x72,0x50,0x07,0x76,
  1311. 0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,0x50,
  1312. 0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07,0x7a,0x50,0x07,0x71,0x20,0x07,
  1313. 0x6d,0x60,0x0f,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74,
  1314. 0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x6d,0xe0,0x0e,0x78,0xa0,0x07,0x71,0x60,
  1315. 0x07,0x7a,0x30,0x07,0x72,0x30,0x84,0x41,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,
  1316. 0x18,0xc2,0x38,0x40,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x64,0x81,0x00,0x00,0x00,
  1317. 0x00,0x08,0x00,0x00,0x00,0x32,0x1e,0x98,0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,
  1318. 0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02,0x50,0x04,0x85,0x50,0x10,0x65,0x40,0x70,
  1319. 0x2c,0xe1,0x01,0x00,0x00,0x79,0x18,0x00,0x00,0xd1,0x00,0x00,0x00,0x1a,0x03,0x4c,
  1320. 0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x42,
  1321. 0x3c,0x00,0x84,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,
  1322. 0x2c,0xc2,0x23,0x2c,0x05,0xe3,0x20,0x08,0x0e,0x8e,0xad,0x0c,0xa4,0xad,0x8c,0x2e,
  1323. 0x8c,0x0d,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x46,0x06,0x46,0x66,0xc6,
  1324. 0x65,0x66,0xa6,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,0xac,0x65,0x46,0x06,
  1325. 0x46,0x66,0xc6,0x65,0x66,0xa6,0x26,0x65,0x88,0xf0,0x10,0x43,0x8c,0x45,0x58,0x8c,
  1326. 0x65,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x79,0x8e,0x45,0x58,0x84,0x65,0xe0,
  1327. 0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,
  1328. 0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,0x44,0x78,0x12,0x72,
  1329. 0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,
  1330. 0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,0x43,0x84,0x67,0x61,
  1331. 0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,
  1332. 0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x91,
  1333. 0xa5,0xcd,0x85,0x89,0xb1,0x95,0x0d,0x11,0x9e,0x86,0x51,0x58,0x9a,0x9c,0x8b,0x5c,
  1334. 0x99,0x1b,0x59,0x99,0xdc,0x17,0x5d,0x98,0xdc,0x59,0x19,0x1d,0xa3,0xb0,0x34,0x39,
  1335. 0x97,0x30,0xb9,0xb3,0x2f,0xba,0x3c,0xb8,0xb2,0x2f,0xb7,0xb0,0xb6,0x32,0x1a,0x66,
  1336. 0x6c,0x6f,0x61,0x74,0x34,0x64,0xc2,0xd2,0xe4,0x5c,0xc2,0xe4,0xce,0xbe,0xdc,0xc2,
  1337. 0xda,0xca,0xa8,0x98,0xc9,0x85,0x9d,0x7d,0x8d,0xbd,0xb1,0xbd,0xc9,0x0d,0x61,0x9e,
  1338. 0x67,0x19,0x1e,0xe8,0x89,0x1e,0xe9,0x99,0x86,0x08,0x0f,0x45,0x29,0x2c,0x4d,0xce,
  1339. 0xc5,0x4c,0x2e,0xec,0xac,0xad,0xcc,0x8d,0xee,0x2b,0xcd,0x0d,0xae,0x8e,0x8e,0x4b,
  1340. 0xdd,0x5c,0x99,0x1c,0x0a,0xdb,0xdb,0x98,0x1b,0x4c,0x0a,0x95,0xb0,0x34,0x39,0x97,
  1341. 0xb1,0x32,0x37,0xba,0x32,0x39,0x3e,0x61,0x69,0x72,0x2e,0x70,0x65,0x72,0x73,0x70,
  1342. 0x65,0x63,0x74,0x69,0x76,0x65,0x14,0xea,0xec,0x86,0x48,0xcb,0xf0,0x58,0xcf,0xf5,
  1343. 0x60,0x4f,0xf6,0x40,0x4f,0xf4,0x48,0x8f,0xc6,0xa5,0x6e,0xae,0x4c,0x0e,0x85,0xed,
  1344. 0x6d,0xcc,0x2d,0x26,0x85,0xc5,0xd8,0x1b,0xdb,0x9b,0xdc,0x10,0x69,0x11,0x1e,0xeb,
  1345. 0xe1,0x1e,0xec,0xc9,0x1e,0xe8,0x89,0x1e,0xe9,0xe9,0xb8,0x84,0xa5,0xc9,0xb9,0xd0,
  1346. 0x95,0xe1,0xd1,0xd5,0xc9,0x95,0x51,0x0a,0x4b,0x93,0x73,0x61,0x7b,0x1b,0x0b,0xa3,
  1347. 0x4b,0x7b,0x73,0xfb,0x4a,0x73,0x23,0x2b,0xc3,0xa3,0x12,0x96,0x26,0xe7,0x32,0x17,
  1348. 0xd6,0x06,0xc7,0x56,0x46,0x8c,0xae,0x0c,0x8f,0xae,0x4e,0xae,0x4c,0x86,0x8c,0xc7,
  1349. 0x8c,0xed,0x2d,0x8c,0x8e,0x05,0x64,0x2e,0xac,0x0d,0x8e,0xad,0xcc,0x87,0x03,0x5d,
  1350. 0x19,0xde,0x10,0x6a,0x21,0x9e,0xef,0x01,0x83,0x65,0x58,0x84,0x27,0x0c,0x1e,0xe8,
  1351. 0x11,0x83,0x47,0x7a,0xc6,0x80,0x4b,0x58,0x9a,0x9c,0xcb,0x5c,0x58,0x1b,0x1c,0x5b,
  1352. 0x99,0x1c,0x8f,0xb9,0xb0,0x36,0x38,0xb6,0x32,0x39,0x0e,0x73,0x6d,0x70,0x43,0xa4,
  1353. 0xe5,0x78,0xca,0xe0,0x01,0x83,0x65,0x58,0x84,0x07,0x7a,0xcc,0xe0,0x91,0x9e,0x33,
  1354. 0x18,0x82,0x3c,0xdb,0xe3,0x3d,0x64,0xf0,0xa0,0xc1,0x10,0x03,0x01,0x9e,0xea,0x49,
  1355. 0x03,0x5e,0x61,0x69,0x72,0x2d,0x61,0x6c,0x69,0x61,0x73,0x2d,0x73,0x63,0x6f,0x70,
  1356. 0x65,0x73,0x28,0x6d,0x61,0x69,0x6e,0x30,0x29,0x43,0x88,0x87,0x0d,0x9e,0x35,0x20,
  1357. 0x16,0x96,0x26,0xd7,0x12,0xc6,0x96,0x16,0x36,0xd7,0x32,0x37,0xf6,0x06,0x57,0xd6,
  1358. 0x42,0x57,0x86,0x47,0x57,0x27,0x57,0x36,0x37,0xc4,0x78,0xdc,0xe0,0x61,0x83,0xa7,
  1359. 0x0d,0x88,0x85,0xa5,0xc9,0xb5,0x84,0xb1,0xa5,0x85,0xcd,0xb5,0xcc,0x8d,0xbd,0xc1,
  1360. 0x95,0xb5,0xcc,0x85,0xb5,0xc1,0xb1,0x95,0xc9,0xcd,0x0d,0x31,0x1e,0x38,0x78,0xd8,
  1361. 0xe0,0x79,0x83,0x21,0xc4,0xe3,0x06,0x0f,0x1c,0x8c,0x88,0xd8,0x81,0x1d,0xec,0xa1,
  1362. 0x1d,0xdc,0xa0,0x1d,0xde,0x81,0x1c,0xea,0x81,0x1d,0xca,0xc1,0x0d,0xcc,0x81,0x1d,
  1363. 0xc2,0xe1,0x1c,0xe6,0x61,0x8a,0x10,0x0c,0x23,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,
  1364. 0x37,0x48,0x07,0x72,0x28,0x07,0x77,0xa0,0x87,0x29,0x41,0x31,0x62,0x09,0x87,0x74,
  1365. 0x90,0x07,0x37,0xb0,0x87,0x72,0x90,0x87,0x79,0x48,0x87,0x77,0x70,0x87,0x29,0x81,
  1366. 0x31,0x82,0x0a,0x87,0x74,0x90,0x07,0x37,0x60,0x87,0x70,0x70,0x87,0x73,0xa8,0x87,
  1367. 0x70,0x38,0x87,0x72,0xf8,0x05,0x7b,0x28,0x07,0x79,0x98,0x87,0x74,0x78,0x07,0x77,
  1368. 0x98,0x12,0x20,0x23,0xa6,0x70,0x48,0x07,0x79,0x70,0x83,0x71,0x78,0x87,0x76,0x80,
  1369. 0x87,0x74,0x60,0x87,0x72,0xf8,0x85,0x77,0x80,0x07,0x7a,0x48,0x87,0x77,0x70,0x87,
  1370. 0x79,0x98,0x32,0x28,0x8c,0x33,0x82,0x09,0x87,0x74,0x90,0x07,0x37,0x30,0x07,0x79,
  1371. 0x08,0x87,0x73,0x68,0x87,0x72,0x70,0x07,0x7a,0x98,0x12,0xa8,0x01,0x00,0x00,0x00,
  1372. 0x00,0x79,0x18,0x00,0x00,0xa5,0x00,0x00,0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,
  1373. 0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,
  1374. 0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,
  1375. 0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,
  1376. 0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,
  1377. 0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,
  1378. 0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,
  1379. 0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,
  1380. 0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,
  1381. 0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,
  1382. 0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,
  1383. 0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,
  1384. 0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,
  1385. 0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,
  1386. 0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,
  1387. 0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,
  1388. 0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,
  1389. 0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,
  1390. 0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,
  1391. 0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,
  1392. 0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,
  1393. 0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,
  1394. 0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,
  1395. 0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,
  1396. 0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,
  1397. 0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,
  1398. 0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,
  1399. 0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x98,0x81,0x5c,0xe3,0x10,0x0e,0xec,
  1400. 0xc0,0x0e,0xe5,0x50,0x0e,0xf3,0x30,0x23,0xc1,0xd2,0x41,0x1e,0xe4,0xe1,0x17,0xd8,
  1401. 0xe1,0x1d,0xde,0x01,0x1e,0x66,0x48,0x19,0x3b,0xb0,0x83,0x3d,0xb4,0x83,0x1b,0x84,
  1402. 0xc3,0x38,0x8c,0x43,0x39,0xcc,0xc3,0x3c,0xb8,0xc1,0x39,0xc8,0xc3,0x3b,0xd4,0x03,
  1403. 0x3c,0xcc,0x48,0xb4,0x71,0x08,0x07,0x76,0x60,0x07,0x71,0x08,0x87,0x71,0x58,0x87,
  1404. 0x19,0xdb,0xc6,0x0e,0xec,0x60,0x0f,0xed,0xe0,0x06,0xf0,0x20,0x0f,0xe5,0x30,0x0f,
  1405. 0xe5,0x20,0x0f,0xf6,0x50,0x0e,0x6e,0x10,0x0e,0xe3,0x30,0x0e,0xe5,0x30,0x0f,0xf3,
  1406. 0xe0,0x06,0xe9,0xe0,0x0e,0xe4,0x50,0x0e,0xf8,0x30,0x23,0xe2,0xec,0x61,0x1c,0xc2,
  1407. 0x81,0x1d,0xd8,0xe1,0x17,0xec,0x21,0x1d,0xe6,0x21,0x1d,0xc4,0x21,0x1d,0xd8,0x21,
  1408. 0x1d,0xe8,0x21,0x1f,0x66,0x20,0x9d,0x3b,0xbc,0x43,0x3d,0xb8,0x03,0x39,0x94,0x83,
  1409. 0x39,0xcc,0x58,0xbc,0x70,0x70,0x07,0x77,0x78,0x07,0x7a,0x08,0x07,0x7a,0x48,0x87,
  1410. 0x77,0x70,0x87,0x19,0xce,0x87,0x0e,0xe5,0x10,0x0e,0xf0,0x10,0x0e,0xec,0xc0,0x0e,
  1411. 0xef,0x30,0x0e,0xf3,0x90,0x0e,0xf4,0x50,0x0e,0x33,0x28,0x30,0x08,0x87,0x74,0x90,
  1412. 0x07,0x37,0x30,0x87,0x7a,0x70,0x87,0x71,0xa0,0x87,0x74,0x78,0x07,0x77,0xf8,0x85,
  1413. 0x73,0x90,0x87,0x77,0xa8,0x07,0x78,0x98,0x07,0x00,0x00,0x00,0x00,0x71,0x20,0x00,
  1414. 0x00,0x08,0x00,0x00,0x00,0x16,0xb0,0x01,0x48,0xe4,0x4b,0x00,0xf3,0x2c,0xc4,0x3f,
  1415. 0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0x7e,0x85,0x17,0xb7,0x6d,0x00,0x05,0x03,0x20,
  1416. 0x0d,0x0d,0x00,0x00,0x00,0x61,0x20,0x00,0x00,0x14,0x00,0x00,0x00,0x13,0x04,0x41,
  1417. 0x2c,0x10,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xc4,0x46,0x00,0xc6,0x12,0x80,0x80,
  1418. 0xd4,0x08,0x40,0x0d,0x90,0x98,0x01,0xa0,0x30,0x03,0x40,0x60,0x04,0x00,0x00,0x00,
  1419. 0x00,0x83,0x0c,0x8b,0x60,0x8c,0x18,0x28,0x43,0x40,0x29,0x49,0x50,0x20,0x86,0x60,
  1420. 0x01,0x23,0x9f,0xd9,0x06,0x23,0x00,0x32,0x08,0x88,0x01,0x00,0x00,0x02,0x00,0x00,
  1421. 0x00,0x5b,0x86,0xe0,0x88,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1422. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1423. };
  1424. /*
  1425. #include <metal_stdlib>
  1426. #include <simd/simd.h>
  1427. using namespace metal;
  1428. struct vs_params
  1429. {
  1430. float4x4 mvp;
  1431. float4x4 tm;
  1432. };
  1433. struct main0_out
  1434. {
  1435. float4 uv [[user(locn0)]];
  1436. float4 color [[user(locn1)]];
  1437. float4 gl_Position [[position]];
  1438. float gl_PointSize [[point_size]];
  1439. };
  1440. struct main0_in
  1441. {
  1442. float4 position [[attribute(0)]];
  1443. float2 texcoord0 [[attribute(1)]];
  1444. float4 color0 [[attribute(2)]];
  1445. float psize [[attribute(3)]];
  1446. };
  1447. vertex main0_out main0(main0_in in [[stage_in]], constant vs_params& _19 [[buffer(0)]])
  1448. {
  1449. main0_out out = {};
  1450. out.gl_Position = _19.mvp * in.position;
  1451. out.gl_PointSize = in.psize;
  1452. out.uv = _19.tm * float4(in.texcoord0, 0.0, 1.0);
  1453. out.color = in.color0;
  1454. return out;
  1455. }
  1456. */
  1457. static const uint8_t _sgl_vs_bytecode_metal_ios[3493] = {
  1458. 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1459. 0xa5,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1460. 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1461. 0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
  1462. 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
  1463. 0x90,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00,
  1464. 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45,
  1465. 0x01,0x00,0x00,0x48,0x41,0x53,0x48,0x20,0x00,0x81,0x80,0x75,0xbc,0xa9,0xd0,0xb9,
  1466. 0x4f,0xee,0x63,0x10,0x8f,0xfe,0x66,0xa5,0x3b,0x40,0xb7,0x43,0x44,0x12,0xba,0x69,
  1467. 0x7d,0xf3,0x83,0x9a,0xda,0x47,0x00,0x29,0xec,0x4f,0x46,0x46,0x54,0x18,0x00,0x00,
  1468. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1469. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08,
  1470. 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x40,0x00,0x00,0x00,0x56,0x41,0x54,
  1471. 0x54,0x2a,0x00,0x04,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0x00,0x80,
  1472. 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x00,0x01,0x80,0x63,0x6f,0x6c,0x6f,
  1473. 0x72,0x30,0x00,0x02,0x80,0x70,0x73,0x69,0x7a,0x65,0x00,0x03,0x80,0x56,0x41,0x54,
  1474. 0x59,0x06,0x00,0x04,0x00,0x06,0x04,0x06,0x03,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,
  1475. 0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b,0x00,0x00,0x00,0x00,0x14,0x00,0x00,
  1476. 0x00,0x70,0x0c,0x00,0x00,0xff,0xff,0xff,0xff,0x42,0x43,0xc0,0xde,0x21,0x0c,0x00,
  1477. 0x00,0x19,0x03,0x00,0x00,0x0b,0x82,0x20,0x00,0x02,0x00,0x00,0x00,0x12,0x00,0x00,
  1478. 0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49,0x06,0x10,0x32,0x39,0x92,0x01,0x84,
  1479. 0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62,0x80,0x14,0x45,0x02,0x42,0x92,0x0b,
  1480. 0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49,0x0a,0x32,0x44,0x24,0x48,0x0a,0x90,
  1481. 0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72,0x24,0x07,0xc8,0x48,0x11,0x62,0xa8,
  1482. 0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00,0x51,0x18,0x00,0x00,0x70,0x00,0x00,
  1483. 0x00,0x1b,0x7e,0x24,0xf8,0xff,0xff,0xff,0xff,0x01,0x90,0x00,0x8a,0x08,0x07,0x78,
  1484. 0x80,0x07,0x79,0x78,0x07,0x7c,0x68,0x03,0x73,0xa8,0x07,0x77,0x18,0x87,0x36,0x30,
  1485. 0x07,0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,
  1486. 0x01,0x20,0xda,0x21,0x1d,0xdc,0xa1,0x0d,0xd8,0xa1,0x1c,0xce,0x21,0x1c,0xd8,0xa1,
  1487. 0x0d,0xec,0xa1,0x1c,0xc6,0x81,0x1e,0xde,0x41,0x1e,0xda,0xe0,0x1e,0xd2,0x81,0x1c,
  1488. 0xe8,0x01,0x1d,0x80,0x38,0x90,0x03,0x3c,0x00,0x06,0x77,0x78,0x87,0x36,0x10,0x87,
  1489. 0x7a,0x48,0x07,0x76,0xa0,0x87,0x74,0x70,0x87,0x79,0x00,0x08,0x77,0x78,0x87,0x36,
  1490. 0x30,0x07,0x79,0x08,0x87,0x76,0x28,0x87,0x36,0x80,0x87,0x77,0x48,0x07,0x77,0xa0,
  1491. 0x87,0x72,0x90,0x87,0x36,0x28,0x07,0x76,0x48,0x87,0x76,0x00,0xe8,0x41,0x1e,0xea,
  1492. 0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xcc,0x41,0x1e,0xc2,0xa1,0x1d,0xca,0xa1,
  1493. 0x0d,0xe0,0xe1,0x1d,0xd2,0xc1,0x1d,0xe8,0xa1,0x1c,0xe4,0xa1,0x0d,0xca,0x81,0x1d,
  1494. 0xd2,0xa1,0x1d,0xda,0xc0,0x1d,0xde,0xc1,0x1d,0xda,0x80,0x1d,0xca,0x21,0x1c,0xcc,
  1495. 0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,0x48,0x07,0x77,
  1496. 0x30,0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,
  1497. 0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xdc,0x21,0x1c,0xdc,
  1498. 0x61,0x1e,0xda,0xc0,0x1c,0xe0,0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,
  1499. 0x90,0x87,0x7a,0x28,0x07,0x80,0x70,0x87,0x77,0x68,0x83,0x79,0x48,0x87,0x73,0x70,
  1500. 0x87,0x72,0x20,0x87,0x36,0xd0,0x87,0x72,0x90,0x87,0x77,0x98,0x87,0x36,0x30,0x07,
  1501. 0x78,0x68,0x83,0x76,0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,
  1502. 0x20,0xdc,0xe1,0x1d,0xda,0x80,0x1e,0xe4,0x21,0x1c,0xe0,0x01,0x1e,0xd2,0xc1,0x1d,
  1503. 0xce,0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,
  1504. 0x80,0x98,0x07,0x7a,0x08,0x87,0x71,0x58,0x87,0x36,0x80,0x07,0x79,0x78,0x07,0x7a,
  1505. 0x28,0x87,0x71,0xa0,0x87,0x77,0x90,0x87,0x36,0x10,0x87,0x7a,0x30,0x07,0x73,0x28,
  1506. 0x07,0x79,0x68,0x83,0x79,0x48,0x07,0x7d,0x28,0x07,0x00,0x0f,0x00,0xa2,0x1e,0xdc,
  1507. 0x61,0x1e,0xc2,0xc1,0x1c,0xca,0xa1,0x0d,0xcc,0x01,0x1e,0xda,0xa0,0x1d,0xc2,0x81,
  1508. 0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x36,0x6c,0x42,0x01,0x2c,0x40,
  1509. 0x35,0x84,0x43,0x3a,0xc8,0x43,0x1b,0x88,0x43,0x3d,0x98,0x83,0x39,0x94,0x83,0x3c,
  1510. 0xb4,0x81,0x3b,0xbc,0x43,0x1b,0x84,0x03,0x3b,0xa4,0x43,0x38,0xcc,0x03,0x00,0x00,
  1511. 0x00,0x49,0x18,0x00,0x00,0x01,0x00,0x00,0x00,0x13,0x84,0x40,0x00,0x89,0x20,0x00,
  1512. 0x00,0x20,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,
  1513. 0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,
  1514. 0x4c,0x10,0x44,0x33,0x00,0xc3,0x08,0x04,0x60,0x89,0x10,0x02,0x18,0x46,0x10,0x80,
  1515. 0x24,0x08,0x33,0x51,0xf3,0x40,0x0f,0xf2,0x50,0x0f,0xe3,0x40,0x0f,0x6e,0xd0,0x0e,
  1516. 0xe5,0x40,0x0f,0xe1,0xc0,0x0e,0x7a,0xa0,0x07,0xed,0x10,0x0e,0xf4,0x20,0x0f,0xe9,
  1517. 0x80,0x0f,0x28,0x20,0x07,0x49,0x53,0x44,0x09,0x93,0x5f,0x49,0xff,0x03,0x44,0x00,
  1518. 0x23,0x21,0xa1,0x94,0x41,0x04,0x43,0x28,0x86,0x08,0x23,0x80,0x43,0x68,0x20,0x60,
  1519. 0x8e,0x00,0x0c,0x52,0x60,0xcd,0x11,0x80,0xc2,0x20,0x42,0x20,0x0c,0x23,0x10,0xcb,
  1520. 0x08,0x00,0x00,0x00,0x00,0x13,0xa8,0x70,0x48,0x07,0x79,0xb0,0x03,0x3a,0x68,0x83,
  1521. 0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x74,0x78,0x87,0x79,0xc8,0x03,0x37,
  1522. 0x80,0x03,0x37,0x80,0x83,0x0d,0xb7,0x51,0x0e,0x6d,0x00,0x0f,0x7a,0x60,0x07,0x74,
  1523. 0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe9,0x10,0x07,0x7a,0x80,
  1524. 0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x78,0xa0,0x07,0x78,0xa0,0x07,0x78,0xd0,0x06,
  1525. 0xe9,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xe9,
  1526. 0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe9,0x60,
  1527. 0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe6,0x30,0x07,
  1528. 0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xe6,0x60,0x07,0x74,
  1529. 0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x10,0x07,0x76,0xa0,
  1530. 0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xf6,0x20,0x07,0x74,0xa0,0x07,
  1531. 0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x30,0x07,0x72,0xa0,0x07,0x73,
  1532. 0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x40,0x07,0x78,0xa0,0x07,0x76,0x40,
  1533. 0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,
  1534. 0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x90,0x07,0x76,0xa0,0x07,0x71,0x20,0x07,0x78,
  1535. 0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,
  1536. 0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,0x0f,0x71,0x90,0x07,
  1537. 0x72,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,0x76,0xd0,0x06,0xf6,
  1538. 0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,
  1539. 0x07,0x6d,0x60,0x0f,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xa0,0x07,
  1540. 0x75,0x10,0x07,0x72,0xd0,0x06,0xf6,0x10,0x07,0x70,0x20,0x07,0x74,0xa0,0x07,0x71,
  1541. 0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74,0xd0,0x06,0xee,0x80,
  1542. 0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x73,0x20,0x07,0x43,0x98,0x04,0x00,0x80,0x00,
  1543. 0x00,0x00,0x00,0x00,0x80,0x2c,0x10,0x00,0x00,0x0b,0x00,0x00,0x00,0x32,0x1e,0x98,
  1544. 0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02,
  1545. 0x50,0x04,0x05,0x18,0x50,0x08,0x65,0x50,0x80,0x02,0x05,0x51,0x20,0xd4,0x46,0x00,
  1546. 0x88,0x8d,0x25,0x48,0x00,0x00,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0x12,0x01,0x00,
  1547. 0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,0xb9,0xb9,0xb4,0x37,
  1548. 0xb7,0x21,0xc6,0x32,0x28,0x00,0xb3,0x50,0xb9,0x1b,0x43,0x0b,0x93,0xfb,0x9a,0x4b,
  1549. 0xd3,0x2b,0x1b,0x62,0x2c,0x81,0x22,0x2c,0x05,0xe3,0x20,0x08,0x0e,0x8e,0xad,0x0c,
  1550. 0xa4,0xad,0x8c,0x2e,0x8c,0x0d,0xc4,0xae,0x4c,0x6e,0x2e,0xed,0xcd,0x0d,0x64,0x46,
  1551. 0x06,0x46,0x66,0xc6,0x65,0x66,0xa6,0x06,0x04,0xa5,0xad,0x8c,0x2e,0x8c,0xcd,0xac,
  1552. 0xac,0x65,0x46,0x06,0x46,0x66,0xc6,0x65,0x66,0xa6,0x26,0x65,0x88,0xa0,0x10,0x43,
  1553. 0x8c,0x25,0x58,0x90,0x45,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,0x04,0x51,0x8e,0x25,
  1554. 0x58,0x82,0x45,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,0x97,0xc6,0x56,0xe6,
  1555. 0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,0x26,0xc6,0x56,0x36,
  1556. 0x44,0x50,0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x2e,
  1557. 0x66,0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,0x61,0x62,0x6c,0x65,
  1558. 0x43,0x04,0x65,0x21,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,0xc1,0xa5,0xb1,0x95,
  1559. 0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,0x7d,0x99,0x95,0xd1,
  1560. 0x8d,0xa1,0x7d,0x95,0xb9,0x85,0x89,0xb1,0x95,0x0d,0x11,0x94,0x86,0x51,0x58,0x9a,
  1561. 0x9c,0x8b,0x5d,0x99,0x1c,0x5d,0x19,0xde,0xd7,0x5b,0x1d,0x1d,0x5c,0x1d,0x1d,0x97,
  1562. 0xba,0xb9,0x32,0x39,0x14,0xb6,0xb7,0x31,0x37,0x98,0x14,0x46,0x61,0x69,0x72,0x2e,
  1563. 0x61,0x72,0x67,0x5f,0x74,0x79,0x70,0x65,0x5f,0x6e,0x61,0x6d,0x65,0x34,0xcc,0xd8,
  1564. 0xde,0xc2,0xe8,0x68,0xc8,0x84,0xa5,0xc9,0xb9,0x84,0xc9,0x9d,0x7d,0xb9,0x85,0xb5,
  1565. 0x95,0x51,0xa8,0xb3,0x1b,0xc2,0x28,0x8f,0x02,0x29,0x91,0x22,0x29,0x93,0x42,0x71,
  1566. 0xa9,0x9b,0x2b,0x93,0x43,0x61,0x7b,0x1b,0x73,0x8b,0x49,0x61,0x31,0xf6,0xc6,0xf6,
  1567. 0x26,0x37,0x84,0x51,0x1e,0xc5,0x52,0x22,0x45,0x52,0x26,0xe5,0x22,0x13,0x96,0x26,
  1568. 0xe7,0x02,0xf7,0x36,0x97,0x46,0x97,0xf6,0xe6,0xc6,0xe5,0x8c,0xed,0x0b,0xea,0x6d,
  1569. 0x2e,0x8d,0x2e,0xed,0xcd,0x6d,0x88,0xa2,0x64,0x4a,0xa4,0x48,0xca,0xa4,0x68,0x74,
  1570. 0xc2,0xd2,0xe4,0x5c,0xe0,0xde,0xd2,0xdc,0xe8,0xbe,0xe6,0xd2,0xf4,0xca,0x58,0x98,
  1571. 0xb1,0xbd,0x85,0xd1,0x91,0x39,0x63,0xfb,0x82,0x7a,0x4b,0x73,0xa3,0x9b,0x4a,0xd3,
  1572. 0x2b,0x1b,0xa2,0x28,0x9c,0x12,0x29,0x9d,0x32,0x29,0xde,0x10,0x44,0xa9,0x14,0x4c,
  1573. 0xd9,0x94,0x8f,0x50,0x58,0x9a,0x9c,0x8b,0x5d,0x99,0x1c,0x5d,0x19,0xde,0x57,0x9a,
  1574. 0x1b,0x5c,0x1d,0x1d,0xa5,0xb0,0x34,0x39,0x17,0xb6,0xb7,0xb1,0x30,0xba,0xb4,0x37,
  1575. 0xb7,0xaf,0x34,0x37,0xb2,0x32,0x3c,0x7a,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,
  1576. 0x64,0x28,0x5f,0x5f,0x61,0x69,0x72,0x5f,0x70,0x6c,0x61,0x63,0x65,0x68,0x6f,0x6c,
  1577. 0x64,0x65,0x72,0x5f,0x5f,0x29,0x44,0xe0,0xde,0xe6,0xd2,0xe8,0xd2,0xde,0xdc,0x86,
  1578. 0x50,0x8b,0xa0,0x84,0x81,0x22,0x06,0x8b,0xb0,0x04,0xca,0x18,0x28,0x91,0x22,0x29,
  1579. 0x93,0x42,0x06,0x34,0xcc,0xd8,0xde,0xc2,0xe8,0x64,0x98,0xd0,0x95,0xe1,0x8d,0xbd,
  1580. 0xbd,0xc9,0x91,0xc1,0x0c,0xa1,0x96,0x40,0x09,0x03,0x45,0x0c,0x96,0x60,0x09,0x94,
  1581. 0x31,0x50,0x22,0xc5,0x0c,0x94,0x49,0x39,0x03,0x1a,0x63,0x6f,0x6c,0x6f,0x72,0x30,
  1582. 0x43,0xa8,0x65,0x50,0xc2,0x40,0x11,0x83,0x65,0x58,0x02,0x65,0x0c,0x94,0x48,0x91,
  1583. 0x94,0x49,0x49,0x03,0x16,0x70,0x73,0x69,0x7a,0x65,0x43,0xa8,0xc5,0x50,0xc2,0x40,
  1584. 0x11,0x83,0xc5,0x58,0x02,0x65,0x0c,0x94,0x48,0xe9,0x94,0x49,0x59,0x03,0x2a,0x61,
  1585. 0x69,0x72,0x2e,0x62,0x75,0x66,0x66,0x65,0x72,0x7c,0xc2,0xd2,0xe4,0x5c,0xc4,0xea,
  1586. 0xcc,0xcc,0xca,0xe4,0xbe,0xe6,0xd2,0xf4,0xca,0x88,0x84,0xa5,0xc9,0xb9,0xc8,0x95,
  1587. 0x85,0x91,0x91,0x0a,0x4b,0x93,0x73,0x99,0xa3,0x93,0xab,0x1b,0xa3,0xfb,0xa2,0xcb,
  1588. 0x83,0x2b,0xfb,0x4a,0x73,0x33,0x7b,0x23,0x62,0xc6,0xf6,0x16,0x46,0x47,0x83,0x47,
  1589. 0xc3,0xa1,0xcd,0x0e,0x8e,0x02,0x5d,0xdb,0x10,0x6a,0x11,0x16,0x62,0x11,0x94,0x38,
  1590. 0x50,0xe4,0x60,0x21,0x16,0x62,0x11,0x94,0x38,0x50,0xe6,0x80,0x51,0x58,0x9a,0x9c,
  1591. 0x4b,0x98,0xdc,0xd9,0x17,0x5d,0x1e,0x5c,0xd9,0xd7,0x5c,0x9a,0x5e,0x19,0xaf,0xb0,
  1592. 0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,0xba,0x3c,0xb8,0xb2,0xaf,0x30,0xb6,0xb4,0x33,
  1593. 0xb7,0xaf,0xb9,0x34,0xbd,0x32,0x26,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
  1594. 0x1c,0xbe,0x62,0x72,0x86,0x90,0xc1,0x52,0x28,0x6d,0xa0,0xb8,0xc1,0x72,0x28,0x62,
  1595. 0xb0,0x08,0x4b,0xa0,0xbc,0x81,0x02,0x07,0x0a,0x1d,0x28,0x75,0xb0,0x1c,0x8a,0x1d,
  1596. 0x2c,0x89,0x12,0x29,0x77,0xa0,0x4c,0x0a,0x1e,0x0c,0x51,0x94,0x32,0x50,0xd0,0x40,
  1597. 0x51,0x03,0x85,0x0d,0x94,0x3c,0x18,0x62,0x24,0x80,0x02,0x06,0x8a,0x1e,0xf0,0x79,
  1598. 0x6b,0x73,0x4b,0x83,0x7b,0xa3,0x2b,0x73,0xa3,0x03,0x19,0x43,0x0b,0x93,0xe3,0x33,
  1599. 0x95,0xd6,0x06,0xc7,0x56,0x06,0x32,0xb4,0xb2,0x02,0x42,0x25,0x14,0x14,0x34,0x44,
  1600. 0x50,0xfa,0x60,0x88,0xa1,0xf0,0x81,0xe2,0x07,0x8d,0x32,0xc4,0x50,0xfe,0x40,0xf9,
  1601. 0x83,0x46,0xe1,0x15,0x96,0x26,0xd7,0x12,0xc6,0x96,0x16,0x36,0xd7,0x32,0x37,0xf6,
  1602. 0x06,0x57,0x36,0x87,0xd2,0x16,0x96,0xe6,0x06,0x93,0x32,0x84,0x50,0x44,0x41,0x09,
  1603. 0x05,0x5a,0x61,0x69,0x72,0x2d,0x61,0x6c,0x69,0x61,0x73,0x2d,0x73,0x63,0x6f,0x70,
  1604. 0x65,0x2d,0x61,0x72,0x67,0x28,0x34,0x29,0x43,0x0c,0x85,0x14,0x14,0x51,0x50,0x46,
  1605. 0x61,0x88,0xa0,0x90,0xc2,0x88,0x88,0x1d,0xd8,0xc1,0x1e,0xda,0xc1,0x0d,0xda,0xe1,
  1606. 0x1d,0xc8,0xa1,0x1e,0xd8,0xa1,0x1c,0xdc,0xc0,0x1c,0xd8,0x21,0x1c,0xce,0x61,0x1e,
  1607. 0xa6,0x08,0xc1,0x30,0x42,0x61,0x07,0x76,0xb0,0x87,0x76,0x70,0x83,0x74,0x20,0x87,
  1608. 0x72,0x70,0x07,0x7a,0x98,0x12,0x14,0x23,0x96,0x70,0x48,0x07,0x79,0x70,0x03,0x7b,
  1609. 0x28,0x07,0x79,0x98,0x87,0x74,0x78,0x07,0x77,0x98,0x12,0x18,0x23,0xa8,0x70,0x48,
  1610. 0x07,0x79,0x70,0x03,0x76,0x08,0x07,0x77,0x38,0x87,0x7a,0x08,0x87,0x73,0x28,0x87,
  1611. 0x5f,0xb0,0x87,0x72,0x90,0x87,0x79,0x48,0x87,0x77,0x70,0x87,0x29,0x01,0x32,0x62,
  1612. 0x0a,0x87,0x74,0x90,0x07,0x37,0x18,0x87,0x77,0x68,0x07,0x78,0x48,0x07,0x76,0x28,
  1613. 0x87,0x5f,0x78,0x07,0x78,0xa0,0x87,0x74,0x78,0x07,0x77,0x98,0x87,0x29,0x83,0xc2,
  1614. 0x38,0x23,0x94,0x70,0x48,0x07,0x79,0x70,0x03,0x7b,0x28,0x07,0x79,0xa0,0x87,0x72,
  1615. 0xc0,0x87,0x29,0xc1,0x1e,0x00,0x00,0x00,0x00,0x79,0x18,0x00,0x00,0xa5,0x00,0x00,
  1616. 0x00,0x33,0x08,0x80,0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,
  1617. 0xc3,0x8c,0x42,0x80,0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,
  1618. 0x10,0x0e,0xf4,0x80,0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,
  1619. 0x30,0x05,0x3d,0x88,0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,
  1620. 0x03,0x3d,0xcc,0x78,0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,
  1621. 0x07,0x7a,0x70,0x03,0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,
  1622. 0x0e,0xe1,0x30,0x0f,0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,
  1623. 0x1d,0xde,0x21,0x1c,0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,
  1624. 0x3b,0xd0,0x43,0x39,0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,
  1625. 0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,
  1626. 0x90,0x87,0x70,0x60,0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,
  1627. 0x87,0x5f,0x08,0x87,0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,
  1628. 0x0e,0xee,0xe0,0x0e,0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,
  1629. 0x1c,0xcc,0xa1,0x1c,0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,
  1630. 0xca,0x61,0x06,0xd6,0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,
  1631. 0xb8,0xc3,0x38,0x94,0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,
  1632. 0x82,0x3b,0xd4,0x03,0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,
  1633. 0x83,0x74,0x68,0x07,0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,
  1634. 0x0f,0xee,0x00,0x0f,0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,
  1635. 0xec,0x50,0x0e,0x33,0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,
  1636. 0xdc,0x81,0x1e,0xdc,0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,
  1637. 0xb0,0x43,0x3a,0x9c,0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,
  1638. 0x60,0x87,0x77,0x78,0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,
  1639. 0x1e,0x6a,0x1e,0xca,0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,
  1640. 0xa1,0x1c,0xcc,0x21,0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,
  1641. 0x43,0x3d,0xd0,0x43,0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,
  1642. 0x8c,0xc5,0x0a,0x87,0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,
  1643. 0x72,0x98,0x81,0x5c,0xe3,0x10,0x0e,0xec,0xc0,0x0e,0xe5,0x50,0x0e,0xf3,0x30,0x23,
  1644. 0xc1,0xd2,0x41,0x1e,0xe4,0xe1,0x17,0xd8,0xe1,0x1d,0xde,0x01,0x1e,0x66,0x48,0x19,
  1645. 0x3b,0xb0,0x83,0x3d,0xb4,0x83,0x1b,0x84,0xc3,0x38,0x8c,0x43,0x39,0xcc,0xc3,0x3c,
  1646. 0xb8,0xc1,0x39,0xc8,0xc3,0x3b,0xd4,0x03,0x3c,0xcc,0x48,0xb4,0x71,0x08,0x07,0x76,
  1647. 0x60,0x07,0x71,0x08,0x87,0x71,0x58,0x87,0x19,0xdb,0xc6,0x0e,0xec,0x60,0x0f,0xed,
  1648. 0xe0,0x06,0xf0,0x20,0x0f,0xe5,0x30,0x0f,0xe5,0x20,0x0f,0xf6,0x50,0x0e,0x6e,0x10,
  1649. 0x0e,0xe3,0x30,0x0e,0xe5,0x30,0x0f,0xf3,0xe0,0x06,0xe9,0xe0,0x0e,0xe4,0x50,0x0e,
  1650. 0xf8,0x30,0x23,0xe2,0xec,0x61,0x1c,0xc2,0x81,0x1d,0xd8,0xe1,0x17,0xec,0x21,0x1d,
  1651. 0xe6,0x21,0x1d,0xc4,0x21,0x1d,0xd8,0x21,0x1d,0xe8,0x21,0x1f,0x66,0x20,0x9d,0x3b,
  1652. 0xbc,0x43,0x3d,0xb8,0x03,0x39,0x94,0x83,0x39,0xcc,0x58,0xbc,0x70,0x70,0x07,0x77,
  1653. 0x78,0x07,0x7a,0x08,0x07,0x7a,0x48,0x87,0x77,0x70,0x87,0x19,0xce,0x87,0x0e,0xe5,
  1654. 0x10,0x0e,0xf0,0x10,0x0e,0xec,0xc0,0x0e,0xef,0x30,0x0e,0xf3,0x90,0x0e,0xf4,0x50,
  1655. 0x0e,0x33,0x28,0x30,0x08,0x87,0x74,0x90,0x07,0x37,0x30,0x87,0x7a,0x70,0x87,0x71,
  1656. 0xa0,0x87,0x74,0x78,0x07,0x77,0xf8,0x85,0x73,0x90,0x87,0x77,0xa8,0x07,0x78,0x98,
  1657. 0x07,0x00,0x00,0x00,0x00,0x71,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x06,0x50,0x30,
  1658. 0x00,0xd2,0xd0,0x00,0x00,0x61,0x20,0x00,0x00,0x42,0x00,0x00,0x00,0x13,0x04,0x41,
  1659. 0x2c,0x10,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xf4,0xc6,0x22,0x86,0x61,0x18,0xc6,
  1660. 0x22,0x04,0x41,0x10,0xc6,0x22,0x82,0x20,0x08,0x46,0x00,0xa8,0x95,0x40,0x19,0x14,
  1661. 0x01,0x8d,0x19,0x00,0x12,0x33,0x00,0x14,0x66,0x00,0x66,0x00,0x00,0xe3,0x15,0x8c,
  1662. 0xa4,0x69,0x12,0x05,0x65,0x90,0x41,0x22,0x14,0x13,0x02,0xf9,0x8c,0x57,0x40,0x96,
  1663. 0xe7,0x2d,0x14,0x94,0x41,0x06,0xeb,0x78,0x4c,0x08,0xe4,0x63,0x41,0x01,0x9f,0xf1,
  1664. 0x8a,0x6a,0x1b,0x83,0x31,0x70,0x28,0x28,0x83,0x0c,0x1b,0x53,0x99,0x10,0xc8,0xc7,
  1665. 0x8a,0x00,0x3e,0xe3,0x15,0x1a,0x18,0xa0,0x01,0x1a,0x50,0x14,0x94,0x41,0x06,0x30,
  1666. 0x88,0x36,0x13,0x02,0xf9,0x58,0x11,0xc0,0x67,0xbc,0xe2,0x2b,0x03,0x37,0x68,0x83,
  1667. 0x32,0xa0,0xa0,0x0c,0x32,0x90,0x41,0xd6,0x99,0x10,0xc8,0x67,0xbc,0x62,0x0c,0xd2,
  1668. 0x40,0x0e,0xe2,0xc0,0xa3,0xa0,0x0c,0x32,0xa0,0x41,0x27,0x06,0x26,0x04,0xf2,0xb1,
  1669. 0xa0,0x80,0xcf,0x78,0x05,0x1a,0xb8,0xc1,0x1d,0xd8,0x81,0x18,0x50,0x50,0x6c,0x08,
  1670. 0xe0,0x33,0xdb,0x20,0x06,0x01,0x30,0xdb,0x10,0xb8,0x41,0x30,0xdb,0x10,0x3c,0xc2,
  1671. 0x6c,0x43,0xf0,0x06,0x43,0x06,0x01,0x31,0x00,0x0d,0x00,0x00,0x00,0x5b,0x8a,0x20,
  1672. 0x00,0x85,0xa3,0x14,0xb6,0x14,0x45,0x00,0x0a,0x47,0x29,0x6c,0x29,0x94,0x00,0x14,
  1673. 0x8e,0x52,0xd8,0x52,0x3c,0x01,0x28,0x1c,0xa5,0xb0,0xa5,0xa0,0x02,0x50,0x38,0x4a,
  1674. 0x61,0x4b,0x81,0x05,0xa0,0x70,0x94,0xc2,0x96,0xa2,0x0b,0x40,0xe1,0x28,0x05,0x00,
  1675. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1676. 0x00,0x00,0x00,0x00,0x00,
  1677. };
  1678. /*
  1679. #include <metal_stdlib>
  1680. #include <simd/simd.h>
  1681. using namespace metal;
  1682. struct main0_out
  1683. {
  1684. float4 frag_color [[color(0)]];
  1685. };
  1686. struct main0_in
  1687. {
  1688. float4 uv [[user(locn0)]];
  1689. float4 color [[user(locn1)]];
  1690. };
  1691. fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler smp [[sampler(0)]])
  1692. {
  1693. main0_out out = {};
  1694. out.frag_color = tex.sample(smp, in.uv.xy) * in.color;
  1695. return out;
  1696. }
  1697. */
  1698. static const uint8_t _sgl_fs_bytecode_metal_ios[3017] = {
  1699. 0x4d,0x54,0x4c,0x42,0x01,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1700. 0xc9,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1701. 0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1702. 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1703. 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1704. 0xf0,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x6d,0x00,0x00,0x00,
  1705. 0x4e,0x41,0x4d,0x45,0x06,0x00,0x6d,0x61,0x69,0x6e,0x30,0x00,0x54,0x59,0x50,0x45,
  1706. 0x01,0x00,0x01,0x48,0x41,0x53,0x48,0x20,0x00,0x40,0xd6,0xeb,0xe8,0x54,0x51,0x57,
  1707. 0x09,0x04,0x8e,0xcb,0x4c,0x44,0x2c,0x92,0x69,0x71,0x54,0xbd,0xb6,0xe0,0x7e,0x6b,
  1708. 0x97,0x01,0x63,0xb9,0x24,0x88,0x76,0x15,0x8c,0x4f,0x46,0x46,0x54,0x18,0x00,0x00,
  1709. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1710. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x45,0x52,0x53,0x08,0x00,0x01,0x00,0x08,
  1711. 0x00,0x01,0x00,0x01,0x00,0x45,0x4e,0x44,0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,
  1712. 0x54,0x04,0x00,0x00,0x00,0x45,0x4e,0x44,0x54,0xde,0xc0,0x17,0x0b,0x00,0x00,0x00,
  1713. 0x00,0x14,0x00,0x00,0x00,0xd8,0x0a,0x00,0x00,0xff,0xff,0xff,0xff,0x42,0x43,0xc0,
  1714. 0xde,0x21,0x0c,0x00,0x00,0xb3,0x02,0x00,0x00,0x0b,0x82,0x20,0x00,0x02,0x00,0x00,
  1715. 0x00,0x12,0x00,0x00,0x00,0x07,0x81,0x23,0x91,0x41,0xc8,0x04,0x49,0x06,0x10,0x32,
  1716. 0x39,0x92,0x01,0x84,0x0c,0x25,0x05,0x08,0x19,0x1e,0x04,0x8b,0x62,0x80,0x14,0x45,
  1717. 0x02,0x42,0x92,0x0b,0x42,0xa4,0x10,0x32,0x14,0x38,0x08,0x18,0x49,0x0a,0x32,0x44,
  1718. 0x24,0x48,0x0a,0x90,0x21,0x23,0xc4,0x52,0x80,0x0c,0x19,0x21,0x72,0x24,0x07,0xc8,
  1719. 0x48,0x11,0x62,0xa8,0xa0,0xa8,0x40,0xc6,0xf0,0x01,0x00,0x00,0x00,0x51,0x18,0x00,
  1720. 0x00,0x74,0x00,0x00,0x00,0x1b,0xc2,0x24,0xf8,0xff,0xff,0xff,0xff,0x01,0x60,0x00,
  1721. 0x09,0xa8,0x88,0x70,0x80,0x07,0x78,0x90,0x87,0x77,0xc0,0x87,0x36,0x30,0x87,0x7a,
  1722. 0x70,0x87,0x71,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,
  1723. 0xe8,0x41,0x1e,0xea,0xa1,0x1c,0x00,0xa2,0x1d,0xd2,0xc1,0x1d,0xda,0x80,0x1d,0xca,
  1724. 0xe1,0x1c,0xc2,0x81,0x1d,0xda,0xc0,0x1e,0xca,0x61,0x1c,0xe8,0xe1,0x1d,0xe4,0xa1,
  1725. 0x0d,0xee,0x21,0x1d,0xc8,0x81,0x1e,0xd0,0x01,0x88,0x03,0x39,0xc0,0x03,0x60,0x70,
  1726. 0x87,0x77,0x68,0x03,0x71,0xa8,0x87,0x74,0x60,0x07,0x7a,0x48,0x07,0x77,0x98,0x07,
  1727. 0x80,0x70,0x87,0x77,0x68,0x03,0x73,0x90,0x87,0x70,0x68,0x87,0x72,0x68,0x03,0x78,
  1728. 0x78,0x87,0x74,0x70,0x07,0x7a,0x28,0x07,0x79,0x68,0x83,0x72,0x60,0x87,0x74,0x68,
  1729. 0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,0xda,0xc0,0x1c,0xe4,
  1730. 0x21,0x1c,0xda,0xa1,0x1c,0xda,0x00,0x1e,0xde,0x21,0x1d,0xdc,0x81,0x1e,0xca,0x41,
  1731. 0x1e,0xda,0xa0,0x1c,0xd8,0x21,0x1d,0xda,0xa1,0x0d,0xdc,0xe1,0x1d,0xdc,0xa1,0x0d,
  1732. 0xd8,0xa1,0x1c,0xc2,0xc1,0x1c,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x80,0x70,0x87,
  1733. 0x77,0x68,0x83,0x74,0x70,0x07,0x73,0x98,0x87,0x36,0x30,0x07,0x78,0x68,0x83,0x76,
  1734. 0x08,0x07,0x7a,0x40,0x07,0x80,0x1e,0xe4,0xa1,0x1e,0xca,0x01,0x20,0xdc,0xe1,0x1d,
  1735. 0xda,0xc0,0x1d,0xc2,0xc1,0x1d,0xe6,0xa1,0x0d,0xcc,0x01,0x1e,0xda,0xa0,0x1d,0xc2,
  1736. 0x81,0x1e,0xd0,0x01,0xa0,0x07,0x79,0xa8,0x87,0x72,0x00,0x08,0x77,0x78,0x87,0x36,
  1737. 0x98,0x87,0x74,0x38,0x07,0x77,0x28,0x07,0x72,0x68,0x03,0x7d,0x28,0x07,0x79,0x78,
  1738. 0x87,0x79,0x68,0x03,0x73,0x80,0x87,0x36,0x68,0x87,0x70,0xa0,0x07,0x74,0x00,0xe8,
  1739. 0x41,0x1e,0xea,0xa1,0x1c,0x00,0xc2,0x1d,0xde,0xa1,0x0d,0xe8,0x41,0x1e,0xc2,0x01,
  1740. 0x1e,0xe0,0x21,0x1d,0xdc,0xe1,0x1c,0xda,0xa0,0x1d,0xc2,0x81,0x1e,0xd0,0x01,0xa0,
  1741. 0x07,0x79,0xa8,0x87,0x72,0x00,0x88,0x79,0xa0,0x87,0x70,0x18,0x87,0x75,0x68,0x03,
  1742. 0x78,0x90,0x87,0x77,0xa0,0x87,0x72,0x18,0x07,0x7a,0x78,0x07,0x79,0x68,0x03,0x71,
  1743. 0xa8,0x07,0x73,0x30,0x87,0x72,0x90,0x87,0x36,0x98,0x87,0x74,0xd0,0x87,0x72,0x00,
  1744. 0xf0,0x00,0x20,0xea,0xc1,0x1d,0xe6,0x21,0x1c,0xcc,0xa1,0x1c,0xda,0xc0,0x1c,0xe0,
  1745. 0xa1,0x0d,0xda,0x21,0x1c,0xe8,0x01,0x1d,0x00,0x7a,0x90,0x87,0x7a,0x28,0x07,0x60,
  1746. 0x83,0x21,0x0c,0xc0,0x02,0x54,0x1b,0x8c,0x81,0x00,0x16,0xa0,0xda,0x80,0x10,0xff,
  1747. 0xff,0xff,0xff,0x3f,0x00,0x0c,0x20,0x01,0xd5,0x06,0xa3,0x08,0x80,0x05,0xa8,0x36,
  1748. 0x18,0x86,0x00,0x2c,0x40,0xb5,0x01,0x39,0xfe,0xff,0xff,0xff,0x7f,0x00,0x18,0x40,
  1749. 0x02,0x2a,0x00,0x00,0x00,0x49,0x18,0x00,0x00,0x04,0x00,0x00,0x00,0x13,0x86,0x40,
  1750. 0x18,0x26,0x0c,0x44,0x61,0x4c,0x18,0x8e,0xc2,0x00,0x00,0x00,0x00,0x89,0x20,0x00,
  1751. 0x00,0x1d,0x00,0x00,0x00,0x32,0x22,0x48,0x09,0x20,0x64,0x85,0x04,0x93,0x22,0xa4,
  1752. 0x84,0x04,0x93,0x22,0xe3,0x84,0xa1,0x90,0x14,0x12,0x4c,0x8a,0x8c,0x0b,0x84,0xa4,
  1753. 0x4c,0x10,0x48,0x33,0x00,0xc3,0x08,0x04,0x60,0x83,0x70,0x94,0x34,0x45,0x94,0x30,
  1754. 0xf9,0xff,0x44,0x5c,0x13,0x15,0x11,0xbf,0x3d,0xfc,0xd3,0x18,0x01,0x30,0x88,0x30,
  1755. 0x04,0x17,0x49,0x53,0x44,0x09,0x93,0xff,0x4b,0x00,0xf3,0x2c,0x44,0xf4,0x4f,0x63,
  1756. 0x04,0xc0,0x20,0x42,0x21,0x94,0x42,0x84,0x40,0x0c,0x9d,0x61,0x04,0x01,0x98,0x23,
  1757. 0x08,0xe6,0x08,0xc0,0x60,0x18,0x41,0x58,0x0a,0x12,0x88,0x49,0x8a,0x29,0x40,0x6d,
  1758. 0x20,0x20,0x05,0xd6,0x08,0x00,0x00,0x00,0x00,0x13,0xa8,0x70,0x48,0x07,0x79,0xb0,
  1759. 0x03,0x3a,0x68,0x83,0x70,0x80,0x07,0x78,0x60,0x87,0x72,0x68,0x83,0x74,0x78,0x87,
  1760. 0x79,0xc8,0x03,0x37,0x80,0x03,0x37,0x80,0x83,0x0d,0xb7,0x51,0x0e,0x6d,0x00,0x0f,
  1761. 0x7a,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xe9,
  1762. 0x10,0x07,0x7a,0x80,0x07,0x7a,0x80,0x07,0x6d,0x90,0x0e,0x78,0xa0,0x07,0x78,0xa0,
  1763. 0x07,0x78,0xd0,0x06,0xe9,0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,
  1764. 0x76,0xd0,0x06,0xe9,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,
  1765. 0xd0,0x06,0xe9,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,
  1766. 0x06,0xe6,0x30,0x07,0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,
  1767. 0xe6,0x60,0x07,0x74,0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,
  1768. 0x10,0x07,0x76,0xa0,0x07,0x71,0x60,0x07,0x7a,0x10,0x07,0x76,0xd0,0x06,0xf6,0x20,
  1769. 0x07,0x74,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x30,0x07,
  1770. 0x72,0xa0,0x07,0x73,0x20,0x07,0x7a,0x30,0x07,0x72,0xd0,0x06,0xf6,0x40,0x07,0x78,
  1771. 0xa0,0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x60,0x07,0x74,0xa0,
  1772. 0x07,0x76,0x40,0x07,0x7a,0x60,0x07,0x74,0xd0,0x06,0xf6,0x90,0x07,0x76,0xa0,0x07,
  1773. 0x71,0x20,0x07,0x78,0xa0,0x07,0x71,0x20,0x07,0x78,0xd0,0x06,0xf6,0x10,0x07,0x72,
  1774. 0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x7a,0x10,0x07,0x72,0x80,0x07,0x6d,0x60,
  1775. 0x0f,0x71,0x90,0x07,0x72,0xa0,0x07,0x72,0x50,0x07,0x76,0xa0,0x07,0x72,0x50,0x07,
  1776. 0x76,0xd0,0x06,0xf6,0x20,0x07,0x75,0x60,0x07,0x7a,0x20,0x07,0x75,0x60,0x07,0x7a,
  1777. 0x20,0x07,0x75,0x60,0x07,0x6d,0x60,0x0f,0x75,0x10,0x07,0x72,0xa0,0x07,0x75,0x10,
  1778. 0x07,0x72,0xa0,0x07,0x75,0x10,0x07,0x72,0xd0,0x06,0xf6,0x10,0x07,0x70,0x20,0x07,
  1779. 0x74,0xa0,0x07,0x71,0x00,0x07,0x72,0x40,0x07,0x7a,0x10,0x07,0x70,0x20,0x07,0x74,
  1780. 0xd0,0x06,0xee,0x80,0x07,0x7a,0x10,0x07,0x76,0xa0,0x07,0x73,0x20,0x07,0x43,0x18,
  1781. 0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x21,0x8c,0x03,0x04,0x80,0x00,0x00,
  1782. 0x00,0x00,0x00,0x40,0x16,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x32,0x1e,0x98,
  1783. 0x10,0x19,0x11,0x4c,0x90,0x8c,0x09,0x26,0x47,0xc6,0x04,0x43,0x5a,0x25,0x30,0x02,
  1784. 0x50,0x04,0x85,0x50,0x10,0x65,0x40,0x70,0x2c,0x41,0x02,0x00,0x00,0x79,0x18,0x00,
  1785. 0x00,0xd0,0x00,0x00,0x00,0x1a,0x03,0x4c,0x10,0x97,0x29,0xa2,0x25,0x10,0xab,0x32,
  1786. 0xb9,0xb9,0xb4,0x37,0xb7,0x21,0xc6,0x42,0x3c,0x00,0x84,0x50,0xb9,0x1b,0x43,0x0b,
  1787. 0x93,0xfb,0x9a,0x4b,0xd3,0x2b,0x1b,0x62,0x2c,0xc2,0x23,0x2c,0x05,0xe3,0x20,0x08,
  1788. 0x0e,0x8e,0xad,0x0c,0xa4,0xad,0x8c,0x2e,0x8c,0x0d,0xc4,0xae,0x4c,0x6e,0x2e,0xed,
  1789. 0xcd,0x0d,0x64,0x46,0x06,0x46,0x66,0xc6,0x65,0x66,0xa6,0x06,0x04,0xa5,0xad,0x8c,
  1790. 0x2e,0x8c,0xcd,0xac,0xac,0x65,0x46,0x06,0x46,0x66,0xc6,0x65,0x66,0xa6,0x26,0x65,
  1791. 0x88,0xf0,0x10,0x43,0x8c,0x45,0x58,0x8c,0x65,0x60,0xd1,0x54,0x46,0x17,0xc6,0x36,
  1792. 0x04,0x79,0x8e,0x45,0x58,0x84,0x65,0xe0,0x16,0x96,0x26,0xe7,0x32,0xf6,0xd6,0x06,
  1793. 0x97,0xc6,0x56,0xe6,0x42,0x56,0xe6,0xf6,0x26,0xd7,0x36,0xf7,0x45,0x96,0x36,0x17,
  1794. 0x26,0xc6,0x56,0x36,0x44,0x78,0x12,0x72,0x61,0x69,0x72,0x2e,0x63,0x6f,0x6d,0x70,
  1795. 0x69,0x6c,0x65,0x2e,0x66,0x61,0x73,0x74,0x5f,0x6d,0x61,0x74,0x68,0x5f,0x65,0x6e,
  1796. 0x61,0x62,0x6c,0x65,0x43,0x84,0x67,0x21,0x19,0x84,0xa5,0xc9,0xb9,0x8c,0xbd,0xb5,
  1797. 0xc1,0xa5,0xb1,0x95,0xb9,0x98,0xc9,0x85,0xb5,0x95,0x89,0xd5,0x99,0x99,0x95,0xc9,
  1798. 0x7d,0x99,0x95,0xd1,0x8d,0xa1,0x7d,0x95,0xb9,0x85,0x89,0xb1,0x95,0x0d,0x11,0x9e,
  1799. 0x86,0x51,0x58,0x9a,0x9c,0x8b,0x5c,0x99,0x1b,0x59,0x99,0xdc,0x17,0x5d,0x98,0xdc,
  1800. 0x59,0x19,0x1d,0xa3,0xb0,0x34,0x39,0x97,0x30,0xb9,0xb3,0x2f,0xba,0x3c,0xb8,0xb2,
  1801. 0x2f,0xb7,0xb0,0xb6,0x32,0x1a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x64,0xc2,0xd2,0xe4,
  1802. 0x5c,0xc2,0xe4,0xce,0xbe,0xdc,0xc2,0xda,0xca,0xa8,0x98,0xc9,0x85,0x9d,0x7d,0x8d,
  1803. 0xbd,0xb1,0xbd,0xc9,0x0d,0x61,0x9e,0x67,0x19,0x1e,0xe8,0x89,0x1e,0xe9,0x99,0x86,
  1804. 0x08,0x0f,0x45,0x29,0x2c,0x4d,0xce,0xc5,0x4c,0x2e,0xec,0xac,0xad,0xcc,0x8d,0xee,
  1805. 0x2b,0xcd,0x0d,0xae,0x8e,0x8e,0x4b,0xdd,0x5c,0x99,0x1c,0x0a,0xdb,0xdb,0x98,0x1b,
  1806. 0x4c,0x0a,0x95,0xb0,0x34,0x39,0x97,0xb1,0x32,0x37,0xba,0x32,0x39,0x3e,0x61,0x69,
  1807. 0x72,0x2e,0x70,0x65,0x72,0x73,0x70,0x65,0x63,0x74,0x69,0x76,0x65,0x14,0xea,0xec,
  1808. 0x86,0x48,0xcb,0xf0,0x58,0xcf,0xf5,0x60,0x4f,0xf6,0x40,0x4f,0xf4,0x48,0x8f,0xc6,
  1809. 0xa5,0x6e,0xae,0x4c,0x0e,0x85,0xed,0x6d,0xcc,0x2d,0x26,0x85,0xc5,0xd8,0x1b,0xdb,
  1810. 0x9b,0xdc,0x10,0x69,0x11,0x1e,0xeb,0xe1,0x1e,0xec,0xc9,0x1e,0xe8,0x89,0x1e,0xe9,
  1811. 0xe9,0xb8,0x84,0xa5,0xc9,0xb9,0xd0,0x95,0xe1,0xd1,0xd5,0xc9,0x95,0x51,0x0a,0x4b,
  1812. 0x93,0x73,0x61,0x7b,0x1b,0x0b,0xa3,0x4b,0x7b,0x73,0xfb,0x4a,0x73,0x23,0x2b,0xc3,
  1813. 0xa3,0x12,0x96,0x26,0xe7,0x32,0x17,0xd6,0x06,0xc7,0x56,0x46,0x8c,0xae,0x0c,0x8f,
  1814. 0xae,0x4e,0xae,0x4c,0x86,0x8c,0xc7,0x8c,0xed,0x2d,0x8c,0x8e,0x05,0x64,0x2e,0xac,
  1815. 0x0d,0x8e,0xad,0xcc,0x87,0x03,0x5d,0x19,0xde,0x10,0x6a,0x21,0x9e,0xef,0x01,0x83,
  1816. 0x65,0x58,0x84,0x27,0x0c,0x1e,0xe8,0x11,0x83,0x47,0x7a,0xc6,0x80,0x4b,0x58,0x9a,
  1817. 0x9c,0xcb,0x5c,0x58,0x1b,0x1c,0x5b,0x99,0x1c,0x8f,0xb9,0xb0,0x36,0x38,0xb6,0x32,
  1818. 0x39,0x0e,0x73,0x6d,0x70,0x43,0xa4,0xe5,0x78,0xca,0xe0,0x01,0x83,0x65,0x58,0x84,
  1819. 0x07,0x7a,0xcc,0xe0,0x91,0x9e,0x33,0x18,0x82,0x3c,0xdb,0xe3,0x3d,0x64,0xf0,0xa0,
  1820. 0xc1,0x10,0x03,0x01,0x9e,0xea,0x49,0x03,0x5e,0x61,0x69,0x72,0x2d,0x61,0x6c,0x69,
  1821. 0x61,0x73,0x2d,0x73,0x63,0x6f,0x70,0x65,0x73,0x28,0x6d,0x61,0x69,0x6e,0x30,0x29,
  1822. 0x43,0x88,0x87,0x0d,0x9e,0x35,0x20,0x16,0x96,0x26,0xd7,0x12,0xc6,0x96,0x16,0x36,
  1823. 0xd7,0x32,0x37,0xf6,0x06,0x57,0xd6,0x42,0x57,0x86,0x47,0x57,0x27,0x57,0x36,0x37,
  1824. 0xc4,0x78,0xdc,0xe0,0x61,0x83,0xa7,0x0d,0x88,0x85,0xa5,0xc9,0xb5,0x84,0xb1,0xa5,
  1825. 0x85,0xcd,0xb5,0xcc,0x8d,0xbd,0xc1,0x95,0xb5,0xcc,0x85,0xb5,0xc1,0xb1,0x95,0xc9,
  1826. 0xcd,0x0d,0x31,0x1e,0x38,0x78,0xd8,0xe0,0x79,0x83,0x21,0xc4,0xe3,0x06,0x0f,0x1c,
  1827. 0x8c,0x88,0xd8,0x81,0x1d,0xec,0xa1,0x1d,0xdc,0xa0,0x1d,0xde,0x81,0x1c,0xea,0x81,
  1828. 0x1d,0xca,0xc1,0x0d,0xcc,0x81,0x1d,0xc2,0xe1,0x1c,0xe6,0x61,0x8a,0x10,0x0c,0x23,
  1829. 0x14,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x48,0x07,0x72,0x28,0x07,0x77,0xa0,0x87,
  1830. 0x29,0x41,0x31,0x62,0x09,0x87,0x74,0x90,0x07,0x37,0xb0,0x87,0x72,0x90,0x87,0x79,
  1831. 0x48,0x87,0x77,0x70,0x87,0x29,0x81,0x31,0x82,0x0a,0x87,0x74,0x90,0x07,0x37,0x60,
  1832. 0x87,0x70,0x70,0x87,0x73,0xa8,0x87,0x70,0x38,0x87,0x72,0xf8,0x05,0x7b,0x28,0x07,
  1833. 0x79,0x98,0x87,0x74,0x78,0x07,0x77,0x98,0x12,0x20,0x23,0xa6,0x70,0x48,0x07,0x79,
  1834. 0x70,0x83,0x71,0x78,0x87,0x76,0x80,0x87,0x74,0x60,0x87,0x72,0xf8,0x85,0x77,0x80,
  1835. 0x07,0x7a,0x48,0x87,0x77,0x70,0x87,0x79,0x98,0x32,0x28,0x8c,0x33,0x82,0x09,0x87,
  1836. 0x74,0x90,0x07,0x37,0x30,0x07,0x79,0x08,0x87,0x73,0x68,0x87,0x72,0x70,0x07,0x7a,
  1837. 0x98,0x12,0xa8,0x01,0x00,0x79,0x18,0x00,0x00,0xa5,0x00,0x00,0x00,0x33,0x08,0x80,
  1838. 0x1c,0xc4,0xe1,0x1c,0x66,0x14,0x01,0x3d,0x88,0x43,0x38,0x84,0xc3,0x8c,0x42,0x80,
  1839. 0x07,0x79,0x78,0x07,0x73,0x98,0x71,0x0c,0xe6,0x00,0x0f,0xed,0x10,0x0e,0xf4,0x80,
  1840. 0x0e,0x33,0x0c,0x42,0x1e,0xc2,0xc1,0x1d,0xce,0xa1,0x1c,0x66,0x30,0x05,0x3d,0x88,
  1841. 0x43,0x38,0x84,0x83,0x1b,0xcc,0x03,0x3d,0xc8,0x43,0x3d,0x8c,0x03,0x3d,0xcc,0x78,
  1842. 0x8c,0x74,0x70,0x07,0x7b,0x08,0x07,0x79,0x48,0x87,0x70,0x70,0x07,0x7a,0x70,0x03,
  1843. 0x76,0x78,0x87,0x70,0x20,0x87,0x19,0xcc,0x11,0x0e,0xec,0x90,0x0e,0xe1,0x30,0x0f,
  1844. 0x6e,0x30,0x0f,0xe3,0xf0,0x0e,0xf0,0x50,0x0e,0x33,0x10,0xc4,0x1d,0xde,0x21,0x1c,
  1845. 0xd8,0x21,0x1d,0xc2,0x61,0x1e,0x66,0x30,0x89,0x3b,0xbc,0x83,0x3b,0xd0,0x43,0x39,
  1846. 0xb4,0x03,0x3c,0xbc,0x83,0x3c,0x84,0x03,0x3b,0xcc,0xf0,0x14,0x76,0x60,0x07,0x7b,
  1847. 0x68,0x07,0x37,0x68,0x87,0x72,0x68,0x07,0x37,0x80,0x87,0x70,0x90,0x87,0x70,0x60,
  1848. 0x07,0x76,0x28,0x07,0x76,0xf8,0x05,0x76,0x78,0x87,0x77,0x80,0x87,0x5f,0x08,0x87,
  1849. 0x71,0x18,0x87,0x72,0x98,0x87,0x79,0x98,0x81,0x2c,0xee,0xf0,0x0e,0xee,0xe0,0x0e,
  1850. 0xf5,0xc0,0x0e,0xec,0x30,0x03,0x62,0xc8,0xa1,0x1c,0xe4,0xa1,0x1c,0xcc,0xa1,0x1c,
  1851. 0xe4,0xa1,0x1c,0xdc,0x61,0x1c,0xca,0x21,0x1c,0xc4,0x81,0x1d,0xca,0x61,0x06,0xd6,
  1852. 0x90,0x43,0x39,0xc8,0x43,0x39,0x98,0x43,0x39,0xc8,0x43,0x39,0xb8,0xc3,0x38,0x94,
  1853. 0x43,0x38,0x88,0x03,0x3b,0x94,0xc3,0x2f,0xbc,0x83,0x3c,0xfc,0x82,0x3b,0xd4,0x03,
  1854. 0x3b,0xb0,0xc3,0x0c,0xc7,0x69,0x87,0x70,0x58,0x87,0x72,0x70,0x83,0x74,0x68,0x07,
  1855. 0x78,0x60,0x87,0x74,0x18,0x87,0x74,0xa0,0x87,0x19,0xce,0x53,0x0f,0xee,0x00,0x0f,
  1856. 0xf2,0x50,0x0e,0xe4,0x90,0x0e,0xe3,0x40,0x0f,0xe1,0x20,0x0e,0xec,0x50,0x0e,0x33,
  1857. 0x20,0x28,0x1d,0xdc,0xc1,0x1e,0xc2,0x41,0x1e,0xd2,0x21,0x1c,0xdc,0x81,0x1e,0xdc,
  1858. 0xe0,0x1c,0xe4,0xe1,0x1d,0xea,0x01,0x1e,0x66,0x18,0x51,0x38,0xb0,0x43,0x3a,0x9c,
  1859. 0x83,0x3b,0xcc,0x50,0x24,0x76,0x60,0x07,0x7b,0x68,0x07,0x37,0x60,0x87,0x77,0x78,
  1860. 0x07,0x78,0x98,0x51,0x4c,0xf4,0x90,0x0f,0xf0,0x50,0x0e,0x33,0x1e,0x6a,0x1e,0xca,
  1861. 0x61,0x1c,0xe8,0x21,0x1d,0xde,0xc1,0x1d,0x7e,0x01,0x1e,0xe4,0xa1,0x1c,0xcc,0x21,
  1862. 0x1d,0xf0,0x61,0x06,0x54,0x85,0x83,0x38,0xcc,0xc3,0x3b,0xb0,0x43,0x3d,0xd0,0x43,
  1863. 0x39,0xfc,0xc2,0x3c,0xe4,0x43,0x3b,0x88,0xc3,0x3b,0xb0,0xc3,0x8c,0xc5,0x0a,0x87,
  1864. 0x79,0x98,0x87,0x77,0x18,0x87,0x74,0x08,0x07,0x7a,0x28,0x07,0x72,0x98,0x81,0x5c,
  1865. 0xe3,0x10,0x0e,0xec,0xc0,0x0e,0xe5,0x50,0x0e,0xf3,0x30,0x23,0xc1,0xd2,0x41,0x1e,
  1866. 0xe4,0xe1,0x17,0xd8,0xe1,0x1d,0xde,0x01,0x1e,0x66,0x48,0x19,0x3b,0xb0,0x83,0x3d,
  1867. 0xb4,0x83,0x1b,0x84,0xc3,0x38,0x8c,0x43,0x39,0xcc,0xc3,0x3c,0xb8,0xc1,0x39,0xc8,
  1868. 0xc3,0x3b,0xd4,0x03,0x3c,0xcc,0x48,0xb4,0x71,0x08,0x07,0x76,0x60,0x07,0x71,0x08,
  1869. 0x87,0x71,0x58,0x87,0x19,0xdb,0xc6,0x0e,0xec,0x60,0x0f,0xed,0xe0,0x06,0xf0,0x20,
  1870. 0x0f,0xe5,0x30,0x0f,0xe5,0x20,0x0f,0xf6,0x50,0x0e,0x6e,0x10,0x0e,0xe3,0x30,0x0e,
  1871. 0xe5,0x30,0x0f,0xf3,0xe0,0x06,0xe9,0xe0,0x0e,0xe4,0x50,0x0e,0xf8,0x30,0x23,0xe2,
  1872. 0xec,0x61,0x1c,0xc2,0x81,0x1d,0xd8,0xe1,0x17,0xec,0x21,0x1d,0xe6,0x21,0x1d,0xc4,
  1873. 0x21,0x1d,0xd8,0x21,0x1d,0xe8,0x21,0x1f,0x66,0x20,0x9d,0x3b,0xbc,0x43,0x3d,0xb8,
  1874. 0x03,0x39,0x94,0x83,0x39,0xcc,0x58,0xbc,0x70,0x70,0x07,0x77,0x78,0x07,0x7a,0x08,
  1875. 0x07,0x7a,0x48,0x87,0x77,0x70,0x87,0x19,0xce,0x87,0x0e,0xe5,0x10,0x0e,0xf0,0x10,
  1876. 0x0e,0xec,0xc0,0x0e,0xef,0x30,0x0e,0xf3,0x90,0x0e,0xf4,0x50,0x0e,0x33,0x28,0x30,
  1877. 0x08,0x87,0x74,0x90,0x07,0x37,0x30,0x87,0x7a,0x70,0x87,0x71,0xa0,0x87,0x74,0x78,
  1878. 0x07,0x77,0xf8,0x85,0x73,0x90,0x87,0x77,0xa8,0x07,0x78,0x98,0x07,0x00,0x00,0x00,
  1879. 0x00,0x71,0x20,0x00,0x00,0x08,0x00,0x00,0x00,0x16,0xb0,0x01,0x48,0xe4,0x4b,0x00,
  1880. 0xf3,0x2c,0xc4,0x3f,0x11,0xd7,0x44,0x45,0xc4,0x6f,0x0f,0x7e,0x85,0x17,0xb7,0x6d,
  1881. 0x00,0x05,0x03,0x20,0x0d,0x0d,0x00,0x00,0x00,0x61,0x20,0x00,0x00,0x14,0x00,0x00,
  1882. 0x00,0x13,0x04,0x41,0x2c,0x10,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xc4,0x46,0x00,
  1883. 0xc6,0x12,0x80,0x80,0xd4,0x08,0x40,0x0d,0x90,0x98,0x01,0xa0,0x30,0x03,0x40,0x60,
  1884. 0x04,0x00,0x00,0x00,0x00,0x83,0x0c,0x8b,0x60,0x8c,0x18,0x28,0x43,0x40,0x29,0x49,
  1885. 0x50,0x20,0x86,0x60,0x01,0x23,0x9f,0xd9,0x06,0x23,0x00,0x32,0x08,0x88,0x01,0x00,
  1886. 0x00,0x02,0x00,0x00,0x00,0x5b,0x86,0xe0,0x88,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
  1887. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1888. };
  1889. /*
  1890. #include <metal_stdlib>
  1891. #include <simd/simd.h>
  1892. using namespace metal;
  1893. struct vs_params
  1894. {
  1895. float4x4 mvp;
  1896. float4x4 tm;
  1897. };
  1898. struct main0_out
  1899. {
  1900. float4 uv [[user(locn0)]];
  1901. float4 color [[user(locn1)]];
  1902. float4 gl_Position [[position]];
  1903. float gl_PointSize [[point_size]];
  1904. };
  1905. struct main0_in
  1906. {
  1907. float4 position [[attribute(0)]];
  1908. float2 texcoord0 [[attribute(1)]];
  1909. float4 color0 [[attribute(2)]];
  1910. float psize [[attribute(3)]];
  1911. };
  1912. vertex main0_out main0(main0_in in [[stage_in]], constant vs_params& _19 [[buffer(0)]])
  1913. {
  1914. main0_out out = {};
  1915. out.gl_Position = _19.mvp * in.position;
  1916. out.gl_PointSize = in.psize;
  1917. out.uv = _19.tm * float4(in.texcoord0, 0.0, 1.0);
  1918. out.color = in.color0;
  1919. return out;
  1920. }
  1921. */
  1922. static const uint8_t _sgl_vs_source_metal_sim[756] = {
  1923. 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
  1924. 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
  1925. 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
  1926. 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
  1927. 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76,
  1928. 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
  1929. 0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x20,0x20,0x20,
  1930. 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x74,0x6d,0x3b,0x0a,0x7d,0x3b,
  1931. 0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,
  1932. 0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
  1933. 0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,
  1934. 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,
  1935. 0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,
  1936. 0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
  1937. 0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,
  1938. 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
  1939. 0x6c,0x6f,0x61,0x74,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,
  1940. 0x65,0x20,0x5b,0x5b,0x70,0x6f,0x69,0x6e,0x74,0x5f,0x73,0x69,0x7a,0x65,0x5d,0x5d,
  1941. 0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,
  1942. 0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
  1943. 0x74,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,
  1944. 0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,
  1945. 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
  1946. 0x64,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,
  1947. 0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
  1948. 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,
  1949. 0x74,0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
  1950. 0x61,0x74,0x20,0x70,0x73,0x69,0x7a,0x65,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,
  1951. 0x62,0x75,0x74,0x65,0x28,0x33,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,
  1952. 0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,
  1953. 0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,
  1954. 0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,
  1955. 0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
  1956. 0x6d,0x73,0x26,0x20,0x5f,0x31,0x39,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,
  1957. 0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,
  1958. 0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,
  1959. 0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,
  1960. 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x31,0x39,0x2e,0x6d,0x76,0x70,0x20,0x2a,
  1961. 0x20,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,
  1962. 0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,
  1963. 0x7a,0x65,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x70,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,
  1964. 0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x75,0x76,0x20,0x3d,0x20,0x5f,0x31,0x39,0x2e,
  1965. 0x74,0x6d,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,0x74,
  1966. 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,
  1967. 0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,
  1968. 0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,
  1969. 0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,
  1970. 0x7d,0x0a,0x0a,0x00,
  1971. };
  1972. /*
  1973. #include <metal_stdlib>
  1974. #include <simd/simd.h>
  1975. using namespace metal;
  1976. struct main0_out
  1977. {
  1978. float4 frag_color [[color(0)]];
  1979. };
  1980. struct main0_in
  1981. {
  1982. float4 uv [[user(locn0)]];
  1983. float4 color [[user(locn1)]];
  1984. };
  1985. fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler smp [[sampler(0)]])
  1986. {
  1987. main0_out out = {};
  1988. out.frag_color = tex.sample(smp, in.uv.xy) * in.color;
  1989. return out;
  1990. }
  1991. */
  1992. static const uint8_t _sgl_fs_source_metal_sim[439] = {
  1993. 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
  1994. 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
  1995. 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
  1996. 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
  1997. 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
  1998. 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
  1999. 0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
  2000. 0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,
  2001. 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
  2002. 0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
  2003. 0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,
  2004. 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,
  2005. 0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,
  2006. 0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,
  2007. 0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,
  2008. 0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,
  2009. 0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x74,0x65,0x78,
  2010. 0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x74,0x65,
  2011. 0x78,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,
  2012. 0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x73,0x6d,0x70,0x20,0x5b,0x5b,
  2013. 0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,
  2014. 0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,
  2015. 0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,
  2016. 0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,
  2017. 0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,0x73,0x6d,0x70,0x2c,0x20,0x69,0x6e,0x2e,
  2018. 0x75,0x76,0x2e,0x78,0x79,0x29,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,
  2019. 0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,
  2020. 0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
  2021. };
  2022. #elif defined(SOKOL_D3D11)
  2023. /*
  2024. cbuffer vs_params : register(b0)
  2025. {
  2026. row_major float4x4 _19_mvp : packoffset(c0);
  2027. row_major float4x4 _19_tm : packoffset(c4);
  2028. };
  2029. static float4 gl_Position;
  2030. static float gl_PointSize;
  2031. static float4 position;
  2032. static float psize;
  2033. static float4 uv;
  2034. static float2 texcoord0;
  2035. static float4 color;
  2036. static float4 color0;
  2037. struct SPIRV_Cross_Input
  2038. {
  2039. float4 position : TEXCOORD0;
  2040. float2 texcoord0 : TEXCOORD1;
  2041. float4 color0 : TEXCOORD2;
  2042. float psize : TEXCOORD3;
  2043. };
  2044. struct SPIRV_Cross_Output
  2045. {
  2046. float4 uv : TEXCOORD0;
  2047. float4 color : TEXCOORD1;
  2048. float4 gl_Position : SV_Position;
  2049. };
  2050. void vert_main()
  2051. {
  2052. gl_Position = mul(position, _19_mvp);
  2053. gl_PointSize = psize;
  2054. uv = mul(float4(texcoord0, 0.0f, 1.0f), _19_tm);
  2055. color = color0;
  2056. }
  2057. SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
  2058. {
  2059. position = stage_input.position;
  2060. psize = stage_input.psize;
  2061. texcoord0 = stage_input.texcoord0;
  2062. color0 = stage_input.color0;
  2063. vert_main();
  2064. SPIRV_Cross_Output stage_output;
  2065. stage_output.gl_Position = gl_Position;
  2066. stage_output.uv = uv;
  2067. stage_output.color = color;
  2068. return stage_output;
  2069. }
  2070. */
  2071. static const uint8_t _sgl_vs_bytecode_hlsl4[1032] = {
  2072. 0x44,0x58,0x42,0x43,0x74,0x7f,0x01,0xd9,0xf4,0xd5,0xed,0x1d,0x74,0xc1,0x30,0x27,
  2073. 0xd8,0xe9,0x9d,0x50,0x01,0x00,0x00,0x00,0x08,0x04,0x00,0x00,0x05,0x00,0x00,0x00,
  2074. 0x34,0x00,0x00,0x00,0x14,0x01,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x02,0x00,0x00,
  2075. 0x8c,0x03,0x00,0x00,0x52,0x44,0x45,0x46,0xd8,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2076. 0x48,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xfe,0xff,
  2077. 0x10,0x81,0x00,0x00,0xaf,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2078. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2079. 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
  2080. 0x73,0x00,0xab,0xab,0x3c,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x60,0x00,0x00,0x00,
  2081. 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x00,0x00,0x00,
  2082. 0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x98,0x00,0x00,0x00,
  2083. 0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x40,0x00,0x00,0x00,
  2084. 0x02,0x00,0x00,0x00,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5f,0x31,0x39,0x5f,
  2085. 0x6d,0x76,0x70,0x00,0x02,0x00,0x03,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
  2086. 0x00,0x00,0x00,0x00,0x5f,0x31,0x39,0x5f,0x74,0x6d,0x00,0x4d,0x69,0x63,0x72,0x6f,
  2087. 0x73,0x6f,0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68,
  2088. 0x61,0x64,0x65,0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30,
  2089. 0x2e,0x31,0x00,0xab,0x49,0x53,0x47,0x4e,0x74,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
  2090. 0x08,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2091. 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x68,0x00,0x00,0x00,
  2092. 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2093. 0x03,0x03,0x00,0x00,0x68,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2094. 0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x68,0x00,0x00,0x00,
  2095. 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
  2096. 0x01,0x00,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x00,0xab,0xab,0xab,
  2097. 0x4f,0x53,0x47,0x4e,0x68,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
  2098. 0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
  2099. 0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2100. 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,
  2101. 0x59,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
  2102. 0x02,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,
  2103. 0x00,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,0xab,0xab,0xab,
  2104. 0x53,0x48,0x44,0x52,0x84,0x01,0x00,0x00,0x40,0x00,0x01,0x00,0x61,0x00,0x00,0x00,
  2105. 0x59,0x00,0x00,0x04,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
  2106. 0x5f,0x00,0x00,0x03,0xf2,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x03,
  2107. 0x32,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x5f,0x00,0x00,0x03,0xf2,0x10,0x10,0x00,
  2108. 0x02,0x00,0x00,0x00,0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00,
  2109. 0x65,0x00,0x00,0x03,0xf2,0x20,0x10,0x00,0x01,0x00,0x00,0x00,0x67,0x00,0x00,0x04,
  2110. 0xf2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x68,0x00,0x00,0x02,
  2111. 0x01,0x00,0x00,0x00,0x38,0x00,0x00,0x08,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,
  2112. 0x56,0x15,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,
  2113. 0x05,0x00,0x00,0x00,0x32,0x00,0x00,0x0a,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,
  2114. 0x06,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,
  2115. 0x04,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
  2116. 0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,
  2117. 0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x36,0x00,0x00,0x05,
  2118. 0xf2,0x20,0x10,0x00,0x01,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x02,0x00,0x00,0x00,
  2119. 0x38,0x00,0x00,0x08,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x56,0x15,0x10,0x00,
  2120. 0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2121. 0x32,0x00,0x00,0x0a,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x06,0x10,0x10,0x00,
  2122. 0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2123. 0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x32,0x00,0x00,0x0a,0xf2,0x00,0x10,0x00,
  2124. 0x00,0x00,0x00,0x00,0xa6,0x1a,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,
  2125. 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,
  2126. 0x32,0x00,0x00,0x0a,0xf2,0x20,0x10,0x00,0x02,0x00,0x00,0x00,0xf6,0x1f,0x10,0x00,
  2127. 0x00,0x00,0x00,0x00,0x46,0x8e,0x20,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
  2128. 0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x01,0x53,0x54,0x41,0x54,
  2129. 0x74,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2130. 0x06,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2131. 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2132. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2133. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2134. 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2135. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2136. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2137. };
  2138. /*
  2139. Texture2D<float4> tex : register(t0);
  2140. SamplerState smp : register(s0);
  2141. static float4 frag_color;
  2142. static float4 uv;
  2143. static float4 color;
  2144. struct SPIRV_Cross_Input
  2145. {
  2146. float4 uv : TEXCOORD0;
  2147. float4 color : TEXCOORD1;
  2148. };
  2149. struct SPIRV_Cross_Output
  2150. {
  2151. float4 frag_color : SV_Target0;
  2152. };
  2153. void frag_main()
  2154. {
  2155. frag_color = tex.Sample(smp, uv.xy) * color;
  2156. }
  2157. SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
  2158. {
  2159. uv = stage_input.uv;
  2160. color = stage_input.color;
  2161. frag_main();
  2162. SPIRV_Cross_Output stage_output;
  2163. stage_output.frag_color = frag_color;
  2164. return stage_output;
  2165. }
  2166. */
  2167. static const uint8_t _sgl_fs_bytecode_hlsl4[608] = {
  2168. 0x44,0x58,0x42,0x43,0xc8,0x9b,0x66,0x64,0x80,0x2f,0xbe,0x14,0xd9,0x88,0xa0,0x97,
  2169. 0x64,0x14,0x66,0xff,0x01,0x00,0x00,0x00,0x60,0x02,0x00,0x00,0x05,0x00,0x00,0x00,
  2170. 0x34,0x00,0x00,0x00,0xc8,0x00,0x00,0x00,0x14,0x01,0x00,0x00,0x48,0x01,0x00,0x00,
  2171. 0xe4,0x01,0x00,0x00,0x52,0x44,0x45,0x46,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2172. 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x04,0xff,0xff,
  2173. 0x10,0x81,0x00,0x00,0x64,0x00,0x00,0x00,0x5c,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
  2174. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2175. 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
  2176. 0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
  2177. 0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x73,0x6d,0x70,0x00,0x74,0x65,0x78,0x00,
  2178. 0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,
  2179. 0x53,0x4c,0x20,0x53,0x68,0x61,0x64,0x65,0x72,0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,
  2180. 0x65,0x72,0x20,0x31,0x30,0x2e,0x31,0x00,0x49,0x53,0x47,0x4e,0x44,0x00,0x00,0x00,
  2181. 0x02,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2182. 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x03,0x00,0x00,
  2183. 0x38,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
  2184. 0x01,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,
  2185. 0x00,0xab,0xab,0xab,0x4f,0x53,0x47,0x4e,0x2c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2186. 0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2187. 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x53,0x56,0x5f,0x54,
  2188. 0x61,0x72,0x67,0x65,0x74,0x00,0xab,0xab,0x53,0x48,0x44,0x52,0x94,0x00,0x00,0x00,
  2189. 0x40,0x00,0x00,0x00,0x25,0x00,0x00,0x00,0x5a,0x00,0x00,0x03,0x00,0x60,0x10,0x00,
  2190. 0x00,0x00,0x00,0x00,0x58,0x18,0x00,0x04,0x00,0x70,0x10,0x00,0x00,0x00,0x00,0x00,
  2191. 0x55,0x55,0x00,0x00,0x62,0x10,0x00,0x03,0x32,0x10,0x10,0x00,0x00,0x00,0x00,0x00,
  2192. 0x62,0x10,0x00,0x03,0xf2,0x10,0x10,0x00,0x01,0x00,0x00,0x00,0x65,0x00,0x00,0x03,
  2193. 0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x68,0x00,0x00,0x02,0x01,0x00,0x00,0x00,
  2194. 0x45,0x00,0x00,0x09,0xf2,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x10,0x00,
  2195. 0x00,0x00,0x00,0x00,0x46,0x7e,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x10,0x00,
  2196. 0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x07,0xf2,0x20,0x10,0x00,0x00,0x00,0x00,0x00,
  2197. 0x46,0x0e,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x1e,0x10,0x00,0x01,0x00,0x00,0x00,
  2198. 0x3e,0x00,0x00,0x01,0x53,0x54,0x41,0x54,0x74,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
  2199. 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2200. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2201. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2202. 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2203. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2204. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2205. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2206. };
  2207. #elif defined(SOKOL_WGPU)
  2208. /*
  2209. diagnostic(off, derivative_uniformity);
  2210. struct vs_params {
  2211. /_ @offset(0) _/
  2212. mvp : mat4x4f,
  2213. /_ @offset(64) _/
  2214. tm : mat4x4f,
  2215. }
  2216. @binding(0) @group(0) var<uniform> x_19 : vs_params;
  2217. var<private> position_1 : vec4f;
  2218. var<private> uv : vec4f;
  2219. var<private> texcoord0 : vec2f;
  2220. var<private> color : vec4f;
  2221. var<private> color0 : vec4f;
  2222. var<private> psize : f32;
  2223. var<private> gl_Position : vec4f;
  2224. fn main_1() {
  2225. gl_Position = (x_19.mvp * position_1);
  2226. uv = (x_19.tm * vec4f(texcoord0.x, texcoord0.y, 0.0f, 1.0f));
  2227. color = color0;
  2228. return;
  2229. }
  2230. struct main_out {
  2231. @builtin(position)
  2232. gl_Position : vec4f,
  2233. @location(0)
  2234. uv_1 : vec4f,
  2235. @location(1)
  2236. color_1 : vec4f,
  2237. }
  2238. @vertex
  2239. fn main(@location(0) position_1_param : vec4f, @location(1) texcoord0_param : vec2f, @location(2) color0_param : vec4f, @location(3) psize_param : f32) -> main_out {
  2240. position_1 = position_1_param;
  2241. texcoord0 = texcoord0_param;
  2242. color0 = color0_param;
  2243. psize = psize_param;
  2244. main_1();
  2245. return main_out(gl_Position, uv, color);
  2246. }
  2247. */
  2248. static const uint8_t _sgl_vs_source_wgsl[1027] = {
  2249. 0x64,0x69,0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x28,0x6f,0x66,0x66,0x2c,0x20,
  2250. 0x64,0x65,0x72,0x69,0x76,0x61,0x74,0x69,0x76,0x65,0x5f,0x75,0x6e,0x69,0x66,0x6f,
  2251. 0x72,0x6d,0x69,0x74,0x79,0x29,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
  2252. 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x20,0x7b,0x0a,0x20,0x20,0x2f,0x2a,
  2253. 0x20,0x40,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x30,0x29,0x20,0x2a,0x2f,0x0a,0x20,
  2254. 0x20,0x6d,0x76,0x70,0x20,0x3a,0x20,0x6d,0x61,0x74,0x34,0x78,0x34,0x66,0x2c,0x0a,
  2255. 0x20,0x20,0x2f,0x2a,0x20,0x40,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x36,0x34,0x29,
  2256. 0x20,0x2a,0x2f,0x0a,0x20,0x20,0x74,0x6d,0x20,0x3a,0x20,0x6d,0x61,0x74,0x34,0x78,
  2257. 0x34,0x66,0x2c,0x0a,0x7d,0x0a,0x0a,0x40,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x28,
  2258. 0x30,0x29,0x20,0x40,0x67,0x72,0x6f,0x75,0x70,0x28,0x30,0x29,0x20,0x76,0x61,0x72,
  2259. 0x3c,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x3e,0x20,0x78,0x5f,0x31,0x39,0x20,0x3a,
  2260. 0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x3b,0x0a,0x0a,0x76,0x61,0x72,
  2261. 0x3c,0x70,0x72,0x69,0x76,0x61,0x74,0x65,0x3e,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,
  2262. 0x6f,0x6e,0x5f,0x31,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x3b,0x0a,0x0a,0x76,
  2263. 0x61,0x72,0x3c,0x70,0x72,0x69,0x76,0x61,0x74,0x65,0x3e,0x20,0x75,0x76,0x20,0x3a,
  2264. 0x20,0x76,0x65,0x63,0x34,0x66,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x3c,0x70,0x72,0x69,
  2265. 0x76,0x61,0x74,0x65,0x3e,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,
  2266. 0x3a,0x20,0x76,0x65,0x63,0x32,0x66,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x3c,0x70,0x72,
  2267. 0x69,0x76,0x61,0x74,0x65,0x3e,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x76,
  2268. 0x65,0x63,0x34,0x66,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x3c,0x70,0x72,0x69,0x76,0x61,
  2269. 0x74,0x65,0x3e,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,0x3a,0x20,0x76,0x65,0x63,
  2270. 0x34,0x66,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x3c,0x70,0x72,0x69,0x76,0x61,0x74,0x65,
  2271. 0x3e,0x20,0x70,0x73,0x69,0x7a,0x65,0x20,0x3a,0x20,0x66,0x33,0x32,0x3b,0x0a,0x0a,
  2272. 0x76,0x61,0x72,0x3c,0x70,0x72,0x69,0x76,0x61,0x74,0x65,0x3e,0x20,0x67,0x6c,0x5f,
  2273. 0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,
  2274. 0x3b,0x0a,0x0a,0x66,0x6e,0x20,0x6d,0x61,0x69,0x6e,0x5f,0x31,0x28,0x29,0x20,0x7b,
  2275. 0x0a,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,
  2276. 0x20,0x28,0x78,0x5f,0x31,0x39,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x70,0x6f,0x73,
  2277. 0x69,0x74,0x69,0x6f,0x6e,0x5f,0x31,0x29,0x3b,0x0a,0x20,0x20,0x75,0x76,0x20,0x3d,
  2278. 0x20,0x28,0x78,0x5f,0x31,0x39,0x2e,0x74,0x6d,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,
  2279. 0x66,0x28,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2e,0x78,0x2c,0x20,0x74,
  2280. 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2e,0x79,0x2c,0x20,0x30,0x2e,0x30,0x66,
  2281. 0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x29,0x3b,0x0a,0x20,0x20,0x63,0x6f,0x6c,0x6f,
  2282. 0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x72,0x65,
  2283. 0x74,0x75,0x72,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
  2284. 0x6d,0x61,0x69,0x6e,0x5f,0x6f,0x75,0x74,0x20,0x7b,0x0a,0x20,0x20,0x40,0x62,0x75,
  2285. 0x69,0x6c,0x74,0x69,0x6e,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x0a,
  2286. 0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,
  2287. 0x76,0x65,0x63,0x34,0x66,0x2c,0x0a,0x20,0x20,0x40,0x6c,0x6f,0x63,0x61,0x74,0x69,
  2288. 0x6f,0x6e,0x28,0x30,0x29,0x0a,0x20,0x20,0x75,0x76,0x5f,0x31,0x20,0x3a,0x20,0x76,
  2289. 0x65,0x63,0x34,0x66,0x2c,0x0a,0x20,0x20,0x40,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,
  2290. 0x6e,0x28,0x31,0x29,0x0a,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x31,0x20,0x3a,
  2291. 0x20,0x76,0x65,0x63,0x34,0x66,0x2c,0x0a,0x7d,0x0a,0x0a,0x40,0x76,0x65,0x72,0x74,
  2292. 0x65,0x78,0x0a,0x66,0x6e,0x20,0x6d,0x61,0x69,0x6e,0x28,0x40,0x6c,0x6f,0x63,0x61,
  2293. 0x74,0x69,0x6f,0x6e,0x28,0x30,0x29,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
  2294. 0x5f,0x31,0x5f,0x70,0x61,0x72,0x61,0x6d,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,
  2295. 0x2c,0x20,0x40,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x28,0x31,0x29,0x20,0x74,
  2296. 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x5f,0x70,0x61,0x72,0x61,0x6d,0x20,0x3a,
  2297. 0x20,0x76,0x65,0x63,0x32,0x66,0x2c,0x20,0x40,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,
  2298. 0x6e,0x28,0x32,0x29,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x5f,0x70,0x61,0x72,0x61,
  2299. 0x6d,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x2c,0x20,0x40,0x6c,0x6f,0x63,0x61,
  2300. 0x74,0x69,0x6f,0x6e,0x28,0x33,0x29,0x20,0x70,0x73,0x69,0x7a,0x65,0x5f,0x70,0x61,
  2301. 0x72,0x61,0x6d,0x20,0x3a,0x20,0x66,0x33,0x32,0x29,0x20,0x2d,0x3e,0x20,0x6d,0x61,
  2302. 0x69,0x6e,0x5f,0x6f,0x75,0x74,0x20,0x7b,0x0a,0x20,0x20,0x70,0x6f,0x73,0x69,0x74,
  2303. 0x69,0x6f,0x6e,0x5f,0x31,0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
  2304. 0x5f,0x31,0x5f,0x70,0x61,0x72,0x61,0x6d,0x3b,0x0a,0x20,0x20,0x74,0x65,0x78,0x63,
  2305. 0x6f,0x6f,0x72,0x64,0x30,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
  2306. 0x30,0x5f,0x70,0x61,0x72,0x61,0x6d,0x3b,0x0a,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,
  2307. 0x30,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x5f,0x70,0x61,0x72,0x61,0x6d,
  2308. 0x3b,0x0a,0x20,0x20,0x70,0x73,0x69,0x7a,0x65,0x20,0x3d,0x20,0x70,0x73,0x69,0x7a,
  2309. 0x65,0x5f,0x70,0x61,0x72,0x61,0x6d,0x3b,0x0a,0x20,0x20,0x6d,0x61,0x69,0x6e,0x5f,
  2310. 0x31,0x28,0x29,0x3b,0x0a,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6d,0x61,
  2311. 0x69,0x6e,0x5f,0x6f,0x75,0x74,0x28,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
  2312. 0x6f,0x6e,0x2c,0x20,0x75,0x76,0x2c,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x29,0x3b,0x0a,
  2313. 0x7d,0x0a,0x00,
  2314. };
  2315. /*
  2316. diagnostic(off, derivative_uniformity);
  2317. var<private> frag_color : vec4f;
  2318. @binding(0) @group(1) var tex : texture_2d<f32>;
  2319. @binding(32) @group(1) var smp : sampler;
  2320. var<private> uv : vec4f;
  2321. var<private> color : vec4f;
  2322. fn main_1() {
  2323. let x_23 = uv;
  2324. let x_25 = textureSample(tex, smp, x_23.xy);
  2325. frag_color = (x_25 * color);
  2326. return;
  2327. }
  2328. struct main_out {
  2329. @location(0)
  2330. frag_color_1 : vec4f,
  2331. }
  2332. @fragment
  2333. fn main(@location(0) uv_param : vec4f, @location(1) color_param : vec4f) -> main_out {
  2334. uv = uv_param;
  2335. color = color_param;
  2336. main_1();
  2337. return main_out(frag_color);
  2338. }
  2339. */
  2340. static const uint8_t _sgl_fs_source_wgsl[588] = {
  2341. 0x64,0x69,0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x28,0x6f,0x66,0x66,0x2c,0x20,
  2342. 0x64,0x65,0x72,0x69,0x76,0x61,0x74,0x69,0x76,0x65,0x5f,0x75,0x6e,0x69,0x66,0x6f,
  2343. 0x72,0x6d,0x69,0x74,0x79,0x29,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x3c,0x70,0x72,0x69,
  2344. 0x76,0x61,0x74,0x65,0x3e,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
  2345. 0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x3b,0x0a,0x0a,0x40,0x62,0x69,0x6e,0x64,
  2346. 0x69,0x6e,0x67,0x28,0x30,0x29,0x20,0x40,0x67,0x72,0x6f,0x75,0x70,0x28,0x31,0x29,
  2347. 0x20,0x76,0x61,0x72,0x20,0x74,0x65,0x78,0x20,0x3a,0x20,0x74,0x65,0x78,0x74,0x75,
  2348. 0x72,0x65,0x5f,0x32,0x64,0x3c,0x66,0x33,0x32,0x3e,0x3b,0x0a,0x0a,0x40,0x62,0x69,
  2349. 0x6e,0x64,0x69,0x6e,0x67,0x28,0x33,0x32,0x29,0x20,0x40,0x67,0x72,0x6f,0x75,0x70,
  2350. 0x28,0x31,0x29,0x20,0x76,0x61,0x72,0x20,0x73,0x6d,0x70,0x20,0x3a,0x20,0x73,0x61,
  2351. 0x6d,0x70,0x6c,0x65,0x72,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x3c,0x70,0x72,0x69,0x76,
  2352. 0x61,0x74,0x65,0x3e,0x20,0x75,0x76,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x3b,
  2353. 0x0a,0x0a,0x76,0x61,0x72,0x3c,0x70,0x72,0x69,0x76,0x61,0x74,0x65,0x3e,0x20,0x63,
  2354. 0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x3b,0x0a,0x0a,0x66,
  2355. 0x6e,0x20,0x6d,0x61,0x69,0x6e,0x5f,0x31,0x28,0x29,0x20,0x7b,0x0a,0x20,0x20,0x6c,
  2356. 0x65,0x74,0x20,0x78,0x5f,0x32,0x33,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x20,0x20,
  2357. 0x6c,0x65,0x74,0x20,0x78,0x5f,0x32,0x35,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,
  2358. 0x72,0x65,0x53,0x61,0x6d,0x70,0x6c,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x73,0x6d,
  2359. 0x70,0x2c,0x20,0x78,0x5f,0x32,0x33,0x2e,0x78,0x79,0x29,0x3b,0x0a,0x20,0x20,0x66,
  2360. 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x28,0x78,0x5f,0x32,
  2361. 0x35,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x29,0x3b,0x0a,0x20,0x20,0x72,0x65,
  2362. 0x74,0x75,0x72,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
  2363. 0x6d,0x61,0x69,0x6e,0x5f,0x6f,0x75,0x74,0x20,0x7b,0x0a,0x20,0x20,0x40,0x6c,0x6f,
  2364. 0x63,0x61,0x74,0x69,0x6f,0x6e,0x28,0x30,0x29,0x0a,0x20,0x20,0x66,0x72,0x61,0x67,
  2365. 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x31,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,
  2366. 0x2c,0x0a,0x7d,0x0a,0x0a,0x40,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x0a,0x66,
  2367. 0x6e,0x20,0x6d,0x61,0x69,0x6e,0x28,0x40,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
  2368. 0x28,0x30,0x29,0x20,0x75,0x76,0x5f,0x70,0x61,0x72,0x61,0x6d,0x20,0x3a,0x20,0x76,
  2369. 0x65,0x63,0x34,0x66,0x2c,0x20,0x40,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x28,
  2370. 0x31,0x29,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x20,0x3a,
  2371. 0x20,0x76,0x65,0x63,0x34,0x66,0x29,0x20,0x2d,0x3e,0x20,0x6d,0x61,0x69,0x6e,0x5f,
  2372. 0x6f,0x75,0x74,0x20,0x7b,0x0a,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x75,0x76,0x5f,
  2373. 0x70,0x61,0x72,0x61,0x6d,0x3b,0x0a,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
  2374. 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x70,0x61,0x72,0x61,0x6d,0x3b,0x0a,0x20,0x20,
  2375. 0x6d,0x61,0x69,0x6e,0x5f,0x31,0x28,0x29,0x3b,0x0a,0x20,0x20,0x72,0x65,0x74,0x75,
  2376. 0x72,0x6e,0x20,0x6d,0x61,0x69,0x6e,0x5f,0x6f,0x75,0x74,0x28,0x66,0x72,0x61,0x67,
  2377. 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x29,0x3b,0x0a,0x7d,0x0a,0x00,
  2378. };
  2379. #elif defined(SOKOL_VULKAN)
  2380. /*
  2381. #version 460
  2382. layout(set = 0, binding = 0, std140) uniform vs_params
  2383. {
  2384. mat4 mvp;
  2385. mat4 tm;
  2386. } _19;
  2387. layout(location = 0) in vec4 position;
  2388. layout(location = 3) in float psize;
  2389. layout(location = 0) out vec4 uv;
  2390. layout(location = 1) in vec2 texcoord0;
  2391. layout(location = 1) out vec4 color;
  2392. layout(location = 2) in vec4 color0;
  2393. void main()
  2394. {
  2395. gl_Position = _19.mvp * position;
  2396. gl_PointSize = psize;
  2397. uv = _19.tm * vec4(texcoord0, 0.0, 1.0);
  2398. color = color0;
  2399. }
  2400. */
  2401. static const uint8_t _sgl_vs_bytecode_spirv_vk[1668] = {
  2402. 0x03,0x02,0x23,0x07,0x00,0x04,0x01,0x00,0x0b,0x00,0x08,0x00,0x33,0x00,0x00,0x00,
  2403. 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00,
  2404. 0x01,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30,
  2405. 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2406. 0x0f,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e,
  2407. 0x00,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x18,0x00,0x00,0x00,
  2408. 0x1f,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
  2409. 0x31,0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x02,0x00,0x00,0x00,0xcc,0x01,0x00,0x00,
  2410. 0x05,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e,0x00,0x00,0x00,0x00,
  2411. 0x05,0x00,0x06,0x00,0x0b,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x65,0x72,0x56,0x65,
  2412. 0x72,0x74,0x65,0x78,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x0b,0x00,0x00,0x00,
  2413. 0x00,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x00,
  2414. 0x06,0x00,0x07,0x00,0x0b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x67,0x6c,0x5f,0x50,
  2415. 0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,0x65,0x00,0x00,0x00,0x00,0x06,0x00,0x07,0x00,
  2416. 0x0b,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x67,0x6c,0x5f,0x43,0x6c,0x69,0x70,0x44,
  2417. 0x69,0x73,0x74,0x61,0x6e,0x63,0x65,0x00,0x06,0x00,0x07,0x00,0x0b,0x00,0x00,0x00,
  2418. 0x03,0x00,0x00,0x00,0x67,0x6c,0x5f,0x43,0x75,0x6c,0x6c,0x44,0x69,0x73,0x74,0x61,
  2419. 0x6e,0x63,0x65,0x00,0x05,0x00,0x03,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2420. 0x05,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
  2421. 0x73,0x00,0x00,0x00,0x06,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2422. 0x6d,0x76,0x70,0x00,0x06,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2423. 0x74,0x6d,0x00,0x00,0x05,0x00,0x03,0x00,0x13,0x00,0x00,0x00,0x5f,0x31,0x39,0x00,
  2424. 0x05,0x00,0x05,0x00,0x18,0x00,0x00,0x00,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
  2425. 0x00,0x00,0x00,0x00,0x05,0x00,0x04,0x00,0x1f,0x00,0x00,0x00,0x70,0x73,0x69,0x7a,
  2426. 0x65,0x00,0x00,0x00,0x05,0x00,0x03,0x00,0x23,0x00,0x00,0x00,0x75,0x76,0x00,0x00,
  2427. 0x05,0x00,0x05,0x00,0x28,0x00,0x00,0x00,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,
  2428. 0x30,0x00,0x00,0x00,0x05,0x00,0x04,0x00,0x30,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f,
  2429. 0x72,0x00,0x00,0x00,0x05,0x00,0x04,0x00,0x31,0x00,0x00,0x00,0x63,0x6f,0x6c,0x6f,
  2430. 0x72,0x30,0x00,0x00,0x47,0x00,0x03,0x00,0x0b,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
  2431. 0x48,0x00,0x05,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,
  2432. 0x00,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2433. 0x0b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x0b,0x00,0x00,0x00,
  2434. 0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x48,0x00,0x05,0x00,
  2435. 0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
  2436. 0x47,0x00,0x03,0x00,0x11,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x48,0x00,0x04,0x00,
  2437. 0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x48,0x00,0x05,0x00,
  2438. 0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
  2439. 0x48,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x23,0x00,0x00,0x00,
  2440. 0x00,0x00,0x00,0x00,0x48,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2441. 0x05,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x11,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2442. 0x07,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x48,0x00,0x05,0x00,0x11,0x00,0x00,0x00,
  2443. 0x01,0x00,0x00,0x00,0x23,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x47,0x00,0x04,0x00,
  2444. 0x13,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,
  2445. 0x13,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,
  2446. 0x18,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,
  2447. 0x1f,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x47,0x00,0x04,0x00,
  2448. 0x23,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,
  2449. 0x28,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x47,0x00,0x04,0x00,
  2450. 0x30,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x47,0x00,0x04,0x00,
  2451. 0x31,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x13,0x00,0x02,0x00,
  2452. 0x02,0x00,0x00,0x00,0x21,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
  2453. 0x16,0x00,0x03,0x00,0x06,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x17,0x00,0x04,0x00,
  2454. 0x07,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x15,0x00,0x04,0x00,
  2455. 0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,
  2456. 0x08,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x1c,0x00,0x04,0x00,
  2457. 0x0a,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x1e,0x00,0x06,0x00,
  2458. 0x0b,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
  2459. 0x0a,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x0c,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
  2460. 0x0b,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x0c,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,
  2461. 0x03,0x00,0x00,0x00,0x15,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
  2462. 0x01,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,
  2463. 0x00,0x00,0x00,0x00,0x18,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
  2464. 0x04,0x00,0x00,0x00,0x1e,0x00,0x04,0x00,0x11,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
  2465. 0x10,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
  2466. 0x11,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x12,0x00,0x00,0x00,0x13,0x00,0x00,0x00,
  2467. 0x02,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x14,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
  2468. 0x10,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x17,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2469. 0x07,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x17,0x00,0x00,0x00,0x18,0x00,0x00,0x00,
  2470. 0x01,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x1b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
  2471. 0x07,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x0e,0x00,0x00,0x00,0x1d,0x00,0x00,0x00,
  2472. 0x01,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2473. 0x06,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x1e,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,
  2474. 0x01,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x21,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
  2475. 0x06,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x1b,0x00,0x00,0x00,0x23,0x00,0x00,0x00,
  2476. 0x03,0x00,0x00,0x00,0x17,0x00,0x04,0x00,0x26,0x00,0x00,0x00,0x06,0x00,0x00,0x00,
  2477. 0x02,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x27,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2478. 0x26,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x27,0x00,0x00,0x00,0x28,0x00,0x00,0x00,
  2479. 0x01,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x06,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,
  2480. 0x00,0x00,0x00,0x00,0x2b,0x00,0x04,0x00,0x06,0x00,0x00,0x00,0x2b,0x00,0x00,0x00,
  2481. 0x00,0x00,0x80,0x3f,0x3b,0x00,0x04,0x00,0x1b,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
  2482. 0x03,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x17,0x00,0x00,0x00,0x31,0x00,0x00,0x00,
  2483. 0x01,0x00,0x00,0x00,0x36,0x00,0x05,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
  2484. 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xf8,0x00,0x02,0x00,0x05,0x00,0x00,0x00,
  2485. 0x41,0x00,0x05,0x00,0x14,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x13,0x00,0x00,0x00,
  2486. 0x0f,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x16,0x00,0x00,0x00,
  2487. 0x15,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x19,0x00,0x00,0x00,
  2488. 0x18,0x00,0x00,0x00,0x91,0x00,0x05,0x00,0x07,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,
  2489. 0x16,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x41,0x00,0x05,0x00,0x1b,0x00,0x00,0x00,
  2490. 0x1c,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,
  2491. 0x1c,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,0x06,0x00,0x00,0x00,
  2492. 0x20,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x41,0x00,0x05,0x00,0x21,0x00,0x00,0x00,
  2493. 0x22,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x1d,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,
  2494. 0x22,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x41,0x00,0x05,0x00,0x14,0x00,0x00,0x00,
  2495. 0x24,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x1d,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,
  2496. 0x10,0x00,0x00,0x00,0x25,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,
  2497. 0x26,0x00,0x00,0x00,0x29,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x51,0x00,0x05,0x00,
  2498. 0x06,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2499. 0x51,0x00,0x05,0x00,0x06,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x29,0x00,0x00,0x00,
  2500. 0x01,0x00,0x00,0x00,0x50,0x00,0x07,0x00,0x07,0x00,0x00,0x00,0x2e,0x00,0x00,0x00,
  2501. 0x2c,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x2a,0x00,0x00,0x00,0x2b,0x00,0x00,0x00,
  2502. 0x91,0x00,0x05,0x00,0x07,0x00,0x00,0x00,0x2f,0x00,0x00,0x00,0x25,0x00,0x00,0x00,
  2503. 0x2e,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x23,0x00,0x00,0x00,0x2f,0x00,0x00,0x00,
  2504. 0x3d,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0x31,0x00,0x00,0x00,
  2505. 0x3e,0x00,0x03,0x00,0x30,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0xfd,0x00,0x01,0x00,
  2506. 0x38,0x00,0x01,0x00,
  2507. };
  2508. /*
  2509. #version 460
  2510. layout(set = 1, binding = 0) uniform texture2D tex;
  2511. layout(set = 1, binding = 32) uniform sampler smp;
  2512. layout(location = 0) out vec4 frag_color;
  2513. layout(location = 0) in vec4 uv;
  2514. layout(location = 1) in vec4 color;
  2515. void main()
  2516. {
  2517. frag_color = texture(sampler2D(tex, smp), uv.xy) * color;
  2518. }
  2519. */
  2520. static const uint8_t _sgl_fs_bytecode_spirv_vk[792] = {
  2521. 0x03,0x02,0x23,0x07,0x00,0x04,0x01,0x00,0x0b,0x00,0x08,0x00,0x1d,0x00,0x00,0x00,
  2522. 0x00,0x00,0x00,0x00,0x11,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x06,0x00,
  2523. 0x01,0x00,0x00,0x00,0x47,0x4c,0x53,0x4c,0x2e,0x73,0x74,0x64,0x2e,0x34,0x35,0x30,
  2524. 0x00,0x00,0x00,0x00,0x0e,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2525. 0x0f,0x00,0x0a,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e,
  2526. 0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
  2527. 0x15,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x10,0x00,0x03,0x00,0x04,0x00,0x00,0x00,
  2528. 0x07,0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x02,0x00,0x00,0x00,0xcc,0x01,0x00,0x00,
  2529. 0x05,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x6d,0x61,0x69,0x6e,0x00,0x00,0x00,0x00,
  2530. 0x05,0x00,0x05,0x00,0x09,0x00,0x00,0x00,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
  2531. 0x6f,0x72,0x00,0x00,0x05,0x00,0x03,0x00,0x0c,0x00,0x00,0x00,0x74,0x65,0x78,0x00,
  2532. 0x05,0x00,0x03,0x00,0x10,0x00,0x00,0x00,0x73,0x6d,0x70,0x00,0x05,0x00,0x03,0x00,
  2533. 0x15,0x00,0x00,0x00,0x75,0x76,0x00,0x00,0x05,0x00,0x04,0x00,0x1a,0x00,0x00,0x00,
  2534. 0x63,0x6f,0x6c,0x6f,0x72,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x09,0x00,0x00,0x00,
  2535. 0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x0c,0x00,0x00,0x00,
  2536. 0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x0c,0x00,0x00,0x00,
  2537. 0x22,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x10,0x00,0x00,0x00,
  2538. 0x21,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x10,0x00,0x00,0x00,
  2539. 0x22,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x15,0x00,0x00,0x00,
  2540. 0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x04,0x00,0x1a,0x00,0x00,0x00,
  2541. 0x1e,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x13,0x00,0x02,0x00,0x02,0x00,0x00,0x00,
  2542. 0x21,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x16,0x00,0x03,0x00,
  2543. 0x06,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x17,0x00,0x04,0x00,0x07,0x00,0x00,0x00,
  2544. 0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x08,0x00,0x00,0x00,
  2545. 0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x08,0x00,0x00,0x00,
  2546. 0x09,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x19,0x00,0x09,0x00,0x0a,0x00,0x00,0x00,
  2547. 0x06,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2548. 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x04,0x00,
  2549. 0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,
  2550. 0x0b,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1a,0x00,0x02,0x00,
  2551. 0x0e,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2552. 0x0e,0x00,0x00,0x00,0x3b,0x00,0x04,0x00,0x0f,0x00,0x00,0x00,0x10,0x00,0x00,0x00,
  2553. 0x00,0x00,0x00,0x00,0x1b,0x00,0x03,0x00,0x12,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
  2554. 0x20,0x00,0x04,0x00,0x14,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x07,0x00,0x00,0x00,
  2555. 0x3b,0x00,0x04,0x00,0x14,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2556. 0x17,0x00,0x04,0x00,0x16,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
  2557. 0x3b,0x00,0x04,0x00,0x14,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
  2558. 0x36,0x00,0x05,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2559. 0x03,0x00,0x00,0x00,0xf8,0x00,0x02,0x00,0x05,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,
  2560. 0x0a,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x3d,0x00,0x04,0x00,
  2561. 0x0e,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x56,0x00,0x05,0x00,
  2562. 0x12,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x11,0x00,0x00,0x00,
  2563. 0x3d,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x17,0x00,0x00,0x00,0x15,0x00,0x00,0x00,
  2564. 0x4f,0x00,0x07,0x00,0x16,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x17,0x00,0x00,0x00,
  2565. 0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x57,0x00,0x05,0x00,
  2566. 0x07,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x18,0x00,0x00,0x00,
  2567. 0x3d,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x1a,0x00,0x00,0x00,
  2568. 0x85,0x00,0x05,0x00,0x07,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x19,0x00,0x00,0x00,
  2569. 0x1b,0x00,0x00,0x00,0x3e,0x00,0x03,0x00,0x09,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,
  2570. 0xfd,0x00,0x01,0x00,0x38,0x00,0x01,0x00,
  2571. };
  2572. #elif defined(SOKOL_DUMMY_BACKEND)
  2573. static const char* _sgl_vs_source_dummy = "";
  2574. static const char* _sgl_fs_source_dummy = "";
  2575. #else
  2576. #error "Please define one of SOKOL_GLCORE, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!"
  2577. #endif
  2578. // ████████ ██ ██ ██████ ███████ ███████
  2579. // ██ ██ ██ ██ ██ ██ ██
  2580. // ██ ████ ██████ █████ ███████
  2581. // ██ ██ ██ ██ ██
  2582. // ██ ██ ██ ███████ ███████
  2583. //
  2584. // >>types
  2585. typedef enum {
  2586. SGL_PRIMITIVETYPE_POINTS = 0,
  2587. SGL_PRIMITIVETYPE_LINES,
  2588. SGL_PRIMITIVETYPE_LINE_STRIP,
  2589. SGL_PRIMITIVETYPE_TRIANGLES,
  2590. SGL_PRIMITIVETYPE_TRIANGLE_STRIP,
  2591. SGL_PRIMITIVETYPE_QUADS,
  2592. SGL_NUM_PRIMITIVE_TYPES,
  2593. } _sgl_primitive_type_t;
  2594. typedef struct {
  2595. uint32_t id;
  2596. sg_resource_state state;
  2597. } _sgl_slot_t;
  2598. typedef struct {
  2599. int size;
  2600. int queue_top;
  2601. uint32_t* gen_ctrs;
  2602. int* free_queue;
  2603. } _sgl_pool_t;
  2604. typedef struct {
  2605. _sgl_slot_t slot;
  2606. sg_pipeline pip[SGL_NUM_PRIMITIVE_TYPES];
  2607. } _sgl_pipeline_t;
  2608. typedef struct {
  2609. _sgl_pool_t pool;
  2610. _sgl_pipeline_t* pips;
  2611. } _sgl_pipeline_pool_t;
  2612. typedef enum {
  2613. SGL_MATRIXMODE_MODELVIEW,
  2614. SGL_MATRIXMODE_PROJECTION,
  2615. SGL_MATRIXMODE_TEXTURE,
  2616. SGL_NUM_MATRIXMODES
  2617. } _sgl_matrix_mode_t;
  2618. typedef struct {
  2619. float pos[3];
  2620. float uv[2];
  2621. uint32_t rgba;
  2622. float psize;
  2623. } _sgl_vertex_t;
  2624. typedef struct {
  2625. float v[4][4];
  2626. } _sgl_matrix_t;
  2627. typedef struct {
  2628. _sgl_matrix_t mvp; /* model-view-projection matrix */
  2629. _sgl_matrix_t tm; /* texture matrix */
  2630. } _sgl_uniform_t;
  2631. typedef enum {
  2632. SGL_COMMAND_DRAW,
  2633. SGL_COMMAND_VIEWPORT,
  2634. SGL_COMMAND_SCISSOR_RECT,
  2635. } _sgl_command_type_t;
  2636. typedef struct {
  2637. sg_pipeline pip;
  2638. sg_view view;
  2639. sg_sampler smp;
  2640. int base_vertex;
  2641. int num_vertices;
  2642. int uniform_index;
  2643. } _sgl_draw_args_t;
  2644. typedef struct {
  2645. int x, y, w, h;
  2646. bool origin_top_left;
  2647. } _sgl_viewport_args_t;
  2648. typedef struct {
  2649. int x, y, w, h;
  2650. bool origin_top_left;
  2651. } _sgl_scissor_rect_args_t;
  2652. typedef union {
  2653. _sgl_draw_args_t draw;
  2654. _sgl_viewport_args_t viewport;
  2655. _sgl_scissor_rect_args_t scissor_rect;
  2656. } _sgl_args_t;
  2657. typedef struct {
  2658. _sgl_command_type_t cmd;
  2659. int layer_id;
  2660. _sgl_args_t args;
  2661. } _sgl_command_t;
  2662. #define _SGL_INVALID_SLOT_INDEX (0)
  2663. #define _SGL_MAX_STACK_DEPTH (64)
  2664. #define _SGL_DEFAULT_CONTEXT_POOL_SIZE (4)
  2665. #define _SGL_DEFAULT_PIPELINE_POOL_SIZE (64)
  2666. #define _SGL_DEFAULT_MAX_VERTICES (1<<16)
  2667. #define _SGL_DEFAULT_MAX_COMMANDS (1<<14)
  2668. #define _SGL_SLOT_SHIFT (16)
  2669. #define _SGL_MAX_POOL_SIZE (1<<_SGL_SLOT_SHIFT)
  2670. #define _SGL_SLOT_MASK (_SGL_MAX_POOL_SIZE-1)
  2671. typedef struct {
  2672. _sgl_slot_t slot;
  2673. sgl_context_desc_t desc;
  2674. uint32_t frame_id;
  2675. uint32_t update_frame_id;
  2676. struct {
  2677. int cap;
  2678. int next;
  2679. _sgl_vertex_t* ptr;
  2680. } vertices;
  2681. struct {
  2682. int cap;
  2683. int next;
  2684. _sgl_uniform_t* ptr;
  2685. } uniforms;
  2686. struct {
  2687. int cap;
  2688. int next;
  2689. _sgl_command_t* ptr;
  2690. } commands;
  2691. /* state tracking */
  2692. int base_vertex;
  2693. int quad_vtx_count; /* number of times vtx function has been called, used for non-triangle primitives */
  2694. sgl_error_t error;
  2695. bool in_begin;
  2696. int layer_id;
  2697. float u, v;
  2698. uint32_t rgba;
  2699. float point_size;
  2700. _sgl_primitive_type_t cur_prim_type;
  2701. sg_view cur_view;
  2702. sg_sampler cur_smp;
  2703. bool texturing_enabled;
  2704. bool matrix_dirty; /* reset in sgl_end(), set in any of the matrix stack functions */
  2705. /* sokol-gfx resources */
  2706. sg_buffer vbuf;
  2707. sgl_pipeline def_pip;
  2708. sg_bindings bind;
  2709. /* pipeline stack */
  2710. int pip_tos;
  2711. sgl_pipeline pip_stack[_SGL_MAX_STACK_DEPTH];
  2712. /* matrix stacks */
  2713. _sgl_matrix_mode_t cur_matrix_mode;
  2714. int matrix_tos[SGL_NUM_MATRIXMODES];
  2715. _sgl_matrix_t matrix_stack[SGL_NUM_MATRIXMODES][_SGL_MAX_STACK_DEPTH];
  2716. } _sgl_context_t;
  2717. typedef struct {
  2718. _sgl_pool_t pool;
  2719. _sgl_context_t* contexts;
  2720. } _sgl_context_pool_t;
  2721. typedef struct {
  2722. uint32_t init_cookie;
  2723. sgl_desc_t desc;
  2724. sg_image def_img; // a default white texture
  2725. sg_view def_view; // ...and the texture view for the default image
  2726. sg_sampler def_smp; // a default sampler
  2727. sg_shader shd; // same shader for all contexts
  2728. sgl_context def_ctx_id;
  2729. sgl_context cur_ctx_id;
  2730. _sgl_context_t* cur_ctx; // may be 0!
  2731. _sgl_pipeline_pool_t pip_pool;
  2732. _sgl_context_pool_t context_pool;
  2733. } _sgl_t;
  2734. static _sgl_t _sgl;
  2735. // ██ ██████ ██████ ██████ ██ ███ ██ ██████
  2736. // ██ ██ ██ ██ ██ ██ ████ ██ ██
  2737. // ██ ██ ██ ██ ███ ██ ███ ██ ██ ██ ██ ██ ███
  2738. // ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
  2739. // ███████ ██████ ██████ ██████ ██ ██ ████ ██████
  2740. //
  2741. // >>logging
  2742. #if defined(SOKOL_DEBUG)
  2743. #define _SGL_LOGITEM_XMACRO(item,msg) #item ": " msg,
  2744. static const char* _sgl_log_messages[] = {
  2745. _SGL_LOG_ITEMS
  2746. };
  2747. #undef _SGL_LOGITEM_XMACRO
  2748. #endif // SOKOL_DEBUG
  2749. #define _SGL_PANIC(code) _sgl_log(SGL_LOGITEM_ ##code, 0, __LINE__)
  2750. #define _SGL_ERROR(code) _sgl_log(SGL_LOGITEM_ ##code, 1, __LINE__)
  2751. #define _SGL_WARN(code) _sgl_log(SGL_LOGITEM_ ##code, 2, __LINE__)
  2752. #define _SGL_INFO(code) _sgl_log(SGL_LOGITEM_ ##code, 3, __LINE__)
  2753. static void _sgl_log(sgl_log_item_t log_item, uint32_t log_level, uint32_t line_nr) {
  2754. if (_sgl.desc.logger.func) {
  2755. #if defined(SOKOL_DEBUG)
  2756. const char* filename = __FILE__;
  2757. const char* message = _sgl_log_messages[log_item];
  2758. #else
  2759. const char* filename = 0;
  2760. const char* message = 0;
  2761. #endif
  2762. _sgl.desc.logger.func("sgl", log_level, (uint32_t)log_item, message, line_nr, filename, _sgl.desc.logger.user_data);
  2763. } else {
  2764. // for log level PANIC it would be 'undefined behaviour' to continue
  2765. if (log_level == 0) {
  2766. abort();
  2767. }
  2768. }
  2769. }
  2770. // ███ ███ ███████ ███ ███ ██████ ██████ ██ ██
  2771. // ████ ████ ██ ████ ████ ██ ██ ██ ██ ██ ██
  2772. // ██ ████ ██ █████ ██ ████ ██ ██ ██ ██████ ████
  2773. // ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
  2774. // ██ ██ ███████ ██ ██ ██████ ██ ██ ██
  2775. //
  2776. // >>memory
  2777. static void _sgl_clear(void* ptr, size_t size) {
  2778. SOKOL_ASSERT(ptr && (size > 0));
  2779. memset(ptr, 0, size);
  2780. }
  2781. static void* _sgl_malloc(size_t size) {
  2782. SOKOL_ASSERT(size > 0);
  2783. void* ptr;
  2784. if (_sgl.desc.allocator.alloc_fn) {
  2785. ptr = _sgl.desc.allocator.alloc_fn(size, _sgl.desc.allocator.user_data);
  2786. } else {
  2787. ptr = malloc(size);
  2788. }
  2789. if (0 == ptr) {
  2790. _SGL_PANIC(MALLOC_FAILED);
  2791. }
  2792. return ptr;
  2793. }
  2794. static void* _sgl_malloc_clear(size_t size) {
  2795. void* ptr = _sgl_malloc(size);
  2796. _sgl_clear(ptr, size);
  2797. return ptr;
  2798. }
  2799. static void _sgl_free(void* ptr) {
  2800. if (_sgl.desc.allocator.free_fn) {
  2801. _sgl.desc.allocator.free_fn(ptr, _sgl.desc.allocator.user_data);
  2802. } else {
  2803. free(ptr);
  2804. }
  2805. }
  2806. // ██████ ██████ ██████ ██
  2807. // ██ ██ ██ ██ ██ ██ ██
  2808. // ██████ ██ ██ ██ ██ ██
  2809. // ██ ██ ██ ██ ██ ██
  2810. // ██ ██████ ██████ ███████
  2811. //
  2812. // >>pool
  2813. static void _sgl_init_pool(_sgl_pool_t* pool, int num) {
  2814. SOKOL_ASSERT(pool && (num >= 1));
  2815. /* slot 0 is reserved for the 'invalid id', so bump the pool size by 1 */
  2816. pool->size = num + 1;
  2817. pool->queue_top = 0;
  2818. /* generation counters indexable by pool slot index, slot 0 is reserved */
  2819. size_t gen_ctrs_size = sizeof(uint32_t) * (size_t)pool->size;
  2820. pool->gen_ctrs = (uint32_t*) _sgl_malloc_clear(gen_ctrs_size);
  2821. /* it's not a bug to only reserve 'num' here */
  2822. pool->free_queue = (int*) _sgl_malloc_clear(sizeof(int) * (size_t)num);
  2823. /* never allocate the zero-th pool item since the invalid id is 0 */
  2824. for (int i = pool->size-1; i >= 1; i--) {
  2825. pool->free_queue[pool->queue_top++] = i;
  2826. }
  2827. }
  2828. static void _sgl_discard_pool(_sgl_pool_t* pool) {
  2829. SOKOL_ASSERT(pool);
  2830. SOKOL_ASSERT(pool->free_queue);
  2831. _sgl_free(pool->free_queue);
  2832. pool->free_queue = 0;
  2833. SOKOL_ASSERT(pool->gen_ctrs);
  2834. _sgl_free(pool->gen_ctrs);
  2835. pool->gen_ctrs = 0;
  2836. pool->size = 0;
  2837. pool->queue_top = 0;
  2838. }
  2839. static int _sgl_pool_alloc_index(_sgl_pool_t* pool) {
  2840. SOKOL_ASSERT(pool);
  2841. SOKOL_ASSERT(pool->free_queue);
  2842. if (pool->queue_top > 0) {
  2843. int slot_index = pool->free_queue[--pool->queue_top];
  2844. SOKOL_ASSERT((slot_index > 0) && (slot_index < pool->size));
  2845. return slot_index;
  2846. } else {
  2847. // pool exhausted
  2848. return _SGL_INVALID_SLOT_INDEX;
  2849. }
  2850. }
  2851. static void _sgl_pool_free_index(_sgl_pool_t* pool, int slot_index) {
  2852. SOKOL_ASSERT((slot_index > _SGL_INVALID_SLOT_INDEX) && (slot_index < pool->size));
  2853. SOKOL_ASSERT(pool);
  2854. SOKOL_ASSERT(pool->free_queue);
  2855. SOKOL_ASSERT(pool->queue_top < pool->size);
  2856. #ifdef SOKOL_DEBUG
  2857. /* debug check against double-free */
  2858. for (int i = 0; i < pool->queue_top; i++) {
  2859. SOKOL_ASSERT(pool->free_queue[i] != slot_index);
  2860. }
  2861. #endif
  2862. pool->free_queue[pool->queue_top++] = slot_index;
  2863. SOKOL_ASSERT(pool->queue_top <= (pool->size-1));
  2864. }
  2865. /* allocate the slot at slot_index:
  2866. - bump the slot's generation counter
  2867. - create a resource id from the generation counter and slot index
  2868. - set the slot's id to this id
  2869. - set the slot's state to ALLOC
  2870. - return the resource id
  2871. */
  2872. static uint32_t _sgl_slot_alloc(_sgl_pool_t* pool, _sgl_slot_t* slot, int slot_index) {
  2873. /* FIXME: add handling for an overflowing generation counter,
  2874. for now, just overflow (another option is to disable
  2875. the slot)
  2876. */
  2877. SOKOL_ASSERT(pool && pool->gen_ctrs);
  2878. SOKOL_ASSERT((slot_index > _SGL_INVALID_SLOT_INDEX) && (slot_index < pool->size));
  2879. SOKOL_ASSERT((slot->state == SG_RESOURCESTATE_INITIAL) && (slot->id == SG_INVALID_ID));
  2880. uint32_t ctr = ++pool->gen_ctrs[slot_index];
  2881. slot->id = (ctr<<_SGL_SLOT_SHIFT)|(slot_index & _SGL_SLOT_MASK);
  2882. slot->state = SG_RESOURCESTATE_ALLOC;
  2883. return slot->id;
  2884. }
  2885. /* extract slot index from id */
  2886. static int _sgl_slot_index(uint32_t id) {
  2887. int slot_index = (int) (id & _SGL_SLOT_MASK);
  2888. SOKOL_ASSERT(_SGL_INVALID_SLOT_INDEX != slot_index);
  2889. return slot_index;
  2890. }
  2891. // ██████ ██ ██████ ███████ ██ ██ ███ ██ ███████ ███████
  2892. // ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██
  2893. // ██████ ██ ██████ █████ ██ ██ ██ ██ ██ █████ ███████
  2894. // ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
  2895. // ██ ██ ██ ███████ ███████ ██ ██ ████ ███████ ███████
  2896. //
  2897. // >>pipelines
  2898. static void _sgl_reset_pipeline(_sgl_pipeline_t* pip) {
  2899. SOKOL_ASSERT(pip);
  2900. _sgl_clear(pip, sizeof(_sgl_pipeline_t));
  2901. }
  2902. static void _sgl_setup_pipeline_pool(int pool_size) {
  2903. /* note: the pools here will have an additional item, since slot 0 is reserved */
  2904. SOKOL_ASSERT((pool_size > 0) && (pool_size < _SGL_MAX_POOL_SIZE));
  2905. _sgl_init_pool(&_sgl.pip_pool.pool, pool_size);
  2906. size_t pool_byte_size = sizeof(_sgl_pipeline_t) * (size_t)_sgl.pip_pool.pool.size;
  2907. _sgl.pip_pool.pips = (_sgl_pipeline_t*) _sgl_malloc_clear(pool_byte_size);
  2908. }
  2909. static void _sgl_discard_pipeline_pool(void) {
  2910. SOKOL_ASSERT(0 != _sgl.pip_pool.pips);
  2911. _sgl_free(_sgl.pip_pool.pips); _sgl.pip_pool.pips = 0;
  2912. _sgl_discard_pool(&_sgl.pip_pool.pool);
  2913. }
  2914. /* get pipeline pointer without id-check */
  2915. static _sgl_pipeline_t* _sgl_pipeline_at(uint32_t pip_id) {
  2916. SOKOL_ASSERT(SG_INVALID_ID != pip_id);
  2917. int slot_index = _sgl_slot_index(pip_id);
  2918. SOKOL_ASSERT((slot_index > _SGL_INVALID_SLOT_INDEX) && (slot_index < _sgl.pip_pool.pool.size));
  2919. return &_sgl.pip_pool.pips[slot_index];
  2920. }
  2921. /* get pipeline pointer with id-check, returns 0 if no match */
  2922. static _sgl_pipeline_t* _sgl_lookup_pipeline(uint32_t pip_id) {
  2923. if (SG_INVALID_ID != pip_id) {
  2924. _sgl_pipeline_t* pip = _sgl_pipeline_at(pip_id);
  2925. if (pip->slot.id == pip_id) {
  2926. return pip;
  2927. }
  2928. }
  2929. return 0;
  2930. }
  2931. /* make pipeline id from uint32_t id */
  2932. static sgl_pipeline _sgl_make_pip_id(uint32_t pip_id) {
  2933. sgl_pipeline pip = { pip_id };
  2934. return pip;
  2935. }
  2936. static sgl_pipeline _sgl_alloc_pipeline(void) {
  2937. sgl_pipeline res;
  2938. int slot_index = _sgl_pool_alloc_index(&_sgl.pip_pool.pool);
  2939. if (_SGL_INVALID_SLOT_INDEX != slot_index) {
  2940. res = _sgl_make_pip_id(_sgl_slot_alloc(&_sgl.pip_pool.pool, &_sgl.pip_pool.pips[slot_index].slot, slot_index));
  2941. } else {
  2942. /* pool is exhausted */
  2943. res = _sgl_make_pip_id(SG_INVALID_ID);
  2944. }
  2945. return res;
  2946. }
  2947. static void _sgl_init_pipeline(sgl_pipeline pip_id, const sg_pipeline_desc* in_desc, const sgl_context_desc_t* ctx_desc) {
  2948. SOKOL_ASSERT((pip_id.id != SG_INVALID_ID) && in_desc && ctx_desc);
  2949. /* create a new desc with 'patched' shader and pixel format state */
  2950. sg_pipeline_desc desc = *in_desc;
  2951. desc.layout.buffers[0].stride = sizeof(_sgl_vertex_t);
  2952. {
  2953. sg_vertex_attr_state* pos = &desc.layout.attrs[0];
  2954. pos->offset = offsetof(_sgl_vertex_t, pos);
  2955. pos->format = SG_VERTEXFORMAT_FLOAT3;
  2956. }
  2957. {
  2958. sg_vertex_attr_state* uv = &desc.layout.attrs[1];
  2959. uv->offset = offsetof(_sgl_vertex_t, uv);
  2960. uv->format = SG_VERTEXFORMAT_FLOAT2;
  2961. }
  2962. {
  2963. sg_vertex_attr_state* rgba = &desc.layout.attrs[2];
  2964. rgba->offset = offsetof(_sgl_vertex_t, rgba);
  2965. rgba->format = SG_VERTEXFORMAT_UBYTE4N;
  2966. }
  2967. {
  2968. sg_vertex_attr_state* psize = &desc.layout.attrs[3];
  2969. psize->offset = offsetof(_sgl_vertex_t, psize);
  2970. psize->format = SG_VERTEXFORMAT_FLOAT;
  2971. }
  2972. if (in_desc->shader.id == SG_INVALID_ID) {
  2973. desc.shader = _sgl.shd;
  2974. }
  2975. desc.index_type = SG_INDEXTYPE_NONE;
  2976. desc.sample_count = ctx_desc->sample_count;
  2977. if (desc.face_winding == _SG_FACEWINDING_DEFAULT) {
  2978. desc.face_winding = _sgl.desc.face_winding;
  2979. }
  2980. desc.depth.pixel_format = ctx_desc->depth_format;
  2981. if (ctx_desc->depth_format == SG_PIXELFORMAT_NONE) {
  2982. desc.depth.write_enabled = false;
  2983. }
  2984. desc.colors[0].pixel_format = ctx_desc->color_format;
  2985. if (desc.colors[0].write_mask == _SG_COLORMASK_DEFAULT) {
  2986. desc.colors[0].write_mask = SG_COLORMASK_RGB;
  2987. }
  2988. _sgl_pipeline_t* pip = _sgl_lookup_pipeline(pip_id.id);
  2989. SOKOL_ASSERT(pip && (pip->slot.state == SG_RESOURCESTATE_ALLOC));
  2990. pip->slot.state = SG_RESOURCESTATE_VALID;
  2991. for (int i = 0; i < SGL_NUM_PRIMITIVE_TYPES; i++) {
  2992. switch (i) {
  2993. case SGL_PRIMITIVETYPE_POINTS:
  2994. desc.primitive_type = SG_PRIMITIVETYPE_POINTS;
  2995. break;
  2996. case SGL_PRIMITIVETYPE_LINES:
  2997. desc.primitive_type = SG_PRIMITIVETYPE_LINES;
  2998. break;
  2999. case SGL_PRIMITIVETYPE_LINE_STRIP:
  3000. desc.primitive_type = SG_PRIMITIVETYPE_LINE_STRIP;
  3001. break;
  3002. case SGL_PRIMITIVETYPE_TRIANGLES:
  3003. desc.primitive_type = SG_PRIMITIVETYPE_TRIANGLES;
  3004. break;
  3005. case SGL_PRIMITIVETYPE_TRIANGLE_STRIP:
  3006. case SGL_PRIMITIVETYPE_QUADS:
  3007. desc.primitive_type = SG_PRIMITIVETYPE_TRIANGLE_STRIP;
  3008. break;
  3009. }
  3010. if (SGL_PRIMITIVETYPE_QUADS == i) {
  3011. /* quads are emulated via triangles, use the same pipeline object */
  3012. pip->pip[i] = pip->pip[SGL_PRIMITIVETYPE_TRIANGLES];
  3013. } else {
  3014. pip->pip[i] = sg_make_pipeline(&desc);
  3015. if (pip->pip[i].id == SG_INVALID_ID) {
  3016. _SGL_ERROR(MAKE_PIPELINE_FAILED);
  3017. pip->slot.state = SG_RESOURCESTATE_FAILED;
  3018. }
  3019. }
  3020. }
  3021. }
  3022. static sgl_pipeline _sgl_make_pipeline(const sg_pipeline_desc* desc, const sgl_context_desc_t* ctx_desc) {
  3023. SOKOL_ASSERT(desc && ctx_desc);
  3024. sgl_pipeline pip_id = _sgl_alloc_pipeline();
  3025. if (pip_id.id != SG_INVALID_ID) {
  3026. _sgl_init_pipeline(pip_id, desc, ctx_desc);
  3027. } else {
  3028. _SGL_ERROR(PIPELINE_POOL_EXHAUSTED);
  3029. }
  3030. return pip_id;
  3031. }
  3032. static void _sgl_destroy_pipeline(sgl_pipeline pip_id) {
  3033. _sgl_pipeline_t* pip = _sgl_lookup_pipeline(pip_id.id);
  3034. if (pip) {
  3035. sg_push_debug_group("sokol-gl");
  3036. for (int i = 0; i < SGL_NUM_PRIMITIVE_TYPES; i++) {
  3037. if (i != SGL_PRIMITIVETYPE_QUADS) {
  3038. sg_destroy_pipeline(pip->pip[i]);
  3039. }
  3040. }
  3041. sg_pop_debug_group();
  3042. _sgl_reset_pipeline(pip);
  3043. _sgl_pool_free_index(&_sgl.pip_pool.pool, _sgl_slot_index(pip_id.id));
  3044. }
  3045. }
  3046. static sg_pipeline _sgl_get_pipeline(sgl_pipeline pip_id, _sgl_primitive_type_t prim_type) {
  3047. _sgl_pipeline_t* pip = _sgl_lookup_pipeline(pip_id.id);
  3048. if (pip) {
  3049. return pip->pip[prim_type];
  3050. } else {
  3051. sg_pipeline dummy_id = { SG_INVALID_ID };
  3052. return dummy_id;
  3053. }
  3054. }
  3055. // ██████ ██████ ███ ██ ████████ ███████ ██ ██ ████████ ███████
  3056. // ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██
  3057. // ██ ██ ██ ██ ██ ██ ██ █████ ███ ██ ███████
  3058. // ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
  3059. // ██████ ██████ ██ ████ ██ ███████ ██ ██ ██ ███████
  3060. //
  3061. // >>contexts
  3062. static void _sgl_reset_context(_sgl_context_t* ctx) {
  3063. SOKOL_ASSERT(ctx);
  3064. SOKOL_ASSERT(0 == ctx->vertices.ptr);
  3065. SOKOL_ASSERT(0 == ctx->uniforms.ptr);
  3066. SOKOL_ASSERT(0 == ctx->commands.ptr);
  3067. _sgl_clear(ctx, sizeof(_sgl_context_t));
  3068. }
  3069. static void _sgl_setup_context_pool(int pool_size) {
  3070. /* note: the pools here will have an additional item, since slot 0 is reserved */
  3071. SOKOL_ASSERT((pool_size > 0) && (pool_size < _SGL_MAX_POOL_SIZE));
  3072. _sgl_init_pool(&_sgl.context_pool.pool, pool_size);
  3073. size_t pool_byte_size = sizeof(_sgl_context_t) * (size_t)_sgl.context_pool.pool.size;
  3074. _sgl.context_pool.contexts = (_sgl_context_t*) _sgl_malloc_clear(pool_byte_size);
  3075. }
  3076. static void _sgl_discard_context_pool(void) {
  3077. SOKOL_ASSERT(0 != _sgl.context_pool.contexts);
  3078. _sgl_free(_sgl.context_pool.contexts); _sgl.context_pool.contexts = 0;
  3079. _sgl_discard_pool(&_sgl.context_pool.pool);
  3080. }
  3081. // get context pointer without id-check
  3082. static _sgl_context_t* _sgl_context_at(uint32_t ctx_id) {
  3083. SOKOL_ASSERT(SG_INVALID_ID != ctx_id);
  3084. int slot_index = _sgl_slot_index(ctx_id);
  3085. SOKOL_ASSERT((slot_index > _SGL_INVALID_SLOT_INDEX) && (slot_index < _sgl.context_pool.pool.size));
  3086. return &_sgl.context_pool.contexts[slot_index];
  3087. }
  3088. // get context pointer with id-check, returns 0 if no match
  3089. static _sgl_context_t* _sgl_lookup_context(uint32_t ctx_id) {
  3090. if (SG_INVALID_ID != ctx_id) {
  3091. _sgl_context_t* ctx = _sgl_context_at(ctx_id);
  3092. if (ctx->slot.id == ctx_id) {
  3093. return ctx;
  3094. }
  3095. }
  3096. return 0;
  3097. }
  3098. // make context id from uint32_t id
  3099. static sgl_context _sgl_make_ctx_id(uint32_t ctx_id) {
  3100. sgl_context ctx = { ctx_id };
  3101. return ctx;
  3102. }
  3103. static sgl_context _sgl_alloc_context(void) {
  3104. sgl_context res;
  3105. int slot_index = _sgl_pool_alloc_index(&_sgl.context_pool.pool);
  3106. if (_SGL_INVALID_SLOT_INDEX != slot_index) {
  3107. res = _sgl_make_ctx_id(_sgl_slot_alloc(&_sgl.context_pool.pool, &_sgl.context_pool.contexts[slot_index].slot, slot_index));
  3108. } else {
  3109. // pool is exhausted
  3110. res = _sgl_make_ctx_id(SG_INVALID_ID);
  3111. }
  3112. return res;
  3113. }
  3114. // return sgl_context_desc_t with patched defaults
  3115. static sgl_context_desc_t _sgl_context_desc_defaults(const sgl_context_desc_t* desc) {
  3116. sgl_context_desc_t res = *desc;
  3117. res.max_vertices = _sgl_def(desc->max_vertices, _SGL_DEFAULT_MAX_VERTICES);
  3118. res.max_commands = _sgl_def(desc->max_commands, _SGL_DEFAULT_MAX_COMMANDS);
  3119. return res;
  3120. }
  3121. static void _sgl_identity(_sgl_matrix_t*);
  3122. static sg_commit_listener _sgl_make_commit_listener(_sgl_context_t* ctx);
  3123. static void _sgl_init_context(sgl_context ctx_id, const sgl_context_desc_t* in_desc) {
  3124. SOKOL_ASSERT((ctx_id.id != SG_INVALID_ID) && in_desc);
  3125. _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id);
  3126. SOKOL_ASSERT(ctx);
  3127. ctx->desc = _sgl_context_desc_defaults(in_desc);
  3128. // NOTE: frame_id must be non-zero, so that updates trigger in first frame
  3129. ctx->frame_id = 1;
  3130. ctx->cur_view = _sgl.def_view;
  3131. ctx->cur_smp = _sgl.def_smp;
  3132. // allocate buffers and pools
  3133. ctx->vertices.cap = ctx->desc.max_vertices;
  3134. ctx->commands.cap = ctx->uniforms.cap = ctx->desc.max_commands;
  3135. ctx->vertices.ptr = (_sgl_vertex_t*) _sgl_malloc((size_t)ctx->vertices.cap * sizeof(_sgl_vertex_t));
  3136. ctx->uniforms.ptr = (_sgl_uniform_t*) _sgl_malloc((size_t)ctx->uniforms.cap * sizeof(_sgl_uniform_t));
  3137. ctx->commands.ptr = (_sgl_command_t*) _sgl_malloc((size_t)ctx->commands.cap * sizeof(_sgl_command_t));
  3138. // create sokol-gfx resource objects
  3139. sg_push_debug_group("sokol-gl");
  3140. sg_buffer_desc vbuf_desc;
  3141. _sgl_clear(&vbuf_desc, sizeof(vbuf_desc));
  3142. vbuf_desc.size = (size_t)ctx->vertices.cap * sizeof(_sgl_vertex_t);
  3143. vbuf_desc.usage.vertex_buffer = true;
  3144. vbuf_desc.usage.stream_update = true;
  3145. vbuf_desc.label = "sgl-vertex-buffer";
  3146. ctx->vbuf = sg_make_buffer(&vbuf_desc);
  3147. SOKOL_ASSERT(SG_INVALID_ID != ctx->vbuf.id);
  3148. ctx->bind.vertex_buffers[0] = ctx->vbuf;
  3149. sg_pipeline_desc def_pip_desc;
  3150. _sgl_clear(&def_pip_desc, sizeof(def_pip_desc));
  3151. def_pip_desc.depth.write_enabled = true;
  3152. ctx->def_pip = _sgl_make_pipeline(&def_pip_desc, &ctx->desc);
  3153. if (!sg_add_commit_listener(_sgl_make_commit_listener(ctx))) {
  3154. _SGL_ERROR(ADD_COMMIT_LISTENER_FAILED);
  3155. }
  3156. sg_pop_debug_group();
  3157. // default state
  3158. ctx->rgba = 0xFFFFFFFF;
  3159. ctx->point_size = 1.0f;
  3160. for (int i = 0; i < SGL_NUM_MATRIXMODES; i++) {
  3161. _sgl_identity(&ctx->matrix_stack[i][0]);
  3162. }
  3163. ctx->pip_stack[0] = ctx->def_pip;
  3164. ctx->matrix_dirty = true;
  3165. }
  3166. static sgl_context _sgl_make_context(const sgl_context_desc_t* desc) {
  3167. SOKOL_ASSERT(desc);
  3168. sgl_context ctx_id = _sgl_alloc_context();
  3169. if (ctx_id.id != SG_INVALID_ID) {
  3170. _sgl_init_context(ctx_id, desc);
  3171. } else {
  3172. _SGL_ERROR(CONTEXT_POOL_EXHAUSTED);
  3173. }
  3174. return ctx_id;
  3175. }
  3176. static void _sgl_destroy_context(sgl_context ctx_id) {
  3177. _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id);
  3178. if (ctx) {
  3179. SOKOL_ASSERT(ctx->vertices.ptr);
  3180. SOKOL_ASSERT(ctx->uniforms.ptr);
  3181. SOKOL_ASSERT(ctx->commands.ptr);
  3182. _sgl_free(ctx->vertices.ptr);
  3183. _sgl_free(ctx->uniforms.ptr);
  3184. _sgl_free(ctx->commands.ptr);
  3185. ctx->vertices.ptr = 0;
  3186. ctx->uniforms.ptr = 0;
  3187. ctx->commands.ptr = 0;
  3188. sg_push_debug_group("sokol-gl");
  3189. sg_destroy_buffer(ctx->vbuf);
  3190. _sgl_destroy_pipeline(ctx->def_pip);
  3191. sg_remove_commit_listener(_sgl_make_commit_listener(ctx));
  3192. sg_pop_debug_group();
  3193. _sgl_reset_context(ctx);
  3194. _sgl_pool_free_index(&_sgl.context_pool.pool, _sgl_slot_index(ctx_id.id));
  3195. }
  3196. }
  3197. // ███ ███ ██ ███████ ██████
  3198. // ████ ████ ██ ██ ██
  3199. // ██ ████ ██ ██ ███████ ██
  3200. // ██ ██ ██ ██ ██ ██
  3201. // ██ ██ ██ ███████ ██████
  3202. //
  3203. // >>misc
  3204. static sgl_error_t _sgl_error_defaults(void) {
  3205. sgl_error_t defaults;
  3206. _sgl_clear(&defaults, sizeof(defaults));
  3207. return defaults;
  3208. }
  3209. static int _sgl_num_vertices(_sgl_context_t* ctx) {
  3210. return ctx->vertices.next;
  3211. }
  3212. static int _sgl_num_commands(_sgl_context_t* ctx) {
  3213. return ctx->commands.next;
  3214. }
  3215. static void _sgl_begin(_sgl_context_t* ctx, _sgl_primitive_type_t mode) {
  3216. ctx->in_begin = true;
  3217. ctx->base_vertex = ctx->vertices.next;
  3218. ctx->quad_vtx_count = 0;
  3219. ctx->cur_prim_type = mode;
  3220. }
  3221. static void _sgl_rewind(_sgl_context_t* ctx) {
  3222. ctx->frame_id++;
  3223. ctx->vertices.next = 0;
  3224. ctx->uniforms.next = 0;
  3225. ctx->commands.next = 0;
  3226. ctx->base_vertex = 0;
  3227. ctx->error = _sgl_error_defaults();
  3228. ctx->layer_id = 0;
  3229. ctx->matrix_dirty = true;
  3230. }
  3231. // called from inside sokol-gfx sg_commit()
  3232. static void _sgl_commit_listener(void* userdata) {
  3233. _sgl_context_t* ctx = _sgl_lookup_context((uint32_t)(uintptr_t)userdata);
  3234. if (ctx) {
  3235. _sgl_rewind(ctx);
  3236. }
  3237. }
  3238. static sg_commit_listener _sgl_make_commit_listener(_sgl_context_t* ctx) {
  3239. sg_commit_listener listener = { _sgl_commit_listener, (void*)(uintptr_t)(ctx->slot.id) };
  3240. return listener;
  3241. }
  3242. static _sgl_vertex_t* _sgl_next_vertex(_sgl_context_t* ctx) {
  3243. if (ctx->vertices.next < ctx->vertices.cap) {
  3244. return &ctx->vertices.ptr[ctx->vertices.next++];
  3245. } else {
  3246. ctx->error.vertices_full = true;
  3247. ctx->error.any = true;
  3248. return 0;
  3249. }
  3250. }
  3251. static _sgl_uniform_t* _sgl_next_uniform(_sgl_context_t* ctx) {
  3252. if (ctx->uniforms.next < ctx->uniforms.cap) {
  3253. return &ctx->uniforms.ptr[ctx->uniforms.next++];
  3254. } else {
  3255. ctx->error.uniforms_full = true;
  3256. ctx->error.any = true;
  3257. return 0;
  3258. }
  3259. }
  3260. static _sgl_command_t* _sgl_cur_command(_sgl_context_t* ctx) {
  3261. if (ctx->commands.next > 0) {
  3262. return &ctx->commands.ptr[ctx->commands.next - 1];
  3263. } else {
  3264. return 0;
  3265. }
  3266. }
  3267. static _sgl_command_t* _sgl_next_command(_sgl_context_t* ctx) {
  3268. if (ctx->commands.next < ctx->commands.cap) {
  3269. return &ctx->commands.ptr[ctx->commands.next++];
  3270. } else {
  3271. ctx->error.commands_full = true;
  3272. ctx->error.any = true;
  3273. return 0;
  3274. }
  3275. }
  3276. static uint32_t _sgl_pack_rgbab(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
  3277. return (uint32_t)(((uint32_t)a<<24)|((uint32_t)b<<16)|((uint32_t)g<<8)|r);
  3278. }
  3279. static float _sgl_clamp(float v, float lo, float hi) {
  3280. if (v < lo) return lo;
  3281. else if (v > hi) return hi;
  3282. else return v;
  3283. }
  3284. static uint32_t _sgl_pack_rgbaf(float r, float g, float b, float a) {
  3285. uint8_t r_u8 = (uint8_t) (_sgl_clamp(r, 0.0f, 1.0f) * 255.0f);
  3286. uint8_t g_u8 = (uint8_t) (_sgl_clamp(g, 0.0f, 1.0f) * 255.0f);
  3287. uint8_t b_u8 = (uint8_t) (_sgl_clamp(b, 0.0f, 1.0f) * 255.0f);
  3288. uint8_t a_u8 = (uint8_t) (_sgl_clamp(a, 0.0f, 1.0f) * 255.0f);
  3289. return _sgl_pack_rgbab(r_u8, g_u8, b_u8, a_u8);
  3290. }
  3291. static void _sgl_vtx(_sgl_context_t* ctx, float x, float y, float z, float u, float v, uint32_t rgba) {
  3292. SOKOL_ASSERT(ctx->in_begin);
  3293. _sgl_vertex_t* vtx;
  3294. /* handle non-native primitive types */
  3295. if ((ctx->cur_prim_type == SGL_PRIMITIVETYPE_QUADS) && ((ctx->quad_vtx_count & 3) == 3)) {
  3296. /* for quads, before writing the last quad vertex, reuse
  3297. the first and third vertex to start the second triangle in the quad
  3298. */
  3299. vtx = _sgl_next_vertex(ctx);
  3300. if (vtx) { *vtx = *(vtx - 3); }
  3301. vtx = _sgl_next_vertex(ctx);
  3302. if (vtx) { *vtx = *(vtx - 2); }
  3303. }
  3304. vtx = _sgl_next_vertex(ctx);
  3305. if (vtx) {
  3306. vtx->pos[0] = x; vtx->pos[1] = y; vtx->pos[2] = z;
  3307. vtx->uv[0] = u; vtx->uv[1] = v;
  3308. vtx->rgba = rgba;
  3309. vtx->psize = ctx->point_size;
  3310. }
  3311. ctx->quad_vtx_count++;
  3312. }
  3313. static void _sgl_identity(_sgl_matrix_t* m) {
  3314. for (int c = 0; c < 4; c++) {
  3315. for (int r = 0; r < 4; r++) {
  3316. m->v[c][r] = (r == c) ? 1.0f : 0.0f;
  3317. }
  3318. }
  3319. }
  3320. static void _sgl_transpose(_sgl_matrix_t* dst, const _sgl_matrix_t* m) {
  3321. SOKOL_ASSERT(dst != m);
  3322. for (int c = 0; c < 4; c++) {
  3323. for (int r = 0; r < 4; r++) {
  3324. dst->v[r][c] = m->v[c][r];
  3325. }
  3326. }
  3327. }
  3328. /* _sgl_rotate, _sgl_frustum, _sgl_ortho from MESA m_matric.c */
  3329. static void _sgl_matmul4(_sgl_matrix_t* p, const _sgl_matrix_t* a, const _sgl_matrix_t* b) {
  3330. for (int r = 0; r < 4; r++) {
  3331. float ai0=a->v[0][r], ai1=a->v[1][r], ai2=a->v[2][r], ai3=a->v[3][r];
  3332. p->v[0][r] = ai0*b->v[0][0] + ai1*b->v[0][1] + ai2*b->v[0][2] + ai3*b->v[0][3];
  3333. p->v[1][r] = ai0*b->v[1][0] + ai1*b->v[1][1] + ai2*b->v[1][2] + ai3*b->v[1][3];
  3334. p->v[2][r] = ai0*b->v[2][0] + ai1*b->v[2][1] + ai2*b->v[2][2] + ai3*b->v[2][3];
  3335. p->v[3][r] = ai0*b->v[3][0] + ai1*b->v[3][1] + ai2*b->v[3][2] + ai3*b->v[3][3];
  3336. }
  3337. }
  3338. static void _sgl_mul(_sgl_matrix_t* dst, const _sgl_matrix_t* m) {
  3339. _sgl_matmul4(dst, dst, m);
  3340. }
  3341. static void _sgl_rotate(_sgl_matrix_t* dst, float a, float x, float y, float z) {
  3342. float s = sinf(a);
  3343. float c = cosf(a);
  3344. float mag = sqrtf(x*x + y*y + z*z);
  3345. if (mag < 1.0e-4F) {
  3346. return;
  3347. }
  3348. x /= mag;
  3349. y /= mag;
  3350. z /= mag;
  3351. float xx = x * x;
  3352. float yy = y * y;
  3353. float zz = z * z;
  3354. float xy = x * y;
  3355. float yz = y * z;
  3356. float zx = z * x;
  3357. float xs = x * s;
  3358. float ys = y * s;
  3359. float zs = z * s;
  3360. float one_c = 1.0f - c;
  3361. _sgl_matrix_t m;
  3362. m.v[0][0] = (one_c * xx) + c;
  3363. m.v[1][0] = (one_c * xy) - zs;
  3364. m.v[2][0] = (one_c * zx) + ys;
  3365. m.v[3][0] = 0.0f;
  3366. m.v[0][1] = (one_c * xy) + zs;
  3367. m.v[1][1] = (one_c * yy) + c;
  3368. m.v[2][1] = (one_c * yz) - xs;
  3369. m.v[3][1] = 0.0f;
  3370. m.v[0][2] = (one_c * zx) - ys;
  3371. m.v[1][2] = (one_c * yz) + xs;
  3372. m.v[2][2] = (one_c * zz) + c;
  3373. m.v[3][2] = 0.0f;
  3374. m.v[0][3] = 0.0f;
  3375. m.v[1][3] = 0.0f;
  3376. m.v[2][3] = 0.0f;
  3377. m.v[3][3] = 1.0f;
  3378. _sgl_mul(dst, &m);
  3379. }
  3380. static void _sgl_scale(_sgl_matrix_t* dst, float x, float y, float z) {
  3381. for (int r = 0; r < 4; r++) {
  3382. dst->v[0][r] *= x;
  3383. dst->v[1][r] *= y;
  3384. dst->v[2][r] *= z;
  3385. }
  3386. }
  3387. static void _sgl_translate(_sgl_matrix_t* dst, float x, float y, float z) {
  3388. for (int r = 0; r < 4; r++) {
  3389. dst->v[3][r] = dst->v[0][r]*x + dst->v[1][r]*y + dst->v[2][r]*z + dst->v[3][r];
  3390. }
  3391. }
  3392. static void _sgl_frustum(_sgl_matrix_t* dst, float left, float right, float bottom, float top, float znear, float zfar) {
  3393. float x = (2.0f * znear) / (right - left);
  3394. float y = (2.0f * znear) / (top - bottom);
  3395. float a = (right + left) / (right - left);
  3396. float b = (top + bottom) / (top - bottom);
  3397. float c = -(zfar + znear) / (zfar - znear);
  3398. float d = -(2.0f * zfar * znear) / (zfar - znear);
  3399. _sgl_matrix_t m;
  3400. m.v[0][0] = x; m.v[0][1] = 0.0f; m.v[0][2] = 0.0f; m.v[0][3] = 0.0f;
  3401. m.v[1][0] = 0.0f; m.v[1][1] = y; m.v[1][2] = 0.0f; m.v[1][3] = 0.0f;
  3402. m.v[2][0] = a; m.v[2][1] = b; m.v[2][2] = c; m.v[2][3] = -1.0f;
  3403. m.v[3][0] = 0.0f; m.v[3][1] = 0.0f; m.v[3][2] = d; m.v[3][3] = 0.0f;
  3404. _sgl_mul(dst, &m);
  3405. }
  3406. static void _sgl_ortho(_sgl_matrix_t* dst, float left, float right, float bottom, float top, float znear, float zfar) {
  3407. _sgl_matrix_t m;
  3408. m.v[0][0] = 2.0f / (right - left);
  3409. m.v[1][0] = 0.0f;
  3410. m.v[2][0] = 0.0f;
  3411. m.v[3][0] = -(right + left) / (right - left);
  3412. m.v[0][1] = 0.0f;
  3413. m.v[1][1] = 2.0f / (top - bottom);
  3414. m.v[2][1] = 0.0f;
  3415. m.v[3][1] = -(top + bottom) / (top - bottom);
  3416. m.v[0][2] = 0.0f;
  3417. m.v[1][2] = 0.0f;
  3418. m.v[2][2] = -2.0f / (zfar - znear);
  3419. m.v[3][2] = -(zfar + znear) / (zfar - znear);
  3420. m.v[0][3] = 0.0f;
  3421. m.v[1][3] = 0.0f;
  3422. m.v[2][3] = 0.0f;
  3423. m.v[3][3] = 1.0f;
  3424. _sgl_mul(dst, &m);
  3425. }
  3426. /* _sgl_perspective, _sgl_lookat from Regal project.c */
  3427. static void _sgl_perspective(_sgl_matrix_t* dst, float fovy, float aspect, float znear, float zfar) {
  3428. float sine = sinf(fovy / 2.0f);
  3429. float delta_z = zfar - znear;
  3430. if ((delta_z == 0.0f) || (sine == 0.0f) || (aspect == 0.0f)) {
  3431. return;
  3432. }
  3433. float cotan = cosf(fovy / 2.0f) / sine;
  3434. _sgl_matrix_t m;
  3435. _sgl_identity(&m);
  3436. m.v[0][0] = cotan / aspect;
  3437. m.v[1][1] = cotan;
  3438. m.v[2][2] = -(zfar + znear) / delta_z;
  3439. m.v[2][3] = -1.0f;
  3440. m.v[3][2] = -2.0f * znear * zfar / delta_z;
  3441. m.v[3][3] = 0.0f;
  3442. _sgl_mul(dst, &m);
  3443. }
  3444. static void _sgl_normalize(float v[3]) {
  3445. float r = sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
  3446. if (r == 0.0f) {
  3447. return;
  3448. }
  3449. v[0] /= r;
  3450. v[1] /= r;
  3451. v[2] /= r;
  3452. }
  3453. static void _sgl_cross(float v1[3], float v2[3], float res[3]) {
  3454. res[0] = v1[1]*v2[2] - v1[2]*v2[1];
  3455. res[1] = v1[2]*v2[0] - v1[0]*v2[2];
  3456. res[2] = v1[0]*v2[1] - v1[1]*v2[0];
  3457. }
  3458. static void _sgl_lookat(_sgl_matrix_t* dst,
  3459. float eye_x, float eye_y, float eye_z,
  3460. float center_x, float center_y, float center_z,
  3461. float up_x, float up_y, float up_z)
  3462. {
  3463. float fwd[3], side[3], up[3];
  3464. fwd[0] = center_x - eye_x; fwd[1] = center_y - eye_y; fwd[2] = center_z - eye_z;
  3465. up[0] = up_x; up[1] = up_y; up[2] = up_z;
  3466. _sgl_normalize(fwd);
  3467. _sgl_cross(fwd, up, side);
  3468. _sgl_normalize(side);
  3469. _sgl_cross(side, fwd, up);
  3470. _sgl_matrix_t m;
  3471. _sgl_identity(&m);
  3472. m.v[0][0] = side[0];
  3473. m.v[1][0] = side[1];
  3474. m.v[2][0] = side[2];
  3475. m.v[0][1] = up[0];
  3476. m.v[1][1] = up[1];
  3477. m.v[2][1] = up[2];
  3478. m.v[0][2] = -fwd[0];
  3479. m.v[1][2] = -fwd[1];
  3480. m.v[2][2] = -fwd[2];
  3481. _sgl_mul(dst, &m);
  3482. _sgl_translate(dst, -eye_x, -eye_y, -eye_z);
  3483. }
  3484. /* current top-of-stack projection matrix */
  3485. static _sgl_matrix_t* _sgl_matrix_projection(_sgl_context_t* ctx) {
  3486. return &ctx->matrix_stack[SGL_MATRIXMODE_PROJECTION][ctx->matrix_tos[SGL_MATRIXMODE_PROJECTION]];
  3487. }
  3488. /* get top-of-stack modelview matrix */
  3489. static _sgl_matrix_t* _sgl_matrix_modelview(_sgl_context_t* ctx) {
  3490. return &ctx->matrix_stack[SGL_MATRIXMODE_MODELVIEW][ctx->matrix_tos[SGL_MATRIXMODE_MODELVIEW]];
  3491. }
  3492. /* get top-of-stack texture matrix */
  3493. static _sgl_matrix_t* _sgl_matrix_texture(_sgl_context_t* ctx) {
  3494. return &ctx->matrix_stack[SGL_MATRIXMODE_TEXTURE][ctx->matrix_tos[SGL_MATRIXMODE_TEXTURE]];
  3495. }
  3496. /* get pointer to current top-of-stack of current matrix mode */
  3497. static _sgl_matrix_t* _sgl_matrix(_sgl_context_t* ctx) {
  3498. return &ctx->matrix_stack[ctx->cur_matrix_mode][ctx->matrix_tos[ctx->cur_matrix_mode]];
  3499. }
  3500. static sgl_desc_t _sgl_desc_defaults(const sgl_desc_t* desc) {
  3501. SOKOL_ASSERT((desc->allocator.alloc_fn && desc->allocator.free_fn) || (!desc->allocator.alloc_fn && !desc->allocator.free_fn));
  3502. sgl_desc_t res = *desc;
  3503. res.max_vertices = _sgl_def(desc->max_vertices, _SGL_DEFAULT_MAX_VERTICES);
  3504. res.max_commands = _sgl_def(desc->max_commands, _SGL_DEFAULT_MAX_COMMANDS);
  3505. res.context_pool_size = _sgl_def(desc->context_pool_size, _SGL_DEFAULT_CONTEXT_POOL_SIZE);
  3506. res.pipeline_pool_size = _sgl_def(desc->pipeline_pool_size, _SGL_DEFAULT_PIPELINE_POOL_SIZE);
  3507. res.face_winding = _sgl_def(desc->face_winding, SG_FACEWINDING_CCW);
  3508. return res;
  3509. }
  3510. // create resources which are shared between all contexts
  3511. static void _sgl_setup_common(void) {
  3512. sg_push_debug_group("sokol-gl");
  3513. uint32_t pixels[64];
  3514. for (int i = 0; i < 64; i++) {
  3515. pixels[i] = 0xFFFFFFFF;
  3516. }
  3517. sg_image_desc img_desc;
  3518. _sgl_clear(&img_desc, sizeof(img_desc));
  3519. img_desc.type = SG_IMAGETYPE_2D;
  3520. img_desc.width = 8;
  3521. img_desc.height = 8;
  3522. img_desc.num_mipmaps = 1;
  3523. img_desc.pixel_format = SG_PIXELFORMAT_RGBA8;
  3524. img_desc.data.mip_levels[0] = SG_RANGE(pixels);
  3525. img_desc.label = "sgl-default-texture";
  3526. _sgl.def_img = sg_make_image(&img_desc);
  3527. SOKOL_ASSERT(SG_INVALID_ID != _sgl.def_img.id);
  3528. sg_view_desc view_desc;
  3529. _sgl_clear(&view_desc, sizeof(view_desc));
  3530. view_desc.texture.image = _sgl.def_img;
  3531. view_desc.label = "sgl-default-texture-view";
  3532. _sgl.def_view = sg_make_view(&view_desc);
  3533. SOKOL_ASSERT(SG_INVALID_ID != _sgl.def_view.id);
  3534. sg_sampler_desc smp_desc;
  3535. _sgl_clear(&smp_desc, sizeof(smp_desc));
  3536. smp_desc.min_filter = SG_FILTER_NEAREST;
  3537. smp_desc.mag_filter = SG_FILTER_NEAREST;
  3538. smp_desc.label = "sgl-default-sampler";
  3539. _sgl.def_smp = sg_make_sampler(&smp_desc);
  3540. SOKOL_ASSERT(SG_INVALID_ID != _sgl.def_smp.id);
  3541. // one shader for all contexts
  3542. sg_shader_desc shd_desc;
  3543. _sgl_clear(&shd_desc, sizeof(shd_desc));
  3544. shd_desc.attrs[0].glsl_name = "position";
  3545. shd_desc.attrs[1].glsl_name = "texcoord0";
  3546. shd_desc.attrs[2].glsl_name = "color0";
  3547. shd_desc.attrs[3].glsl_name = "psize";
  3548. shd_desc.attrs[0].hlsl_sem_name = "TEXCOORD";
  3549. shd_desc.attrs[0].hlsl_sem_index = 0;
  3550. shd_desc.attrs[1].hlsl_sem_name = "TEXCOORD";
  3551. shd_desc.attrs[1].hlsl_sem_index = 1;
  3552. shd_desc.attrs[2].hlsl_sem_name = "TEXCOORD";
  3553. shd_desc.attrs[2].hlsl_sem_index = 2;
  3554. shd_desc.attrs[3].hlsl_sem_name = "TEXCOORD";
  3555. shd_desc.attrs[3].hlsl_sem_index = 3;
  3556. shd_desc.attrs[0].base_type = SG_SHADERATTRBASETYPE_FLOAT;
  3557. shd_desc.attrs[1].base_type = SG_SHADERATTRBASETYPE_FLOAT;
  3558. shd_desc.attrs[2].base_type = SG_SHADERATTRBASETYPE_FLOAT;
  3559. shd_desc.attrs[3].base_type = SG_SHADERATTRBASETYPE_FLOAT;
  3560. shd_desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
  3561. shd_desc.uniform_blocks[0].size = sizeof(_sgl_uniform_t);
  3562. shd_desc.uniform_blocks[0].hlsl_register_b_n = 0;
  3563. shd_desc.uniform_blocks[0].msl_buffer_n = 0;
  3564. shd_desc.uniform_blocks[0].wgsl_group0_binding_n = 0;
  3565. shd_desc.uniform_blocks[0].spirv_set0_binding_n = 0;
  3566. shd_desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "vs_params";
  3567. shd_desc.uniform_blocks[0].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
  3568. shd_desc.uniform_blocks[0].glsl_uniforms[0].array_count = 8;
  3569. shd_desc.views[0].texture.stage = SG_SHADERSTAGE_FRAGMENT;
  3570. shd_desc.views[0].texture.image_type = SG_IMAGETYPE_2D;
  3571. shd_desc.views[0].texture.sample_type = SG_IMAGESAMPLETYPE_FLOAT;
  3572. shd_desc.views[0].texture.hlsl_register_t_n = 0;
  3573. shd_desc.views[0].texture.msl_texture_n = 0;
  3574. shd_desc.views[0].texture.wgsl_group1_binding_n = 0;
  3575. shd_desc.views[0].texture.spirv_set1_binding_n = 0;
  3576. shd_desc.samplers[0].stage = SG_SHADERSTAGE_FRAGMENT;
  3577. shd_desc.samplers[0].sampler_type = SG_SAMPLERTYPE_FILTERING;
  3578. shd_desc.samplers[0].hlsl_register_s_n = 0;
  3579. shd_desc.samplers[0].msl_sampler_n = 0;
  3580. shd_desc.samplers[0].wgsl_group1_binding_n = 32;
  3581. shd_desc.samplers[0].spirv_set1_binding_n = 32;
  3582. shd_desc.texture_sampler_pairs[0].stage = SG_SHADERSTAGE_FRAGMENT;
  3583. shd_desc.texture_sampler_pairs[0].view_slot = 0;
  3584. shd_desc.texture_sampler_pairs[0].sampler_slot = 0;
  3585. shd_desc.texture_sampler_pairs[0].glsl_name = "tex_smp";
  3586. shd_desc.label = "sgl-shader";
  3587. #if defined(SOKOL_GLCORE)
  3588. shd_desc.vertex_func.source = (const char*)_sgl_vs_source_glsl410;
  3589. shd_desc.fragment_func.source = (const char*)_sgl_fs_source_glsl410;
  3590. #elif defined(SOKOL_GLES3)
  3591. shd_desc.vertex_func.source = (const char*)_sgl_vs_source_glsl300es;
  3592. shd_desc.fragment_func.source = (const char*)_sgl_fs_source_glsl300es;
  3593. #elif defined(SOKOL_METAL)
  3594. shd_desc.vertex_func.entry = "main0";
  3595. shd_desc.fragment_func.entry = "main0";
  3596. switch (sg_query_backend()) {
  3597. case SG_BACKEND_METAL_MACOS:
  3598. shd_desc.vertex_func.bytecode = SG_RANGE(_sgl_vs_bytecode_metal_macos);
  3599. shd_desc.fragment_func.bytecode = SG_RANGE(_sgl_fs_bytecode_metal_macos);
  3600. break;
  3601. case SG_BACKEND_METAL_IOS:
  3602. shd_desc.vertex_func.bytecode = SG_RANGE(_sgl_vs_bytecode_metal_ios);
  3603. shd_desc.fragment_func.bytecode = SG_RANGE(_sgl_fs_bytecode_metal_ios);
  3604. break;
  3605. default:
  3606. shd_desc.vertex_func.source = (const char*)_sgl_vs_source_metal_sim;
  3607. shd_desc.fragment_func.source = (const char*)_sgl_fs_source_metal_sim;
  3608. break;
  3609. }
  3610. #elif defined(SOKOL_D3D11)
  3611. shd_desc.vertex_func.bytecode = SG_RANGE(_sgl_vs_bytecode_hlsl4);
  3612. shd_desc.fragment_func.bytecode = SG_RANGE(_sgl_fs_bytecode_hlsl4);
  3613. #elif defined(SOKOL_WGPU)
  3614. shd_desc.vertex_func.source = (const char*)_sgl_vs_source_wgsl;
  3615. shd_desc.fragment_func.source = (const char*)_sgl_fs_source_wgsl;
  3616. #elif defined(SOKOL_VULKAN)
  3617. shd_desc.vertex_func.bytecode = SG_RANGE(_sgl_vs_bytecode_spirv_vk);
  3618. shd_desc.vertex_func.entry = "main";
  3619. shd_desc.fragment_func.bytecode = SG_RANGE(_sgl_fs_bytecode_spirv_vk);
  3620. shd_desc.fragment_func.entry = "main";
  3621. #else
  3622. shd_desc.vertex_func.source = _sgl_vs_source_dummy;
  3623. shd_desc.fragment_func.source = _sgl_fs_source_dummy;
  3624. #endif
  3625. _sgl.shd = sg_make_shader(&shd_desc);
  3626. SOKOL_ASSERT(SG_INVALID_ID != _sgl.shd.id);
  3627. sg_pop_debug_group();
  3628. }
  3629. // discard resources which are shared between all contexts
  3630. static void _sgl_discard_common(void) {
  3631. sg_push_debug_group("sokol-gl");
  3632. sg_destroy_view(_sgl.def_view);
  3633. sg_destroy_image(_sgl.def_img);
  3634. sg_destroy_sampler(_sgl.def_smp);
  3635. sg_destroy_shader(_sgl.shd);
  3636. sg_pop_debug_group();
  3637. }
  3638. static bool _sgl_is_default_context(sgl_context ctx_id) {
  3639. return ctx_id.id == SGL_DEFAULT_CONTEXT.id;
  3640. }
  3641. static void _sgl_draw(_sgl_context_t* ctx, int layer_id) {
  3642. SOKOL_ASSERT(ctx);
  3643. if ((ctx->vertices.next > 0) && (ctx->commands.next > 0)) {
  3644. sg_push_debug_group("sokol-gl");
  3645. uint32_t cur_pip_id = SG_INVALID_ID;
  3646. uint32_t cur_tex_id = SG_INVALID_ID;
  3647. uint32_t cur_smp_id = SG_INVALID_ID;
  3648. int cur_uniform_index = -1;
  3649. if (ctx->update_frame_id != ctx->frame_id) {
  3650. ctx->update_frame_id = ctx->frame_id;
  3651. const sg_range range = { ctx->vertices.ptr, (size_t)ctx->vertices.next * sizeof(_sgl_vertex_t) };
  3652. sg_update_buffer(ctx->vbuf, &range);
  3653. }
  3654. // render all successfully recorded commands (this may be less than the
  3655. // issued commands if we're in an error state)
  3656. for (int i = 0; i < ctx->commands.next; i++) {
  3657. const _sgl_command_t* cmd = &ctx->commands.ptr[i];
  3658. if (cmd->layer_id != layer_id) {
  3659. continue;
  3660. }
  3661. switch (cmd->cmd) {
  3662. case SGL_COMMAND_VIEWPORT:
  3663. {
  3664. const _sgl_viewport_args_t* args = &cmd->args.viewport;
  3665. sg_apply_viewport(args->x, args->y, args->w, args->h, args->origin_top_left);
  3666. }
  3667. break;
  3668. case SGL_COMMAND_SCISSOR_RECT:
  3669. {
  3670. const _sgl_scissor_rect_args_t* args = &cmd->args.scissor_rect;
  3671. sg_apply_scissor_rect(args->x, args->y, args->w, args->h, args->origin_top_left);
  3672. }
  3673. break;
  3674. case SGL_COMMAND_DRAW:
  3675. {
  3676. const _sgl_draw_args_t* args = &cmd->args.draw;
  3677. if (args->pip.id != cur_pip_id) {
  3678. sg_apply_pipeline(args->pip);
  3679. cur_pip_id = args->pip.id;
  3680. // when pipeline changes, also need to re-apply uniforms and bindings
  3681. cur_tex_id = SG_INVALID_ID;
  3682. cur_smp_id = SG_INVALID_ID;
  3683. cur_uniform_index = -1;
  3684. }
  3685. if ((cur_tex_id != args->view.id) || (cur_smp_id != args->smp.id)) {
  3686. ctx->bind.views[0] = args->view;
  3687. ctx->bind.samplers[0] = args->smp;
  3688. sg_apply_bindings(&ctx->bind);
  3689. cur_tex_id = args->view.id;
  3690. cur_smp_id = args->smp.id;
  3691. }
  3692. if (cur_uniform_index != args->uniform_index) {
  3693. const sg_range ub_range = { &ctx->uniforms.ptr[args->uniform_index], sizeof(_sgl_uniform_t) };
  3694. sg_apply_uniforms(0, &ub_range);
  3695. cur_uniform_index = args->uniform_index;
  3696. }
  3697. // FIXME: what if number of vertices doesn't match the primitive type?
  3698. if (args->num_vertices > 0) {
  3699. sg_draw(args->base_vertex, args->num_vertices, 1);
  3700. }
  3701. }
  3702. break;
  3703. }
  3704. }
  3705. sg_pop_debug_group();
  3706. }
  3707. }
  3708. static sgl_context_desc_t _sgl_as_context_desc(const sgl_desc_t* desc) {
  3709. sgl_context_desc_t ctx_desc;
  3710. _sgl_clear(&ctx_desc, sizeof(ctx_desc));
  3711. ctx_desc.max_vertices = desc->max_vertices;
  3712. ctx_desc.max_commands = desc->max_commands;
  3713. ctx_desc.color_format = desc->color_format;
  3714. ctx_desc.depth_format = desc->depth_format;
  3715. ctx_desc.sample_count = desc->sample_count;
  3716. return ctx_desc;
  3717. }
  3718. // ██████ ██ ██ ██████ ██ ██ ██████
  3719. // ██ ██ ██ ██ ██ ██ ██ ██ ██
  3720. // ██████ ██ ██ ██████ ██ ██ ██
  3721. // ██ ██ ██ ██ ██ ██ ██ ██
  3722. // ██ ██████ ██████ ███████ ██ ██████
  3723. //
  3724. // >>public
  3725. SOKOL_API_IMPL void sgl_setup(const sgl_desc_t* desc) {
  3726. SOKOL_ASSERT(desc);
  3727. _sgl_clear(&_sgl, sizeof(_sgl));
  3728. _sgl.init_cookie = _SGL_INIT_COOKIE;
  3729. _sgl.desc = _sgl_desc_defaults(desc);
  3730. _sgl_setup_pipeline_pool(_sgl.desc.pipeline_pool_size);
  3731. _sgl_setup_context_pool(_sgl.desc.context_pool_size);
  3732. _sgl_setup_common();
  3733. const sgl_context_desc_t ctx_desc = _sgl_as_context_desc(&_sgl.desc);
  3734. _sgl.def_ctx_id = sgl_make_context(&ctx_desc);
  3735. SOKOL_ASSERT(SGL_DEFAULT_CONTEXT.id == _sgl.def_ctx_id.id);
  3736. sgl_set_context(_sgl.def_ctx_id);
  3737. }
  3738. SOKOL_API_IMPL void sgl_shutdown(void) {
  3739. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3740. // contexts own a pipeline, so destroy contexts before pipelines
  3741. for (int i = 0; i < _sgl.context_pool.pool.size; i++) {
  3742. _sgl_context_t* ctx = &_sgl.context_pool.contexts[i];
  3743. _sgl_destroy_context(_sgl_make_ctx_id(ctx->slot.id));
  3744. }
  3745. for (int i = 0; i < _sgl.pip_pool.pool.size; i++) {
  3746. _sgl_pipeline_t* pip = &_sgl.pip_pool.pips[i];
  3747. _sgl_destroy_pipeline(_sgl_make_pip_id(pip->slot.id));
  3748. }
  3749. _sgl_discard_context_pool();
  3750. _sgl_discard_pipeline_pool();
  3751. _sgl_discard_common();
  3752. _sgl.init_cookie = 0;
  3753. }
  3754. SOKOL_API_IMPL sgl_error_t sgl_error(void) {
  3755. _sgl_context_t* ctx = _sgl.cur_ctx;
  3756. if (ctx) {
  3757. return ctx->error;
  3758. } else {
  3759. sgl_error_t err = _sgl_error_defaults();
  3760. err.no_context = true;
  3761. err.any = true;
  3762. return err;
  3763. }
  3764. }
  3765. SOKOL_API_IMPL sgl_error_t sgl_context_error(sgl_context ctx_id) {
  3766. const _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id);
  3767. if (ctx) {
  3768. return ctx->error;
  3769. } else {
  3770. sgl_error_t err = _sgl_error_defaults();
  3771. err.no_context = true;
  3772. err.any = true;
  3773. return err;
  3774. }
  3775. }
  3776. SOKOL_API_IMPL float sgl_rad(float deg) {
  3777. return (deg * (float)M_PI) / 180.0f;
  3778. }
  3779. SOKOL_API_IMPL float sgl_deg(float rad) {
  3780. return (rad * 180.0f) / (float)M_PI;
  3781. }
  3782. SOKOL_API_IMPL sgl_context sgl_make_context(const sgl_context_desc_t* desc) {
  3783. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3784. return _sgl_make_context(desc);
  3785. }
  3786. SOKOL_API_IMPL void sgl_destroy_context(sgl_context ctx_id) {
  3787. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3788. if (_sgl_is_default_context(ctx_id)) {
  3789. _SGL_WARN(CANNOT_DESTROY_DEFAULT_CONTEXT);
  3790. return;
  3791. }
  3792. _sgl_destroy_context(ctx_id);
  3793. // re-validate the current context pointer (this will return a nullptr
  3794. // if we just destroyed the current context)
  3795. _sgl.cur_ctx = _sgl_lookup_context(_sgl.cur_ctx_id.id);
  3796. }
  3797. SOKOL_API_IMPL void sgl_set_context(sgl_context ctx_id) {
  3798. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3799. if (_sgl_is_default_context(ctx_id)) {
  3800. _sgl.cur_ctx_id = _sgl.def_ctx_id;
  3801. } else {
  3802. _sgl.cur_ctx_id = ctx_id;
  3803. }
  3804. // this will return null if the handle isn't valid
  3805. _sgl.cur_ctx = _sgl_lookup_context(_sgl.cur_ctx_id.id);
  3806. }
  3807. SOKOL_API_IMPL sgl_context sgl_get_context(void) {
  3808. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3809. return _sgl.cur_ctx_id;
  3810. }
  3811. SOKOL_API_IMPL sgl_context sgl_default_context(void) {
  3812. return SGL_DEFAULT_CONTEXT;
  3813. }
  3814. SOKOL_API_IMPL int sgl_num_vertices(void) {
  3815. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3816. _sgl_context_t* ctx = _sgl.cur_ctx;
  3817. if (ctx) {
  3818. return _sgl_num_vertices(ctx);
  3819. } else {
  3820. return 0;
  3821. }
  3822. }
  3823. SOKOL_API_IMPL int sgl_num_commands(void) {
  3824. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3825. _sgl_context_t* ctx = _sgl.cur_ctx;
  3826. if (ctx) {
  3827. return _sgl_num_commands(ctx);
  3828. } else {
  3829. return 0;
  3830. }
  3831. }
  3832. SOKOL_API_IMPL sgl_pipeline sgl_make_pipeline(const sg_pipeline_desc* desc) {
  3833. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3834. _sgl_context_t* ctx = _sgl.cur_ctx;
  3835. if (ctx) {
  3836. return _sgl_make_pipeline(desc, &ctx->desc);
  3837. } else {
  3838. return _sgl_make_pip_id(SG_INVALID_ID);
  3839. }
  3840. }
  3841. SOKOL_API_IMPL sgl_pipeline sgl_context_make_pipeline(sgl_context ctx_id, const sg_pipeline_desc* desc) {
  3842. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3843. const _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id);
  3844. if (ctx) {
  3845. return _sgl_make_pipeline(desc, &ctx->desc);
  3846. } else {
  3847. return _sgl_make_pip_id(SG_INVALID_ID);
  3848. }
  3849. }
  3850. SOKOL_API_IMPL void sgl_destroy_pipeline(sgl_pipeline pip_id) {
  3851. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3852. _sgl_destroy_pipeline(pip_id);
  3853. }
  3854. SOKOL_API_IMPL void sgl_load_pipeline(sgl_pipeline pip_id) {
  3855. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3856. _sgl_context_t* ctx = _sgl.cur_ctx;
  3857. if (!ctx) {
  3858. return;
  3859. }
  3860. SOKOL_ASSERT((ctx->pip_tos >= 0) && (ctx->pip_tos < _SGL_MAX_STACK_DEPTH));
  3861. ctx->pip_stack[ctx->pip_tos] = pip_id;
  3862. }
  3863. SOKOL_API_IMPL void sgl_load_default_pipeline(void) {
  3864. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3865. _sgl_context_t* ctx = _sgl.cur_ctx;
  3866. if (!ctx) {
  3867. return;
  3868. }
  3869. SOKOL_ASSERT((ctx->pip_tos >= 0) && (ctx->pip_tos < _SGL_MAX_STACK_DEPTH));
  3870. ctx->pip_stack[ctx->pip_tos] = ctx->def_pip;
  3871. }
  3872. SOKOL_API_IMPL void sgl_push_pipeline(void) {
  3873. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3874. _sgl_context_t* ctx = _sgl.cur_ctx;
  3875. if (!ctx) {
  3876. return;
  3877. }
  3878. if (ctx->pip_tos < (_SGL_MAX_STACK_DEPTH - 1)) {
  3879. ctx->pip_tos++;
  3880. ctx->pip_stack[ctx->pip_tos] = ctx->pip_stack[ctx->pip_tos-1];
  3881. } else {
  3882. ctx->error.stack_overflow = true;
  3883. ctx->error.any = true;
  3884. }
  3885. }
  3886. SOKOL_API_IMPL void sgl_pop_pipeline(void) {
  3887. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3888. _sgl_context_t* ctx = _sgl.cur_ctx;
  3889. if (!ctx) {
  3890. return;
  3891. }
  3892. if (ctx->pip_tos > 0) {
  3893. ctx->pip_tos--;
  3894. } else {
  3895. ctx->error.stack_underflow = true;
  3896. ctx->error.any = true;
  3897. }
  3898. }
  3899. SOKOL_API_IMPL void sgl_defaults(void) {
  3900. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3901. _sgl_context_t* ctx = _sgl.cur_ctx;
  3902. if (!ctx) {
  3903. return;
  3904. }
  3905. SOKOL_ASSERT(!ctx->in_begin);
  3906. ctx->u = 0.0f; ctx->v = 0.0f;
  3907. ctx->rgba = 0xFFFFFFFF;
  3908. ctx->point_size = 1.0f;
  3909. ctx->texturing_enabled = false;
  3910. ctx->cur_view = _sgl.def_view;
  3911. ctx->cur_smp = _sgl.def_smp;
  3912. sgl_load_default_pipeline();
  3913. _sgl_identity(_sgl_matrix_texture(ctx));
  3914. _sgl_identity(_sgl_matrix_modelview(ctx));
  3915. _sgl_identity(_sgl_matrix_projection(ctx));
  3916. ctx->cur_matrix_mode = SGL_MATRIXMODE_MODELVIEW;
  3917. ctx->matrix_dirty = true;
  3918. }
  3919. SOKOL_API_IMPL void sgl_layer(int layer_id) {
  3920. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3921. _sgl_context_t* ctx = _sgl.cur_ctx;
  3922. if (!ctx) {
  3923. return;
  3924. }
  3925. SOKOL_ASSERT(!ctx->in_begin);
  3926. ctx->layer_id = layer_id;
  3927. }
  3928. SOKOL_API_IMPL void sgl_viewport(int x, int y, int w, int h, bool origin_top_left) {
  3929. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3930. _sgl_context_t* ctx = _sgl.cur_ctx;
  3931. if (!ctx) {
  3932. return;
  3933. }
  3934. SOKOL_ASSERT(!ctx->in_begin);
  3935. _sgl_command_t* cmd = _sgl_next_command(ctx);
  3936. if (cmd) {
  3937. cmd->cmd = SGL_COMMAND_VIEWPORT;
  3938. cmd->layer_id = ctx->layer_id;
  3939. cmd->args.viewport.x = x;
  3940. cmd->args.viewport.y = y;
  3941. cmd->args.viewport.w = w;
  3942. cmd->args.viewport.h = h;
  3943. cmd->args.viewport.origin_top_left = origin_top_left;
  3944. }
  3945. }
  3946. SOKOL_API_IMPL void sgl_viewportf(float x, float y, float w, float h, bool origin_top_left) {
  3947. sgl_viewport((int)x, (int)y, (int)w, (int)h, origin_top_left);
  3948. }
  3949. SOKOL_API_IMPL void sgl_scissor_rect(int x, int y, int w, int h, bool origin_top_left) {
  3950. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3951. _sgl_context_t* ctx = _sgl.cur_ctx;
  3952. if (!ctx) {
  3953. return;
  3954. }
  3955. SOKOL_ASSERT(!ctx->in_begin);
  3956. _sgl_command_t* cmd = _sgl_next_command(ctx);
  3957. if (cmd) {
  3958. cmd->cmd = SGL_COMMAND_SCISSOR_RECT;
  3959. cmd->layer_id = ctx->layer_id;
  3960. cmd->args.scissor_rect.x = x;
  3961. cmd->args.scissor_rect.y = y;
  3962. cmd->args.scissor_rect.w = w;
  3963. cmd->args.scissor_rect.h = h;
  3964. cmd->args.scissor_rect.origin_top_left = origin_top_left;
  3965. }
  3966. }
  3967. SOKOL_API_IMPL void sgl_scissor_rectf(float x, float y, float w, float h, bool origin_top_left) {
  3968. sgl_scissor_rect((int)x, (int)y, (int)w, (int)h, origin_top_left);
  3969. }
  3970. SOKOL_API_IMPL void sgl_enable_texture(void) {
  3971. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3972. _sgl_context_t* ctx = _sgl.cur_ctx;
  3973. if (!ctx) {
  3974. return;
  3975. }
  3976. SOKOL_ASSERT(!ctx->in_begin);
  3977. ctx->texturing_enabled = true;
  3978. }
  3979. SOKOL_API_IMPL void sgl_disable_texture(void) {
  3980. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3981. _sgl_context_t* ctx = _sgl.cur_ctx;
  3982. if (!ctx) {
  3983. return;
  3984. }
  3985. SOKOL_ASSERT(!ctx->in_begin);
  3986. ctx->texturing_enabled = false;
  3987. }
  3988. SOKOL_API_IMPL void sgl_texture(sg_view tex_view, sg_sampler smp) {
  3989. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  3990. _sgl_context_t* ctx = _sgl.cur_ctx;
  3991. if (!ctx) {
  3992. return;
  3993. }
  3994. SOKOL_ASSERT(!ctx->in_begin);
  3995. if (SG_INVALID_ID != tex_view.id) {
  3996. ctx->cur_view = tex_view;
  3997. } else {
  3998. ctx->cur_view = _sgl.def_view;
  3999. }
  4000. if (SG_INVALID_ID != smp.id) {
  4001. ctx->cur_smp = smp;
  4002. } else {
  4003. ctx->cur_smp = _sgl.def_smp;
  4004. }
  4005. }
  4006. SOKOL_API_IMPL void sgl_begin_points(void) {
  4007. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4008. _sgl_context_t* ctx = _sgl.cur_ctx;
  4009. if (!ctx) {
  4010. return;
  4011. }
  4012. SOKOL_ASSERT(!ctx->in_begin);
  4013. _sgl_begin(ctx, SGL_PRIMITIVETYPE_POINTS);
  4014. }
  4015. SOKOL_API_IMPL void sgl_begin_lines(void) {
  4016. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4017. _sgl_context_t* ctx = _sgl.cur_ctx;
  4018. if (!ctx) {
  4019. return;
  4020. }
  4021. SOKOL_ASSERT(!ctx->in_begin);
  4022. _sgl_begin(ctx, SGL_PRIMITIVETYPE_LINES);
  4023. }
  4024. SOKOL_API_IMPL void sgl_begin_line_strip(void) {
  4025. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4026. _sgl_context_t* ctx = _sgl.cur_ctx;
  4027. if (!ctx) {
  4028. return;
  4029. }
  4030. SOKOL_ASSERT(!ctx->in_begin);
  4031. _sgl_begin(ctx, SGL_PRIMITIVETYPE_LINE_STRIP);
  4032. }
  4033. SOKOL_API_IMPL void sgl_begin_triangles(void) {
  4034. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4035. _sgl_context_t* ctx = _sgl.cur_ctx;
  4036. if (!ctx) {
  4037. return;
  4038. }
  4039. SOKOL_ASSERT(!ctx->in_begin);
  4040. _sgl_begin(ctx, SGL_PRIMITIVETYPE_TRIANGLES);
  4041. }
  4042. SOKOL_API_IMPL void sgl_begin_triangle_strip(void) {
  4043. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4044. _sgl_context_t* ctx = _sgl.cur_ctx;
  4045. if (!ctx) {
  4046. return;
  4047. }
  4048. SOKOL_ASSERT(!ctx->in_begin);
  4049. _sgl_begin(ctx, SGL_PRIMITIVETYPE_TRIANGLE_STRIP);
  4050. }
  4051. SOKOL_API_IMPL void sgl_begin_quads(void) {
  4052. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4053. _sgl_context_t* ctx = _sgl.cur_ctx;
  4054. if (!ctx) {
  4055. return;
  4056. }
  4057. SOKOL_ASSERT(!ctx->in_begin);
  4058. _sgl_begin(ctx, SGL_PRIMITIVETYPE_QUADS);
  4059. }
  4060. SOKOL_API_IMPL void sgl_end(void) {
  4061. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4062. _sgl_context_t* ctx = _sgl.cur_ctx;
  4063. if (!ctx) {
  4064. return;
  4065. }
  4066. SOKOL_ASSERT(ctx->in_begin);
  4067. SOKOL_ASSERT(ctx->vertices.next >= ctx->base_vertex);
  4068. ctx->in_begin = false;
  4069. bool matrix_dirty = ctx->matrix_dirty;
  4070. if (matrix_dirty) {
  4071. ctx->matrix_dirty = false;
  4072. _sgl_uniform_t* uni = _sgl_next_uniform(ctx);
  4073. if (uni) {
  4074. _sgl_matmul4(&uni->mvp, _sgl_matrix_projection(ctx), _sgl_matrix_modelview(ctx));
  4075. uni->tm = *_sgl_matrix_texture(ctx);
  4076. }
  4077. }
  4078. // don't record any new commands when we're in an error state
  4079. if (ctx->error.any) {
  4080. return;
  4081. }
  4082. // check if command can be merged with current command
  4083. sg_pipeline pip = _sgl_get_pipeline(ctx->pip_stack[ctx->pip_tos], ctx->cur_prim_type);
  4084. sg_view view = ctx->texturing_enabled ? ctx->cur_view : _sgl.def_view;
  4085. sg_sampler smp = ctx->texturing_enabled ? ctx->cur_smp : _sgl.def_smp;
  4086. _sgl_command_t* cur_cmd = _sgl_cur_command(ctx);
  4087. bool merge_cmd = false;
  4088. if (cur_cmd) {
  4089. if ((cur_cmd->cmd == SGL_COMMAND_DRAW) &&
  4090. (cur_cmd->layer_id == ctx->layer_id) &&
  4091. (ctx->cur_prim_type != SGL_PRIMITIVETYPE_LINE_STRIP) &&
  4092. (ctx->cur_prim_type != SGL_PRIMITIVETYPE_TRIANGLE_STRIP) &&
  4093. !matrix_dirty &&
  4094. (cur_cmd->args.draw.view.id == view.id) &&
  4095. (cur_cmd->args.draw.smp.id == smp.id) &&
  4096. (cur_cmd->args.draw.pip.id == pip.id))
  4097. {
  4098. merge_cmd = true;
  4099. }
  4100. }
  4101. if (merge_cmd) {
  4102. // draw command can be merged with the previous command
  4103. cur_cmd->args.draw.num_vertices += ctx->vertices.next - ctx->base_vertex;
  4104. } else {
  4105. // append a new draw command
  4106. _sgl_command_t* cmd = _sgl_next_command(ctx);
  4107. if (cmd) {
  4108. SOKOL_ASSERT(ctx->uniforms.next > 0);
  4109. cmd->cmd = SGL_COMMAND_DRAW;
  4110. cmd->layer_id = ctx->layer_id;
  4111. cmd->args.draw.view = view;
  4112. cmd->args.draw.smp = smp;
  4113. cmd->args.draw.pip = _sgl_get_pipeline(ctx->pip_stack[ctx->pip_tos], ctx->cur_prim_type);
  4114. cmd->args.draw.base_vertex = ctx->base_vertex;
  4115. cmd->args.draw.num_vertices = ctx->vertices.next - ctx->base_vertex;
  4116. cmd->args.draw.uniform_index = ctx->uniforms.next - 1;
  4117. }
  4118. }
  4119. }
  4120. SOKOL_API_IMPL void sgl_point_size(float s) {
  4121. _sgl_context_t* ctx = _sgl.cur_ctx;
  4122. if (ctx) {
  4123. ctx->point_size = s;
  4124. }
  4125. }
  4126. SOKOL_API_IMPL void sgl_t2f(float u, float v) {
  4127. _sgl_context_t* ctx = _sgl.cur_ctx;
  4128. if (ctx) {
  4129. ctx->u = u;
  4130. ctx->v = v;
  4131. }
  4132. }
  4133. SOKOL_API_IMPL void sgl_c3f(float r, float g, float b) {
  4134. _sgl_context_t* ctx = _sgl.cur_ctx;
  4135. if (ctx) {
  4136. ctx->rgba = _sgl_pack_rgbaf(r, g, b, 1.0f);
  4137. }
  4138. }
  4139. SOKOL_API_IMPL void sgl_c4f(float r, float g, float b, float a) {
  4140. _sgl_context_t* ctx = _sgl.cur_ctx;
  4141. if (ctx) {
  4142. ctx->rgba = _sgl_pack_rgbaf(r, g, b, a);
  4143. }
  4144. }
  4145. SOKOL_API_IMPL void sgl_c3b(uint8_t r, uint8_t g, uint8_t b) {
  4146. _sgl_context_t* ctx = _sgl.cur_ctx;
  4147. if (ctx) {
  4148. ctx->rgba = _sgl_pack_rgbab(r, g, b, 255);
  4149. }
  4150. }
  4151. SOKOL_API_IMPL void sgl_c4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
  4152. _sgl_context_t* ctx = _sgl.cur_ctx;
  4153. if (ctx) {
  4154. ctx->rgba = _sgl_pack_rgbab(r, g, b, a);
  4155. }
  4156. }
  4157. SOKOL_API_IMPL void sgl_c1i(uint32_t rgba) {
  4158. _sgl_context_t* ctx = _sgl.cur_ctx;
  4159. if (ctx) {
  4160. ctx->rgba = rgba;
  4161. }
  4162. }
  4163. SOKOL_API_IMPL void sgl_v2f(float x, float y) {
  4164. _sgl_context_t* ctx = _sgl.cur_ctx;
  4165. if (ctx) {
  4166. _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, ctx->rgba);
  4167. }
  4168. }
  4169. SOKOL_API_IMPL void sgl_v3f(float x, float y, float z) {
  4170. _sgl_context_t* ctx = _sgl.cur_ctx;
  4171. if (ctx) {
  4172. _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, ctx->rgba);
  4173. }
  4174. }
  4175. SOKOL_API_IMPL void sgl_v2f_t2f(float x, float y, float u, float v) {
  4176. _sgl_context_t* ctx = _sgl.cur_ctx;
  4177. if (ctx) {
  4178. _sgl_vtx(ctx, x, y, 0.0f, u, v, ctx->rgba);
  4179. }
  4180. }
  4181. SOKOL_API_IMPL void sgl_v3f_t2f(float x, float y, float z, float u, float v) {
  4182. _sgl_context_t* ctx = _sgl.cur_ctx;
  4183. if (ctx) {
  4184. _sgl_vtx(ctx, x, y, z, u, v, ctx->rgba);
  4185. }
  4186. }
  4187. SOKOL_API_IMPL void sgl_v2f_c3f(float x, float y, float r, float g, float b) {
  4188. _sgl_context_t* ctx = _sgl.cur_ctx;
  4189. if (ctx) {
  4190. _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, _sgl_pack_rgbaf(r, g, b, 1.0f));
  4191. }
  4192. }
  4193. SOKOL_API_IMPL void sgl_v2f_c3b(float x, float y, uint8_t r, uint8_t g, uint8_t b) {
  4194. _sgl_context_t* ctx = _sgl.cur_ctx;
  4195. if (ctx) {
  4196. _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, _sgl_pack_rgbab(r, g, b, 255));
  4197. }
  4198. }
  4199. SOKOL_API_IMPL void sgl_v2f_c4f(float x, float y, float r, float g, float b, float a) {
  4200. _sgl_context_t* ctx = _sgl.cur_ctx;
  4201. if (ctx) {
  4202. _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, _sgl_pack_rgbaf(r, g, b, a));
  4203. }
  4204. }
  4205. SOKOL_API_IMPL void sgl_v2f_c4b(float x, float y, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
  4206. _sgl_context_t* ctx = _sgl.cur_ctx;
  4207. if (ctx) {
  4208. _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, _sgl_pack_rgbab(r, g, b, a));
  4209. }
  4210. }
  4211. SOKOL_API_IMPL void sgl_v2f_c1i(float x, float y, uint32_t rgba) {
  4212. _sgl_context_t* ctx = _sgl.cur_ctx;
  4213. if (ctx) {
  4214. _sgl_vtx(ctx, x, y, 0.0f, ctx->u, ctx->v, rgba);
  4215. }
  4216. }
  4217. SOKOL_API_IMPL void sgl_v3f_c3f(float x, float y, float z, float r, float g, float b) {
  4218. _sgl_context_t* ctx = _sgl.cur_ctx;
  4219. if (ctx) {
  4220. _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, _sgl_pack_rgbaf(r, g, b, 1.0f));
  4221. }
  4222. }
  4223. SOKOL_API_IMPL void sgl_v3f_c3b(float x, float y, float z, uint8_t r, uint8_t g, uint8_t b) {
  4224. _sgl_context_t* ctx = _sgl.cur_ctx;
  4225. if (ctx) {
  4226. _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, _sgl_pack_rgbab(r, g, b, 255));
  4227. }
  4228. }
  4229. SOKOL_API_IMPL void sgl_v3f_c4f(float x, float y, float z, float r, float g, float b, float a) {
  4230. _sgl_context_t* ctx = _sgl.cur_ctx;
  4231. if (ctx) {
  4232. _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, _sgl_pack_rgbaf(r, g, b, a));
  4233. }
  4234. }
  4235. SOKOL_API_IMPL void sgl_v3f_c4b(float x, float y, float z, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
  4236. _sgl_context_t* ctx = _sgl.cur_ctx;
  4237. if (ctx) {
  4238. _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, _sgl_pack_rgbab(r, g, b, a));
  4239. }
  4240. }
  4241. SOKOL_API_IMPL void sgl_v3f_c1i(float x, float y, float z, uint32_t rgba) {
  4242. _sgl_context_t* ctx = _sgl.cur_ctx;
  4243. if (ctx) {
  4244. _sgl_vtx(ctx, x, y, z, ctx->u, ctx->v, rgba);
  4245. }
  4246. }
  4247. SOKOL_API_IMPL void sgl_v2f_t2f_c3f(float x, float y, float u, float v, float r, float g, float b) {
  4248. _sgl_context_t* ctx = _sgl.cur_ctx;
  4249. if (ctx) {
  4250. _sgl_vtx(ctx, x, y, 0.0f, u, v, _sgl_pack_rgbaf(r, g, b, 1.0f));
  4251. }
  4252. }
  4253. SOKOL_API_IMPL void sgl_v2f_t2f_c3b(float x, float y, float u, float v, uint8_t r, uint8_t g, uint8_t b) {
  4254. _sgl_context_t* ctx = _sgl.cur_ctx;
  4255. if (ctx) {
  4256. _sgl_vtx(ctx, x, y, 0.0f, u, v, _sgl_pack_rgbab(r, g, b, 255));
  4257. }
  4258. }
  4259. SOKOL_API_IMPL void sgl_v2f_t2f_c4f(float x, float y, float u, float v, float r, float g, float b, float a) {
  4260. _sgl_context_t* ctx = _sgl.cur_ctx;
  4261. if (ctx) {
  4262. _sgl_vtx(ctx, x, y, 0.0f, u, v, _sgl_pack_rgbaf(r, g, b, a));
  4263. }
  4264. }
  4265. SOKOL_API_IMPL void sgl_v2f_t2f_c4b(float x, float y, float u, float v, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
  4266. _sgl_context_t* ctx = _sgl.cur_ctx;
  4267. if (ctx) {
  4268. _sgl_vtx(ctx, x, y, 0.0f, u, v, _sgl_pack_rgbab(r, g, b, a));
  4269. }
  4270. }
  4271. SOKOL_API_IMPL void sgl_v2f_t2f_c1i(float x, float y, float u, float v, uint32_t rgba) {
  4272. _sgl_context_t* ctx = _sgl.cur_ctx;
  4273. if (ctx) {
  4274. _sgl_vtx(ctx, x, y, 0.0f, u, v, rgba);
  4275. }
  4276. }
  4277. SOKOL_API_IMPL void sgl_v3f_t2f_c3f(float x, float y, float z, float u, float v, float r, float g, float b) {
  4278. _sgl_context_t* ctx = _sgl.cur_ctx;
  4279. if (ctx) {
  4280. _sgl_vtx(ctx, x, y, z, u, v, _sgl_pack_rgbaf(r, g, b, 1.0f));
  4281. }
  4282. }
  4283. SOKOL_API_IMPL void sgl_v3f_t2f_c3b(float x, float y, float z, float u, float v, uint8_t r, uint8_t g, uint8_t b) {
  4284. _sgl_context_t* ctx = _sgl.cur_ctx;
  4285. if (ctx) {
  4286. _sgl_vtx(ctx, x, y, z, u, v, _sgl_pack_rgbab(r, g, b, 255));
  4287. }
  4288. }
  4289. SOKOL_API_IMPL void sgl_v3f_t2f_c4f(float x, float y, float z, float u, float v, float r, float g, float b, float a) {
  4290. _sgl_context_t* ctx = _sgl.cur_ctx;
  4291. if (ctx) {
  4292. _sgl_vtx(ctx, x, y, z, u, v, _sgl_pack_rgbaf(r, g, b, a));
  4293. }
  4294. }
  4295. SOKOL_API_IMPL void sgl_v3f_t2f_c4b(float x, float y, float z, float u, float v, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
  4296. _sgl_context_t* ctx = _sgl.cur_ctx;
  4297. if (ctx) {
  4298. _sgl_vtx(ctx, x, y, z, u, v, _sgl_pack_rgbab(r, g, b, a));
  4299. }
  4300. }
  4301. SOKOL_API_IMPL void sgl_v3f_t2f_c1i(float x, float y, float z, float u, float v, uint32_t rgba) {
  4302. _sgl_context_t* ctx = _sgl.cur_ctx;
  4303. if (ctx) {
  4304. _sgl_vtx(ctx,x, y, z, u, v, rgba);
  4305. }
  4306. }
  4307. SOKOL_API_IMPL void sgl_matrix_mode_modelview(void) {
  4308. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4309. _sgl_context_t* ctx = _sgl.cur_ctx;
  4310. if (ctx) {
  4311. ctx->cur_matrix_mode = SGL_MATRIXMODE_MODELVIEW;
  4312. }
  4313. }
  4314. SOKOL_API_IMPL void sgl_matrix_mode_projection(void) {
  4315. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4316. _sgl_context_t* ctx = _sgl.cur_ctx;
  4317. if (ctx) {
  4318. ctx->cur_matrix_mode = SGL_MATRIXMODE_PROJECTION;
  4319. }
  4320. }
  4321. SOKOL_API_IMPL void sgl_matrix_mode_texture(void) {
  4322. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4323. _sgl_context_t* ctx = _sgl.cur_ctx;
  4324. if (ctx) {
  4325. ctx->cur_matrix_mode = SGL_MATRIXMODE_TEXTURE;
  4326. }
  4327. }
  4328. SOKOL_API_IMPL void sgl_load_identity(void) {
  4329. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4330. _sgl_context_t* ctx = _sgl.cur_ctx;
  4331. if (!ctx) {
  4332. return;
  4333. }
  4334. ctx->matrix_dirty = true;
  4335. _sgl_identity(_sgl_matrix(ctx));
  4336. }
  4337. SOKOL_API_IMPL void sgl_load_matrix(const float m[16]) {
  4338. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4339. _sgl_context_t* ctx = _sgl.cur_ctx;
  4340. if (!ctx) {
  4341. return;
  4342. }
  4343. ctx->matrix_dirty = true;
  4344. memcpy(&_sgl_matrix(ctx)->v[0][0], &m[0], 64);
  4345. }
  4346. SOKOL_API_IMPL void sgl_load_transpose_matrix(const float m[16]) {
  4347. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4348. _sgl_context_t* ctx = _sgl.cur_ctx;
  4349. if (!ctx) {
  4350. return;
  4351. }
  4352. ctx->matrix_dirty = true;
  4353. _sgl_transpose(_sgl_matrix(ctx), (const _sgl_matrix_t*) &m[0]);
  4354. }
  4355. SOKOL_API_IMPL void sgl_mult_matrix(const float m[16]) {
  4356. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4357. _sgl_context_t* ctx = _sgl.cur_ctx;
  4358. if (!ctx) {
  4359. return;
  4360. }
  4361. ctx->matrix_dirty = true;
  4362. const _sgl_matrix_t* m0 = (const _sgl_matrix_t*) &m[0];
  4363. _sgl_mul(_sgl_matrix(ctx), m0);
  4364. }
  4365. SOKOL_API_IMPL void sgl_mult_transpose_matrix(const float m[16]) {
  4366. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4367. _sgl_context_t* ctx = _sgl.cur_ctx;
  4368. if (!ctx) {
  4369. return;
  4370. }
  4371. ctx->matrix_dirty = true;
  4372. _sgl_matrix_t m0;
  4373. _sgl_transpose(&m0, (const _sgl_matrix_t*) &m[0]);
  4374. _sgl_mul(_sgl_matrix(ctx), &m0);
  4375. }
  4376. SOKOL_API_IMPL void sgl_rotate(float angle_rad, float x, float y, float z) {
  4377. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4378. _sgl_context_t* ctx = _sgl.cur_ctx;
  4379. if (!ctx) {
  4380. return;
  4381. }
  4382. ctx->matrix_dirty = true;
  4383. _sgl_rotate(_sgl_matrix(ctx), angle_rad, x, y, z);
  4384. }
  4385. SOKOL_API_IMPL void sgl_scale(float x, float y, float z) {
  4386. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4387. _sgl_context_t* ctx = _sgl.cur_ctx;
  4388. if (!ctx) {
  4389. return;
  4390. }
  4391. ctx->matrix_dirty = true;
  4392. _sgl_scale(_sgl_matrix(ctx), x, y, z);
  4393. }
  4394. SOKOL_API_IMPL void sgl_translate(float x, float y, float z) {
  4395. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4396. _sgl_context_t* ctx = _sgl.cur_ctx;
  4397. if (!ctx) {
  4398. return;
  4399. }
  4400. ctx->matrix_dirty = true;
  4401. _sgl_translate(_sgl_matrix(ctx), x, y, z);
  4402. }
  4403. SOKOL_API_IMPL void sgl_frustum(float l, float r, float b, float t, float n, float f) {
  4404. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4405. _sgl_context_t* ctx = _sgl.cur_ctx;
  4406. if (!ctx) {
  4407. return;
  4408. }
  4409. ctx->matrix_dirty = true;
  4410. _sgl_frustum(_sgl_matrix(ctx), l, r, b, t, n, f);
  4411. }
  4412. SOKOL_API_IMPL void sgl_ortho(float l, float r, float b, float t, float n, float f) {
  4413. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4414. _sgl_context_t* ctx = _sgl.cur_ctx;
  4415. if (!ctx) {
  4416. return;
  4417. }
  4418. ctx->matrix_dirty = true;
  4419. _sgl_ortho(_sgl_matrix(ctx), l, r, b, t, n, f);
  4420. }
  4421. SOKOL_API_IMPL void sgl_perspective(float fov_y, float aspect, float z_near, float z_far) {
  4422. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4423. _sgl_context_t* ctx = _sgl.cur_ctx;
  4424. if (!ctx) {
  4425. return;
  4426. }
  4427. ctx->matrix_dirty = true;
  4428. _sgl_perspective(_sgl_matrix(ctx), fov_y, aspect, z_near, z_far);
  4429. }
  4430. SOKOL_API_IMPL void sgl_lookat(float eye_x, float eye_y, float eye_z, float center_x, float center_y, float center_z, float up_x, float up_y, float up_z) {
  4431. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4432. _sgl_context_t* ctx = _sgl.cur_ctx;
  4433. if (!ctx) {
  4434. return;
  4435. }
  4436. ctx->matrix_dirty = true;
  4437. _sgl_lookat(_sgl_matrix(ctx), eye_x, eye_y, eye_z, center_x, center_y, center_z, up_x, up_y, up_z);
  4438. }
  4439. SOKOL_GL_API_DECL void sgl_push_matrix(void) {
  4440. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4441. _sgl_context_t* ctx = _sgl.cur_ctx;
  4442. if (!ctx) {
  4443. return;
  4444. }
  4445. SOKOL_ASSERT((ctx->cur_matrix_mode >= 0) && (ctx->cur_matrix_mode < SGL_NUM_MATRIXMODES));
  4446. ctx->matrix_dirty = true;
  4447. if (ctx->matrix_tos[ctx->cur_matrix_mode] < (_SGL_MAX_STACK_DEPTH - 1)) {
  4448. const _sgl_matrix_t* src = _sgl_matrix(ctx);
  4449. ctx->matrix_tos[ctx->cur_matrix_mode]++;
  4450. _sgl_matrix_t* dst = _sgl_matrix(ctx);
  4451. *dst = *src;
  4452. } else {
  4453. ctx->error.stack_overflow = true;
  4454. ctx->error.any = true;
  4455. }
  4456. }
  4457. SOKOL_GL_API_DECL void sgl_pop_matrix(void) {
  4458. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4459. _sgl_context_t* ctx = _sgl.cur_ctx;
  4460. if (!ctx) {
  4461. return;
  4462. }
  4463. SOKOL_ASSERT((ctx->cur_matrix_mode >= 0) && (ctx->cur_matrix_mode < SGL_NUM_MATRIXMODES));
  4464. ctx->matrix_dirty = true;
  4465. if (ctx->matrix_tos[ctx->cur_matrix_mode] > 0) {
  4466. ctx->matrix_tos[ctx->cur_matrix_mode]--;
  4467. } else {
  4468. ctx->error.stack_underflow = true;
  4469. ctx->error.any = true;
  4470. }
  4471. }
  4472. SOKOL_API_IMPL void sgl_draw(void) {
  4473. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4474. _sgl_context_t* ctx = _sgl.cur_ctx;
  4475. if (ctx) {
  4476. _sgl_draw(ctx, 0);
  4477. }
  4478. }
  4479. SOKOL_API_IMPL void sgl_draw_layer(int layer_id) {
  4480. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4481. _sgl_context_t* ctx = _sgl.cur_ctx;
  4482. if (ctx) {
  4483. _sgl_draw(ctx, layer_id);
  4484. }
  4485. }
  4486. SOKOL_API_IMPL void sgl_context_draw(sgl_context ctx_id) {
  4487. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4488. _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id);
  4489. if (ctx) {
  4490. _sgl_draw(ctx, 0);
  4491. }
  4492. }
  4493. SOKOL_API_IMPL void sgl_context_draw_layer(sgl_context ctx_id, int layer_id) {
  4494. SOKOL_ASSERT(_SGL_INIT_COOKIE == _sgl.init_cookie);
  4495. _sgl_context_t* ctx = _sgl_lookup_context(ctx_id.id);
  4496. if (ctx) {
  4497. _sgl_draw(ctx, layer_id);
  4498. }
  4499. }
  4500. #endif /* SOKOL_GL_IMPL */